@@ -135,11 +135,13 @@ discard block |
||
135 | 135 | */ |
136 | 136 | function build_tree() { |
137 | 137 | $html = $this->_dom->getElementsByTagName("html")->item(0); |
138 | - if ( is_null($html) ) |
|
139 | - $html = $this->_dom->firstChild; |
|
138 | + if ( is_null($html) ) { |
|
139 | + $html = $this->_dom->firstChild; |
|
140 | + } |
|
140 | 141 | |
141 | - if ( is_null($html) ) |
|
142 | - throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
142 | + if ( is_null($html) ) { |
|
143 | + throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
144 | + } |
|
143 | 145 | |
144 | 146 | $this->_root = $this->_build_tree_r($html); |
145 | 147 | |
@@ -162,8 +164,9 @@ discard block |
||
162 | 164 | $id = $frame->get_id(); |
163 | 165 | $this->_registry[ $id ] = $frame; |
164 | 166 | |
165 | - if ( !$node->hasChildNodes() ) |
|
166 | - return $frame; |
|
167 | + if ( !$node->hasChildNodes() ) { |
|
168 | + return $frame; |
|
169 | + } |
|
167 | 170 | |
168 | 171 | // Fixes 'cannot access undefined property for object with |
169 | 172 | // overloaded access', fix by Stefan radulian |
@@ -172,15 +175,17 @@ discard block |
||
172 | 175 | |
173 | 176 | // Store the children in an array so that the tree can be modified |
174 | 177 | $children = array(); |
175 | - for ($i = 0; $i < $node->childNodes->length; $i++) |
|
176 | - $children[] = $node->childNodes->item($i); |
|
178 | + for ($i = 0; $i < $node->childNodes->length; $i++) { |
|
179 | + $children[] = $node->childNodes->item($i); |
|
180 | + } |
|
177 | 181 | |
178 | 182 | foreach ($children as $child) { |
179 | 183 | // Skip non-displaying nodes |
180 | 184 | if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
181 | 185 | if ( mb_strtolower($child->nodeName) !== "head" && |
182 | - mb_strtolower($child->nodeName) !== "style" ) |
|
183 | - $child->parentNode->removeChild($child); |
|
186 | + mb_strtolower($child->nodeName) !== "style" ) { |
|
187 | + $child->parentNode->removeChild($child); |
|
188 | + } |
|
184 | 189 | continue; |
185 | 190 | } |
186 | 191 | |
@@ -203,15 +208,17 @@ discard block |
||
203 | 208 | // Move attributes to inner node |
204 | 209 | foreach ( $child->attributes as $attr => $attr_node ) { |
205 | 210 | // Skip style, but move all other attributes |
206 | - if ( $attr === "style" ) |
|
207 | - continue; |
|
211 | + if ( $attr === "style" ) { |
|
212 | + continue; |
|
213 | + } |
|
208 | 214 | |
209 | 215 | $img_node->setAttribute($attr, $attr_node->value); |
210 | 216 | } |
211 | 217 | |
212 | 218 | foreach ( $child->attributes as $attr => $node ) { |
213 | - if ( $attr === "style" ) |
|
214 | - continue; |
|
219 | + if ( $attr === "style" ) { |
|
220 | + continue; |
|
221 | + } |
|
215 | 222 | $child->removeAttribute($attr); |
216 | 223 | } |
217 | 224 |
@@ -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); |