@@ -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 |
@@ -56,7 +56,7 @@ |
||
56 | 56 | $cb = $this->_frame->get_containing_block(); |
57 | 57 | $p = $this->_frame->get_prev_sibling(); |
58 | 58 | |
59 | - if ( $p ) |
|
59 | + if ($p) |
|
60 | 60 | $y = $p->get_position("y") + $p->get_margin_height(); |
61 | 61 | |
62 | 62 | else |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @param float $h |
118 | 118 | */ |
119 | 119 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
120 | - parent::set_containing_block($x,$y,$w,$h); |
|
120 | + parent::set_containing_block($x, $y, $w, $h); |
|
121 | 121 | $w = $this->get_containing_block("w"); |
122 | - if ( isset($h) ) |
|
122 | + if (isset($h)) |
|
123 | 123 | $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
124 | 124 | } |
125 | 125 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | function check_forced_page_break(Frame $frame) { |
177 | 177 | |
178 | 178 | // Skip check if page is already split |
179 | - if ( $this->_page_full ) |
|
179 | + if ($this->_page_full) |
|
180 | 180 | return; |
181 | 181 | |
182 | 182 | $block_types = array("block", "list-item", "table"); |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | |
185 | 185 | $style = $frame->get_style(); |
186 | 186 | |
187 | - if ( !in_array($style->display, $block_types) ) |
|
187 | + if (!in_array($style->display, $block_types)) |
|
188 | 188 | return false; |
189 | 189 | |
190 | 190 | // Find the previous block-level sibling |
191 | 191 | $prev = $frame->get_prev_sibling(); |
192 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
192 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
193 | 193 | $prev = $prev->get_prev_sibling(); |
194 | 194 | |
195 | - if ( in_array($style->page_break_before, $page_breaks) ) { |
|
195 | + if (in_array($style->page_break_before, $page_breaks)) { |
|
196 | 196 | |
197 | 197 | // Prevent cascading splits |
198 | 198 | $frame->split(); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | return true; |
204 | 204 | } |
205 | 205 | |
206 | - if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
|
206 | + if (($prev && in_array($prev->get_style()->page_break_after, $page_breaks))) { |
|
207 | 207 | // Prevent cascading splits |
208 | 208 | $frame->split(); |
209 | 209 | $prev->get_style()->page_break_after = "auto"; |
@@ -270,32 +270,32 @@ discard block |
||
270 | 270 | */ |
271 | 271 | |
272 | 272 | $block_types = array("block", "list-item", "table"); |
273 | - dompdf_debug("page-break", "_page_break_allowed(" . $frame->get_node()->nodeName. ")"); |
|
273 | + dompdf_debug("page-break", "_page_break_allowed(".$frame->get_node()->nodeName.")"); |
|
274 | 274 | $display = $frame->get_style()->display; |
275 | 275 | |
276 | 276 | // Block Frames (1): |
277 | - if ( in_array($display, $block_types) ) { |
|
277 | + if (in_array($display, $block_types)) { |
|
278 | 278 | |
279 | 279 | // Avoid breaks within table-cells |
280 | - if ( $this->_in_table ) { |
|
281 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
280 | + if ($this->_in_table) { |
|
281 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Rules A & B |
286 | 286 | |
287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
287 | + if ($frame->get_style()->page_break_before === "avoid") { |
|
288 | 288 | dompdf_debug("page-break", "before: avoid"); |
289 | 289 | return false; |
290 | 290 | } |
291 | 291 | |
292 | 292 | // Find the preceeding block-level sibling |
293 | 293 | $prev = $frame->get_prev_sibling(); |
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
294 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
295 | 295 | $prev = $prev->get_prev_sibling(); |
296 | 296 | |
297 | 297 | // Does the previous element allow a page break after? |
298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
298 | + if ($prev && $prev->get_style()->page_break_after === "avoid") { |
|
299 | 299 | dompdf_debug("page-break", "after: avoid"); |
300 | 300 | return false; |
301 | 301 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | // If both $prev & $frame have the same parent, check the parent's |
304 | 304 | // page_break_inside property. |
305 | 305 | $parent = $frame->get_parent(); |
306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
306 | + if ($prev && $parent && $parent->get_style()->page_break_inside === "avoid") { |
|
307 | 307 | dompdf_debug("page-break", "parent inside: avoid"); |
308 | 308 | return false; |
309 | 309 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // To prevent cascading page breaks when a top-level element has |
312 | 312 | // page-break-inside: avoid, ensure that at least one frame is |
313 | 313 | // on the page before splitting. |
314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
314 | + if ($parent->get_node()->nodeName === "body" && !$prev) { |
|
315 | 315 | // We are the body's first child |
316 | 316 | dompdf_debug("page-break", "Body's first child."); |
317 | 317 | return false; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | // If the frame is the first block-level frame, use the value from |
321 | 321 | // $frame's parent instead. |
322 | - if ( !$prev && $parent ) |
|
323 | - return $this->_page_break_allowed( $parent ); |
|
322 | + if (!$prev && $parent) |
|
323 | + return $this->_page_break_allowed($parent); |
|
324 | 324 | |
325 | 325 | dompdf_debug("page-break", "block: break allowed"); |
326 | 326 | return true; |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | // Inline frames (2): |
331 | - else if ( in_array($display, Style::$INLINE_TYPES) ) { |
|
331 | + else if (in_array($display, Style::$INLINE_TYPES)) { |
|
332 | 332 | |
333 | 333 | // Avoid breaks within table-cells |
334 | - if ( $this->_in_table ) { |
|
335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
334 | + if ($this->_in_table) { |
|
335 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Rule C |
340 | 340 | $block_parent = $frame->find_block_parent(); |
341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
341 | + if (count($block_parent->get_lines()) < $frame->get_style()->orphans) { |
|
342 | 342 | dompdf_debug("page-break", "orphans"); |
343 | 343 | return false; |
344 | 344 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // Rule D |
350 | 350 | $p = $block_parent; |
351 | 351 | while ($p) { |
352 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
352 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
353 | 353 | dompdf_debug("page-break", "parent->inside: avoid"); |
354 | 354 | return false; |
355 | 355 | } |
@@ -360,32 +360,32 @@ discard block |
||
360 | 360 | // page-break-inside: avoid, ensure that at least one frame with |
361 | 361 | // some content is on the page before splitting. |
362 | 362 | $prev = $frame->get_prev_sibling(); |
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
363 | + while ($prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "")) |
|
364 | 364 | $prev = $prev->get_prev_sibling(); |
365 | 365 | |
366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
366 | + if ($block_parent->get_node()->nodeName === "body" && !$prev) { |
|
367 | 367 | // We are the body's first child |
368 | 368 | dompdf_debug("page-break", "Body's first child."); |
369 | 369 | return false; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // Skip breaks on empty text nodes |
373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
374 | - $frame->get_node()->nodeValue == "" ) |
|
373 | + if ($frame->get_node()->nodeName === "#text" && |
|
374 | + $frame->get_node()->nodeValue == "") |
|
375 | 375 | return false; |
376 | 376 | |
377 | 377 | dompdf_debug("page-break", "inline: break allowed"); |
378 | 378 | return true; |
379 | 379 | |
380 | 380 | // Table-rows |
381 | - } else if ( $display === "table-row" ) { |
|
381 | + } else if ($display === "table-row") { |
|
382 | 382 | |
383 | 383 | // Simply check if the parent table's page_break_inside property is |
384 | 384 | // not 'avoid' |
385 | 385 | $p = Table_Frame_Decorator::find_parent_table($frame); |
386 | 386 | |
387 | 387 | while ($p) { |
388 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
388 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
389 | 389 | dompdf_debug("page-break", "parent->inside: avoid"); |
390 | 390 | return false; |
391 | 391 | } |
@@ -393,28 +393,28 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | // Avoid breaking after the first row of a table |
396 | - if ( $p && $p->get_first_child() === $frame) { |
|
396 | + if ($p && $p->get_first_child() === $frame) { |
|
397 | 397 | dompdf_debug("page-break", "table: first-row"); |
398 | 398 | return false; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // If this is a nested table, prevent the page from breaking |
402 | - if ( $this->_in_table > 1 ) { |
|
402 | + if ($this->_in_table > 1) { |
|
403 | 403 | dompdf_debug("page-break", "table: nested table"); |
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
407 | + dompdf_debug("page-break", "table-row/row-groups: break allowed"); |
|
408 | 408 | return true; |
409 | 409 | |
410 | - } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
|
410 | + } else if (in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) { |
|
411 | 411 | |
412 | 412 | // Disallow breaks at row-groups: only split at row boundaries |
413 | 413 | return false; |
414 | 414 | |
415 | 415 | } else { |
416 | 416 | |
417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
417 | + dompdf_debug("page-break", "? ".$frame->get_style()->display.""); |
|
418 | 418 | return false; |
419 | 419 | } |
420 | 420 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function check_page_break(Frame $frame) { |
432 | 432 | // Do not split if we have already |
433 | - if ( $this->_page_full ) |
|
433 | + if ($this->_page_full) |
|
434 | 434 | return false; |
435 | 435 | |
436 | 436 | // Determine the frame's maximum y value |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | // If a split is to occur here, then the bottom margins & paddings of all |
440 | 440 | // parents of $frame must fit on the page as well: |
441 | 441 | $p = $frame->get_parent(); |
442 | - while ( $p ) { |
|
442 | + while ($p) { |
|
443 | 443 | $style = $p->get_style(); |
444 | 444 | $max_y += $style->length_in_pt(array($style->margin_bottom, |
445 | 445 | $style->padding_bottom, |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | |
450 | 450 | |
451 | 451 | // Check if $frame flows off the page |
452 | - if ( $max_y <= $this->_bottom_page_margin ) |
|
452 | + if ($max_y <= $this->_bottom_page_margin) |
|
453 | 453 | // no: do nothing |
454 | 454 | return false; |
455 | 455 | |
456 | 456 | dompdf_debug("page-break", "check_page_break"); |
457 | - dompdf_debug("page-break", "in_table: " . $this->_in_table); |
|
457 | + dompdf_debug("page-break", "in_table: ".$this->_in_table); |
|
458 | 458 | |
459 | 459 | |
460 | 460 | // yes: determine page break location |
@@ -463,42 +463,42 @@ discard block |
||
463 | 463 | |
464 | 464 | $in_table = $this->_in_table; |
465 | 465 | |
466 | - dompdf_debug("page-break","Starting search"); |
|
467 | - while ( $iter ) { |
|
466 | + dompdf_debug("page-break", "Starting search"); |
|
467 | + while ($iter) { |
|
468 | 468 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
469 | - if ( $iter === $this ) { |
|
469 | + if ($iter === $this) { |
|
470 | 470 | dompdf_debug("page-break", "reached root."); |
471 | 471 | // We've reached the root in our search. Just split at $frame. |
472 | 472 | break; |
473 | 473 | } |
474 | 474 | |
475 | - if ( $this->_page_break_allowed($iter) ) { |
|
476 | - dompdf_debug("page-break","break allowed, splitting."); |
|
475 | + if ($this->_page_break_allowed($iter)) { |
|
476 | + dompdf_debug("page-break", "break allowed, splitting."); |
|
477 | 477 | $iter->split(); |
478 | 478 | $this->_page_full = true; |
479 | 479 | $this->_in_table = $in_table; |
480 | 480 | return true; |
481 | 481 | } |
482 | 482 | |
483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
483 | + if (!$flg && $next = $iter->get_last_child()) { |
|
484 | 484 | dompdf_debug("page-break", "following last child."); |
485 | 485 | |
486 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
|
486 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES)) |
|
487 | 487 | $this->_in_table++; |
488 | 488 | |
489 | 489 | $iter = $next; |
490 | 490 | continue; |
491 | 491 | } |
492 | 492 | |
493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
493 | + if ($next = $iter->get_prev_sibling()) { |
|
494 | 494 | dompdf_debug("page-break", "following prev sibling."); |
495 | 495 | |
496 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
497 | - !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
496 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
497 | + !in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
498 | 498 | $this->_in_table++; |
499 | 499 | |
500 | - else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
501 | - in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
500 | + else if (!in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
501 | + in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
502 | 502 | $this->_in_table--; |
503 | 503 | |
504 | 504 | $iter = $next; |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | continue; |
507 | 507 | } |
508 | 508 | |
509 | - if ( $next = $iter->get_parent() ) { |
|
509 | + if ($next = $iter->get_parent()) { |
|
510 | 510 | dompdf_debug("page-break", "following parent."); |
511 | 511 | |
512 | - if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
512 | + if (in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
513 | 513 | $this->_in_table--; |
514 | 514 | |
515 | 515 | $iter = $next; |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | dompdf_debug("page-break", "no valid break found, just splitting."); |
528 | 528 | |
529 | 529 | // If we are in a table, backtrack to the nearest top-level table row |
530 | - if ( $this->_in_table ) { |
|
530 | + if ($this->_in_table) { |
|
531 | 531 | $num_tables = $this->_in_table - 1; |
532 | 532 | |
533 | 533 | $iter = $frame; |
534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
534 | + while ($iter && $num_tables && $iter->get_style->display !== "table") { |
|
535 | 535 | $iter = $iter->get_parent(); |
536 | 536 | $num_tables--; |
537 | 537 | } |
538 | 538 | |
539 | 539 | $iter = $frame; |
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
540 | + while ($iter && $iter->get_style()->display !== "table-row") |
|
541 | 541 | $iter = $iter->get_parent(); |
542 | 542 | |
543 | 543 | $iter->split(); |
@@ -53,13 +53,13 @@ discard block |
||
53 | 53 | $style = $this->_frame->get_style(); |
54 | 54 | |
55 | 55 | $top = $style->length_in_pt($style->top, $cb["w"]); |
56 | - $left = $style->length_in_pt($style->left, $cb["w"]); |
|
57 | - $right = $style->length_in_pt($style->right, $cb["w"]); |
|
56 | + $left = $style->length_in_pt($style->left, $cb["w"]); |
|
57 | + $right = $style->length_in_pt($style->right, $cb["w"]); |
|
58 | 58 | $bottom = $style->length_in_pt($style->bottom, $cb["w"]); |
59 | 59 | |
60 | 60 | $p = $this->_frame->find_block_parent(); |
61 | 61 | |
62 | - if ( $p ) { |
|
62 | + if ($p) { |
|
63 | 63 | |
64 | 64 | // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
65 | 65 | |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | |
73 | 73 | } |
74 | 74 | |
75 | - if ( isset($top) ) { |
|
75 | + if (isset($top)) { |
|
76 | 76 | $y += $top; |
77 | - } else if ( isset($bottom) ) { |
|
77 | + } else if (isset($bottom)) { |
|
78 | 78 | // FIXME: need to know this frame's height before we can do this correctly |
79 | 79 | } |
80 | 80 |