@@ -150,8 +150,9 @@ discard block |
||
150 | 150 | |
151 | 151 | $new_header = $header->deep_copy(); |
152 | 152 | |
153 | - if ( is_null($first_header) ) |
|
154 | - $first_header = $new_header; |
|
153 | + if ( is_null($first_header) ) { |
|
154 | + $first_header = $new_header; |
|
155 | + } |
|
155 | 156 | |
156 | 157 | $this->insert_child_before($new_header, $child); |
157 | 158 | } |
@@ -184,9 +185,10 @@ discard block |
||
184 | 185 | */ |
185 | 186 | static function find_parent_table(Frame $frame) { |
186 | 187 | |
187 | - while ( $frame = $frame->get_parent() ) |
|
188 | - if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
188 | + while ( $frame = $frame->get_parent() ) { |
|
189 | + if ( in_array($frame->get_style()->display, Style::$TABLE_TYPES) ) |
|
189 | 190 | break; |
191 | + } |
|
190 | 192 | |
191 | 193 | return $frame; |
192 | 194 | } |
@@ -279,8 +281,9 @@ discard block |
||
279 | 281 | // Lookup styles for tr tags. If the user wants styles to work |
280 | 282 | // better, they should make the tr explicit... I'm not going to |
281 | 283 | // try to guess what they intended. |
282 | - if ( $tr_style = $css->lookup("tr") ) |
|
283 | - $style->merge($tr_style); |
|
284 | + if ( $tr_style = $css->lookup("tr") ) { |
|
285 | + $style->merge($tr_style); |
|
286 | + } |
|
284 | 287 | |
285 | 288 | // Okay, I have absolutely no idea why I need this clone here, but |
286 | 289 | // if it's omitted, php (as of 2004-07-28) segfaults. |
@@ -302,16 +305,17 @@ discard block |
||
302 | 305 | |
303 | 306 | // Normalise other table parts (i.e. row groups) |
304 | 307 | foreach ($child->get_children() as $grandchild) { |
305 | - if ( $grandchild->get_style()->display === "table-row" ) |
|
306 | - $grandchild->normalise(); |
|
308 | + if ( $grandchild->get_style()->display === "table-row" ) { |
|
309 | + $grandchild->normalise(); |
|
310 | + } |
|
307 | 311 | } |
308 | 312 | |
309 | 313 | // Add headers and footers |
310 | - if ( $display === "table-header-group" ) |
|
311 | - $this->_headers[] = $child; |
|
312 | - |
|
313 | - else if ( $display === "table-footer-group" ) |
|
314 | - $this->_footers[] = $child; |
|
314 | + if ( $display === "table-header-group" ) { |
|
315 | + $this->_headers[] = $child; |
|
316 | + } else if ( $display === "table-footer-group" ) { |
|
317 | + $this->_footers[] = $child; |
|
318 | + } |
|
315 | 319 | } |
316 | 320 | } |
317 | 321 | |
@@ -322,8 +326,9 @@ discard block |
||
322 | 326 | $this->_cellmap->add_row(); |
323 | 327 | } |
324 | 328 | |
325 | - foreach ($erroneous_frames as $frame) |
|
326 | - $this->move_after($frame); |
|
329 | + foreach ($erroneous_frames as $frame) { |
|
330 | + $this->move_after($frame); |
|
331 | + } |
|
327 | 332 | |
328 | 333 | } |
329 | 334 |
@@ -109,11 +109,14 @@ discard block |
||
109 | 109 | $sheet = $style->get_stylesheet(); |
110 | 110 | |
111 | 111 | // Skip degenerate cases |
112 | - if ( $width == 0 || $height == 0 ) |
|
113 | - return; |
|
112 | + if ( $width == 0 || $height == 0 ) { |
|
113 | + return; |
|
114 | + } |
|
114 | 115 | |
115 | 116 | //debugpng |
116 | - if (DEBUGPNG) print '[_background_image '.$url.']'; |
|
117 | + if (DEBUGPNG) { |
|
118 | + print '[_background_image '.$url.']'; |
|
119 | + } |
|
117 | 120 | |
118 | 121 | list($img, $ext) = Image_Cache::resolve_url($url, |
119 | 122 | $sheet->get_protocol(), |
@@ -121,8 +124,9 @@ discard block |
||
121 | 124 | $sheet->get_base_path()); |
122 | 125 | |
123 | 126 | // Bail if the image is no good |
124 | - if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) |
|
125 | - return; |
|
127 | + if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) { |
|
128 | + return; |
|
129 | + } |
|
126 | 130 | |
127 | 131 | //Try to optimize away reading and composing of same background multiple times |
128 | 132 | //Postponing read with imagecreatefrom ...() |
@@ -446,16 +450,21 @@ discard block |
||
446 | 450 | } else { |
447 | 451 | $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png'; |
448 | 452 | //debugpng |
449 | - if (DEBUGPNG) print '[_background_image '.$tmp_file.']'; |
|
453 | + if (DEBUGPNG) { |
|
454 | + print '[_background_image '.$tmp_file.']'; |
|
455 | + } |
|
450 | 456 | |
451 | 457 | imagepng($bg, $tmp_file); |
452 | 458 | $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height); |
453 | 459 | |
454 | 460 | //debugpng |
455 | - if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']'; |
|
461 | + if (DEBUGPNG) { |
|
462 | + print '[_background_image unlink '.$tmp_file.']'; |
|
463 | + } |
|
456 | 464 | |
457 | - if (!DEBUGKEEPTEMP) |
|
458 | - unlink($tmp_file); |
|
465 | + if (!DEBUGKEEPTEMP) { |
|
466 | + unlink($tmp_file); |
|
467 | + } |
|
459 | 468 | } |
460 | 469 | } |
461 | 470 | |
@@ -467,10 +476,11 @@ discard block |
||
467 | 476 | protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") { |
468 | 477 | list($top, $right, $bottom, $left) = $widths; |
469 | 478 | |
470 | - if ( $$side < 2 ) |
|
471 | - $dash = array($$side, 2); |
|
472 | - else |
|
473 | - $dash = array($$side); |
|
479 | + if ( $$side < 2 ) { |
|
480 | + $dash = array($$side, 2); |
|
481 | + } else { |
|
482 | + $dash = array($$side); |
|
483 | + } |
|
474 | 484 | |
475 | 485 | |
476 | 486 | switch ($side) { |
@@ -536,8 +546,9 @@ discard block |
||
536 | 546 | $x + $length - $right, $y + $top, |
537 | 547 | $x + $left, $y + $top); |
538 | 548 | $this->_canvas->polygon($points, $color, null, null, true); |
539 | - } else |
|
540 | - $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
549 | + } else { |
|
550 | + $this->_canvas->filled_rectangle($x, $y, $length, $top, $color); |
|
551 | + } |
|
541 | 552 | |
542 | 553 | break; |
543 | 554 | |
@@ -548,8 +559,9 @@ discard block |
||
548 | 559 | $x + $length - $right, $y - $bottom, |
549 | 560 | $x + $left, $y - $bottom); |
550 | 561 | $this->_canvas->polygon($points, $color, null, null, true); |
551 | - } else |
|
552 | - $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
562 | + } else { |
|
563 | + $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color); |
|
564 | + } |
|
553 | 565 | |
554 | 566 | break; |
555 | 567 | |
@@ -560,8 +572,9 @@ discard block |
||
560 | 572 | $x + $left, $y + $length - $bottom, |
561 | 573 | $x + $left, $y + $top); |
562 | 574 | $this->_canvas->polygon($points, $color, null, null, true); |
563 | - } else |
|
564 | - $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
575 | + } else { |
|
576 | + $this->_canvas->filled_rectangle($x, $y, $left, $length, $color); |
|
577 | + } |
|
565 | 578 | |
566 | 579 | break; |
567 | 580 | |
@@ -572,8 +585,9 @@ discard block |
||
572 | 585 | $x - $right, $y + $length - $bottom, |
573 | 586 | $x - $right, $y + $top); |
574 | 587 | $this->_canvas->polygon($points, $color, null, null, true); |
575 | - } else |
|
576 | - $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
588 | + } else { |
|
589 | + $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color); |
|
590 | + } |
|
577 | 591 | |
578 | 592 | break; |
579 | 593 | |
@@ -784,15 +798,17 @@ discard block |
||
784 | 798 | } |
785 | 799 | |
786 | 800 | protected function _tint($c) { |
787 | - if ( !is_numeric($c) ) |
|
788 | - return $c; |
|
801 | + if ( !is_numeric($c) ) { |
|
802 | + return $c; |
|
803 | + } |
|
789 | 804 | |
790 | 805 | return min(1, $c + 0.66); |
791 | 806 | } |
792 | 807 | |
793 | 808 | protected function _shade($c) { |
794 | - if ( !is_numeric($c) ) |
|
795 | - return $c; |
|
809 | + if ( !is_numeric($c) ) { |
|
810 | + return $c; |
|
811 | + } |
|
796 | 812 | |
797 | 813 | return max(0, $c - 0.66); |
798 | 814 | } |
@@ -144,7 +144,9 @@ |
||
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if (DEBUGPNG) print $width.' '.$height.';'; |
|
147 | + if (DEBUGPNG) { |
|
148 | + print $width.' '.$height.';'; |
|
149 | + } |
|
148 | 150 | |
149 | 151 | // Synchronize the styles |
150 | 152 | $inner_style = $this->_frame->get_style(); |
@@ -58,24 +58,20 @@ |
||
58 | 58 | |
59 | 59 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
60 | 60 | |
61 | - if ( isset($class) && class_exists($class, false) ) |
|
62 | - $class .= "_Adapter"; |
|
63 | - |
|
64 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
65 | - class_exists("PDFLib", false) ) |
|
66 | - $class = "PDFLib_Adapter"; |
|
67 | - |
|
68 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) |
|
69 | - $class = "CPDF_Adapter"; |
|
70 | - |
|
71 | - else if ( ( $backend === "tcpdf") ) |
|
72 | - $class = "TCPDF_Adapter"; |
|
73 | - |
|
74 | - else if ( $backend === "gd" ) |
|
75 | - $class = "GD_Adapter"; |
|
76 | - |
|
77 | - else |
|
78 | - $class = "CPDF_Adapter"; |
|
61 | + if ( isset($class) && class_exists($class, false) ) { |
|
62 | + $class .= "_Adapter"; |
|
63 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
64 | + class_exists("PDFLib", false) ) { |
|
65 | + $class = "PDFLib_Adapter"; |
|
66 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) { |
|
67 | + $class = "CPDF_Adapter"; |
|
68 | + } else if ( ( $backend === "tcpdf") ) { |
|
69 | + $class = "TCPDF_Adapter"; |
|
70 | + } else if ( $backend === "gd" ) { |
|
71 | + $class = "GD_Adapter"; |
|
72 | + } else { |
|
73 | + $class = "CPDF_Adapter"; |
|
74 | + } |
|
79 | 75 | |
80 | 76 | return new $class($paper, $orientation); |
81 | 77 |
@@ -216,13 +216,15 @@ |
||
216 | 216 | * @see save_font_families() |
217 | 217 | */ |
218 | 218 | static function load_font_families() { |
219 | - if ( !is_readable(self::CACHE_FILE) ) |
|
220 | - return; |
|
219 | + if ( !is_readable(self::CACHE_FILE) ) { |
|
220 | + return; |
|
221 | + } |
|
221 | 222 | |
222 | 223 | $data = file_get_contents(self::CACHE_FILE); |
223 | 224 | |
224 | - if ( $data != "" ) |
|
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
225 | + if ( $data != "" ) { |
|
226 | + eval ('self::$_font_lookup = ' . $data . ";"); |
|
227 | + } |
|
226 | 228 | } |
227 | 229 | |
228 | 230 | /** |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
59 | 59 | } |
60 | 60 | |
61 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
62 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
61 | + if ( ($url = $style->background_image) && $url !== "none" ) { |
|
62 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
63 | + } |
|
63 | 64 | |
64 | 65 | |
65 | 66 | $this->_render_border($frame); |
@@ -81,8 +82,9 @@ discard block |
||
81 | 82 | foreach ($bp as $side => $props) { |
82 | 83 | list($x, $y, $w, $h) = $bbox; |
83 | 84 | |
84 | - if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) |
|
85 | - continue; |
|
85 | + if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) { |
|
86 | + continue; |
|
87 | + } |
|
86 | 88 | |
87 | 89 | |
88 | 90 | switch($side) { |
@@ -62,8 +62,9 @@ |
||
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - if ( $frame->get_parent() !== $this ) |
|
66 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
65 | + if ( $frame->get_parent() !== $this ) { |
|
66 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
69 | 70 | $this->get_parent()->insert_child_after($split, $this); |
@@ -100,10 +100,11 @@ discard block |
||
100 | 100 | break; |
101 | 101 | |
102 | 102 | case "inline": |
103 | - if ( $frame->get_node()->nodeName === "#text" ) |
|
104 | - $this->_render_frame("text", $frame); |
|
105 | - else |
|
106 | - $this->_render_frame("inline", $frame); |
|
103 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
104 | + $this->_render_frame("text", $frame); |
|
105 | + } else { |
|
106 | + $this->_render_frame("inline", $frame); |
|
107 | + } |
|
107 | 108 | break; |
108 | 109 | |
109 | 110 | case "table-cell": |
@@ -126,9 +127,7 @@ discard block |
||
126 | 127 | $node->getAttribute("language") === "php" ) { |
127 | 128 | // Evaluate embedded php scripts |
128 | 129 | $this->_render_frame("php", $frame); |
129 | - } |
|
130 | - |
|
131 | - elseif ( $node->getAttribute("type") === "text/javascript" || |
|
130 | + } elseif ( $node->getAttribute("type") === "text/javascript" || |
|
132 | 131 | $node->getAttribute("language") === "javascript" ) { |
133 | 132 | // Insert JavaScript |
134 | 133 | $this->_render_frame("javascript", $frame); |
@@ -146,8 +145,9 @@ discard block |
||
146 | 145 | // Check for begin frame callback |
147 | 146 | $this->_check_callbacks("begin_frame", $frame); |
148 | 147 | |
149 | - foreach ($frame->get_children() as $child) |
|
150 | - $this->render($child); |
|
148 | + foreach ($frame->get_children() as $child) { |
|
149 | + $this->render($child); |
|
150 | + } |
|
151 | 151 | |
152 | 152 | // Check for end frame callback |
153 | 153 | $this->_check_callbacks("end_frame", $frame); |
@@ -52,8 +52,10 @@ discard block |
||
52 | 52 | function render(Frame $frame) { |
53 | 53 | $style = $frame->get_style(); |
54 | 54 | |
55 | - if ( !$frame->get_first_child() ) |
|
56 | - return; // No children, no service |
|
55 | + if ( !$frame->get_first_child() ) { |
|
56 | + return; |
|
57 | + } |
|
58 | + // No children, no service |
|
57 | 59 | |
58 | 60 | // Draw the left border if applicable |
59 | 61 | $bp = $style->get_border_properties(); |
@@ -87,8 +89,9 @@ discard block |
||
87 | 89 | // borders on this line. |
88 | 90 | |
89 | 91 | // Background: |
90 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
91 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
92 | + if ( ($bg = $style->background_color) !== "transparent" ) { |
|
93 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
94 | + } |
|
92 | 95 | |
93 | 96 | if ( ($url = $style->background_image) && $url !== "none" ) { |
94 | 97 | $this->_background_image($url, $x, $y, $w, $h, $style); |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | // Handle anchors & links |
119 | 122 | if ( $frame->get_node()->nodeName === "a" ) { |
120 | 123 | |
121 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
122 | - $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
124 | + if ( $href = $frame->get_node()->getAttribute("href") ) { |
|
125 | + $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
126 | + } |
|
123 | 127 | |
124 | 128 | } |
125 | 129 | |
@@ -130,18 +134,20 @@ discard block |
||
130 | 134 | continue; |
131 | 135 | } |
132 | 136 | |
133 | - if ( is_null($w) ) |
|
134 | - $w = $child_w; |
|
135 | - else |
|
136 | - $w += $child_w; |
|
137 | + if ( is_null($w) ) { |
|
138 | + $w = $child_w; |
|
139 | + } else { |
|
140 | + $w += $child_w; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $h = max($h, $child_h); |
139 | 144 | } |
140 | 145 | |
141 | 146 | |
142 | 147 | // Handle the last child |
143 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
144 | - $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
148 | + if ( ($bg = $style->background_color) !== "transparent" ) { |
|
149 | + $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | //On continuation lines (after line break) of inline elements, the style got copied. |
147 | 153 | //But a non repeatable background image should not be repeated on the next line. |
@@ -151,8 +157,9 @@ discard block |
||
151 | 157 | // Repeat not given: default is Style::__construct |
152 | 158 | // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ... |
153 | 159 | //different position? $this->_background_image($url, $x, $y, $w, $h, $style); |
154 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
155 | - $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
160 | + if ( ($url = $style->background_image) && $url !== "none" ) { |
|
161 | + $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
162 | + } |
|
156 | 163 | |
157 | 164 | // Add the border widths |
158 | 165 | $w += $widths[1] + $widths[3]; |
@@ -190,11 +197,13 @@ discard block |
||
190 | 197 | // Handle anchors & links |
191 | 198 | if ( $frame->get_node()->nodeName === "a" ) { |
192 | 199 | |
193 | - if ( $name = $frame->get_node()->getAttribute("name") ) |
|
194 | - $this->_canvas->add_named_dest($name); |
|
200 | + if ( $name = $frame->get_node()->getAttribute("name") ) { |
|
201 | + $this->_canvas->add_named_dest($name); |
|
202 | + } |
|
195 | 203 | |
196 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
197 | - $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
204 | + if ( $href = $frame->get_node()->getAttribute("href") ) { |
|
205 | + $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
206 | + } |
|
198 | 207 | } |
199 | 208 | } |
200 | 209 | } |