Annotation of /mambo/branches/4.6/includes/pdf.php
Parent Directory
|
Revision Log
Revision 297 - (view) (download)
| 1 : | root | 1 | <?php |
| 2 : | /** | ||
| 3 : | csouza | 297 | * @package Mambo Open Source |
| 4 : | * @copyright (C) 2005 - 2006 Mambo Foundation Inc. | ||
| 5 : | root | 1 | * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL |
| 6 : | csouza | 297 | * |
| 7 : | * Mambo was originally developed by Miro (www.miro.com.au) in 2000. Miro assigned the copyright in Mambo to The Mambo Foundation in 2005 to ensure | ||
| 8 : | * that Mambo remained free Open Source software owned and managed by the community. | ||
| 9 : | root | 1 | * Mambo is Free Software |
| 10 : | csouza | 297 | */ |
| 11 : | root | 1 | |
| 12 : | /** ensure this file is being included by a parent file */ | ||
| 13 : | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); | ||
| 14 : | |||
| 15 : | mambo | 117 | require_once($mosConfig_absolute_path.'/components/com_content/content.class.php'); |
| 16 : | root | 1 | global $mosConfig_offset, $mosConfig_hideAuthor, $mosConfig_hideModifyDate, $mosConfig_hideCreateDate, $mosConfig_live_site; |
| 17 : | |||
| 18 : | function dofreePDF ( $database ) { | ||
| 19 : | global $mosConfig_live_site, $mosConfig_sitename, $mosConfig_offset, $mosConfig_hideCreateDate, $mosConfig_hideAuthor, $mosConfig_hideModifyDate; | ||
| 20 : | |||
| 21 : | $id = intval( mosGetParam( $_REQUEST, 'id', 1 ) ); | ||
| 22 : | include( 'includes/class.ezpdf.php' ); | ||
| 23 : | $row = new mosContent( $database ); | ||
| 24 : | $row->load( $id ); | ||
| 25 : | //Find Author Name | ||
| 26 : | $users_rows = new mosUser( $database ); | ||
| 27 : | $users_rows->load( $row->created_by ); | ||
| 28 : | $row->author = $users_rows->name; | ||
| 29 : | $row->usertype = $users_rows->usertype; | ||
| 30 : | |||
| 31 : | // Ugly but needed to get rid of all the stuff the PDF class cant handle | ||
| 32 : | $row->fulltext = str_replace( '<p>', "\n\n" , $row->fulltext ); | ||
| 33 : | $row->fulltext = str_replace( '<P>', "\n\n" , $row->fulltext ); | ||
| 34 : | $row->fulltext = str_replace( '<br />', "\n" , $row->fulltext ); | ||
| 35 : | $row->fulltext = str_replace( '<br>', "\n" , $row->fulltext ); | ||
| 36 : | $row->fulltext = str_replace( '<BR />', "\n" , $row->fulltext ); | ||
| 37 : | $row->fulltext = str_replace( '<BR>', "\n" , $row->fulltext ); | ||
| 38 : | $row->fulltext = str_replace( '<li>', "\n - " , $row->fulltext ); | ||
| 39 : | $row->fulltext = str_replace( '<LI>', "\n - " , $row->fulltext ); | ||
| 40 : | $row->fulltext = strip_tags( $row->fulltext ); | ||
| 41 : | $row->fulltext = str_replace( '{mosimage}', '', $row->fulltext ); | ||
| 42 : | $row->fulltext = str_replace( '{mospagebreak}', '', $row->fulltext ); | ||
| 43 : | $row->fulltext = decodeHTML( $row->fulltext ); | ||
| 44 : | |||
| 45 : | $row->introtext = str_replace( '<p>', "\n\n", $row->introtext ); | ||
| 46 : | $row->introtext = str_replace( '<P>', "\n\n", $row->introtext ); | ||
| 47 : | $row->introtext = str_replace( '<li>', "\n - " , $row->introtext ); | ||
| 48 : | $row->introtext = str_replace( '<LI>', "\n - " , $row->introtext ); | ||
| 49 : | $row->introtext = strip_tags( $row->introtext ); | ||
| 50 : | $row->introtext = str_replace( '{mosimage}', '', $row->introtext ); | ||
| 51 : | $row->introtext = str_replace( '{mospagebreak}', '', $row->introtext ); | ||
| 52 : | $row->introtext = decodeHTML( $row->introtext ); | ||
| 53 : | |||
| 54 : | $pdf =& new Cezpdf( 'a4', 'P' ); //A4 Portrait | ||
| 55 : | $pdf -> ezSetCmMargins( 2, 1.5, 1, 1); | ||
| 56 : | $pdf->selectFont( './fonts/Helvetica.afm' ); //choose font | ||
| 57 : | |||
| 58 : | $all = $pdf->openObject(); | ||
| 59 : | $pdf->saveState(); | ||
| 60 : | $pdf->setStrokeColor( 0, 0, 0, 1 ); | ||
| 61 : | |||
| 62 : | // footer | ||
| 63 : | $pdf->line( 10, 40, 578, 40 ); | ||
| 64 : | $pdf->line( 10, 822, 578, 822 ); | ||
| 65 : | $pdf->addText( 30, 34, 6, $mosConfig_live_site .' - '. $mosConfig_sitename ); | ||
| 66 : | csouza | 183 | $pdf->addText( 250, 34, 6, T_('Powered by Mambo') ); |
| 67 : | $pdf->addText( 450, 34, 6, T_('Generated:'). date( 'j F, Y, H:i', time() + $mosConfig_offset*60*60 ) ); | ||
| 68 : | root | 1 | |
| 69 : | $pdf->restoreState(); | ||
| 70 : | $pdf->closeObject(); | ||
| 71 : | $pdf->addObject( $all, 'all' ); | ||
| 72 : | $pdf->ezSetDy( 30 ); | ||
| 73 : | |||
| 74 : | $txt1 = $row->title; | ||
| 75 : | $pdf->ezText( $txt1, 14 ); | ||
| 76 : | |||
| 77 : | $txt2 = NULL; | ||
| 78 : | $mod_date = NULL; | ||
| 79 : | $create_date = NULL; | ||
| 80 : | if ( intval( $row->modified ) <> 0 ) { | ||
| 81 : | $mod_date = mosFormatDate( $row->modified ); | ||
| 82 : | } | ||
| 83 : | if ( intval( $row->created ) <> 0 ) { | ||
| 84 : | $create_date = mosFormatDate( $row->created ); | ||
| 85 : | } | ||
| 86 : | |||
| 87 : | if ( $mosConfig_hideCreateDate == '0' ) { | ||
| 88 : | $txt2 .= '('. $create_date .') - '; | ||
| 89 : | } | ||
| 90 : | |||
| 91 : | if ( $mosConfig_hideAuthor == "0" ) { | ||
| 92 : | if ( $row->author != '' && $mosConfig_hideAuthor == '0' ) { | ||
| 93 : | if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator') { | ||
| 94 : | csouza | 183 | $txt2 .= T_('Written by') .' '. ( $row->created_by_alias ? $row->created_by_alias : $row->author ); |
| 95 : | root | 1 | } else { |
| 96 : | csouza | 183 | $txt2 .= T_('Contributed by') .' '. ( $row->created_by_alias ? $row->created_by_alias : $row->author ); |
| 97 : | root | 1 | } |
| 98 : | } | ||
| 99 : | } | ||
| 100 : | |||
| 101 : | if ( $mosConfig_hideModifyDate == "0" ) { | ||
| 102 : | csouza | 183 | $txt2 .= ' - '. T_('Last Updated') .' ('. $mod_date .') '; |
| 103 : | root | 1 | } |
| 104 : | |||
| 105 : | $txt2 .= "\n\n"; | ||
| 106 : | $pdf->ezText( $txt2, 8 ); | ||
| 107 : | $txt3 = $row->introtext ."\n". $row->fulltext; | ||
| 108 : | $pdf->ezText( $txt3, 10 ); | ||
| 109 : | $pdf->ezStream(); | ||
| 110 : | } | ||
| 111 : | |||
| 112 : | function decodeHTML( $string ) { | ||
| 113 : | $string = strtr( $string, array_flip(get_html_translation_table( HTML_ENTITIES ) ) ); | ||
| 114 : | $string = preg_replace( "/&#([0-9]+);/me", "chr('\\1')", $string ); | ||
| 115 : | return $string; | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | function get_php_setting ($val ) { | ||
| 119 : | $r = ( ini_get( $val ) == '1' ? 1 : 0 ); | ||
| 120 : | csouza | 183 | return $r ? T_('ON') : T_('OFF'); |
| 121 : | root | 1 | } |
| 122 : | |||
| 123 : | dofreePDF ( $database ); | ||
| 124 : | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

