Source for file pdf.php

Documentation is available at pdf.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */ 
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. require_once($mosConfig_absolute_path.'/components/com_content/content.class.php');
  19. global $mosConfig_offset$mosConfig_hideAuthor$mosConfig_hideModifyDate$mosConfig_hideCreateDate$mosConfig_live_site;
  20.  
  21. function dofreePDF $database {
  22.     global $mosConfig_live_site$mosConfig_sitename$mosConfig_offset$mosConfig_hideCreateDate$mosConfig_hideAuthor$mosConfig_hideModifyDate;
  23.  
  24.     $id intvalmosGetParam$_REQUEST'id') );
  25.  
  26.     // Access check
  27.     global $gid;
  28.     $now date'Y-m-d H:i:s'time($mosConfig_offset 60 60 );
  29.     $query "SELECT COUNT(a.id)"
  30.     . "\n FROM #__content AS a"
  31.     . "\n LEFT JOIN #__categories AS cc ON cc.id = a.catid"
  32.     . "\n LEFT JOIN #__sections AS s ON s.id = cc.section AND s.scope='content'"
  33.     . "\n LEFT JOIN #__users AS u ON u.id = a.created_by"
  34.     . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id"
  35.     . "\n LEFT JOIN #__groups AS g ON a.access = g.id"
  36.     . "\n WHERE a.id='"$id ."' "
  37.     . "\n AND (a.state = '1' OR a.state = '-1')"
  38.     . "\n AND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now')"
  39.     . "\n AND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')"
  40.     . "\n AND a.access <= "intval($gid)
  41.     ;
  42.     $database->setQuery$query );
  43.     if (!$database->loadResult() ) {
  44.         exit(T_('You are not authorized to view this resource.'));
  45.     }
  46.  
  47.     include'includes/class.ezpdf.php' );
  48.     $row new mosContent$database );
  49.     $row->load$id );
  50.     //Find Author Name
  51.     $users_rows new mosUser$database );
  52.     $users_rows->load$row->created_by );
  53.     $row->author $users_rows->name;
  54.     $row->usertype $users_rows->usertype;
  55.  
  56.     // Ugly but needed to get rid of all the stuff the PDF class cant handle
  57.     $row->fulltext     str_replace'<p>'"\n\n" $row->fulltext );
  58.     $row->fulltext     str_replace'<P>'"\n\n" $row->fulltext );
  59.     $row->fulltext     str_replace'<br />'"\n" $row->fulltext );
  60.     $row->fulltext     str_replace'<br>'"\n" $row->fulltext );
  61.     $row->fulltext     str_replace'<BR />'"\n" $row->fulltext );
  62.     $row->fulltext     str_replace'<BR>'"\n" $row->fulltext );
  63.     $row->fulltext     str_replace'<li>'"\n - " $row->fulltext );
  64.     $row->fulltext     str_replace'<LI>'"\n - " $row->fulltext );
  65.     $row->fulltext     strip_tags$row->fulltext );
  66.     $row->fulltext     str_replace'{mosimage}'''$row->fulltext );
  67.     $row->fulltext     str_replace'{mospagebreak}'''$row->fulltext );
  68.     $row->fulltext     decodeHTML$row->fulltext );
  69.  
  70.     $row->introtext     str_replace'<p>'"\n\n"$row->introtext );
  71.     $row->introtext     str_replace'<P>'"\n\n"$row->introtext );
  72.     $row->introtext     str_replace'<li>'"\n - " $row->introtext );
  73.     $row->introtext     str_replace'<LI>'"\n - " $row->introtext );
  74.     $row->introtext     strip_tags$row->introtext );
  75.     $row->introtext     str_replace'{mosimage}'''$row->introtext );
  76.     $row->introtext     str_replace'{mospagebreak}'''$row->introtext );
  77.     $row->introtext     decodeHTML$row->introtext );
  78.  
  79.     $pdf =new Cezpdf'a4''P' );  //A4 Portrait
  80.     $pdf -> ezSetCmMargins21.511);
  81.     $pdf->selectFont'./fonts/Helvetica.afm' )//choose font
  82.  
  83.     $all $pdf->openObject();
  84.     $pdf->saveState();
  85.     $pdf->setStrokeColor000);
  86.  
  87.     // footer
  88.     $pdf->line104057840 );
  89.     $pdf->line10822578822 );
  90.     $pdf->addText30346$mosConfig_live_site .' - '$mosConfig_sitename );
  91.     $pdf->addText250346T_('Powered by Mambo') );
  92.     $pdf->addText450346T_('Generated:')date'j F, Y, H:i'time($mosConfig_offset*60*60 ) );
  93.  
  94.     $pdf->restoreState();
  95.     $pdf->closeObject();
  96.     $pdf->addObject$all'all' );
  97.     $pdf->ezSetDy30 );
  98.  
  99.     $txt1 $row->title;
  100.     $pdf->ezText$txt114 );
  101.  
  102.     $txt2 NULL;
  103.     $mod_date NULL
  104.     $create_date NULL;
  105.     if intval$row->modified <> {
  106.         $mod_date mosFormatDate$row->modified );
  107.     }
  108.     if intval$row->created <> {
  109.         $create_date mosFormatDate$row->created );
  110.     }
  111.  
  112.     if $mosConfig_hideCreateDate == '0' {
  113.         $txt2 .= '('$create_date .') - ';
  114.     }
  115.  
  116.     if $mosConfig_hideAuthor == "0" {
  117.         if $row->author != '' && $mosConfig_hideAuthor == '0' {
  118.             if ($row->usertype == 'administrator' || $row->usertype == 'superadministrator'{
  119.                 $txt2 .=  T_('Written by'.' '$row->created_by_alias $row->created_by_alias $row->author );
  120.             else {
  121.                 $txt2 .=  T_('Contributed by'.' '$row->created_by_alias $row->created_by_alias $row->author );
  122.             }
  123.         }
  124.     }
  125.  
  126.     if $mosConfig_hideModifyDate == "0" {
  127.         $txt2 .= ' - 'T_('Last Updated'.' ('$mod_date .') ';
  128.     }
  129.  
  130.     $txt2 .= "\n\n";
  131.     $pdf->ezText$txt2);
  132.     $txt3 $row->introtext ."\n"$row->fulltext;
  133.     $pdf->ezText$txt310 );
  134.     $pdf->ezStream();
  135. }
  136.  
  137. function decodeHTML$string {
  138.     $string strtr$stringarray_flip(get_html_translation_tableHTML_ENTITIES ) ) );
  139.     $string preg_replace"/&#([0-9]+);/me""chr('\\1')"$string );
  140.     return $string;
  141. }
  142.  
  143. function get_php_setting ($val {
  144.     $r ini_get$val == '1' );
  145.     return $r T_('ON'T_('OFF');
  146. }
  147.  
  148. dofreePDF $database );
  149. ?>

Documentation generated on Mon, 05 May 2008 16:22:11 +0400 by phpDocumentor 1.4.0