@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | protected $_pdf; |
57 | 57 | protected $_cache_id; |
58 | 58 | protected $_current_page_id; |
59 | - protected $_fonts; // fonts used in this document |
|
59 | + protected $_fonts; // fonts used in this document |
|
60 | 60 | |
61 | 61 | function __construct($cache_id, CPDF_Adapter $pdf) { |
62 | 62 | $this->_pdf = $pdf; |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | $this->_pdf->image($img_url, $x, $y, $w, $h); |
116 | 116 | } |
117 | 117 | |
118 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
118 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
119 | 119 | $this->_fonts[$font] = true; |
120 | 120 | $this->_pdf->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
121 | 121 | } |
122 | 122 | |
123 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
123 | + function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
124 | 124 | |
125 | 125 | // We want to remove this from cached pages since it may not be correct |
126 | 126 | $this->_pdf->close_object(); |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | function stream($filename) { |
155 | 155 | // Store the last page in the page cache |
156 | - if ( !is_null($this->_current_page_id) ) { |
|
156 | + if (!is_null($this->_current_page_id)) { |
|
157 | 157 | $this->_pdf->close_object(); |
158 | 158 | $this->_pdf->add_object($this->_current_page_id, "add"); |
159 | 159 | Page_Cache::store_page($this->_cache_id, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | |
170 | 170 | function &output() { |
171 | 171 | // Store the last page in the page cache |
172 | - if ( !is_null($this->_current_page_id) ) { |
|
172 | + if (!is_null($this->_current_page_id)) { |
|
173 | 173 | $this->_pdf->close_object(); |
174 | 174 | $this->_pdf->add_object($this->_current_page_id, "add"); |
175 | 175 | Page_Cache::store_page($this->_cache_id, |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | /* $Id: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
41 | 41 | |
42 | -require_once(DOMPDF_LIB_DIR . '/tcpdf/tcpdf.php'); |
|
42 | +require_once(DOMPDF_LIB_DIR.'/tcpdf/tcpdf.php'); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * TCPDF PDF Rendering interface |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | */ |
139 | 139 | function __construct($paper = "letter", $orientation = "portrait") { |
140 | 140 | |
141 | - if ( is_array($paper) ) |
|
141 | + if (is_array($paper)) |
|
142 | 142 | $size = $paper; |
143 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
143 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
144 | 144 | $size = self::$PAPER_SIZE[$paper]; |
145 | 145 | else |
146 | 146 | $size = self::$PAPER_SIZE["letter"]; |
147 | 147 | |
148 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
148 | + if (mb_strtolower($orientation) === "landscape") { |
|
149 | 149 | $a = $size[3]; |
150 | 150 | $size[3] = $size[2]; |
151 | 151 | $size[2] = $a; |
@@ -186,8 +186,8 @@ discard block |
||
186 | 186 | $colour[1] = round(255 * $colour[1]); |
187 | 187 | $colour[2] = round(255 * $colour[2]); |
188 | 188 | |
189 | - if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) { |
|
190 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
189 | + if (is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color) { |
|
190 | + $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]); |
|
191 | 191 | $this->_last_stroke_color = $color; |
192 | 192 | } |
193 | 193 | |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | $colour[1] = round(255 * $colour[1]); |
204 | 204 | $colour[2] = round(255 * $colour[2]); |
205 | 205 | |
206 | - if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) { |
|
207 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
206 | + if (is_null($this->_last_fill_color) || $color != $this->_last_fill_color) { |
|
207 | + $this->_pdf->SetDrawColor($color[0], $color[1], $color[2]); |
|
208 | 208 | $this->_last_fill_color = $color; |
209 | 209 | } |
210 | 210 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param int $count |
242 | 242 | */ |
243 | 243 | function set_page_count($count) { |
244 | - $this->_page_count = (int)$count; |
|
244 | + $this->_page_count = (int) $count; |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | */ |
262 | 262 | function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
263 | 263 | |
264 | - if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
|
264 | + if (is_null($this->_last_line_width) || $width != $this->_last_line_width) { |
|
265 | 265 | $this->_pdf->SetLineWidth($width); |
266 | 266 | $this->_last_line_width = $width; |
267 | 267 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | */ |
290 | 290 | function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
291 | 291 | |
292 | - if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
|
292 | + if (is_null($this->_last_line_width) || $width != $this->_last_line_width) { |
|
293 | 293 | $this->_pdf->SetLineWidth($width); |
294 | 294 | $this->_last_line_width = $width; |
295 | 295 | } |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * @param array $style |
364 | 364 | * @param bool $fill Fills the circle if true |
365 | 365 | */ |
366 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
366 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {} |
|
367 | 367 | |
368 | 368 | /** |
369 | 369 | * Add an image to the pdf. |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @param int $w width (in pixels) |
379 | 379 | * @param int $h height (in pixels) |
380 | 380 | */ |
381 | - function image($img_url, $img_type, $x, $y, $w, $h){} |
|
381 | + function image($img_url, $img_type, $x, $y, $w, $h) {} |
|
382 | 382 | |
383 | 383 | /** |
384 | 384 | * Writes text at the specified x and y coordinates |
@@ -393,16 +393,16 @@ discard block |
||
393 | 393 | * @param array $color |
394 | 394 | * @param float $adjust word spacing adjustment |
395 | 395 | */ |
396 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
396 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0) {} |
|
397 | 397 | |
398 | - function javascript($code){} |
|
398 | + function javascript($code) {} |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Add a named destination (similar to <a name="foo">...</a> in html) |
402 | 402 | * |
403 | 403 | * @param string $anchorname The name of the named destination |
404 | 404 | */ |
405 | - function add_named_dest($anchorname){} |
|
405 | + function add_named_dest($anchorname) {} |
|
406 | 406 | |
407 | 407 | /** |
408 | 408 | * Add a link to the pdf |
@@ -413,7 +413,7 @@ discard block |
||
413 | 413 | * @param float $width The width of the link |
414 | 414 | * @param float $height The height of the link |
415 | 415 | */ |
416 | - function add_link($url, $x, $y, $width, $height){} |
|
416 | + function add_link($url, $x, $y, $width, $height) {} |
|
417 | 417 | |
418 | 418 | /** |
419 | 419 | * Calculates text size, in points |
@@ -424,7 +424,7 @@ discard block |
||
424 | 424 | * @param float $spacing word spacing, if any |
425 | 425 | * @return float |
426 | 426 | */ |
427 | - function get_text_width($text, $font, $size, $spacing = 0){} |
|
427 | + function get_text_width($text, $font, $size, $spacing = 0) {} |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Calculates font height, in points |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * @param float $size |
434 | 434 | * @return float |
435 | 435 | */ |
436 | - function get_font_height($font, $size){} |
|
436 | + function get_font_height($font, $size) {} |
|
437 | 437 | |
438 | 438 | |
439 | 439 | /** |
@@ -441,7 +441,7 @@ discard block |
||
441 | 441 | * |
442 | 442 | * Subsequent drawing operations will appear on the new page. |
443 | 443 | */ |
444 | - function new_page(){} |
|
444 | + function new_page() {} |
|
445 | 445 | |
446 | 446 | /** |
447 | 447 | * Streams the PDF directly to the browser |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | * @param string $filename the name of the PDF file |
450 | 450 | * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
451 | 451 | */ |
452 | - function stream($filename, $options = null){} |
|
452 | + function stream($filename, $options = null) {} |
|
453 | 453 | |
454 | 454 | /** |
455 | 455 | * Returns the PDF as a string |
@@ -457,7 +457,7 @@ discard block |
||
457 | 457 | * @param array $options associative array: 'compress' => 1 or 0 |
458 | 458 | * @return string |
459 | 459 | */ |
460 | - function output($options = null){} |
|
460 | + function output($options = null) {} |
|
461 | 461 | |
462 | 462 | } |
463 | 463 |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
101 | 101 | */ |
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
102 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1, 1, 1, 0)) { |
|
103 | 103 | |
104 | - if ( !is_array($size) ) { |
|
104 | + if (!is_array($size)) { |
|
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
106 | + if (isset(CPDF_Adapter::$PAPER_SIZES[strtolower($size)])) |
|
107 | 107 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | 108 | else |
109 | 109 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - if ( strtolower($orientation) === "landscape" ) { |
|
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + if (strtolower($orientation) === "landscape") { |
|
114 | + list($size[2], $size[3]) = array($size[3], $size[2]); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $aa_factor < 1 ) |
|
117 | + if ($aa_factor < 1) |
|
118 | 118 | $aa_factor = 1; |
119 | 119 | |
120 | 120 | $this->_aa_factor = $aa_factor; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 129 | |
130 | - if ( is_null($bg_color) || !is_array($bg_color) ) { |
|
130 | + if (is_null($bg_color) || !is_array($bg_color)) { |
|
131 | 131 | // Pure white bg |
132 | - $bg_color = array(1,1,1,0); |
|
132 | + $bg_color = array(1, 1, 1, 0); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | private function _allocate_color($color) { |
198 | 198 | |
199 | 199 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
200 | + if (!isset($color[3])) |
|
201 | 201 | $color[3] = 0; |
202 | 202 | |
203 | - list($r,$g,$b,$a) = $color; |
|
203 | + list($r, $g, $b, $a) = $color; |
|
204 | 204 | |
205 | 205 | $r *= 255; |
206 | 206 | $g *= 255; |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | |
221 | 221 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 222 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
223 | + if (isset($this->_colors[$key])) |
|
224 | 224 | return $this->_colors[$key]; |
225 | 225 | |
226 | - if ( $a != 0 ) |
|
226 | + if ($a != 0) |
|
227 | 227 | $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
228 | 228 | else |
229 | 229 | $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | $c = $this->_allocate_color($color); |
260 | 260 | |
261 | 261 | // Convert the style array if required |
262 | - if ( !is_null($style) ) { |
|
262 | + if (!is_null($style)) { |
|
263 | 263 | $gd_style = array(); |
264 | 264 | |
265 | - if ( count($style) == 1 ) { |
|
265 | + if (count($style) == 1) { |
|
266 | 266 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | 267 | $gd_style[] = $c; |
268 | 268 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $i = 0; |
277 | 277 | foreach ($style as $length) { |
278 | 278 | |
279 | - if ( $i % 2 == 0 ) { |
|
279 | + if ($i % 2 == 0) { |
|
280 | 280 | // 'On' pattern |
281 | 281 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | 282 | $gd_style[] = $c; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $c = $this->_allocate_color($color); |
328 | 328 | |
329 | 329 | // Convert the style array if required |
330 | - if ( !is_null($style) ) { |
|
330 | + if (!is_null($style)) { |
|
331 | 331 | $gd_style = array(); |
332 | 332 | |
333 | 333 | foreach ($style as $length) { |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $c = $this->_allocate_color($color); |
405 | 405 | |
406 | 406 | // Convert the style array if required |
407 | - if ( !is_null($style) && !$fill ) { |
|
407 | + if (!is_null($style) && !$fill) { |
|
408 | 408 | $gd_style = array(); |
409 | 409 | |
410 | 410 | foreach ($style as $length) { |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | imagesetthickness($this->_img, $width); |
421 | 421 | |
422 | - if ( $fill ) |
|
422 | + if ($fill) |
|
423 | 423 | imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
424 | 424 | else |
425 | 425 | imagepolygon($this->_img, $points, count($points) / 2, $c); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $c = $this->_allocate_color($color); |
452 | 452 | |
453 | 453 | // Convert the style array if required |
454 | - if ( !is_null($style) && !$fill ) { |
|
454 | + if (!is_null($style) && !$fill) { |
|
455 | 455 | $gd_style = array(); |
456 | 456 | |
457 | 457 | foreach ($style as $length) { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | imagesetthickness($this->_img, $width); |
468 | 468 | |
469 | - if ( $fill ) |
|
469 | + if ($fill) |
|
470 | 470 | imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
471 | 471 | else |
472 | 472 | imageellipse($this->_img, $x, $y, $r, $r, $c); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - if ( !$src ) |
|
510 | + if (!$src) |
|
511 | 511 | return; // Probably should add to $_dompdf_errors or whatever here |
512 | 512 | |
513 | 513 | // Scale by the AA factor |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param float $adjust word spacing adjustment |
540 | 540 | * @param float $angle Text angle |
541 | 541 | */ |
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
542 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
543 | 543 | |
544 | 544 | // Scale by the AA factor |
545 | 545 | $x *= $this->_aa_factor; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | $c = $this->_allocate_color($color); |
552 | 552 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
553 | + if (strpos($font, '.ttf') === false) |
|
554 | 554 | $font .= ".ttf"; |
555 | 555 | |
556 | 556 | // FIXME: word spacing |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 597 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
598 | + if (strpos($font, '.ttf') === false) |
|
599 | 599 | $font .= ".ttf"; |
600 | 600 | |
601 | 601 | // FIXME: word spacing |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | * @return float |
612 | 612 | */ |
613 | 613 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
614 | + if (strpos($font, '.ttf') === false) |
|
615 | 615 | $font .= ".ttf"; |
616 | 616 | |
617 | 617 | // FIXME: word spacing |
618 | - list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
618 | + list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
619 | 619 | return $y2 - $y1; |
620 | 620 | } |
621 | 621 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | function stream($filename, $options = null) { |
639 | 639 | |
640 | 640 | // Perform any antialiasing |
641 | - if ( $this->_aa_factor != 1 ) { |
|
641 | + if ($this->_aa_factor != 1) { |
|
642 | 642 | $dst_w = $this->_width / $this->_aa_factor; |
643 | 643 | $dst_h = $this->_height / $this->_aa_factor; |
644 | 644 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | $dst = $this->_img; |
650 | 650 | } |
651 | 651 | |
652 | - if ( !isset($options["type"]) ) |
|
652 | + if (!isset($options["type"])) |
|
653 | 653 | $options["type"] = "png"; |
654 | 654 | |
655 | 655 | $type = strtolower($options["type"]); |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | |
661 | 661 | case "jpg": |
662 | 662 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
663 | + if (!isset($options["quality"])) |
|
664 | 664 | $options["quality"] = 75; |
665 | 665 | |
666 | 666 | header("Content-type: image/jpeg"); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | break; |
675 | 675 | } |
676 | 676 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
677 | + if ($this->_aa_factor != 1) |
|
678 | 678 | imagedestroy($dst); |
679 | 679 | } |
680 | 680 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | function output($options = null) { |
688 | 688 | |
689 | - if ( $this->_aa_factor != 1 ) { |
|
689 | + if ($this->_aa_factor != 1) { |
|
690 | 690 | $dst_w = $this->_width / $this->_aa_factor; |
691 | 691 | $dst_h = $this->_height / $this->_aa_factor; |
692 | 692 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | $dst = $this->_img; |
698 | 698 | } |
699 | 699 | |
700 | - if ( !isset($options["type"]) ) |
|
700 | + if (!isset($options["type"])) |
|
701 | 701 | $options["type"] = "png"; |
702 | 702 | |
703 | 703 | $type = $options["type"]; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | case "jpg": |
710 | 710 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
711 | + if (!isset($options["quality"])) |
|
712 | 712 | $options["quality"] = 75; |
713 | 713 | |
714 | 714 | imagejpeg($dst, '', $options["quality"]); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $image = ob_get_contents(); |
724 | 724 | ob_end_clean(); |
725 | 725 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
726 | + if ($this->_aa_factor != 1) |
|
727 | 727 | imagedestroy($dst); |
728 | 728 | |
729 | 729 | return $image; |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | protected $_text_spacing; |
52 | 52 | |
53 | 53 | function __construct(Frame $frame, DOMPDF $dompdf) { |
54 | - if ( $frame->get_node()->nodeName !== "#text" ) |
|
54 | + if ($frame->get_node()->nodeName !== "#text") |
|
55 | 55 | throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
56 | 56 | |
57 | 57 | parent::__construct($frame, $dompdf); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | function get_text() { |
74 | 74 | // FIXME: this should be in a child class (and is incorrect) |
75 | - if ( $this->_frame->get_style()->content !== "normal" ) { |
|
75 | + if ($this->_frame->get_style()->content !== "normal") { |
|
76 | 76 | $this->_frame->get_node()->data = $this->_frame->get_style()->content; |
77 | 77 | $this->_frame->get_style()->content = "normal"; |
78 | 78 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | // split the text in this frame at the offset specified. The remaining |
155 | 155 | // text is added a sibling frame following this one and is returned. |
156 | 156 | function split_text($offset) { |
157 | - if ( $offset == 0 ) |
|
157 | + if ($offset == 0) |
|
158 | 158 | return; |
159 | 159 | |
160 | 160 | $split = $this->_frame->get_node()->splitText($offset); |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | $p = $this->get_parent(); |
164 | 164 | $p->insert_child_after($deco, $this, false); |
165 | 165 | |
166 | - if ( $p instanceof Inline_Frame_Decorator ) |
|
166 | + if ($p instanceof Inline_Frame_Decorator) |
|
167 | 167 | $p->split($deco); |
168 | 168 | |
169 | 169 | } |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | // |
53 | 53 | // thank you var_export() :D |
54 | 54 | static private $__ATTRIBUTE_LOOKUP = |
55 | - array (//'caption' => array ( 'align' => '', ), |
|
55 | + array(//'caption' => array ( 'align' => '', ), |
|
56 | 56 | 'img_inner' => // img tags actually end up wrapping img_inner elements |
57 | - array ('align' => array('bottom' => 'vertical-align: baseline;', |
|
57 | + array('align' => array('bottom' => 'vertical-align: baseline;', |
|
58 | 58 | 'middle' => 'vertical-align: middle;', |
59 | 59 | 'top' => 'vertical-align: top;', |
60 | 60 | 'left' => 'float: left;', |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'width' => 'width: %s px;', |
67 | 67 | ), |
68 | 68 | 'table' => |
69 | - array ("align" => array('left' => 'margin-left: 0; margin-right: auto;', |
|
69 | + array("align" => array('left' => 'margin-left: 0; margin-right: auto;', |
|
70 | 70 | 'center' => 'margin-left: auto; margin-right: auto;', |
71 | 71 | 'right' => 'margin-left: auto; margin-right: 0;' |
72 | 72 | ), |
@@ -87,42 +87,42 @@ discard block |
||
87 | 87 | 'width' => 'width: %s;', |
88 | 88 | ), |
89 | 89 | 'hr' => |
90 | - array ( |
|
90 | + array( |
|
91 | 91 | 'align' => '!set_hr_align', // Need to grab width to set 'left' & 'right' correctly |
92 | 92 | 'noshade' => 'border-style: solid;', |
93 | 93 | 'size' => 'border-width: %0.2f px;', |
94 | 94 | 'width' => 'width: %s;', |
95 | 95 | ), |
96 | 96 | 'div' => |
97 | - array ( |
|
97 | + array( |
|
98 | 98 | 'align' => 'text-align: %s;', |
99 | 99 | ), |
100 | 100 | 'h1' => |
101 | - array ( |
|
101 | + array( |
|
102 | 102 | 'align' => 'text-align: %s;', |
103 | 103 | ), |
104 | 104 | 'h2' => |
105 | - array ( |
|
105 | + array( |
|
106 | 106 | 'align' => 'text-align: %s;', |
107 | 107 | ), |
108 | 108 | 'h3' => |
109 | - array ( |
|
109 | + array( |
|
110 | 110 | 'align' => 'text-align: %s;', |
111 | 111 | ), |
112 | 112 | 'h4' => |
113 | - array ( |
|
113 | + array( |
|
114 | 114 | 'align' => 'text-align: %s;', |
115 | 115 | ), |
116 | 116 | 'h5' => |
117 | - array ( |
|
117 | + array( |
|
118 | 118 | 'align' => 'text-align: %s;', |
119 | 119 | ), |
120 | 120 | 'h6' => |
121 | - array ( |
|
121 | + array( |
|
122 | 122 | 'align' => 'text-align: %s;', |
123 | 123 | ), |
124 | 124 | 'p' => |
125 | - array ( |
|
125 | + array( |
|
126 | 126 | 'align' => 'text-align: %s;', |
127 | 127 | ), |
128 | 128 | // 'col' => |
@@ -136,12 +136,12 @@ discard block |
||
136 | 136 | // 'valign' => '', |
137 | 137 | // ), |
138 | 138 | 'tbody' => |
139 | - array ( |
|
139 | + array( |
|
140 | 140 | 'align' => '!set_table_row_align', |
141 | 141 | 'valign' => '!set_table_row_valign', |
142 | 142 | ), |
143 | 143 | 'td' => |
144 | - array ( |
|
144 | + array( |
|
145 | 145 | 'align' => 'text-align: %s;', |
146 | 146 | 'bgcolor' => 'background-color: %s;', |
147 | 147 | 'height' => 'height: %s;', |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | 'width' => 'width: %s;', |
151 | 151 | ), |
152 | 152 | 'tfoot' => |
153 | - array ( |
|
153 | + array( |
|
154 | 154 | 'align' => '!set_table_row_align', |
155 | 155 | 'valign' => '!set_table_row_valign', |
156 | 156 | ), |
157 | 157 | 'th' => |
158 | - array ( |
|
158 | + array( |
|
159 | 159 | 'align' => 'text-align: %s;', |
160 | 160 | 'bgcolor' => 'background-color: %s;', |
161 | 161 | 'height' => 'height: %s;', |
@@ -164,69 +164,69 @@ discard block |
||
164 | 164 | 'width' => 'width: %s;', |
165 | 165 | ), |
166 | 166 | 'thead' => |
167 | - array ( |
|
167 | + array( |
|
168 | 168 | 'align' => '!set_table_row_align', |
169 | 169 | 'valign' => '!set_table_row_valign', |
170 | 170 | ), |
171 | 171 | 'tr' => |
172 | - array ( |
|
172 | + array( |
|
173 | 173 | 'align' => '!set_table_row_align', |
174 | 174 | 'bgcolor' => '!set_table_row_bgcolor', |
175 | 175 | 'valign' => '!set_table_row_valign', |
176 | 176 | ), |
177 | 177 | 'body' => |
178 | - array ( |
|
178 | + array( |
|
179 | 179 | 'background' => 'background-image: url(%s);', |
180 | 180 | 'bgcolor' => 'background-color: %s;', |
181 | 181 | 'link' => '!set_body_link', |
182 | 182 | 'text' => 'color: %s;', |
183 | 183 | ), |
184 | 184 | 'br' => |
185 | - array ( |
|
185 | + array( |
|
186 | 186 | 'clear' => 'clear: %s;', |
187 | 187 | ), |
188 | 188 | 'basefont' => |
189 | - array ( |
|
189 | + array( |
|
190 | 190 | 'color' => 'color: %s;', |
191 | 191 | 'face' => 'font-family: %s;', |
192 | 192 | 'size' => '!set_basefont_size', |
193 | 193 | ), |
194 | 194 | 'font' => |
195 | - array ( |
|
195 | + array( |
|
196 | 196 | 'color' => 'color: %s;', |
197 | 197 | 'face' => 'font-family: %s;', |
198 | 198 | 'size' => '!set_font_size', |
199 | 199 | ), |
200 | 200 | 'dir' => |
201 | - array ( |
|
201 | + array( |
|
202 | 202 | 'compact' => 'margin: 0.5em 0;', |
203 | 203 | ), |
204 | 204 | 'dl' => |
205 | - array ( |
|
205 | + array( |
|
206 | 206 | 'compact' => 'margin: 0.5em 0;', |
207 | 207 | ), |
208 | 208 | 'menu' => |
209 | - array ( |
|
209 | + array( |
|
210 | 210 | 'compact' => 'margin: 0.5em 0;', |
211 | 211 | ), |
212 | 212 | 'ol' => |
213 | - array ( |
|
213 | + array( |
|
214 | 214 | 'compact' => 'margin: 0.5em 0;', |
215 | 215 | 'start' => 'counter-reset: -dompdf-default-counter %d;', |
216 | 216 | 'type' => 'list-style-type: %s;', |
217 | 217 | ), |
218 | 218 | 'ul' => |
219 | - array ( |
|
219 | + array( |
|
220 | 220 | 'compact' => 'margin: 0.5em 0;', |
221 | 221 | 'type' => 'list-style-type: %s;', |
222 | 222 | ), |
223 | 223 | 'li' => |
224 | - array ( |
|
224 | + array( |
|
225 | 225 | 'type' => 'list-style-type: %s;', |
226 | 226 | 'value' => 'counter-reset: -dompdf-default-counter %d;', |
227 | 227 | ), |
228 | 228 | 'pre' => |
229 | - array ( |
|
229 | + array( |
|
230 | 230 | 'width' => 'width: %s;', |
231 | 231 | ), |
232 | 232 | ); |
@@ -246,17 +246,17 @@ discard block |
||
246 | 246 | $node = $frame->get_node(); |
247 | 247 | $tag = $node->tagName; |
248 | 248 | |
249 | - if ( !isset(self::$__ATTRIBUTE_LOOKUP[$tag]) ) |
|
249 | + if (!isset(self::$__ATTRIBUTE_LOOKUP[$tag])) |
|
250 | 250 | return; |
251 | 251 | |
252 | 252 | $valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag]; |
253 | 253 | $attrs = $node->attributes; |
254 | 254 | $style = rtrim($node->getAttribute("style"), "; "); |
255 | - if ( $style != "" ) |
|
255 | + if ($style != "") |
|
256 | 256 | $style .= ";"; |
257 | 257 | |
258 | - foreach ($attrs as $attr => $attr_node ) { |
|
259 | - if ( !isset($valid_attrs[$attr]) ) |
|
258 | + foreach ($attrs as $attr => $attr_node) { |
|
259 | + if (!isset($valid_attrs[$attr])) |
|
260 | 260 | continue; |
261 | 261 | |
262 | 262 | $value = $attr_node->value; |
@@ -264,17 +264,17 @@ discard block |
||
264 | 264 | $target = $valid_attrs[$attr]; |
265 | 265 | |
266 | 266 | // Look up $value in $target, if $target is an array: |
267 | - if ( is_array($target) ) { |
|
267 | + if (is_array($target)) { |
|
268 | 268 | |
269 | - if ( isset($target[$value]) ) |
|
270 | - $style .= " " . self::_resolve_target($node, $target[$value], $value); |
|
269 | + if (isset($target[$value])) |
|
270 | + $style .= " ".self::_resolve_target($node, $target[$value], $value); |
|
271 | 271 | |
272 | 272 | } else { |
273 | 273 | // otherwise use target directly |
274 | - $style .= " " . self::_resolve_target($node, $target, $value); |
|
274 | + $style .= " ".self::_resolve_target($node, $target, $value); |
|
275 | 275 | } |
276 | 276 | } |
277 | - if ( !is_null($style) ) { |
|
277 | + if (!is_null($style)) { |
|
278 | 278 | $style = ltrim($style); |
279 | 279 | $node->setAttribute("style", $style); |
280 | 280 | } |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | } |
283 | 283 | |
284 | 284 | static protected function _resolve_target($node, $target, $value) { |
285 | - if ( $target[0] === "!" ) { |
|
285 | + if ($target[0] === "!") { |
|
286 | 286 | // Function call |
287 | - $func = "_" . mb_substr($target, 1); |
|
287 | + $func = "_".mb_substr($target, 1); |
|
288 | 288 | return self::$func($node, $value); |
289 | 289 | } |
290 | 290 | |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | $td_list = $node->getElementsByTagName("td"); |
299 | 299 | foreach ($td_list as $td) { |
300 | 300 | $style = rtrim($td->getAttribute("style"), ";"); |
301 | - $style .= "; padding: $value" . "px;"; |
|
301 | + $style .= "; padding: $value"."px;"; |
|
302 | 302 | $style = ltrim($style, ";"); |
303 | 303 | $td->setAttribute("style", $style); |
304 | 304 | } |
@@ -309,20 +309,20 @@ discard block |
||
309 | 309 | $td_list = $node->getElementsByTagName("td"); |
310 | 310 | foreach ($td_list as $td) { |
311 | 311 | $style = $td->getAttribute("style"); |
312 | - if ( strpos($style, "border") !== false ) |
|
312 | + if (strpos($style, "border") !== false) |
|
313 | 313 | continue; |
314 | 314 | $style = rtrim($style, ";"); |
315 | - $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
315 | + $style .= "; border-width: $value"."px; border-style: ridge;"; |
|
316 | 316 | $style = ltrim($style, ";"); |
317 | 317 | $td->setAttribute("style", $style); |
318 | 318 | } |
319 | 319 | $th_list = $node->getElementsByTagName("th"); |
320 | 320 | foreach ($th_list as $th) { |
321 | 321 | $style = $th->getAttribute("style"); |
322 | - if ( strpos($style, "border") !== false ) |
|
322 | + if (strpos($style, "border") !== false) |
|
323 | 323 | continue; |
324 | 324 | $style = rtrim($style, ";"); |
325 | - $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
325 | + $style .= "; border-width: $value"."px; border-style: ridge;"; |
|
326 | 326 | $style = ltrim($style, ";"); |
327 | 327 | $th->setAttribute("style", $style); |
328 | 328 | } |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | static protected function _set_table_cellspacing($node, $value) { |
334 | 334 | $style = rtrim($td->getAttribute($style), ";"); |
335 | 335 | |
336 | - if ( $value == 0 ) |
|
336 | + if ($value == 0) |
|
337 | 337 | $style .= "; border-collapse: collapse;"; |
338 | 338 | |
339 | 339 | else |
@@ -382,12 +382,12 @@ discard block |
||
382 | 382 | |
383 | 383 | static protected function _set_hr_align($node, $value) { |
384 | 384 | |
385 | - $style = rtrim($node->getAttribute("style"),";"); |
|
385 | + $style = rtrim($node->getAttribute("style"), ";"); |
|
386 | 386 | $width = $node->getAttribute("width"); |
387 | - if ( $width == "" ) |
|
387 | + if ($width == "") |
|
388 | 388 | $width = "100%"; |
389 | 389 | |
390 | - $remainder = 100 - (double)rtrim($width, "% "); |
|
390 | + $remainder = 100 - (double) rtrim($width, "% "); |
|
391 | 391 | |
392 | 392 | switch ($value) { |
393 | 393 | case "left": |
@@ -475,11 +475,11 @@ discard block |
||
475 | 475 | static protected function _set_font_size($node, $value) { |
476 | 476 | $style = $node->getAttribute("style"); |
477 | 477 | |
478 | - if ( $value[0] === "-" || $value[0] === "+" ) |
|
479 | - $value = self::$_last_basefont_size + (int)$value; |
|
478 | + if ($value[0] === "-" || $value[0] === "+") |
|
479 | + $value = self::$_last_basefont_size + (int) $value; |
|
480 | 480 | |
481 | - if ( isset(self::$_font_size_lookup[$value]) ) |
|
482 | - $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";"; |
|
481 | + if (isset(self::$_font_size_lookup[$value])) |
|
482 | + $style .= "; font-size: ".self::$_font_size_lookup[$value].";"; |
|
483 | 483 | else |
484 | 484 | $style .= "; font-size: $value;"; |
485 | 485 |
@@ -63,7 +63,7 @@ |
||
63 | 63 | $w = $style->length_in_pt($style->width, $cb["w"]); |
64 | 64 | $h = $style->length_in_pt($style->height, $cb["h"]); |
65 | 65 | |
66 | - $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); |
|
66 | + $this->_canvas->image($frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | } |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | |
62 | 62 | protected function _parse_string($string) { |
63 | 63 | $string = trim($string, "'\""); |
64 | - $string = str_replace(array("\\\n",'\\"',"\\'"), |
|
65 | - array("",'"',"'"), $string); |
|
64 | + $string = str_replace(array("\\\n", '\\"', "\\'"), |
|
65 | + array("", '"', "'"), $string); |
|
66 | 66 | |
67 | 67 | // Convert escaped hex characters into ascii characters (e.g. \A => newline) |
68 | 68 | $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})(\s)?(?(2)|(?=[^0-9a-fA-F]))/", |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | "\s(counters?\\([^)]*\\))|\n". |
81 | 81 | "\A(counters?\\([^)]*\\))|\n". |
82 | 82 | "\s([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\3|\n". |
83 | - "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n" . |
|
84 | - "\s([^\s\"']+)|\n" . |
|
83 | + "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n". |
|
84 | + "\s([^\s\"']+)|\n". |
|
85 | 85 | "\A([^\s\"']+)\n". |
86 | 86 | "/xi"; |
87 | 87 | |
@@ -94,16 +94,16 @@ discard block |
||
94 | 94 | $text = ""; |
95 | 95 | |
96 | 96 | foreach ($matches as $match) { |
97 | - if ( isset($match[2]) && $match[2] !== "" ) |
|
97 | + if (isset($match[2]) && $match[2] !== "") |
|
98 | 98 | $match[1] = $match[1]; |
99 | 99 | |
100 | - if ( isset($match[6]) && $match[6] !== "" ) |
|
100 | + if (isset($match[6]) && $match[6] !== "") |
|
101 | 101 | $match[4] = $match[6]; |
102 | 102 | |
103 | - if ( isset($match[8]) && $match[8] !== "" ) |
|
103 | + if (isset($match[8]) && $match[8] !== "") |
|
104 | 104 | $match[7] = $match[8]; |
105 | 105 | |
106 | - if ( isset($match[1]) && $match[1] !== "" ) { |
|
106 | + if (isset($match[1]) && $match[1] !== "") { |
|
107 | 107 | // counters?(...) |
108 | 108 | $match[1] = mb_strtolower(trim($match[1])); |
109 | 109 | |
@@ -111,16 +111,16 @@ discard block |
||
111 | 111 | // http://www.w3.org/TR/CSS21/generate.html#content |
112 | 112 | |
113 | 113 | $i = mb_strpos($match[1], ")"); |
114 | - if ( $i === false ) |
|
114 | + if ($i === false) |
|
115 | 115 | continue; |
116 | 116 | |
117 | 117 | $args = explode(",", mb_substr($match[1], 7, $i - 7)); |
118 | 118 | $counter_id = $args[0]; |
119 | 119 | |
120 | - if ( $match[1]{7} === "(" ) { |
|
120 | + if ($match[1]{7} === "(") { |
|
121 | 121 | // counter(name [,style]) |
122 | 122 | |
123 | - if ( isset($args[1]) ) |
|
123 | + if (isset($args[1])) |
|
124 | 124 | $type = $args[1]; |
125 | 125 | else |
126 | 126 | $type = null; |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | |
131 | 131 | $text .= $p->counter_value($counter_id, $type); |
132 | 132 | |
133 | - } else if ( $match[1]{7} === "s" ) { |
|
133 | + } else if ($match[1]{7} === "s") { |
|
134 | 134 | // counters(name, string [,style]) |
135 | - if ( isset($args[1]) ) |
|
135 | + if (isset($args[1])) |
|
136 | 136 | $string = $this->_parse_string(trim($args[1])); |
137 | 137 | else |
138 | 138 | $string = ""; |
139 | 139 | |
140 | - if ( isset($args[2]) ) |
|
140 | + if (isset($args[2])) |
|
141 | 141 | $type = $args[2]; |
142 | 142 | else |
143 | 143 | $type = null; |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $p = $this->_frame->find_block_parent(); |
146 | 146 | $tmp = ""; |
147 | 147 | while ($p) { |
148 | - $tmp = $p->counter_value($counter_id, $type) . $string . $tmp; |
|
148 | + $tmp = $p->counter_value($counter_id, $type).$string.$tmp; |
|
149 | 149 | $p = $p->find_block_parent(); |
150 | 150 | } |
151 | 151 | $text .= $tmp; |
@@ -154,29 +154,29 @@ discard block |
||
154 | 154 | // countertops? |
155 | 155 | continue; |
156 | 156 | |
157 | - } else if ( isset($match[4]) && $match[4] !== "" ) { |
|
157 | + } else if (isset($match[4]) && $match[4] !== "") { |
|
158 | 158 | // String match |
159 | 159 | $text .= $this->_parse_string($match[4]); |
160 | 160 | |
161 | - } else if ( isset($match[7]) && $match[7] !== "" ) { |
|
161 | + } else if (isset($match[7]) && $match[7] !== "") { |
|
162 | 162 | // Directive match |
163 | 163 | |
164 | - if ( $match[7] === "open-quote" ) { |
|
164 | + if ($match[7] === "open-quote") { |
|
165 | 165 | // FIXME: do something here |
166 | - } else if ( $match[7] === "close-quote" ) { |
|
166 | + } else if ($match[7] === "close-quote") { |
|
167 | 167 | // FIXME: do something else here |
168 | - } else if ( $match[7] === "no-open-quote" ) { |
|
168 | + } else if ($match[7] === "no-open-quote") { |
|
169 | 169 | // FIXME: |
170 | - } else if ( $match[7] === "no-close-quote" ) { |
|
170 | + } else if ($match[7] === "no-close-quote") { |
|
171 | 171 | // FIXME: |
172 | - } else if ( mb_strpos($match[7],"attr(") === 0 ) { |
|
172 | + } else if (mb_strpos($match[7], "attr(") === 0) { |
|
173 | 173 | |
174 | - $i = mb_strpos($match[7],")"); |
|
175 | - if ( $i === false ) |
|
174 | + $i = mb_strpos($match[7], ")"); |
|
175 | + if ($i === false) |
|
176 | 176 | continue; |
177 | 177 | |
178 | 178 | $attr = mb_substr($match[7], 6, $i - 6); |
179 | - if ( $attr == "" ) |
|
179 | + if ($attr == "") |
|
180 | 180 | continue; |
181 | 181 | |
182 | 182 | $text .= $this->_frame->get_node()->getAttribute($attr); |
@@ -193,7 +193,7 @@ |
||
193 | 193 | * @param array $color |
194 | 194 | * @param float $adjust word spacing adjustment |
195 | 195 | */ |
196 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0); |
|
196 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0); |
|
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Add a named destination (similar to <a name="foo">...</a> in html) |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * The location of the default built-in CSS file. |
55 | 55 | * {@link Stylesheet::DEFAULT_STYLESHEET} |
56 | 56 | */ |
57 | -define('__DEFAULT_STYLESHEET', DOMPDF_LIB_DIR . DIRECTORY_SEPARATOR . "res" . DIRECTORY_SEPARATOR . "html.css"); |
|
57 | +define('__DEFAULT_STYLESHEET', DOMPDF_LIB_DIR.DIRECTORY_SEPARATOR."res".DIRECTORY_SEPARATOR."html.css"); |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * The master stylesheet class |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | if (!is_string($key)) |
214 | 214 | throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
215 | 215 | |
216 | - if ( isset($this->_styles[$key]) ) |
|
216 | + if (isset($this->_styles[$key])) |
|
217 | 217 | $this->_styles[$key]->merge($style); |
218 | 218 | else |
219 | 219 | $this->_styles[$key] = clone $style; |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | * @return Style |
231 | 231 | */ |
232 | 232 | function lookup($key) { |
233 | - if ( !isset($this->_styles[$key]) ) |
|
233 | + if (!isset($this->_styles[$key])) |
|
234 | 234 | return null; |
235 | 235 | |
236 | 236 | return $this->_styles[$key]; |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | global $_dompdf_warnings; |
265 | 265 | |
266 | 266 | // Prevent circular references |
267 | - if ( isset($this->_loaded_files[$file]) ) |
|
267 | + if (isset($this->_loaded_files[$file])) |
|
268 | 268 | return; |
269 | 269 | |
270 | 270 | $this->_loaded_files[$file] = true; |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | |
273 | 273 | list($this->_protocol, $this->_base_host, $this->_base_path, $filename) = $parsed_url; |
274 | 274 | |
275 | - if ( !DOMPDF_ENABLE_REMOTE && |
|
276 | - ($this->_protocol != "" && $this->_protocol !== "file://") ) { |
|
275 | + if (!DOMPDF_ENABLE_REMOTE && |
|
276 | + ($this->_protocol != "" && $this->_protocol !== "file://")) { |
|
277 | 277 | record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__); |
278 | 278 | return; |
279 | 279 | } |
280 | 280 | |
281 | 281 | // Fix submitted by Nick Oostveen for aliased directory support: |
282 | - if ( $this->_protocol == "" ) |
|
283 | - $file = $this->_base_path . $filename; |
|
282 | + if ($this->_protocol == "") |
|
283 | + $file = $this->_base_path.$filename; |
|
284 | 284 | else |
285 | 285 | $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
286 | 286 | |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | $css = file_get_contents($file); |
289 | 289 | restore_error_handler(); |
290 | 290 | |
291 | - if ( $css == "" ) { |
|
292 | - record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);; |
|
291 | + if ($css == "") { |
|
292 | + record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__); ; |
|
293 | 293 | return; |
294 | 294 | } |
295 | 295 | |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | //this can lead to a too small specificity |
325 | 325 | //see _css_selector_to_xpath |
326 | 326 | |
327 | - if ( !in_array($selector[0], array(" ", ">", ".", "#", "+", ":", "[")) ) { |
|
327 | + if (!in_array($selector[0], array(" ", ">", ".", "#", "+", ":", "["))) { |
|
328 | 328 | $d++; |
329 | 329 | } |
330 | 330 | |
@@ -361,14 +361,14 @@ discard block |
||
361 | 361 | |
362 | 362 | // Add an implicit space at the beginning of the selector if there is no |
363 | 363 | // delimiter there already. |
364 | - if ( !in_array($selector[0], $delimiters) ) |
|
364 | + if (!in_array($selector[0], $delimiters)) |
|
365 | 365 | $selector = " $selector"; |
366 | 366 | |
367 | 367 | $tok = ""; |
368 | 368 | $len = mb_strlen($selector); |
369 | 369 | $i = 0; |
370 | 370 | |
371 | - while ( $i < $len ) { |
|
371 | + while ($i < $len) { |
|
372 | 372 | |
373 | 373 | $s = $selector[$i]; |
374 | 374 | $i++; |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | $tok = ""; |
378 | 378 | |
379 | 379 | while ($i < $len) { |
380 | - if ( in_array($selector[$i], $delimiters) ) |
|
380 | + if (in_array($selector[$i], $delimiters)) |
|
381 | 381 | break; |
382 | 382 | $tok .= $selector[$i++]; |
383 | 383 | } |
@@ -390,10 +390,10 @@ discard block |
||
390 | 390 | // the current token |
391 | 391 | $expr = $s === " " ? "descendant" : "child"; |
392 | 392 | |
393 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
393 | + if (mb_substr($query, -1, 1) !== "/") |
|
394 | 394 | $query .= "/"; |
395 | 395 | |
396 | - if ( !$tok ) |
|
396 | + if (!$tok) |
|
397 | 397 | $tok = "*"; |
398 | 398 | |
399 | 399 | $query .= "$expr::$tok"; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | $attr = $s === "." ? "class" : "id"; |
409 | 409 | |
410 | 410 | // empty class/id == * |
411 | - if ( mb_substr($query, -1, 1) === "/" ) |
|
411 | + if (mb_substr($query, -1, 1) === "/") |
|
412 | 412 | $query .= "*"; |
413 | 413 | |
414 | 414 | // Match multiple classes: $tok contains the current selected |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | |
426 | 426 | case "+": |
427 | 427 | // All sibling elements that folow the current token |
428 | - if ( mb_substr($query, -1, 1) !== "/" ) |
|
428 | + if (mb_substr($query, -1, 1) !== "/") |
|
429 | 429 | $query .= "/"; |
430 | 430 | |
431 | 431 | $query .= "following-sibling::$tok"; |
@@ -472,19 +472,19 @@ discard block |
||
472 | 472 | $op = ""; |
473 | 473 | $value = ""; |
474 | 474 | |
475 | - while ( $j < $tok_len ) { |
|
476 | - if ( in_array($tok[$j], $attr_delimiters) ) |
|
475 | + while ($j < $tok_len) { |
|
476 | + if (in_array($tok[$j], $attr_delimiters)) |
|
477 | 477 | break; |
478 | 478 | $attr .= $tok[$j++]; |
479 | 479 | } |
480 | 480 | |
481 | - switch ( $tok[$j] ) { |
|
481 | + switch ($tok[$j]) { |
|
482 | 482 | |
483 | 483 | case "~": |
484 | 484 | case "|": |
485 | 485 | $op .= $tok[$j++]; |
486 | 486 | |
487 | - if ( $tok[$j] !== "=" ) |
|
487 | + if ($tok[$j] !== "=") |
|
488 | 488 | throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
489 | 489 | |
490 | 490 | $op .= $tok[$j]; |
@@ -497,22 +497,22 @@ discard block |
||
497 | 497 | } |
498 | 498 | |
499 | 499 | // Read the attribute value, if required |
500 | - if ( $op != "" ) { |
|
500 | + if ($op != "") { |
|
501 | 501 | $j++; |
502 | - while ( $j < $tok_len ) { |
|
503 | - if ( $tok[$j] === "]" ) |
|
502 | + while ($j < $tok_len) { |
|
503 | + if ($tok[$j] === "]") |
|
504 | 504 | break; |
505 | 505 | $value .= $tok[$j++]; |
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
509 | - if ( $attr == "" ) |
|
509 | + if ($attr == "") |
|
510 | 510 | throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
511 | 511 | |
512 | - switch ( $op ) { |
|
512 | + switch ($op) { |
|
513 | 513 | |
514 | 514 | case "": |
515 | - $query .= "[@$attr]"; |
|
515 | + $query .= "[@$attr]"; |
|
516 | 516 | break; |
517 | 517 | |
518 | 518 | case "=": |
@@ -523,12 +523,12 @@ discard block |
||
523 | 523 | // FIXME: this will break if $value contains quoted strings |
524 | 524 | // (e.g. [type~="a b c" "d e f"]) |
525 | 525 | $values = explode(" ", $value); |
526 | - $query .= "["; |
|
526 | + $query .= "["; |
|
527 | 527 | |
528 | - foreach ( $values as $val ) |
|
528 | + foreach ($values as $val) |
|
529 | 529 | $query .= "@$attr=\"$val\" or "; |
530 | 530 | |
531 | - $query = rtrim($query, " or ") . "]"; |
|
531 | + $query = rtrim($query, " or ")."]"; |
|
532 | 532 | break; |
533 | 533 | |
534 | 534 | case "|=": |
@@ -538,7 +538,7 @@ discard block |
||
538 | 538 | foreach ($values as $val) |
539 | 539 | $query .= "starts-with(@$attr, \"$val\") or "; |
540 | 540 | |
541 | - $query = rtrim($query, " or ") . "]"; |
|
541 | + $query = rtrim($query, " or ")."]"; |
|
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | |
571 | 571 | |
572 | 572 | // Trim the trailing '/' from the query |
573 | - if ( mb_strlen($query) > 2 ) |
|
573 | + if (mb_strlen($query) > 2) |
|
574 | 574 | $query = rtrim($query, "/"); |
575 | 575 | |
576 | 576 | return $query; |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | foreach ($nodes as $node) { |
617 | 617 | //echo $node->nodeName . "\n"; |
618 | 618 | // Retrieve the node id |
619 | - if ( $node->nodeType != 1 ) // Only DOMElements get styles |
|
619 | + if ($node->nodeType != 1) // Only DOMElements get styles |
|
620 | 620 | continue; |
621 | 621 | |
622 | 622 | $id = $node->getAttribute("frame_id"); |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | $root_flg = false; |
633 | 633 | foreach ($tree->get_frames() as $frame) { |
634 | 634 | // pre_r($frame->get_node()->nodeName . ":"); |
635 | - if ( !$root_flg && $this->_page_style ) { |
|
635 | + if (!$root_flg && $this->_page_style) { |
|
636 | 636 | $style = $this->_page_style; |
637 | 637 | $root_flg = true; |
638 | 638 | } else |
@@ -640,14 +640,14 @@ discard block |
||
640 | 640 | |
641 | 641 | // Find nearest DOMElement parent |
642 | 642 | $p = $frame; |
643 | - while ( $p = $p->get_parent() ) |
|
644 | - if ($p->get_node()->nodeType == 1 ) |
|
643 | + while ($p = $p->get_parent()) |
|
644 | + if ($p->get_node()->nodeType == 1) |
|
645 | 645 | break; |
646 | 646 | |
647 | 647 | // Styles can only be applied directly to DOMElements; anonymous |
648 | 648 | // frames inherit from their parent |
649 | - if ( $frame->get_node()->nodeType != 1 ) { |
|
650 | - if ( $p ) |
|
649 | + if ($frame->get_node()->nodeType != 1) { |
|
650 | + if ($p) |
|
651 | 651 | $style->inherit($p->get_style()); |
652 | 652 | $frame->set_style($style); |
653 | 653 | continue; |
@@ -659,15 +659,15 @@ discard block |
||
659 | 659 | Attribute_Translator::translate_attributes($frame); |
660 | 660 | |
661 | 661 | // Locate any additional style attributes |
662 | - if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) { |
|
662 | + if (($str = $frame->get_node()->getAttribute("style")) !== "") { |
|
663 | 663 | $spec = $this->_specificity("!style attribute"); |
664 | 664 | $styles[$id][$spec][] = $this->_parse_properties($str); |
665 | 665 | } |
666 | 666 | |
667 | 667 | // Grab the applicable styles |
668 | - if ( isset($styles[$id]) ) { |
|
668 | + if (isset($styles[$id])) { |
|
669 | 669 | |
670 | - $applied_styles = $styles[ $frame->get_id() ]; |
|
670 | + $applied_styles = $styles[$frame->get_id()]; |
|
671 | 671 | |
672 | 672 | // Sort by specificity |
673 | 673 | ksort($applied_styles); |
@@ -676,7 +676,7 @@ discard block |
||
676 | 676 | $debug_nodename = $frame->get_node()->nodeName; |
677 | 677 | print "<pre>\n[$debug_nodename\n"; |
678 | 678 | foreach ($applied_styles as $spec => $arr) { |
679 | - printf("specificity: 0x%08x\n",$spec); |
|
679 | + printf("specificity: 0x%08x\n", $spec); |
|
680 | 680 | foreach ($arr as $s) { |
681 | 681 | print "[\n"; |
682 | 682 | $s->debug_print(); |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | } |
694 | 694 | |
695 | 695 | // Inherit parent's styles if required |
696 | - if ( $p ) { |
|
696 | + if ($p) { |
|
697 | 697 | |
698 | 698 | if (DEBUGCSS) { |
699 | 699 | print "inherit:\n"; |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | print "]\n"; |
703 | 703 | } |
704 | 704 | |
705 | - $style->inherit( $p->get_style() ); |
|
705 | + $style->inherit($p->get_style()); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | if (DEBUGCSS) { |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | |
725 | 725 | // We're done! Clean out the registry of all styles since we |
726 | 726 | // won't be needing this later. |
727 | - foreach ( array_keys($this->_styles) as $key ) { |
|
727 | + foreach (array_keys($this->_styles) as $key) { |
|
728 | 728 | unset($this->_styles[$key]); |
729 | 729 | } |
730 | 730 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | "([^{]*{[^}]*})) # Parse normal rulesets\n". |
766 | 766 | "/xs"; |
767 | 767 | |
768 | - if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false ) |
|
768 | + if (preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false) |
|
769 | 769 | // An error occured |
770 | 770 | throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
771 | 771 | |
@@ -781,10 +781,10 @@ discard block |
||
781 | 781 | // [7] => individual rules, outside of media rules |
782 | 782 | // |
783 | 783 | //pre_r($matches); |
784 | - foreach ( $matches as $match ) { |
|
784 | + foreach ($matches as $match) { |
|
785 | 785 | $match[2] = trim($match[2]); |
786 | 786 | |
787 | - if ( $match[2] !== "" ) { |
|
787 | + if ($match[2] !== "") { |
|
788 | 788 | // Handle @rules |
789 | 789 | switch ($match[2]) { |
790 | 790 | |
@@ -794,12 +794,12 @@ discard block |
||
794 | 794 | |
795 | 795 | case "media": |
796 | 796 | $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
797 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
797 | + if (defined("DOMPDF_DEFAULT_MEDIA_TYPE")) { |
|
798 | 798 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
799 | 799 | } else { |
800 | 800 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
801 | 801 | } |
802 | - if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
802 | + if (in_array(mb_strtolower(trim($match[3])), $acceptedmedia)) { |
|
803 | 803 | $this->_parse_sections($match[5]); |
804 | 804 | } |
805 | 805 | break; |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | //assign it to the <body> tag, possibly only for the css of the correct media type. |
826 | 826 | |
827 | 827 | // Store the style for later... |
828 | - if ( is_null($this->_page_style) ) |
|
828 | + if (is_null($this->_page_style)) |
|
829 | 829 | $this->_page_style = $this->_parse_properties($match[5]); |
830 | 830 | else |
831 | 831 | $this->_page_style->merge($this->_parse_properties($match[5])); |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | continue; |
840 | 840 | } |
841 | 841 | |
842 | - if ( $match[7] !== "" ) |
|
842 | + if ($match[7] !== "") |
|
843 | 843 | $this->_parse_sections($match[7]); |
844 | 844 | |
845 | 845 | } |
@@ -847,23 +847,23 @@ discard block |
||
847 | 847 | |
848 | 848 | /* See also style.cls Style::_image(), refactoring?, works also for imported css files */ |
849 | 849 | protected function _image($val) { |
850 | - $DEBUGCSS=DEBUGCSS; |
|
850 | + $DEBUGCSS = DEBUGCSS; |
|
851 | 851 | |
852 | - if ( mb_strpos($val, "url") === false ) { |
|
852 | + if (mb_strpos($val, "url") === false) { |
|
853 | 853 | $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
854 | 854 | } |
855 | 855 | else { |
856 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
856 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/", "\\1", trim($val)); |
|
857 | 857 | |
858 | 858 | // Resolve the url now in the context of the current stylesheet |
859 | 859 | $parsed_url = explode_url($val); |
860 | - if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) { |
|
861 | - if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
|
860 | + if ($parsed_url["protocol"] == "" && $this->get_protocol() == "") { |
|
861 | + if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\') { |
|
862 | 862 | $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
863 | 863 | } else { |
864 | 864 | $path = $this->get_base_path(); |
865 | 865 | } |
866 | - $path .= $parsed_url["path"] . $parsed_url["file"]; |
|
866 | + $path .= $parsed_url["path"].$parsed_url["file"]; |
|
867 | 867 | $path = realpath($path); |
868 | 868 | // If realpath returns FALSE then specifically state that there is no background image |
869 | 869 | if (!$path) { $path = 'none'; } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | print "<pre>[_image\n"; |
879 | 879 | print_r($parsed_url); |
880 | 880 | print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n"; |
881 | - print "_image]</pre>";; |
|
881 | + print "_image]</pre>"; ; |
|
882 | 882 | } |
883 | 883 | return $path; |
884 | 884 | } |
@@ -889,22 +889,22 @@ discard block |
||
889 | 889 | * @param string $url the url of the imported CSS file |
890 | 890 | */ |
891 | 891 | private function _parse_import($url) { |
892 | - $arr = preg_split("/[\s\n,]/", $url,-1, PREG_SPLIT_NO_EMPTY); |
|
892 | + $arr = preg_split("/[\s\n,]/", $url, -1, PREG_SPLIT_NO_EMPTY); |
|
893 | 893 | $url = array_shift($arr); |
894 | 894 | $accept = false; |
895 | 895 | |
896 | - if ( count($arr) > 0 ) { |
|
896 | + if (count($arr) > 0) { |
|
897 | 897 | |
898 | 898 | $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
899 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
899 | + if (defined("DOMPDF_DEFAULT_MEDIA_TYPE")) { |
|
900 | 900 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
901 | 901 | } else { |
902 | 902 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
903 | 903 | } |
904 | 904 | |
905 | 905 | // @import url media_type [media_type...] |
906 | - foreach ( $arr as $type ) { |
|
907 | - if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) { |
|
906 | + foreach ($arr as $type) { |
|
907 | + if (in_array(mb_strtolower(trim($type)), $acceptedmedia)) { |
|
908 | 908 | $accept = true; |
909 | 909 | break; |
910 | 910 | } |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | $accept = true; |
916 | 916 | } |
917 | 917 | |
918 | - if ( $accept ) { |
|
918 | + if ($accept) { |
|
919 | 919 | // Store our current base url properties in case the new url is elsewhere |
920 | 920 | $protocol = $this->_protocol; |
921 | 921 | $host = $this->_base_host; |
@@ -975,10 +975,10 @@ discard block |
||
975 | 975 | if (DEBUGCSS) print '('; |
976 | 976 | $important = false; |
977 | 977 | $prop = trim($prop); |
978 | - if (substr($prop,-9) === 'important') { |
|
979 | - $prop_tmp = rtrim(substr($prop,0,-9)); |
|
980 | - if (substr($prop_tmp,-1) === '!') { |
|
981 | - $prop = rtrim(substr($prop_tmp,0,-1)); |
|
978 | + if (substr($prop, -9) === 'important') { |
|
979 | + $prop_tmp = rtrim(substr($prop, 0, -9)); |
|
980 | + if (substr($prop_tmp, -1) === '!') { |
|
981 | + $prop = rtrim(substr($prop_tmp, 0, -1)); |
|
982 | 982 | $important = true; |
983 | 983 | } |
984 | 984 | } |
@@ -989,14 +989,14 @@ discard block |
||
989 | 989 | } |
990 | 990 | |
991 | 991 | $i = mb_strpos($prop, ":"); |
992 | - if ( $i === false ) { |
|
992 | + if ($i === false) { |
|
993 | 993 | if (DEBUGCSS) print 'novalue'.$prop.')'; |
994 | 994 | continue; |
995 | 995 | } |
996 | 996 | |
997 | 997 | $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
998 | - $value = ltrim(mb_substr($prop, $i+1)); |
|
999 | - if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
998 | + $value = ltrim(mb_substr($prop, $i + 1)); |
|
999 | + if (DEBUGCSS) print $prop_name.':='.$value.($important ? '!IMPORTANT' : '').')'; |
|
1000 | 1000 | //New style, anyway empty |
1001 | 1001 | //if ($important || !$style->important_get($prop_name) ) { |
1002 | 1002 | //$style->$prop_name = array($value,$important); |
@@ -1035,7 +1035,7 @@ discard block |
||
1035 | 1035 | |
1036 | 1036 | $selectors = explode(",", mb_substr($sect, 0, $i)); |
1037 | 1037 | if (DEBUGCSS) print '[section'; |
1038 | - $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
|
1038 | + $style = $this->_parse_properties(trim(mb_substr($sect, $i + 1))); |
|
1039 | 1039 | |
1040 | 1040 | // Assign it to the selected elements |
1041 | 1041 | foreach ($selectors as $selector) { |
@@ -1066,7 +1066,7 @@ discard block |
||
1066 | 1066 | function __toString() { |
1067 | 1067 | $str = ""; |
1068 | 1068 | foreach ($this->_styles as $selector => $style) |
1069 | - $str .= "$selector => " . $style->__toString() . "\n"; |
|
1069 | + $str .= "$selector => ".$style->__toString()."\n"; |
|
1070 | 1070 | |
1071 | 1071 | return $str; |
1072 | 1072 | } |