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

