[ Index ] |
PHP Cross Reference of phpwcms V1.4.7 _r403 (01.11.10) |
[Summary view] [Print] [Text view]
1 <?php 2 /************************************************************************************* 3 Copyright notice 4 5 (c) 2002-2010 Oliver Georgi (oliver@phpwcms.de) // All rights reserved. 6 7 This script is part of PHPWCMS. The PHPWCMS web content management system is 8 free software; you can redistribute it and/or modify it under the terms of 9 the GNU General Public License as published by the Free Software Foundation; 10 either version 2 of the License, or (at your option) any later version. 11 12 The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html 13 A copy is found in the textfile GPL.txt and important notices to the license 14 from the author is found in LICENSE.txt distributed with these scripts. 15 16 This script is distributed in the hope that it will be useful, but WITHOUT ANY 17 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 18 PARTICULAR PURPOSE. See the GNU General Public License for more details. 19 20 This copyright notice MUST APPEAR in all copies of the script! 21 22 ********************************************************************************** 23 24 phpwcms2pdf - Print as PDF 25 =========== 26 marcus@localhorst, 23-Apr-2007 27 28 29 CREDITS: 30 # This use the html2fpdf Library 31 http://html2fpdf.sourceforge.net/ 32 http://html2fpdf.sourceforge.net/classdoc.php 33 fpdf Doc (html2fpdf is build on a changed fpdf class!) 34 http://www.fpdf.org/en/doc/ 35 36 # Based on this thread: http://www.phpwcms.de/forum/viewtopic.php?t=13594#79835 37 which is based on the "nice formatted printing page" hack 38 http://www.phpwcms.de/forum/viewtopic.php?t=3759 39 I just add the template feature and some finetunings for my needs. 40 41 *************************************************************************************/ 42 43 // ---------------------------------------------------------------- 44 // obligate check for phpwcms constants 45 if (!defined('PHPWCMS_ROOT')) { 46 die("You Cannot Access This Script Directly, Have a Nice Day."); 47 } 48 // ---------------------------------------------------------------- 49 50 //@ini_set('display_errors','0'); 51 //error_reporting(0); 52 53 unset($_GET); 54 unset($_POST); 55 56 // include html2fpdf.php 57 define( 'RELATIVE_PATH', PHPWCMS_ROOT.'/include/inc_ext/html2fpdf/' ); 58 define( 'FPDF_FONTPATH', RELATIVE_PATH.'font/' ); 59 60 require_once (PHPWCMS_ROOT.'/include/inc_ext/html2fpdf/html2fpdf.php' ); 61 62 63 $_print_settings['PDF_font_size'] = empty($_print_settings['PDF_font_size']) ? 5 : intval($_print_settings['PDF_font_size']); 64 $_print_settings['PDF_file_prefix'] = empty($_print_settings['PDF_file_prefix']) ? '' : trim($_print_settings['PDF_file_prefix']); 65 $_print_settings['PDF_disable_tags'] = empty($_print_settings['PDF_disable_tags']) ? 'div,input,form,object,embed,script' : trim($_print_settings['PDF_disable_tags']); 66 67 $_print_settings['PDF_title'] = decode_entities(makeCharsetConversion($content["pagetitle"], PHPWCMS_CHARSET, 'iso-8859-1', 0)); 68 $_print_settings['PDF_keywords'] = is_array($content['all_keywords']) ? decode_entities(makeCharsetConversion(implode(', ', $content['all_keywords']), PHPWCMS_CHARSET, 'iso-8859-1', 0)) : ''; 69 $_print_settings['PDF_filename'] = str_replace($pagelayout['layout_title_spacer'], '-', $_print_settings['PDF_title']); 70 $_print_settings['PDF_filename'] = trim(preg_replace('/[^0-9a-zA-Z_\.\-,\s]/', '', $_print_settings['PDF_filename'])); 71 $_print_settings['PDF_filename'] = $_print_settings['PDF_file_prefix'].substr($_print_settings['PDF_filename'], 0, 150).'.pdf'; 72 $_print_settings['PDF_filename'] = str_replace('|', '-', $_print_settings['PDF_filename']); 73 $_print_settings['PDF_filename'] = str_replace('--', '-', $_print_settings['PDF_filename']); 74 75 $_PDF = new HTML2FPDF(); 76 $_PDF->AddPage(); 77 $_PDF->DisableTags( $_print_settings['PDF_disable_tags'] ); 78 $_PDF->SetTitle( $_print_settings['PDF_title'] ); 79 $_PDF->SetSubject( '' ); 80 $_PDF->SetKeywords( $_print_settings['PDF_keywords'] ); 81 $_PDF->SetAuthor( '' ); 82 83 unset($content); 84 85 $_PDF_page = ob_get_contents(); 86 ob_end_clean(); 87 88 $SPECIAL_ENTITIES_TABLES['symbol_decode'] = array( 89 'ƒ', 90 '?', 91 '?', 92 'G', 93 '?', 94 '?', 95 '?', 96 '?', 97 'T', 98 '?', 99 '?', 100 '?', 101 '?', 102 '?', 103 '?', 104 '?', 105 '?', 106 '?', 107 'S', 108 '?', 109 '?', 110 'F', 111 '?', 112 '?', 113 'O', 114 'a', 115 'ß', 116 '?', 117 'd', 118 'e', 119 '?', 120 '?', 121 '?', 122 '?', 123 '?', 124 '?', 125 'µ', 126 '?', 127 '?', 128 '?', 129 'p', 130 '?', 131 '?', 132 's', 133 't', 134 '?', 135 'f', 136 '?', 137 '?', 138 '?', 139 '?', 140 '?', 141 '?', 142 '•', 143 '…', 144 '\'', 145 '?', 146 '?', 147 '/', 148 'P', 149 'I', 150 'R', 151 '™', 152 '?', 153 '?', 154 '?', 155 '?', 156 '?', 157 '?', 158 '?', 159 '?', 160 '?', 161 '?', 162 '?', 163 '?', 164 '?', 165 '?', 166 '?', 167 'Ø', 168 '?', 169 '?', 170 '?', 171 '?', 172 '?', 173 '?', 174 '-', 175 '*', 176 'v', 177 '?', 178 '8', 179 '?', 180 '?', 181 '?', 182 'n', 183 '?', 184 '?', 185 '?', 186 '~', 187 '?', 188 '˜', 189 '?', 190 '=', 191 '=', 192 '=', 193 '?', 194 '?', 195 '?', 196 '?', 197 '?', 198 '?', 199 '?', 200 '?', 201 '·', 202 '?', 203 '?', 204 '?', 205 '?', 206 '<', 207 '>', 208 '?', 209 '?', 210 '?', 211 '?', 212 '?' 213 ); 214 215 $SPECIAL_ENTITIES_TABLES['specialchars_decode'] = array( 216 '"', 217 '&', 218 '<', 219 '>', 220 'Œ', 221 'œ', 222 'Š', 223 'š', 224 'Ÿ', 225 'ˆ', 226 '˜', 227 ' ', 228 ' ', 229 '?', 230 '?', 231 '?', 232 '?', 233 '?', 234 '–', 235 '—', 236 '‘', 237 '’', 238 '‚', 239 '“', 240 '”', 241 '„', 242 '†', 243 '‡', 244 '‰', 245 '‹', 246 '›', 247 '€' 248 ); 249 250 251 $_PDF_page = str_replace($SPECIAL_ENTITIES_TABLES['latin1_encode'], $SPECIAL_ENTITIES_TABLES['latin1_decode'], $_PDF_page); 252 $_PDF_page = str_replace($SPECIAL_ENTITIES_TABLES['symbol_encode'], $SPECIAL_ENTITIES_TABLES['symbol_decode'], $_PDF_page); 253 $_PDF_page = str_replace($SPECIAL_ENTITIES_TABLES['specialchars_encode'], $SPECIAL_ENTITIES_TABLES['specialchars_decode'], $_PDF_page); 254 $_PDF_page = trim(makeCharsetConversion($_PDF_page, PHPWCMS_CHARSET, 'iso-8859-15', 0)); 255 256 257 $include_urlparts = parse_url(PHPWCMS_URL); 258 $_PDF_page = preg_replace_callback('/(href|src|action)=[\'|"]{0,1}(.*?)[\'|"]{0,1}( .*?){0,1}>/i', 'make_absoluteURL', $_PDF_page); 259 260 $include_urlparts['falsepart'] = $include_urlparts['host'].'/'.trim($phpwcms["root"].$phpwcms["root"], ' /').'/'; 261 $include_urlparts['corrected'] = $include_urlparts['host'].'/'.trim($phpwcms["root"], ' /').'/'; 262 263 $_PDF_page = str_replace($include_urlparts['falsepart'], $include_urlparts['corrected'], $_PDF_page); 264 265 //$_PDF->ReadMetaTags( $_PDF_page ); 266 $_PDF->ReadCSS( $_PDF_page ); 267 $_PDF->SetFontSize( $_print_settings['PDF_font_size'] ); 268 $_PDF->WriteHTML( $_PDF_page ); 269 270 // Output -> use file save and redirect 271 $_PDF->Output( PHPWCMS_CONTENT.'tmp/'.$_print_settings['PDF_filename'], 'F'); 272 headerRedirect(PHPWCMS_URL . CONTENT_PATH . 'tmp/'.$_print_settings['PDF_filename']); 273 274 exit(); 275 276 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Nov 16 22:51:00 2010 | Cross-referenced by PHPXref 0.7 |