@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * The location of the DOMPDF include directory |
63 | 63 | */ |
64 | -define("DOMPDF_INC_DIR", DOMPDF_DIR . "/include"); |
|
64 | +define("DOMPDF_INC_DIR", DOMPDF_DIR."/include"); |
|
65 | 65 | |
66 | 66 | /** |
67 | 67 | * The location of the DOMPDF lib directory |
68 | 68 | */ |
69 | -define("DOMPDF_LIB_DIR", DOMPDF_DIR . "/lib"); |
|
69 | +define("DOMPDF_LIB_DIR", DOMPDF_DIR."/lib"); |
|
70 | 70 | |
71 | 71 | //FIXME: Some function definitions rely on the constants defined by DOMPDF. However, might this location prove problematic? |
72 | -require_once(DOMPDF_INC_DIR . "/functions.inc.php"); |
|
72 | +require_once(DOMPDF_INC_DIR."/functions.inc.php"); |
|
73 | 73 | |
74 | 74 | /** |
75 | 75 | * The location of the DOMPDF font directory |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | * |
100 | 100 | * *Please note the trailing slash.* |
101 | 101 | */ |
102 | -define("DOMPDF_FONT_DIR", DOMPDF_DIR . "/lib/fonts/"); |
|
102 | +define("DOMPDF_FONT_DIR", DOMPDF_DIR."/lib/fonts/"); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * The location of the DOMPDF font cache directory |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @link http://ttf2pt1.sourceforge.net/ |
173 | 173 | */ |
174 | 174 | if (!defined("TTF2AFM")) { |
175 | - define("TTF2AFM", DOMPDF_LIB_DIR ."/ttf2ufm/ttf2ufm-src/ttf2pt1"); |
|
175 | + define("TTF2AFM", DOMPDF_LIB_DIR."/ttf2ufm/ttf2ufm-src/ttf2pt1"); |
|
176 | 176 | //define("TTF2AFM", "/usr/bin/ttf2pt1"); |
177 | 177 | } |
178 | 178 | |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | * @param string $class |
345 | 345 | */ |
346 | 346 | function DOMPDF_autoload($class) { |
347 | - $filename = DOMPDF_INC_DIR . "/" . mb_strtolower($class) . ".cls.php"; |
|
347 | + $filename = DOMPDF_INC_DIR."/".mb_strtolower($class).".cls.php"; |
|
348 | 348 | |
349 | - if ( is_file($filename) ) |
|
349 | + if (is_file($filename)) |
|
350 | 350 | require_once($filename); |
351 | 351 | } |
352 | 352 | |
353 | -if ( function_exists("spl_autoload_register") ) { |
|
353 | +if (function_exists("spl_autoload_register")) { |
|
354 | 354 | |
355 | 355 | spl_autoload_register("DOMPDF_autoload"); |
356 | 356 | |
357 | -} else if ( !function_exists("__autoload") ) { |
|
357 | +} else if (!function_exists("__autoload")) { |
|
358 | 358 | /** |
359 | 359 | * Default __autoload() function |
360 | 360 | * |
@@ -416,11 +416,11 @@ discard block |
||
416 | 416 | * the browser cache and the premature output prevents setting of the mime type. |
417 | 417 | */ |
418 | 418 | if (!defined('DEBUGPNG')) { |
419 | - define('DEBUGPNG',0); |
|
419 | + define('DEBUGPNG', 0); |
|
420 | 420 | } |
421 | 421 | if (!defined('DEBUGKEEPTEMP')) { |
422 | - define('DEBUGKEEPTEMP',0); |
|
422 | + define('DEBUGKEEPTEMP', 0); |
|
423 | 423 | } |
424 | 424 | if (!defined('DEBUGCSS')) { |
425 | - define('DEBUGCSS',0); |
|
425 | + define('DEBUGCSS', 0); |
|
426 | 426 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | " -h\t\tShow this message\n". |
79 | 79 | " -l\t\tlist available paper sizes\n". |
80 | 80 | " -p size\tpaper size; something like 'letter', 'A4', 'legal', etc. The default is\n". |
81 | - " \t\t'" . DOMPDF_DEFAULT_PAPER_SIZE . "'\n". |
|
81 | + " \t\t'".DOMPDF_DEFAULT_PAPER_SIZE."'\n". |
|
82 | 82 | " -o orientation\teither 'portrait' or 'landscape'. Default is 'portrait'.\n". |
83 | 83 | " -b path\tset the 'document root' of the html_file. Relative urls (for \n". |
84 | 84 | " \tstylesheets) are resolved using this directory. Default is the \n". |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | $opts = array(); |
98 | 98 | |
99 | - if ( $_SERVER["argc"] == 1 ) |
|
99 | + if ($_SERVER["argc"] == 1) |
|
100 | 100 | return $opts; |
101 | 101 | |
102 | 102 | $i = 1; |
@@ -116,30 +116,30 @@ discard block |
||
116 | 116 | break; |
117 | 117 | |
118 | 118 | case "-p": |
119 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
119 | + if (!isset($_SERVER["argv"][$i + 1])) |
|
120 | 120 | die("-p switch requires a size parameter\n"); |
121 | - $opts["p"] = $_SERVER["argv"][$i+1]; |
|
121 | + $opts["p"] = $_SERVER["argv"][$i + 1]; |
|
122 | 122 | $i += 2; |
123 | 123 | break; |
124 | 124 | |
125 | 125 | case "-o": |
126 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
126 | + if (!isset($_SERVER["argv"][$i + 1])) |
|
127 | 127 | die("-o switch requires an orientation parameter\n"); |
128 | - $opts["o"] = $_SERVER["argv"][$i+1]; |
|
128 | + $opts["o"] = $_SERVER["argv"][$i + 1]; |
|
129 | 129 | $i += 2; |
130 | 130 | break; |
131 | 131 | |
132 | 132 | case "-b": |
133 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
133 | + if (!isset($_SERVER["argv"][$i + 1])) |
|
134 | 134 | die("-b switch requires a path parameter\n"); |
135 | - $opts["b"] = $_SERVER["argv"][$i+1]; |
|
135 | + $opts["b"] = $_SERVER["argv"][$i + 1]; |
|
136 | 136 | $i += 2; |
137 | 137 | break; |
138 | 138 | |
139 | 139 | case "-f": |
140 | - if ( !isset($_SERVER["argv"][$i+1]) ) |
|
140 | + if (!isset($_SERVER["argv"][$i + 1])) |
|
141 | 141 | die("-f switch requires a filename parameter\n"); |
142 | - $opts["f"] = $_SERVER["argv"][$i+1]; |
|
142 | + $opts["f"] = $_SERVER["argv"][$i + 1]; |
|
143 | 143 | $i += 2; |
144 | 144 | break; |
145 | 145 | |
@@ -154,9 +154,9 @@ discard block |
||
154 | 154 | break; |
155 | 155 | |
156 | 156 | case "-t": |
157 | - if ( !isset($_SERVER['argv'][$i + 1]) ) |
|
157 | + if (!isset($_SERVER['argv'][$i + 1])) |
|
158 | 158 | die("-t switch requires a comma separated list of types\n"); |
159 | - $opts["t"] = $_SERVER['argv'][$i+1]; |
|
159 | + $opts["t"] = $_SERVER['argv'][$i + 1]; |
|
160 | 160 | $i += 2; |
161 | 161 | break; |
162 | 162 | |
@@ -177,61 +177,61 @@ discard block |
||
177 | 177 | |
178 | 178 | $sapi = php_sapi_name(); |
179 | 179 | |
180 | -switch ( $sapi ) { |
|
180 | +switch ($sapi) { |
|
181 | 181 | |
182 | 182 | case "cli": |
183 | 183 | |
184 | 184 | $opts = getoptions(); |
185 | 185 | |
186 | - if ( isset($opts["h"]) || (!isset($opts["filename"]) && !isset($opts["l"])) ) { |
|
186 | + if (isset($opts["h"]) || (!isset($opts["filename"]) && !isset($opts["l"]))) { |
|
187 | 187 | dompdf_usage(); |
188 | 188 | exit; |
189 | 189 | } |
190 | 190 | |
191 | - if ( isset($opts["l"]) ) { |
|
191 | + if (isset($opts["l"])) { |
|
192 | 192 | echo "\nUnderstood paper sizes:\n"; |
193 | 193 | |
194 | 194 | foreach (array_keys(CPDF_Adapter::$PAPER_SIZES) as $size) |
195 | - echo " " . mb_strtoupper($size) . "\n"; |
|
195 | + echo " ".mb_strtoupper($size)."\n"; |
|
196 | 196 | exit; |
197 | 197 | } |
198 | 198 | $file = $opts["filename"]; |
199 | 199 | |
200 | - if ( isset($opts["p"]) ) |
|
200 | + if (isset($opts["p"])) |
|
201 | 201 | $paper = $opts["p"]; |
202 | 202 | else |
203 | 203 | $paper = DOMPDF_DEFAULT_PAPER_SIZE; |
204 | 204 | |
205 | - if ( isset($opts["o"]) ) |
|
205 | + if (isset($opts["o"])) |
|
206 | 206 | $orientation = $opts["o"]; |
207 | 207 | else |
208 | 208 | $orientation = "portrait"; |
209 | 209 | |
210 | - if ( isset($opts["b"]) ) |
|
210 | + if (isset($opts["b"])) |
|
211 | 211 | $base_path = $opts["b"]; |
212 | 212 | |
213 | - if ( isset($opts["f"]) ) |
|
213 | + if (isset($opts["f"])) |
|
214 | 214 | $outfile = $opts["f"]; |
215 | 215 | else { |
216 | - if ( $file === "-" ) |
|
216 | + if ($file === "-") |
|
217 | 217 | $outfile = "dompdf_out.pdf"; |
218 | 218 | else |
219 | - $outfile = str_ireplace(array(".html", ".htm", ".php"), "", $file) . ".pdf"; |
|
219 | + $outfile = str_ireplace(array(".html", ".htm", ".php"), "", $file).".pdf"; |
|
220 | 220 | } |
221 | 221 | |
222 | - if ( isset($opts["v"]) ) |
|
222 | + if (isset($opts["v"])) |
|
223 | 223 | $_dompdf_show_warnings = true; |
224 | 224 | |
225 | - if ( isset($opts["d"]) ) { |
|
225 | + if (isset($opts["d"])) { |
|
226 | 226 | $_dompdf_show_warnings = true; |
227 | 227 | $_dompdf_debug = true; |
228 | 228 | } |
229 | 229 | |
230 | - if ( isset($opts['t']) ) { |
|
231 | - $arr = split(',',$opts['t']); |
|
230 | + if (isset($opts['t'])) { |
|
231 | + $arr = split(',', $opts['t']); |
|
232 | 232 | $types = array(); |
233 | 233 | foreach ($arr as $type) |
234 | - $types[ trim($type) ] = 1; |
|
234 | + $types[trim($type)] = 1; |
|
235 | 235 | $_DOMPDF_DEBUG_TYPES = $types; |
236 | 236 | } |
237 | 237 | |
@@ -241,31 +241,31 @@ discard block |
||
241 | 241 | |
242 | 242 | default: |
243 | 243 | |
244 | - if ( isset($_GET["input_file"]) ) |
|
244 | + if (isset($_GET["input_file"])) |
|
245 | 245 | $file = basename(rawurldecode($_GET["input_file"])); |
246 | 246 | else |
247 | 247 | throw new DOMPDF_Exception("An input file is required (i.e. input_file _GET variable)."); |
248 | 248 | |
249 | - if ( isset($_GET["paper"]) ) |
|
249 | + if (isset($_GET["paper"])) |
|
250 | 250 | $paper = rawurldecode($_GET["paper"]); |
251 | 251 | else |
252 | 252 | $paper = DOMPDF_DEFAULT_PAPER_SIZE; |
253 | 253 | |
254 | - if ( isset($_GET["orientation"]) ) |
|
254 | + if (isset($_GET["orientation"])) |
|
255 | 255 | $orientation = rawurldecode($_GET["orientation"]); |
256 | 256 | else |
257 | 257 | $orientation = "portrait"; |
258 | 258 | |
259 | - if ( isset($_GET["base_path"]) ) |
|
259 | + if (isset($_GET["base_path"])) |
|
260 | 260 | $base_path = rawurldecode($_GET["base_path"]); |
261 | 261 | |
262 | 262 | |
263 | 263 | $outfile = "dompdf_out.pdf"; # Don't allow them to set the output file |
264 | 264 | $save_file = false; # Don't save the file |
265 | - $file = $base_path . $file; # Set the input file |
|
265 | + $file = $base_path.$file; # Set the input file |
|
266 | 266 | |
267 | 267 | /* Check to see if the input file and base path = www/test */ |
268 | - if($base_path !== "www/test/") |
|
268 | + if ($base_path !== "www/test/") |
|
269 | 269 | throw new DOMPDF_Exception("Access to dompdf.php via non-cli SAPI has been deprecated due to security concerns. Please use the dompdf class directly."); |
270 | 270 | |
271 | 271 | break; |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | |
274 | 274 | $dompdf = new DOMPDF(); |
275 | 275 | |
276 | -if ( $file === "-" ) { |
|
276 | +if ($file === "-") { |
|
277 | 277 | $str = ""; |
278 | - while ( !feof(STDIN) ) |
|
278 | + while (!feof(STDIN)) |
|
279 | 279 | $str .= fread(STDIN, 4096); |
280 | 280 | |
281 | 281 | $dompdf->load_html($str); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | } else |
284 | 284 | $dompdf->load_html_file($file); |
285 | 285 | |
286 | -if ( isset($base_path) ) { |
|
286 | +if (isset($base_path)) { |
|
287 | 287 | $dompdf->set_base_path($base_path); |
288 | 288 | } |
289 | 289 | |
@@ -291,33 +291,33 @@ discard block |
||
291 | 291 | |
292 | 292 | $dompdf->render(); |
293 | 293 | |
294 | -if ( $_dompdf_show_warnings ) { |
|
294 | +if ($_dompdf_show_warnings) { |
|
295 | 295 | global $_dompdf_warnings; |
296 | 296 | foreach ($_dompdf_warnings as $msg) |
297 | - echo $msg . "\n"; |
|
297 | + echo $msg."\n"; |
|
298 | 298 | echo $dompdf->get_canvas()->get_cpdf()->messages; |
299 | 299 | flush(); |
300 | 300 | } |
301 | 301 | |
302 | -if ( $save_file ) { |
|
302 | +if ($save_file) { |
|
303 | 303 | // if ( !is_writable($outfile) ) |
304 | 304 | // throw new DOMPDF_Exception("'$outfile' is not writable."); |
305 | - if ( strtolower(DOMPDF_PDF_BACKEND) === "gd" ) |
|
305 | + if (strtolower(DOMPDF_PDF_BACKEND) === "gd") |
|
306 | 306 | $outfile = str_replace(".pdf", ".png", $outfile); |
307 | 307 | |
308 | 308 | list($proto, $host, $path, $file) = explode_url($outfile); |
309 | - if ( $proto != "" ) // i.e. not file:// |
|
309 | + if ($proto != "") // i.e. not file:// |
|
310 | 310 | $outfile = $file; // just save it locally, FIXME? could save it like wget: ./host/basepath/file |
311 | 311 | |
312 | - $outfile = realpath(dirname($outfile)) . DIRECTORY_SEPARATOR . basename($outfile); |
|
312 | + $outfile = realpath(dirname($outfile)).DIRECTORY_SEPARATOR.basename($outfile); |
|
313 | 313 | |
314 | - if ( strpos($outfile, DOMPDF_CHROOT) !== 0 ) |
|
314 | + if (strpos($outfile, DOMPDF_CHROOT) !== 0) |
|
315 | 315 | throw new DOMPDF_Exception("Permission denied."); |
316 | 316 | |
317 | - file_put_contents($outfile, $dompdf->output( array("compress" => 0) )); |
|
317 | + file_put_contents($outfile, $dompdf->output(array("compress" => 0))); |
|
318 | 318 | exit(0); |
319 | 319 | } |
320 | 320 | |
321 | -if ( !headers_sent() ) { |
|
321 | +if (!headers_sent()) { |
|
322 | 322 | $dompdf->stream($outfile); |
323 | 323 | } |
@@ -1,9 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | exit; |
3 | 3 | require_once("../dompdf_config.inc.php"); |
4 | -if ( isset( $_POST["html"] ) ) { |
|
4 | +if (isset($_POST["html"])) { |
|
5 | 5 | |
6 | - if ( get_magic_quotes_gpc() ) |
|
6 | + if (get_magic_quotes_gpc()) |
|
7 | 7 | $_POST["html"] = stripslashes($_POST["html"]); |
8 | 8 | |
9 | 9 | $dompdf = new DOMPDF(); |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | //echo '<li>['.$_SERVER["PHP_SELF"].']</li>'; |
42 | 42 | $dompdf = dirname(dirname($_SERVER["PHP_SELF"])); |
43 | 43 | //echo '<li>['.$dompdf.']</li>'; |
44 | -if ( $dompdf == '/' || $dompdf == '\\') { |
|
44 | +if ($dompdf == '/' || $dompdf == '\\') { |
|
45 | 45 | $dompdf = ''; |
46 | 46 | } |
47 | 47 | //echo '<li>['.$dompdf.']</li>'; |
48 | -$dompdf .= "/dompdf.php?base_path=" . rawurlencode("www/test/"); |
|
48 | +$dompdf .= "/dompdf.php?base_path=".rawurlencode("www/test/"); |
|
49 | 49 | //echo '<li>['.$dompdf.']</li>'; |
50 | -foreach ( $test_files as $file ) { |
|
50 | +foreach ($test_files as $file) { |
|
51 | 51 | $file = basename($file); |
52 | - $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; |
|
52 | + $arrow = "images/arrow_0".rand(1, 6).".gif"; |
|
53 | 53 | echo "<li style=\"list-style-image: url('$arrow');\">\n"; |
54 | 54 | echo $file; |
55 | - echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("$file") . "\">PDF</a>]\n"; |
|
55 | + echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=".rawurlencode("$file")."\">PDF</a>]\n"; |
|
56 | 56 | echo "</li>\n"; |
57 | 57 | } |
58 | 58 | ?> |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | <p>Enter your html snippet in the text box below to see it rendered as a |
64 | 64 | PDF: (Note by default, remote stylesheets, images & are disabled.)</p> |
65 | 65 | |
66 | -<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> |
|
66 | +<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"> |
|
67 | 67 | <div> |
68 | 68 | <p>Paper size and orientaion: |
69 | 69 | <select name="paper"> |
70 | 70 | <?php |
71 | -foreach ( array_keys(CPDF_Adapter::$PAPER_SIZES) as $size ) |
|
72 | - echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n"; |
|
71 | +foreach (array_keys(CPDF_Adapter::$PAPER_SIZES) as $size) |
|
72 | + echo "<option ".($size == "letter" ? "selected " : "")."value=\"$size\">$size</option>\n"; |
|
73 | 73 | ?> |
74 | 74 | </select> |
75 | 75 | <select name="orientation"> |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | function li_arrow() { |
3 | - return '<li style="list-style-image: url(\'images/arrow_0' . rand(1,6) . '.gif\');">'; |
|
3 | + return '<li style="list-style-image: url(\'images/arrow_0'.rand(1, 6).'.gif\');">'; |
|
4 | 4 | } |
5 | 5 | function li_star() { |
6 | - return '<li style="list-style-image: url(\'images/star_0' . rand(1,5) . '.gif\');">'; |
|
6 | + return '<li style="list-style-image: url(\'images/star_0'.rand(1, 5).'.gif\');">'; |
|
7 | 7 | } |
8 | 8 | ?> |
9 | -<?php echo '<?' . 'xml version="1.0" encoding="iso-8859-1"?' . '>'; ?> |
|
9 | +<?php echo '<?'.'xml version="1.0" encoding="iso-8859-1"?'.'>'; ?> |
|
10 | 10 | <!DOCTYPE html |
11 | 11 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
12 | 12 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | <head> |
15 | 15 | <title>dompdf - The PHP 5 HTML to PDF Converter</title> |
16 | 16 | <link rel="stylesheet" href="style.css" type="text/css"/> |
17 | -<link rel="SHORTCUT ICON" href="http://<?php echo $_SERVER["HTTP_HOST"] . dirname($_SERVER["PHP_SELF"]);?>/images/favicon.ico"/> |
|
17 | +<link rel="SHORTCUT ICON" href="http://<?php echo $_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"]); ?>/images/favicon.ico"/> |
|
18 | 18 | </head> |
19 | 19 | |
20 | 20 | <body> |
@@ -64,7 +64,7 @@ |
||
64 | 64 | |
65 | 65 | // End debugging |
66 | 66 | |
67 | - if ( !$p ) |
|
67 | + if (!$p) |
|
68 | 68 | throw new DOMPDF_Exception("No block-level parent found. Not good."); |
69 | 69 | |
70 | 70 | $line = $p->get_current_line(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | $parsed_url = explode_url($url); |
86 | 86 | |
87 | - $DEBUGPNG=DEBUGPNG; //=DEBUGPNG; Allow override of global setting for ad hoc debug |
|
87 | + $DEBUGPNG = DEBUGPNG; //=DEBUGPNG; Allow override of global setting for ad hoc debug |
|
88 | 88 | $full_url_dbg = ''; |
89 | 89 | |
90 | 90 | //debugpng |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | $remote = ($proto != "" && $proto !== "file://"); |
94 | 94 | $remote = $remote || ($parsed_url['protocol'] != ""); |
95 | 95 | |
96 | - if ( !DOMPDF_ENABLE_REMOTE && $remote ) { |
|
97 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
96 | + if (!DOMPDF_ENABLE_REMOTE && $remote) { |
|
97 | + $resolved_url = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
98 | 98 | $ext = "png"; |
99 | 99 | |
100 | 100 | //debugpng |
101 | 101 | if ($DEBUGPNG) $full_url_dbg = '(blockedremote)'; |
102 | 102 | |
103 | - } else if ( DOMPDF_ENABLE_REMOTE && $remote ) { |
|
103 | + } else if (DOMPDF_ENABLE_REMOTE && $remote) { |
|
104 | 104 | // Download remote files to a temporary directory |
105 | 105 | $full_url = build_url($proto, $host, $base_path, $url); |
106 | 106 | |
107 | - if ( isset(self::$_cache[$full_url]) ) { |
|
108 | - list($resolved_url,$ext) = self::$_cache[$full_url]; |
|
107 | + if (isset(self::$_cache[$full_url])) { |
|
108 | + list($resolved_url, $ext) = self::$_cache[$full_url]; |
|
109 | 109 | |
110 | 110 | //debugpng |
111 | 111 | if ($DEBUGPNG) $full_url_dbg = $full_url.'(cache)'; |
@@ -114,15 +114,15 @@ discard block |
||
114 | 114 | |
115 | 115 | $resolved_url = tempnam(DOMPDF_TEMP_DIR, "ca_dompdf_img_"); |
116 | 116 | //debugpng |
117 | - if ($DEBUGPNG) echo $resolved_url . "\n"; |
|
117 | + if ($DEBUGPNG) echo $resolved_url."\n"; |
|
118 | 118 | |
119 | 119 | $old_err = set_error_handler("record_warnings"); |
120 | 120 | $image = file_get_contents($full_url); |
121 | 121 | restore_error_handler(); |
122 | 122 | |
123 | - if ( strlen($image) == 0 ) { |
|
123 | + if (strlen($image) == 0) { |
|
124 | 124 | //target image not found |
125 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
125 | + $resolved_url = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
126 | 126 | $ext = "png"; |
127 | 127 | |
128 | 128 | //debugpng |
@@ -140,24 +140,24 @@ discard block |
||
140 | 140 | //Therefore get image type from the content |
141 | 141 | |
142 | 142 | $imagedim = getimagesize($resolved_url); |
143 | - if( $imagedim[2] >= 1 && $imagedim[2] <=3 && $imagedim[0] && $imagedim[1] ) { |
|
143 | + if ($imagedim[2] >= 1 && $imagedim[2] <= 3 && $imagedim[0] && $imagedim[1]) { |
|
144 | 144 | //target image is valid |
145 | 145 | |
146 | - $imagetypes = array('','gif','jpeg','png','swf'); |
|
146 | + $imagetypes = array('', 'gif', 'jpeg', 'png', 'swf'); |
|
147 | 147 | $ext = $imagetypes[$imagedim[2]]; |
148 | - if ( rename($resolved_url,$resolved_url.'.'.$ext) ) { |
|
148 | + if (rename($resolved_url, $resolved_url.'.'.$ext)) { |
|
149 | 149 | $resolved_url .= '.'.$ext; |
150 | 150 | } |
151 | 151 | |
152 | 152 | //Don't put replacement image into cache - otherwise it will be deleted on cache cleanup. |
153 | 153 | //Only execute on successfull caching of remote image. |
154 | - self::$_cache[$full_url] = array($resolved_url,$ext); |
|
154 | + self::$_cache[$full_url] = array($resolved_url, $ext); |
|
155 | 155 | |
156 | 156 | } else { |
157 | 157 | //target image is not valid. |
158 | 158 | unlink($resolved_url); |
159 | 159 | |
160 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
160 | + $resolved_url = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
161 | 161 | $ext = "png"; |
162 | 162 | } |
163 | 163 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $resolved_url = build_url($proto, $host, $base_path, $url); |
170 | 170 | if ($DEBUGPNG) print 'build_url('.$proto.','.$host.','.$base_path.','.$url.')('.$resolved_url.')'; |
171 | 171 | |
172 | - if ( !preg_match("/.*\.(\w+)/",$url,$match) ) { |
|
172 | + if (!preg_match("/.*\.(\w+)/", $url, $match)) { |
|
173 | 173 | //debugpng |
174 | 174 | if ($DEBUGPNG) print '[resolve_url exception '.$url.']'; |
175 | 175 | throw new DOMPDF_Exception("Unknown image type: $url."); |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | |
183 | 183 | } |
184 | 184 | |
185 | - if ( !is_readable($resolved_url) || !filesize($resolved_url) ) { |
|
185 | + if (!is_readable($resolved_url) || !filesize($resolved_url)) { |
|
186 | 186 | |
187 | 187 | //debugpng |
188 | 188 | if ($DEBUGPNG) $full_url_dbg .= '(nocache'.$resolved_url.')'; |
189 | 189 | |
190 | - $_dompdf_warnings[] = "File " .$resolved_url . " is not readable or is an empty file.\n"; |
|
191 | - $resolved_url = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
190 | + $_dompdf_warnings[] = "File ".$resolved_url." is not readable or is an empty file.\n"; |
|
191 | + $resolved_url = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
192 | 192 | $ext = "png"; |
193 | 193 | } |
194 | 194 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * or converted) |
204 | 204 | */ |
205 | 205 | static function clear() { |
206 | - if ( count(self::$_cache) ) { |
|
206 | + if (count(self::$_cache)) { |
|
207 | 207 | while ($entry = array_shift(self::$_cache)) { |
208 | 208 | list($file, $ext) = $entry; |
209 | 209 | //debugpng |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $this->_decorator = null; |
173 | 173 | |
174 | - $this->set_id( self::$ID_COUNTER++ ); |
|
174 | + $this->set_id(self::$ID_COUNTER++); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -181,29 +181,29 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function dispose($recursive = false) { |
183 | 183 | |
184 | - if ( $recursive ) { |
|
185 | - while ( $child = $this->_first_child ) |
|
184 | + if ($recursive) { |
|
185 | + while ($child = $this->_first_child) |
|
186 | 186 | $child->dispose(true); |
187 | 187 | } |
188 | 188 | |
189 | 189 | // Remove this frame from the tree |
190 | - if ( $this->_prev_sibling ) { |
|
190 | + if ($this->_prev_sibling) { |
|
191 | 191 | $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
192 | 192 | } |
193 | 193 | |
194 | - if ( $this->_next_sibling ) { |
|
194 | + if ($this->_next_sibling) { |
|
195 | 195 | $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
196 | 196 | } |
197 | 197 | |
198 | - if ( $this->_parent && $this->_parent->_first_child === $this ) { |
|
198 | + if ($this->_parent && $this->_parent->_first_child === $this) { |
|
199 | 199 | $this->_parent->_first_child = $this->_next_sibling; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $this->_parent && $this->_parent->_last_child === $this ) { |
|
202 | + if ($this->_parent && $this->_parent->_last_child === $this) { |
|
203 | 203 | $this->_parent->_last_child = $this->_prev_sibling; |
204 | 204 | } |
205 | 205 | |
206 | - if ( $this->_parent ) { |
|
206 | + if ($this->_parent) { |
|
207 | 207 | $this->_parent->get_node()->removeChild($this->_node); |
208 | 208 | } |
209 | 209 | |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | // Layout property accessors |
248 | 248 | function get_containing_block($i = null) { |
249 | - if ( isset($i) ) |
|
249 | + if (isset($i)) |
|
250 | 250 | return $this->_containing_block[$i]; |
251 | 251 | return $this->_containing_block; |
252 | 252 | } |
253 | 253 | |
254 | 254 | function get_position($i = null) { |
255 | - if ( isset($i) ) |
|
255 | + if (isset($i)) |
|
256 | 256 | return $this->_position[$i]; |
257 | 257 | return array($this->_position["x"], |
258 | 258 | $this->_position["y"], |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 355 | // Since these are the only objects that we can assign CSS rules to, |
356 | 356 | // this shortcoming is okay. |
357 | - if ( $this->_node->nodeType == 1) |
|
357 | + if ($this->_node->nodeType == 1) |
|
358 | 358 | $this->_node->setAttribute("frame_id", $id); |
359 | 359 | } |
360 | 360 | |
361 | 361 | function set_style(Style $style) { |
362 | - if ( is_null($this->_style) ) |
|
362 | + if (is_null($this->_style)) |
|
363 | 363 | $this->_original_style = clone $style; |
364 | 364 | |
365 | 365 | $this->_style = $style; |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
373 | - if ( is_array($x) ){ |
|
374 | - foreach($x AS $key => $val){ |
|
373 | + if (is_array($x)) { |
|
374 | + foreach ($x AS $key => $val) { |
|
375 | 375 | $$key = $val; |
376 | 376 | } |
377 | 377 | } |
@@ -399,15 +399,15 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | function set_position($x = null, $y = null) { |
402 | - if ( is_array($x) ) |
|
402 | + if (is_array($x)) |
|
403 | 403 | extract($x); |
404 | 404 | |
405 | - if ( is_numeric($x) ) { |
|
405 | + if (is_numeric($x)) { |
|
406 | 406 | $this->_position[0] = $x; |
407 | 407 | $this->_position["x"] = $x; |
408 | 408 | } |
409 | 409 | |
410 | - if ( is_numeric($y) ) { |
|
410 | + if (is_numeric($y)) { |
|
411 | 411 | $this->_position[1] = $y; |
412 | 412 | $this->_position["y"] = $y; |
413 | 413 | } |
@@ -417,18 +417,18 @@ discard block |
||
417 | 417 | |
418 | 418 | function prepend_child(Frame $child, $update_node = true) { |
419 | 419 | |
420 | - if ( $update_node ) |
|
420 | + if ($update_node) |
|
421 | 421 | $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
422 | 422 | |
423 | 423 | // Remove the child from its parent |
424 | - if ( $child->_parent ) |
|
424 | + if ($child->_parent) |
|
425 | 425 | $child->_parent->remove_child($child, false); |
426 | 426 | |
427 | 427 | $child->_parent = $this; |
428 | 428 | $child->_prev_sibling = null; |
429 | 429 | |
430 | 430 | // Handle the first child |
431 | - if ( !$this->_first_child ) { |
|
431 | + if (!$this->_first_child) { |
|
432 | 432 | $this->_first_child = $child; |
433 | 433 | $this->_last_child = $child; |
434 | 434 | $child->_next_sibling = null; |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | |
445 | 445 | function append_child(Frame $child, $update_node = true) { |
446 | 446 | |
447 | - if ( $update_node ) |
|
447 | + if ($update_node) |
|
448 | 448 | $this->_node->appendChild($child->_node); |
449 | 449 | |
450 | 450 | // Remove the child from its parent |
451 | - if ( $child->_parent ) |
|
451 | + if ($child->_parent) |
|
452 | 452 | $child->_parent->remove_child($child, false); |
453 | 453 | |
454 | 454 | $child->_parent = $this; |
455 | 455 | $child->_next_sibling = null; |
456 | 456 | |
457 | 457 | // Handle the first child |
458 | - if ( !$this->_last_child ) { |
|
458 | + if (!$this->_last_child) { |
|
459 | 459 | $this->_first_child = $child; |
460 | 460 | $this->_last_child = $child; |
461 | 461 | $child->_prev_sibling = null; |
@@ -472,32 +472,32 @@ discard block |
||
472 | 472 | // Inserts a new child immediately before the specified frame |
473 | 473 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
474 | 474 | |
475 | - if ( $ref === $this->_first_child ) { |
|
475 | + if ($ref === $this->_first_child) { |
|
476 | 476 | $this->prepend_child($new_child, $update_node); |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - if ( is_null($ref) ) { |
|
480 | + if (is_null($ref)) { |
|
481 | 481 | $this->append_child($new_child, $update_node); |
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
485 | - if ( $ref->_parent !== $this ) |
|
485 | + if ($ref->_parent !== $this) |
|
486 | 486 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
487 | 487 | |
488 | 488 | // Update the node |
489 | - if ( $update_node ) |
|
489 | + if ($update_node) |
|
490 | 490 | $this->_node->insertBefore($new_child->_node, $ref->_node); |
491 | 491 | |
492 | 492 | // Remove the child from its parent |
493 | - if ( $new_child->_parent ) |
|
493 | + if ($new_child->_parent) |
|
494 | 494 | $new_child->_parent->remove_child($new_child, false); |
495 | 495 | |
496 | 496 | $new_child->_parent = $this; |
497 | 497 | $new_child->_next_sibling = $ref; |
498 | 498 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 499 | |
500 | - if ( $ref->_prev_sibling ) |
|
500 | + if ($ref->_prev_sibling) |
|
501 | 501 | $ref->_prev_sibling->_next_sibling = $new_child; |
502 | 502 | |
503 | 503 | $ref->_prev_sibling = $new_child; |
@@ -506,22 +506,22 @@ discard block |
||
506 | 506 | // Inserts a new child immediately after the specified frame |
507 | 507 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
508 | 508 | |
509 | - if ( $ref === $this->_last_child ) { |
|
509 | + if ($ref === $this->_last_child) { |
|
510 | 510 | $this->append_child($new_child, $update_node); |
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if ( is_null($ref) ) { |
|
514 | + if (is_null($ref)) { |
|
515 | 515 | $this->prepend_child($new_child, $update_node); |
516 | 516 | return; |
517 | 517 | } |
518 | 518 | |
519 | - if ( $ref->_parent !== $this ) |
|
519 | + if ($ref->_parent !== $this) |
|
520 | 520 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
521 | 521 | |
522 | 522 | // Update the node |
523 | - if ( $update_node ) { |
|
524 | - if ( $ref->_next_sibling ) { |
|
523 | + if ($update_node) { |
|
524 | + if ($ref->_next_sibling) { |
|
525 | 525 | $next_node = $ref->_next_sibling->_node; |
526 | 526 | $this->_node->insertBefore($new_child->_node, $next_node); |
527 | 527 | } else { |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | // Remove the child from its parent |
533 | - if ( $new_child->_parent) |
|
533 | + if ($new_child->_parent) |
|
534 | 534 | $new_child->_parent->remove_child($new_child, false); |
535 | 535 | |
536 | 536 | $new_child->_parent = $this; |
537 | 537 | $new_child->_prev_sibling = $ref; |
538 | 538 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 539 | |
540 | - if ( $ref->_next_sibling ) |
|
540 | + if ($ref->_next_sibling) |
|
541 | 541 | $ref->_next_sibling->_prev_sibling = $new_child; |
542 | 542 | |
543 | 543 | $ref->_next_sibling = $new_child; |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | |
547 | 547 | function remove_child(Frame $child, $update_node = true) { |
548 | 548 | |
549 | - if ( $child->_parent !== $this ) |
|
549 | + if ($child->_parent !== $this) |
|
550 | 550 | throw new DOMPDF_Exception("Child not found in this frame"); |
551 | 551 | |
552 | - if ( $update_node ) |
|
552 | + if ($update_node) |
|
553 | 553 | $this->_node->removeChild($child->_node); |
554 | 554 | |
555 | - if ( $child === $this->_first_child ) |
|
555 | + if ($child === $this->_first_child) |
|
556 | 556 | $this->_first_child = $child->_next_sibling; |
557 | 557 | |
558 | - if ( $child === $this->_last_child ) |
|
558 | + if ($child === $this->_last_child) |
|
559 | 559 | $this->_last_child = $child->_prev_sibling; |
560 | 560 | |
561 | - if ( $child->_prev_sibling ) |
|
561 | + if ($child->_prev_sibling) |
|
562 | 562 | $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
563 | 563 | |
564 | - if ( $child->_next_sibling ) |
|
564 | + if ($child->_next_sibling) |
|
565 | 565 | $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
566 | 566 | |
567 | 567 | $child->_next_sibling = null; |
@@ -582,68 +582,68 @@ discard block |
||
582 | 582 | // return ""; |
583 | 583 | |
584 | 584 | |
585 | - $str = "<b>" . $this->_node->nodeName . ":</b><br/>"; |
|
585 | + $str = "<b>".$this->_node->nodeName.":</b><br/>"; |
|
586 | 586 | //$str .= spl_object_hash($this->_node) . "<br/>"; |
587 | - $str .= "Id: " .$this->get_id() . "<br/>"; |
|
588 | - $str .= "Class: " .get_class($this) . "<br/>"; |
|
587 | + $str .= "Id: ".$this->get_id()."<br/>"; |
|
588 | + $str .= "Class: ".get_class($this)."<br/>"; |
|
589 | 589 | |
590 | - if ( $this->_node->nodeName === "#text" ) { |
|
590 | + if ($this->_node->nodeName === "#text") { |
|
591 | 591 | $tmp = htmlspecialchars($this->_node->nodeValue); |
592 | - $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
593 | - (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
|
592 | + $str .= "<pre>'".mb_substr($tmp, 0, 70). |
|
593 | + (mb_strlen($tmp) > 70 ? "..." : "")."'</pre>"; |
|
594 | 594 | } |
595 | - if ( $this->_parent ) |
|
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | - " (" . spl_object_hash($this->_parent->_node) . ") " . |
|
595 | + if ($this->_parent) |
|
596 | + $str .= "\nParent:".$this->_parent->_node->nodeName. |
|
597 | + " (".spl_object_hash($this->_parent->_node).") ". |
|
598 | 598 | "<br/>"; |
599 | 599 | |
600 | - if ( $this->_prev_sibling ) |
|
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | - " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
|
600 | + if ($this->_prev_sibling) |
|
601 | + $str .= "Prev: ".$this->_prev_sibling->_node->nodeName. |
|
602 | + " (".spl_object_hash($this->_prev_sibling->_node).") ". |
|
603 | 603 | "<br/>"; |
604 | 604 | |
605 | - if ( $this->_next_sibling ) |
|
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | - " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
|
605 | + if ($this->_next_sibling) |
|
606 | + $str .= "Next: ".$this->_next_sibling->_node->nodeName. |
|
607 | + " (".spl_object_hash($this->_next_sibling->_node).") ". |
|
608 | 608 | "<br/>"; |
609 | 609 | |
610 | 610 | $d = $this->get_decorator(); |
611 | 611 | while ($d && $d != $d->get_decorator()) { |
612 | - $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
612 | + $str .= "Decorator: ".get_class($d)."<br/>"; |
|
613 | 613 | $d = $d->get_decorator(); |
614 | 614 | } |
615 | 615 | |
616 | - $str .= "Position: " . pre_r($this->_position, true); |
|
617 | - $str .= "\nContaining block: " . pre_r($this->_containing_block, true); |
|
618 | - $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true); |
|
619 | - $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true); |
|
616 | + $str .= "Position: ".pre_r($this->_position, true); |
|
617 | + $str .= "\nContaining block: ".pre_r($this->_containing_block, true); |
|
618 | + $str .= "\nMargin width: ".pre_r($this->get_margin_width(), true); |
|
619 | + $str .= "\nMargin height: ".pre_r($this->get_margin_height(), true); |
|
620 | 620 | |
621 | - $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>"; |
|
621 | + $str .= "\nStyle: <pre>".$this->_style->__toString()."</pre>"; |
|
622 | 622 | |
623 | - if ( $this->_decorator instanceof Block_Frame_Decorator ) { |
|
623 | + if ($this->_decorator instanceof Block_Frame_Decorator) { |
|
624 | 624 | $str .= "Lines:<pre>"; |
625 | 625 | foreach ($this->_decorator->get_lines() as $line) { |
626 | 626 | foreach ($line["frames"] as $frame) { |
627 | 627 | if ($frame instanceof Text_Frame_Decorator) { |
628 | 628 | $str .= "\ntext: "; |
629 | - $str .= "'". htmlspecialchars($frame->get_text()) ."'"; |
|
629 | + $str .= "'".htmlspecialchars($frame->get_text())."'"; |
|
630 | 630 | } else { |
631 | - $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; |
|
631 | + $str .= "\nBlock: ".$frame->get_node()->nodeName." (".spl_object_hash($frame->get_node()).")"; |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | 635 | $str .= |
636 | 636 | //"\ncount => " . $line["count"] . "\n". |
637 | - "\ny => " . $line["y"] . "\n" . |
|
638 | - "w => " . $line["w"] . "\n" . |
|
639 | - "h => " . $line["h"] . "\n"; |
|
637 | + "\ny => ".$line["y"]."\n". |
|
638 | + "w => ".$line["w"]."\n". |
|
639 | + "h => ".$line["h"]."\n"; |
|
640 | 640 | } |
641 | 641 | $str .= "</pre>"; |
642 | 642 | } |
643 | 643 | $str .= "\n"; |
644 | - if ( php_sapi_name() === "cli" ) |
|
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | - array("\n","",""), |
|
644 | + if (php_sapi_name() === "cli") |
|
645 | + $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), |
|
646 | + array("\n", "", ""), |
|
647 | 647 | $str)); |
648 | 648 | |
649 | 649 | return $str; |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | } |
694 | 694 | |
695 | 695 | function valid() { |
696 | - return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
696 | + return isset($this->_cur); // && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
697 | 697 | } |
698 | 698 | function key() { return $this->_num; } |
699 | 699 | function current() { return $this->_cur; } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | function next() { |
702 | 702 | |
703 | 703 | $ret = $this->_cur; |
704 | - if ( !$ret ) |
|
704 | + if (!$ret) |
|
705 | 705 | return null; |
706 | 706 | |
707 | 707 | $this->_cur = $this->_cur->get_next_sibling(); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | $b = end($this->_stack); |
759 | 759 | |
760 | 760 | // Pop last element |
761 | - unset($this->_stack[ key($this->_stack) ]); |
|
761 | + unset($this->_stack[key($this->_stack)]); |
|
762 | 762 | $this->_num++; |
763 | 763 | |
764 | 764 | // Push all children onto the stack in reverse order |
765 | - if ( $c = $b->get_last_child() ) { |
|
765 | + if ($c = $b->get_last_child()) { |
|
766 | 766 | $this->_stack[] = $c; |
767 | - while ( $c = $c->get_prev_sibling() ) |
|
767 | + while ($c = $c->get_prev_sibling()) |
|
768 | 768 | $this->_stack[] = $c; |
769 | 769 | } |
770 | 770 | return $b; |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | static private $__connection = null; |
58 | 58 | |
59 | 59 | function init() { |
60 | - if ( is_null(self::$__connection) ) { |
|
61 | - $con_str = "host=" . DB_HOST . |
|
62 | - " dbname=" . self::DB_NAME . |
|
63 | - " user=" . self::DB_USER . |
|
64 | - " password=" . self::DB_PASS; |
|
60 | + if (is_null(self::$__connection)) { |
|
61 | + $con_str = "host=".DB_HOST. |
|
62 | + " dbname=".self::DB_NAME. |
|
63 | + " user=".self::DB_USER. |
|
64 | + " password=".self::DB_PASS; |
|
65 | 65 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
66 | + if (!self::$__connection = pg_connect($con_str)) |
|
67 | 67 | throw new Exception("Database connection failed."); |
68 | 68 | } |
69 | 69 | } |
@@ -71,36 +71,36 @@ discard block |
||
71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 72 | |
73 | 73 | private static function __query($sql) { |
74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
74 | + if (!($res = pg_query(self::$__connection, $sql))) |
|
75 | 75 | throw new Exception(pg_last_error(self::$__connection)); |
76 | 76 | return $res; |
77 | 77 | } |
78 | 78 | |
79 | 79 | static function store_page($id, $page_num, $data) { |
80 | - $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
|
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + $where = "WHERE id='".pg_escape_string($id)."' AND ". |
|
81 | + "page_num=".pg_escape_string($page_num); |
|
82 | 82 | |
83 | - $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
|
83 | + $res = self::__query("SELECT timestamp FROM page_cache ".$where); |
|
84 | 84 | |
85 | 85 | $row = pg_fetch_assoc($res); |
86 | 86 | |
87 | - if ( $row ) |
|
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + if ($row) |
|
88 | + self::__query("UPDATE page_cache SET data='".pg_escape_string($data)."' ".$where); |
|
89 | 89 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
90 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('".pg_escape_string($id)."', ". |
|
91 | + pg_escape_string($page_num).", ". |
|
92 | + "'".pg_escape_string($data)."')"); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | 96 | static function store_fonts($id, $fonts) { |
97 | 97 | self::__query("BEGIN"); |
98 | 98 | // Update the font information |
99 | - self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
99 | + self::__query("DELETE FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
100 | 100 | |
101 | 101 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | - pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
|
102 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('". |
|
103 | + pg_escape_string($id)."', '".pg_escape_string($font)."')"); |
|
104 | 104 | self::__query("COMMIT"); |
105 | 105 | } |
106 | 106 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | // } |
117 | 117 | |
118 | 118 | static function get_page_timestamp($id, $page_num) { |
119 | - $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
|
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + $res = self::__query("SELECT timestamp FROM page_cache WHERE id='".pg_escape_string($id)."' AND ". |
|
120 | + "page_num=".pg_escape_string($page_num)); |
|
121 | 121 | |
122 | 122 | $row = pg_fetch_assoc($res); |
123 | 123 | |
@@ -127,22 +127,22 @@ discard block |
||
127 | 127 | |
128 | 128 | // Adds the cached document referenced by $id to the provided pdf |
129 | 129 | static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
130 | - $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
130 | + $res = self::__query("SELECT font_name FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
131 | 131 | |
132 | 132 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 133 | // the pdf |
134 | 134 | while ($row = pg_fetch_assoc($res)) |
135 | 135 | $pdf->get_cpdf()->selectFont($row["font_name"]); |
136 | 136 | |
137 | - $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
|
137 | + $res = self::__query("SELECT data FROM page_cache WHERE id='".pg_escape_string($id)."'"); |
|
138 | 138 | |
139 | - if ( $new_page ) |
|
139 | + if ($new_page) |
|
140 | 140 | $pdf->new_page(); |
141 | 141 | |
142 | 142 | $first = true; |
143 | 143 | while ($row = pg_fetch_assoc($res)) { |
144 | 144 | |
145 | - if ( !$first ) |
|
145 | + if (!$first) |
|
146 | 146 | $pdf->new_page(); |
147 | 147 | else |
148 | 148 | $first = false; |
@@ -81,22 +81,22 @@ discard block |
||
81 | 81 | $b = $style->length_in_pt($style->margin_bottom, $cb["w"]); |
82 | 82 | |
83 | 83 | // Handle 'auto' values |
84 | - if ( $t === "auto" ) { |
|
84 | + if ($t === "auto") { |
|
85 | 85 | $style->margin_top = "0pt"; |
86 | 86 | $t = 0; |
87 | 87 | } |
88 | 88 | |
89 | - if ( $b === "auto" ) { |
|
89 | + if ($b === "auto") { |
|
90 | 90 | $style->margin_bottom = "0pt"; |
91 | 91 | $b = 0; |
92 | 92 | } |
93 | 93 | |
94 | 94 | // Collapse vertical margins: |
95 | 95 | $n = $this->_frame->get_next_sibling(); |
96 | - while ( $n && !in_array($n->get_style()->display, Style::$BLOCK_TYPES) ) |
|
96 | + while ($n && !in_array($n->get_style()->display, Style::$BLOCK_TYPES)) |
|
97 | 97 | $n = $n->get_next_sibling(); |
98 | 98 | |
99 | - if ( $n ) { // && !$n instanceof Page_Frame_Decorator ) { |
|
99 | + if ($n) { // && !$n instanceof Page_Frame_Decorator ) { |
|
100 | 100 | |
101 | 101 | $b = max($b, $style->length_in_pt($n->get_style()->margin_top, $cb["w"])); |
102 | 102 | |
@@ -107,11 +107,11 @@ discard block |
||
107 | 107 | |
108 | 108 | // Collapse our first child's margin |
109 | 109 | $f = $this->_frame->get_first_child(); |
110 | - while ( $f && !in_array($f->get_style()->display, Style::$BLOCK_TYPES) ) |
|
110 | + while ($f && !in_array($f->get_style()->display, Style::$BLOCK_TYPES)) |
|
111 | 111 | $f = $f->get_next_sibling(); |
112 | 112 | |
113 | - if ( $f ) { |
|
114 | - $t = max( $t, $style->length_in_pt($f->get_style()->margin_top, $cb["w"])); |
|
113 | + if ($f) { |
|
114 | + $t = max($t, $style->length_in_pt($f->get_style()->margin_top, $cb["w"])); |
|
115 | 115 | $style->margin_top = "$t pt"; |
116 | 116 | $f->get_style()->margin_top = "0 pt"; |
117 | 117 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | $y = $this->_frame->get_position("y"); |
124 | 124 | $h = $style->length_in_pt($style->height); |
125 | 125 | // Check if we need to move to a new page |
126 | - if ( $y + $h >= $this->_frame->get_root()->get_page_height() ) |
|
126 | + if ($y + $h >= $this->_frame->get_root()->get_page_height()) |
|
127 | 127 | return true; |
128 | 128 | |
129 | 129 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | // This provides a basic implementation. Child classes should override |
140 | 140 | // this if necessary. |
141 | 141 | function get_min_max_width() { |
142 | - if ( !is_null($this->_min_max_cache) ) { |
|
142 | + if (!is_null($this->_min_max_cache)) { |
|
143 | 143 | return $this->_min_max_cache; |
144 | 144 | } |
145 | 145 | |
@@ -157,27 +157,27 @@ discard block |
||
157 | 157 | $delta = $style->length_in_pt($dims, $cb_w); |
158 | 158 | |
159 | 159 | // Handle degenerate case |
160 | - if ( !$this->_frame->get_first_child() ) |
|
161 | - return $this->_min_max_cache = array($delta, $delta,"min" => $delta, "max" => $delta); |
|
160 | + if (!$this->_frame->get_first_child()) |
|
161 | + return $this->_min_max_cache = array($delta, $delta, "min" => $delta, "max" => $delta); |
|
162 | 162 | |
163 | 163 | $low = array(); |
164 | 164 | $high = array(); |
165 | 165 | |
166 | - for ( $iter = $this->_frame->get_children()->getIterator(); |
|
166 | + for ($iter = $this->_frame->get_children()->getIterator(); |
|
167 | 167 | $iter->valid(); |
168 | - $iter->next() ) { |
|
168 | + $iter->next()) { |
|
169 | 169 | |
170 | 170 | $inline_min = 0; |
171 | 171 | $inline_max = 0; |
172 | 172 | |
173 | 173 | // Add all adjacent inline widths together to calculate max width |
174 | - while ( $iter->valid() && in_array( $iter->current()->get_style()->display, Style::$INLINE_TYPES ) ) { |
|
174 | + while ($iter->valid() && in_array($iter->current()->get_style()->display, Style::$INLINE_TYPES)) { |
|
175 | 175 | |
176 | 176 | $child = $iter->current(); |
177 | 177 | |
178 | 178 | $minmax = $child->get_min_max_width(); |
179 | 179 | |
180 | - if ( in_array( $iter->current()->get_style()->white_space, array("pre", "nowrap") ) ) |
|
180 | + if (in_array($iter->current()->get_style()->white_space, array("pre", "nowrap"))) |
|
181 | 181 | $inline_min += $minmax["min"]; |
182 | 182 | else |
183 | 183 | $low[] = $minmax["min"]; |
@@ -187,13 +187,13 @@ discard block |
||
187 | 187 | |
188 | 188 | } |
189 | 189 | |
190 | - if ( $inline_max > 0 ) |
|
190 | + if ($inline_max > 0) |
|
191 | 191 | $high[] = $inline_max; |
192 | 192 | |
193 | - if ( $inline_min > 0 ) |
|
193 | + if ($inline_min > 0) |
|
194 | 194 | $low[] = $inline_min; |
195 | 195 | |
196 | - if ( $iter->valid() ) { |
|
196 | + if ($iter->valid()) { |
|
197 | 197 | list($low[], $high[]) = $iter->current()->get_min_max_width(); |
198 | 198 | continue; |
199 | 199 | } |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | // Use specified width if it is greater than the minimum defined by the |
206 | 206 | // content. If the width is a percentage ignore it for now. |
207 | 207 | $width = $style->width; |
208 | - if ( $width !== "auto" && !is_percent($width) ) { |
|
208 | + if ($width !== "auto" && !is_percent($width)) { |
|
209 | 209 | $width = $style->length_in_pt($width, $cb_w); |
210 | - if ( $min < $width ) |
|
210 | + if ($min < $width) |
|
211 | 211 | $min = $width; |
212 | - if ( $max < $width ) |
|
212 | + if ($max < $width) |
|
213 | 213 | $max = $width; |
214 | 214 | } |
215 | 215 |