@@ -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 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $new_height = $height - $v_space; |
89 | 89 | $style->height = $new_height; |
90 | 90 | |
91 | - if ( $new_height > $this->_content_height ) { |
|
91 | + if ($new_height > $this->_content_height) { |
|
92 | 92 | // Adjust our vertical alignment |
93 | 93 | $valign = $style->vertical_align; |
94 | 94 | |
@@ -113,9 +113,9 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | // Move our children |
116 | - foreach ( $this->get_lines() as $i => $line ) { |
|
117 | - foreach ( $line["frames"] as $frame ) |
|
118 | - $frame->set_position( null, $frame->get_position("y") + $delta ); |
|
116 | + foreach ($this->get_lines() as $i => $line) { |
|
117 | + foreach ($line["frames"] as $frame) |
|
118 | + $frame->set_position(null, $frame->get_position("y") + $delta); |
|
119 | 119 | } |
120 | 120 | } |
121 | 121 |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | } |
171 | 171 | |
172 | 172 | function &get_column($i) { |
173 | - if ( !isset($this->_columns[$i]) ) |
|
173 | + if (!isset($this->_columns[$i])) |
|
174 | 174 | $this->_columns[$i] = array("x" => 0, |
175 | 175 | "min-width" => 0, |
176 | 176 | "max-width" => 0, |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | } |
188 | 188 | |
189 | 189 | function &get_row($j) { |
190 | - if ( !isset($this->_rows[$j]) ) |
|
190 | + if (!isset($this->_rows[$j])) |
|
191 | 191 | $this->_rows[$j] = array("y" => 0, |
192 | 192 | "first-column" => 0, |
193 | 193 | "height" => null); |
@@ -195,11 +195,11 @@ discard block |
||
195 | 195 | } |
196 | 196 | |
197 | 197 | function get_border($i, $j, $h_v, $prop = null) { |
198 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) |
|
198 | + if (!isset($this->_borders[$i][$j][$h_v])) |
|
199 | 199 | $this->_borders[$i][$j][$h_v] = array("width" => 0, |
200 | 200 | "style" => "solid", |
201 | 201 | "color" => "black"); |
202 | - if ( isset($prop) ) |
|
202 | + if (isset($prop)) |
|
203 | 203 | return $this->_borders[$i][$j][$h_v][$prop]; |
204 | 204 | |
205 | 205 | return $this->_borders[$i][$j][$h_v]; |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | function get_border_properties($i, $j) { |
209 | 209 | |
210 | 210 | $left = $this->get_border($i, $j, "vertical"); |
211 | - $right = $this->get_border($i, $j+1, "vertical"); |
|
211 | + $right = $this->get_border($i, $j + 1, "vertical"); |
|
212 | 212 | $top = $this->get_border($i, $j, "horizontal"); |
213 | - $bottom = $this->get_border($i+1, $j, "horizontal"); |
|
213 | + $bottom = $this->get_border($i + 1, $j, "horizontal"); |
|
214 | 214 | |
215 | 215 | return compact("top", "bottom", "left", "right"); |
216 | 216 | } |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | function get_spanned_cells($frame) { |
221 | 221 | $key = $frame->get_id(); |
222 | 222 | |
223 | - if ( !isset($this->_frames[$key]) ) { |
|
223 | + if (!isset($this->_frames[$key])) { |
|
224 | 224 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
225 | 225 | } |
226 | 226 | |
@@ -238,20 +238,20 @@ discard block |
||
238 | 238 | |
239 | 239 | $key = $frame->get_id(); |
240 | 240 | |
241 | - if ( !isset($this->_frames[$key]) ) { |
|
241 | + if (!isset($this->_frames[$key])) { |
|
242 | 242 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
243 | 243 | } |
244 | 244 | |
245 | 245 | $col = $this->_frames[$key]["columns"][0]; |
246 | 246 | $row = $this->_frames[$key]["rows"][0]; |
247 | 247 | |
248 | - if ( !isset($this->_columns[$col])) { |
|
248 | + if (!isset($this->_columns[$col])) { |
|
249 | 249 | $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
250 | 250 | $x = 0; |
251 | 251 | } else |
252 | 252 | $x = $this->_columns[$col]["x"]; |
253 | 253 | |
254 | - if ( !isset($this->_rows[$row])) { |
|
254 | + if (!isset($this->_rows[$row])) { |
|
255 | 255 | $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
256 | 256 | $y = 0; |
257 | 257 | } else |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | function get_frame_width($frame) { |
264 | 264 | $key = $frame->get_id(); |
265 | 265 | |
266 | - if ( !isset($this->_frames[$key]) ) { |
|
266 | + if (!isset($this->_frames[$key])) { |
|
267 | 267 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
268 | 268 | } |
269 | 269 | |
@@ -279,13 +279,13 @@ discard block |
||
279 | 279 | function get_frame_height($frame) { |
280 | 280 | $key = $frame->get_id(); |
281 | 281 | |
282 | - if ( !isset($this->_frames[$key]) ) |
|
282 | + if (!isset($this->_frames[$key])) |
|
283 | 283 | throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
284 | 284 | |
285 | 285 | $rows = $this->_frames[$key]["rows"]; |
286 | 286 | $h = 0; |
287 | 287 | foreach ($rows as $i) { |
288 | - if ( !isset($this->_rows[$i]) ) { |
|
288 | + if (!isset($this->_rows[$i])) { |
|
289 | 289 | throw new Exception("foo"); |
290 | 290 | } |
291 | 291 | $h += $this->_rows[$i]["height"]; |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | //........................................................................ |
299 | 299 | |
300 | 300 | function set_column_width($j, $width) { |
301 | - $col =& $this->get_column($j); |
|
301 | + $col = & $this->get_column($j); |
|
302 | 302 | $col["used-width"] = $width; |
303 | - $next_col =& $this->get_column($j+1); |
|
303 | + $next_col = & $this->get_column($j + 1); |
|
304 | 304 | $next_col["x"] = $next_col["x"] + $width; |
305 | 305 | } |
306 | 306 | |
307 | 307 | function set_row_height($i, $height) { |
308 | - $row =& $this->get_row($i); |
|
309 | - if ( $height <= $row["height"] ) |
|
308 | + $row = & $this->get_row($i); |
|
309 | + if ($height <= $row["height"]) |
|
310 | 310 | return; |
311 | 311 | |
312 | 312 | $row["height"] = $height; |
313 | - $next_row =& $this->get_row($i+1); |
|
313 | + $next_row = & $this->get_row($i + 1); |
|
314 | 314 | $next_row["y"] = $row["y"] + $height; |
315 | 315 | |
316 | 316 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $n_style = $border_spec["style"]; |
324 | 324 | $n_color = $border_spec["color"]; |
325 | 325 | |
326 | - if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
|
326 | + if (!isset($this->_borders[$i][$j][$h_v])) { |
|
327 | 327 | $this->_borders[$i][$j][$h_v] = $border_spec; |
328 | 328 | return $this->_borders[$i][$j][$h_v]["width"]; |
329 | 329 | } |
@@ -332,15 +332,15 @@ discard block |
||
332 | 332 | $o_style = $this->_borders[$i][$j][$h_v]["style"]; |
333 | 333 | $o_color = $this->_borders[$i][$j][$h_v]["color"]; |
334 | 334 | |
335 | - if ( ($n_style === "hidden" || |
|
336 | - $n_width > $o_width || |
|
335 | + if (($n_style === "hidden" || |
|
336 | + $n_width > $o_width || |
|
337 | 337 | $o_style === "none") |
338 | 338 | |
339 | 339 | or |
340 | 340 | |
341 | 341 | ($o_width == $n_width && |
342 | 342 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
343 | - self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
|
343 | + self::$_BORDER_STYLE_SCORE[$n_style] > self::$_BORDER_STYLE_SCORE[$o_style])) |
|
344 | 344 | $this->_borders[$i][$j][$h_v] = $border_spec; |
345 | 345 | |
346 | 346 | return $this->_borders[$i][$j][$h_v]["width"]; |
@@ -356,37 +356,37 @@ discard block |
||
356 | 356 | $collapse = $this->_table->get_style()->border_collapse == "collapse"; |
357 | 357 | |
358 | 358 | // Recursively add the frames within tables, table-row-groups and table-rows |
359 | - if ( $display == "table-row" || |
|
359 | + if ($display == "table-row" || |
|
360 | 360 | $display == "table" || |
361 | 361 | $display == "inline-table" || |
362 | - in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
|
362 | + in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) { |
|
363 | 363 | |
364 | 364 | $start_row = $this->__row; |
365 | - foreach ( $frame->get_children() as $child ) |
|
366 | - $this->add_frame( $child ); |
|
365 | + foreach ($frame->get_children() as $child) |
|
366 | + $this->add_frame($child); |
|
367 | 367 | |
368 | - if ( $display == "table-row" ) |
|
368 | + if ($display == "table-row") |
|
369 | 369 | $this->add_row(); |
370 | 370 | |
371 | 371 | $num_rows = $this->__row - $start_row - 1; |
372 | 372 | $key = $frame->get_id(); |
373 | 373 | |
374 | 374 | // Row groups always span across the entire table |
375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
375 | + $this->_frames[$key]["columns"] = range(0, max(0, $this->_num_cols - 1)); |
|
376 | + $this->_frames[$key]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
377 | + $this->_frames[$key]["frame"] = $frame; |
|
378 | 378 | |
379 | - if ( $display != "table-row" && $collapse ) { |
|
379 | + if ($display != "table-row" && $collapse) { |
|
380 | 380 | |
381 | 381 | $bp = $style->get_border_properties(); |
382 | 382 | |
383 | 383 | // Resolve the borders |
384 | - for ( $i = 0; $i < $num_rows+1; $i++) { |
|
384 | + for ($i = 0; $i < $num_rows + 1; $i++) { |
|
385 | 385 | $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
386 | 386 | $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
387 | 387 | } |
388 | 388 | |
389 | - for ( $j = 0; $j < $this->_num_cols; $j++) { |
|
389 | + for ($j = 0; $j < $this->_num_cols; $j++) { |
|
390 | 390 | $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
391 | 391 | $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
392 | 392 | } |
@@ -400,14 +400,14 @@ discard block |
||
400 | 400 | $colspan = $frame->get_node()->getAttribute("colspan"); |
401 | 401 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
402 | 402 | |
403 | - if ( !$colspan ) { |
|
403 | + if (!$colspan) { |
|
404 | 404 | $colspan = 1; |
405 | - $frame->get_node()->setAttribute("colspan",1); |
|
405 | + $frame->get_node()->setAttribute("colspan", 1); |
|
406 | 406 | } |
407 | 407 | |
408 | - if ( !$rowspan ) { |
|
408 | + if (!$rowspan) { |
|
409 | 409 | $rowspan = 1; |
410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
410 | + $frame->get_node()->setAttribute("rowspan", 1); |
|
411 | 411 | } |
412 | 412 | $key = $frame->get_id(); |
413 | 413 | |
@@ -419,20 +419,20 @@ discard block |
||
419 | 419 | |
420 | 420 | // Find the next available column (fix by Ciro Mondueri) |
421 | 421 | $ac = $this->__col; |
422 | - while ( isset($this->_cells[$this->__row][$ac]) ) |
|
422 | + while (isset($this->_cells[$this->__row][$ac])) |
|
423 | 423 | $ac++; |
424 | 424 | $this->__col = $ac; |
425 | 425 | |
426 | 426 | // Rows: |
427 | - for ( $i = 0; $i < $rowspan; $i++ ) { |
|
427 | + for ($i = 0; $i < $rowspan; $i++) { |
|
428 | 428 | $row = $this->__row + $i; |
429 | 429 | |
430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
430 | + $this->_frames[$key]["rows"][] = $row; |
|
431 | 431 | |
432 | - for ( $j = 0; $j < $colspan; $j++) |
|
432 | + for ($j = 0; $j < $colspan; $j++) |
|
433 | 433 | $this->_cells[$row][$this->__col + $j] = $frame; |
434 | 434 | |
435 | - if ( $collapse ) { |
|
435 | + if ($collapse) { |
|
436 | 436 | // Resolve vertical borders |
437 | 437 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
438 | 438 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
@@ -442,21 +442,21 @@ discard block |
||
442 | 442 | $max_top = $max_bottom = 0; |
443 | 443 | |
444 | 444 | // Columns: |
445 | - for ( $j = 0; $j < $colspan; $j++ ) { |
|
445 | + for ($j = 0; $j < $colspan; $j++) { |
|
446 | 446 | $col = $this->__col + $j; |
447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
447 | + $this->_frames[$key]["columns"][] = $col; |
|
448 | 448 | |
449 | - if ( $collapse ) { |
|
449 | + if ($collapse) { |
|
450 | 450 | // Resolve horizontal borders |
451 | 451 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
452 | 452 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
453 | 453 | } |
454 | 454 | } |
455 | 455 | |
456 | - $this->_frames[ $key ]["frame"] = $frame; |
|
456 | + $this->_frames[$key]["frame"] = $frame; |
|
457 | 457 | |
458 | 458 | // Handle seperated border model |
459 | - if ( !$collapse ) { |
|
459 | + if (!$collapse) { |
|
460 | 460 | list($h, $v) = $this->_table->get_style()->border_spacing; |
461 | 461 | |
462 | 462 | // Border spacing is effectively a margin between cells |
@@ -481,26 +481,26 @@ discard block |
||
481 | 481 | |
482 | 482 | $width = $style->width; |
483 | 483 | |
484 | - if ( is_percent($width) ) { |
|
484 | + if (is_percent($width)) { |
|
485 | 485 | $var = "percent"; |
486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
486 | + $val = (float) rtrim($width, "% ") / $colspan; |
|
487 | 487 | |
488 | - } else if ( $width !== "auto" ) { |
|
488 | + } else if ($width !== "auto") { |
|
489 | 489 | $var = "absolute"; |
490 | 490 | $val = $style->length_in_pt($frame_min) / $colspan; |
491 | 491 | } |
492 | 492 | |
493 | 493 | $min = 0; |
494 | 494 | $max = 0; |
495 | - for ( $cs = 0; $cs < $colspan; $cs++ ) { |
|
495 | + for ($cs = 0; $cs < $colspan; $cs++) { |
|
496 | 496 | |
497 | 497 | // Resolve the frame's width(s) with other cells |
498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
498 | + $col = & $this->get_column($this->__col + $cs); |
|
499 | 499 | |
500 | 500 | // Note: $var is either 'percent' or 'absolute'. We compare the |
501 | 501 | // requested percentage or absolute values with the existing widths |
502 | 502 | // and adjust accordingly. |
503 | - if ( isset($var) && $val > $col[$var] ) { |
|
503 | + if (isset($var) && $val > $col[$var]) { |
|
504 | 504 | $col[$var] = $val; |
505 | 505 | $col["auto"] = false; |
506 | 506 | } |
@@ -510,25 +510,25 @@ discard block |
||
510 | 510 | } |
511 | 511 | |
512 | 512 | |
513 | - if ( $frame_min > $min ) { |
|
513 | + if ($frame_min > $min) { |
|
514 | 514 | // The frame needs more space. Expand each sub-column |
515 | 515 | $inc = ($frame_min - $min) / $colspan; |
516 | 516 | for ($c = 0; $c < $colspan; $c++) { |
517 | - $col =& $this->get_column($this->__col + $c); |
|
517 | + $col = & $this->get_column($this->__col + $c); |
|
518 | 518 | $col["min-width"] += $inc; |
519 | 519 | } |
520 | 520 | } |
521 | 521 | |
522 | - if ( $frame_max > $max ) { |
|
522 | + if ($frame_max > $max) { |
|
523 | 523 | $inc = ($frame_max - $max) / $colspan; |
524 | 524 | for ($c = 0; $c < $colspan; $c++) { |
525 | - $col =& $this->get_column($this->__col + $c); |
|
525 | + $col = & $this->get_column($this->__col + $c); |
|
526 | 526 | $col["max-width"] += $inc; |
527 | 527 | } |
528 | 528 | } |
529 | 529 | |
530 | 530 | $this->__col += $colspan; |
531 | - if ( $this->__col > $this->_num_cols ) |
|
531 | + if ($this->__col > $this->_num_cols) |
|
532 | 532 | $this->_num_cols = $this->__col; |
533 | 533 | |
534 | 534 | } |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | |
543 | 543 | // Find the next available column |
544 | 544 | $i = 0; |
545 | - while ( isset($this->_cells[$this->__row][$i]) ) |
|
545 | + while (isset($this->_cells[$this->__row][$i])) |
|
546 | 546 | $i++; |
547 | 547 | |
548 | 548 | $this->__col = $i; |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | function remove_row(Frame $row) { |
560 | 560 | |
561 | 561 | $key = $row->get_id(); |
562 | - if ( !isset($this->_frames[$key]) ) |
|
563 | - return; // Presumably this row has alredy been removed |
|
562 | + if (!isset($this->_frames[$key])) |
|
563 | + return; // Presumably this row has alredy been removed |
|
564 | 564 | |
565 | 565 | $this->_row = $this->_num_rows--; |
566 | 566 | |
@@ -568,11 +568,11 @@ discard block |
||
568 | 568 | $columns = $this->_frames[$key]["columns"]; |
569 | 569 | |
570 | 570 | // Remove all frames from this row |
571 | - foreach ( $rows as $r ) { |
|
572 | - foreach ( $columns as $c ) { |
|
573 | - if ( isset($this->_cells[$r][$c]) ) { |
|
571 | + foreach ($rows as $r) { |
|
572 | + foreach ($columns as $c) { |
|
573 | + if (isset($this->_cells[$r][$c])) { |
|
574 | 574 | $frame = $this->_cells[$r][$c]; |
575 | - unset($this->_frames[ $frame->get_id() ]); |
|
575 | + unset($this->_frames[$frame->get_id()]); |
|
576 | 576 | unset($this->_cells[$r][$c]); |
577 | 577 | } |
578 | 578 | } |
@@ -591,8 +591,8 @@ discard block |
||
591 | 591 | function remove_row_group(Frame $group) { |
592 | 592 | |
593 | 593 | $key = $group->get_id(); |
594 | - if ( !isset($this->_frames[$key]) ) |
|
595 | - return; // Presumably this row has alredy been removed |
|
594 | + if (!isset($this->_frames[$key])) |
|
595 | + return; // Presumably this row has alredy been removed |
|
596 | 596 | |
597 | 597 | $iter = $group->get_first_child(); |
598 | 598 | while ($iter) { |
@@ -615,7 +615,7 @@ discard block |
||
615 | 615 | $r_key = $last_row->get_id(); |
616 | 616 | |
617 | 617 | $r_rows = $this->_frames[$r_key]["rows"]; |
618 | - $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
|
618 | + $this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows)); |
|
619 | 619 | |
620 | 620 | } |
621 | 621 | |
@@ -626,7 +626,7 @@ discard block |
||
626 | 626 | // column[0]["x"] must be set. |
627 | 627 | |
628 | 628 | $x = $this->_columns[0]["x"]; |
629 | - foreach ( array_keys($this->_columns) as $j ) { |
|
629 | + foreach (array_keys($this->_columns) as $j) { |
|
630 | 630 | $this->_columns[$j]["x"] = $x; |
631 | 631 | $x += $this->_columns[$j]["used-width"]; |
632 | 632 | |
@@ -638,18 +638,18 @@ discard block |
||
638 | 638 | // Pre-condition: widths and heights of each column & row must be |
639 | 639 | // calcluated |
640 | 640 | |
641 | - foreach ( $this->_frames as $arr ) { |
|
641 | + foreach ($this->_frames as $arr) { |
|
642 | 642 | $frame = $arr["frame"]; |
643 | 643 | |
644 | 644 | $h = 0; |
645 | - foreach( $arr["rows"] as $row ) { |
|
646 | - if ( !isset($this->_rows[$row]) ) |
|
645 | + foreach ($arr["rows"] as $row) { |
|
646 | + if (!isset($this->_rows[$row])) |
|
647 | 647 | // The row has been removed because of a page split, so skip it. |
648 | 648 | continue; |
649 | 649 | $h += $this->_rows[$row]["height"]; |
650 | 650 | } |
651 | 651 | |
652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
652 | + if ($frame instanceof Table_Cell_Frame_Decorator) |
|
653 | 653 | $frame->set_cell_height($h); |
654 | 654 | else |
655 | 655 | $frame->get_style()->height = $h; |
@@ -666,12 +666,12 @@ discard block |
||
666 | 666 | |
667 | 667 | |
668 | 668 | // Distribute the increased height proportionally amongst each row |
669 | - foreach ( $this->_frames as $arr ) { |
|
669 | + foreach ($this->_frames as $arr) { |
|
670 | 670 | $frame = $arr["frame"]; |
671 | 671 | |
672 | 672 | $h = 0; |
673 | - foreach ($arr["rows"] as $row ) { |
|
674 | - if ( !isset($this->_rows[$row]) ) |
|
673 | + foreach ($arr["rows"] as $row) { |
|
674 | + if (!isset($this->_rows[$row])) |
|
675 | 675 | continue; |
676 | 676 | |
677 | 677 | $h += $this->_rows[$row]["height"]; |
@@ -679,7 +679,7 @@ discard block |
||
679 | 679 | |
680 | 680 | $new_height = ($h / $content_height) * $table_height; |
681 | 681 | |
682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
682 | + if ($frame instanceof Table_Cell_Frame_Decorator) |
|
683 | 683 | $frame->set_cell_height($new_height); |
684 | 684 | else |
685 | 685 | $frame->get_style()->height = $new_height; |
@@ -694,19 +694,19 @@ discard block |
||
694 | 694 | $str = ""; |
695 | 695 | $str .= "Columns:<br/>"; |
696 | 696 | $str .= pre_r($this->_columns, true); |
697 | - $str .= "Rows:<br/>"; |
|
697 | + $str .= "Rows:<br/>"; |
|
698 | 698 | $str .= pre_r($this->_rows, true); |
699 | 699 | |
700 | - $str .= "Frames:<br/>"; |
|
700 | + $str .= "Frames:<br/>"; |
|
701 | 701 | $arr = array(); |
702 | - foreach ( $this->_frames as $key => $val ) |
|
702 | + foreach ($this->_frames as $key => $val) |
|
703 | 703 | $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
704 | 704 | |
705 | 705 | $str .= pre_r($arr, true); |
706 | 706 | |
707 | - if ( php_sapi_name() == "cli" ) |
|
708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
709 | - array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
|
707 | + if (php_sapi_name() == "cli") |
|
708 | + $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), |
|
709 | + array("\n", chr(27)."[01;33m", chr(27)."[0m"), |
|
710 | 710 | $str)); |
711 | 711 | return $str; |
712 | 712 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | function reflow() { |
58 | 58 | $page = $this->_frame->get_root(); |
59 | 59 | |
60 | - if ( $page->is_full() ) |
|
60 | + if ($page->is_full()) |
|
61 | 61 | return; |
62 | 62 | |
63 | 63 | $this->_frame->position(); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | foreach ($this->_frame->get_children() as $child) { |
68 | 68 | |
69 | - if ( $page->is_full() ) |
|
69 | + if ($page->is_full()) |
|
70 | 70 | return; |
71 | 71 | |
72 | 72 | $child->set_containing_block($cb); |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | - if ( $page->is_full() ) |
|
77 | + if ($page->is_full()) |
|
78 | 78 | return; |
79 | 79 | |
80 | 80 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | |
56 | 56 | const BULLET_PADDING = 1; // Distance from bullet to text in pt |
57 | 57 | // As fraction of font size (including descent). See also DECO_THICKNESS. |
58 | - const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | - const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | - const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
58 | + const BULLET_THICKNESS = 0.04; // Thickness of bullet outline. Screen: 0.08, print: better less, e.g. 0.04 |
|
59 | + const BULLET_DESCENT = 0.3; //descent of font below baseline. Todo: Guessed for now. |
|
60 | + const BULLET_SIZE = 0.35; // bullet diameter. For now 0.5 of font_size without descent. |
|
61 | 61 | |
62 | 62 | static $BULLET_TYPES = array("disc", "circle", "square"); |
63 | 63 | |
@@ -71,23 +71,23 @@ discard block |
||
71 | 71 | $style = $this->_frame->get_style(); |
72 | 72 | // Small hack to prevent extra indenting of list text on list_style_position === "inside" |
73 | 73 | // and on suppressed bullet |
74 | - if ( $style->list_style_position === "outside" || |
|
75 | - $style->list_style_type === "none" ) |
|
74 | + if ($style->list_style_position === "outside" || |
|
75 | + $style->list_style_type === "none") |
|
76 | 76 | return 0; |
77 | - return $style->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
77 | + return $style->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | //hits only on "inset" lists items, to increase height of box |
81 | 81 | function get_margin_height() { |
82 | - return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
82 | + return $this->_frame->get_style()->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | function get_width() { |
86 | - return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
86 | + return $this->_frame->get_style()->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | function get_height() { |
90 | - return $this->_frame->get_style()->get_font_size()*self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
90 | + return $this->_frame->get_style()->get_font_size() * self::BULLET_SIZE + 2 * self::BULLET_PADDING; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | //........................................................................ |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | $p = $this->_frame->find_block_parent(); |
59 | 59 | |
60 | - if ( $p ) { |
|
60 | + if ($p) { |
|
61 | 61 | $p->add_line(); |
62 | 62 | $y = $p->get_current_line("y"); |
63 | 63 |