@@ -63,8 +63,9 @@ discard block |
||
63 | 63 | |
64 | 64 | foreach ( $this->_frame->get_children() as $child) { |
65 | 65 | // Bail if the page is full |
66 | - if ( $page->is_full() ) |
|
67 | - return; |
|
66 | + if ( $page->is_full() ) { |
|
67 | + return; |
|
68 | + } |
|
68 | 69 | |
69 | 70 | $child->set_containing_block($cb["x"], $cb["y"], $cb["w"], $cb["h"]); |
70 | 71 | $child->reflow(); |
@@ -74,8 +75,9 @@ discard block |
||
74 | 75 | |
75 | 76 | } |
76 | 77 | |
77 | - if ( $page->is_full() ) |
|
78 | - return; |
|
78 | + if ( $page->is_full() ) { |
|
79 | + return; |
|
80 | + } |
|
79 | 81 | |
80 | 82 | $cellmap = $table->get_cellmap(); |
81 | 83 | $style->width = $cellmap->get_frame_width($this->_frame); |
@@ -83,9 +85,10 @@ discard block |
||
83 | 85 | |
84 | 86 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
85 | 87 | |
86 | - if ( $table->get_style()->border_collapse === "collapse" ) |
|
87 | - // Unset our borders because our cells are now using them |
|
88 | + if ( $table->get_style()->border_collapse === "collapse" ) { |
|
89 | + // Unset our borders because our cells are now using them |
|
88 | 90 | $style->border_style = "none"; |
91 | + } |
|
89 | 92 | |
90 | 93 | } |
91 | 94 |
@@ -85,8 +85,9 @@ discard block |
||
85 | 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 | - } else |
|
89 | - $draw_bottom = false; |
|
88 | + } else { |
|
89 | + $draw_bottom = false; |
|
90 | + } |
|
90 | 91 | |
91 | 92 | |
92 | 93 | // Draw the horizontal borders |
@@ -110,8 +111,9 @@ discard block |
||
110 | 111 | |
111 | 112 | if ( $draw_bottom ) { |
112 | 113 | $bp = $cellmap->get_border_properties($num_rows - 1, $j); |
113 | - if ( $bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0 ) |
|
114 | - continue; |
|
114 | + if ( $bp["bottom"]["style"] === "none" || $bp["bottom"]["width"] <= 0 ) { |
|
115 | + continue; |
|
116 | + } |
|
115 | 117 | |
116 | 118 | $y = $bottom_row["y"] + $bottom_row["height"] + $bp["bottom"]["width"] / 2; |
117 | 119 | |
@@ -132,8 +134,9 @@ discard block |
||
132 | 134 | if (in_array($num_cols - 1, $cells["columns"])) { |
133 | 135 | $draw_right = true; |
134 | 136 | $right_col = $cellmap->get_column($num_cols - 1); |
135 | - } else |
|
136 | - $draw_right = false; |
|
137 | + } else { |
|
138 | + $draw_right = false; |
|
139 | + } |
|
137 | 140 | |
138 | 141 | // Draw the vertical borders |
139 | 142 | foreach ( $cells["rows"] as $i ) { |
@@ -159,8 +162,9 @@ discard block |
||
159 | 162 | |
160 | 163 | if ( $draw_right ) { |
161 | 164 | $bp = $cellmap->get_border_properties($i, $num_cols - 1); |
162 | - if ( $bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0 ) |
|
163 | - continue; |
|
165 | + if ( $bp["right"]["style"] === "none" || $bp["right"]["width"] <= 0 ) { |
|
166 | + continue; |
|
167 | + } |
|
164 | 168 | |
165 | 169 | $x = $right_col["x"] + $right_col["used-width"] + $bp["right"]["width"] / 2; |
166 | 170 |
@@ -54,8 +54,9 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | function evaluate($code, $vars = array()) { |
57 | - if ( !DOMPDF_ENABLE_PHP ) |
|
58 | - return; |
|
57 | + if ( !DOMPDF_ENABLE_PHP ) { |
|
58 | + return; |
|
59 | + } |
|
59 | 60 | |
60 | 61 | // Set up some variables for the inline code |
61 | 62 | $pdf = $this->_canvas; |
@@ -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 | /** |