@@ -103,10 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | if ( !is_array($size) ) { |
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | - $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | - else |
|
109 | - $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
106 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) { |
|
107 | + $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | + } else { |
|
109 | + $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
110 | + } |
|
110 | 111 | |
111 | 112 | } |
112 | 113 | |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | list($size[2],$size[3]) = array($size[3],$size[2]); |
115 | 116 | } |
116 | 117 | |
117 | - if ( $aa_factor < 1 ) |
|
118 | - $aa_factor = 1; |
|
118 | + if ( $aa_factor < 1 ) { |
|
119 | + $aa_factor = 1; |
|
120 | + } |
|
119 | 121 | |
120 | 122 | $this->_aa_factor = $aa_factor; |
121 | 123 | |
@@ -197,8 +199,9 @@ discard block |
||
197 | 199 | private function _allocate_color($color) { |
198 | 200 | |
199 | 201 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
201 | - $color[3] = 0; |
|
202 | + if ( !isset($color[3]) ) { |
|
203 | + $color[3] = 0; |
|
204 | + } |
|
202 | 205 | |
203 | 206 | list($r,$g,$b,$a) = $color; |
204 | 207 | |
@@ -220,13 +223,15 @@ discard block |
||
220 | 223 | |
221 | 224 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 225 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
224 | - return $this->_colors[$key]; |
|
226 | + if ( isset($this->_colors[$key]) ) { |
|
227 | + return $this->_colors[$key]; |
|
228 | + } |
|
225 | 229 | |
226 | - if ( $a != 0 ) |
|
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | - else |
|
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | + if ( $a != 0 ) { |
|
231 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
232 | + } else { |
|
233 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
234 | + } |
|
230 | 235 | |
231 | 236 | return $this->_colors[$key]; |
232 | 237 | |
@@ -278,13 +283,15 @@ discard block |
||
278 | 283 | |
279 | 284 | if ( $i % 2 == 0 ) { |
280 | 285 | // 'On' pattern |
281 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
282 | - $gd_style[] = $c; |
|
286 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
287 | + $gd_style[] = $c; |
|
288 | + } |
|
283 | 289 | |
284 | 290 | } else { |
285 | 291 | // Off pattern |
286 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
287 | - $gd_style[] = $this->_bg_color; |
|
292 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
293 | + $gd_style[] = $this->_bg_color; |
|
294 | + } |
|
288 | 295 | |
289 | 296 | } |
290 | 297 | $i++; |
@@ -398,8 +405,9 @@ discard block |
||
398 | 405 | function polygon($points, $color, $width = null, $style = null, $fill = false) { |
399 | 406 | |
400 | 407 | // Scale each point by the AA factor |
401 | - foreach (array_keys($points) as $i) |
|
402 | - $points[$i] *= $this->_aa_factor; |
|
408 | + foreach (array_keys($points) as $i) { |
|
409 | + $points[$i] *= $this->_aa_factor; |
|
410 | + } |
|
403 | 411 | |
404 | 412 | $c = $this->_allocate_color($color); |
405 | 413 | |
@@ -419,10 +427,11 @@ discard block |
||
419 | 427 | |
420 | 428 | imagesetthickness($this->_img, $width); |
421 | 429 | |
422 | - if ( $fill ) |
|
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | - else |
|
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
430 | + if ( $fill ) { |
|
431 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
432 | + } else { |
|
433 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
434 | + } |
|
426 | 435 | |
427 | 436 | } |
428 | 437 | |
@@ -466,10 +475,11 @@ discard block |
||
466 | 475 | |
467 | 476 | imagesetthickness($this->_img, $width); |
468 | 477 | |
469 | - if ( $fill ) |
|
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | - else |
|
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
478 | + if ( $fill ) { |
|
479 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
480 | + } else { |
|
481 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
482 | + } |
|
473 | 483 | |
474 | 484 | } |
475 | 485 | |
@@ -507,8 +517,10 @@ discard block |
||
507 | 517 | |
508 | 518 | } |
509 | 519 | |
510 | - if ( !$src ) |
|
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
520 | + if ( !$src ) { |
|
521 | + return; |
|
522 | + } |
|
523 | + // Probably should add to $_dompdf_errors or whatever here |
|
512 | 524 | |
513 | 525 | // Scale by the AA factor |
514 | 526 | $x *= $this->_aa_factor; |
@@ -550,8 +562,9 @@ discard block |
||
550 | 562 | |
551 | 563 | $c = $this->_allocate_color($color); |
552 | 564 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
554 | - $font .= ".ttf"; |
|
565 | + if ( strpos($font, '.ttf') === false ) { |
|
566 | + $font .= ".ttf"; |
|
567 | + } |
|
555 | 568 | |
556 | 569 | // FIXME: word spacing |
557 | 570 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
@@ -595,8 +608,9 @@ discard block |
||
595 | 608 | */ |
596 | 609 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 610 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
599 | - $font .= ".ttf"; |
|
611 | + if ( strpos($font, '.ttf') === false ) { |
|
612 | + $font .= ".ttf"; |
|
613 | + } |
|
600 | 614 | |
601 | 615 | // FIXME: word spacing |
602 | 616 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
@@ -611,8 +625,9 @@ discard block |
||
611 | 625 | * @return float |
612 | 626 | */ |
613 | 627 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
615 | - $font .= ".ttf"; |
|
628 | + if ( strpos($font, '.ttf') === false ) { |
|
629 | + $font .= ".ttf"; |
|
630 | + } |
|
616 | 631 | |
617 | 632 | // FIXME: word spacing |
618 | 633 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
@@ -649,8 +664,9 @@ discard block |
||
649 | 664 | $dst = $this->_img; |
650 | 665 | } |
651 | 666 | |
652 | - if ( !isset($options["type"]) ) |
|
653 | - $options["type"] = "png"; |
|
667 | + if ( !isset($options["type"]) ) { |
|
668 | + $options["type"] = "png"; |
|
669 | + } |
|
654 | 670 | |
655 | 671 | $type = strtolower($options["type"]); |
656 | 672 | |
@@ -660,8 +676,9 @@ discard block |
||
660 | 676 | |
661 | 677 | case "jpg": |
662 | 678 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
679 | + if ( !isset($options["quality"]) ) { |
|
680 | + $options["quality"] = 75; |
|
681 | + } |
|
665 | 682 | |
666 | 683 | header("Content-type: image/jpeg"); |
667 | 684 | imagejpeg($dst, '', $options["quality"]); |
@@ -674,8 +691,9 @@ discard block |
||
674 | 691 | break; |
675 | 692 | } |
676 | 693 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
678 | - imagedestroy($dst); |
|
694 | + if ( $this->_aa_factor != 1 ) { |
|
695 | + imagedestroy($dst); |
|
696 | + } |
|
679 | 697 | } |
680 | 698 | |
681 | 699 | /** |
@@ -697,8 +715,9 @@ discard block |
||
697 | 715 | $dst = $this->_img; |
698 | 716 | } |
699 | 717 | |
700 | - if ( !isset($options["type"]) ) |
|
701 | - $options["type"] = "png"; |
|
718 | + if ( !isset($options["type"]) ) { |
|
719 | + $options["type"] = "png"; |
|
720 | + } |
|
702 | 721 | |
703 | 722 | $type = $options["type"]; |
704 | 723 | |
@@ -708,8 +727,9 @@ discard block |
||
708 | 727 | |
709 | 728 | case "jpg": |
710 | 729 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
730 | + if ( !isset($options["quality"]) ) { |
|
731 | + $options["quality"] = 75; |
|
732 | + } |
|
713 | 733 | |
714 | 734 | imagejpeg($dst, '', $options["quality"]); |
715 | 735 | break; |
@@ -723,8 +743,9 @@ discard block |
||
723 | 743 | $image = ob_get_contents(); |
724 | 744 | ob_end_clean(); |
725 | 745 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
727 | - imagedestroy($dst); |
|
746 | + if ( $this->_aa_factor != 1 ) { |
|
747 | + imagedestroy($dst); |
|
748 | + } |
|
728 | 749 | |
729 | 750 | return $image; |
730 | 751 | } |
@@ -51,8 +51,9 @@ discard block |
||
51 | 51 | protected $_text_spacing; |
52 | 52 | |
53 | 53 | function __construct(Frame $frame, DOMPDF $dompdf) { |
54 | - if ( $frame->get_node()->nodeName !== "#text" ) |
|
55 | - throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
54 | + if ( $frame->get_node()->nodeName !== "#text" ) { |
|
55 | + throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
56 | + } |
|
56 | 57 | |
57 | 58 | parent::__construct($frame, $dompdf); |
58 | 59 | $this->_text_spacing = null; |
@@ -154,8 +155,9 @@ discard block |
||
154 | 155 | // split the text in this frame at the offset specified. The remaining |
155 | 156 | // text is added a sibling frame following this one and is returned. |
156 | 157 | function split_text($offset) { |
157 | - if ( $offset == 0 ) |
|
158 | - return; |
|
158 | + if ( $offset == 0 ) { |
|
159 | + return; |
|
160 | + } |
|
159 | 161 | |
160 | 162 | $split = $this->_frame->get_node()->splitText($offset); |
161 | 163 | $deco = $this->copy($split); |
@@ -163,8 +165,9 @@ discard block |
||
163 | 165 | $p = $this->get_parent(); |
164 | 166 | $p->insert_child_after($deco, $this, false); |
165 | 167 | |
166 | - if ( $p instanceof Inline_Frame_Decorator ) |
|
167 | - $p->split($deco); |
|
168 | + if ( $p instanceof Inline_Frame_Decorator ) { |
|
169 | + $p->split($deco); |
|
170 | + } |
|
168 | 171 | |
169 | 172 | } |
170 | 173 |
@@ -246,18 +246,21 @@ discard block |
||
246 | 246 | $node = $frame->get_node(); |
247 | 247 | $tag = $node->tagName; |
248 | 248 | |
249 | - if ( !isset(self::$__ATTRIBUTE_LOOKUP[$tag]) ) |
|
250 | - return; |
|
249 | + if ( !isset(self::$__ATTRIBUTE_LOOKUP[$tag]) ) { |
|
250 | + return; |
|
251 | + } |
|
251 | 252 | |
252 | 253 | $valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag]; |
253 | 254 | $attrs = $node->attributes; |
254 | 255 | $style = rtrim($node->getAttribute("style"), "; "); |
255 | - if ( $style != "" ) |
|
256 | - $style .= ";"; |
|
256 | + if ( $style != "" ) { |
|
257 | + $style .= ";"; |
|
258 | + } |
|
257 | 259 | |
258 | 260 | foreach ($attrs as $attr => $attr_node ) { |
259 | - if ( !isset($valid_attrs[$attr]) ) |
|
260 | - continue; |
|
261 | + if ( !isset($valid_attrs[$attr]) ) { |
|
262 | + continue; |
|
263 | + } |
|
261 | 264 | |
262 | 265 | $value = $attr_node->value; |
263 | 266 | |
@@ -266,8 +269,9 @@ discard block |
||
266 | 269 | // Look up $value in $target, if $target is an array: |
267 | 270 | if ( is_array($target) ) { |
268 | 271 | |
269 | - if ( isset($target[$value]) ) |
|
270 | - $style .= " " . self::_resolve_target($node, $target[$value], $value); |
|
272 | + if ( isset($target[$value]) ) { |
|
273 | + $style .= " " . self::_resolve_target($node, $target[$value], $value); |
|
274 | + } |
|
271 | 275 | |
272 | 276 | } else { |
273 | 277 | // otherwise use target directly |
@@ -309,8 +313,9 @@ discard block |
||
309 | 313 | $td_list = $node->getElementsByTagName("td"); |
310 | 314 | foreach ($td_list as $td) { |
311 | 315 | $style = $td->getAttribute("style"); |
312 | - if ( strpos($style, "border") !== false ) |
|
313 | - continue; |
|
316 | + if ( strpos($style, "border") !== false ) { |
|
317 | + continue; |
|
318 | + } |
|
314 | 319 | $style = rtrim($style, ";"); |
315 | 320 | $style .= "; border-width: $value" . "px; border-style: ridge;"; |
316 | 321 | $style = ltrim($style, ";"); |
@@ -319,8 +324,9 @@ discard block |
||
319 | 324 | $th_list = $node->getElementsByTagName("th"); |
320 | 325 | foreach ($th_list as $th) { |
321 | 326 | $style = $th->getAttribute("style"); |
322 | - if ( strpos($style, "border") !== false ) |
|
323 | - continue; |
|
327 | + if ( strpos($style, "border") !== false ) { |
|
328 | + continue; |
|
329 | + } |
|
324 | 330 | $style = rtrim($style, ";"); |
325 | 331 | $style .= "; border-width: $value" . "px; border-style: ridge;"; |
326 | 332 | $style = ltrim($style, ";"); |
@@ -333,11 +339,11 @@ discard block |
||
333 | 339 | static protected function _set_table_cellspacing($node, $value) { |
334 | 340 | $style = rtrim($td->getAttribute($style), ";"); |
335 | 341 | |
336 | - if ( $value == 0 ) |
|
337 | - $style .= "; border-collapse: collapse;"; |
|
338 | - |
|
339 | - else |
|
340 | - $style = "; border-collapse: separate;"; |
|
342 | + if ( $value == 0 ) { |
|
343 | + $style .= "; border-collapse: collapse;"; |
|
344 | + } else { |
|
345 | + $style = "; border-collapse: separate;"; |
|
346 | + } |
|
341 | 347 | |
342 | 348 | return ltrim($style, ";"); |
343 | 349 | } |
@@ -384,8 +390,9 @@ discard block |
||
384 | 390 | |
385 | 391 | $style = rtrim($node->getAttribute("style"),";"); |
386 | 392 | $width = $node->getAttribute("width"); |
387 | - if ( $width == "" ) |
|
388 | - $width = "100%"; |
|
393 | + if ( $width == "" ) { |
|
394 | + $width = "100%"; |
|
395 | + } |
|
389 | 396 | |
390 | 397 | $remainder = 100 - (double)rtrim($width, "% "); |
391 | 398 | |
@@ -475,13 +482,15 @@ discard block |
||
475 | 482 | static protected function _set_font_size($node, $value) { |
476 | 483 | $style = $node->getAttribute("style"); |
477 | 484 | |
478 | - if ( $value[0] === "-" || $value[0] === "+" ) |
|
479 | - $value = self::$_last_basefont_size + (int)$value; |
|
485 | + if ( $value[0] === "-" || $value[0] === "+" ) { |
|
486 | + $value = self::$_last_basefont_size + (int)$value; |
|
487 | + } |
|
480 | 488 | |
481 | - if ( isset(self::$_font_size_lookup[$value]) ) |
|
482 | - $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";"; |
|
483 | - else |
|
484 | - $style .= "; font-size: $value;"; |
|
489 | + if ( isset(self::$_font_size_lookup[$value]) ) { |
|
490 | + $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";"; |
|
491 | + } else { |
|
492 | + $style .= "; font-size: $value;"; |
|
493 | + } |
|
485 | 494 | |
486 | 495 | return ltrim($style, "; "); |
487 | 496 |
@@ -88,20 +88,24 @@ discard block |
||
88 | 88 | $content = $style->content; |
89 | 89 | |
90 | 90 | // split on spaces, except within quotes |
91 | - if (!preg_match_all($re, $content, $matches, PREG_SET_ORDER)) |
|
92 | - return; |
|
91 | + if (!preg_match_all($re, $content, $matches, PREG_SET_ORDER)) { |
|
92 | + return; |
|
93 | + } |
|
93 | 94 | |
94 | 95 | $text = ""; |
95 | 96 | |
96 | 97 | foreach ($matches as $match) { |
97 | - if ( isset($match[2]) && $match[2] !== "" ) |
|
98 | - $match[1] = $match[1]; |
|
98 | + if ( isset($match[2]) && $match[2] !== "" ) { |
|
99 | + $match[1] = $match[1]; |
|
100 | + } |
|
99 | 101 | |
100 | - if ( isset($match[6]) && $match[6] !== "" ) |
|
101 | - $match[4] = $match[6]; |
|
102 | + if ( isset($match[6]) && $match[6] !== "" ) { |
|
103 | + $match[4] = $match[6]; |
|
104 | + } |
|
102 | 105 | |
103 | - if ( isset($match[8]) && $match[8] !== "" ) |
|
104 | - $match[7] = $match[8]; |
|
106 | + if ( isset($match[8]) && $match[8] !== "" ) { |
|
107 | + $match[7] = $match[8]; |
|
108 | + } |
|
105 | 109 | |
106 | 110 | if ( isset($match[1]) && $match[1] !== "" ) { |
107 | 111 | // counters?(...) |
@@ -111,8 +115,9 @@ discard block |
||
111 | 115 | // http://www.w3.org/TR/CSS21/generate.html#content |
112 | 116 | |
113 | 117 | $i = mb_strpos($match[1], ")"); |
114 | - if ( $i === false ) |
|
115 | - continue; |
|
118 | + if ( $i === false ) { |
|
119 | + continue; |
|
120 | + } |
|
116 | 121 | |
117 | 122 | $args = explode(",", mb_substr($match[1], 7, $i - 7)); |
118 | 123 | $counter_id = $args[0]; |
@@ -120,10 +125,11 @@ discard block |
||
120 | 125 | if ( $match[1]{7} === "(" ) { |
121 | 126 | // counter(name [,style]) |
122 | 127 | |
123 | - if ( isset($args[1]) ) |
|
124 | - $type = $args[1]; |
|
125 | - else |
|
126 | - $type = null; |
|
128 | + if ( isset($args[1]) ) { |
|
129 | + $type = $args[1]; |
|
130 | + } else { |
|
131 | + $type = null; |
|
132 | + } |
|
127 | 133 | |
128 | 134 | |
129 | 135 | $p = $this->_frame->find_block_parent(); |
@@ -132,15 +138,17 @@ discard block |
||
132 | 138 | |
133 | 139 | } else if ( $match[1]{7} === "s" ) { |
134 | 140 | // counters(name, string [,style]) |
135 | - if ( isset($args[1]) ) |
|
136 | - $string = $this->_parse_string(trim($args[1])); |
|
137 | - else |
|
138 | - $string = ""; |
|
141 | + if ( isset($args[1]) ) { |
|
142 | + $string = $this->_parse_string(trim($args[1])); |
|
143 | + } else { |
|
144 | + $string = ""; |
|
145 | + } |
|
139 | 146 | |
140 | - if ( isset($args[2]) ) |
|
141 | - $type = $args[2]; |
|
142 | - else |
|
143 | - $type = null; |
|
147 | + if ( isset($args[2]) ) { |
|
148 | + $type = $args[2]; |
|
149 | + } else { |
|
150 | + $type = null; |
|
151 | + } |
|
144 | 152 | |
145 | 153 | $p = $this->_frame->find_block_parent(); |
146 | 154 | $tmp = ""; |
@@ -150,9 +158,10 @@ discard block |
||
150 | 158 | } |
151 | 159 | $text .= $tmp; |
152 | 160 | |
153 | - } else |
|
154 | - // countertops? |
|
161 | + } else { |
|
162 | + // countertops? |
|
155 | 163 | continue; |
164 | + } |
|
156 | 165 | |
157 | 166 | } else if ( isset($match[4]) && $match[4] !== "" ) { |
158 | 167 | // String match |
@@ -172,16 +181,19 @@ discard block |
||
172 | 181 | } else if ( mb_strpos($match[7],"attr(") === 0 ) { |
173 | 182 | |
174 | 183 | $i = mb_strpos($match[7],")"); |
175 | - if ( $i === false ) |
|
176 | - continue; |
|
184 | + if ( $i === false ) { |
|
185 | + continue; |
|
186 | + } |
|
177 | 187 | |
178 | 188 | $attr = mb_substr($match[7], 6, $i - 6); |
179 | - if ( $attr == "" ) |
|
180 | - continue; |
|
189 | + if ( $attr == "" ) { |
|
190 | + continue; |
|
191 | + } |
|
181 | 192 | |
182 | 193 | $text .= $this->_frame->get_node()->getAttribute($attr); |
183 | - } else |
|
184 | - continue; |
|
194 | + } else { |
|
195 | + continue; |
|
196 | + } |
|
185 | 197 | |
186 | 198 | } |
187 | 199 | } |
@@ -210,13 +210,15 @@ discard block |
||
210 | 210 | * @param Style $style the Style to be added |
211 | 211 | */ |
212 | 212 | function add_style($key, Style $style) { |
213 | - if (!is_string($key)) |
|
214 | - throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
213 | + if (!is_string($key)) { |
|
214 | + throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
215 | + } |
|
215 | 216 | |
216 | - if ( isset($this->_styles[$key]) ) |
|
217 | - $this->_styles[$key]->merge($style); |
|
218 | - else |
|
219 | - $this->_styles[$key] = clone $style; |
|
217 | + if ( isset($this->_styles[$key]) ) { |
|
218 | + $this->_styles[$key]->merge($style); |
|
219 | + } else { |
|
220 | + $this->_styles[$key] = clone $style; |
|
221 | + } |
|
220 | 222 | } |
221 | 223 | |
222 | 224 | |
@@ -230,8 +232,9 @@ discard block |
||
230 | 232 | * @return Style |
231 | 233 | */ |
232 | 234 | function lookup($key) { |
233 | - if ( !isset($this->_styles[$key]) ) |
|
234 | - return null; |
|
235 | + if ( !isset($this->_styles[$key]) ) { |
|
236 | + return null; |
|
237 | + } |
|
235 | 238 | |
236 | 239 | return $this->_styles[$key]; |
237 | 240 | } |
@@ -264,8 +267,9 @@ discard block |
||
264 | 267 | global $_dompdf_warnings; |
265 | 268 | |
266 | 269 | // Prevent circular references |
267 | - if ( isset($this->_loaded_files[$file]) ) |
|
268 | - return; |
|
270 | + if ( isset($this->_loaded_files[$file]) ) { |
|
271 | + return; |
|
272 | + } |
|
269 | 273 | |
270 | 274 | $this->_loaded_files[$file] = true; |
271 | 275 | $parsed_url = explode_url($file); |
@@ -279,10 +283,11 @@ discard block |
||
279 | 283 | } |
280 | 284 | |
281 | 285 | // Fix submitted by Nick Oostveen for aliased directory support: |
282 | - if ( $this->_protocol == "" ) |
|
283 | - $file = $this->_base_path . $filename; |
|
284 | - else |
|
285 | - $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
286 | + if ( $this->_protocol == "" ) { |
|
287 | + $file = $this->_base_path . $filename; |
|
288 | + } else { |
|
289 | + $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
290 | + } |
|
286 | 291 | |
287 | 292 | set_error_handler("record_warnings"); |
288 | 293 | $css = file_get_contents($file); |
@@ -361,8 +366,9 @@ discard block |
||
361 | 366 | |
362 | 367 | // Add an implicit space at the beginning of the selector if there is no |
363 | 368 | // delimiter there already. |
364 | - if ( !in_array($selector[0], $delimiters) ) |
|
365 | - $selector = " $selector"; |
|
369 | + if ( !in_array($selector[0], $delimiters) ) { |
|
370 | + $selector = " $selector"; |
|
371 | + } |
|
366 | 372 | |
367 | 373 | $tok = ""; |
368 | 374 | $len = mb_strlen($selector); |
@@ -377,8 +383,9 @@ discard block |
||
377 | 383 | $tok = ""; |
378 | 384 | |
379 | 385 | while ($i < $len) { |
380 | - if ( in_array($selector[$i], $delimiters) ) |
|
381 | - break; |
|
386 | + if ( in_array($selector[$i], $delimiters) ) { |
|
387 | + break; |
|
388 | + } |
|
382 | 389 | $tok .= $selector[$i++]; |
383 | 390 | } |
384 | 391 | |
@@ -390,11 +397,13 @@ discard block |
||
390 | 397 | // the current token |
391 | 398 | $expr = $s === " " ? "descendant" : "child"; |
392 | 399 | |
393 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
394 | - $query .= "/"; |
|
400 | + if ( mb_substr($query, -1, 1) !== "/" ) { |
|
401 | + $query .= "/"; |
|
402 | + } |
|
395 | 403 | |
396 | - if ( !$tok ) |
|
397 | - $tok = "*"; |
|
404 | + if ( !$tok ) { |
|
405 | + $tok = "*"; |
|
406 | + } |
|
398 | 407 | |
399 | 408 | $query .= "$expr::$tok"; |
400 | 409 | $tok = ""; |
@@ -408,8 +417,9 @@ discard block |
||
408 | 417 | $attr = $s === "." ? "class" : "id"; |
409 | 418 | |
410 | 419 | // empty class/id == * |
411 | - if ( mb_substr($query, -1, 1) === "/" ) |
|
412 | - $query .= "*"; |
|
420 | + if ( mb_substr($query, -1, 1) === "/" ) { |
|
421 | + $query .= "*"; |
|
422 | + } |
|
413 | 423 | |
414 | 424 | // Match multiple classes: $tok contains the current selected |
415 | 425 | // class. Search for class attributes with class="$tok", |
@@ -425,8 +435,9 @@ discard block |
||
425 | 435 | |
426 | 436 | case "+": |
427 | 437 | // All sibling elements that folow the current token |
428 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
429 | - $query .= "/"; |
|
438 | + if ( mb_substr($query, -1, 1) !== "/" ) { |
|
439 | + $query .= "/"; |
|
440 | + } |
|
430 | 441 | |
431 | 442 | $query .= "following-sibling::$tok"; |
432 | 443 | $tok = ""; |
@@ -473,8 +484,9 @@ discard block |
||
473 | 484 | $value = ""; |
474 | 485 | |
475 | 486 | while ( $j < $tok_len ) { |
476 | - if ( in_array($tok[$j], $attr_delimiters) ) |
|
477 | - break; |
|
487 | + if ( in_array($tok[$j], $attr_delimiters) ) { |
|
488 | + break; |
|
489 | + } |
|
478 | 490 | $attr .= $tok[$j++]; |
479 | 491 | } |
480 | 492 | |
@@ -484,8 +496,9 @@ discard block |
||
484 | 496 | case "|": |
485 | 497 | $op .= $tok[$j++]; |
486 | 498 | |
487 | - if ( $tok[$j] !== "=" ) |
|
488 | - throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
|
499 | + if ( $tok[$j] !== "=" ) { |
|
500 | + throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
|
501 | + } |
|
489 | 502 | |
490 | 503 | $op .= $tok[$j]; |
491 | 504 | break; |
@@ -500,14 +513,16 @@ discard block |
||
500 | 513 | if ( $op != "" ) { |
501 | 514 | $j++; |
502 | 515 | while ( $j < $tok_len ) { |
503 | - if ( $tok[$j] === "]" ) |
|
504 | - break; |
|
516 | + if ( $tok[$j] === "]" ) { |
|
517 | + break; |
|
518 | + } |
|
505 | 519 | $value .= $tok[$j++]; |
506 | 520 | } |
507 | 521 | } |
508 | 522 | |
509 | - if ( $attr == "" ) |
|
510 | - throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
523 | + if ( $attr == "" ) { |
|
524 | + throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
525 | + } |
|
511 | 526 | |
512 | 527 | switch ( $op ) { |
513 | 528 | |
@@ -525,8 +540,9 @@ discard block |
||
525 | 540 | $values = explode(" ", $value); |
526 | 541 | $query .= "["; |
527 | 542 | |
528 | - foreach ( $values as $val ) |
|
529 | - $query .= "@$attr=\"$val\" or "; |
|
543 | + foreach ( $values as $val ) { |
|
544 | + $query .= "@$attr=\"$val\" or "; |
|
545 | + } |
|
530 | 546 | |
531 | 547 | $query = rtrim($query, " or ") . "]"; |
532 | 548 | break; |
@@ -535,8 +551,9 @@ discard block |
||
535 | 551 | $values = explode("-", $value); |
536 | 552 | $query .= "["; |
537 | 553 | |
538 | - foreach ($values as $val) |
|
539 | - $query .= "starts-with(@$attr, \"$val\") or "; |
|
554 | + foreach ($values as $val) { |
|
555 | + $query .= "starts-with(@$attr, \"$val\") or "; |
|
556 | + } |
|
540 | 557 | |
541 | 558 | $query = rtrim($query, " or ") . "]"; |
542 | 559 | break; |
@@ -570,8 +587,9 @@ discard block |
||
570 | 587 | |
571 | 588 | |
572 | 589 | // Trim the trailing '/' from the query |
573 | - if ( mb_strlen($query) > 2 ) |
|
574 | - $query = rtrim($query, "/"); |
|
590 | + if ( mb_strlen($query) > 2 ) { |
|
591 | + $query = rtrim($query, "/"); |
|
592 | + } |
|
575 | 593 | |
576 | 594 | return $query; |
577 | 595 | } |
@@ -616,8 +634,10 @@ discard block |
||
616 | 634 | foreach ($nodes as $node) { |
617 | 635 | //echo $node->nodeName . "\n"; |
618 | 636 | // Retrieve the node id |
619 | - if ( $node->nodeType != 1 ) // Only DOMElements get styles |
|
637 | + if ( $node->nodeType != 1 ) { |
|
638 | + // Only DOMElements get styles |
|
620 | 639 | continue; |
640 | + } |
|
621 | 641 | |
622 | 642 | $id = $node->getAttribute("frame_id"); |
623 | 643 | |
@@ -635,20 +655,23 @@ discard block |
||
635 | 655 | if ( !$root_flg && $this->_page_style ) { |
636 | 656 | $style = $this->_page_style; |
637 | 657 | $root_flg = true; |
638 | - } else |
|
639 | - $style = $this->create_style(); |
|
658 | + } else { |
|
659 | + $style = $this->create_style(); |
|
660 | + } |
|
640 | 661 | |
641 | 662 | // Find nearest DOMElement parent |
642 | 663 | $p = $frame; |
643 | - while ( $p = $p->get_parent() ) |
|
644 | - if ($p->get_node()->nodeType == 1 ) |
|
664 | + while ( $p = $p->get_parent() ) { |
|
665 | + if ($p->get_node()->nodeType == 1 ) |
|
645 | 666 | break; |
667 | + } |
|
646 | 668 | |
647 | 669 | // Styles can only be applied directly to DOMElements; anonymous |
648 | 670 | // frames inherit from their parent |
649 | 671 | if ( $frame->get_node()->nodeType != 1 ) { |
650 | - if ( $p ) |
|
651 | - $style->inherit($p->get_style()); |
|
672 | + if ( $p ) { |
|
673 | + $style->inherit($p->get_style()); |
|
674 | + } |
|
652 | 675 | $frame->set_style($style); |
653 | 676 | continue; |
654 | 677 | } |
@@ -687,8 +710,9 @@ discard block |
||
687 | 710 | |
688 | 711 | // Merge the new styles with the inherited styles |
689 | 712 | foreach ($applied_styles as $arr) { |
690 | - foreach ($arr as $s) |
|
691 | - $style->merge($s); |
|
713 | + foreach ($arr as $s) { |
|
714 | + $style->merge($s); |
|
715 | + } |
|
692 | 716 | } |
693 | 717 | } |
694 | 718 | |
@@ -765,9 +789,10 @@ discard block |
||
765 | 789 | "([^{]*{[^}]*})) # Parse normal rulesets\n". |
766 | 790 | "/xs"; |
767 | 791 | |
768 | - if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false ) |
|
769 | - // An error occured |
|
792 | + if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false ) { |
|
793 | + // An error occured |
|
770 | 794 | throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
795 | + } |
|
771 | 796 | |
772 | 797 | // After matching, the array indicies are set as follows: |
773 | 798 | // |
@@ -825,10 +850,11 @@ discard block |
||
825 | 850 | //assign it to the <body> tag, possibly only for the css of the correct media type. |
826 | 851 | |
827 | 852 | // Store the style for later... |
828 | - if ( is_null($this->_page_style) ) |
|
829 | - $this->_page_style = $this->_parse_properties($match[5]); |
|
830 | - else |
|
831 | - $this->_page_style->merge($this->_parse_properties($match[5])); |
|
853 | + if ( is_null($this->_page_style) ) { |
|
854 | + $this->_page_style = $this->_parse_properties($match[5]); |
|
855 | + } else { |
|
856 | + $this->_page_style->merge($this->_parse_properties($match[5])); |
|
857 | + } |
|
832 | 858 | break; |
833 | 859 | |
834 | 860 | default: |
@@ -839,8 +865,9 @@ discard block |
||
839 | 865 | continue; |
840 | 866 | } |
841 | 867 | |
842 | - if ( $match[7] !== "" ) |
|
843 | - $this->_parse_sections($match[7]); |
|
868 | + if ( $match[7] !== "" ) { |
|
869 | + $this->_parse_sections($match[7]); |
|
870 | + } |
|
844 | 871 | |
845 | 872 | } |
846 | 873 | } |
@@ -851,8 +878,7 @@ discard block |
||
851 | 878 | |
852 | 879 | if ( mb_strpos($val, "url") === false ) { |
853 | 880 | $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
854 | - } |
|
855 | - else { |
|
881 | + } else { |
|
856 | 882 | $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
857 | 883 | |
858 | 884 | // Resolve the url now in the context of the current stylesheet |
@@ -951,7 +977,9 @@ discard block |
||
951 | 977 | private function _parse_properties($str) { |
952 | 978 | $properties = explode(";", $str); |
953 | 979 | |
954 | - if (DEBUGCSS) print '[_parse_properties'; |
|
980 | + if (DEBUGCSS) { |
|
981 | + print '[_parse_properties'; |
|
982 | + } |
|
955 | 983 | |
956 | 984 | // Create the style |
957 | 985 | $style = new Style($this); |
@@ -972,7 +1000,9 @@ discard block |
||
972 | 1000 | } |
973 | 1001 | $prop = trim($prop); |
974 | 1002 | */ |
975 | - if (DEBUGCSS) print '('; |
|
1003 | + if (DEBUGCSS) { |
|
1004 | + print '('; |
|
1005 | + } |
|
976 | 1006 | $important = false; |
977 | 1007 | $prop = trim($prop); |
978 | 1008 | if (substr($prop,-9) === 'important') { |
@@ -984,19 +1014,25 @@ discard block |
||
984 | 1014 | } |
985 | 1015 | |
986 | 1016 | if ($prop == "") { |
987 | - if (DEBUGCSS) print 'empty)'; |
|
1017 | + if (DEBUGCSS) { |
|
1018 | + print 'empty)'; |
|
1019 | + } |
|
988 | 1020 | continue; |
989 | 1021 | } |
990 | 1022 | |
991 | 1023 | $i = mb_strpos($prop, ":"); |
992 | 1024 | if ( $i === false ) { |
993 | - if (DEBUGCSS) print 'novalue'.$prop.')'; |
|
1025 | + if (DEBUGCSS) { |
|
1026 | + print 'novalue'.$prop.')'; |
|
1027 | + } |
|
994 | 1028 | continue; |
995 | 1029 | } |
996 | 1030 | |
997 | 1031 | $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
998 | 1032 | $value = ltrim(mb_substr($prop, $i+1)); |
999 | - if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1033 | + if (DEBUGCSS) { |
|
1034 | + print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1035 | + } |
|
1000 | 1036 | //New style, anyway empty |
1001 | 1037 | //if ($important || !$style->important_get($prop_name) ) { |
1002 | 1038 | //$style->$prop_name = array($value,$important); |
@@ -1010,7 +1046,9 @@ discard block |
||
1010 | 1046 | $style->$prop_name = $value; |
1011 | 1047 | //$style->props_set($prop_name, $value); |
1012 | 1048 | } |
1013 | - if (DEBUGCSS) print '_parse_properties]'; |
|
1049 | + if (DEBUGCSS) { |
|
1050 | + print '_parse_properties]'; |
|
1051 | + } |
|
1014 | 1052 | |
1015 | 1053 | return $style; |
1016 | 1054 | } |
@@ -1029,12 +1067,16 @@ discard block |
||
1029 | 1067 | $str = preg_replace($patterns, $replacements, $str); |
1030 | 1068 | |
1031 | 1069 | $sections = explode("}", $str); |
1032 | - if (DEBUGCSS) print '[_parse_sections'; |
|
1070 | + if (DEBUGCSS) { |
|
1071 | + print '[_parse_sections'; |
|
1072 | + } |
|
1033 | 1073 | foreach ($sections as $sect) { |
1034 | 1074 | $i = mb_strpos($sect, "{"); |
1035 | 1075 | |
1036 | 1076 | $selectors = explode(",", mb_substr($sect, 0, $i)); |
1037 | - if (DEBUGCSS) print '[section'; |
|
1077 | + if (DEBUGCSS) { |
|
1078 | + print '[section'; |
|
1079 | + } |
|
1038 | 1080 | $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
1039 | 1081 | |
1040 | 1082 | // Assign it to the selected elements |
@@ -1042,17 +1084,25 @@ discard block |
||
1042 | 1084 | $selector = trim($selector); |
1043 | 1085 | |
1044 | 1086 | if ($selector == "") { |
1045 | - if (DEBUGCSS) print '#empty#'; |
|
1087 | + if (DEBUGCSS) { |
|
1088 | + print '#empty#'; |
|
1089 | + } |
|
1046 | 1090 | continue; |
1047 | 1091 | } |
1048 | - if (DEBUGCSS) print '#'.$selector.'#'; |
|
1092 | + if (DEBUGCSS) { |
|
1093 | + print '#'.$selector.'#'; |
|
1094 | + } |
|
1049 | 1095 | //if (DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; } |
1050 | 1096 | |
1051 | 1097 | $this->add_style($selector, $style); |
1052 | 1098 | } |
1053 | - if (DEBUGCSS) print 'section]'; |
|
1099 | + if (DEBUGCSS) { |
|
1100 | + print 'section]'; |
|
1101 | + } |
|
1102 | + } |
|
1103 | + if (DEBUGCSS) { |
|
1104 | + print '_parse_sections]'; |
|
1054 | 1105 | } |
1055 | - if (DEBUGCSS) print '_parse_sections]'; |
|
1056 | 1106 | } |
1057 | 1107 | |
1058 | 1108 | /** |
@@ -1065,8 +1115,9 @@ discard block |
||
1065 | 1115 | */ |
1066 | 1116 | function __toString() { |
1067 | 1117 | $str = ""; |
1068 | - foreach ($this->_styles as $selector => $style) |
|
1069 | - $str .= "$selector => " . $style->__toString() . "\n"; |
|
1118 | + foreach ($this->_styles as $selector => $style) { |
|
1119 | + $str .= "$selector => " . $style->__toString() . "\n"; |
|
1120 | + } |
|
1070 | 1121 | |
1071 | 1122 | return $str; |
1072 | 1123 | } |
@@ -114,8 +114,9 @@ |
||
114 | 114 | |
115 | 115 | // Move our children |
116 | 116 | foreach ( $this->get_lines() as $i => $line ) { |
117 | - foreach ( $line["frames"] as $frame ) |
|
118 | - $frame->set_position( null, $frame->get_position("y") + $delta ); |
|
117 | + foreach ( $line["frames"] as $frame ) { |
|
118 | + $frame->set_position( null, $frame->get_position("y") + $delta ); |
|
119 | + } |
|
119 | 120 | } |
120 | 121 | } |
121 | 122 |
@@ -170,14 +170,15 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | function &get_column($i) { |
173 | - if ( !isset($this->_columns[$i]) ) |
|
174 | - $this->_columns[$i] = array("x" => 0, |
|
173 | + if ( !isset($this->_columns[$i]) ) { |
|
174 | + $this->_columns[$i] = array("x" => 0, |
|
175 | 175 | "min-width" => 0, |
176 | 176 | "max-width" => 0, |
177 | 177 | "used-width" => null, |
178 | 178 | "absolute" => 0, |
179 | 179 | "percent" => 0, |
180 | 180 | "auto" => true); |
181 | + } |
|
181 | 182 | |
182 | 183 | return $this->_columns[$i]; |
183 | 184 | } |
@@ -187,20 +188,23 @@ discard block |
||
187 | 188 | } |
188 | 189 | |
189 | 190 | function &get_row($j) { |
190 | - if ( !isset($this->_rows[$j]) ) |
|
191 | - $this->_rows[$j] = array("y" => 0, |
|
191 | + if ( !isset($this->_rows[$j]) ) { |
|
192 | + $this->_rows[$j] = array("y" => 0, |
|
192 | 193 | "first-column" => 0, |
193 | 194 | "height" => null); |
195 | + } |
|
194 | 196 | return $this->_rows[$j]; |
195 | 197 | } |
196 | 198 | |
197 | 199 | function get_border($i, $j, $h_v, $prop = null) { |
198 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) |
|
199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
200 | + if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
|
201 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
200 | 202 | "style" => "solid", |
201 | 203 | "color" => "black"); |
202 | - if ( isset($prop) ) |
|
203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
204 | + } |
|
205 | + if ( isset($prop) ) { |
|
206 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
207 | + } |
|
204 | 208 | |
205 | 209 | return $this->_borders[$i][$j][$h_v]; |
206 | 210 | } |
@@ -248,14 +252,16 @@ discard block |
||
248 | 252 | if ( !isset($this->_columns[$col])) { |
249 | 253 | $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
250 | 254 | $x = 0; |
251 | - } else |
|
252 | - $x = $this->_columns[$col]["x"]; |
|
255 | + } else { |
|
256 | + $x = $this->_columns[$col]["x"]; |
|
257 | + } |
|
253 | 258 | |
254 | 259 | if ( !isset($this->_rows[$row])) { |
255 | 260 | $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
256 | 261 | $y = 0; |
257 | - } else |
|
258 | - $y = $this->_rows[$row]["y"]; |
|
262 | + } else { |
|
263 | + $y = $this->_rows[$row]["y"]; |
|
264 | + } |
|
259 | 265 | |
260 | 266 | return array($x, $y, "x" => $x, "y" => $y); |
261 | 267 | } |
@@ -269,8 +275,9 @@ discard block |
||
269 | 275 | |
270 | 276 | $cols = $this->_frames[$key]["columns"]; |
271 | 277 | $w = 0; |
272 | - foreach ($cols as $i) |
|
273 | - $w += $this->_columns[$i]["used-width"]; |
|
278 | + foreach ($cols as $i) { |
|
279 | + $w += $this->_columns[$i]["used-width"]; |
|
280 | + } |
|
274 | 281 | |
275 | 282 | return $w; |
276 | 283 | |
@@ -279,8 +286,9 @@ discard block |
||
279 | 286 | function get_frame_height($frame) { |
280 | 287 | $key = $frame->get_id(); |
281 | 288 | |
282 | - if ( !isset($this->_frames[$key]) ) |
|
283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
289 | + if ( !isset($this->_frames[$key]) ) { |
|
290 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
291 | + } |
|
284 | 292 | |
285 | 293 | $rows = $this->_frames[$key]["rows"]; |
286 | 294 | $h = 0; |
@@ -306,8 +314,9 @@ discard block |
||
306 | 314 | |
307 | 315 | function set_row_height($i, $height) { |
308 | 316 | $row =& $this->get_row($i); |
309 | - if ( $height <= $row["height"] ) |
|
310 | - return; |
|
317 | + if ( $height <= $row["height"] ) { |
|
318 | + return; |
|
319 | + } |
|
311 | 320 | |
312 | 321 | $row["height"] = $height; |
313 | 322 | $next_row =& $this->get_row($i+1); |
@@ -340,8 +349,9 @@ discard block |
||
340 | 349 | |
341 | 350 | ($o_width == $n_width && |
342 | 351 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
343 | - self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
|
344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
352 | + self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) { |
|
353 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
354 | + } |
|
345 | 355 | |
346 | 356 | return $this->_borders[$i][$j][$h_v]["width"]; |
347 | 357 | } |
@@ -362,11 +372,13 @@ discard block |
||
362 | 372 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
363 | 373 | |
364 | 374 | $start_row = $this->__row; |
365 | - foreach ( $frame->get_children() as $child ) |
|
366 | - $this->add_frame( $child ); |
|
375 | + foreach ( $frame->get_children() as $child ) { |
|
376 | + $this->add_frame( $child ); |
|
377 | + } |
|
367 | 378 | |
368 | - if ( $display == "table-row" ) |
|
369 | - $this->add_row(); |
|
379 | + if ( $display == "table-row" ) { |
|
380 | + $this->add_row(); |
|
381 | + } |
|
370 | 382 | |
371 | 383 | $num_rows = $this->__row - $start_row - 1; |
372 | 384 | $key = $frame->get_id(); |
@@ -419,8 +431,9 @@ discard block |
||
419 | 431 | |
420 | 432 | // Find the next available column (fix by Ciro Mondueri) |
421 | 433 | $ac = $this->__col; |
422 | - while ( isset($this->_cells[$this->__row][$ac]) ) |
|
423 | - $ac++; |
|
434 | + while ( isset($this->_cells[$this->__row][$ac]) ) { |
|
435 | + $ac++; |
|
436 | + } |
|
424 | 437 | $this->__col = $ac; |
425 | 438 | |
426 | 439 | // Rows: |
@@ -429,8 +442,9 @@ discard block |
||
429 | 442 | |
430 | 443 | $this->_frames[ $key ]["rows"][] = $row; |
431 | 444 | |
432 | - for ( $j = 0; $j < $colspan; $j++) |
|
433 | - $this->_cells[$row][$this->__col + $j] = $frame; |
|
445 | + for ( $j = 0; $j < $colspan; $j++) { |
|
446 | + $this->_cells[$row][$this->__col + $j] = $frame; |
|
447 | + } |
|
434 | 448 | |
435 | 449 | if ( $collapse ) { |
436 | 450 | // Resolve vertical borders |
@@ -528,8 +542,9 @@ discard block |
||
528 | 542 | } |
529 | 543 | |
530 | 544 | $this->__col += $colspan; |
531 | - if ( $this->__col > $this->_num_cols ) |
|
532 | - $this->_num_cols = $this->__col; |
|
545 | + if ( $this->__col > $this->_num_cols ) { |
|
546 | + $this->_num_cols = $this->__col; |
|
547 | + } |
|
533 | 548 | |
534 | 549 | } |
535 | 550 | |
@@ -542,8 +557,9 @@ discard block |
||
542 | 557 | |
543 | 558 | // Find the next available column |
544 | 559 | $i = 0; |
545 | - while ( isset($this->_cells[$this->__row][$i]) ) |
|
546 | - $i++; |
|
560 | + while ( isset($this->_cells[$this->__row][$i]) ) { |
|
561 | + $i++; |
|
562 | + } |
|
547 | 563 | |
548 | 564 | $this->__col = $i; |
549 | 565 | |
@@ -559,8 +575,10 @@ discard block |
||
559 | 575 | function remove_row(Frame $row) { |
560 | 576 | |
561 | 577 | $key = $row->get_id(); |
562 | - if ( !isset($this->_frames[$key]) ) |
|
563 | - return; // Presumably this row has alredy been removed |
|
578 | + if ( !isset($this->_frames[$key]) ) { |
|
579 | + return; |
|
580 | + } |
|
581 | + // Presumably this row has alredy been removed |
|
564 | 582 | |
565 | 583 | $this->_row = $this->_num_rows--; |
566 | 584 | |
@@ -591,8 +609,10 @@ discard block |
||
591 | 609 | function remove_row_group(Frame $group) { |
592 | 610 | |
593 | 611 | $key = $group->get_id(); |
594 | - if ( !isset($this->_frames[$key]) ) |
|
595 | - return; // Presumably this row has alredy been removed |
|
612 | + if ( !isset($this->_frames[$key]) ) { |
|
613 | + return; |
|
614 | + } |
|
615 | + // Presumably this row has alredy been removed |
|
596 | 616 | |
597 | 617 | $iter = $group->get_first_child(); |
598 | 618 | while ($iter) { |
@@ -643,16 +663,18 @@ discard block |
||
643 | 663 | |
644 | 664 | $h = 0; |
645 | 665 | foreach( $arr["rows"] as $row ) { |
646 | - if ( !isset($this->_rows[$row]) ) |
|
647 | - // The row has been removed because of a page split, so skip it. |
|
666 | + if ( !isset($this->_rows[$row]) ) { |
|
667 | + // The row has been removed because of a page split, so skip it. |
|
648 | 668 | continue; |
669 | + } |
|
649 | 670 | $h += $this->_rows[$row]["height"]; |
650 | 671 | } |
651 | 672 | |
652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
653 | - $frame->set_cell_height($h); |
|
654 | - else |
|
655 | - $frame->get_style()->height = $h; |
|
673 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) { |
|
674 | + $frame->set_cell_height($h); |
|
675 | + } else { |
|
676 | + $frame->get_style()->height = $h; |
|
677 | + } |
|
656 | 678 | } |
657 | 679 | |
658 | 680 | } |
@@ -671,18 +693,20 @@ discard block |
||
671 | 693 | |
672 | 694 | $h = 0; |
673 | 695 | foreach ($arr["rows"] as $row ) { |
674 | - if ( !isset($this->_rows[$row]) ) |
|
675 | - continue; |
|
696 | + if ( !isset($this->_rows[$row]) ) { |
|
697 | + continue; |
|
698 | + } |
|
676 | 699 | |
677 | 700 | $h += $this->_rows[$row]["height"]; |
678 | 701 | } |
679 | 702 | |
680 | 703 | $new_height = ($h / $content_height) * $table_height; |
681 | 704 | |
682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
683 | - $frame->set_cell_height($new_height); |
|
684 | - else |
|
685 | - $frame->get_style()->height = $new_height; |
|
705 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) { |
|
706 | + $frame->set_cell_height($new_height); |
|
707 | + } else { |
|
708 | + $frame->get_style()->height = $new_height; |
|
709 | + } |
|
686 | 710 | } |
687 | 711 | |
688 | 712 | } |
@@ -699,15 +723,17 @@ discard block |
||
699 | 723 | |
700 | 724 | $str .= "Frames:<br/>"; |
701 | 725 | $arr = array(); |
702 | - foreach ( $this->_frames as $key => $val ) |
|
703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
726 | + foreach ( $this->_frames as $key => $val ) { |
|
727 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
728 | + } |
|
704 | 729 | |
705 | 730 | $str .= pre_r($arr, true); |
706 | 731 | |
707 | - if ( php_sapi_name() == "cli" ) |
|
708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
732 | + if ( php_sapi_name() == "cli" ) { |
|
733 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
709 | 734 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
710 | 735 | $str)); |
736 | + } |
|
711 | 737 | return $str; |
712 | 738 | } |
713 | 739 | } |
@@ -57,8 +57,9 @@ discard block |
||
57 | 57 | function reflow() { |
58 | 58 | $page = $this->_frame->get_root(); |
59 | 59 | |
60 | - if ( $page->is_full() ) |
|
61 | - return; |
|
60 | + if ( $page->is_full() ) { |
|
61 | + return; |
|
62 | + } |
|
62 | 63 | |
63 | 64 | $this->_frame->position(); |
64 | 65 | $style = $this->_frame->get_style(); |
@@ -66,16 +67,18 @@ discard block |
||
66 | 67 | |
67 | 68 | foreach ($this->_frame->get_children() as $child) { |
68 | 69 | |
69 | - if ( $page->is_full() ) |
|
70 | - return; |
|
70 | + if ( $page->is_full() ) { |
|
71 | + return; |
|
72 | + } |
|
71 | 73 | |
72 | 74 | $child->set_containing_block($cb); |
73 | 75 | $child->reflow(); |
74 | 76 | |
75 | 77 | } |
76 | 78 | |
77 | - if ( $page->is_full() ) |
|
78 | - return; |
|
79 | + if ( $page->is_full() ) { |
|
80 | + return; |
|
81 | + } |
|
79 | 82 | |
80 | 83 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
81 | 84 | $cellmap = $table->get_cellmap(); |
@@ -72,8 +72,9 @@ |
||
72 | 72 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 73 | // and on suppressed bullet |
74 | 74 | if ( $style->list_style_position === "outside" || |
75 | - $style->list_style_type === "none" ) |
|
76 | - return 0; |
|
75 | + $style->list_style_type === "none" ) { |
|
76 | + return 0; |
|
77 | + } |
|
77 | 78 | return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
78 | 79 | } |
79 | 80 |