@@ -74,10 +74,10 @@ |
||
74 | 74 | |
75 | 75 | // This is a bit of a hack... |
76 | 76 | $n = $this->_frame->get_next_sibling(); |
77 | - if ( $n ) { |
|
77 | + if ($n) { |
|
78 | 78 | $style = $n->get_style(); |
79 | - $y += $style->length_in_pt( array($style->margin_top, $style->padding_top), |
|
80 | - $n->get_containing_block("w") ); |
|
79 | + $y += $style->length_in_pt(array($style->margin_top, $style->padding_top), |
|
80 | + $n->get_containing_block("w")); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // Now the position is the left top of the block which should be marked with the bullet. |
@@ -267,24 +267,24 @@ discard block |
||
267 | 267 | // Store parsing warnings as messages (this is to prevent output to the |
268 | 268 | // browser if the html is ugly and the dom extension complains, |
269 | 269 | // preventing the pdf from being streamed.) |
270 | - if ( !$this->_protocol && !$this->_base_host && !$this->_base_path ) |
|
270 | + if (!$this->_protocol && !$this->_base_host && !$this->_base_path) |
|
271 | 271 | list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file); |
272 | 272 | |
273 | - if ( !DOMPDF_ENABLE_REMOTE && |
|
274 | - ($this->_protocol != "" && $this->_protocol !== "file://" ) ) |
|
273 | + if (!DOMPDF_ENABLE_REMOTE && |
|
274 | + ($this->_protocol != "" && $this->_protocol !== "file://")) |
|
275 | 275 | throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false."); |
276 | 276 | |
277 | 277 | if ($this->_protocol == "" || $this->_protocol === "file://") { |
278 | 278 | |
279 | 279 | $realfile = realpath($file); |
280 | - if ( !$file ) |
|
280 | + if (!$file) |
|
281 | 281 | throw new DOMPDF_Exception("File '$file' not found."); |
282 | 282 | |
283 | - if ( strpos($realfile, DOMPDF_CHROOT) !== 0 ) |
|
283 | + if (strpos($realfile, DOMPDF_CHROOT) !== 0) |
|
284 | 284 | throw new DOMPDF_Exception("Permission denied on $file."); |
285 | 285 | |
286 | 286 | // Exclude dot files (e.g. .htaccess) |
287 | - if ( substr(basename($realfile),0,1) === "." ) |
|
287 | + if (substr(basename($realfile), 0, 1) === ".") |
|
288 | 288 | throw new DOMPDF_Exception("Permission denied on $file."); |
289 | 289 | |
290 | 290 | $file = $realfile; |
@@ -305,30 +305,30 @@ discard block |
||
305 | 305 | mb_detect_order('auto'); |
306 | 306 | if (mb_detect_encoding($str) != 'UTF-8') { |
307 | 307 | if (mb_detect_encoding($str) == '') { |
308 | - if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) { |
|
308 | + if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i', $str, $matches)) { |
|
309 | 309 | $encoding = strtoupper($matches[3]); |
310 | 310 | } else { |
311 | 311 | $encoding = 'UTF-8'; |
312 | 312 | } |
313 | 313 | } else { |
314 | - if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) { |
|
314 | + if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i', $str, $matches)) { |
|
315 | 315 | $encoding = strtoupper($matches[3]); |
316 | 316 | } else { |
317 | 317 | $encoding = 'auto'; |
318 | 318 | } |
319 | 319 | } |
320 | 320 | if ($encoding != 'UTF-8') { $str = mb_convert_encoding($str, 'UTF-8', $encoding); } |
321 | - if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',$str,$matches)) { |
|
322 | - $str = preg_replace('/charset=([^\s"]+)/i','charset=UTF-8',$str); |
|
321 | + if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i', $str, $matches)) { |
|
322 | + $str = preg_replace('/charset=([^\s"]+)/i', 'charset=UTF-8', $str); |
|
323 | 323 | } else { |
324 | 324 | $str = str_replace('<head>', '<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">', $str); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | 328 | // Parse embedded php, first-pass |
329 | - if ( DOMPDF_ENABLE_PHP ) { |
|
329 | + if (DOMPDF_ENABLE_PHP) { |
|
330 | 330 | ob_start(); |
331 | - eval("?" . ">$str"); |
|
331 | + eval("?".">$str"); |
|
332 | 332 | $str = ob_get_contents(); |
333 | 333 | ob_end_clean(); |
334 | 334 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET); |
350 | 350 | |
351 | 351 | $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES; |
352 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
352 | + if (defined("DOMPDF_DEFAULT_MEDIA_TYPE")) { |
|
353 | 353 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
354 | 354 | } else { |
355 | 355 | $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
@@ -358,15 +358,15 @@ discard block |
||
358 | 358 | // load <link rel="STYLESHEET" ... /> tags |
359 | 359 | $links = $this->_xml->getElementsByTagName("link"); |
360 | 360 | foreach ($links as $link) { |
361 | - if ( mb_strtolower($link->getAttribute("rel")) === "stylesheet" || |
|
362 | - mb_strtolower($link->getAttribute("type")) === "text/css" ) { |
|
361 | + if (mb_strtolower($link->getAttribute("rel")) === "stylesheet" || |
|
362 | + mb_strtolower($link->getAttribute("type")) === "text/css") { |
|
363 | 363 | //Check if the css file is for an accepted media type |
364 | 364 | //media not given then always valid |
365 | - $formedialist = preg_split("/[\s\n,]/", $link->getAttribute("media"),-1, PREG_SPLIT_NO_EMPTY); |
|
366 | - if ( count($formedialist) > 0 ) { |
|
365 | + $formedialist = preg_split("/[\s\n,]/", $link->getAttribute("media"), -1, PREG_SPLIT_NO_EMPTY); |
|
366 | + if (count($formedialist) > 0) { |
|
367 | 367 | $accept = false; |
368 | - foreach ( $formedialist as $type ) { |
|
369 | - if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) { |
|
368 | + foreach ($formedialist as $type) { |
|
369 | + if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) { |
|
370 | 370 | $accept = true; |
371 | 371 | break; |
372 | 372 | } |
@@ -394,16 +394,16 @@ discard block |
||
394 | 394 | // HTML 4.0 spec: |
395 | 395 | // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media |
396 | 396 | // which states that the default media type is 'screen' |
397 | - if ( $style->hasAttributes() && |
|
397 | + if ($style->hasAttributes() && |
|
398 | 398 | ($media = $style->getAttribute("media")) && |
399 | - !in_array($media, $acceptedmedia) ) |
|
399 | + !in_array($media, $acceptedmedia)) |
|
400 | 400 | continue; |
401 | 401 | |
402 | 402 | $css = ""; |
403 | - if ( $style->hasChildNodes() ) { |
|
403 | + if ($style->hasChildNodes()) { |
|
404 | 404 | |
405 | 405 | $child = $style->firstChild; |
406 | - while ( $child ) { |
|
406 | + while ($child) { |
|
407 | 407 | $css .= $child->nodeValue; // Handle <style><!-- blah --></style> |
408 | 408 | $child = $child->nextSibling; |
409 | 409 | } |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | foreach ($this->_tree->get_frames() as $frame) { |
491 | 491 | // Set up the root frame |
492 | 492 | |
493 | - if ( is_null($root) ) { |
|
494 | - $root = Frame_Factory::decorate_root( $this->_tree->get_root(), $this ); |
|
493 | + if (is_null($root)) { |
|
494 | + $root = Frame_Factory::decorate_root($this->_tree->get_root(), $this); |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $deco->set_root($root); |
501 | 501 | |
502 | 502 | // FIXME: handle generated content |
503 | - if ( $frame->get_style()->display === "list-item" ) { |
|
503 | + if ($frame->get_style()->display === "list-item") { |
|
504 | 504 | |
505 | 505 | // Insert a list-bullet frame |
506 | 506 | $node = $this->_xml->createElement("bullet"); // arbitrary choice |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | $style->inherit($frame->get_style()); |
512 | 512 | $b_f->set_style($style); |
513 | 513 | |
514 | - $deco->prepend_child( Frame_Factory::decorate_frame($b_f, $this) ); |
|
514 | + $deco->prepend_child(Frame_Factory::decorate_frame($b_f, $this)); |
|
515 | 515 | } |
516 | 516 | |
517 | 517 | } |
@@ -528,10 +528,10 @@ discard block |
||
528 | 528 | Image_Cache::clear(); |
529 | 529 | |
530 | 530 | global $_dompdf_warnings, $_dompdf_show_warnings; |
531 | - if ( $_dompdf_show_warnings ) { |
|
531 | + if ($_dompdf_show_warnings) { |
|
532 | 532 | echo '<b>DOMPDF Warnings</b><br><pre>'; |
533 | 533 | foreach ($_dompdf_warnings as $msg) |
534 | - echo $msg . "\n"; |
|
534 | + echo $msg."\n"; |
|
535 | 535 | echo $this->get_canvas()->get_cpdf()->messages; |
536 | 536 | echo '</pre>'; |
537 | 537 | flush(); |
@@ -591,10 +591,10 @@ discard block |
||
591 | 591 | */ |
592 | 592 | function output($options = null) { |
593 | 593 | |
594 | - if ( is_null($this->_pdf) ) |
|
594 | + if (is_null($this->_pdf)) |
|
595 | 595 | return null; |
596 | 596 | |
597 | - return $this->_pdf->output( $options ); |
|
597 | + return $this->_pdf->output($options); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 |
@@ -68,7 +68,7 @@ |
||
68 | 68 | foreach ($this->get_children() as $child) { |
69 | 69 | $display = $child->get_style()->display; |
70 | 70 | |
71 | - if ( $display !== "table-cell" ) |
|
71 | + if ($display !== "table-cell") |
|
72 | 72 | $erroneous_frames[] = $child; |
73 | 73 | } |
74 | 74 |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @package dompdf |
47 | 47 | */ |
48 | 48 | class Block_Frame_Reflower extends Frame_Reflower { |
49 | - const MIN_JUSTIFY_WIDTH = 0.80; // (Minimum line width to justify, as |
|
49 | + const MIN_JUSTIFY_WIDTH = 0.80; // (Minimum line width to justify, as |
|
50 | 50 | // fraction of available width) |
51 | 51 | |
52 | 52 | function __construct(Block_Frame_Decorator $frame) { parent::__construct($frame); } |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | $lm !== "auto" ? $lm : 0); |
77 | 77 | |
78 | 78 | // absolutely positioned boxes take the 'left' and 'right' properties into account |
79 | - if ( $style->position === "absolute" || $style->position === "fixed" ) { |
|
79 | + if ($style->position === "absolute" || $style->position === "fixed") { |
|
80 | 80 | $absolute = true; |
81 | 81 | $dims[] = $left !== "auto" ? $left : 0; |
82 | 82 | $dims[] = $right !== "auto" ? $right : 0; |
@@ -89,18 +89,18 @@ discard block |
||
89 | 89 | // Compare to the containing block |
90 | 90 | $diff = $w - $sum; |
91 | 91 | |
92 | - if ( $diff > 0 ) { |
|
92 | + if ($diff > 0) { |
|
93 | 93 | |
94 | - if ( $absolute ) { |
|
94 | + if ($absolute) { |
|
95 | 95 | |
96 | 96 | // resolve auto properties: see |
97 | 97 | // http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width |
98 | 98 | |
99 | - if ( $width === "auto" && $left === "auto" && $right === "auto" ) { |
|
99 | + if ($width === "auto" && $left === "auto" && $right === "auto") { |
|
100 | 100 | |
101 | - if ( $lm === "auto" ) |
|
101 | + if ($lm === "auto") |
|
102 | 102 | $lm = 0; |
103 | - if ( $rm === "auto" ) |
|
103 | + if ($rm === "auto") |
|
104 | 104 | $rm = 0; |
105 | 105 | |
106 | 106 | // Technically, the width should be "shrink-to-fit" i.e. based on the |
@@ -110,34 +110,34 @@ discard block |
||
110 | 110 | $right = 0; |
111 | 111 | $width = $diff; |
112 | 112 | |
113 | - } else if ( $width === "auto" ) { |
|
113 | + } else if ($width === "auto") { |
|
114 | 114 | |
115 | - if ( $lm === "auto" ) |
|
115 | + if ($lm === "auto") |
|
116 | 116 | $lm = 0; |
117 | - if ( $rm === "auto" ) |
|
117 | + if ($rm === "auto") |
|
118 | 118 | $rm = 0; |
119 | - if ( $left === "auto" ) |
|
119 | + if ($left === "auto") |
|
120 | 120 | $left = 0; |
121 | - if ( $right === "auto" ) |
|
121 | + if ($right === "auto") |
|
122 | 122 | $right = 0; |
123 | 123 | |
124 | 124 | $width = $diff; |
125 | 125 | |
126 | - } else if ( $left === "auto" ) { |
|
127 | - if ( $lm === "auto" ) |
|
126 | + } else if ($left === "auto") { |
|
127 | + if ($lm === "auto") |
|
128 | 128 | $lm = 0; |
129 | - if ( $rm === "auto" ) |
|
129 | + if ($rm === "auto") |
|
130 | 130 | $rm = 0; |
131 | - if ( $right === "auto" ) |
|
131 | + if ($right === "auto") |
|
132 | 132 | $right = 0; |
133 | 133 | |
134 | 134 | $left = $diff; |
135 | 135 | |
136 | - } else if ( $right === "auto" ) { |
|
136 | + } else if ($right === "auto") { |
|
137 | 137 | |
138 | - if ( $lm === "auto" ) |
|
138 | + if ($lm === "auto") |
|
139 | 139 | $lm = 0; |
140 | - if ( $rm === "auto" ) |
|
140 | + if ($rm === "auto") |
|
141 | 141 | $rm = 0; |
142 | 142 | |
143 | 143 | $right = $diff; |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | } else { |
147 | 147 | |
148 | 148 | // Find auto properties and get them to take up the slack |
149 | - if ( $width === "auto" ) |
|
149 | + if ($width === "auto") |
|
150 | 150 | $width = $diff; |
151 | 151 | |
152 | - else if ( $lm === "auto" && $rm === "auto" ) |
|
152 | + else if ($lm === "auto" && $rm === "auto") |
|
153 | 153 | $lm = $rm = round($diff / 2); |
154 | 154 | |
155 | - else if ( $lm === "auto" ) |
|
155 | + else if ($lm === "auto") |
|
156 | 156 | $lm = $diff; |
157 | 157 | |
158 | - else if ( $rm === "auto" ) |
|
158 | + else if ($rm === "auto") |
|
159 | 159 | $rm = $diff; |
160 | 160 | } |
161 | 161 | |
@@ -176,11 +176,11 @@ discard block |
||
176 | 176 | $style = $this->_frame->get_style(); |
177 | 177 | $cb = $this->_frame->get_containing_block(); |
178 | 178 | |
179 | - if ( !isset($cb["w"]) ) |
|
179 | + if (!isset($cb["w"])) |
|
180 | 180 | throw new DOMPDF_Exception("Box property calculation requires containing block width"); |
181 | 181 | |
182 | 182 | // Treat width 100% as auto |
183 | - if ( $style->width === "100%" ) |
|
183 | + if ($style->width === "100%") |
|
184 | 184 | $width = "auto"; |
185 | 185 | else |
186 | 186 | $width = $style->length_in_pt($style->width, $cb["w"]); |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | $min_width = $style->length_in_pt($style->min_width, $cb["w"]); |
192 | 192 | $max_width = $style->length_in_pt($style->max_width, $cb["w"]); |
193 | 193 | |
194 | - if ( $max_width !== "none" && $min_width > $max_width) |
|
194 | + if ($max_width !== "none" && $min_width > $max_width) |
|
195 | 195 | // Swap 'em |
196 | 196 | list($max_width, $min_width) = array($min_width, $max_width); |
197 | 197 | |
198 | - if ( $max_width !== "none" && $width > $max_width ) |
|
198 | + if ($max_width !== "none" && $width > $max_width) |
|
199 | 199 | extract($this->_calculate_width($max_width)); |
200 | 200 | |
201 | - if ( $width < $min_width ) |
|
201 | + if ($width < $min_width) |
|
202 | 202 | extract($this->_calculate_width($min_width)); |
203 | 203 | |
204 | 204 | return array($width, $margin_left, $margin_right, $left, $right); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $margin_top = $style->length_in_pt($style->margin_top, $cb["h"]); |
236 | 236 | $margin_bottom = $style->length_in_pt($style->margin_bottom, $cb["h"]); |
237 | 237 | |
238 | - if ( $style->position === "absolute" || $style->position === "fixed" ) { |
|
238 | + if ($style->position === "absolute" || $style->position === "fixed") { |
|
239 | 239 | |
240 | 240 | // see http://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-height |
241 | 241 | |
@@ -253,87 +253,87 @@ discard block |
||
253 | 253 | |
254 | 254 | $diff = $cb["h"] - $sum; |
255 | 255 | |
256 | - if ( $diff > 0 ) { |
|
256 | + if ($diff > 0) { |
|
257 | 257 | |
258 | - if ( $height === "auto" && $top === "auto" && $bottom === "auto" ) { |
|
258 | + if ($height === "auto" && $top === "auto" && $bottom === "auto") { |
|
259 | 259 | |
260 | - if ( $margin_top === "auto" ) |
|
260 | + if ($margin_top === "auto") |
|
261 | 261 | $margin_top = 0; |
262 | - if ( $margin_bottom === "auto" ) |
|
262 | + if ($margin_bottom === "auto") |
|
263 | 263 | $margin_bottom = 0; |
264 | 264 | |
265 | 265 | $height = $diff; |
266 | 266 | |
267 | - } else if ( $height === "auto" && $top === "auto" ) { |
|
267 | + } else if ($height === "auto" && $top === "auto") { |
|
268 | 268 | |
269 | - if ( $margin_top === "auto" ) |
|
269 | + if ($margin_top === "auto") |
|
270 | 270 | $margin_top = 0; |
271 | - if ( $margin_bottom === "auto" ) |
|
271 | + if ($margin_bottom === "auto") |
|
272 | 272 | $margin_bottom = 0; |
273 | 273 | |
274 | 274 | $height = $content_height; |
275 | 275 | $top = $diff - $content_height; |
276 | 276 | |
277 | - } else if ( $height === "auto" && $bottom === "auto" ) { |
|
277 | + } else if ($height === "auto" && $bottom === "auto") { |
|
278 | 278 | |
279 | - if ( $margin_top === "auto" ) |
|
279 | + if ($margin_top === "auto") |
|
280 | 280 | $margin_top = 0; |
281 | - if ( $margin_bottom === "auto" ) |
|
281 | + if ($margin_bottom === "auto") |
|
282 | 282 | $margin_bottom = 0; |
283 | 283 | |
284 | 284 | $height = $content_height; |
285 | 285 | $bottom = $diff - $content_height; |
286 | 286 | |
287 | - } else if ( $top === "auto" && $bottom === "auto" ) { |
|
287 | + } else if ($top === "auto" && $bottom === "auto") { |
|
288 | 288 | |
289 | - if ( $margin_top === "auto" ) |
|
289 | + if ($margin_top === "auto") |
|
290 | 290 | $margin_top = 0; |
291 | - if ( $margin_bottom === "auto" ) |
|
291 | + if ($margin_bottom === "auto") |
|
292 | 292 | $margin_bottom = 0; |
293 | 293 | |
294 | 294 | $bottom = $diff; |
295 | 295 | |
296 | - } else if ( $top === "auto" ) { |
|
296 | + } else if ($top === "auto") { |
|
297 | 297 | |
298 | - if ( $margin_top === "auto" ) |
|
298 | + if ($margin_top === "auto") |
|
299 | 299 | $margin_top = 0; |
300 | - if ( $margin_bottom === "auto" ) |
|
300 | + if ($margin_bottom === "auto") |
|
301 | 301 | $margin_bottom = 0; |
302 | 302 | |
303 | 303 | $top = $diff; |
304 | 304 | |
305 | - } else if ( $height === "auto" ) { |
|
305 | + } else if ($height === "auto") { |
|
306 | 306 | |
307 | - if ( $margin_top === "auto" ) |
|
307 | + if ($margin_top === "auto") |
|
308 | 308 | $margin_top = 0; |
309 | - if ( $margin_bottom === "auto" ) |
|
309 | + if ($margin_bottom === "auto") |
|
310 | 310 | $margin_bottom = 0; |
311 | 311 | |
312 | 312 | $height = $diff; |
313 | 313 | |
314 | - } else if ( $bottom === "auto" ) { |
|
314 | + } else if ($bottom === "auto") { |
|
315 | 315 | |
316 | - if ( $margin_top === "auto" ) |
|
316 | + if ($margin_top === "auto") |
|
317 | 317 | $margin_top = 0; |
318 | - if ( $margin_bottom === "auto" ) |
|
318 | + if ($margin_bottom === "auto") |
|
319 | 319 | $margin_bottom = 0; |
320 | 320 | |
321 | 321 | $bottom = $diff; |
322 | 322 | |
323 | 323 | } else { |
324 | 324 | |
325 | - if ( $style->overflow === "visible" ) { |
|
325 | + if ($style->overflow === "visible") { |
|
326 | 326 | |
327 | 327 | // set all autos to zero |
328 | - if ( $margin_top === "auto" ) |
|
328 | + if ($margin_top === "auto") |
|
329 | 329 | $margin_top = 0; |
330 | - if ( $margin_bottom === "auto" ) |
|
330 | + if ($margin_bottom === "auto") |
|
331 | 331 | $margin_bottom = 0; |
332 | - if ( $top === "auto" ) |
|
332 | + if ($top === "auto") |
|
333 | 333 | $top = 0; |
334 | - if ( $bottom === "auto" ) |
|
334 | + if ($bottom === "auto") |
|
335 | 335 | $bottom = 0; |
336 | - if ( $height === "auto" ) |
|
336 | + if ($height === "auto") |
|
337 | 337 | $height = $content_height; |
338 | 338 | |
339 | 339 | } |
@@ -346,44 +346,44 @@ discard block |
||
346 | 346 | } else { |
347 | 347 | |
348 | 348 | // Expand the height if overflow is visible |
349 | - if ( $height == "auto" && $content_height > $height && $style->overflow === "visible" ) |
|
349 | + if ($height == "auto" && $content_height > $height && $style->overflow === "visible") |
|
350 | 350 | $height = $content_height; |
351 | 351 | |
352 | 352 | // FIXME: this should probably be moved to a seperate function as per |
353 | 353 | // _calculate_restricted_width |
354 | 354 | |
355 | 355 | // Only handle min/max height if the height is independent of the frame's content |
356 | - if ( !($style->overflow === "visible" || |
|
357 | - ($style->overflow === "hidden" && $height === "auto")) ) { |
|
356 | + if (!($style->overflow === "visible" || |
|
357 | + ($style->overflow === "hidden" && $height === "auto"))) { |
|
358 | 358 | |
359 | 359 | $min_height = $style->min_height; |
360 | 360 | $max_height = $style->max_height; |
361 | 361 | |
362 | - if ( isset($cb["h"]) ) { |
|
362 | + if (isset($cb["h"])) { |
|
363 | 363 | $min_height = $style->length_in_pt($min_height, $cb["h"]); |
364 | 364 | $max_height = $style->length_in_pt($max_height, $cb["h"]); |
365 | 365 | |
366 | - } else if ( isset($cb["w"]) ) { |
|
366 | + } else if (isset($cb["w"])) { |
|
367 | 367 | |
368 | - if ( mb_strpos($min_height, "%") !== false ) |
|
368 | + if (mb_strpos($min_height, "%") !== false) |
|
369 | 369 | $min_height = 0; |
370 | 370 | else |
371 | 371 | $min_height = $style->length_in_pt($min_height, $cb["w"]); |
372 | 372 | |
373 | - if ( mb_strpos($max_height, "%") !== false ) |
|
373 | + if (mb_strpos($max_height, "%") !== false) |
|
374 | 374 | $max_height = "none"; |
375 | 375 | else |
376 | 376 | $max_height = $style->length_in_pt($max_height, $cb["w"]); |
377 | 377 | } |
378 | 378 | |
379 | - if ( $max_height !== "none" && $min_height > $max_height ) |
|
379 | + if ($max_height !== "none" && $min_height > $max_height) |
|
380 | 380 | // Swap 'em |
381 | 381 | list($max_height, $min_height) = array($min_height, $max_height); |
382 | 382 | |
383 | - if ( $max_height !== "none" && $height > $max_height ) |
|
383 | + if ($max_height !== "none" && $height > $max_height) |
|
384 | 384 | $height = $max_height; |
385 | 385 | |
386 | - if ( $height < $min_height ) |
|
386 | + if ($height < $min_height) |
|
387 | 387 | $height = $min_height; |
388 | 388 | } |
389 | 389 | |
@@ -413,8 +413,8 @@ discard block |
||
413 | 413 | |
414 | 414 | // Move each child over by $dx |
415 | 415 | $dx = $width - $line["w"]; |
416 | - foreach($line["frames"] as $frame) |
|
417 | - $frame->set_position( $frame->get_position("x") + $dx ); |
|
416 | + foreach ($line["frames"] as $frame) |
|
417 | + $frame->set_position($frame->get_position("x") + $dx); |
|
418 | 418 | |
419 | 419 | } |
420 | 420 | break; |
@@ -425,19 +425,19 @@ discard block |
||
425 | 425 | |
426 | 426 | // Only set the spacing if the line is long enough. This is really |
427 | 427 | // just an aesthetic choice ;) |
428 | - if ( $line["w"] > self::MIN_JUSTIFY_WIDTH * $width ) { |
|
428 | + if ($line["w"] > self::MIN_JUSTIFY_WIDTH * $width) { |
|
429 | 429 | // Set the spacing for each child |
430 | - if ( $line["wc"] > 1 ) |
|
430 | + if ($line["wc"] > 1) |
|
431 | 431 | $spacing = ($width - $line["w"]) / ($line["wc"] - 1); |
432 | 432 | else |
433 | 433 | $spacing = 0; |
434 | 434 | |
435 | 435 | $dx = 0; |
436 | - foreach($line["frames"] as $frame) { |
|
437 | - if ( !$frame instanceof Text_Frame_Decorator ) |
|
436 | + foreach ($line["frames"] as $frame) { |
|
437 | + if (!$frame instanceof Text_Frame_Decorator) |
|
438 | 438 | continue; |
439 | 439 | |
440 | - $frame->set_position( $frame->get_position("x") + $dx ); |
|
440 | + $frame->set_position($frame->get_position("x") + $dx); |
|
441 | 441 | $frame->set_text_spacing($spacing); |
442 | 442 | $dx += mb_substr_count($frame->get_text(), " ") * $spacing; |
443 | 443 | } |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | // Centre each line by moving each frame in the line by: |
456 | 456 | $dx = ($width - $line["w"]) / 2; |
457 | 457 | foreach ($line["frames"] as $frame) |
458 | - $frame->set_position( $frame->get_position("x") + $dx ); |
|
458 | + $frame->set_position($frame->get_position("x") + $dx); |
|
459 | 459 | } |
460 | 460 | break; |
461 | 461 | } |
@@ -466,12 +466,12 @@ discard block |
||
466 | 466 | */ |
467 | 467 | function vertical_align() { |
468 | 468 | // Align each child vertically after each line is reflowed |
469 | - foreach ( $this->_frame->get_lines() as $i => $line ) { |
|
469 | + foreach ($this->_frame->get_lines() as $i => $line) { |
|
470 | 470 | |
471 | - foreach ( $line["frames"] as $frame ) { |
|
471 | + foreach ($line["frames"] as $frame) { |
|
472 | 472 | $style = $frame->get_style(); |
473 | 473 | |
474 | - if ( $style->display !== "inline" && $style->display !== "text" ) |
|
474 | + if ($style->display !== "inline" && $style->display !== "text") |
|
475 | 475 | continue; |
476 | 476 | |
477 | 477 | $align = $style->vertical_align; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | $page->check_forced_page_break($this->_frame); |
524 | 524 | |
525 | 525 | // Bail if the page is full |
526 | - if ( $page->is_full() ) |
|
526 | + if ($page->is_full()) |
|
527 | 527 | return; |
528 | 528 | |
529 | 529 | // Collapse margins if required |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | $style->width = $w; |
541 | 541 | $style->margin_left = $left_margin."pt"; |
542 | 542 | $style->margin_right = $right_margin."pt"; |
543 | - $style->left = $left ."pt"; |
|
544 | - $style->right = $right . "pt"; |
|
543 | + $style->left = $left."pt"; |
|
544 | + $style->right = $right."pt"; |
|
545 | 545 | |
546 | 546 | // Update the position |
547 | 547 | $this->_frame->position(); |
@@ -572,24 +572,24 @@ discard block |
||
572 | 572 | $this->_frame->set_current_line($line_y); |
573 | 573 | |
574 | 574 | // Set the containing blocks and reflow each child |
575 | - foreach ( $this->_frame->get_children() as $child ) { |
|
575 | + foreach ($this->_frame->get_children() as $child) { |
|
576 | 576 | |
577 | 577 | // Bail out if the page is full |
578 | - if ( $page->is_full() ) |
|
578 | + if ($page->is_full()) |
|
579 | 579 | break; |
580 | 580 | |
581 | 581 | $child->set_containing_block($cb_x, $cb_y, $w, $cb_h); |
582 | 582 | $child->reflow(); |
583 | 583 | |
584 | 584 | // Don't add the child to the line if a page break has occurred |
585 | - if ( $page->check_page_break($child) ) |
|
585 | + if ($page->check_page_break($child)) |
|
586 | 586 | break; |
587 | 587 | |
588 | 588 | // If the frame is not absolutely positioned, It's okay to add the frame |
589 | 589 | // to the line |
590 | - if ( $child->get_style()->position !== "absolute" && |
|
591 | - $child->get_style()->position !== "fixed" ) { |
|
592 | - $this->_frame->add_frame_to_line( $child ); |
|
590 | + if ($child->get_style()->position !== "absolute" && |
|
591 | + $child->get_style()->position !== "fixed") { |
|
592 | + $this->_frame->add_frame_to_line($child); |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 |
@@ -57,7 +57,7 @@ |
||
57 | 57 | $style->width = $this->_frame->get_width(); |
58 | 58 | $this->_frame->position(); |
59 | 59 | |
60 | - if ( $style->list_style_position === "inside" ) { |
|
60 | + if ($style->list_style_position === "inside") { |
|
61 | 61 | $p = $this->_frame->find_block_parent(); |
62 | 62 | $p->add_frame_to_line($this->_frame); |
63 | 63 | } |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | $cb = $this->_frame->get_containing_block(); |
63 | 63 | |
64 | - foreach ( $this->_frame->get_children() as $child) { |
|
64 | + foreach ($this->_frame->get_children() as $child) { |
|
65 | 65 | // Bail if the page is full |
66 | - if ( $page->is_full() ) |
|
66 | + if ($page->is_full()) |
|
67 | 67 | return; |
68 | 68 | |
69 | 69 | $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - if ( $page->is_full() ) |
|
77 | + if ($page->is_full()) |
|
78 | 78 | return; |
79 | 79 | |
80 | 80 | $cellmap = $table->get_cellmap(); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | |
84 | 84 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
85 | 85 | |
86 | - if ( $table->get_style()->border_collapse === "collapse" ) |
|
86 | + if ($table->get_style()->border_collapse === "collapse") |
|
87 | 87 | // Unset our borders because our cells are now using them |
88 | 88 | $style->border_style = "none"; |
89 | 89 |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | list($x, $y, $w, $h) = $frame->get_padding_box(); |
55 | 55 | |
56 | 56 | // Draw our background, border and content |
57 | - if ( ($bg = $style->background_color) !== "transparent" ) { |
|
57 | + if (($bg = $style->background_color) !== "transparent") { |
|
58 | 58 | list($x, $y, $w, $h) = $frame->get_padding_box(); |
59 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
|
59 | + $this->_canvas->filled_rectangle($x, $y, $w, $h, $style->background_color); |
|
60 | 60 | } |
61 | 61 | |
62 | - if ( ($url = $style->background_image) && $url !== "none" ) { |
|
62 | + if (($url = $style->background_image) && $url !== "none") { |
|
63 | 63 | $this->_background_image($url, $x, $y, $w, $h, $style); |
64 | 64 | } |
65 | 65 | |
66 | - if ( $style->border_collapse !== "collapse" ) { |
|
66 | + if ($style->border_collapse !== "collapse") { |
|
67 | 67 | $this->_render_border($frame, "bevel"); |
68 | 68 | return; |
69 | 69 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | // Determine if this cell borders on the bottom of the table. If so, |
83 | 83 | // then we draw its bottom border. Otherwise the next row down will |
84 | 84 | // draw its top border instead. |
85 | - if (in_array( $num_rows - 1, $cells["rows"])) { |
|
85 | + if (in_array($num_rows - 1, $cells["rows"])) { |
|
86 | 86 | $draw_bottom = true; |
87 | 87 | $bottom_row = $cellmap->get_row($num_rows - 1); |
88 | 88 | } else |
@@ -90,27 +90,27 @@ discard block |
||
90 | 90 | |
91 | 91 | |
92 | 92 | // Draw the horizontal borders |
93 | - foreach ( $cells["columns"] as $j ) { |
|
93 | + foreach ($cells["columns"] as $j) { |
|
94 | 94 | $bp = $cellmap->get_border_properties($i, $j); |
95 | 95 | |
96 | 96 | $y = $top_row["y"] - $bp["top"]["width"] / 2; |
97 | 97 | |
98 | 98 | $col = $cellmap->get_column($j); |
99 | 99 | $x = $col["x"] - $bp["left"]["width"] / 2; |
100 | - $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"] ) / 2; |
|
100 | + $w = $col["used-width"] + ($bp["left"]["width"] + $bp["right"]["width"]) / 2; |
|
101 | 101 | |
102 | - if ( $bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0 ) { |
|
102 | + if ($bp["top"]["style"] !== "none" && $bp["top"]["width"] > 0) { |
|
103 | 103 | $widths = array($bp["top"]["width"], |
104 | 104 | $bp["right"]["width"], |
105 | 105 | $bp["bottom"]["width"], |
106 | 106 | $bp["left"]["width"]); |
107 | - $method = "_border_". $bp["top"]["style"]; |
|
107 | + $method = "_border_".$bp["top"]["style"]; |
|
108 | 108 | $this->$method($x, $y, $w, $bp["top"]["color"], $widths, "top", "square"); |
109 | 109 | } |
110 | 110 | |
111 | - if ( $draw_bottom ) { |
|
111 | + if ($draw_bottom) { |
|
112 | 112 | $bp = $cellmap->get_border_properties($num_rows - 1, $j); |
113 | - if ( $bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0 ) |
|
113 | + if ($bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0) |
|
114 | 114 | continue; |
115 | 115 | |
116 | 116 | $y = $bottom_row["y"] + $bottom_row["height"] + $bp["bottom"]["width"] / 2; |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | $bp["right"]["width"], |
120 | 120 | $bp["bottom"]["width"], |
121 | 121 | $bp["left"]["width"]); |
122 | - $method = "_border_". $bp["bottom"]["style"]; |
|
122 | + $method = "_border_".$bp["bottom"]["style"]; |
|
123 | 123 | $this->$method($x, $y, $w, $bp["bottom"]["color"], $widths, "bottom", "square"); |
124 | 124 | |
125 | 125 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | $draw_right = false; |
137 | 137 | |
138 | 138 | // Draw the vertical borders |
139 | - foreach ( $cells["rows"] as $i ) { |
|
139 | + foreach ($cells["rows"] as $i) { |
|
140 | 140 | $bp = $cellmap->get_border_properties($i, $j); |
141 | 141 | |
142 | 142 | $x = $left_col["x"] - $bp["left"]["width"] / 2; |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | $row = $cellmap->get_row($i); |
145 | 145 | |
146 | 146 | $y = $row["y"] - $bp["top"]["width"] / 2; |
147 | - $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"])/ 2; |
|
147 | + $h = $row["height"] + ($bp["top"]["width"] + $bp["bottom"]["width"]) / 2; |
|
148 | 148 | |
149 | - if ( $bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0 ) { |
|
149 | + if ($bp["left"]["style"] !== "none" && $bp["left"]["width"] > 0) { |
|
150 | 150 | |
151 | 151 | $widths = array($bp["top"]["width"], |
152 | 152 | $bp["right"]["width"], |
153 | 153 | $bp["bottom"]["width"], |
154 | 154 | $bp["left"]["width"]); |
155 | 155 | |
156 | - $method = "_border_" . $bp["left"]["style"]; |
|
156 | + $method = "_border_".$bp["left"]["style"]; |
|
157 | 157 | $this->$method($x, $y, $h, $bp["left"]["color"], $widths, "left", "square"); |
158 | 158 | } |
159 | 159 | |
160 | - if ( $draw_right ) { |
|
160 | + if ($draw_right) { |
|
161 | 161 | $bp = $cellmap->get_border_properties($i, $num_cols - 1); |
162 | - if ( $bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0 ) |
|
162 | + if ($bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0) |
|
163 | 163 | continue; |
164 | 164 | |
165 | 165 | $x = $right_col["x"] + $right_col["used-width"] + $bp["right"]["width"] / 2; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $bp["bottom"]["width"], |
170 | 170 | $bp["left"]["width"]); |
171 | 171 | |
172 | - $method = "_border_" . $bp["right"]["style"]; |
|
172 | + $method = "_border_".$bp["right"]["style"]; |
|
173 | 173 | $this->$method($x, $y, $h, $bp["right"]["color"], $widths, "right", "square"); |
174 | 174 | |
175 | 175 | } |
@@ -54,7 +54,7 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | function evaluate($code, $vars = array()) { |
57 | - if ( !DOMPDF_ENABLE_PHP ) |
|
57 | + if (!DOMPDF_ENABLE_PHP) |
|
58 | 58 | return; |
59 | 59 | |
60 | 60 | // Set up some variables for the inline code |
@@ -135,10 +135,10 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function build_tree() { |
137 | 137 | $html = $this->_dom->getElementsByTagName("html")->item(0); |
138 | - if ( is_null($html) ) |
|
138 | + if (is_null($html)) |
|
139 | 139 | $html = $this->_dom->firstChild; |
140 | 140 | |
141 | - if ( is_null($html) ) |
|
141 | + if (is_null($html)) |
|
142 | 142 | throw new DOMPDF_Exception("Requested HTML document contains no data."); |
143 | 143 | |
144 | 144 | $this->_root = $this->_build_tree_r($html); |
@@ -160,9 +160,9 @@ discard block |
||
160 | 160 | |
161 | 161 | $frame = new Frame($node); |
162 | 162 | $id = $frame->get_id(); |
163 | - $this->_registry[ $id ] = $frame; |
|
163 | + $this->_registry[$id] = $frame; |
|
164 | 164 | |
165 | - if ( !$node->hasChildNodes() ) |
|
165 | + if (!$node->hasChildNodes()) |
|
166 | 166 | return $frame; |
167 | 167 | |
168 | 168 | // Fixes 'cannot access undefined property for object with |
@@ -177,40 +177,40 @@ discard block |
||
177 | 177 | |
178 | 178 | foreach ($children as $child) { |
179 | 179 | // Skip non-displaying nodes |
180 | - if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
|
181 | - if ( mb_strtolower($child->nodeName) !== "head" && |
|
182 | - mb_strtolower($child->nodeName) !== "style" ) |
|
180 | + if (in_array(mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS)) { |
|
181 | + if (mb_strtolower($child->nodeName) !== "head" && |
|
182 | + mb_strtolower($child->nodeName) !== "style") |
|
183 | 183 | $child->parentNode->removeChild($child); |
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | |
187 | 187 | // Skip empty text nodes |
188 | - if ( $child->nodeName === "#text" && $child->nodeValue == "" ) { |
|
188 | + if ($child->nodeName === "#text" && $child->nodeValue == "") { |
|
189 | 189 | $child->parentNode->removeChild($child); |
190 | 190 | continue; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Skip empty image nodes |
194 | - if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) { |
|
194 | + if ($child->nodeName === "img" && $child->getAttribute("src") == "") { |
|
195 | 195 | $child->parentNode->removeChild($child); |
196 | 196 | continue; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Add a container frame for images |
200 | - if ( $child->nodeName === "img" ) { |
|
200 | + if ($child->nodeName === "img") { |
|
201 | 201 | $img_node = $child->ownerDocument->createElement("img_inner"); |
202 | 202 | |
203 | 203 | // Move attributes to inner node |
204 | - foreach ( $child->attributes as $attr => $attr_node ) { |
|
204 | + foreach ($child->attributes as $attr => $attr_node) { |
|
205 | 205 | // Skip style, but move all other attributes |
206 | - if ( $attr === "style" ) |
|
206 | + if ($attr === "style") |
|
207 | 207 | continue; |
208 | 208 | |
209 | 209 | $img_node->setAttribute($attr, $attr_node->value); |
210 | 210 | } |
211 | 211 | |
212 | - foreach ( $child->attributes as $attr => $node ) { |
|
213 | - if ( $attr === "style" ) |
|
212 | + foreach ($child->attributes as $attr => $node) { |
|
213 | + if ($attr === "style") |
|
214 | 214 | continue; |
215 | 215 | $child->removeAttribute($attr); |
216 | 216 | } |