C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\rodam\includes\pdf.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<?php
/**
* @version $Id: pdf.php 784 2005-11-01 12:23:42Z stingrey $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
* Created by Phil Taylor me@phil-taylor.com
* Support file to display PDF Text Only using class from - http://www.ros.co.nz/pdf/readme.pdf
* HTMLDoc is available from: http://www.easysw.com/htmldoc and needs installing on the server for better HTML to PDF conversion
**/

// no direct access
defined'_VALID_MOS' ) or die( 'Restricted access' );

function 
dofreePDF $database ) {
    global 
$mosConfig_live_site$mosConfig_sitename$mosConfig_offset;
    global 
$mainframe;
    
    include( 
'includes/class.ezpdf.php' );

    
$id intvalmosGetParam$_REQUEST'id') );
    
$row = new mosContent$database );
    
$row->load$id );

    
$params = new mosParameters$row->attribs );    
    
$params->def'author',     !$mainframe->getCfg'hideAuthor' ) );
    
$params->def'createdate', !$mainframe->getCfg'hideCreateDate' ) );
    
$params->def'modifydate', !$mainframe->getCfg'hideModifyDate' ) );
    
    
$row->fulltext     pdfCleaner$row->fulltext );
    
$row->introtext pdfCleaner$row->introtext );

    
$pdf = new Cezpdf'a4''P' );  //A4 Portrait
    
$pdf -> ezSetCmMargins21.511);
    
$pdf->selectFont'./fonts/Helvetica.afm' ); //choose font

    
$all $pdf->openObject();
    
$pdf->saveState();
    
$pdf->setStrokeColor000);

    
// footer
    
$pdf->addText2508226$mosConfig_sitename );
    
$pdf->line104057840 );
    
$pdf->line10818578818 );
    
$pdf->addText30346$mosConfig_live_site );
    
$pdf->addText250346_PDF_POWERED );
    
$pdf->addText450346_PDF_GENERATED .' 'date'j F, Y, H:i'time() + $mosConfig_offset 60 60 ) );

    
$pdf->restoreState();
    
$pdf->closeObject();
    
$pdf->addObject$all'all' );
    
$pdf->ezSetDy30 );

    
$txt1 $row->title;
    
$pdf->ezText$txt114 );

    
$txt2 AuthorDateLine$row$params );

    
$pdf->ezText$txt2);
    
    
$txt3 $row->introtext ."\n"$row->fulltext;
    
$pdf->ezText$txt310 );
    
    
$pdf->ezStream();
}

function 
decodeHTML$string ) {
    
$string strtr$stringarray_flip(get_html_translation_tableHTML_ENTITIES ) ) );
    
$string preg_replace"/&#([0-9]+);/me""chr('\\1')"$string );
    
    return 
$string;
}

function 
get_php_setting ($val ) {
    
$r = ( ini_get$val ) == '1' );
    
    return 
$r 'ON' 'OFF';
}

function 
pdfCleaner$text ) {    
    
// Ugly but needed to get rid of all the stuff the PDF class cant handle
    
    
$text str_replace'<p>',             "\n\n",     $text );
    
$text str_replace'<P>',             "\n\n",     $text );
    
$text str_replace'<br />',             "\n",         $text );
    
$text str_replace'<br>',             "\n",         $text );
    
$text str_replace'<BR />',             "\n",         $text );
    
$text str_replace'<BR>',             "\n",         $text );
    
$text str_replace'<li>',             "\n - ",     $text );
    
$text str_replace'<LI>',             "\n - ",     $text );
    
$text str_replace'{mosimage}',         '',         $text );
    
$text str_replace'{mospagebreak}',     '',            $text );
    
    
$text strip_tags$text );
    
$text decodeHTML$text );

    return 
$text;
}

function 
AuthorDateLine( &$row, &$params ) {
    global 
$database;
    
    
$text '';
    
    if ( 
$params->get'author' ) ) {
        
// Display Author name
        
        //Find Author Name
        
$users_rows = new mosUser$database );
        
$users_rows->load$row->created_by );
        
$row->author     $users_rows->name;
        
$row->usertype     $users_rows->usertype;        
        
        if (
$row->usertype == 'administrator' || $row->usertype == 'superadministrator') {
            
$text .= "\n";
            
$text .=  _WRITTEN_BY .' '. ( $row->created_by_alias $row->created_by_alias $row->author );
        } else {
            
$text .= "\n";
            
$text .=  _AUTHOR_BY .' '. ( $row->created_by_alias $row->created_by_alias $row->author );
        }
    }
    
    if ( 
$params->get'createdate' ) && $params->get'author' ) ) {
        
// Display Separator
        
$text .= "\n";
    }
    
    if ( 
$params->get'createdate' ) ) {
        
// Display Created Date
        
if ( intval$row->created ) ) {
            
$create_date     mosFormatDate$row->created );
            
$text             .= $create_date;
        }                
    }    
    
    if ( 
$params->get'modifydate' ) && ( $params->get'author' ) || $params->get'createdate' ) ) ) {
        
// Display Separator
        
$text .= "\n";
    }
    
    if ( 
$params->get'modifydate' ) ) {
        
// Display Modified Date
        
if ( intval$row->modified ) ) {
            
$mod_date     mosFormatDate$row->modified );
            
$text         .= _LAST_UPDATED .' '$mod_date;
            
        }
    }    
    
    
$text .= "\n\n";

    return 
$text;
}

dofreePDF $database );
?>