@@ -61,8 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | 63 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | - if ( is_null($dompdf) ) |
|
65 | - throw new Exception("foo"); |
|
64 | + if ( is_null($dompdf) ) { |
|
65 | + throw new Exception("foo"); |
|
66 | + } |
|
66 | 67 | switch ($frame->get_style()->display) { |
67 | 68 | |
68 | 69 | case "block": |
@@ -127,15 +128,17 @@ discard block |
||
127 | 128 | break; |
128 | 129 | |
129 | 130 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
131 | - $positioner = "Inline"; |
|
132 | - else |
|
133 | - $positioner = "List_Bullet"; |
|
134 | - |
|
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | - $decorator = "List_Bullet_Image"; |
|
137 | - else |
|
138 | - $decorator = "List_Bullet"; |
|
131 | + if ( $frame->get_style()->list_style_position === "inside" ) { |
|
132 | + $positioner = "Inline"; |
|
133 | + } else { |
|
134 | + $positioner = "List_Bullet"; |
|
135 | + } |
|
136 | + |
|
137 | + if ( $frame->get_style()->list_style_image !== "none" ) { |
|
138 | + $decorator = "List_Bullet_Image"; |
|
139 | + } else { |
|
140 | + $decorator = "List_Bullet"; |
|
141 | + } |
|
139 | 142 | |
140 | 143 | $reflower = "List_Bullet"; |
141 | 144 | break; |
@@ -163,8 +166,9 @@ discard block |
||
163 | 166 | } |
164 | 167 | |
165 | 168 | if ( $frame->get_style()->position === "absolute" || |
166 | - $frame->get_style()->position === "fixed" ) |
|
167 | - $positioner = "Absolute"; |
|
169 | + $frame->get_style()->position === "fixed" ) { |
|
170 | + $positioner = "Absolute"; |
|
171 | + } |
|
168 | 172 | |
169 | 173 | $positioner .= "_Positioner"; |
170 | 174 | $decorator .= "_Frame_Decorator"; |
@@ -102,8 +102,9 @@ discard block |
||
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | 104 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
106 | - $child->dispose(true); |
|
105 | + while ( $child = $this->get_first_child() ) { |
|
106 | + $child->dispose(true); |
|
107 | + } |
|
107 | 108 | } |
108 | 109 | |
109 | 110 | unset($this->_root); |
@@ -134,8 +135,9 @@ discard block |
||
134 | 135 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 136 | $deco->set_root($this->_root); |
136 | 137 | |
137 | - foreach ($this->get_children() as $child) |
|
138 | - $deco->append_child($child->deep_copy()); |
|
138 | + foreach ($this->get_children() as $child) { |
|
139 | + $deco->append_child($child->deep_copy()); |
|
140 | + } |
|
139 | 141 | |
140 | 142 | return $deco; |
141 | 143 | } |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | $this->_frame->reset(); |
147 | 149 | |
148 | 150 | // Reset all children |
149 | - foreach ($this->get_children() as $child) |
|
150 | - $child->reset(); |
|
151 | + foreach ($this->get_children() as $child) { |
|
152 | + $child->reset(); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | } |
153 | 156 | |
@@ -183,42 +186,49 @@ discard block |
||
183 | 186 | function __toString() { return $this->_frame->__toString(); } |
184 | 187 | |
185 | 188 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
187 | - $child = $child->_frame; |
|
189 | + while ( $child instanceof Frame_Decorator ) { |
|
190 | + $child = $child->_frame; |
|
191 | + } |
|
188 | 192 | |
189 | 193 | $this->_frame->prepend_child($child, $update_node); |
190 | 194 | } |
191 | 195 | |
192 | 196 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
194 | - $child = $child->_frame; |
|
197 | + while ( $child instanceof Frame_Decorator ) { |
|
198 | + $child = $child->_frame; |
|
199 | + } |
|
195 | 200 | |
196 | 201 | $this->_frame->append_child($child, $update_node); |
197 | 202 | } |
198 | 203 | |
199 | 204 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
201 | - $new_child = $new_child->_frame; |
|
205 | + while ( $new_child instanceof Frame_Decorator ) { |
|
206 | + $new_child = $new_child->_frame; |
|
207 | + } |
|
202 | 208 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
204 | - $ref = $ref->_frame; |
|
209 | + if ( $ref instanceof Frame_Decorator ) { |
|
210 | + $ref = $ref->_frame; |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 214 | } |
208 | 215 | |
209 | 216 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
211 | - $new_child = $new_child->_frame; |
|
217 | + while ( $new_child instanceof Frame_Decorator ) { |
|
218 | + $new_child = $new_child->_frame; |
|
219 | + } |
|
212 | 220 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
214 | - $ref = $ref->_frame; |
|
221 | + while ( $ref instanceof Frame_Decorator ) { |
|
222 | + $ref = $ref->_frame; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 226 | } |
218 | 227 | |
219 | 228 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
221 | - $child = $new_child->_frame; |
|
229 | + while ( $child instanceof Frame_Decorator ) { |
|
230 | + $child = $new_child->_frame; |
|
231 | + } |
|
222 | 232 | |
223 | 233 | $this->_frame->remove_child($child, $update_node); |
224 | 234 | } |
@@ -230,61 +240,71 @@ discard block |
||
230 | 240 | $p = $this->_frame->get_parent(); |
231 | 241 | |
232 | 242 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
234 | - $deco = $tmp; |
|
243 | + while ( $tmp = $deco->get_decorator() ) { |
|
244 | + $deco = $tmp; |
|
245 | + } |
|
235 | 246 | return $deco; |
236 | - } else if ( $p ) |
|
237 | - return $p; |
|
238 | - else |
|
239 | - return null; |
|
247 | + } else if ( $p ) { |
|
248 | + return $p; |
|
249 | + } else { |
|
250 | + return null; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | |
242 | 254 | function get_first_child() { |
243 | 255 | $c = $this->_frame->get_first_child(); |
244 | 256 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
246 | - $deco = $tmp; |
|
257 | + while ( $tmp = $deco->get_decorator() ) { |
|
258 | + $deco = $tmp; |
|
259 | + } |
|
247 | 260 | return $deco; |
248 | - } else if ( $c ) |
|
249 | - return $c; |
|
250 | - else |
|
251 | - return null; |
|
261 | + } else if ( $c ) { |
|
262 | + return $c; |
|
263 | + } else { |
|
264 | + return null; |
|
265 | + } |
|
252 | 266 | } |
253 | 267 | |
254 | 268 | function get_last_child() { |
255 | 269 | $c = $this->_frame->get_last_child(); |
256 | 270 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
258 | - $deco = $tmp; |
|
271 | + while ( $tmp = $deco->get_decorator() ) { |
|
272 | + $deco = $tmp; |
|
273 | + } |
|
259 | 274 | return $deco; |
260 | - } else if ( $c ) |
|
261 | - return $c; |
|
262 | - else |
|
263 | - return null; |
|
275 | + } else if ( $c ) { |
|
276 | + return $c; |
|
277 | + } else { |
|
278 | + return null; |
|
279 | + } |
|
264 | 280 | } |
265 | 281 | |
266 | 282 | function get_prev_sibling() { |
267 | 283 | $s = $this->_frame->get_prev_sibling(); |
268 | 284 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
270 | - $deco = $tmp; |
|
285 | + while ( $tmp = $deco->get_decorator() ) { |
|
286 | + $deco = $tmp; |
|
287 | + } |
|
271 | 288 | return $deco; |
272 | - } else if ( $s ) |
|
273 | - return $s; |
|
274 | - else |
|
275 | - return null; |
|
289 | + } else if ( $s ) { |
|
290 | + return $s; |
|
291 | + } else { |
|
292 | + return null; |
|
293 | + } |
|
276 | 294 | } |
277 | 295 | |
278 | 296 | function get_next_sibling() { |
279 | 297 | $s = $this->_frame->get_next_sibling(); |
280 | 298 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
282 | - $deco = $tmp; |
|
299 | + while ( $tmp = $deco->get_decorator() ) { |
|
300 | + $deco = $tmp; |
|
301 | + } |
|
283 | 302 | return $deco; |
284 | - } else if ( $s ) |
|
285 | - return $s; |
|
286 | - else |
|
287 | - return null; |
|
303 | + } else if ( $s ) { |
|
304 | + return $s; |
|
305 | + } else { |
|
306 | + return null; |
|
307 | + } |
|
288 | 308 | } |
289 | 309 | |
290 | 310 | function get_children() { |
@@ -299,16 +319,18 @@ discard block |
||
299 | 319 | |
300 | 320 | function set_positioner(Positioner $posn) { |
301 | 321 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
303 | - $this->_frame->set_positioner($posn); |
|
322 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
323 | + $this->_frame->set_positioner($posn); |
|
324 | + } |
|
304 | 325 | } |
305 | 326 | |
306 | 327 | //........................................................................ |
307 | 328 | |
308 | 329 | function set_reflower(Frame_Reflower $reflower) { |
309 | 330 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
331 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
332 | + $this->_frame->set_reflower( $reflower ); |
|
333 | + } |
|
312 | 334 | } |
313 | 335 | |
314 | 336 | function get_reflower() { return $this->_reflower; } |
@@ -317,8 +339,9 @@ discard block |
||
317 | 339 | |
318 | 340 | function set_root(Frame $root) { |
319 | 341 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | - $this->_frame->set_root($root); |
|
342 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
343 | + $this->_frame->set_root($root); |
|
344 | + } |
|
322 | 345 | } |
323 | 346 | |
324 | 347 | function get_root() { return $this->_root; } |
@@ -331,8 +354,9 @@ discard block |
||
331 | 354 | $p = $this->get_parent(); |
332 | 355 | |
333 | 356 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | - break; |
|
357 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) { |
|
358 | + break; |
|
359 | + } |
|
336 | 360 | |
337 | 361 | $p = $p->get_parent(); |
338 | 362 | } |
@@ -358,8 +382,9 @@ discard block |
||
358 | 382 | return; |
359 | 383 | } |
360 | 384 | |
361 | - if ( $child->get_parent() !== $this ) |
|
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
385 | + if ( $child->get_parent() !== $this ) { |
|
386 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
387 | + } |
|
363 | 388 | |
364 | 389 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 390 | $split->reset(); |
@@ -74,14 +74,17 @@ discard block |
||
74 | 74 | list($x, $y) = $frame->get_position(); |
75 | 75 | $cb = $frame->get_containing_block(); |
76 | 76 | |
77 | - if ( ($ml = $style->margin_left) === "auto" || $ml === "none" ) |
|
78 | - $ml = 0; |
|
77 | + if ( ($ml = $style->margin_left) === "auto" || $ml === "none" ) { |
|
78 | + $ml = 0; |
|
79 | + } |
|
79 | 80 | |
80 | - if ( ($pl = $style->padding_left) === "auto" || $pl === "none" ) |
|
81 | - $pl = 0; |
|
81 | + if ( ($pl = $style->padding_left) === "auto" || $pl === "none" ) { |
|
82 | + $pl = 0; |
|
83 | + } |
|
82 | 84 | |
83 | - if ( ($bl = $style->border_left_width) === "auto" || $bl === "none" ) |
|
84 | - $bl = 0; |
|
85 | + if ( ($bl = $style->border_left_width) === "auto" || $bl === "none" ) { |
|
86 | + $bl = 0; |
|
87 | + } |
|
85 | 88 | |
86 | 89 | $x += $style->length_in_pt( array($ml, $pl, $bl), $cb["w"] ); |
87 | 90 | |
@@ -118,15 +121,17 @@ discard block |
||
118 | 121 | // our way down. |
119 | 122 | $p = $frame; |
120 | 123 | $stack = array(); |
121 | - while ( $p = $p->get_parent() ) |
|
122 | - $stack[] = $p; |
|
124 | + while ( $p = $p->get_parent() ) { |
|
125 | + $stack[] = $p; |
|
126 | + } |
|
123 | 127 | |
124 | 128 | while ( count($stack) > 0 ) { |
125 | 129 | $f = array_pop($stack); |
126 | 130 | |
127 | 131 | $deco_y = $y; |
128 | - if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) |
|
129 | - continue; |
|
132 | + if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) { |
|
133 | + continue; |
|
134 | + } |
|
130 | 135 | |
131 | 136 | $color = $f->get_style()->color; |
132 | 137 |
@@ -201,12 +201,13 @@ discard block |
||
201 | 201 | */ |
202 | 202 | function __construct($paper = "letter", $orientation = "portrait") { |
203 | 203 | |
204 | - if ( is_array($paper) ) |
|
205 | - $size = $paper; |
|
206 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
207 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
208 | - else |
|
209 | - $size = self::$PAPER_SIZES["letter"]; |
|
204 | + if ( is_array($paper) ) { |
|
205 | + $size = $paper; |
|
206 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
207 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
208 | + } else { |
|
209 | + $size = self::$PAPER_SIZES["letter"]; |
|
210 | + } |
|
210 | 211 | |
211 | 212 | if ( mb_strtolower($orientation) === "landscape" ) { |
212 | 213 | $a = $size[3]; |
@@ -243,9 +244,12 @@ discard block |
||
243 | 244 | function __destruct() { |
244 | 245 | foreach ($this->_image_cache as $img) { |
245 | 246 | //debugpng |
246 | - if (DEBUGPNG) print '[__destruct unlink '.$img.']'; |
|
247 | - if (!DEBUGKEEPTEMP) |
|
248 | - unlink($img); |
|
247 | + if (DEBUGPNG) { |
|
248 | + print '[__destruct unlink '.$img.']'; |
|
249 | + } |
|
250 | + if (!DEBUGKEEPTEMP) { |
|
251 | + unlink($img); |
|
252 | + } |
|
249 | 253 | } |
250 | 254 | } |
251 | 255 | |
@@ -559,12 +563,14 @@ discard block |
||
559 | 563 | $this->_set_line_transparency($blend, $opacity); |
560 | 564 | $this->_set_fill_transparency($blend, $opacity); |
561 | 565 | |
562 | - if ( !$fill && isset($width) ) |
|
563 | - $this->_set_line_style($width, "square", "miter", $style); |
|
566 | + if ( !$fill && isset($width) ) { |
|
567 | + $this->_set_line_style($width, "square", "miter", $style); |
|
568 | + } |
|
564 | 569 | |
565 | 570 | // Adjust y values |
566 | - for ( $i = 1; $i < count($points); $i += 2) |
|
567 | - $points[$i] = $this->y($points[$i]); |
|
571 | + for ( $i = 1; $i < count($points); $i += 2) { |
|
572 | + $points[$i] = $this->y($points[$i]); |
|
573 | + } |
|
568 | 574 | |
569 | 575 | $this->_pdf->polygon($points, count($points) / 2, $fill); |
570 | 576 | } |
@@ -580,8 +586,9 @@ discard block |
||
580 | 586 | $this->_set_line_transparency($blend, $opacity); |
581 | 587 | $this->_set_fill_transparency($blend, $opacity); |
582 | 588 | |
583 | - if ( !$fill && isset($width) ) |
|
584 | - $this->_set_line_style($width, "round", "round", $style); |
|
589 | + if ( !$fill && isset($width) ) { |
|
590 | + $this->_set_line_style($width, "round", "round", $style); |
|
591 | + } |
|
585 | 592 | |
586 | 593 | $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill); |
587 | 594 | } |
@@ -590,7 +597,9 @@ discard block |
||
590 | 597 | |
591 | 598 | function image($img_url, $img_type, $x, $y, $w, $h) { |
592 | 599 | //debugpng |
593 | - if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']'; |
|
600 | + if (DEBUGPNG) { |
|
601 | + print '[image:'.$img_url.'|'.$img_type.']'; |
|
602 | + } |
|
594 | 603 | |
595 | 604 | $img_type = mb_strtolower($img_type); |
596 | 605 | |
@@ -598,14 +607,18 @@ discard block |
||
598 | 607 | case "jpeg": |
599 | 608 | case "jpg": |
600 | 609 | //debugpng |
601 | - if (DEBUGPNG) print '!!!jpg!!!'; |
|
610 | + if (DEBUGPNG) { |
|
611 | + print '!!!jpg!!!'; |
|
612 | + } |
|
602 | 613 | |
603 | 614 | $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
604 | 615 | break; |
605 | 616 | |
606 | 617 | case "png": |
607 | 618 | //debugpng |
608 | - if (DEBUGPNG) print '!!!png!!!'; |
|
619 | + if (DEBUGPNG) { |
|
620 | + print '!!!png!!!'; |
|
621 | + } |
|
609 | 622 | |
610 | 623 | $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
611 | 624 | break; |
@@ -616,7 +629,9 @@ discard block |
||
616 | 629 | //if (0) { |
617 | 630 | if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
618 | 631 | //debugpng |
619 | - if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
|
632 | + if (DEBUGPNG) { |
|
633 | + print '!!!gif addImagePng!!!'; |
|
634 | + } |
|
620 | 635 | |
621 | 636 | //If optimization to direct png creation from gd object is available, |
622 | 637 | //don't create temp file, but place gd object directly into the pdf |
@@ -635,7 +650,9 @@ discard block |
||
635 | 650 | $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img); |
636 | 651 | } else { |
637 | 652 | //debugpng |
638 | - if (DEBUGPNG) print '!!!gif addPngFromFile!!!'; |
|
653 | + if (DEBUGPNG) { |
|
654 | + print '!!!gif addPngFromFile!!!'; |
|
655 | + } |
|
639 | 656 | $img_url = $this->_convert_gif_to_png($img_url); |
640 | 657 | $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h); |
641 | 658 | } |
@@ -643,7 +660,9 @@ discard block |
||
643 | 660 | |
644 | 661 | default: |
645 | 662 | //debugpng |
646 | - if (DEBUGPNG) print '!!!unknown!!!'; |
|
663 | + if (DEBUGPNG) { |
|
664 | + print '!!!unknown!!!'; |
|
665 | + } |
|
647 | 666 | break; |
648 | 667 | } |
649 | 668 | |
@@ -733,8 +752,9 @@ discard block |
||
733 | 752 | if ( strpos($url, '#') === 0 ) { |
734 | 753 | // Local link |
735 | 754 | $name = substr($url,1); |
736 | - if ( $name ) |
|
737 | - $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
|
755 | + if ( $name ) { |
|
756 | + $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
|
757 | + } |
|
738 | 758 | |
739 | 759 | } else { |
740 | 760 | $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height); |
@@ -819,8 +839,9 @@ discard block |
||
819 | 839 | */ |
820 | 840 | protected function _add_page_text() { |
821 | 841 | |
822 | - if ( !count($this->_page_text) ) |
|
823 | - return; |
|
842 | + if ( !count($this->_page_text) ) { |
|
843 | + return; |
|
844 | + } |
|
824 | 845 | |
825 | 846 | $page_number = 1; |
826 | 847 | $eval = null; |
@@ -878,10 +899,11 @@ discard block |
||
878 | 899 | // Add page text |
879 | 900 | $this->_add_page_text(); |
880 | 901 | |
881 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
882 | - $debug = 1; |
|
883 | - else |
|
884 | - $debug = 0; |
|
902 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
903 | + $debug = 1; |
|
904 | + } else { |
|
905 | + $debug = 0; |
|
906 | + } |
|
885 | 907 | |
886 | 908 | return $this->_pdf->output($debug); |
887 | 909 |
@@ -185,12 +185,13 @@ discard block |
||
185 | 185 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
186 | 186 | */ |
187 | 187 | function __construct($paper = "letter", $orientation = "portrait") { |
188 | - if ( is_array($paper) ) |
|
189 | - $size = $paper; |
|
190 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | - else |
|
193 | - $size = self::$PAPER_SIZES["letter"]; |
|
188 | + if ( is_array($paper) ) { |
|
189 | + $size = $paper; |
|
190 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | + } else { |
|
193 | + $size = self::$PAPER_SIZES["letter"]; |
|
194 | + } |
|
194 | 195 | |
195 | 196 | if ( mb_strtolower($orientation) === "landscape" ) { |
196 | 197 | $a = $size[3]; |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | |
203 | 204 | $this->_pdf = new PDFLib(); |
204 | 205 | |
205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
206 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
207 | + $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
208 | + } |
|
207 | 209 | |
208 | 210 | $this->_pdf->set_parameter("textformat", "utf8"); |
209 | 211 | $this->_pdf->set_parameter("fontwarning", "false"); |
@@ -220,9 +222,9 @@ discard block |
||
220 | 222 | $this->_pdf->set_info("Date", date("Y-m-d")); |
221 | 223 | } |
222 | 224 | |
223 | - if ( self::$IN_MEMORY ) |
|
224 | - $this->_pdf->begin_document("",""); |
|
225 | - else { |
|
225 | + if ( self::$IN_MEMORY ) { |
|
226 | + $this->_pdf->begin_document("",""); |
|
227 | + } else { |
|
226 | 228 | $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
227 | 229 | $this->_pdf->begin_document($this->_file,""); |
228 | 230 | } |
@@ -254,19 +256,23 @@ discard block |
||
254 | 256 | } else if ( file_exists($file . ".pfb") ) { |
255 | 257 | $outline = "$file.pfb"; |
256 | 258 | |
257 | - if ( file_exists($file . ".afm") ) |
|
258 | - $afm = "$file.afm"; |
|
259 | + if ( file_exists($file . ".afm") ) { |
|
260 | + $afm = "$file.afm"; |
|
261 | + } |
|
259 | 262 | |
260 | 263 | } else if ( file_exists($file . ".PFB") ) { |
261 | 264 | $outline = "$file.PFB"; |
262 | - if ( file_exists($file . ".AFM") ) |
|
263 | - $afm = "$file.AFM"; |
|
264 | - } else |
|
265 | - continue; |
|
265 | + if ( file_exists($file . ".AFM") ) { |
|
266 | + $afm = "$file.AFM"; |
|
267 | + } |
|
268 | + } else { |
|
269 | + continue; |
|
270 | + } |
|
266 | 271 | |
267 | 272 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
268 | - if ( !is_null($afm) ) |
|
269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
273 | + if ( !is_null($afm) ) { |
|
274 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
275 | + } |
|
270 | 276 | } |
271 | 277 | } |
272 | 278 | } |
@@ -369,8 +375,9 @@ discard block |
||
369 | 375 | if ( mb_strpos($where, "next") !== false ) { |
370 | 376 | $this->_objs[$object]["start_page"]++; |
371 | 377 | $where = str_replace("next", "", $where); |
372 | - if ( $where == "" ) |
|
373 | - $where = "add"; |
|
378 | + if ( $where == "" ) { |
|
379 | + $where = "add"; |
|
380 | + } |
|
374 | 381 | } |
375 | 382 | |
376 | 383 | $this->_objs[$object]["where"] = $where; |
@@ -386,8 +393,9 @@ discard block |
||
386 | 393 | */ |
387 | 394 | function stop_object($object) { |
388 | 395 | |
389 | - if ( !isset($this->_objs[$object]) ) |
|
390 | - return; |
|
396 | + if ( !isset($this->_objs[$object]) ) { |
|
397 | + return; |
|
398 | + } |
|
391 | 399 | |
392 | 400 | $start = $this->_objs[$object]["start_page"]; |
393 | 401 | $where = $this->_objs[$object]["where"]; |
@@ -396,8 +404,9 @@ discard block |
||
396 | 404 | if ( $this->_page_number >= $start && |
397 | 405 | (($this->_page_number % 2 == 0 && $where === "even") || |
398 | 406 | ($this->_page_number % 2 == 1 && $where === "odd") || |
399 | - ($where === "all")) ) |
|
400 | - $this->_pdf->fit_image($object,0,0,""); |
|
407 | + ($where === "all")) ) { |
|
408 | + $this->_pdf->fit_image($object,0,0,""); |
|
409 | + } |
|
401 | 410 | |
402 | 411 | unset($this->_objs[$object]); |
403 | 412 | } |
@@ -445,13 +454,15 @@ discard block |
||
445 | 454 | */ |
446 | 455 | protected function _set_line_style($width, $cap, $join, $dash) { |
447 | 456 | |
448 | - if ( count($dash) == 1 ) |
|
449 | - $dash[] = $dash[0]; |
|
457 | + if ( count($dash) == 1 ) { |
|
458 | + $dash[] = $dash[0]; |
|
459 | + } |
|
450 | 460 | |
451 | - if ( count($dash) > 1 ) |
|
452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
453 | - else |
|
454 | - $this->_pdf->setdash(0,0); |
|
461 | + if ( count($dash) > 1 ) { |
|
462 | + $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
463 | + } else { |
|
464 | + $this->_pdf->setdash(0,0); |
|
465 | + } |
|
455 | 466 | |
456 | 467 | switch ( $join ) { |
457 | 468 | case "miter": |
@@ -497,8 +508,9 @@ discard block |
||
497 | 508 | * @param array $color array(r,g,b) |
498 | 509 | */ |
499 | 510 | protected function _set_stroke_color($color) { |
500 | - if($this->_last_stroke_color == $color) |
|
501 | - return; |
|
511 | + if($this->_last_stroke_color == $color) { |
|
512 | + return; |
|
513 | + } |
|
502 | 514 | |
503 | 515 | $this->_last_stroke_color = $color; |
504 | 516 | |
@@ -512,8 +524,9 @@ discard block |
||
512 | 524 | * @param array $color array(r,g,b) |
513 | 525 | */ |
514 | 526 | protected function _set_fill_color($color) { |
515 | - if($this->_last_fill_color == $color) |
|
516 | - return; |
|
527 | + if($this->_last_fill_color == $color) { |
|
528 | + return; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | $this->_last_fill_color = $color; |
519 | 532 | |
@@ -549,19 +562,19 @@ discard block |
||
549 | 562 | |
550 | 563 | // Unicode encoding is only available for the commerical |
551 | 564 | // version of PDFlib and not PDFlib-Lite |
552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
553 | - $encoding = "unicode"; |
|
554 | - else |
|
555 | - $encoding = "auto"; |
|
565 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
566 | + $encoding = "unicode"; |
|
567 | + } else { |
|
568 | + $encoding = "auto"; |
|
569 | + } |
|
556 | 570 | |
557 | 571 | } |
558 | 572 | |
559 | 573 | $key = $font .":". $encoding .":". $options; |
560 | 574 | |
561 | - if ( isset($this->_fonts[$key]) ) |
|
562 | - return $this->_fonts[$key]; |
|
563 | - |
|
564 | - else { |
|
575 | + if ( isset($this->_fonts[$key]) ) { |
|
576 | + return $this->_fonts[$key]; |
|
577 | + } else { |
|
565 | 578 | |
566 | 579 | $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
567 | 580 | return $this->_fonts[$key]; |
@@ -622,8 +635,9 @@ discard block |
||
622 | 635 | $this->_set_fill_color($color); |
623 | 636 | $this->_set_stroke_color($color); |
624 | 637 | |
625 | - if ( !$fill && isset($width) ) |
|
626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
638 | + if ( !$fill && isset($width) ) { |
|
639 | + $this->_set_line_style($width, "square", "miter", $style); |
|
640 | + } |
|
627 | 641 | |
628 | 642 | $y = $this->y(array_pop($points)); |
629 | 643 | $x = array_pop($points); |
@@ -635,10 +649,11 @@ discard block |
||
635 | 649 | $this->_pdf->lineto($x,$y); |
636 | 650 | } |
637 | 651 | |
638 | - if ( $fill ) |
|
639 | - $this->_pdf->fill(); |
|
640 | - else |
|
641 | - $this->_pdf->closepath_stroke(); |
|
652 | + if ( $fill ) { |
|
653 | + $this->_pdf->fill(); |
|
654 | + } else { |
|
655 | + $this->_pdf->closepath_stroke(); |
|
656 | + } |
|
642 | 657 | } |
643 | 658 | |
644 | 659 | //........................................................................ |
@@ -648,17 +663,19 @@ discard block |
||
648 | 663 | $this->_set_fill_color($color); |
649 | 664 | $this->_set_stroke_color($color); |
650 | 665 | |
651 | - if ( !$fill && isset($width) ) |
|
652 | - $this->_set_line_style($width, "round", "round", $style); |
|
666 | + if ( !$fill && isset($width) ) { |
|
667 | + $this->_set_line_style($width, "round", "round", $style); |
|
668 | + } |
|
653 | 669 | |
654 | 670 | $y = $this->y($y); |
655 | 671 | |
656 | 672 | $this->_pdf->circle($x, $y, $r); |
657 | 673 | |
658 | - if ( $fill ) |
|
659 | - $this->_pdf->fill(); |
|
660 | - else |
|
661 | - $this->_pdf->stroke(); |
|
674 | + if ( $fill ) { |
|
675 | + $this->_pdf->fill(); |
|
676 | + } else { |
|
677 | + $this->_pdf->stroke(); |
|
678 | + } |
|
662 | 679 | |
663 | 680 | } |
664 | 681 | |
@@ -670,13 +687,13 @@ discard block |
||
670 | 687 | |
671 | 688 | $img_type = strtolower($img_type); |
672 | 689 | |
673 | - if ( $img_type === "jpg" ) |
|
674 | - $img_type = "jpeg"; |
|
675 | - |
|
676 | - if ( isset($this->_imgs[$img_url]) ) |
|
677 | - $img = $this->_imgs[$img_url]; |
|
690 | + if ( $img_type === "jpg" ) { |
|
691 | + $img_type = "jpeg"; |
|
692 | + } |
|
678 | 693 | |
679 | - else { |
|
694 | + if ( isset($this->_imgs[$img_url]) ) { |
|
695 | + $img = $this->_imgs[$img_url]; |
|
696 | + } else { |
|
680 | 697 | |
681 | 698 | $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
682 | 699 | } |
@@ -737,14 +754,17 @@ discard block |
||
737 | 754 | if ( strpos($url, '#') === 0 ) { |
738 | 755 | // Local link |
739 | 756 | $name = substr($url,1); |
740 | - if ( $name ) |
|
741 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
757 | + if ( $name ) { |
|
758 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
759 | + } |
|
742 | 760 | } else { |
743 | 761 | |
744 | 762 | list($proto, $host, $path, $file) = explode_url($url); |
745 | 763 | |
746 | - if ( $proto == "" || $proto === "file://" ) |
|
747 | - return; // Local links are not allowed |
|
764 | + if ( $proto == "" || $proto === "file://" ) { |
|
765 | + return; |
|
766 | + } |
|
767 | + // Local links are not allowed |
|
748 | 768 | $url = build_url($proto, $host, $path, $file); |
749 | 769 | $url = '{' . rawurldecode($url) . '}'; |
750 | 770 | |
@@ -842,8 +862,9 @@ discard block |
||
842 | 862 | */ |
843 | 863 | protected function _add_page_text() { |
844 | 864 | |
845 | - if ( !count($this->_page_text) ) |
|
846 | - return; |
|
865 | + if ( !count($this->_page_text) ) { |
|
866 | + return; |
|
867 | + } |
|
847 | 868 | |
848 | 869 | $this->_pdf->suspend_page(""); |
849 | 870 | |
@@ -883,10 +904,11 @@ discard block |
||
883 | 904 | // Add page text |
884 | 905 | $this->_add_page_text(); |
885 | 906 | |
886 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
887 | - $this->_pdf->set_value("compress", 0); |
|
888 | - else |
|
889 | - $this->_pdf->set_value("compress", 6); |
|
907 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
908 | + $this->_pdf->set_value("compress", 0); |
|
909 | + } else { |
|
910 | + $this->_pdf->set_value("compress", 6); |
|
911 | + } |
|
890 | 912 | |
891 | 913 | $this->_close(); |
892 | 914 | |
@@ -894,8 +916,9 @@ discard block |
||
894 | 916 | $data = $this->_pdf->get_buffer(); |
895 | 917 | $size = strlen($data); |
896 | 918 | |
897 | - } else |
|
898 | - $size = filesize($this->_file); |
|
919 | + } else { |
|
920 | + $size = filesize($this->_file); |
|
921 | + } |
|
899 | 922 | |
900 | 923 | |
901 | 924 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -907,26 +930,30 @@ discard block |
||
907 | 930 | |
908 | 931 | //header("Content-length: " . $size); |
909 | 932 | |
910 | - if ( self::$IN_MEMORY ) |
|
911 | - echo $data; |
|
912 | - |
|
913 | - else { |
|
933 | + if ( self::$IN_MEMORY ) { |
|
934 | + echo $data; |
|
935 | + } else { |
|
914 | 936 | |
915 | 937 | // Chunked readfile() |
916 | 938 | $chunk = (1 << 21); // 2 MB |
917 | 939 | $fh = fopen($this->_file, "rb"); |
918 | - if ( !$fh ) |
|
919 | - throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
940 | + if ( !$fh ) { |
|
941 | + throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
942 | + } |
|
920 | 943 | |
921 | - while ( !feof($fh) ) |
|
922 | - echo fread($fh,$chunk); |
|
944 | + while ( !feof($fh) ) { |
|
945 | + echo fread($fh,$chunk); |
|
946 | + } |
|
923 | 947 | fclose($fh); |
924 | 948 | |
925 | 949 | //debugpng |
926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | - if (!DEBUGKEEPTEMP) |
|
928 | - |
|
950 | + if (DEBUGPNG) { |
|
951 | + print '[pdflib stream unlink '.$this->_file.']'; |
|
952 | + } |
|
953 | + if (!DEBUGKEEPTEMP) { |
|
954 | + |
|
929 | 955 | unlink($this->_file); |
956 | + } |
|
930 | 957 | $this->_file = null; |
931 | 958 | } |
932 | 959 | |
@@ -942,24 +969,27 @@ discard block |
||
942 | 969 | // Add page text |
943 | 970 | $this->_add_page_text(); |
944 | 971 | |
945 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
946 | - $this->_pdf->set_value("compress", 0); |
|
947 | - else |
|
948 | - $this->_pdf->set_value("compress", 6); |
|
972 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
973 | + $this->_pdf->set_value("compress", 0); |
|
974 | + } else { |
|
975 | + $this->_pdf->set_value("compress", 6); |
|
976 | + } |
|
949 | 977 | |
950 | 978 | $this->_close(); |
951 | 979 | |
952 | - if ( self::$IN_MEMORY ) |
|
953 | - $data = $this->_pdf->get_buffer(); |
|
954 | - |
|
955 | - else { |
|
980 | + if ( self::$IN_MEMORY ) { |
|
981 | + $data = $this->_pdf->get_buffer(); |
|
982 | + } else { |
|
956 | 983 | $data = file_get_contents($this->_file); |
957 | 984 | |
958 | 985 | //debugpng |
959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | - if (!DEBUGKEEPTEMP) |
|
961 | - |
|
986 | + if (DEBUGPNG) { |
|
987 | + print '[pdflib output unlink '.$this->_file.']'; |
|
988 | + } |
|
989 | + if (!DEBUGKEEPTEMP) { |
|
990 | + |
|
962 | 991 | unlink($this->_file); |
992 | + } |
|
963 | 993 | $this->_file = null; |
964 | 994 | } |
965 | 995 |
@@ -112,8 +112,9 @@ discard block |
||
112 | 112 | // Set the containing blocks and reflow each child |
113 | 113 | foreach ( $this->_frame->get_children() as $child ) { |
114 | 114 | |
115 | - if ( $page->is_full() ) |
|
116 | - break; |
|
115 | + if ( $page->is_full() ) { |
|
116 | + break; |
|
117 | + } |
|
117 | 118 | |
118 | 119 | $child->set_containing_block($content_x, $content_y, $cb_w, $h); |
119 | 120 | $child->reflow(); |
@@ -132,11 +133,13 @@ discard block |
||
132 | 133 | // Let the cellmap know our height |
133 | 134 | $cell_height = $height / count($cells["rows"]); |
134 | 135 | |
135 | - if ($style_height < $height) |
|
136 | - $cell_height += $top_space + $bottom_space; |
|
136 | + if ($style_height < $height) { |
|
137 | + $cell_height += $top_space + $bottom_space; |
|
138 | + } |
|
137 | 139 | |
138 | - foreach ($cells["rows"] as $i) |
|
139 | - $cellmap->set_row_height($i, $cell_height); |
|
140 | + foreach ($cells["rows"] as $i) { |
|
141 | + $cellmap->set_row_height($i, $cell_height); |
|
142 | + } |
|
140 | 143 | |
141 | 144 | $style->height = $height; |
142 | 145 |
@@ -63,17 +63,20 @@ discard block |
||
63 | 63 | */ |
64 | 64 | if ( !function_exists("pre_r") ) { |
65 | 65 | function pre_r($mixed, $return = false) { |
66 | - if ($return) |
|
67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
66 | + if ($return) { |
|
67 | + return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
68 | + } |
|
68 | 69 | |
69 | - if ( php_sapi_name() !== "cli") |
|
70 | - echo ("<pre>"); |
|
70 | + if ( php_sapi_name() !== "cli") { |
|
71 | + echo ("<pre>"); |
|
72 | + } |
|
71 | 73 | print_r($mixed); |
72 | 74 | |
73 | - if ( php_sapi_name() !== "cli") |
|
74 | - echo("</pre>"); |
|
75 | - else |
|
76 | - echo ("\n"); |
|
75 | + if ( php_sapi_name() !== "cli") { |
|
76 | + echo("</pre>"); |
|
77 | + } else { |
|
78 | + echo ("\n"); |
|
79 | + } |
|
77 | 80 | flush(); |
78 | 81 | |
79 | 82 | } |
@@ -89,12 +92,14 @@ discard block |
||
89 | 92 | */ |
90 | 93 | if ( !function_exists("pre_var_dump") ) { |
91 | 94 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
93 | - echo("<pre>"); |
|
95 | + if ( php_sapi_name() !== "cli") { |
|
96 | + echo("<pre>"); |
|
97 | + } |
|
94 | 98 | var_dump($mixed); |
95 | - if ( php_sapi_name() !== "cli") |
|
96 | - echo("</pre>"); |
|
97 | -} |
|
99 | + if ( php_sapi_name() !== "cli") { |
|
100 | + echo("</pre>"); |
|
101 | + } |
|
102 | + } |
|
98 | 103 | } |
99 | 104 | |
100 | 105 | /** |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | // Is the url already fully qualified? |
124 | - if ( mb_strpos($url, "://") !== false ) |
|
125 | - return $url; |
|
129 | + if ( mb_strpos($url, "://") !== false ) { |
|
130 | + return $url; |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $ret = $protocol; |
128 | 134 | |
@@ -170,24 +176,29 @@ discard block |
||
170 | 176 | |
171 | 177 | if ( isset($arr["scheme"]) && |
172 | 178 | $arr["scheme"] !== "file" && |
173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
179 | + mb_strlen($arr["scheme"]) > 1 ) { |
|
180 | + // Exclude windows drive letters... |
|
174 | 181 | { |
175 | 182 | $protocol = $arr["scheme"] . "://"; |
183 | + } |
|
176 | 184 | |
177 | 185 | if ( isset($arr["user"]) ) { |
178 | 186 | $host .= $arr["user"]; |
179 | 187 | |
180 | - if ( isset($arr["pass"]) ) |
|
181 | - $host .= "@" . $arr["pass"]; |
|
188 | + if ( isset($arr["pass"]) ) { |
|
189 | + $host .= "@" . $arr["pass"]; |
|
190 | + } |
|
182 | 191 | |
183 | 192 | $host .= ":"; |
184 | 193 | } |
185 | 194 | |
186 | - if ( isset($arr["host"]) ) |
|
187 | - $host .= $arr["host"]; |
|
195 | + if ( isset($arr["host"]) ) { |
|
196 | + $host .= $arr["host"]; |
|
197 | + } |
|
188 | 198 | |
189 | - if ( isset($arr["port"]) ) |
|
190 | - $host .= ":" . $arr["port"]; |
|
199 | + if ( isset($arr["port"]) ) { |
|
200 | + $host .= ":" . $arr["port"]; |
|
201 | + } |
|
191 | 202 | |
192 | 203 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
193 | 204 | // Do we have a trailing slash? |
@@ -200,17 +211,20 @@ discard block |
||
200 | 211 | } |
201 | 212 | } |
202 | 213 | |
203 | - if ( isset($arr["query"]) ) |
|
204 | - $file .= "?" . $arr["query"]; |
|
214 | + if ( isset($arr["query"]) ) { |
|
215 | + $file .= "?" . $arr["query"]; |
|
216 | + } |
|
205 | 217 | |
206 | - if ( isset($arr["fragment"]) ) |
|
207 | - $file .= "#" . $arr["fragment"]; |
|
218 | + if ( isset($arr["fragment"]) ) { |
|
219 | + $file .= "#" . $arr["fragment"]; |
|
220 | + } |
|
208 | 221 | |
209 | 222 | } else { |
210 | 223 | |
211 | 224 | $i = mb_strpos($url, "file://"); |
212 | - if ( $i !== false) |
|
213 | - $url = mb_substr($url, $i + 7); |
|
225 | + if ( $i !== false) { |
|
226 | + $url = mb_substr($url, $i + 7); |
|
227 | + } |
|
214 | 228 | |
215 | 229 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
216 | 230 | // network filenames like //COMPU/SHARENAME |
@@ -262,11 +276,13 @@ discard block |
||
262 | 276 | "dc", "dcc", "dccc", "cm"); |
263 | 277 | static $thou = array("", "m", "mm", "mmm"); |
264 | 278 | |
265 | - if ( !is_numeric($num) ) |
|
266 | - throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
279 | + if ( !is_numeric($num) ) { |
|
280 | + throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
281 | + } |
|
267 | 282 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
269 | - return "(out of range)"; |
|
283 | + if ( $num > 4000 || $num < 0 ) { |
|
284 | + return "(out of range)"; |
|
285 | + } |
|
270 | 286 | |
271 | 287 | $num = strrev((string)$num); |
272 | 288 | |
@@ -372,10 +388,11 @@ discard block |
||
372 | 388 | |
373 | 389 | if ( !function_exists("mb_substr") ) { |
374 | 390 | function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
375 | - if ( is_null($length) ) |
|
376 | - return substr($str, $start); |
|
377 | - else |
|
378 | - return substr($str, $start, $length); |
|
391 | + if ( is_null($length) ) { |
|
392 | + return substr($str, $start); |
|
393 | + } else { |
|
394 | + return substr($str, $start, $length); |
|
395 | + } |
|
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
@@ -402,14 +419,17 @@ discard block |
||
402 | 419 | */ |
403 | 420 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 421 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
422 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) { |
|
423 | + // Not a warning or notice |
|
406 | 424 | throw new DOMPDF_Exception($errstr . " $errno"); |
425 | + } |
|
407 | 426 | |
408 | 427 | global $_dompdf_warnings; |
409 | 428 | global $_dompdf_show_warnings; |
410 | 429 | |
411 | - if ( $_dompdf_show_warnings ) |
|
412 | - echo $errstr . "\n"; |
|
430 | + if ( $_dompdf_show_warnings ) { |
|
431 | + echo $errstr . "\n"; |
|
432 | + } |
|
413 | 433 | |
414 | 434 | $_dompdf_warnings[] = $errstr; |
415 | 435 | } |
@@ -496,9 +516,10 @@ discard block |
||
496 | 516 | if ( !function_exists("mark_memusage") ) { |
497 | 517 | function mark_memusage($location) { |
498 | 518 | global $memusage; |
499 | - if ( isset($memusage) ) |
|
500 | - $memusage[$location] = memory_get_usage(); |
|
501 | -} |
|
519 | + if ( isset($memusage) ) { |
|
520 | + $memusage[$location] = memory_get_usage(); |
|
521 | + } |
|
522 | + } |
|
502 | 523 | } |
503 | 524 | |
504 | 525 | /** |
@@ -87,8 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | function get_current_line($i = null) { |
89 | 89 | $cl = $this->_lines[$this->_cl]; |
90 | - if ( isset($i) ) |
|
91 | - return $cl[$i]; |
|
90 | + if ( isset($i) ) { |
|
91 | + return $cl[$i]; |
|
92 | + } |
|
92 | 93 | return $cl; |
93 | 94 | } |
94 | 95 | |
@@ -102,23 +103,28 @@ discard block |
||
102 | 103 | } |
103 | 104 | |
104 | 105 | function clear_line($i) { |
105 | - if ( isset($this->_lines[$i]) ) |
|
106 | - unset($this->_lines[$i]); |
|
106 | + if ( isset($this->_lines[$i]) ) { |
|
107 | + unset($this->_lines[$i]); |
|
108 | + } |
|
107 | 109 | } |
108 | 110 | |
109 | 111 | function set_line($lineno, $y = null, $w = null, $h = null) { |
110 | 112 | |
111 | - if ( is_array($y) ) |
|
112 | - extract($y); |
|
113 | + if ( is_array($y) ) { |
|
114 | + extract($y); |
|
115 | + } |
|
113 | 116 | |
114 | - if (is_numeric($y)) |
|
115 | - $this->_lines[$lineno]["y"] = $y; |
|
117 | + if (is_numeric($y)) { |
|
118 | + $this->_lines[$lineno]["y"] = $y; |
|
119 | + } |
|
116 | 120 | |
117 | - if (is_numeric($w)) |
|
118 | - $this->_lines[$lineno]["w"] = $w; |
|
121 | + if (is_numeric($w)) { |
|
122 | + $this->_lines[$lineno]["w"] = $w; |
|
123 | + } |
|
119 | 124 | |
120 | - if (is_numeric($h)) |
|
121 | - $this->_lines[$lineno]["h"] = $h; |
|
125 | + if (is_numeric($h)) { |
|
126 | + $this->_lines[$lineno]["h"] = $h; |
|
127 | + } |
|
122 | 128 | |
123 | 129 | } |
124 | 130 | |
@@ -136,8 +142,9 @@ discard block |
||
136 | 142 | } |
137 | 143 | |
138 | 144 | // Add each child of the inline frame to the line individually |
139 | - foreach ($frame->get_children() as $child) |
|
140 | - $this->add_frame_to_line( $child ); |
|
145 | + foreach ($frame->get_children() as $child) { |
|
146 | + $this->add_frame_to_line( $child ); |
|
147 | + } |
|
141 | 148 | |
142 | 149 | return; |
143 | 150 | } |
@@ -156,8 +163,9 @@ discard block |
||
156 | 163 | |
157 | 164 | $w = $frame->get_margin_width(); |
158 | 165 | |
159 | - if ( $w == 0 ) |
|
160 | - return; |
|
166 | + if ( $w == 0 ) { |
|
167 | + return; |
|
168 | + } |
|
161 | 169 | |
162 | 170 | // Debugging code: |
163 | 171 | /* |
@@ -176,16 +184,18 @@ discard block |
||
176 | 184 | */ |
177 | 185 | // End debugging |
178 | 186 | |
179 | - if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) |
|
180 | - $this->add_line(); |
|
187 | + if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) { |
|
188 | + $this->add_line(); |
|
189 | + } |
|
181 | 190 | |
182 | 191 | $frame->position(); |
183 | 192 | |
184 | 193 | |
185 | 194 | $this->_lines[$this->_cl]["frames"][] = $frame; |
186 | 195 | |
187 | - if ( $frame->get_node()->nodeName === "#text") |
|
188 | - $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
196 | + if ( $frame->get_node()->nodeName === "#text") { |
|
197 | + $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text())); |
|
198 | + } |
|
189 | 199 | |
190 | 200 | $this->_lines[$this->_cl]["w"] += $w; |
191 | 201 | $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height()); |
@@ -197,13 +207,15 @@ discard block |
||
197 | 207 | $i = $this->_cl; |
198 | 208 | |
199 | 209 | while ($i >= 0) { |
200 | - if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) |
|
201 | - break; |
|
210 | + if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) { |
|
211 | + break; |
|
212 | + } |
|
202 | 213 | $i--; |
203 | 214 | } |
204 | 215 | |
205 | - if ( $j === false ) |
|
206 | - return; |
|
216 | + if ( $j === false ) { |
|
217 | + return; |
|
218 | + } |
|
207 | 219 | |
208 | 220 | // Remove $frame and all frames that follow |
209 | 221 | while ($j < count($this->_lines[$i]["frames"])) { |
@@ -214,14 +226,16 @@ discard block |
||
214 | 226 | |
215 | 227 | // Recalculate the height of the line |
216 | 228 | $h = 0; |
217 | - foreach ($this->_lines[$i]["frames"] as $f) |
|
218 | - $h = max( $h, $f->get_margin_height() ); |
|
229 | + foreach ($this->_lines[$i]["frames"] as $f) { |
|
230 | + $h = max( $h, $f->get_margin_height() ); |
|
231 | + } |
|
219 | 232 | |
220 | 233 | $this->_lines[$i]["h"] = $h; |
221 | 234 | |
222 | 235 | // Remove all lines that follow |
223 | - while ($this->_cl > $i) |
|
224 | - unset($this->_lines[ $this->_cl-- ]); |
|
236 | + while ($this->_cl > $i) { |
|
237 | + unset($this->_lines[ $this->_cl-- ]); |
|
238 | + } |
|
225 | 239 | |
226 | 240 | } |
227 | 241 | |
@@ -252,17 +266,19 @@ discard block |
||
252 | 266 | } |
253 | 267 | |
254 | 268 | function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) { |
255 | - if ( !isset($this->_counters[$id]) ) |
|
256 | - $this->_counters[$id] = $increment; |
|
257 | - else |
|
258 | - $this->_counters[$id] += $increment; |
|
269 | + if ( !isset($this->_counters[$id]) ) { |
|
270 | + $this->_counters[$id] = $increment; |
|
271 | + } else { |
|
272 | + $this->_counters[$id] += $increment; |
|
273 | + } |
|
259 | 274 | |
260 | 275 | } |
261 | 276 | |
262 | 277 | function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") { |
263 | 278 | $type = mb_strtolower($type); |
264 | - if ( !isset($this->_counters[$id]) ) |
|
265 | - $this->_counters[$id] = 0; |
|
279 | + if ( !isset($this->_counters[$id]) ) { |
|
280 | + $this->_counters[$id] = 0; |
|
281 | + } |
|
266 | 282 | |
267 | 283 | switch ($type) { |
268 | 284 |
@@ -398,20 +398,24 @@ discard block |
||
398 | 398 | */ |
399 | 399 | function length_in_pt($length, $ref_size = null) { |
400 | 400 | |
401 | - if ( !is_array($length) ) |
|
402 | - $length = array($length); |
|
401 | + if ( !is_array($length) ) { |
|
402 | + $length = array($length); |
|
403 | + } |
|
403 | 404 | |
404 | - if ( !isset($ref_size) ) |
|
405 | - $ref_size = self::$default_font_size; |
|
405 | + if ( !isset($ref_size) ) { |
|
406 | + $ref_size = self::$default_font_size; |
|
407 | + } |
|
406 | 408 | |
407 | 409 | $ret = 0; |
408 | 410 | foreach ($length as $l) { |
409 | 411 | |
410 | - if ( $l === "auto" ) |
|
411 | - return "auto"; |
|
412 | + if ( $l === "auto" ) { |
|
413 | + return "auto"; |
|
414 | + } |
|
412 | 415 | |
413 | - if ( $l === "none" ) |
|
414 | - return "none"; |
|
416 | + if ( $l === "none" ) { |
|
417 | + return "none"; |
|
418 | + } |
|
415 | 419 | |
416 | 420 | // Assume numeric values are already in points |
417 | 421 | if ( is_numeric($l) ) { |
@@ -567,8 +571,9 @@ discard block |
||
567 | 571 | } |
568 | 572 | } |
569 | 573 | |
570 | - if ( isset($style->_props["font_size"]) ) |
|
571 | - $this->__font_size_calculated = false; |
|
574 | + if ( isset($style->_props["font_size"]) ) { |
|
575 | + $this->__font_size_calculated = false; |
|
576 | + } |
|
572 | 577 | } |
573 | 578 | |
574 | 579 | |
@@ -580,10 +585,11 @@ discard block |
||
580 | 585 | * @return array |
581 | 586 | */ |
582 | 587 | function munge_colour($colour) { |
583 | - if ( is_array($colour) ) |
|
584 | - // Assume the array has the right format... |
|
588 | + if ( is_array($colour) ) { |
|
589 | + // Assume the array has the right format... |
|
585 | 590 | // FIXME: should/could verify this. |
586 | 591 | return $colour; |
592 | + } |
|
587 | 593 | |
588 | 594 | $r = 0; |
589 | 595 | $g = 0; |
@@ -689,19 +695,22 @@ discard block |
||
689 | 695 | $j = mb_strpos($colour, ")"); |
690 | 696 | |
691 | 697 | // Bad colour value |
692 | - if ($i === false || $j === false) |
|
693 | - return null; |
|
698 | + if ($i === false || $j === false) { |
|
699 | + return null; |
|
700 | + } |
|
694 | 701 | |
695 | 702 | $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
696 | 703 | |
697 | - if (count($triplet) != 3) |
|
698 | - return null; |
|
704 | + if (count($triplet) != 3) { |
|
705 | + return null; |
|
706 | + } |
|
699 | 707 | |
700 | 708 | foreach (array_keys($triplet) as $c) { |
701 | 709 | $triplet[$c] = trim($triplet[$c]); |
702 | 710 | |
703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
704 | - $triplet[$c] = round($triplet[$c] * 0.255); |
|
711 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) { |
|
712 | + $triplet[$c] = round($triplet[$c] * 0.255); |
|
713 | + } |
|
705 | 714 | } |
706 | 715 | |
707 | 716 | list($r, $g, $b) = $triplet; |
@@ -796,10 +805,11 @@ discard block |
||
796 | 805 | |
797 | 806 | $method = "set_$prop"; |
798 | 807 | |
799 | - if ( method_exists($this, $method) ) |
|
800 | - $this->$method($val); |
|
801 | - else |
|
802 | - $this->_props[$prop] = $val; |
|
808 | + if ( method_exists($this, $method) ) { |
|
809 | + $this->$method($val); |
|
810 | + } else { |
|
811 | + $this->_props[$prop] = $val; |
|
812 | + } |
|
803 | 813 | |
804 | 814 | } |
805 | 815 | |
@@ -818,20 +828,24 @@ discard block |
||
818 | 828 | */ |
819 | 829 | function __get($prop) { |
820 | 830 | |
821 | - if ( !isset(self::$_defaults[$prop]) ) |
|
822 | - throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
831 | + if ( !isset(self::$_defaults[$prop]) ) { |
|
832 | + throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
833 | + } |
|
823 | 834 | |
824 | - if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
|
825 | - return $this->_prop_cache[$prop]; |
|
835 | + if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) { |
|
836 | + return $this->_prop_cache[$prop]; |
|
837 | + } |
|
826 | 838 | |
827 | 839 | $method = "get_$prop"; |
828 | 840 | |
829 | 841 | // Fall back on defaults if property is not set |
830 | - if ( !isset($this->_props[$prop]) ) |
|
831 | - $this->_props[$prop] = self::$_defaults[$prop]; |
|
842 | + if ( !isset($this->_props[$prop]) ) { |
|
843 | + $this->_props[$prop] = self::$_defaults[$prop]; |
|
844 | + } |
|
832 | 845 | |
833 | - if ( method_exists($this, $method) ) |
|
834 | - return $this->_prop_cache[$prop] = $this->$method(); |
|
846 | + if ( method_exists($this, $method) ) { |
|
847 | + return $this->_prop_cache[$prop] = $this->$method(); |
|
848 | + } |
|
835 | 849 | |
836 | 850 | |
837 | 851 | return $this->_prop_cache[$prop] = $this->_props[$prop]; |
@@ -859,10 +873,11 @@ discard block |
||
859 | 873 | |
860 | 874 | if ( is_numeric($weight) ) { |
861 | 875 | |
862 | - if ( $weight < 600 ) |
|
863 | - $weight = "normal"; |
|
864 | - else |
|
865 | - $weight = "bold"; |
|
876 | + if ( $weight < 600 ) { |
|
877 | + $weight = "normal"; |
|
878 | + } else { |
|
879 | + $weight = "bold"; |
|
880 | + } |
|
866 | 881 | |
867 | 882 | } else if ( $weight === "bold" || $weight === "bolder" ) { |
868 | 883 | $weight = "bold"; |
@@ -875,14 +890,15 @@ discard block |
||
875 | 890 | // Resolve font-style |
876 | 891 | $font_style = $this->__get("font_style"); |
877 | 892 | |
878 | - if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
879 | - $subtype = "bold_italic"; |
|
880 | - else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) |
|
881 | - $subtype = "bold"; |
|
882 | - else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
|
883 | - $subtype = "italic"; |
|
884 | - else |
|
885 | - $subtype = "normal"; |
|
893 | + if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) { |
|
894 | + $subtype = "bold_italic"; |
|
895 | + } else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) { |
|
896 | + $subtype = "bold"; |
|
897 | + } else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) { |
|
898 | + $subtype = "italic"; |
|
899 | + } else { |
|
900 | + $subtype = "normal"; |
|
901 | + } |
|
886 | 902 | |
887 | 903 | // Resolve the font family |
888 | 904 | if ($DEBUGCSS) { |
@@ -899,21 +915,29 @@ discard block |
||
899 | 915 | //remove leading and trailing string delimiters, e.g. on font names with spaces; |
900 | 916 | //remove leading and trailing whitespace |
901 | 917 | $family=trim($family," \t\n\r\x0B\"'"); |
902 | - if ($DEBUGCSS) print '('.$family.')'; |
|
918 | + if ($DEBUGCSS) { |
|
919 | + print '('.$family.')'; |
|
920 | + } |
|
903 | 921 | $font = Font_Metrics::get_font($family, $subtype); |
904 | 922 | |
905 | 923 | if ( $font ) { |
906 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
924 | + if ($DEBUGCSS) { |
|
925 | + print '('.$font.")get_font_family]\n</pre>"; |
|
926 | + } |
|
907 | 927 | return $font; |
908 | 928 | } |
909 | 929 | } |
910 | 930 | |
911 | 931 | $family = null; |
912 | - if ($DEBUGCSS) print '(default)'; |
|
932 | + if ($DEBUGCSS) { |
|
933 | + print '(default)'; |
|
934 | + } |
|
913 | 935 | $font = Font_Metrics::get_font($family, $subtype); |
914 | 936 | |
915 | 937 | if ( $font ) { |
916 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
938 | + if ($DEBUGCSS) { |
|
939 | + print '('.$font.")get_font_family]\n</pre>"; |
|
940 | + } |
|
917 | 941 | return $font; |
918 | 942 | } |
919 | 943 | throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); |
@@ -928,16 +952,19 @@ discard block |
||
928 | 952 | */ |
929 | 953 | function get_font_size() { |
930 | 954 | |
931 | - if ( $this->__font_size_calculated ) |
|
932 | - return $this->_props["font_size"]; |
|
955 | + if ( $this->__font_size_calculated ) { |
|
956 | + return $this->_props["font_size"]; |
|
957 | + } |
|
933 | 958 | |
934 | - if ( !isset($this->_props["font_size"]) ) |
|
935 | - $fs = self::$_defaults["font_size"]; |
|
936 | - else |
|
937 | - $fs = $this->_props["font_size"]; |
|
959 | + if ( !isset($this->_props["font_size"]) ) { |
|
960 | + $fs = self::$_defaults["font_size"]; |
|
961 | + } else { |
|
962 | + $fs = $this->_props["font_size"]; |
|
963 | + } |
|
938 | 964 | |
939 | - if ( !isset($this->_parent_font_size) ) |
|
940 | - $this->_parent_font_size = self::$default_font_size; |
|
965 | + if ( !isset($this->_parent_font_size) ) { |
|
966 | + $this->_parent_font_size = self::$default_font_size; |
|
967 | + } |
|
941 | 968 | |
942 | 969 | switch ($fs) { |
943 | 970 | |
@@ -976,14 +1003,13 @@ discard block |
||
976 | 1003 | } |
977 | 1004 | |
978 | 1005 | // Ensure relative sizes resolve to something |
979 | - if ( ($i = mb_strpos($fs, "em")) !== false ) |
|
980 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
981 | - |
|
982 | - else if ( ($i = mb_strpos($fs, "ex")) !== false ) |
|
983 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
984 | - |
|
985 | - else |
|
986 | - $fs = $this->length_in_pt($fs); |
|
1006 | + if ( ($i = mb_strpos($fs, "em")) !== false ) { |
|
1007 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
1008 | + } else if ( ($i = mb_strpos($fs, "ex")) !== false ) { |
|
1009 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
1010 | + } else { |
|
1011 | + $fs = $this->length_in_pt($fs); |
|
1012 | + } |
|
987 | 1013 | |
988 | 1014 | //see __set and __get, on all assignments clear cache! |
989 | 1015 | $this->_prop_cache["font_size"] = null; |
@@ -998,8 +1024,9 @@ discard block |
||
998 | 1024 | * @return float |
999 | 1025 | */ |
1000 | 1026 | function get_word_spacing() { |
1001 | - if ( $this->_props["word_spacing"] === "normal" ) |
|
1002 | - return 0; |
|
1027 | + if ( $this->_props["word_spacing"] === "normal" ) { |
|
1028 | + return 0; |
|
1029 | + } |
|
1003 | 1030 | |
1004 | 1031 | return $this->_props["word_spacing"]; |
1005 | 1032 | } |
@@ -1009,11 +1036,13 @@ discard block |
||
1009 | 1036 | * @return float |
1010 | 1037 | */ |
1011 | 1038 | function get_line_height() { |
1012 | - if ( $this->_props["line_height"] === "normal" ) |
|
1013 | - return self::$default_line_height * $this->get_font_size(); |
|
1039 | + if ( $this->_props["line_height"] === "normal" ) { |
|
1040 | + return self::$default_line_height * $this->get_font_size(); |
|
1041 | + } |
|
1014 | 1042 | |
1015 | - if ( is_numeric($this->_props["line_height"]) ) |
|
1016 | - return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
1043 | + if ( is_numeric($this->_props["line_height"]) ) { |
|
1044 | + return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
1045 | + } |
|
1017 | 1046 | |
1018 | 1047 | return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() ); |
1019 | 1048 | } |
@@ -1104,10 +1133,11 @@ discard block |
||
1104 | 1133 | break; |
1105 | 1134 | |
1106 | 1135 | case "center": |
1107 | - if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
|
1108 | - $y = "50%"; |
|
1109 | - else |
|
1110 | - $x = "50%"; |
|
1136 | + if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) { |
|
1137 | + $y = "50%"; |
|
1138 | + } else { |
|
1139 | + $x = "50%"; |
|
1140 | + } |
|
1111 | 1141 | break; |
1112 | 1142 | |
1113 | 1143 | default: |
@@ -1119,11 +1149,13 @@ discard block |
||
1119 | 1149 | $y = "50%"; |
1120 | 1150 | } |
1121 | 1151 | |
1122 | - if ( !isset($x) ) |
|
1123 | - $x = "0%"; |
|
1152 | + if ( !isset($x) ) { |
|
1153 | + $x = "0%"; |
|
1154 | + } |
|
1124 | 1155 | |
1125 | - if ( !isset($y) ) |
|
1126 | - $y = "0%"; |
|
1156 | + if ( !isset($y) ) { |
|
1157 | + $y = "0%"; |
|
1158 | + } |
|
1127 | 1159 | |
1128 | 1160 | return array( 0 => $x, "x" => $x, |
1129 | 1161 | 1 => $y, "y" => $y ); |
@@ -1477,8 +1509,9 @@ discard block |
||
1477 | 1509 | function set_color($colour) { |
1478 | 1510 | $col = $this->munge_colour($colour); |
1479 | 1511 | |
1480 | - if ( is_null($col) ) |
|
1481 | - $col = self::$_defaults["color"]; |
|
1512 | + if ( is_null($col) ) { |
|
1513 | + $col = self::$_defaults["color"]; |
|
1514 | + } |
|
1482 | 1515 | |
1483 | 1516 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1484 | 1517 | $this->_prop_cache["color"] = null; |
@@ -1493,8 +1526,9 @@ discard block |
||
1493 | 1526 | */ |
1494 | 1527 | function set_background_color($colour) { |
1495 | 1528 | $col = $this->munge_colour($colour); |
1496 | - if ( is_null($col) ) |
|
1497 | - $col = self::$_defaults["background_color"]; |
|
1529 | + if ( is_null($col) ) { |
|
1530 | + $col = self::$_defaults["background_color"]; |
|
1531 | + } |
|
1498 | 1532 | |
1499 | 1533 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1500 | 1534 | $this->_prop_cache["background_color"] = null; |
@@ -1520,8 +1554,9 @@ discard block |
||
1520 | 1554 | * @param string $val |
1521 | 1555 | */ |
1522 | 1556 | function set_background_repeat($val) { |
1523 | - if ( is_null($val) ) |
|
1524 | - $val = self::$_defaults["background_repeat"]; |
|
1557 | + if ( is_null($val) ) { |
|
1558 | + $val = self::$_defaults["background_repeat"]; |
|
1559 | + } |
|
1525 | 1560 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1526 | 1561 | $this->_prop_cache["background_repeat"] = null; |
1527 | 1562 | $this->_props["background_repeat"] = $val; |
@@ -1534,8 +1569,9 @@ discard block |
||
1534 | 1569 | * @param string $val |
1535 | 1570 | */ |
1536 | 1571 | function set_background_attachment($val) { |
1537 | - if ( is_null($val) ) |
|
1538 | - $val = self::$_defaults["background_attachment"]; |
|
1572 | + if ( is_null($val) ) { |
|
1573 | + $val = self::$_defaults["background_attachment"]; |
|
1574 | + } |
|
1539 | 1575 | |
1540 | 1576 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1541 | 1577 | $this->_prop_cache["background_attachment"] = null; |
@@ -1549,8 +1585,9 @@ discard block |
||
1549 | 1585 | * @param string $val |
1550 | 1586 | */ |
1551 | 1587 | function set_background_position($val) { |
1552 | - if ( is_null($val) ) |
|
1553 | - $val = self::$_defaults["background_position"]; |
|
1588 | + if ( is_null($val) ) { |
|
1589 | + $val = self::$_defaults["background_position"]; |
|
1590 | + } |
|
1554 | 1591 | |
1555 | 1592 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1556 | 1593 | $this->_prop_cache["background_position"] = null; |
@@ -1688,8 +1725,9 @@ discard block |
||
1688 | 1725 | * @param string $break |
1689 | 1726 | */ |
1690 | 1727 | function set_page_break_before($break) { |
1691 | - if ($break === "left" || $break === "right") |
|
1692 | - $break = "always"; |
|
1728 | + if ($break === "left" || $break === "right") { |
|
1729 | + $break = "always"; |
|
1730 | + } |
|
1693 | 1731 | |
1694 | 1732 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1695 | 1733 | $this->_prop_cache["page_break_before"] = null; |
@@ -1697,8 +1735,9 @@ discard block |
||
1697 | 1735 | } |
1698 | 1736 | |
1699 | 1737 | function set_page_break_after($break) { |
1700 | - if ($break === "left" || $break === "right") |
|
1701 | - $break = "always"; |
|
1738 | + if ($break === "left" || $break === "right") { |
|
1739 | + $break = "always"; |
|
1740 | + } |
|
1702 | 1741 | |
1703 | 1742 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1704 | 1743 | $this->_prop_cache["page_break_after"] = null; |
@@ -1847,8 +1886,9 @@ discard block |
||
1847 | 1886 | |
1848 | 1887 | $arr = explode(" ", $val); |
1849 | 1888 | |
1850 | - if ( count($arr) == 1 ) |
|
1851 | - $arr[1] = $arr[0]; |
|
1889 | + if ( count($arr) == 1 ) { |
|
1890 | + $arr[1] = $arr[0]; |
|
1891 | + } |
|
1852 | 1892 | |
1853 | 1893 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1854 | 1894 | $this->_prop_cache["border_spacing"] = null; |