@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | // Resample the bullet image to be consistent with 'auto' sized images |
91 | 91 | // See also Image_Frame_Reflower::get_min_max_width |
92 | 92 | // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
93 | - $this->_width = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | - $this->_height = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
93 | + $this->_width = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | + $this->_height = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
95 | 95 | |
96 | 96 | //If an image is taller as the containing block/box, the box should be extended. |
97 | 97 | //Neighbour elements are overwriting the overlapping image areas. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
117 | 117 | //This controls the distance between bullet image and text |
118 | 118 | //return $this->_width; |
119 | - return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
119 | + return $this->_frame->get_style()->get_font_size() * List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
121 | 121 | } |
122 | 122 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
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 | - if ( $this->_frame->get_style()->list_style_position === "outside" || |
|
148 | + if ($this->_frame->get_style()->list_style_position === "outside" || |
|
149 | 149 | $this->_width == 0) |
150 | 150 | return 0; |
151 | 151 | //This aligns the "inside" image position with the text. |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | static function decorate_root(Frame $root, DOMPDF $dompdf) { |
56 | 56 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | - $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
|
57 | + $frame->set_reflower(new Page_Frame_Reflower($frame)); |
|
58 | 58 | $root->set_decorator($frame); |
59 | 59 | return $frame; |
60 | 60 | } |
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) ) |
|
64 | + if (is_null($dompdf)) |
|
65 | 65 | throw new Exception("foo"); |
66 | 66 | switch ($frame->get_style()->display) { |
67 | 67 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | case "inline": |
81 | 81 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
82 | + if ($frame->get_node()->nodeName === "#text") { |
|
83 | 83 | $decorator = "Text"; |
84 | 84 | $reflower = "Text"; |
85 | 85 | } else { |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | break; |
128 | 128 | |
129 | 129 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
130 | + if ($frame->get_style()->list_style_position === "inside") |
|
131 | 131 | $positioner = "Inline"; |
132 | 132 | else |
133 | 133 | $positioner = "List_Bullet"; |
134 | 134 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
135 | + if ($frame->get_style()->list_style_image !== "none") |
|
136 | 136 | $decorator = "List_Bullet_Image"; |
137 | 137 | else |
138 | 138 | $decorator = "List_Bullet"; |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - if ( $frame->get_style()->position === "absolute" || |
|
166 | - $frame->get_style()->position === "fixed" ) |
|
165 | + if ($frame->get_style()->position === "absolute" || |
|
166 | + $frame->get_style()->position === "fixed") |
|
167 | 167 | $positioner = "Absolute"; |
168 | 168 | |
169 | 169 | $positioner .= "_Positioner"; |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | $reflower .= "_Frame_Reflower"; |
172 | 172 | |
173 | 173 | $deco = new $decorator($frame, $dompdf); |
174 | - $deco->set_positioner( new $positioner($deco) ); |
|
174 | + $deco->set_positioner(new $positioner($deco)); |
|
175 | 175 | $reflow = new $reflower($deco); |
176 | 176 | |
177 | 177 | // Generated content is a special case |
178 | - if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
|
178 | + if ($frame->get_node()->nodeName === "_dompdf_generated") { |
|
179 | 179 | // Decorate the reflower |
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
180 | + $gen = new Generated_Frame_Reflower($deco); |
|
181 | + $gen->set_reflower($reflow); |
|
182 | 182 | $reflow = $gen; |
183 | 183 | } |
184 | 184 | |
185 | - $deco->set_reflower( $reflow ); |
|
185 | + $deco->set_reflower($reflow); |
|
186 | 186 | |
187 | 187 | // Images are a special case |
188 | 188 | // if ( $frame->get_node()->nodeName === "img" ) { |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | - if ( $recursive ) { |
|
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + if ($recursive) { |
|
105 | + while ($child = $this->get_first_child()) |
|
106 | 106 | $child->dispose(true); |
107 | 107 | } |
108 | 108 | |
@@ -183,41 +183,41 @@ discard block |
||
183 | 183 | function __toString() { return $this->_frame->__toString(); } |
184 | 184 | |
185 | 185 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
186 | + while ($child instanceof Frame_Decorator) |
|
187 | 187 | $child = $child->_frame; |
188 | 188 | |
189 | 189 | $this->_frame->prepend_child($child, $update_node); |
190 | 190 | } |
191 | 191 | |
192 | 192 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
193 | + while ($child instanceof Frame_Decorator) |
|
194 | 194 | $child = $child->_frame; |
195 | 195 | |
196 | 196 | $this->_frame->append_child($child, $update_node); |
197 | 197 | } |
198 | 198 | |
199 | 199 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
200 | + while ($new_child instanceof Frame_Decorator) |
|
201 | 201 | $new_child = $new_child->_frame; |
202 | 202 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
203 | + if ($ref instanceof Frame_Decorator) |
|
204 | 204 | $ref = $ref->_frame; |
205 | 205 | |
206 | 206 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 207 | } |
208 | 208 | |
209 | 209 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
210 | + while ($new_child instanceof Frame_Decorator) |
|
211 | 211 | $new_child = $new_child->_frame; |
212 | 212 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
213 | + while ($ref instanceof Frame_Decorator) |
|
214 | 214 | $ref = $ref->_frame; |
215 | 215 | |
216 | 216 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 217 | } |
218 | 218 | |
219 | 219 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
220 | + while ($child instanceof Frame_Decorator) |
|
221 | 221 | $child = $new_child->_frame; |
222 | 222 | |
223 | 223 | $this->_frame->remove_child($child, $update_node); |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | |
230 | 230 | $p = $this->_frame->get_parent(); |
231 | 231 | |
232 | - if ( $p && $deco = $p->get_decorator() ) { |
|
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + if ($p && $deco = $p->get_decorator()) { |
|
233 | + while ($tmp = $deco->get_decorator()) |
|
234 | 234 | $deco = $tmp; |
235 | 235 | return $deco; |
236 | - } else if ( $p ) |
|
236 | + } else if ($p) |
|
237 | 237 | return $p; |
238 | 238 | else |
239 | 239 | return null; |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | |
242 | 242 | function get_first_child() { |
243 | 243 | $c = $this->_frame->get_first_child(); |
244 | - if ( $c && $deco = $c->get_decorator() ) { |
|
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + if ($c && $deco = $c->get_decorator()) { |
|
245 | + while ($tmp = $deco->get_decorator()) |
|
246 | 246 | $deco = $tmp; |
247 | 247 | return $deco; |
248 | - } else if ( $c ) |
|
248 | + } else if ($c) |
|
249 | 249 | return $c; |
250 | 250 | else |
251 | 251 | return null; |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | |
254 | 254 | function get_last_child() { |
255 | 255 | $c = $this->_frame->get_last_child(); |
256 | - if ( $c && $deco = $c->get_decorator() ) { |
|
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + if ($c && $deco = $c->get_decorator()) { |
|
257 | + while ($tmp = $deco->get_decorator()) |
|
258 | 258 | $deco = $tmp; |
259 | 259 | return $deco; |
260 | - } else if ( $c ) |
|
260 | + } else if ($c) |
|
261 | 261 | return $c; |
262 | 262 | else |
263 | 263 | return null; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | function get_prev_sibling() { |
267 | 267 | $s = $this->_frame->get_prev_sibling(); |
268 | - if ( $s && $deco = $s->get_decorator() ) { |
|
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + if ($s && $deco = $s->get_decorator()) { |
|
269 | + while ($tmp = $deco->get_decorator()) |
|
270 | 270 | $deco = $tmp; |
271 | 271 | return $deco; |
272 | - } else if ( $s ) |
|
272 | + } else if ($s) |
|
273 | 273 | return $s; |
274 | 274 | else |
275 | 275 | return null; |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | function get_next_sibling() { |
279 | 279 | $s = $this->_frame->get_next_sibling(); |
280 | - if ( $s && $deco = $s->get_decorator() ) { |
|
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + if ($s && $deco = $s->get_decorator()) { |
|
281 | + while ($tmp = $deco->get_decorator()) |
|
282 | 282 | $deco = $tmp; |
283 | 283 | return $deco; |
284 | - } else if ( $s ) |
|
284 | + } else if ($s) |
|
285 | 285 | return $s; |
286 | 286 | else |
287 | 287 | return null; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | function set_positioner(Positioner $posn) { |
301 | 301 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
302 | + if ($this->_frame instanceof Frame_Decorator) |
|
303 | 303 | $this->_frame->set_positioner($posn); |
304 | 304 | } |
305 | 305 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | |
308 | 308 | function set_reflower(Frame_Reflower $reflower) { |
309 | 309 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
310 | + if ($this->_frame instanceof Frame_Decorator) |
|
311 | + $this->_frame->set_reflower($reflower); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function get_reflower() { return $this->_reflower; } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | function set_root(Frame $root) { |
319 | 319 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
320 | + if ($this->_frame instanceof Frame_Decorator) |
|
321 | 321 | $this->_frame->set_root($root); |
322 | 322 | } |
323 | 323 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | // Find our nearest block level parent |
331 | 331 | $p = $this->get_parent(); |
332 | 332 | |
333 | - while ( $p ) { |
|
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + while ($p) { |
|
334 | + if (in_array($p->get_style()->display, Style::$BLOCK_TYPES)) |
|
335 | 335 | break; |
336 | 336 | |
337 | 337 | $p = $p->get_parent(); |
@@ -353,15 +353,15 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function split($child = null) { |
355 | 355 | |
356 | - if ( is_null( $child ) ) { |
|
356 | + if (is_null($child)) { |
|
357 | 357 | $this->get_parent()->split($this); |
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | - if ( $child->get_parent() !== $this ) |
|
361 | + if ($child->get_parent() !== $this) |
|
362 | 362 | throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
363 | 363 | |
364 | - $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
|
364 | + $split = $this->copy($this->_frame->get_node()->cloneNode()); |
|
365 | 365 | $split->reset(); |
366 | 366 | $this->get_parent()->insert_child_after($split, $this); |
367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | //........................................................................ |
381 | 381 | |
382 | - final function position() { $this->_positioner->position(); } |
|
382 | + final function position() { $this->_positioner->position(); } |
|
383 | 383 | |
384 | 384 | final function reflow() { |
385 | 385 | // Uncomment this to see the frames before they're laid out, instead of |
@@ -54,17 +54,17 @@ discard block |
||
54 | 54 | */ |
55 | 55 | class Text_Renderer extends Abstract_Renderer { |
56 | 56 | |
57 | - const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
57 | + const DECO_THICKNESS = 0.04; // Thickness of underline. Screen: 0.08, print: better less, e.g. 0.04 |
|
58 | 58 | |
59 | 59 | //Tweaking if $base and $descent are not accurate. |
60 | 60 | //Check method_exists( $this->_canvas, "get_cpdf" ) |
61 | 61 | //- For cpdf these can and must stay 0, because font metrics are used directly. |
62 | 62 | //- For other renderers, if different values are wanted, separate the parameter sets. |
63 | 63 | // But $size and $size-$height seem to be accurate enough |
64 | - const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
65 | - const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
64 | + const UNDERLINE_OFFSET = 0.0; // Relative to bottom of text, as fraction of height. |
|
65 | + const OVERLINE_OFFSET = 0.0; // Relative to top of text |
|
66 | 66 | const LINETHROUGH_OFFSET = 0.0; // Relative to centre of text. |
67 | - const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
67 | + const DECO_EXTENSION = 0.0; // How far to extend lines past either end, in pt |
|
68 | 68 | |
69 | 69 | //........................................................................ |
70 | 70 | |
@@ -74,16 +74,16 @@ discard block |
||
74 | 74 | list($x, $y) = $frame->get_position(); |
75 | 75 | $cb = $frame->get_containing_block(); |
76 | 76 | |
77 | - if ( ($ml = $style->margin_left) === "auto" || $ml === "none" ) |
|
77 | + if (($ml = $style->margin_left) === "auto" || $ml === "none") |
|
78 | 78 | $ml = 0; |
79 | 79 | |
80 | - if ( ($pl = $style->padding_left) === "auto" || $pl === "none" ) |
|
80 | + if (($pl = $style->padding_left) === "auto" || $pl === "none") |
|
81 | 81 | $pl = 0; |
82 | 82 | |
83 | - if ( ($bl = $style->border_left_width) === "auto" || $bl === "none" ) |
|
83 | + if (($bl = $style->border_left_width) === "auto" || $bl === "none") |
|
84 | 84 | $bl = 0; |
85 | 85 | |
86 | - $x += $style->length_in_pt( array($ml, $pl, $bl), $cb["w"] ); |
|
86 | + $x += $style->length_in_pt(array($ml, $pl, $bl), $cb["w"]); |
|
87 | 87 | |
88 | 88 | $text = $frame->get_text(); |
89 | 89 | |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | $font, $size, |
100 | 100 | $style->color, $spacing); |
101 | 101 | |
102 | - if ( method_exists( $this->_canvas, "get_cpdf" ) ) { |
|
103 | - $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3]*$size)/1000; |
|
104 | - $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1]*$size)/1000; |
|
102 | + if (method_exists($this->_canvas, "get_cpdf")) { |
|
103 | + $base = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][3] * $size) / 1000; |
|
104 | + $descent = ($this->_canvas->get_cpdf()->fonts[$this->_canvas->get_cpdf()->currentFont]['FontBBox'][1] * $size) / 1000; |
|
105 | 105 | //print '<pre>Text_Renderer cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
106 | 106 | } else { |
107 | 107 | //Descent is font part below baseline, typically negative. $height is about full height of font box. |
108 | 108 | //$descent = -$size/6; is less accurate, depends on font family. |
109 | 109 | $base = $size; |
110 | - $descent = $size-$height; |
|
110 | + $descent = $size - $height; |
|
111 | 111 | //print '<pre>Text_Renderer other than cpdf:'.$base.' '.$descent.' '.$size.'</pre>'; |
112 | 112 | } |
113 | 113 | |
@@ -118,14 +118,14 @@ discard block |
||
118 | 118 | // our way down. |
119 | 119 | $p = $frame; |
120 | 120 | $stack = array(); |
121 | - while ( $p = $p->get_parent() ) |
|
121 | + while ($p = $p->get_parent()) |
|
122 | 122 | $stack[] = $p; |
123 | 123 | |
124 | - while ( count($stack) > 0 ) { |
|
124 | + while (count($stack) > 0) { |
|
125 | 125 | $f = array_pop($stack); |
126 | 126 | |
127 | 127 | $deco_y = $y; |
128 | - if ( ($text_deco = $f->get_style()->text_decoration) === "none" ) |
|
128 | + if (($text_deco = $f->get_style()->text_decoration) === "none") |
|
129 | 129 | continue; |
130 | 130 | |
131 | 131 | $color = $f->get_style()->color; |
@@ -136,11 +136,11 @@ discard block |
||
136 | 136 | continue; |
137 | 137 | |
138 | 138 | case "underline": |
139 | - $deco_y += $base - $descent+ $size * (self::UNDERLINE_OFFSET - self::DECO_THICKNESS/2); |
|
139 | + $deco_y += $base - $descent + $size * (self::UNDERLINE_OFFSET - self::DECO_THICKNESS / 2); |
|
140 | 140 | break; |
141 | 141 | |
142 | 142 | case "overline": |
143 | - $deco_y += $size * (self::OVERLINE_OFFSET + self::DECO_THICKNESS/2); |
|
143 | + $deco_y += $size * (self::OVERLINE_OFFSET + self::DECO_THICKNESS / 2); |
|
144 | 144 | break; |
145 | 145 | |
146 | 146 | case "line-through": |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | /* $Id: cpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
56 | 56 | |
57 | 57 | // FIXME: Need to sanity check inputs to this class |
58 | -require_once(DOMPDF_LIB_DIR . "/class.pdf.php"); |
|
58 | +require_once(DOMPDF_LIB_DIR."/class.pdf.php"); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * PDF rendering interface |
@@ -79,62 +79,62 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @var array; |
81 | 81 | */ |
82 | - static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79), |
|
83 | - "2a0" => array(0,0,3370.39,4767.87), |
|
84 | - "a0" => array(0,0,2383.94,3370.39), |
|
85 | - "a1" => array(0,0,1683.78,2383.94), |
|
86 | - "a2" => array(0,0,1190.55,1683.78), |
|
87 | - "a3" => array(0,0,841.89,1190.55), |
|
88 | - "a4" => array(0,0,595.28,841.89), |
|
89 | - "a5" => array(0,0,419.53,595.28), |
|
90 | - "a6" => array(0,0,297.64,419.53), |
|
91 | - "a7" => array(0,0,209.76,297.64), |
|
92 | - "a8" => array(0,0,147.40,209.76), |
|
93 | - "a9" => array(0,0,104.88,147.40), |
|
94 | - "a10" => array(0,0,73.70,104.88), |
|
95 | - "b0" => array(0,0,2834.65,4008.19), |
|
96 | - "b1" => array(0,0,2004.09,2834.65), |
|
97 | - "b2" => array(0,0,1417.32,2004.09), |
|
98 | - "b3" => array(0,0,1000.63,1417.32), |
|
99 | - "b4" => array(0,0,708.66,1000.63), |
|
100 | - "b5" => array(0,0,498.90,708.66), |
|
101 | - "b6" => array(0,0,354.33,498.90), |
|
102 | - "b7" => array(0,0,249.45,354.33), |
|
103 | - "b8" => array(0,0,175.75,249.45), |
|
104 | - "b9" => array(0,0,124.72,175.75), |
|
105 | - "b10" => array(0,0,87.87,124.72), |
|
106 | - "c0" => array(0,0,2599.37,3676.54), |
|
107 | - "c1" => array(0,0,1836.85,2599.37), |
|
108 | - "c2" => array(0,0,1298.27,1836.85), |
|
109 | - "c3" => array(0,0,918.43,1298.27), |
|
110 | - "c4" => array(0,0,649.13,918.43), |
|
111 | - "c5" => array(0,0,459.21,649.13), |
|
112 | - "c6" => array(0,0,323.15,459.21), |
|
113 | - "c7" => array(0,0,229.61,323.15), |
|
114 | - "c8" => array(0,0,161.57,229.61), |
|
115 | - "c9" => array(0,0,113.39,161.57), |
|
116 | - "c10" => array(0,0,79.37,113.39), |
|
117 | - "ra0" => array(0,0,2437.80,3458.27), |
|
118 | - "ra1" => array(0,0,1729.13,2437.80), |
|
119 | - "ra2" => array(0,0,1218.90,1729.13), |
|
120 | - "ra3" => array(0,0,864.57,1218.90), |
|
121 | - "ra4" => array(0,0,609.45,864.57), |
|
122 | - "sra0" => array(0,0,2551.18,3628.35), |
|
123 | - "sra1" => array(0,0,1814.17,2551.18), |
|
124 | - "sra2" => array(0,0,1275.59,1814.17), |
|
125 | - "sra3" => array(0,0,907.09,1275.59), |
|
126 | - "sra4" => array(0,0,637.80,907.09), |
|
127 | - "letter" => array(0,0,612.00,792.00), |
|
128 | - "legal" => array(0,0,612.00,1008.00), |
|
129 | - "ledger" => array(0,0,1224.00, 792.00), |
|
130 | - "tabloid" => array(0,0,792.00, 1224.00), |
|
131 | - "executive" => array(0,0,521.86,756.00), |
|
132 | - "folio" => array(0,0,612.00,936.00), |
|
133 | - "commerical #10 envelope" => array(0,0,684,297), |
|
134 | - "catalog #10 1/2 envelope" => array(0,0,648,864), |
|
135 | - "8.5x11" => array(0,0,612.00,792.00), |
|
136 | - "8.5x14" => array(0,0,612.00,1008.0), |
|
137 | - "11x17" => array(0,0,792.00, 1224.00)); |
|
82 | + static $PAPER_SIZES = array("4a0" => array(0, 0, 4767.87, 6740.79), |
|
83 | + "2a0" => array(0, 0, 3370.39, 4767.87), |
|
84 | + "a0" => array(0, 0, 2383.94, 3370.39), |
|
85 | + "a1" => array(0, 0, 1683.78, 2383.94), |
|
86 | + "a2" => array(0, 0, 1190.55, 1683.78), |
|
87 | + "a3" => array(0, 0, 841.89, 1190.55), |
|
88 | + "a4" => array(0, 0, 595.28, 841.89), |
|
89 | + "a5" => array(0, 0, 419.53, 595.28), |
|
90 | + "a6" => array(0, 0, 297.64, 419.53), |
|
91 | + "a7" => array(0, 0, 209.76, 297.64), |
|
92 | + "a8" => array(0, 0, 147.40, 209.76), |
|
93 | + "a9" => array(0, 0, 104.88, 147.40), |
|
94 | + "a10" => array(0, 0, 73.70, 104.88), |
|
95 | + "b0" => array(0, 0, 2834.65, 4008.19), |
|
96 | + "b1" => array(0, 0, 2004.09, 2834.65), |
|
97 | + "b2" => array(0, 0, 1417.32, 2004.09), |
|
98 | + "b3" => array(0, 0, 1000.63, 1417.32), |
|
99 | + "b4" => array(0, 0, 708.66, 1000.63), |
|
100 | + "b5" => array(0, 0, 498.90, 708.66), |
|
101 | + "b6" => array(0, 0, 354.33, 498.90), |
|
102 | + "b7" => array(0, 0, 249.45, 354.33), |
|
103 | + "b8" => array(0, 0, 175.75, 249.45), |
|
104 | + "b9" => array(0, 0, 124.72, 175.75), |
|
105 | + "b10" => array(0, 0, 87.87, 124.72), |
|
106 | + "c0" => array(0, 0, 2599.37, 3676.54), |
|
107 | + "c1" => array(0, 0, 1836.85, 2599.37), |
|
108 | + "c2" => array(0, 0, 1298.27, 1836.85), |
|
109 | + "c3" => array(0, 0, 918.43, 1298.27), |
|
110 | + "c4" => array(0, 0, 649.13, 918.43), |
|
111 | + "c5" => array(0, 0, 459.21, 649.13), |
|
112 | + "c6" => array(0, 0, 323.15, 459.21), |
|
113 | + "c7" => array(0, 0, 229.61, 323.15), |
|
114 | + "c8" => array(0, 0, 161.57, 229.61), |
|
115 | + "c9" => array(0, 0, 113.39, 161.57), |
|
116 | + "c10" => array(0, 0, 79.37, 113.39), |
|
117 | + "ra0" => array(0, 0, 2437.80, 3458.27), |
|
118 | + "ra1" => array(0, 0, 1729.13, 2437.80), |
|
119 | + "ra2" => array(0, 0, 1218.90, 1729.13), |
|
120 | + "ra3" => array(0, 0, 864.57, 1218.90), |
|
121 | + "ra4" => array(0, 0, 609.45, 864.57), |
|
122 | + "sra0" => array(0, 0, 2551.18, 3628.35), |
|
123 | + "sra1" => array(0, 0, 1814.17, 2551.18), |
|
124 | + "sra2" => array(0, 0, 1275.59, 1814.17), |
|
125 | + "sra3" => array(0, 0, 907.09, 1275.59), |
|
126 | + "sra4" => array(0, 0, 637.80, 907.09), |
|
127 | + "letter" => array(0, 0, 612.00, 792.00), |
|
128 | + "legal" => array(0, 0, 612.00, 1008.00), |
|
129 | + "ledger" => array(0, 0, 1224.00, 792.00), |
|
130 | + "tabloid" => array(0, 0, 792.00, 1224.00), |
|
131 | + "executive" => array(0, 0, 521.86, 756.00), |
|
132 | + "folio" => array(0, 0, 612.00, 936.00), |
|
133 | + "commerical #10 envelope" => array(0, 0, 684, 297), |
|
134 | + "catalog #10 1/2 envelope" => array(0, 0, 648, 864), |
|
135 | + "8.5x11" => array(0, 0, 612.00, 792.00), |
|
136 | + "8.5x14" => array(0, 0, 612.00, 1008.0), |
|
137 | + "11x17" => array(0, 0, 792.00, 1224.00)); |
|
138 | 138 | |
139 | 139 | |
140 | 140 | /** |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | */ |
202 | 202 | function __construct($paper = "letter", $orientation = "portrait") { |
203 | 203 | |
204 | - if ( is_array($paper) ) |
|
204 | + if (is_array($paper)) |
|
205 | 205 | $size = $paper; |
206 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
206 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
207 | 207 | $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
208 | 208 | else |
209 | 209 | $size = self::$PAPER_SIZES["letter"]; |
210 | 210 | |
211 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
211 | + if (mb_strtolower($orientation) === "landscape") { |
|
212 | 212 | $a = $size[3]; |
213 | 213 | $size[3] = $size[2]; |
214 | 214 | $size[2] = $a; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | |
225 | 225 | |
226 | 226 | $this->_width = $size[2] - $size[0]; |
227 | - $this->_height= $size[3] - $size[1]; |
|
227 | + $this->_height = $size[3] - $size[1]; |
|
228 | 228 | $this->_pdf->openHere('Fit'); |
229 | 229 | |
230 | 230 | $this->_page_number = $this->_page_count = 1; |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | */ |
501 | 501 | protected function _convert_gif_to_png($image_url) { |
502 | 502 | |
503 | - if ( !function_exists("imagecreatefromgif") ) { |
|
503 | + if (!function_exists("imagecreatefromgif")) { |
|
504 | 504 | throw new DOMPDF_Exception("Function imagecreatefromgif() not found. Cannot convert gif image: $image_url. Please install the image PHP extension."); |
505 | 505 | } |
506 | 506 | |
507 | 507 | $old_err = set_error_handler("record_warnings"); |
508 | 508 | $im = imagecreatefromgif($image_url); |
509 | 509 | |
510 | - if ( $im ) { |
|
510 | + if ($im) { |
|
511 | 511 | imageinterlace($im, 0); |
512 | 512 | |
513 | 513 | $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png'; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | imagepng($im, $filename); |
517 | 517 | |
518 | 518 | } else { |
519 | - $filename = DOMPDF_LIB_DIR . "/res/broken_image.png"; |
|
519 | + $filename = DOMPDF_LIB_DIR."/res/broken_image.png"; |
|
520 | 520 | |
521 | 521 | } |
522 | 522 | |
@@ -559,11 +559,11 @@ discard block |
||
559 | 559 | $this->_set_line_transparency($blend, $opacity); |
560 | 560 | $this->_set_fill_transparency($blend, $opacity); |
561 | 561 | |
562 | - if ( !$fill && isset($width) ) |
|
562 | + if (!$fill && isset($width)) |
|
563 | 563 | $this->_set_line_style($width, "square", "miter", $style); |
564 | 564 | |
565 | 565 | // Adjust y values |
566 | - for ( $i = 1; $i < count($points); $i += 2) |
|
566 | + for ($i = 1; $i < count($points); $i += 2) |
|
567 | 567 | $points[$i] = $this->y($points[$i]); |
568 | 568 | |
569 | 569 | $this->_pdf->polygon($points, count($points) / 2, $fill); |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | $this->_set_line_transparency($blend, $opacity); |
581 | 581 | $this->_set_fill_transparency($blend, $opacity); |
582 | 582 | |
583 | - if ( !$fill && isset($width) ) |
|
583 | + if (!$fill && isset($width)) |
|
584 | 584 | $this->_set_line_style($width, "round", "round", $style); |
585 | 585 | |
586 | 586 | $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill); |
@@ -614,14 +614,14 @@ discard block |
||
614 | 614 | // Convert gifs to pngs |
615 | 615 | //DEBUG_IMG_TEMP |
616 | 616 | //if (0) { |
617 | - if ( method_exists( $this->_pdf, "addImagePng" ) ) { |
|
617 | + if (method_exists($this->_pdf, "addImagePng")) { |
|
618 | 618 | //debugpng |
619 | 619 | if (DEBUGPNG) print '!!!gif addImagePng!!!'; |
620 | 620 | |
621 | 621 | //If optimization to direct png creation from gd object is available, |
622 | 622 | //don't create temp file, but place gd object directly into the pdf |
623 | - if ( method_exists( $this->_pdf, "image_iscached" ) && |
|
624 | - $this->_pdf->image_iscached($img_url) ) { |
|
623 | + if (method_exists($this->_pdf, "image_iscached") && |
|
624 | + $this->_pdf->image_iscached($img_url)) { |
|
625 | 625 | //If same image has occured already before, no need to load because |
626 | 626 | //duplicate will anyway be eliminated. |
627 | 627 | $img = null; |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | |
653 | 653 | //........................................................................ |
654 | 654 | |
655 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
655 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
656 | 656 | $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
657 | 657 | |
658 | 658 | list($r, $g, $b) = $color; |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust); |
696 | 696 | //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust); |
697 | 697 | //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust); |
698 | - $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust); |
|
698 | + $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3] * $size) / 1000, $size, $text, $angle, $adjust); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | //........................................................................ |
@@ -712,7 +712,7 @@ discard block |
||
712 | 712 | * @param string $anchorname The name of the named destination |
713 | 713 | */ |
714 | 714 | function add_named_dest($anchorname) { |
715 | - $this->_pdf->addDestination($anchorname,"Fit"); |
|
715 | + $this->_pdf->addDestination($anchorname, "Fit"); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | //........................................................................ |
@@ -730,10 +730,10 @@ discard block |
||
730 | 730 | |
731 | 731 | $y = $this->y($y) - $height; |
732 | 732 | |
733 | - if ( strpos($url, '#') === 0 ) { |
|
733 | + if (strpos($url, '#') === 0) { |
|
734 | 734 | // Local link |
735 | - $name = substr($url,1); |
|
736 | - if ( $name ) |
|
735 | + $name = substr($url, 1); |
|
736 | + if ($name) |
|
737 | 737 | $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height); |
738 | 738 | |
739 | 739 | } else { |
@@ -778,7 +778,7 @@ discard block |
||
778 | 778 | * @param float $adjust word spacing adjustment |
779 | 779 | * @param float $angle angle to write the text at, measured CW starting from the x-axis |
780 | 780 | */ |
781 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
781 | + function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
782 | 782 | $adjust = 0, $angle = 0) { |
783 | 783 | $_t = "text"; |
784 | 784 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
@@ -819,7 +819,7 @@ discard block |
||
819 | 819 | */ |
820 | 820 | protected function _add_page_text() { |
821 | 821 | |
822 | - if ( !count($this->_page_text) ) |
|
822 | + if (!count($this->_page_text)) |
|
823 | 823 | return; |
824 | 824 | |
825 | 825 | $page_number = 1; |
@@ -834,7 +834,7 @@ discard block |
||
834 | 834 | switch ($_t) { |
835 | 835 | |
836 | 836 | case "text": |
837 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
837 | + $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"), |
|
838 | 838 | array($page_number, $this->_page_count), $text); |
839 | 839 | $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
840 | 840 | break; |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | // Add page text |
879 | 879 | $this->_add_page_text(); |
880 | 880 | |
881 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
881 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
882 | 882 | $debug = 1; |
883 | 883 | else |
884 | 884 | $debug = 0; |
@@ -63,10 +63,10 @@ discard block |
||
63 | 63 | |
64 | 64 | // Handle list-style-image |
65 | 65 | // If list style image is requested but missing, fall back to predefined types |
66 | - if ( $style->list_style_image !== "none" && |
|
67 | - strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR . "/res/broken_image.png") != 0) { |
|
66 | + if ($style->list_style_image !== "none" && |
|
67 | + strcmp($img = $frame->get_image_url(), DOMPDF_LIB_DIR."/res/broken_image.png") != 0) { |
|
68 | 68 | |
69 | - list($x,$y) = $frame->get_position(); |
|
69 | + list($x, $y) = $frame->get_position(); |
|
70 | 70 | |
71 | 71 | //For expected size and aspect, instead of box size, use image natural size scaled to DPI. |
72 | 72 | // Resample the bullet image to be consistent with 'auto' sized images |
@@ -75,13 +75,13 @@ discard block |
||
75 | 75 | //$w = $frame->get_width(); |
76 | 76 | //$h = $frame->get_height(); |
77 | 77 | list($width, $height) = getimagesize($img); |
78 | - $w = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
79 | - $h = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
78 | + $w = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
79 | + $h = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
80 | 80 | |
81 | 81 | $x -= $w; |
82 | - $y -= ($line_height - $font_size)/2; //Reverse hinting of list_bullet_positioner |
|
82 | + $y -= ($line_height - $font_size) / 2; //Reverse hinting of list_bullet_positioner |
|
83 | 83 | |
84 | - $this->_canvas->image( $img, $frame->get_image_ext(), $x, $y, $w, $h); |
|
84 | + $this->_canvas->image($img, $frame->get_image_ext(), $x, $y, $w, $h); |
|
85 | 85 | |
86 | 86 | } else { |
87 | 87 | |
@@ -96,19 +96,19 @@ discard block |
||
96 | 96 | $fill = true; |
97 | 97 | |
98 | 98 | case "circle": |
99 | - list($x,$y) = $frame->get_position(); |
|
100 | - $r = ($font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/ ))/2; |
|
101 | - $x -= $font_size*(List_Bullet_Frame_Decorator::BULLET_SIZE/2); |
|
102 | - $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT))/2; |
|
103 | - $o = $font_size*List_Bullet_Frame_Decorator::BULLET_THICKNESS; |
|
99 | + list($x, $y) = $frame->get_position(); |
|
100 | + $r = ($font_size * (List_Bullet_Frame_Decorator::BULLET_SIZE /*-List_Bullet_Frame_Decorator::BULLET_THICKNESS*/)) / 2; |
|
101 | + $x -= $font_size * (List_Bullet_Frame_Decorator::BULLET_SIZE / 2); |
|
102 | + $y += ($font_size * (1 - List_Bullet_Frame_Decorator::BULLET_DESCENT)) / 2; |
|
103 | + $o = $font_size * List_Bullet_Frame_Decorator::BULLET_THICKNESS; |
|
104 | 104 | $this->_canvas->circle($x, $y, $r, $style->color, $o, null, $fill); |
105 | 105 | break; |
106 | 106 | |
107 | 107 | case "square": |
108 | 108 | list($x, $y) = $frame->get_position(); |
109 | - $w = $font_size*List_Bullet_Frame_Decorator::BULLET_SIZE; |
|
109 | + $w = $font_size * List_Bullet_Frame_Decorator::BULLET_SIZE; |
|
110 | 110 | $x -= $w; |
111 | - $y += ($font_size*(1-List_Bullet_Frame_Decorator::BULLET_DESCENT-List_Bullet_Frame_Decorator::BULLET_SIZE))/2; |
|
111 | + $y += ($font_size * (1 - List_Bullet_Frame_Decorator::BULLET_DESCENT - List_Bullet_Frame_Decorator::BULLET_SIZE)) / 2; |
|
112 | 112 | $this->_canvas->filled_rectangle($x, $y, $w, $w, $style->color); |
113 | 113 | break; |
114 | 114 |
@@ -185,25 +185,25 @@ discard block |
||
185 | 185 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
186 | 186 | */ |
187 | 187 | function __construct($paper = "letter", $orientation = "portrait") { |
188 | - if ( is_array($paper) ) |
|
188 | + if (is_array($paper)) |
|
189 | 189 | $size = $paper; |
190 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
190 | + else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)])) |
|
191 | 191 | $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
192 | 192 | else |
193 | 193 | $size = self::$PAPER_SIZES["letter"]; |
194 | 194 | |
195 | - if ( mb_strtolower($orientation) === "landscape" ) { |
|
195 | + if (mb_strtolower($orientation) === "landscape") { |
|
196 | 196 | $a = $size[3]; |
197 | 197 | $size[3] = $size[2]; |
198 | 198 | $size[2] = $a; |
199 | 199 | } |
200 | 200 | $this->_width = $size[2] - $size[0]; |
201 | - $this->_height= $size[3] - $size[1]; |
|
201 | + $this->_height = $size[3] - $size[1]; |
|
202 | 202 | |
203 | 203 | $this->_pdf = new PDFLib(); |
204 | 204 | |
205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
205 | + if (defined("DOMPDF_PDFLIB_LICENSE")) |
|
206 | + $this->_pdf->set_parameter("license", DOMPDF_PDFLIB_LICENSE); |
|
207 | 207 | |
208 | 208 | $this->_pdf->set_parameter("textformat", "utf8"); |
209 | 209 | $this->_pdf->set_parameter("fontwarning", "false"); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $this->_pdf->set_info("Creator", "DOMPDF Converter"); |
212 | 212 | |
213 | 213 | // Silence pedantic warnings about missing TZ settings |
214 | - if ( function_exists("date_default_timezone_get") ) { |
|
214 | + if (function_exists("date_default_timezone_get")) { |
|
215 | 215 | $tz = @date_default_timezone_get(); |
216 | 216 | date_default_timezone_set("UTC"); |
217 | 217 | $this->_pdf->set_info("Date", date("Y-m-d")); |
@@ -220,11 +220,11 @@ discard block |
||
220 | 220 | $this->_pdf->set_info("Date", date("Y-m-d")); |
221 | 221 | } |
222 | 222 | |
223 | - if ( self::$IN_MEMORY ) |
|
224 | - $this->_pdf->begin_document("",""); |
|
223 | + if (self::$IN_MEMORY) |
|
224 | + $this->_pdf->begin_document("", ""); |
|
225 | 225 | else { |
226 | 226 | $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
227 | - $this->_pdf->begin_document($this->_file,""); |
|
227 | + $this->_pdf->begin_document($this->_file, ""); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
@@ -243,29 +243,29 @@ discard block |
||
243 | 243 | $face = basename($file); |
244 | 244 | |
245 | 245 | // Prefer ttfs to afms |
246 | - if ( file_exists($file.".ttf") ) { |
|
246 | + if (file_exists($file.".ttf")) { |
|
247 | 247 | $outline = "$file.ttf"; |
248 | 248 | $afm = null; |
249 | 249 | |
250 | - } else if ( file_exists($file .".TTF") ) { |
|
250 | + } else if (file_exists($file.".TTF")) { |
|
251 | 251 | $outline = "$file.TTF"; |
252 | 252 | $afm = null; |
253 | 253 | |
254 | - } else if ( file_exists($file . ".pfb") ) { |
|
254 | + } else if (file_exists($file.".pfb")) { |
|
255 | 255 | $outline = "$file.pfb"; |
256 | 256 | |
257 | - if ( file_exists($file . ".afm") ) |
|
257 | + if (file_exists($file.".afm")) |
|
258 | 258 | $afm = "$file.afm"; |
259 | 259 | |
260 | - } else if ( file_exists($file . ".PFB") ) { |
|
260 | + } else if (file_exists($file.".PFB")) { |
|
261 | 261 | $outline = "$file.PFB"; |
262 | - if ( file_exists($file . ".AFM") ) |
|
262 | + if (file_exists($file.".AFM")) |
|
263 | 263 | $afm = "$file.AFM"; |
264 | 264 | } else |
265 | 265 | continue; |
266 | 266 | |
267 | 267 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
268 | - if ( !is_null($afm) ) |
|
268 | + if (!is_null($afm)) |
|
269 | 269 | $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
270 | 270 | } |
271 | 271 | } |
@@ -366,10 +366,10 @@ discard block |
||
366 | 366 | */ |
367 | 367 | function add_object($object, $where = 'all') { |
368 | 368 | |
369 | - if ( mb_strpos($where, "next") !== false ) { |
|
369 | + if (mb_strpos($where, "next") !== false) { |
|
370 | 370 | $this->_objs[$object]["start_page"]++; |
371 | 371 | $where = str_replace("next", "", $where); |
372 | - if ( $where == "" ) |
|
372 | + if ($where == "") |
|
373 | 373 | $where = "add"; |
374 | 374 | } |
375 | 375 | |
@@ -386,18 +386,18 @@ discard block |
||
386 | 386 | */ |
387 | 387 | function stop_object($object) { |
388 | 388 | |
389 | - if ( !isset($this->_objs[$object]) ) |
|
389 | + if (!isset($this->_objs[$object])) |
|
390 | 390 | return; |
391 | 391 | |
392 | 392 | $start = $this->_objs[$object]["start_page"]; |
393 | 393 | $where = $this->_objs[$object]["where"]; |
394 | 394 | |
395 | 395 | // Place the object on this page if required |
396 | - if ( $this->_page_number >= $start && |
|
396 | + if ($this->_page_number >= $start && |
|
397 | 397 | (($this->_page_number % 2 == 0 && $where === "even") || |
398 | 398 | ($this->_page_number % 2 == 1 && $where === "odd") || |
399 | - ($where === "all")) ) |
|
400 | - $this->_pdf->fit_image($object,0,0,""); |
|
399 | + ($where === "all"))) |
|
400 | + $this->_pdf->fit_image($object, 0, 0, ""); |
|
401 | 401 | |
402 | 402 | unset($this->_objs[$object]); |
403 | 403 | } |
@@ -407,16 +407,16 @@ discard block |
||
407 | 407 | */ |
408 | 408 | protected function _place_objects() { |
409 | 409 | |
410 | - foreach ( $this->_objs as $obj => $props ) { |
|
410 | + foreach ($this->_objs as $obj => $props) { |
|
411 | 411 | $start = $props["start_page"]; |
412 | 412 | $where = $props["where"]; |
413 | 413 | |
414 | 414 | // Place the object on this page if required |
415 | - if ( $this->_page_number >= $start && |
|
415 | + if ($this->_page_number >= $start && |
|
416 | 416 | (($this->_page_number % 2 == 0 && $where === "even") || |
417 | 417 | ($this->_page_number % 2 == 1 && $where === "odd") || |
418 | - ($where === "all")) ) { |
|
419 | - $this->_pdf->fit_image($obj,0,0,""); |
|
418 | + ($where === "all"))) { |
|
419 | + $this->_pdf->fit_image($obj, 0, 0, ""); |
|
420 | 420 | } |
421 | 421 | } |
422 | 422 | |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | |
431 | 431 | function get_page_count() { return $this->_page_count; } |
432 | 432 | |
433 | - function set_page_number($num) { $this->_page_number = (int)$num; } |
|
433 | + function set_page_number($num) { $this->_page_number = (int) $num; } |
|
434 | 434 | |
435 | - function set_page_count($count) { $this->_page_count = (int)$count; } |
|
435 | + function set_page_count($count) { $this->_page_count = (int) $count; } |
|
436 | 436 | |
437 | 437 | |
438 | 438 | /** |
@@ -445,15 +445,15 @@ discard block |
||
445 | 445 | */ |
446 | 446 | protected function _set_line_style($width, $cap, $join, $dash) { |
447 | 447 | |
448 | - if ( count($dash) == 1 ) |
|
448 | + if (count($dash) == 1) |
|
449 | 449 | $dash[] = $dash[0]; |
450 | 450 | |
451 | - if ( count($dash) > 1 ) |
|
452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
451 | + if (count($dash) > 1) |
|
452 | + $this->_pdf->setdashpattern("dasharray={".join(" ", $dash)."}"); |
|
453 | 453 | else |
454 | - $this->_pdf->setdash(0,0); |
|
454 | + $this->_pdf->setdash(0, 0); |
|
455 | 455 | |
456 | - switch ( $join ) { |
|
456 | + switch ($join) { |
|
457 | 457 | case "miter": |
458 | 458 | $this->_pdf->setlinejoin(0); |
459 | 459 | break; |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | break; |
471 | 471 | } |
472 | 472 | |
473 | - switch ( $cap ) { |
|
473 | + switch ($cap) { |
|
474 | 474 | case "butt": |
475 | 475 | $this->_pdf->setlinecap(0); |
476 | 476 | break; |
@@ -497,12 +497,12 @@ discard block |
||
497 | 497 | * @param array $color array(r,g,b) |
498 | 498 | */ |
499 | 499 | protected function _set_stroke_color($color) { |
500 | - if($this->_last_stroke_color == $color) |
|
500 | + if ($this->_last_stroke_color == $color) |
|
501 | 501 | return; |
502 | 502 | |
503 | 503 | $this->_last_stroke_color = $color; |
504 | 504 | |
505 | - list($r,$g,$b) = $color; |
|
505 | + list($r, $g, $b) = $color; |
|
506 | 506 | $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0); |
507 | 507 | } |
508 | 508 | |
@@ -512,12 +512,12 @@ discard block |
||
512 | 512 | * @param array $color array(r,g,b) |
513 | 513 | */ |
514 | 514 | protected function _set_fill_color($color) { |
515 | - if($this->_last_fill_color == $color) |
|
515 | + if ($this->_last_fill_color == $color) |
|
516 | 516 | return; |
517 | 517 | |
518 | 518 | $this->_last_fill_color = $color; |
519 | 519 | |
520 | - list($r,$g,$b) = $color; |
|
520 | + list($r, $g, $b) = $color; |
|
521 | 521 | $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0); |
522 | 522 | } |
523 | 523 | |
@@ -537,7 +537,7 @@ discard block |
||
537 | 537 | "symbol", "zapfdinbats"); |
538 | 538 | |
539 | 539 | $test = strtolower(basename($font)); |
540 | - if ( in_array($test, $native_fonts) ) { |
|
540 | + if (in_array($test, $native_fonts)) { |
|
541 | 541 | $font = basename($font); |
542 | 542 | |
543 | 543 | } else { |
@@ -545,20 +545,20 @@ discard block |
||
545 | 545 | $options .= " embedding=true"; |
546 | 546 | } |
547 | 547 | |
548 | - if ( is_null($encoding) ) { |
|
548 | + if (is_null($encoding)) { |
|
549 | 549 | |
550 | 550 | // Unicode encoding is only available for the commerical |
551 | 551 | // version of PDFlib and not PDFlib-Lite |
552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
552 | + if (defined("DOMPDF_PDFLIB_LICENSE")) |
|
553 | 553 | $encoding = "unicode"; |
554 | 554 | else |
555 | 555 | $encoding = "auto"; |
556 | 556 | |
557 | 557 | } |
558 | 558 | |
559 | - $key = $font .":". $encoding .":". $options; |
|
559 | + $key = $font.":".$encoding.":".$options; |
|
560 | 560 | |
561 | - if ( isset($this->_fonts[$key]) ) |
|
561 | + if (isset($this->_fonts[$key])) |
|
562 | 562 | return $this->_fonts[$key]; |
563 | 563 | |
564 | 564 | else { |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | $y1 = $this->y($y1); |
588 | 588 | $y2 = $this->y($y2); |
589 | 589 | |
590 | - $this->_pdf->moveto($x1,$y1); |
|
590 | + $this->_pdf->moveto($x1, $y1); |
|
591 | 591 | $this->_pdf->lineto($x2, $y2); |
592 | 592 | $this->_pdf->stroke(); |
593 | 593 | } |
@@ -622,20 +622,20 @@ discard block |
||
622 | 622 | $this->_set_fill_color($color); |
623 | 623 | $this->_set_stroke_color($color); |
624 | 624 | |
625 | - if ( !$fill && isset($width) ) |
|
625 | + if (!$fill && isset($width)) |
|
626 | 626 | $this->_set_line_style($width, "square", "miter", $style); |
627 | 627 | |
628 | 628 | $y = $this->y(array_pop($points)); |
629 | 629 | $x = array_pop($points); |
630 | - $this->_pdf->moveto($x,$y); |
|
630 | + $this->_pdf->moveto($x, $y); |
|
631 | 631 | |
632 | 632 | while (count($points) > 1) { |
633 | 633 | $y = $this->y(array_pop($points)); |
634 | 634 | $x = array_pop($points); |
635 | - $this->_pdf->lineto($x,$y); |
|
635 | + $this->_pdf->lineto($x, $y); |
|
636 | 636 | } |
637 | 637 | |
638 | - if ( $fill ) |
|
638 | + if ($fill) |
|
639 | 639 | $this->_pdf->fill(); |
640 | 640 | else |
641 | 641 | $this->_pdf->closepath_stroke(); |
@@ -648,14 +648,14 @@ discard block |
||
648 | 648 | $this->_set_fill_color($color); |
649 | 649 | $this->_set_stroke_color($color); |
650 | 650 | |
651 | - if ( !$fill && isset($width) ) |
|
651 | + if (!$fill && isset($width)) |
|
652 | 652 | $this->_set_line_style($width, "round", "round", $style); |
653 | 653 | |
654 | 654 | $y = $this->y($y); |
655 | 655 | |
656 | 656 | $this->_pdf->circle($x, $y, $r); |
657 | 657 | |
658 | - if ( $fill ) |
|
658 | + if ($fill) |
|
659 | 659 | $this->_pdf->fill(); |
660 | 660 | else |
661 | 661 | $this->_pdf->stroke(); |
@@ -665,15 +665,15 @@ discard block |
||
665 | 665 | //........................................................................ |
666 | 666 | |
667 | 667 | function image($img_url, $img_type, $x, $y, $w, $h) { |
668 | - $w = (int)$w; |
|
669 | - $h = (int)$h; |
|
668 | + $w = (int) $w; |
|
669 | + $h = (int) $h; |
|
670 | 670 | |
671 | 671 | $img_type = strtolower($img_type); |
672 | 672 | |
673 | - if ( $img_type === "jpg" ) |
|
673 | + if ($img_type === "jpg") |
|
674 | 674 | $img_type = "jpeg"; |
675 | 675 | |
676 | - if ( isset($this->_imgs[$img_url]) ) |
|
676 | + if (isset($this->_imgs[$img_url])) |
|
677 | 677 | $img = $this->_imgs[$img_url]; |
678 | 678 | |
679 | 679 | else { |
@@ -682,13 +682,13 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | $y = $this->y($y) - $h; |
685 | - $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire'); |
|
685 | + $this->_pdf->fit_image($img, $x, $y, 'boxsize={'."$w $h".'} fitmethod=entire'); |
|
686 | 686 | |
687 | 687 | } |
688 | 688 | |
689 | 689 | //........................................................................ |
690 | 690 | |
691 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
691 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
692 | 692 | $fh = $this->_load_font($font); |
693 | 693 | |
694 | 694 | $this->_pdf->setfont($fh, $size); |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | |
697 | 697 | $y = $this->y($y) - Font_Metrics::get_font_height($font, $size); |
698 | 698 | |
699 | - $adjust = (float)$adjust; |
|
700 | - $angle = -(float)$angle; |
|
699 | + $adjust = (float) $adjust; |
|
700 | + $angle = -(float) $angle; |
|
701 | 701 | |
702 | 702 | $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust"); |
703 | 703 | |
@@ -717,7 +717,7 @@ discard block |
||
717 | 717 | * @param string $anchorname The name of the named destination |
718 | 718 | */ |
719 | 719 | function add_named_dest($anchorname) { |
720 | - $this->_pdf->add_nameddest($anchorname,""); |
|
720 | + $this->_pdf->add_nameddest($anchorname, ""); |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | //........................................................................ |
@@ -734,21 +734,21 @@ discard block |
||
734 | 734 | function add_link($url, $x, $y, $width, $height) { |
735 | 735 | |
736 | 736 | $y = $this->y($y) - $height; |
737 | - if ( strpos($url, '#') === 0 ) { |
|
737 | + if (strpos($url, '#') === 0) { |
|
738 | 738 | // Local link |
739 | - $name = substr($url,1); |
|
740 | - if ( $name ) |
|
741 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
739 | + $name = substr($url, 1); |
|
740 | + if ($name) |
|
741 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=".substr($url, 1)." linewidth=0"); |
|
742 | 742 | } else { |
743 | 743 | |
744 | 744 | list($proto, $host, $path, $file) = explode_url($url); |
745 | 745 | |
746 | - if ( $proto == "" || $proto === "file://" ) |
|
746 | + if ($proto == "" || $proto === "file://") |
|
747 | 747 | return; // Local links are not allowed |
748 | 748 | $url = build_url($proto, $host, $path, $file); |
749 | - $url = '{' . rawurldecode($url) . '}'; |
|
749 | + $url = '{'.rawurldecode($url).'}'; |
|
750 | 750 | |
751 | - $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
751 | + $action = $this->_pdf->create_action("URI", "url=".$url); |
|
752 | 752 | $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
753 | 753 | } |
754 | 754 | } |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | $fh = $this->_load_font($font); |
760 | 760 | |
761 | 761 | // Determine the additional width due to extra spacing |
762 | - $num_spaces = mb_substr_count($text," "); |
|
762 | + $num_spaces = mb_substr_count($text, " "); |
|
763 | 763 | $delta = $spacing * $num_spaces; |
764 | 764 | return $this->_pdf->stringwidth($text, $fh, $size) + $delta; |
765 | 765 | } |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | * @param float $adjust word spacing adjustment |
799 | 799 | * @param float $angle angle to write the text at, measured CW starting from the x-axis |
800 | 800 | */ |
801 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
802 | - $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
801 | + function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0), |
|
802 | + $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
803 | 803 | $_t = "text"; |
804 | 804 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
805 | 805 | } |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | protected function _add_page_text() { |
844 | 844 | |
845 | - if ( !count($this->_page_text) ) |
|
845 | + if (!count($this->_page_text)) |
|
846 | 846 | return; |
847 | 847 | |
848 | 848 | $this->_pdf->suspend_page(""); |
@@ -856,7 +856,7 @@ discard block |
||
856 | 856 | switch ($_t) { |
857 | 857 | |
858 | 858 | case "text": |
859 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
859 | + $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"), |
|
860 | 860 | array($p, $this->_page_count), $text); |
861 | 861 | $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
862 | 862 | break; |
@@ -883,14 +883,14 @@ discard block |
||
883 | 883 | // Add page text |
884 | 884 | $this->_add_page_text(); |
885 | 885 | |
886 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
886 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
887 | 887 | $this->_pdf->set_value("compress", 0); |
888 | 888 | else |
889 | 889 | $this->_pdf->set_value("compress", 6); |
890 | 890 | |
891 | 891 | $this->_close(); |
892 | 892 | |
893 | - if ( self::$IN_MEMORY ) { |
|
893 | + if (self::$IN_MEMORY) { |
|
894 | 894 | $data = $this->_pdf->get_buffer(); |
895 | 895 | $size = strlen($data); |
896 | 896 | |
@@ -898,7 +898,7 @@ discard block |
||
898 | 898 | $size = filesize($this->_file); |
899 | 899 | |
900 | 900 | |
901 | - $filename = str_replace(array("\n","'"),"", $filename); |
|
901 | + $filename = str_replace(array("\n", "'"), "", $filename); |
|
902 | 902 | $attach = (isset($options["Attachment"]) && $options["Attachment"]) ? "attachment" : "inline"; |
903 | 903 | |
904 | 904 | header("Cache-Control: private"); |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | |
908 | 908 | //header("Content-length: " . $size); |
909 | 909 | |
910 | - if ( self::$IN_MEMORY ) |
|
910 | + if (self::$IN_MEMORY) |
|
911 | 911 | echo $data; |
912 | 912 | |
913 | 913 | else { |
@@ -915,11 +915,11 @@ discard block |
||
915 | 915 | // Chunked readfile() |
916 | 916 | $chunk = (1 << 21); // 2 MB |
917 | 917 | $fh = fopen($this->_file, "rb"); |
918 | - if ( !$fh ) |
|
919 | - throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
918 | + if (!$fh) |
|
919 | + throw new DOMPDF_Exception("Unable to load temporary PDF file: ".$this->_file); |
|
920 | 920 | |
921 | - while ( !feof($fh) ) |
|
922 | - echo fread($fh,$chunk); |
|
921 | + while (!feof($fh)) |
|
922 | + echo fread($fh, $chunk); |
|
923 | 923 | fclose($fh); |
924 | 924 | |
925 | 925 | //debugpng |
@@ -942,14 +942,14 @@ discard block |
||
942 | 942 | // Add page text |
943 | 943 | $this->_add_page_text(); |
944 | 944 | |
945 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
945 | + if (isset($options["compress"]) && $options["compress"] != 1) |
|
946 | 946 | $this->_pdf->set_value("compress", 0); |
947 | 947 | else |
948 | 948 | $this->_pdf->set_value("compress", 6); |
949 | 949 | |
950 | 950 | $this->_close(); |
951 | 951 | |
952 | - if ( self::$IN_MEMORY ) |
|
952 | + if (self::$IN_MEMORY) |
|
953 | 953 | $data = $this->_pdf->get_buffer(); |
954 | 954 | |
955 | 955 | else { |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | $cells = $cellmap->get_spanned_cells($this->_frame); |
70 | 70 | |
71 | 71 | $w = 0; |
72 | - foreach ( $cells["columns"] as $i ) { |
|
73 | - $col = $cellmap->get_column( $i ); |
|
72 | + foreach ($cells["columns"] as $i) { |
|
73 | + $col = $cellmap->get_column($i); |
|
74 | 74 | $w += $col["used-width"]; |
75 | 75 | } |
76 | 76 | |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | $this->_frame->set_current_line($line_y); |
111 | 111 | |
112 | 112 | // Set the containing blocks and reflow each child |
113 | - foreach ( $this->_frame->get_children() as $child ) { |
|
113 | + foreach ($this->_frame->get_children() as $child) { |
|
114 | 114 | |
115 | - if ( $page->is_full() ) |
|
115 | + if ($page->is_full()) |
|
116 | 116 | break; |
117 | 117 | |
118 | 118 | $child->set_containing_block($content_x, $content_y, $cb_w, $h); |
119 | 119 | $child->reflow(); |
120 | 120 | |
121 | - $this->_frame->add_frame_to_line( $child ); |
|
121 | + $this->_frame->add_frame_to_line($child); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | * @param bool $return |
62 | 62 | * |
63 | 63 | */ |
64 | -if ( !function_exists("pre_r") ) { |
|
64 | +if (!function_exists("pre_r")) { |
|
65 | 65 | function pre_r($mixed, $return = false) { |
66 | 66 | if ($return) |
67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
67 | + return "<pre>".print_r($mixed, true)."</pre>"; |
|
68 | 68 | |
69 | - if ( php_sapi_name() !== "cli") |
|
69 | + if (php_sapi_name() !== "cli") |
|
70 | 70 | echo ("<pre>"); |
71 | 71 | print_r($mixed); |
72 | 72 | |
73 | - if ( php_sapi_name() !== "cli") |
|
73 | + if (php_sapi_name() !== "cli") |
|
74 | 74 | echo("</pre>"); |
75 | 75 | else |
76 | 76 | echo ("\n"); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @param mixed $mixed variable or expression to display. |
89 | 89 | */ |
90 | -if ( !function_exists("pre_var_dump") ) { |
|
90 | +if (!function_exists("pre_var_dump")) { |
|
91 | 91 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
92 | + if (php_sapi_name() !== "cli") |
|
93 | 93 | echo("<pre>"); |
94 | 94 | var_dump($mixed); |
95 | - if ( php_sapi_name() !== "cli") |
|
95 | + if (php_sapi_name() !== "cli") |
|
96 | 96 | echo("</pre>"); |
97 | 97 | } |
98 | 98 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * is appended (o.k. also for Windows) |
116 | 116 | */ |
117 | 117 | function build_url($protocol, $host, $base_path, $url) { |
118 | - if ( mb_strlen($url) == 0 ) { |
|
118 | + if (mb_strlen($url) == 0) { |
|
119 | 119 | //return $protocol . $host . rtrim($base_path, "/\\") . "/"; |
120 | - return $protocol . $host . $base_path; |
|
120 | + return $protocol.$host.$base_path; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Is the url already fully qualified? |
124 | - if ( mb_strpos($url, "://") !== false ) |
|
124 | + if (mb_strpos($url, "://") !== false) |
|
125 | 125 | return $url; |
126 | 126 | |
127 | 127 | $ret = $protocol; |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | //remote urls with backslash in html/css are not really correct, but lets be genereous |
143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
143 | + if ($url[0] === '/' || $url[0] === '\\') { |
|
144 | 144 | // Absolute path |
145 | - $ret .= $host . $url; |
|
145 | + $ret .= $host.$url; |
|
146 | 146 | } else { |
147 | 147 | // Relative path |
148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
149 | - $ret .= $host . $base_path . $url; |
|
149 | + $ret .= $host.$base_path.$url; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $ret; |
@@ -168,48 +168,48 @@ discard block |
||
168 | 168 | |
169 | 169 | $arr = parse_url($url); |
170 | 170 | |
171 | - if ( isset($arr["scheme"]) && |
|
171 | + if (isset($arr["scheme"]) && |
|
172 | 172 | $arr["scheme"] !== "file" && |
173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
173 | + mb_strlen($arr["scheme"]) > 1) // Exclude windows drive letters... |
|
174 | 174 | { |
175 | - $protocol = $arr["scheme"] . "://"; |
|
175 | + $protocol = $arr["scheme"]."://"; |
|
176 | 176 | |
177 | - if ( isset($arr["user"]) ) { |
|
177 | + if (isset($arr["user"])) { |
|
178 | 178 | $host .= $arr["user"]; |
179 | 179 | |
180 | - if ( isset($arr["pass"]) ) |
|
181 | - $host .= "@" . $arr["pass"]; |
|
180 | + if (isset($arr["pass"])) |
|
181 | + $host .= "@".$arr["pass"]; |
|
182 | 182 | |
183 | 183 | $host .= ":"; |
184 | 184 | } |
185 | 185 | |
186 | - if ( isset($arr["host"]) ) |
|
186 | + if (isset($arr["host"])) |
|
187 | 187 | $host .= $arr["host"]; |
188 | 188 | |
189 | - if ( isset($arr["port"]) ) |
|
190 | - $host .= ":" . $arr["port"]; |
|
189 | + if (isset($arr["port"])) |
|
190 | + $host .= ":".$arr["port"]; |
|
191 | 191 | |
192 | - if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
|
192 | + if (isset($arr["path"]) && $arr["path"] !== "") { |
|
193 | 193 | // Do we have a trailing slash? |
194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
194 | + if ($arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/") { |
|
195 | 195 | $path = $arr["path"]; |
196 | 196 | $file = ""; |
197 | 197 | } else { |
198 | - $path = dirname($arr["path"]) . "/"; |
|
198 | + $path = dirname($arr["path"])."/"; |
|
199 | 199 | $file = basename($arr["path"]); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - if ( isset($arr["query"]) ) |
|
204 | - $file .= "?" . $arr["query"]; |
|
203 | + if (isset($arr["query"])) |
|
204 | + $file .= "?".$arr["query"]; |
|
205 | 205 | |
206 | - if ( isset($arr["fragment"]) ) |
|
207 | - $file .= "#" . $arr["fragment"]; |
|
206 | + if (isset($arr["fragment"])) |
|
207 | + $file .= "#".$arr["fragment"]; |
|
208 | 208 | |
209 | 209 | } else { |
210 | 210 | |
211 | 211 | $i = mb_strpos($url, "file://"); |
212 | - if ( $i !== false) |
|
212 | + if ($i !== false) |
|
213 | 213 | $url = mb_substr($url, $i + 7); |
214 | 214 | |
215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $path = dirname($url); |
222 | 222 | |
223 | 223 | // Check that the path exists |
224 | - if ( $path !== false ) { |
|
224 | + if ($path !== false) { |
|
225 | 225 | $path .= '/'; |
226 | 226 | |
227 | 227 | } else { |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | |
231 | 231 | $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
232 | 232 | |
233 | - if ( substr($arr["path"], 0, 1) === '/' ) { |
|
233 | + if (substr($arr["path"], 0, 1) === '/') { |
|
234 | 234 | $path = dirname($arr["path"]); |
235 | 235 | } else { |
236 | - $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
|
236 | + $path = '/'.rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/').'/'.$arr["path"]; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | "dc", "dcc", "dccc", "cm"); |
263 | 263 | static $thou = array("", "m", "mm", "mmm"); |
264 | 264 | |
265 | - if ( !is_numeric($num) ) |
|
265 | + if (!is_numeric($num)) |
|
266 | 266 | throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
267 | 267 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
268 | + if ($num > 4000 || $num < 0) |
|
269 | 269 | return "(out of range)"; |
270 | 270 | |
271 | - $num = strrev((string)$num); |
|
271 | + $num = strrev((string) $num); |
|
272 | 272 | |
273 | 273 | $ret = ""; |
274 | 274 | switch (mb_strlen($num)) { |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * mb_string compatibility |
305 | 305 | */ |
306 | 306 | |
307 | -if ( !function_exists("mb_convert_encoding") ) { |
|
308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
307 | +if (!function_exists("mb_convert_encoding")) { |
|
308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding = 'UTF-8') { |
|
309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | 310 | return utf8_encode($data); |
311 | 311 | } else { |
@@ -314,20 +314,20 @@ discard block |
||
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | -if ( !function_exists("mb_detect_encoding") ) { |
|
318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
317 | +if (!function_exists("mb_detect_encoding")) { |
|
318 | + function mb_detect_encoding($data, $encoding_list = array('iso-8859-1'), $strict = false) { |
|
319 | 319 | return 'iso-8859-1'; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | -if ( !function_exists("mb_detect_order") ) { |
|
324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
323 | +if (!function_exists("mb_detect_order")) { |
|
324 | + function mb_detect_order($encoding_list = array('iso-8859-1')) { |
|
325 | 325 | return 'iso-8859-1'; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | -if ( !function_exists("mb_internal_encoding") ) { |
|
330 | - function mb_internal_encoding($encoding=NULL) { |
|
329 | +if (!function_exists("mb_internal_encoding")) { |
|
330 | + function mb_internal_encoding($encoding = NULL) { |
|
331 | 331 | if (isset($encoding)) { |
332 | 332 | return true; |
333 | 333 | } else { |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | -if ( !function_exists("mb_strlen") ) { |
|
340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
339 | +if (!function_exists("mb_strlen")) { |
|
340 | + function mb_strlen($str, $encoding = 'iso-8859-1') { |
|
341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
342 | 342 | return strlen(utf8_encode($data)); |
343 | 343 | } else { |
@@ -346,40 +346,40 @@ discard block |
||
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | -if ( !function_exists("mb_strpos") ) { |
|
349 | +if (!function_exists("mb_strpos")) { |
|
350 | 350 | function mb_strpos($haystack, $needle, $offset = 0) { |
351 | 351 | return strpos($haystack, $needle, $offset); |
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | -if ( !function_exists("mb_strrpos") ) { |
|
355 | +if (!function_exists("mb_strrpos")) { |
|
356 | 356 | function mb_strrpos($haystack, $needle, $offset = 0) { |
357 | 357 | return strrpos($haystack, $needle, $offset); |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -if ( !function_exists("mb_strtolower") ) { |
|
361 | +if (!function_exists("mb_strtolower")) { |
|
362 | 362 | function mb_strtolower($str) { |
363 | 363 | return strtolower($str); |
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | -if ( !function_exists("mb_strtoupper") ) { |
|
367 | +if (!function_exists("mb_strtoupper")) { |
|
368 | 368 | function mb_strtoupper($str) { |
369 | 369 | return strtoupper($str); |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | -if ( !function_exists("mb_substr") ) { |
|
374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
375 | - if ( is_null($length) ) |
|
373 | +if (!function_exists("mb_substr")) { |
|
374 | + function mb_substr($str, $start, $length = null, $encoding = 'iso-8859-1') { |
|
375 | + if (is_null($length)) |
|
376 | 376 | return substr($str, $start); |
377 | 377 | else |
378 | 378 | return substr($str, $start, $length); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( !function_exists("mb_substr_count") ) { |
|
382 | +if (!function_exists("mb_substr_count")) { |
|
383 | 383 | function mb_substr_count($haystack, $needle) { |
384 | 384 | return substr_count($haystack, $needle); |
385 | 385 | } |
@@ -402,14 +402,14 @@ discard block |
||
402 | 402 | */ |
403 | 403 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 404 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
406 | - throw new DOMPDF_Exception($errstr . " $errno"); |
|
405 | + if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) // Not a warning or notice |
|
406 | + throw new DOMPDF_Exception($errstr." $errno"); |
|
407 | 407 | |
408 | 408 | global $_dompdf_warnings; |
409 | 409 | global $_dompdf_show_warnings; |
410 | 410 | |
411 | - if ( $_dompdf_show_warnings ) |
|
412 | - echo $errstr . "\n"; |
|
411 | + if ($_dompdf_show_warnings) |
|
412 | + echo $errstr."\n"; |
|
413 | 413 | |
414 | 414 | $_dompdf_warnings[] = $errstr; |
415 | 415 | } |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | |
426 | 426 | $i = 0; |
427 | 427 | foreach ($bt as $call) { |
428 | - $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
|
429 | - if ( isset($call["class"]) ) { |
|
430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
428 | + $file = basename($call["file"])." (".$call["line"].")"; |
|
429 | + if (isset($call["class"])) { |
|
430 | + $func = $call["class"]."->".$call["function"]."()"; |
|
431 | 431 | } else { |
432 | - $func = $call["function"] . "()"; |
|
432 | + $func = $call["function"]."()"; |
|
433 | 433 | } |
434 | 434 | |
435 | - echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
|
435 | + echo "#".str_pad($i, 2, " ", STR_PAD_RIGHT).": ".str_pad($file.":", 42)." $func\n"; |
|
436 | 436 | $i++; |
437 | 437 | } |
438 | 438 | echo "\n"; |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | global $_DOMPDF_DEBUG_TYPES; |
448 | 448 | global $_dompdf_show_warnings; |
449 | 449 | global $_dompdf_debug; |
450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
450 | + if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) { |
|
451 | 451 | $arr = debug_backtrace(); |
452 | 452 | |
453 | - echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
|
453 | + echo basename($arr[0]["file"])." (".$arr[0]["line"]."): ".$arr[1]["function"].": "; |
|
454 | 454 | pre_r($msg); |
455 | 455 | } |
456 | 456 | } |
@@ -458,29 +458,29 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Dump memory usage |
460 | 460 | */ |
461 | -if ( !function_exists("print_memusage") ) { |
|
461 | +if (!function_exists("print_memusage")) { |
|
462 | 462 | function print_memusage() { |
463 | 463 | global $memusage; |
464 | 464 | echo ("Memory Usage\n"); |
465 | 465 | $prev = 0; |
466 | 466 | $initial = reset($memusage); |
467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
467 | + echo (str_pad("Initial:", 40).$initial."\n\n"); |
|
468 | 468 | |
469 | 469 | foreach ($memusage as $key=>$mem) { |
470 | 470 | $mem -= $initial; |
471 | - echo (str_pad("$key:" , 40)); |
|
472 | - echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n"); |
|
471 | + echo (str_pad("$key:", 40)); |
|
472 | + echo (str_pad("$mem", 12)."(diff: ".($mem - $prev).")\n"); |
|
473 | 473 | $prev = $mem; |
474 | 474 | } |
475 | 475 | |
476 | - echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
476 | + echo ("\n".str_pad("Total:", 40).memory_get_usage())."\n"; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Initialize memory profiling code |
482 | 482 | */ |
483 | -if ( !function_exists("enable_mem_profile") ) { |
|
483 | +if (!function_exists("enable_mem_profile")) { |
|
484 | 484 | function enable_mem_profile() { |
485 | 485 | global $memusage; |
486 | 486 | $memusage = array("Startup" => memory_get_usage()); |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param string $location a meaningful location |
495 | 495 | */ |
496 | -if ( !function_exists("mark_memusage") ) { |
|
496 | +if (!function_exists("mark_memusage")) { |
|
497 | 497 | function mark_memusage($location) { |
498 | 498 | global $memusage; |
499 | - if ( isset($memusage) ) |
|
499 | + if (isset($memusage)) |
|
500 | 500 | $memusage[$location] = memory_get_usage(); |
501 | 501 | } |
502 | 502 | } |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
508 | 508 | */ |
509 | -if ( !function_exists('sys_get_temp_dir')) { |
|
509 | +if (!function_exists('sys_get_temp_dir')) { |
|
510 | 510 | function sys_get_temp_dir() { |
511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
512 | - if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
|
513 | - if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
|
514 | - $tempfile=tempnam(uniqid(rand(),TRUE),''); |
|
512 | + if (!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); } |
|
513 | + if (!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); } |
|
514 | + $tempfile = tempnam(uniqid(rand(), TRUE), ''); |
|
515 | 515 | if (file_exists($tempfile)) { |
516 | 516 | unlink($tempfile); |
517 | 517 | return realpath(dirname($tempfile)); |