@@ -144,7 +144,9 @@ |
||
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | - if (DEBUGPNG) print $width.' '.$height.';'; |
|
147 | + if (DEBUGPNG) { |
|
148 | + print $width.' '.$height.';'; |
|
149 | + } |
|
148 | 150 | |
149 | 151 | // Synchronize the styles |
150 | 152 | $inner_style = $this->_frame->get_style(); |
@@ -58,24 +58,20 @@ |
||
58 | 58 | |
59 | 59 | $backend = strtolower(DOMPDF_PDF_BACKEND); |
60 | 60 | |
61 | - if ( isset($class) && class_exists($class, false) ) |
|
62 | - $class .= "_Adapter"; |
|
63 | - |
|
64 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
65 | - class_exists("PDFLib", false) ) |
|
66 | - $class = "PDFLib_Adapter"; |
|
67 | - |
|
68 | - else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) |
|
69 | - $class = "CPDF_Adapter"; |
|
70 | - |
|
71 | - else if ( ( $backend === "tcpdf") ) |
|
72 | - $class = "TCPDF_Adapter"; |
|
73 | - |
|
74 | - else if ( $backend === "gd" ) |
|
75 | - $class = "GD_Adapter"; |
|
76 | - |
|
77 | - else |
|
78 | - $class = "CPDF_Adapter"; |
|
61 | + if ( isset($class) && class_exists($class, false) ) { |
|
62 | + $class .= "_Adapter"; |
|
63 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) && |
|
64 | + class_exists("PDFLib", false) ) { |
|
65 | + $class = "PDFLib_Adapter"; |
|
66 | + } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) { |
|
67 | + $class = "CPDF_Adapter"; |
|
68 | + } else if ( ( $backend === "tcpdf") ) { |
|
69 | + $class = "TCPDF_Adapter"; |
|
70 | + } else if ( $backend === "gd" ) { |
|
71 | + $class = "GD_Adapter"; |
|
72 | + } else { |
|
73 | + $class = "CPDF_Adapter"; |
|
74 | + } |
|
79 | 75 | |
80 | 76 | return new $class($paper, $orientation); |
81 | 77 |
@@ -216,13 +216,15 @@ |
||
216 | 216 | * @see save_font_families() |
217 | 217 | */ |
218 | 218 | static function load_font_families() { |
219 | - if ( !is_readable(self::CACHE_FILE) ) |
|
220 | - return; |
|
219 | + if ( !is_readable(self::CACHE_FILE) ) { |
|
220 | + return; |
|
221 | + } |
|
221 | 222 | |
222 | 223 | $data = file_get_contents(self::CACHE_FILE); |
223 | 224 | |
224 | - if ( $data != "" ) |
|
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
225 | + if ( $data != "" ) { |
|
226 | + eval ('self::$_font_lookup = ' . $data . ";"); |
|
227 | + } |
|
226 | 228 | } |
227 | 229 | |
228 | 230 | /** |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color ); |
59 | 59 | } |
60 | 60 | |
61 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
62 | - $this->_background_image($url, $x, $y, $w, $h, $style); |
|
61 | + if ( ($url = $style->background_image) && $url !== "none" ) { |
|
62 | + $this->_background_image($url, $x, $y, $w, $h, $style); |
|
63 | + } |
|
63 | 64 | |
64 | 65 | |
65 | 66 | $this->_render_border($frame); |
@@ -81,8 +82,9 @@ discard block |
||
81 | 82 | foreach ($bp as $side => $props) { |
82 | 83 | list($x, $y, $w, $h) = $bbox; |
83 | 84 | |
84 | - if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) |
|
85 | - continue; |
|
85 | + if ( !$props["style"] || $props["style"] === "none" || $props["width"] <= 0 ) { |
|
86 | + continue; |
|
87 | + } |
|
86 | 88 | |
87 | 89 | |
88 | 90 | switch($side) { |
@@ -62,8 +62,9 @@ |
||
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - if ( $frame->get_parent() !== $this ) |
|
66 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
65 | + if ( $frame->get_parent() !== $this ) { |
|
66 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
67 | + } |
|
67 | 68 | |
68 | 69 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
69 | 70 | $this->get_parent()->insert_child_after($split, $this); |
@@ -100,10 +100,11 @@ discard block |
||
100 | 100 | break; |
101 | 101 | |
102 | 102 | case "inline": |
103 | - if ( $frame->get_node()->nodeName === "#text" ) |
|
104 | - $this->_render_frame("text", $frame); |
|
105 | - else |
|
106 | - $this->_render_frame("inline", $frame); |
|
103 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
104 | + $this->_render_frame("text", $frame); |
|
105 | + } else { |
|
106 | + $this->_render_frame("inline", $frame); |
|
107 | + } |
|
107 | 108 | break; |
108 | 109 | |
109 | 110 | case "table-cell": |
@@ -126,9 +127,7 @@ discard block |
||
126 | 127 | $node->getAttribute("language") === "php" ) { |
127 | 128 | // Evaluate embedded php scripts |
128 | 129 | $this->_render_frame("php", $frame); |
129 | - } |
|
130 | - |
|
131 | - elseif ( $node->getAttribute("type") === "text/javascript" || |
|
130 | + } elseif ( $node->getAttribute("type") === "text/javascript" || |
|
132 | 131 | $node->getAttribute("language") === "javascript" ) { |
133 | 132 | // Insert JavaScript |
134 | 133 | $this->_render_frame("javascript", $frame); |
@@ -146,8 +145,9 @@ discard block |
||
146 | 145 | // Check for begin frame callback |
147 | 146 | $this->_check_callbacks("begin_frame", $frame); |
148 | 147 | |
149 | - foreach ($frame->get_children() as $child) |
|
150 | - $this->render($child); |
|
148 | + foreach ($frame->get_children() as $child) { |
|
149 | + $this->render($child); |
|
150 | + } |
|
151 | 151 | |
152 | 152 | // Check for end frame callback |
153 | 153 | $this->_check_callbacks("end_frame", $frame); |
@@ -52,8 +52,10 @@ discard block |
||
52 | 52 | function render(Frame $frame) { |
53 | 53 | $style = $frame->get_style(); |
54 | 54 | |
55 | - if ( !$frame->get_first_child() ) |
|
56 | - return; // No children, no service |
|
55 | + if ( !$frame->get_first_child() ) { |
|
56 | + return; |
|
57 | + } |
|
58 | + // No children, no service |
|
57 | 59 | |
58 | 60 | // Draw the left border if applicable |
59 | 61 | $bp = $style->get_border_properties(); |
@@ -87,8 +89,9 @@ discard block |
||
87 | 89 | // borders on this line. |
88 | 90 | |
89 | 91 | // Background: |
90 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
91 | - $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
92 | + if ( ($bg = $style->background_color) !== "transparent" ) { |
|
93 | + $this->_canvas->filled_rectangle( $x, $y, $w, $h, $style->background_color); |
|
94 | + } |
|
92 | 95 | |
93 | 96 | if ( ($url = $style->background_image) && $url !== "none" ) { |
94 | 97 | $this->_background_image($url, $x, $y, $w, $h, $style); |
@@ -118,8 +121,9 @@ discard block |
||
118 | 121 | // Handle anchors & links |
119 | 122 | if ( $frame->get_node()->nodeName === "a" ) { |
120 | 123 | |
121 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
122 | - $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
124 | + if ( $href = $frame->get_node()->getAttribute("href") ) { |
|
125 | + $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
126 | + } |
|
123 | 127 | |
124 | 128 | } |
125 | 129 | |
@@ -130,18 +134,20 @@ discard block |
||
130 | 134 | continue; |
131 | 135 | } |
132 | 136 | |
133 | - if ( is_null($w) ) |
|
134 | - $w = $child_w; |
|
135 | - else |
|
136 | - $w += $child_w; |
|
137 | + if ( is_null($w) ) { |
|
138 | + $w = $child_w; |
|
139 | + } else { |
|
140 | + $w += $child_w; |
|
141 | + } |
|
137 | 142 | |
138 | 143 | $h = max($h, $child_h); |
139 | 144 | } |
140 | 145 | |
141 | 146 | |
142 | 147 | // Handle the last child |
143 | - if ( ($bg = $style->background_color) !== "transparent" ) |
|
144 | - $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
148 | + if ( ($bg = $style->background_color) !== "transparent" ) { |
|
149 | + $this->_canvas->filled_rectangle( $x + $widths[3], $y + $widths[0], $w, $h, $style->background_color); |
|
150 | + } |
|
145 | 151 | |
146 | 152 | //On continuation lines (after line break) of inline elements, the style got copied. |
147 | 153 | //But a non repeatable background image should not be repeated on the next line. |
@@ -151,8 +157,9 @@ discard block |
||
151 | 157 | // Repeat not given: default is Style::__construct |
152 | 158 | // ... && (!($repeat = $style->background_repeat) || $repeat === "repeat" ... |
153 | 159 | //different position? $this->_background_image($url, $x, $y, $w, $h, $style); |
154 | - if ( ($url = $style->background_image) && $url !== "none" ) |
|
155 | - $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
160 | + if ( ($url = $style->background_image) && $url !== "none" ) { |
|
161 | + $this->_background_image($url, $x + $widths[3], $y + $widths[0], $w, $h, $style); |
|
162 | + } |
|
156 | 163 | |
157 | 164 | // Add the border widths |
158 | 165 | $w += $widths[1] + $widths[3]; |
@@ -190,11 +197,13 @@ discard block |
||
190 | 197 | // Handle anchors & links |
191 | 198 | if ( $frame->get_node()->nodeName === "a" ) { |
192 | 199 | |
193 | - if ( $name = $frame->get_node()->getAttribute("name") ) |
|
194 | - $this->_canvas->add_named_dest($name); |
|
200 | + if ( $name = $frame->get_node()->getAttribute("name") ) { |
|
201 | + $this->_canvas->add_named_dest($name); |
|
202 | + } |
|
195 | 203 | |
196 | - if ( $href = $frame->get_node()->getAttribute("href") ) |
|
197 | - $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
204 | + if ( $href = $frame->get_node()->getAttribute("href") ) { |
|
205 | + $this->_canvas->add_link($href, $x, $y, $w, $h); |
|
206 | + } |
|
198 | 207 | } |
199 | 208 | } |
200 | 209 | } |
@@ -146,8 +146,9 @@ |
||
146 | 146 | // Small hack to prevent indenting of list text |
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
149 | - $this->_width == 0) |
|
150 | - return 0; |
|
149 | + $this->_width == 0) { |
|
150 | + return 0; |
|
151 | + } |
|
151 | 152 | //This aligns the "inside" image position with the text. |
152 | 153 | //The text starts to the right of the image. |
153 | 154 | //Between the image and the text there is an added margin of image width. |
@@ -61,8 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | 63 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | - if ( is_null($dompdf) ) |
|
65 | - throw new Exception("foo"); |
|
64 | + if ( is_null($dompdf) ) { |
|
65 | + throw new Exception("foo"); |
|
66 | + } |
|
66 | 67 | switch ($frame->get_style()->display) { |
67 | 68 | |
68 | 69 | case "block": |
@@ -127,15 +128,17 @@ discard block |
||
127 | 128 | break; |
128 | 129 | |
129 | 130 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
131 | - $positioner = "Inline"; |
|
132 | - else |
|
133 | - $positioner = "List_Bullet"; |
|
134 | - |
|
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | - $decorator = "List_Bullet_Image"; |
|
137 | - else |
|
138 | - $decorator = "List_Bullet"; |
|
131 | + if ( $frame->get_style()->list_style_position === "inside" ) { |
|
132 | + $positioner = "Inline"; |
|
133 | + } else { |
|
134 | + $positioner = "List_Bullet"; |
|
135 | + } |
|
136 | + |
|
137 | + if ( $frame->get_style()->list_style_image !== "none" ) { |
|
138 | + $decorator = "List_Bullet_Image"; |
|
139 | + } else { |
|
140 | + $decorator = "List_Bullet"; |
|
141 | + } |
|
139 | 142 | |
140 | 143 | $reflower = "List_Bullet"; |
141 | 144 | break; |
@@ -163,8 +166,9 @@ discard block |
||
163 | 166 | } |
164 | 167 | |
165 | 168 | if ( $frame->get_style()->position === "absolute" || |
166 | - $frame->get_style()->position === "fixed" ) |
|
167 | - $positioner = "Absolute"; |
|
169 | + $frame->get_style()->position === "fixed" ) { |
|
170 | + $positioner = "Absolute"; |
|
171 | + } |
|
168 | 172 | |
169 | 173 | $positioner .= "_Positioner"; |
170 | 174 | $decorator .= "_Frame_Decorator"; |