@@ -662,6 +662,9 @@ |
||
662 | 662 | class FrameList implements IteratorAggregate { |
663 | 663 | protected $_frame; |
664 | 664 | |
665 | + /** |
|
666 | + * @param Frame $frame |
|
667 | + */ |
|
665 | 668 | function __construct($frame) { $this->_frame = $frame; } |
666 | 669 | function getIterator() { return new FrameListIterator($this->_frame); } |
667 | 670 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -53,105 +52,105 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class Frame { |
55 | 54 | |
56 | - /** |
|
57 | - * The DOMNode object this frame represents |
|
58 | - * |
|
59 | - * @var DOMNode |
|
60 | - */ |
|
61 | - protected $_node; |
|
62 | - |
|
63 | - /** |
|
64 | - * Unique identifier for this frame. Used to reference this frame |
|
65 | - * via the node. |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $_id; |
|
70 | - |
|
71 | - /** |
|
72 | - * Unique id counter |
|
73 | - */ |
|
74 | - static protected $ID_COUNTER = 0; |
|
55 | + /** |
|
56 | + * The DOMNode object this frame represents |
|
57 | + * |
|
58 | + * @var DOMNode |
|
59 | + */ |
|
60 | + protected $_node; |
|
61 | + |
|
62 | + /** |
|
63 | + * Unique identifier for this frame. Used to reference this frame |
|
64 | + * via the node. |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $_id; |
|
69 | + |
|
70 | + /** |
|
71 | + * Unique id counter |
|
72 | + */ |
|
73 | + static protected $ID_COUNTER = 0; |
|
75 | 74 | |
76 | - /** |
|
77 | - * This frame's calculated style |
|
78 | - * |
|
79 | - * @var Style |
|
80 | - */ |
|
81 | - protected $_style; |
|
82 | - |
|
83 | - /** |
|
84 | - * This frame's original style. Needed for cases where frames are |
|
85 | - * split across pages. |
|
86 | - * |
|
87 | - * @var Style |
|
88 | - */ |
|
89 | - protected $_original_style; |
|
75 | + /** |
|
76 | + * This frame's calculated style |
|
77 | + * |
|
78 | + * @var Style |
|
79 | + */ |
|
80 | + protected $_style; |
|
81 | + |
|
82 | + /** |
|
83 | + * This frame's original style. Needed for cases where frames are |
|
84 | + * split across pages. |
|
85 | + * |
|
86 | + * @var Style |
|
87 | + */ |
|
88 | + protected $_original_style; |
|
90 | 89 | |
91 | - /** |
|
92 | - * This frame's parent in the document tree. |
|
93 | - * |
|
94 | - * @var Frame |
|
95 | - */ |
|
96 | - protected $_parent; |
|
97 | - |
|
98 | - /** |
|
99 | - * This frame's first child. All children are handled as a |
|
100 | - * doubly-linked list. |
|
101 | - * |
|
102 | - * @var Frame |
|
103 | - */ |
|
104 | - protected $_first_child; |
|
105 | - |
|
106 | - /** |
|
107 | - * This frame's last child. |
|
108 | - * |
|
109 | - * @var Frame |
|
110 | - */ |
|
111 | - protected $_last_child; |
|
112 | - |
|
113 | - /** |
|
114 | - * This frame's previous sibling in the document tree. |
|
115 | - * |
|
116 | - * @var Frame |
|
117 | - */ |
|
118 | - protected $_prev_sibling; |
|
119 | - |
|
120 | - /** |
|
121 | - * This frame's next sibling in the document tree. |
|
122 | - * |
|
123 | - * @var Frame |
|
124 | - */ |
|
125 | - protected $_next_sibling; |
|
90 | + /** |
|
91 | + * This frame's parent in the document tree. |
|
92 | + * |
|
93 | + * @var Frame |
|
94 | + */ |
|
95 | + protected $_parent; |
|
96 | + |
|
97 | + /** |
|
98 | + * This frame's first child. All children are handled as a |
|
99 | + * doubly-linked list. |
|
100 | + * |
|
101 | + * @var Frame |
|
102 | + */ |
|
103 | + protected $_first_child; |
|
104 | + |
|
105 | + /** |
|
106 | + * This frame's last child. |
|
107 | + * |
|
108 | + * @var Frame |
|
109 | + */ |
|
110 | + protected $_last_child; |
|
111 | + |
|
112 | + /** |
|
113 | + * This frame's previous sibling in the document tree. |
|
114 | + * |
|
115 | + * @var Frame |
|
116 | + */ |
|
117 | + protected $_prev_sibling; |
|
118 | + |
|
119 | + /** |
|
120 | + * This frame's next sibling in the document tree. |
|
121 | + * |
|
122 | + * @var Frame |
|
123 | + */ |
|
124 | + protected $_next_sibling; |
|
126 | 125 | |
127 | - /** |
|
128 | - * This frame's containing block (used in layout): array(x, y, w, h) |
|
129 | - * |
|
130 | - * @var array |
|
131 | - */ |
|
132 | - protected $_containing_block; |
|
133 | - |
|
134 | - /** |
|
135 | - * Position on the page of the top-left corner of the margin box of |
|
136 | - * this frame: array(x,y) |
|
137 | - * |
|
138 | - * @var array |
|
139 | - */ |
|
140 | - protected $_position; |
|
141 | - |
|
142 | - /** |
|
143 | - * This frame's decorator |
|
144 | - * |
|
145 | - * @var Frame_Decorator |
|
146 | - */ |
|
147 | - protected $_decorator; |
|
148 | - |
|
149 | - /** |
|
150 | - * Class constructor |
|
151 | - * |
|
152 | - * @param DOMNode $node the DOMNode this frame represents |
|
153 | - */ |
|
154 | - function __construct(DomNode $node) { |
|
126 | + /** |
|
127 | + * This frame's containing block (used in layout): array(x, y, w, h) |
|
128 | + * |
|
129 | + * @var array |
|
130 | + */ |
|
131 | + protected $_containing_block; |
|
132 | + |
|
133 | + /** |
|
134 | + * Position on the page of the top-left corner of the margin box of |
|
135 | + * this frame: array(x,y) |
|
136 | + * |
|
137 | + * @var array |
|
138 | + */ |
|
139 | + protected $_position; |
|
140 | + |
|
141 | + /** |
|
142 | + * This frame's decorator |
|
143 | + * |
|
144 | + * @var Frame_Decorator |
|
145 | + */ |
|
146 | + protected $_decorator; |
|
147 | + |
|
148 | + /** |
|
149 | + * Class constructor |
|
150 | + * |
|
151 | + * @param DOMNode $node the DOMNode this frame represents |
|
152 | + */ |
|
153 | + function __construct(DomNode $node) { |
|
155 | 154 | $this->_node = $node; |
156 | 155 | |
157 | 156 | $this->_parent = null; |
@@ -163,48 +162,48 @@ discard block |
||
163 | 162 | $this->_original_style = null; |
164 | 163 | |
165 | 164 | $this->_containing_block = array("x" => null, |
166 | - "y" => null, |
|
167 | - "w" => null, |
|
168 | - "h" => null); |
|
165 | + "y" => null, |
|
166 | + "w" => null, |
|
167 | + "h" => null); |
|
169 | 168 | $this->_position = array("x" => null, |
170 | - "y" => null); |
|
169 | + "y" => null); |
|
171 | 170 | |
172 | 171 | $this->_decorator = null; |
173 | 172 | |
174 | 173 | $this->set_id( self::$ID_COUNTER++ ); |
175 | - } |
|
174 | + } |
|
176 | 175 | |
177 | - /** |
|
178 | - * "Destructor": forcibly free all references held by this frame |
|
179 | - * |
|
180 | - * @param bool $recursive if true, call dispose on all children |
|
181 | - */ |
|
182 | - function dispose($recursive = false) { |
|
176 | + /** |
|
177 | + * "Destructor": forcibly free all references held by this frame |
|
178 | + * |
|
179 | + * @param bool $recursive if true, call dispose on all children |
|
180 | + */ |
|
181 | + function dispose($recursive = false) { |
|
183 | 182 | |
184 | 183 | if ( $recursive ) { |
185 | - while ( $child = $this->_first_child ) |
|
184 | + while ( $child = $this->_first_child ) |
|
186 | 185 | $child->dispose(true); |
187 | 186 | } |
188 | 187 | |
189 | 188 | // Remove this frame from the tree |
190 | 189 | if ( $this->_prev_sibling ) { |
191 | - $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
|
190 | + $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
|
192 | 191 | } |
193 | 192 | |
194 | 193 | if ( $this->_next_sibling ) { |
195 | - $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
|
194 | + $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
|
196 | 195 | } |
197 | 196 | |
198 | 197 | if ( $this->_parent && $this->_parent->_first_child === $this ) { |
199 | - $this->_parent->_first_child = $this->_next_sibling; |
|
198 | + $this->_parent->_first_child = $this->_next_sibling; |
|
200 | 199 | } |
201 | 200 | |
202 | 201 | if ( $this->_parent && $this->_parent->_last_child === $this ) { |
203 | - $this->_parent->_last_child = $this->_prev_sibling; |
|
202 | + $this->_parent->_last_child = $this->_prev_sibling; |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | if ( $this->_parent ) { |
207 | - $this->_parent->get_node()->removeChild($this->_node); |
|
206 | + $this->_parent->get_node()->removeChild($this->_node); |
|
208 | 207 | } |
209 | 208 | |
210 | 209 | $this->_style->dispose(); |
@@ -212,369 +211,369 @@ discard block |
||
212 | 211 | $this->_original_style->dispose(); |
213 | 212 | unset($this->_original_style); |
214 | 213 | |
215 | - } |
|
214 | + } |
|
216 | 215 | |
217 | - // Re-initialize the frame |
|
218 | - function reset() { |
|
216 | + // Re-initialize the frame |
|
217 | + function reset() { |
|
219 | 218 | $this->_position = array("x" => null, |
220 | - "y" => null); |
|
219 | + "y" => null); |
|
221 | 220 | $this->_containing_block = array("x" => null, |
222 | - "y" => null, |
|
223 | - "w" => null, |
|
224 | - "h" => null); |
|
221 | + "y" => null, |
|
222 | + "w" => null, |
|
223 | + "h" => null); |
|
225 | 224 | |
226 | 225 | unset($this->_style); |
227 | 226 | $this->_style = clone $this->_original_style; |
228 | 227 | |
229 | - } |
|
228 | + } |
|
230 | 229 | |
231 | - //........................................................................ |
|
232 | - |
|
233 | - // Accessor methods |
|
234 | - function get_node() { return $this->_node; } |
|
235 | - function get_id() { return $this->_id; } |
|
236 | - function get_style() { return $this->_style; } |
|
237 | - function get_original_style() { return $this->_original_style; } |
|
238 | - function get_parent() { return $this->_parent; } |
|
239 | - function get_decorator() { return $this->_decorator; } |
|
240 | - function get_first_child() { return $this->_first_child; } |
|
241 | - function get_last_child() { return $this->_last_child; } |
|
242 | - function get_prev_sibling() { return $this->_prev_sibling; } |
|
243 | - function get_next_sibling() { return $this->_next_sibling; } |
|
244 | - |
|
245 | - function get_children() { return new FrameList($this); } |
|
230 | + //........................................................................ |
|
231 | + |
|
232 | + // Accessor methods |
|
233 | + function get_node() { return $this->_node; } |
|
234 | + function get_id() { return $this->_id; } |
|
235 | + function get_style() { return $this->_style; } |
|
236 | + function get_original_style() { return $this->_original_style; } |
|
237 | + function get_parent() { return $this->_parent; } |
|
238 | + function get_decorator() { return $this->_decorator; } |
|
239 | + function get_first_child() { return $this->_first_child; } |
|
240 | + function get_last_child() { return $this->_last_child; } |
|
241 | + function get_prev_sibling() { return $this->_prev_sibling; } |
|
242 | + function get_next_sibling() { return $this->_next_sibling; } |
|
243 | + |
|
244 | + function get_children() { return new FrameList($this); } |
|
246 | 245 | |
247 | - // Layout property accessors |
|
248 | - function get_containing_block($i = null) { |
|
246 | + // Layout property accessors |
|
247 | + function get_containing_block($i = null) { |
|
249 | 248 | if ( isset($i) ) |
250 | - return $this->_containing_block[$i]; |
|
249 | + return $this->_containing_block[$i]; |
|
251 | 250 | return $this->_containing_block; |
252 | - } |
|
251 | + } |
|
253 | 252 | |
254 | - function get_position($i = null) { |
|
253 | + function get_position($i = null) { |
|
255 | 254 | if ( isset($i) ) |
256 | - return $this->_position[$i]; |
|
255 | + return $this->_position[$i]; |
|
257 | 256 | return array($this->_position["x"], |
258 | - $this->_position["y"], |
|
259 | - "x"=>$this->_position["x"], |
|
260 | - "y"=>$this->_position["y"]); |
|
261 | - } |
|
257 | + $this->_position["y"], |
|
258 | + "x"=>$this->_position["x"], |
|
259 | + "y"=>$this->_position["y"]); |
|
260 | + } |
|
262 | 261 | |
263 | - //........................................................................ |
|
262 | + //........................................................................ |
|
264 | 263 | |
265 | - // Return the height of the margin box of the frame, in pt. Meaningless |
|
266 | - // unless the height has been calculated properly. |
|
267 | - function get_margin_height() { |
|
264 | + // Return the height of the margin box of the frame, in pt. Meaningless |
|
265 | + // unless the height has been calculated properly. |
|
266 | + function get_margin_height() { |
|
268 | 267 | return $this->_style->length_in_pt(array($this->_style->height, |
269 | - $this->_style->margin_top, |
|
270 | - $this->_style->margin_bottom, |
|
271 | - $this->_style->border_top_width, |
|
272 | - $this->_style->border_bottom_width, |
|
273 | - $this->_style->padding_top, |
|
274 | - $this->_style->padding_bottom), |
|
275 | - $this->_containing_block["w"]); |
|
276 | - } |
|
277 | - |
|
278 | - // Return the width of the margin box of the frame, in pt. Meaningless |
|
279 | - // unless the width has been calculted properly. |
|
280 | - function get_margin_width() { |
|
268 | + $this->_style->margin_top, |
|
269 | + $this->_style->margin_bottom, |
|
270 | + $this->_style->border_top_width, |
|
271 | + $this->_style->border_bottom_width, |
|
272 | + $this->_style->padding_top, |
|
273 | + $this->_style->padding_bottom), |
|
274 | + $this->_containing_block["w"]); |
|
275 | + } |
|
276 | + |
|
277 | + // Return the width of the margin box of the frame, in pt. Meaningless |
|
278 | + // unless the width has been calculted properly. |
|
279 | + function get_margin_width() { |
|
281 | 280 | return $this->_style->length_in_pt(array($this->_style->width, |
282 | - $this->_style->margin_left, |
|
283 | - $this->_style->margin_right, |
|
284 | - $this->_style->border_left_width, |
|
285 | - $this->_style->border_right_width, |
|
286 | - $this->_style->padding_left, |
|
287 | - $this->_style->padding_right), |
|
288 | - $this->_containing_block["w"]); |
|
289 | - } |
|
290 | - |
|
291 | - // Return the padding box (x,y,w,h) of the frame |
|
292 | - function get_padding_box() { |
|
281 | + $this->_style->margin_left, |
|
282 | + $this->_style->margin_right, |
|
283 | + $this->_style->border_left_width, |
|
284 | + $this->_style->border_right_width, |
|
285 | + $this->_style->padding_left, |
|
286 | + $this->_style->padding_right), |
|
287 | + $this->_containing_block["w"]); |
|
288 | + } |
|
289 | + |
|
290 | + // Return the padding box (x,y,w,h) of the frame |
|
291 | + function get_padding_box() { |
|
293 | 292 | $x = $this->_position["x"] + |
294 | 293 | $this->_style->length_in_pt(array($this->_style->margin_left, |
295 | 294 | $this->_style->border_left_width), |
296 | - $this->_containing_block["w"]); |
|
295 | + $this->_containing_block["w"]); |
|
297 | 296 | $y = $this->_position["y"] + |
298 | 297 | $this->_style->length_in_pt(array($this->_style->margin_top, |
299 | 298 | $this->_style->border_top_width), |
300 | - $this->_containing_block["w"]); |
|
299 | + $this->_containing_block["w"]); |
|
301 | 300 | |
302 | 301 | $w = $this->_style->length_in_pt(array($this->_style->padding_left, |
303 | - $this->_style->width, |
|
304 | - $this->_style->padding_right), |
|
305 | - $this->_containing_block["w"]); |
|
302 | + $this->_style->width, |
|
303 | + $this->_style->padding_right), |
|
304 | + $this->_containing_block["w"]); |
|
306 | 305 | |
307 | 306 | $h = $this->_style->length_in_pt(array($this->_style->padding_top, |
308 | - $this->_style->height, |
|
309 | - $this->_style->padding_bottom), |
|
310 | - $this->_containing_block["w"]); |
|
307 | + $this->_style->height, |
|
308 | + $this->_style->padding_bottom), |
|
309 | + $this->_containing_block["w"]); |
|
311 | 310 | |
312 | 311 | return array(0 => $x, "x" => $x, |
313 | - 1 => $y, "y" => $y, |
|
314 | - 2 => $w, "w" => $w, |
|
315 | - 3 => $h, "h" => $h); |
|
316 | - } |
|
312 | + 1 => $y, "y" => $y, |
|
313 | + 2 => $w, "w" => $w, |
|
314 | + 3 => $h, "h" => $h); |
|
315 | + } |
|
317 | 316 | |
318 | - // Return the border box of the frame |
|
319 | - function get_border_box() { |
|
317 | + // Return the border box of the frame |
|
318 | + function get_border_box() { |
|
320 | 319 | $x = $this->_position["x"] + |
321 | 320 | $this->_style->length_in_pt($this->_style->margin_left, |
322 | - $this->_containing_block["w"]); |
|
321 | + $this->_containing_block["w"]); |
|
323 | 322 | $y = $this->_position["y"] + |
324 | 323 | $this->_style->length_in_pt($this->_style->margin_top, |
325 | - $this->_containing_block["w"]); |
|
324 | + $this->_containing_block["w"]); |
|
326 | 325 | |
327 | 326 | $w = $this->_style->length_in_pt(array($this->_style->border_left_width, |
328 | - $this->_style->padding_left, |
|
329 | - $this->_style->width, |
|
330 | - $this->_style->padding_right, |
|
331 | - $this->_style->border_right_width), |
|
332 | - $this->_containing_block["w"]); |
|
327 | + $this->_style->padding_left, |
|
328 | + $this->_style->width, |
|
329 | + $this->_style->padding_right, |
|
330 | + $this->_style->border_right_width), |
|
331 | + $this->_containing_block["w"]); |
|
333 | 332 | |
334 | 333 | $h = $this->_style->length_in_pt(array($this->_style->border_top_width, |
335 | - $this->_style->padding_top, |
|
336 | - $this->_style->height, |
|
337 | - $this->_style->padding_bottom, |
|
338 | - $this->_style->border_bottom_width), |
|
339 | - $this->_containing_block["w"]); |
|
334 | + $this->_style->padding_top, |
|
335 | + $this->_style->height, |
|
336 | + $this->_style->padding_bottom, |
|
337 | + $this->_style->border_bottom_width), |
|
338 | + $this->_containing_block["w"]); |
|
340 | 339 | |
341 | 340 | return array(0 => $x, "x" => $x, |
342 | - 1 => $y, "y" => $y, |
|
343 | - 2 => $w, "w" => $w, |
|
344 | - 3 => $h, "h" => $h); |
|
341 | + 1 => $y, "y" => $y, |
|
342 | + 2 => $w, "w" => $w, |
|
343 | + 3 => $h, "h" => $h); |
|
345 | 344 | |
346 | - } |
|
345 | + } |
|
347 | 346 | |
348 | - //........................................................................ |
|
347 | + //........................................................................ |
|
349 | 348 | |
350 | - // Set methods |
|
351 | - function set_id($id) { |
|
349 | + // Set methods |
|
350 | + function set_id($id) { |
|
352 | 351 | $this->_id = $id; |
353 | 352 | |
354 | 353 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 354 | // Since these are the only objects that we can assign CSS rules to, |
356 | 355 | // this shortcoming is okay. |
357 | 356 | if ( $this->_node->nodeType == 1) |
358 | - $this->_node->setAttribute("frame_id", $id); |
|
359 | - } |
|
357 | + $this->_node->setAttribute("frame_id", $id); |
|
358 | + } |
|
360 | 359 | |
361 | - function set_style(Style $style) { |
|
360 | + function set_style(Style $style) { |
|
362 | 361 | if ( is_null($this->_style) ) |
363 | - $this->_original_style = clone $style; |
|
362 | + $this->_original_style = clone $style; |
|
364 | 363 | |
365 | 364 | $this->_style = $style; |
366 | - } |
|
365 | + } |
|
367 | 366 | |
368 | - function set_decorator(Frame_Decorator $decorator) { |
|
367 | + function set_decorator(Frame_Decorator $decorator) { |
|
369 | 368 | $this->_decorator = $decorator; |
370 | - } |
|
369 | + } |
|
371 | 370 | |
372 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
371 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
373 | 372 | if ( is_array($x) ){ |
374 | - foreach($x AS $key => $val){ |
|
375 | - $$key = $val; |
|
376 | - } |
|
373 | + foreach($x AS $key => $val){ |
|
374 | + $$key = $val; |
|
375 | + } |
|
377 | 376 | } |
378 | 377 | |
379 | 378 | if (is_numeric($x)) { |
380 | - $this->_containing_block[0] = $x; |
|
381 | - $this->_containing_block["x"] = $x; |
|
379 | + $this->_containing_block[0] = $x; |
|
380 | + $this->_containing_block["x"] = $x; |
|
382 | 381 | } |
383 | 382 | |
384 | 383 | if (is_numeric($y)) { |
385 | - $this->_containing_block[1] = $y; |
|
386 | - $this->_containing_block["y"] = $y; |
|
384 | + $this->_containing_block[1] = $y; |
|
385 | + $this->_containing_block["y"] = $y; |
|
387 | 386 | } |
388 | 387 | |
389 | 388 | if (is_numeric($w)) { |
390 | - $this->_containing_block[2] = $w; |
|
391 | - $this->_containing_block["w"] = $w; |
|
389 | + $this->_containing_block[2] = $w; |
|
390 | + $this->_containing_block["w"] = $w; |
|
392 | 391 | } |
393 | 392 | |
394 | 393 | if (is_numeric($h)) { |
395 | - $this->_containing_block[3] = $h; |
|
396 | - $this->_containing_block["h"] = $h; |
|
394 | + $this->_containing_block[3] = $h; |
|
395 | + $this->_containing_block["h"] = $h; |
|
397 | 396 | } |
398 | 397 | |
399 | - } |
|
398 | + } |
|
400 | 399 | |
401 | - function set_position($x = null, $y = null) { |
|
400 | + function set_position($x = null, $y = null) { |
|
402 | 401 | if ( is_array($x) ) |
403 | - extract($x); |
|
402 | + extract($x); |
|
404 | 403 | |
405 | 404 | if ( is_numeric($x) ) { |
406 | - $this->_position[0] = $x; |
|
407 | - $this->_position["x"] = $x; |
|
405 | + $this->_position[0] = $x; |
|
406 | + $this->_position["x"] = $x; |
|
408 | 407 | } |
409 | 408 | |
410 | 409 | if ( is_numeric($y) ) { |
411 | - $this->_position[1] = $y; |
|
412 | - $this->_position["y"] = $y; |
|
410 | + $this->_position[1] = $y; |
|
411 | + $this->_position["y"] = $y; |
|
412 | + } |
|
413 | 413 | } |
414 | - } |
|
415 | 414 | |
416 | - //........................................................................ |
|
415 | + //........................................................................ |
|
417 | 416 | |
418 | - function prepend_child(Frame $child, $update_node = true) { |
|
417 | + function prepend_child(Frame $child, $update_node = true) { |
|
419 | 418 | |
420 | 419 | if ( $update_node ) |
421 | - $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
420 | + $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
422 | 421 | |
423 | 422 | // Remove the child from its parent |
424 | 423 | if ( $child->_parent ) |
425 | - $child->_parent->remove_child($child, false); |
|
424 | + $child->_parent->remove_child($child, false); |
|
426 | 425 | |
427 | 426 | $child->_parent = $this; |
428 | 427 | $child->_prev_sibling = null; |
429 | 428 | |
430 | 429 | // Handle the first child |
431 | 430 | if ( !$this->_first_child ) { |
432 | - $this->_first_child = $child; |
|
433 | - $this->_last_child = $child; |
|
434 | - $child->_next_sibling = null; |
|
431 | + $this->_first_child = $child; |
|
432 | + $this->_last_child = $child; |
|
433 | + $child->_next_sibling = null; |
|
435 | 434 | |
436 | 435 | } else { |
437 | 436 | |
438 | - $this->_first_child->_prev_sibling = $child; |
|
439 | - $child->_next_sibling = $this->_first_child; |
|
440 | - $this->_first_child = $child; |
|
437 | + $this->_first_child->_prev_sibling = $child; |
|
438 | + $child->_next_sibling = $this->_first_child; |
|
439 | + $this->_first_child = $child; |
|
441 | 440 | |
442 | 441 | } |
443 | - } |
|
442 | + } |
|
444 | 443 | |
445 | - function append_child(Frame $child, $update_node = true) { |
|
444 | + function append_child(Frame $child, $update_node = true) { |
|
446 | 445 | |
447 | 446 | if ( $update_node ) |
448 | - $this->_node->appendChild($child->_node); |
|
447 | + $this->_node->appendChild($child->_node); |
|
449 | 448 | |
450 | 449 | // Remove the child from its parent |
451 | 450 | if ( $child->_parent ) |
452 | - $child->_parent->remove_child($child, false); |
|
451 | + $child->_parent->remove_child($child, false); |
|
453 | 452 | |
454 | 453 | $child->_parent = $this; |
455 | 454 | $child->_next_sibling = null; |
456 | 455 | |
457 | 456 | // Handle the first child |
458 | 457 | if ( !$this->_last_child ) { |
459 | - $this->_first_child = $child; |
|
460 | - $this->_last_child = $child; |
|
461 | - $child->_prev_sibling = null; |
|
458 | + $this->_first_child = $child; |
|
459 | + $this->_last_child = $child; |
|
460 | + $child->_prev_sibling = null; |
|
462 | 461 | |
463 | 462 | } else { |
464 | 463 | |
465 | - $this->_last_child->_next_sibling = $child; |
|
466 | - $child->_prev_sibling = $this->_last_child; |
|
467 | - $this->_last_child = $child; |
|
464 | + $this->_last_child->_next_sibling = $child; |
|
465 | + $child->_prev_sibling = $this->_last_child; |
|
466 | + $this->_last_child = $child; |
|
468 | 467 | |
469 | 468 | } |
470 | - } |
|
469 | + } |
|
471 | 470 | |
472 | - // Inserts a new child immediately before the specified frame |
|
473 | - function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
471 | + // Inserts a new child immediately before the specified frame |
|
472 | + function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
474 | 473 | |
475 | 474 | if ( $ref === $this->_first_child ) { |
476 | - $this->prepend_child($new_child, $update_node); |
|
477 | - return; |
|
475 | + $this->prepend_child($new_child, $update_node); |
|
476 | + return; |
|
478 | 477 | } |
479 | 478 | |
480 | 479 | if ( is_null($ref) ) { |
481 | - $this->append_child($new_child, $update_node); |
|
482 | - return; |
|
480 | + $this->append_child($new_child, $update_node); |
|
481 | + return; |
|
483 | 482 | } |
484 | 483 | |
485 | 484 | if ( $ref->_parent !== $this ) |
486 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
485 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
487 | 486 | |
488 | 487 | // Update the node |
489 | 488 | if ( $update_node ) |
490 | - $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
489 | + $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
491 | 490 | |
492 | 491 | // Remove the child from its parent |
493 | 492 | if ( $new_child->_parent ) |
494 | - $new_child->_parent->remove_child($new_child, false); |
|
493 | + $new_child->_parent->remove_child($new_child, false); |
|
495 | 494 | |
496 | 495 | $new_child->_parent = $this; |
497 | 496 | $new_child->_next_sibling = $ref; |
498 | 497 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 498 | |
500 | 499 | if ( $ref->_prev_sibling ) |
501 | - $ref->_prev_sibling->_next_sibling = $new_child; |
|
500 | + $ref->_prev_sibling->_next_sibling = $new_child; |
|
502 | 501 | |
503 | 502 | $ref->_prev_sibling = $new_child; |
504 | - } |
|
503 | + } |
|
505 | 504 | |
506 | - // Inserts a new child immediately after the specified frame |
|
507 | - function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
505 | + // Inserts a new child immediately after the specified frame |
|
506 | + function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
508 | 507 | |
509 | 508 | if ( $ref === $this->_last_child ) { |
510 | - $this->append_child($new_child, $update_node); |
|
511 | - return; |
|
509 | + $this->append_child($new_child, $update_node); |
|
510 | + return; |
|
512 | 511 | } |
513 | 512 | |
514 | 513 | if ( is_null($ref) ) { |
515 | - $this->prepend_child($new_child, $update_node); |
|
516 | - return; |
|
514 | + $this->prepend_child($new_child, $update_node); |
|
515 | + return; |
|
517 | 516 | } |
518 | 517 | |
519 | 518 | if ( $ref->_parent !== $this ) |
520 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
519 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
521 | 520 | |
522 | 521 | // Update the node |
523 | 522 | if ( $update_node ) { |
524 | - if ( $ref->_next_sibling ) { |
|
523 | + if ( $ref->_next_sibling ) { |
|
525 | 524 | $next_node = $ref->_next_sibling->_node; |
526 | 525 | $this->_node->insertBefore($new_child->_node, $next_node); |
527 | - } else { |
|
526 | + } else { |
|
528 | 527 | $new_child->_node = $this->_node->appendChild($new_child); |
529 | - } |
|
528 | + } |
|
530 | 529 | } |
531 | 530 | |
532 | 531 | // Remove the child from its parent |
533 | 532 | if ( $new_child->_parent) |
534 | - $new_child->_parent->remove_child($new_child, false); |
|
533 | + $new_child->_parent->remove_child($new_child, false); |
|
535 | 534 | |
536 | 535 | $new_child->_parent = $this; |
537 | 536 | $new_child->_prev_sibling = $ref; |
538 | 537 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 538 | |
540 | 539 | if ( $ref->_next_sibling ) |
541 | - $ref->_next_sibling->_prev_sibling = $new_child; |
|
540 | + $ref->_next_sibling->_prev_sibling = $new_child; |
|
542 | 541 | |
543 | 542 | $ref->_next_sibling = $new_child; |
544 | - } |
|
543 | + } |
|
545 | 544 | |
546 | 545 | |
547 | - function remove_child(Frame $child, $update_node = true) { |
|
546 | + function remove_child(Frame $child, $update_node = true) { |
|
548 | 547 | |
549 | 548 | if ( $child->_parent !== $this ) |
550 | - throw new DOMPDF_Exception("Child not found in this frame"); |
|
549 | + throw new DOMPDF_Exception("Child not found in this frame"); |
|
551 | 550 | |
552 | 551 | if ( $update_node ) |
553 | - $this->_node->removeChild($child->_node); |
|
552 | + $this->_node->removeChild($child->_node); |
|
554 | 553 | |
555 | 554 | if ( $child === $this->_first_child ) |
556 | - $this->_first_child = $child->_next_sibling; |
|
555 | + $this->_first_child = $child->_next_sibling; |
|
557 | 556 | |
558 | 557 | if ( $child === $this->_last_child ) |
559 | - $this->_last_child = $child->_prev_sibling; |
|
558 | + $this->_last_child = $child->_prev_sibling; |
|
560 | 559 | |
561 | 560 | if ( $child->_prev_sibling ) |
562 | - $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
561 | + $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
563 | 562 | |
564 | 563 | if ( $child->_next_sibling ) |
565 | - $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
564 | + $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
566 | 565 | |
567 | 566 | $child->_next_sibling = null; |
568 | 567 | $child->_prev_sibling = null; |
569 | 568 | $child->_parent = null; |
570 | 569 | return $child; |
571 | 570 | |
572 | - } |
|
571 | + } |
|
573 | 572 | |
574 | - //........................................................................ |
|
573 | + //........................................................................ |
|
575 | 574 | |
576 | - // Debugging function: |
|
577 | - function __toString() { |
|
575 | + // Debugging function: |
|
576 | + function __toString() { |
|
578 | 577 | |
579 | 578 | // Skip empty text frames |
580 | 579 | // if ( $this->_node->nodeName === "#text" && |
@@ -588,29 +587,29 @@ discard block |
||
588 | 587 | $str .= "Class: " .get_class($this) . "<br/>"; |
589 | 588 | |
590 | 589 | if ( $this->_node->nodeName === "#text" ) { |
591 | - $tmp = htmlspecialchars($this->_node->nodeValue); |
|
592 | - $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
590 | + $tmp = htmlspecialchars($this->_node->nodeValue); |
|
591 | + $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
593 | 592 | (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
594 | 593 | } |
595 | 594 | if ( $this->_parent ) |
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
595 | + $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | 596 | " (" . spl_object_hash($this->_parent->_node) . ") " . |
598 | 597 | "<br/>"; |
599 | 598 | |
600 | 599 | if ( $this->_prev_sibling ) |
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
600 | + $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | 601 | " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
603 | 602 | "<br/>"; |
604 | 603 | |
605 | 604 | if ( $this->_next_sibling ) |
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
605 | + $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | 606 | " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
608 | 607 | "<br/>"; |
609 | 608 | |
610 | 609 | $d = $this->get_decorator(); |
611 | 610 | while ($d && $d != $d->get_decorator()) { |
612 | - $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
613 | - $d = $d->get_decorator(); |
|
611 | + $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
612 | + $d = $d->get_decorator(); |
|
614 | 613 | } |
615 | 614 | |
616 | 615 | $str .= "Position: " . pre_r($this->_position, true); |
@@ -621,33 +620,33 @@ discard block |
||
621 | 620 | $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>"; |
622 | 621 | |
623 | 622 | if ( $this->_decorator instanceof Block_Frame_Decorator ) { |
624 | - $str .= "Lines:<pre>"; |
|
625 | - foreach ($this->_decorator->get_lines() as $line) { |
|
623 | + $str .= "Lines:<pre>"; |
|
624 | + foreach ($this->_decorator->get_lines() as $line) { |
|
626 | 625 | foreach ($line["frames"] as $frame) { |
627 | - if ($frame instanceof Text_Frame_Decorator) { |
|
626 | + if ($frame instanceof Text_Frame_Decorator) { |
|
628 | 627 | $str .= "\ntext: "; |
629 | 628 | $str .= "'". htmlspecialchars($frame->get_text()) ."'"; |
630 | - } else { |
|
629 | + } else { |
|
631 | 630 | $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; |
632 | - } |
|
631 | + } |
|
633 | 632 | } |
634 | 633 | |
635 | 634 | $str .= |
636 | - //"\ncount => " . $line["count"] . "\n". |
|
637 | - "\ny => " . $line["y"] . "\n" . |
|
638 | - "w => " . $line["w"] . "\n" . |
|
639 | - "h => " . $line["h"] . "\n"; |
|
640 | - } |
|
641 | - $str .= "</pre>"; |
|
635 | + //"\ncount => " . $line["count"] . "\n". |
|
636 | + "\ny => " . $line["y"] . "\n" . |
|
637 | + "w => " . $line["w"] . "\n" . |
|
638 | + "h => " . $line["h"] . "\n"; |
|
639 | + } |
|
640 | + $str .= "</pre>"; |
|
642 | 641 | } |
643 | 642 | $str .= "\n"; |
644 | 643 | if ( php_sapi_name() === "cli" ) |
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
644 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | 645 | array("\n","",""), |
647 | 646 | $str)); |
648 | 647 | |
649 | 648 | return $str; |
650 | - } |
|
649 | + } |
|
651 | 650 | |
652 | 651 | } |
653 | 652 | |
@@ -660,10 +659,10 @@ discard block |
||
660 | 659 | * @package dompdf |
661 | 660 | */ |
662 | 661 | class FrameList implements IteratorAggregate { |
663 | - protected $_frame; |
|
662 | + protected $_frame; |
|
664 | 663 | |
665 | - function __construct($frame) { $this->_frame = $frame; } |
|
666 | - function getIterator() { return new FrameListIterator($this->_frame); } |
|
664 | + function __construct($frame) { $this->_frame = $frame; } |
|
665 | + function getIterator() { return new FrameListIterator($this->_frame); } |
|
667 | 666 | } |
668 | 667 | |
669 | 668 | /** |
@@ -677,37 +676,37 @@ discard block |
||
677 | 676 | */ |
678 | 677 | class FrameListIterator implements Iterator { |
679 | 678 | |
680 | - protected $_parent; |
|
681 | - protected $_cur; |
|
682 | - protected $_num; |
|
679 | + protected $_parent; |
|
680 | + protected $_cur; |
|
681 | + protected $_num; |
|
683 | 682 | |
684 | - function __construct(Frame $frame) { |
|
683 | + function __construct(Frame $frame) { |
|
685 | 684 | $this->_parent = $frame; |
686 | 685 | $this->_cur = $frame->get_first_child(); |
687 | 686 | $this->_num = 0; |
688 | - } |
|
687 | + } |
|
689 | 688 | |
690 | - function rewind() { |
|
689 | + function rewind() { |
|
691 | 690 | $this->_cur = $this->_parent->get_first_child(); |
692 | 691 | $this->_num = 0; |
693 | - } |
|
692 | + } |
|
694 | 693 | |
695 | - function valid() { |
|
694 | + function valid() { |
|
696 | 695 | return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev); |
697 | - } |
|
698 | - function key() { return $this->_num; } |
|
699 | - function current() { return $this->_cur; } |
|
696 | + } |
|
697 | + function key() { return $this->_num; } |
|
698 | + function current() { return $this->_cur; } |
|
700 | 699 | |
701 | - function next() { |
|
700 | + function next() { |
|
702 | 701 | |
703 | 702 | $ret = $this->_cur; |
704 | 703 | if ( !$ret ) |
705 | - return null; |
|
704 | + return null; |
|
706 | 705 | |
707 | 706 | $this->_cur = $this->_cur->get_next_sibling(); |
708 | 707 | $this->_num++; |
709 | 708 | return $ret; |
710 | - } |
|
709 | + } |
|
711 | 710 | } |
712 | 711 | |
713 | 712 | //------------------------------------------------------------------------ |
@@ -720,9 +719,9 @@ discard block |
||
720 | 719 | */ |
721 | 720 | class FrameTreeList implements IteratorAggregate { |
722 | 721 | |
723 | - protected $_root; |
|
724 | - function __construct(Frame $root) { $this->_root = $root; } |
|
725 | - function getIterator() { return new FrameTreeIterator($this->_root); } |
|
722 | + protected $_root; |
|
723 | + function __construct(Frame $root) { $this->_root = $root; } |
|
724 | + function getIterator() { return new FrameTreeIterator($this->_root); } |
|
726 | 725 | |
727 | 726 | } |
728 | 727 | |
@@ -736,25 +735,25 @@ discard block |
||
736 | 735 | */ |
737 | 736 | class FrameTreeIterator implements Iterator { |
738 | 737 | |
739 | - protected $_root; |
|
740 | - protected $_stack = array(); |
|
741 | - protected $_num; |
|
738 | + protected $_root; |
|
739 | + protected $_stack = array(); |
|
740 | + protected $_num; |
|
742 | 741 | |
743 | - function __construct(Frame $root) { |
|
742 | + function __construct(Frame $root) { |
|
744 | 743 | $this->_stack[] = $this->_root = $root; |
745 | 744 | $this->_num = 0; |
746 | - } |
|
745 | + } |
|
747 | 746 | |
748 | - function rewind() { |
|
747 | + function rewind() { |
|
749 | 748 | $this->_stack = array($this->_root); |
750 | 749 | $this->_num = 0; |
751 | - } |
|
750 | + } |
|
752 | 751 | |
753 | - function valid() { return count($this->_stack) > 0; } |
|
754 | - function key() { return $this->_num; } |
|
755 | - function current() { return end($this->_stack); } |
|
752 | + function valid() { return count($this->_stack) > 0; } |
|
753 | + function key() { return $this->_num; } |
|
754 | + function current() { return end($this->_stack); } |
|
756 | 755 | |
757 | - function next() { |
|
756 | + function next() { |
|
758 | 757 | $b = end($this->_stack); |
759 | 758 | |
760 | 759 | // Pop last element |
@@ -763,10 +762,10 @@ discard block |
||
763 | 762 | |
764 | 763 | // Push all children onto the stack in reverse order |
765 | 764 | if ( $c = $b->get_last_child() ) { |
766 | - $this->_stack[] = $c; |
|
767 | - while ( $c = $c->get_prev_sibling() ) |
|
765 | + $this->_stack[] = $c; |
|
766 | + while ( $c = $c->get_prev_sibling() ) |
|
768 | 767 | $this->_stack[] = $c; |
769 | 768 | } |
770 | 769 | return $b; |
771 | - } |
|
770 | + } |
|
772 | 771 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $this->_decorator = null; |
173 | 173 | |
174 | - $this->set_id( self::$ID_COUNTER++ ); |
|
174 | + $this->set_id(self::$ID_COUNTER++); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -181,29 +181,29 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function dispose($recursive = false) { |
183 | 183 | |
184 | - if ( $recursive ) { |
|
185 | - while ( $child = $this->_first_child ) |
|
184 | + if ($recursive) { |
|
185 | + while ($child = $this->_first_child) |
|
186 | 186 | $child->dispose(true); |
187 | 187 | } |
188 | 188 | |
189 | 189 | // Remove this frame from the tree |
190 | - if ( $this->_prev_sibling ) { |
|
190 | + if ($this->_prev_sibling) { |
|
191 | 191 | $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
192 | 192 | } |
193 | 193 | |
194 | - if ( $this->_next_sibling ) { |
|
194 | + if ($this->_next_sibling) { |
|
195 | 195 | $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
196 | 196 | } |
197 | 197 | |
198 | - if ( $this->_parent && $this->_parent->_first_child === $this ) { |
|
198 | + if ($this->_parent && $this->_parent->_first_child === $this) { |
|
199 | 199 | $this->_parent->_first_child = $this->_next_sibling; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $this->_parent && $this->_parent->_last_child === $this ) { |
|
202 | + if ($this->_parent && $this->_parent->_last_child === $this) { |
|
203 | 203 | $this->_parent->_last_child = $this->_prev_sibling; |
204 | 204 | } |
205 | 205 | |
206 | - if ( $this->_parent ) { |
|
206 | + if ($this->_parent) { |
|
207 | 207 | $this->_parent->get_node()->removeChild($this->_node); |
208 | 208 | } |
209 | 209 | |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | // Layout property accessors |
248 | 248 | function get_containing_block($i = null) { |
249 | - if ( isset($i) ) |
|
249 | + if (isset($i)) |
|
250 | 250 | return $this->_containing_block[$i]; |
251 | 251 | return $this->_containing_block; |
252 | 252 | } |
253 | 253 | |
254 | 254 | function get_position($i = null) { |
255 | - if ( isset($i) ) |
|
255 | + if (isset($i)) |
|
256 | 256 | return $this->_position[$i]; |
257 | 257 | return array($this->_position["x"], |
258 | 258 | $this->_position["y"], |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 355 | // Since these are the only objects that we can assign CSS rules to, |
356 | 356 | // this shortcoming is okay. |
357 | - if ( $this->_node->nodeType == 1) |
|
357 | + if ($this->_node->nodeType == 1) |
|
358 | 358 | $this->_node->setAttribute("frame_id", $id); |
359 | 359 | } |
360 | 360 | |
361 | 361 | function set_style(Style $style) { |
362 | - if ( is_null($this->_style) ) |
|
362 | + if (is_null($this->_style)) |
|
363 | 363 | $this->_original_style = clone $style; |
364 | 364 | |
365 | 365 | $this->_style = $style; |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
373 | - if ( is_array($x) ){ |
|
374 | - foreach($x AS $key => $val){ |
|
373 | + if (is_array($x)) { |
|
374 | + foreach ($x AS $key => $val) { |
|
375 | 375 | $$key = $val; |
376 | 376 | } |
377 | 377 | } |
@@ -399,15 +399,15 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | function set_position($x = null, $y = null) { |
402 | - if ( is_array($x) ) |
|
402 | + if (is_array($x)) |
|
403 | 403 | extract($x); |
404 | 404 | |
405 | - if ( is_numeric($x) ) { |
|
405 | + if (is_numeric($x)) { |
|
406 | 406 | $this->_position[0] = $x; |
407 | 407 | $this->_position["x"] = $x; |
408 | 408 | } |
409 | 409 | |
410 | - if ( is_numeric($y) ) { |
|
410 | + if (is_numeric($y)) { |
|
411 | 411 | $this->_position[1] = $y; |
412 | 412 | $this->_position["y"] = $y; |
413 | 413 | } |
@@ -417,18 +417,18 @@ discard block |
||
417 | 417 | |
418 | 418 | function prepend_child(Frame $child, $update_node = true) { |
419 | 419 | |
420 | - if ( $update_node ) |
|
420 | + if ($update_node) |
|
421 | 421 | $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
422 | 422 | |
423 | 423 | // Remove the child from its parent |
424 | - if ( $child->_parent ) |
|
424 | + if ($child->_parent) |
|
425 | 425 | $child->_parent->remove_child($child, false); |
426 | 426 | |
427 | 427 | $child->_parent = $this; |
428 | 428 | $child->_prev_sibling = null; |
429 | 429 | |
430 | 430 | // Handle the first child |
431 | - if ( !$this->_first_child ) { |
|
431 | + if (!$this->_first_child) { |
|
432 | 432 | $this->_first_child = $child; |
433 | 433 | $this->_last_child = $child; |
434 | 434 | $child->_next_sibling = null; |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | |
445 | 445 | function append_child(Frame $child, $update_node = true) { |
446 | 446 | |
447 | - if ( $update_node ) |
|
447 | + if ($update_node) |
|
448 | 448 | $this->_node->appendChild($child->_node); |
449 | 449 | |
450 | 450 | // Remove the child from its parent |
451 | - if ( $child->_parent ) |
|
451 | + if ($child->_parent) |
|
452 | 452 | $child->_parent->remove_child($child, false); |
453 | 453 | |
454 | 454 | $child->_parent = $this; |
455 | 455 | $child->_next_sibling = null; |
456 | 456 | |
457 | 457 | // Handle the first child |
458 | - if ( !$this->_last_child ) { |
|
458 | + if (!$this->_last_child) { |
|
459 | 459 | $this->_first_child = $child; |
460 | 460 | $this->_last_child = $child; |
461 | 461 | $child->_prev_sibling = null; |
@@ -472,32 +472,32 @@ discard block |
||
472 | 472 | // Inserts a new child immediately before the specified frame |
473 | 473 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
474 | 474 | |
475 | - if ( $ref === $this->_first_child ) { |
|
475 | + if ($ref === $this->_first_child) { |
|
476 | 476 | $this->prepend_child($new_child, $update_node); |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - if ( is_null($ref) ) { |
|
480 | + if (is_null($ref)) { |
|
481 | 481 | $this->append_child($new_child, $update_node); |
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
485 | - if ( $ref->_parent !== $this ) |
|
485 | + if ($ref->_parent !== $this) |
|
486 | 486 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
487 | 487 | |
488 | 488 | // Update the node |
489 | - if ( $update_node ) |
|
489 | + if ($update_node) |
|
490 | 490 | $this->_node->insertBefore($new_child->_node, $ref->_node); |
491 | 491 | |
492 | 492 | // Remove the child from its parent |
493 | - if ( $new_child->_parent ) |
|
493 | + if ($new_child->_parent) |
|
494 | 494 | $new_child->_parent->remove_child($new_child, false); |
495 | 495 | |
496 | 496 | $new_child->_parent = $this; |
497 | 497 | $new_child->_next_sibling = $ref; |
498 | 498 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 499 | |
500 | - if ( $ref->_prev_sibling ) |
|
500 | + if ($ref->_prev_sibling) |
|
501 | 501 | $ref->_prev_sibling->_next_sibling = $new_child; |
502 | 502 | |
503 | 503 | $ref->_prev_sibling = $new_child; |
@@ -506,22 +506,22 @@ discard block |
||
506 | 506 | // Inserts a new child immediately after the specified frame |
507 | 507 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
508 | 508 | |
509 | - if ( $ref === $this->_last_child ) { |
|
509 | + if ($ref === $this->_last_child) { |
|
510 | 510 | $this->append_child($new_child, $update_node); |
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if ( is_null($ref) ) { |
|
514 | + if (is_null($ref)) { |
|
515 | 515 | $this->prepend_child($new_child, $update_node); |
516 | 516 | return; |
517 | 517 | } |
518 | 518 | |
519 | - if ( $ref->_parent !== $this ) |
|
519 | + if ($ref->_parent !== $this) |
|
520 | 520 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
521 | 521 | |
522 | 522 | // Update the node |
523 | - if ( $update_node ) { |
|
524 | - if ( $ref->_next_sibling ) { |
|
523 | + if ($update_node) { |
|
524 | + if ($ref->_next_sibling) { |
|
525 | 525 | $next_node = $ref->_next_sibling->_node; |
526 | 526 | $this->_node->insertBefore($new_child->_node, $next_node); |
527 | 527 | } else { |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | // Remove the child from its parent |
533 | - if ( $new_child->_parent) |
|
533 | + if ($new_child->_parent) |
|
534 | 534 | $new_child->_parent->remove_child($new_child, false); |
535 | 535 | |
536 | 536 | $new_child->_parent = $this; |
537 | 537 | $new_child->_prev_sibling = $ref; |
538 | 538 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 539 | |
540 | - if ( $ref->_next_sibling ) |
|
540 | + if ($ref->_next_sibling) |
|
541 | 541 | $ref->_next_sibling->_prev_sibling = $new_child; |
542 | 542 | |
543 | 543 | $ref->_next_sibling = $new_child; |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | |
547 | 547 | function remove_child(Frame $child, $update_node = true) { |
548 | 548 | |
549 | - if ( $child->_parent !== $this ) |
|
549 | + if ($child->_parent !== $this) |
|
550 | 550 | throw new DOMPDF_Exception("Child not found in this frame"); |
551 | 551 | |
552 | - if ( $update_node ) |
|
552 | + if ($update_node) |
|
553 | 553 | $this->_node->removeChild($child->_node); |
554 | 554 | |
555 | - if ( $child === $this->_first_child ) |
|
555 | + if ($child === $this->_first_child) |
|
556 | 556 | $this->_first_child = $child->_next_sibling; |
557 | 557 | |
558 | - if ( $child === $this->_last_child ) |
|
558 | + if ($child === $this->_last_child) |
|
559 | 559 | $this->_last_child = $child->_prev_sibling; |
560 | 560 | |
561 | - if ( $child->_prev_sibling ) |
|
561 | + if ($child->_prev_sibling) |
|
562 | 562 | $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
563 | 563 | |
564 | - if ( $child->_next_sibling ) |
|
564 | + if ($child->_next_sibling) |
|
565 | 565 | $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
566 | 566 | |
567 | 567 | $child->_next_sibling = null; |
@@ -582,68 +582,68 @@ discard block |
||
582 | 582 | // return ""; |
583 | 583 | |
584 | 584 | |
585 | - $str = "<b>" . $this->_node->nodeName . ":</b><br/>"; |
|
585 | + $str = "<b>".$this->_node->nodeName.":</b><br/>"; |
|
586 | 586 | //$str .= spl_object_hash($this->_node) . "<br/>"; |
587 | - $str .= "Id: " .$this->get_id() . "<br/>"; |
|
588 | - $str .= "Class: " .get_class($this) . "<br/>"; |
|
587 | + $str .= "Id: ".$this->get_id()."<br/>"; |
|
588 | + $str .= "Class: ".get_class($this)."<br/>"; |
|
589 | 589 | |
590 | - if ( $this->_node->nodeName === "#text" ) { |
|
590 | + if ($this->_node->nodeName === "#text") { |
|
591 | 591 | $tmp = htmlspecialchars($this->_node->nodeValue); |
592 | - $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
593 | - (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
|
592 | + $str .= "<pre>'".mb_substr($tmp, 0, 70). |
|
593 | + (mb_strlen($tmp) > 70 ? "..." : "")."'</pre>"; |
|
594 | 594 | } |
595 | - if ( $this->_parent ) |
|
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | - " (" . spl_object_hash($this->_parent->_node) . ") " . |
|
595 | + if ($this->_parent) |
|
596 | + $str .= "\nParent:".$this->_parent->_node->nodeName. |
|
597 | + " (".spl_object_hash($this->_parent->_node).") ". |
|
598 | 598 | "<br/>"; |
599 | 599 | |
600 | - if ( $this->_prev_sibling ) |
|
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | - " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
|
600 | + if ($this->_prev_sibling) |
|
601 | + $str .= "Prev: ".$this->_prev_sibling->_node->nodeName. |
|
602 | + " (".spl_object_hash($this->_prev_sibling->_node).") ". |
|
603 | 603 | "<br/>"; |
604 | 604 | |
605 | - if ( $this->_next_sibling ) |
|
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | - " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
|
605 | + if ($this->_next_sibling) |
|
606 | + $str .= "Next: ".$this->_next_sibling->_node->nodeName. |
|
607 | + " (".spl_object_hash($this->_next_sibling->_node).") ". |
|
608 | 608 | "<br/>"; |
609 | 609 | |
610 | 610 | $d = $this->get_decorator(); |
611 | 611 | while ($d && $d != $d->get_decorator()) { |
612 | - $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
612 | + $str .= "Decorator: ".get_class($d)."<br/>"; |
|
613 | 613 | $d = $d->get_decorator(); |
614 | 614 | } |
615 | 615 | |
616 | - $str .= "Position: " . pre_r($this->_position, true); |
|
617 | - $str .= "\nContaining block: " . pre_r($this->_containing_block, true); |
|
618 | - $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true); |
|
619 | - $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true); |
|
616 | + $str .= "Position: ".pre_r($this->_position, true); |
|
617 | + $str .= "\nContaining block: ".pre_r($this->_containing_block, true); |
|
618 | + $str .= "\nMargin width: ".pre_r($this->get_margin_width(), true); |
|
619 | + $str .= "\nMargin height: ".pre_r($this->get_margin_height(), true); |
|
620 | 620 | |
621 | - $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>"; |
|
621 | + $str .= "\nStyle: <pre>".$this->_style->__toString()."</pre>"; |
|
622 | 622 | |
623 | - if ( $this->_decorator instanceof Block_Frame_Decorator ) { |
|
623 | + if ($this->_decorator instanceof Block_Frame_Decorator) { |
|
624 | 624 | $str .= "Lines:<pre>"; |
625 | 625 | foreach ($this->_decorator->get_lines() as $line) { |
626 | 626 | foreach ($line["frames"] as $frame) { |
627 | 627 | if ($frame instanceof Text_Frame_Decorator) { |
628 | 628 | $str .= "\ntext: "; |
629 | - $str .= "'". htmlspecialchars($frame->get_text()) ."'"; |
|
629 | + $str .= "'".htmlspecialchars($frame->get_text())."'"; |
|
630 | 630 | } else { |
631 | - $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; |
|
631 | + $str .= "\nBlock: ".$frame->get_node()->nodeName." (".spl_object_hash($frame->get_node()).")"; |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | 635 | $str .= |
636 | 636 | //"\ncount => " . $line["count"] . "\n". |
637 | - "\ny => " . $line["y"] . "\n" . |
|
638 | - "w => " . $line["w"] . "\n" . |
|
639 | - "h => " . $line["h"] . "\n"; |
|
637 | + "\ny => ".$line["y"]."\n". |
|
638 | + "w => ".$line["w"]."\n". |
|
639 | + "h => ".$line["h"]."\n"; |
|
640 | 640 | } |
641 | 641 | $str .= "</pre>"; |
642 | 642 | } |
643 | 643 | $str .= "\n"; |
644 | - if ( php_sapi_name() === "cli" ) |
|
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | - array("\n","",""), |
|
644 | + if (php_sapi_name() === "cli") |
|
645 | + $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), |
|
646 | + array("\n", "", ""), |
|
647 | 647 | $str)); |
648 | 648 | |
649 | 649 | return $str; |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | } |
694 | 694 | |
695 | 695 | function valid() { |
696 | - return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
696 | + return isset($this->_cur); // && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
697 | 697 | } |
698 | 698 | function key() { return $this->_num; } |
699 | 699 | function current() { return $this->_cur; } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | function next() { |
702 | 702 | |
703 | 703 | $ret = $this->_cur; |
704 | - if ( !$ret ) |
|
704 | + if (!$ret) |
|
705 | 705 | return null; |
706 | 706 | |
707 | 707 | $this->_cur = $this->_cur->get_next_sibling(); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | $b = end($this->_stack); |
759 | 759 | |
760 | 760 | // Pop last element |
761 | - unset($this->_stack[ key($this->_stack) ]); |
|
761 | + unset($this->_stack[key($this->_stack)]); |
|
762 | 762 | $this->_num++; |
763 | 763 | |
764 | 764 | // Push all children onto the stack in reverse order |
765 | - if ( $c = $b->get_last_child() ) { |
|
765 | + if ($c = $b->get_last_child()) { |
|
766 | 766 | $this->_stack[] = $c; |
767 | - while ( $c = $c->get_prev_sibling() ) |
|
767 | + while ($c = $c->get_prev_sibling()) |
|
768 | 768 | $this->_stack[] = $c; |
769 | 769 | } |
770 | 770 | return $b; |
@@ -182,8 +182,9 @@ discard block |
||
182 | 182 | function dispose($recursive = false) { |
183 | 183 | |
184 | 184 | if ( $recursive ) { |
185 | - while ( $child = $this->_first_child ) |
|
186 | - $child->dispose(true); |
|
185 | + while ( $child = $this->_first_child ) { |
|
186 | + $child->dispose(true); |
|
187 | + } |
|
187 | 188 | } |
188 | 189 | |
189 | 190 | // Remove this frame from the tree |
@@ -246,14 +247,16 @@ discard block |
||
246 | 247 | |
247 | 248 | // Layout property accessors |
248 | 249 | function get_containing_block($i = null) { |
249 | - if ( isset($i) ) |
|
250 | - return $this->_containing_block[$i]; |
|
250 | + if ( isset($i) ) { |
|
251 | + return $this->_containing_block[$i]; |
|
252 | + } |
|
251 | 253 | return $this->_containing_block; |
252 | 254 | } |
253 | 255 | |
254 | 256 | function get_position($i = null) { |
255 | - if ( isset($i) ) |
|
256 | - return $this->_position[$i]; |
|
257 | + if ( isset($i) ) { |
|
258 | + return $this->_position[$i]; |
|
259 | + } |
|
257 | 260 | return array($this->_position["x"], |
258 | 261 | $this->_position["y"], |
259 | 262 | "x"=>$this->_position["x"], |
@@ -354,13 +357,15 @@ discard block |
||
354 | 357 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 358 | // Since these are the only objects that we can assign CSS rules to, |
356 | 359 | // this shortcoming is okay. |
357 | - if ( $this->_node->nodeType == 1) |
|
358 | - $this->_node->setAttribute("frame_id", $id); |
|
360 | + if ( $this->_node->nodeType == 1) { |
|
361 | + $this->_node->setAttribute("frame_id", $id); |
|
362 | + } |
|
359 | 363 | } |
360 | 364 | |
361 | 365 | function set_style(Style $style) { |
362 | - if ( is_null($this->_style) ) |
|
363 | - $this->_original_style = clone $style; |
|
366 | + if ( is_null($this->_style) ) { |
|
367 | + $this->_original_style = clone $style; |
|
368 | + } |
|
364 | 369 | |
365 | 370 | $this->_style = $style; |
366 | 371 | } |
@@ -399,8 +404,9 @@ discard block |
||
399 | 404 | } |
400 | 405 | |
401 | 406 | function set_position($x = null, $y = null) { |
402 | - if ( is_array($x) ) |
|
403 | - extract($x); |
|
407 | + if ( is_array($x) ) { |
|
408 | + extract($x); |
|
409 | + } |
|
404 | 410 | |
405 | 411 | if ( is_numeric($x) ) { |
406 | 412 | $this->_position[0] = $x; |
@@ -417,12 +423,14 @@ discard block |
||
417 | 423 | |
418 | 424 | function prepend_child(Frame $child, $update_node = true) { |
419 | 425 | |
420 | - if ( $update_node ) |
|
421 | - $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
426 | + if ( $update_node ) { |
|
427 | + $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
428 | + } |
|
422 | 429 | |
423 | 430 | // Remove the child from its parent |
424 | - if ( $child->_parent ) |
|
425 | - $child->_parent->remove_child($child, false); |
|
431 | + if ( $child->_parent ) { |
|
432 | + $child->_parent->remove_child($child, false); |
|
433 | + } |
|
426 | 434 | |
427 | 435 | $child->_parent = $this; |
428 | 436 | $child->_prev_sibling = null; |
@@ -444,12 +452,14 @@ discard block |
||
444 | 452 | |
445 | 453 | function append_child(Frame $child, $update_node = true) { |
446 | 454 | |
447 | - if ( $update_node ) |
|
448 | - $this->_node->appendChild($child->_node); |
|
455 | + if ( $update_node ) { |
|
456 | + $this->_node->appendChild($child->_node); |
|
457 | + } |
|
449 | 458 | |
450 | 459 | // Remove the child from its parent |
451 | - if ( $child->_parent ) |
|
452 | - $child->_parent->remove_child($child, false); |
|
460 | + if ( $child->_parent ) { |
|
461 | + $child->_parent->remove_child($child, false); |
|
462 | + } |
|
453 | 463 | |
454 | 464 | $child->_parent = $this; |
455 | 465 | $child->_next_sibling = null; |
@@ -482,23 +492,27 @@ discard block |
||
482 | 492 | return; |
483 | 493 | } |
484 | 494 | |
485 | - if ( $ref->_parent !== $this ) |
|
486 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
495 | + if ( $ref->_parent !== $this ) { |
|
496 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
497 | + } |
|
487 | 498 | |
488 | 499 | // Update the node |
489 | - if ( $update_node ) |
|
490 | - $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
500 | + if ( $update_node ) { |
|
501 | + $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
502 | + } |
|
491 | 503 | |
492 | 504 | // Remove the child from its parent |
493 | - if ( $new_child->_parent ) |
|
494 | - $new_child->_parent->remove_child($new_child, false); |
|
505 | + if ( $new_child->_parent ) { |
|
506 | + $new_child->_parent->remove_child($new_child, false); |
|
507 | + } |
|
495 | 508 | |
496 | 509 | $new_child->_parent = $this; |
497 | 510 | $new_child->_next_sibling = $ref; |
498 | 511 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 512 | |
500 | - if ( $ref->_prev_sibling ) |
|
501 | - $ref->_prev_sibling->_next_sibling = $new_child; |
|
513 | + if ( $ref->_prev_sibling ) { |
|
514 | + $ref->_prev_sibling->_next_sibling = $new_child; |
|
515 | + } |
|
502 | 516 | |
503 | 517 | $ref->_prev_sibling = $new_child; |
504 | 518 | } |
@@ -516,8 +530,9 @@ discard block |
||
516 | 530 | return; |
517 | 531 | } |
518 | 532 | |
519 | - if ( $ref->_parent !== $this ) |
|
520 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
533 | + if ( $ref->_parent !== $this ) { |
|
534 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
535 | + } |
|
521 | 536 | |
522 | 537 | // Update the node |
523 | 538 | if ( $update_node ) { |
@@ -530,15 +545,17 @@ discard block |
||
530 | 545 | } |
531 | 546 | |
532 | 547 | // Remove the child from its parent |
533 | - if ( $new_child->_parent) |
|
534 | - $new_child->_parent->remove_child($new_child, false); |
|
548 | + if ( $new_child->_parent) { |
|
549 | + $new_child->_parent->remove_child($new_child, false); |
|
550 | + } |
|
535 | 551 | |
536 | 552 | $new_child->_parent = $this; |
537 | 553 | $new_child->_prev_sibling = $ref; |
538 | 554 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 555 | |
540 | - if ( $ref->_next_sibling ) |
|
541 | - $ref->_next_sibling->_prev_sibling = $new_child; |
|
556 | + if ( $ref->_next_sibling ) { |
|
557 | + $ref->_next_sibling->_prev_sibling = $new_child; |
|
558 | + } |
|
542 | 559 | |
543 | 560 | $ref->_next_sibling = $new_child; |
544 | 561 | } |
@@ -546,23 +563,29 @@ discard block |
||
546 | 563 | |
547 | 564 | function remove_child(Frame $child, $update_node = true) { |
548 | 565 | |
549 | - if ( $child->_parent !== $this ) |
|
550 | - throw new DOMPDF_Exception("Child not found in this frame"); |
|
566 | + if ( $child->_parent !== $this ) { |
|
567 | + throw new DOMPDF_Exception("Child not found in this frame"); |
|
568 | + } |
|
551 | 569 | |
552 | - if ( $update_node ) |
|
553 | - $this->_node->removeChild($child->_node); |
|
570 | + if ( $update_node ) { |
|
571 | + $this->_node->removeChild($child->_node); |
|
572 | + } |
|
554 | 573 | |
555 | - if ( $child === $this->_first_child ) |
|
556 | - $this->_first_child = $child->_next_sibling; |
|
574 | + if ( $child === $this->_first_child ) { |
|
575 | + $this->_first_child = $child->_next_sibling; |
|
576 | + } |
|
557 | 577 | |
558 | - if ( $child === $this->_last_child ) |
|
559 | - $this->_last_child = $child->_prev_sibling; |
|
578 | + if ( $child === $this->_last_child ) { |
|
579 | + $this->_last_child = $child->_prev_sibling; |
|
580 | + } |
|
560 | 581 | |
561 | - if ( $child->_prev_sibling ) |
|
562 | - $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
582 | + if ( $child->_prev_sibling ) { |
|
583 | + $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
584 | + } |
|
563 | 585 | |
564 | - if ( $child->_next_sibling ) |
|
565 | - $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
586 | + if ( $child->_next_sibling ) { |
|
587 | + $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
588 | + } |
|
566 | 589 | |
567 | 590 | $child->_next_sibling = null; |
568 | 591 | $child->_prev_sibling = null; |
@@ -592,20 +615,23 @@ discard block |
||
592 | 615 | $str .= "<pre>'" . mb_substr($tmp,0,70) . |
593 | 616 | (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
594 | 617 | } |
595 | - if ( $this->_parent ) |
|
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
618 | + if ( $this->_parent ) { |
|
619 | + $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | 620 | " (" . spl_object_hash($this->_parent->_node) . ") " . |
598 | 621 | "<br/>"; |
622 | + } |
|
599 | 623 | |
600 | - if ( $this->_prev_sibling ) |
|
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
624 | + if ( $this->_prev_sibling ) { |
|
625 | + $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | 626 | " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
603 | 627 | "<br/>"; |
628 | + } |
|
604 | 629 | |
605 | - if ( $this->_next_sibling ) |
|
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
630 | + if ( $this->_next_sibling ) { |
|
631 | + $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | 632 | " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
608 | 633 | "<br/>"; |
634 | + } |
|
609 | 635 | |
610 | 636 | $d = $this->get_decorator(); |
611 | 637 | while ($d && $d != $d->get_decorator()) { |
@@ -641,10 +667,11 @@ discard block |
||
641 | 667 | $str .= "</pre>"; |
642 | 668 | } |
643 | 669 | $str .= "\n"; |
644 | - if ( php_sapi_name() === "cli" ) |
|
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
670 | + if ( php_sapi_name() === "cli" ) { |
|
671 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | 672 | array("\n","",""), |
647 | 673 | $str)); |
674 | + } |
|
648 | 675 | |
649 | 676 | return $str; |
650 | 677 | } |
@@ -701,8 +728,9 @@ discard block |
||
701 | 728 | function next() { |
702 | 729 | |
703 | 730 | $ret = $this->_cur; |
704 | - if ( !$ret ) |
|
705 | - return null; |
|
731 | + if ( !$ret ) { |
|
732 | + return null; |
|
733 | + } |
|
706 | 734 | |
707 | 735 | $this->_cur = $this->_cur->get_next_sibling(); |
708 | 736 | $this->_num++; |
@@ -764,8 +792,9 @@ discard block |
||
764 | 792 | // Push all children onto the stack in reverse order |
765 | 793 | if ( $c = $b->get_last_child() ) { |
766 | 794 | $this->_stack[] = $c; |
767 | - while ( $c = $c->get_prev_sibling() ) |
|
768 | - $this->_stack[] = $c; |
|
795 | + while ( $c = $c->get_prev_sibling() ) { |
|
796 | + $this->_stack[] = $c; |
|
797 | + } |
|
769 | 798 | } |
770 | 799 | return $b; |
771 | 800 | } |
@@ -155,7 +155,15 @@ discard block |
||
155 | 155 | function get_id() { return $this->_frame->get_id(); } |
156 | 156 | function get_style() { return $this->_frame->get_style(); } |
157 | 157 | function get_original_style() { return $this->_frame->get_original_style(); } |
158 | + |
|
159 | + /** |
|
160 | + * @param string $i |
|
161 | + */ |
|
158 | 162 | function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
163 | + |
|
164 | + /** |
|
165 | + * @param string $i |
|
166 | + */ |
|
159 | 167 | function get_position($i = null) { return $this->_frame->get_position($i); } |
160 | 168 | function get_dompdf() { return $this->_dompdf; } |
161 | 169 | // function get_decorator() { |
@@ -173,6 +181,12 @@ discard block |
||
173 | 181 | function set_id($id) { $this->_frame->set_id($id); } |
174 | 182 | function set_style(Style $style) { $this->_frame->set_style($style); } |
175 | 183 | |
184 | + /** |
|
185 | + * @param double $x |
|
186 | + * @param double $y |
|
187 | + * @param double $w |
|
188 | + * @param double $h |
|
189 | + */ |
|
176 | 190 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
177 | 191 | $this->_frame->set_containing_block($x, $y, $w, $h); |
178 | 192 | } |
@@ -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 |
@@ -102,8 +102,9 @@ discard block |
||
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | 104 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
106 | - $child->dispose(true); |
|
105 | + while ( $child = $this->get_first_child() ) { |
|
106 | + $child->dispose(true); |
|
107 | + } |
|
107 | 108 | } |
108 | 109 | |
109 | 110 | unset($this->_root); |
@@ -134,8 +135,9 @@ discard block |
||
134 | 135 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 136 | $deco->set_root($this->_root); |
136 | 137 | |
137 | - foreach ($this->get_children() as $child) |
|
138 | - $deco->append_child($child->deep_copy()); |
|
138 | + foreach ($this->get_children() as $child) { |
|
139 | + $deco->append_child($child->deep_copy()); |
|
140 | + } |
|
139 | 141 | |
140 | 142 | return $deco; |
141 | 143 | } |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | $this->_frame->reset(); |
147 | 149 | |
148 | 150 | // Reset all children |
149 | - foreach ($this->get_children() as $child) |
|
150 | - $child->reset(); |
|
151 | + foreach ($this->get_children() as $child) { |
|
152 | + $child->reset(); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | } |
153 | 156 | |
@@ -183,42 +186,49 @@ discard block |
||
183 | 186 | function __toString() { return $this->_frame->__toString(); } |
184 | 187 | |
185 | 188 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
187 | - $child = $child->_frame; |
|
189 | + while ( $child instanceof Frame_Decorator ) { |
|
190 | + $child = $child->_frame; |
|
191 | + } |
|
188 | 192 | |
189 | 193 | $this->_frame->prepend_child($child, $update_node); |
190 | 194 | } |
191 | 195 | |
192 | 196 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
194 | - $child = $child->_frame; |
|
197 | + while ( $child instanceof Frame_Decorator ) { |
|
198 | + $child = $child->_frame; |
|
199 | + } |
|
195 | 200 | |
196 | 201 | $this->_frame->append_child($child, $update_node); |
197 | 202 | } |
198 | 203 | |
199 | 204 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
201 | - $new_child = $new_child->_frame; |
|
205 | + while ( $new_child instanceof Frame_Decorator ) { |
|
206 | + $new_child = $new_child->_frame; |
|
207 | + } |
|
202 | 208 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
204 | - $ref = $ref->_frame; |
|
209 | + if ( $ref instanceof Frame_Decorator ) { |
|
210 | + $ref = $ref->_frame; |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 214 | } |
208 | 215 | |
209 | 216 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
211 | - $new_child = $new_child->_frame; |
|
217 | + while ( $new_child instanceof Frame_Decorator ) { |
|
218 | + $new_child = $new_child->_frame; |
|
219 | + } |
|
212 | 220 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
214 | - $ref = $ref->_frame; |
|
221 | + while ( $ref instanceof Frame_Decorator ) { |
|
222 | + $ref = $ref->_frame; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 226 | } |
218 | 227 | |
219 | 228 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
221 | - $child = $new_child->_frame; |
|
229 | + while ( $child instanceof Frame_Decorator ) { |
|
230 | + $child = $new_child->_frame; |
|
231 | + } |
|
222 | 232 | |
223 | 233 | $this->_frame->remove_child($child, $update_node); |
224 | 234 | } |
@@ -230,61 +240,71 @@ discard block |
||
230 | 240 | $p = $this->_frame->get_parent(); |
231 | 241 | |
232 | 242 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
234 | - $deco = $tmp; |
|
243 | + while ( $tmp = $deco->get_decorator() ) { |
|
244 | + $deco = $tmp; |
|
245 | + } |
|
235 | 246 | return $deco; |
236 | - } else if ( $p ) |
|
237 | - return $p; |
|
238 | - else |
|
239 | - return null; |
|
247 | + } else if ( $p ) { |
|
248 | + return $p; |
|
249 | + } else { |
|
250 | + return null; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | |
242 | 254 | function get_first_child() { |
243 | 255 | $c = $this->_frame->get_first_child(); |
244 | 256 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
246 | - $deco = $tmp; |
|
257 | + while ( $tmp = $deco->get_decorator() ) { |
|
258 | + $deco = $tmp; |
|
259 | + } |
|
247 | 260 | return $deco; |
248 | - } else if ( $c ) |
|
249 | - return $c; |
|
250 | - else |
|
251 | - return null; |
|
261 | + } else if ( $c ) { |
|
262 | + return $c; |
|
263 | + } else { |
|
264 | + return null; |
|
265 | + } |
|
252 | 266 | } |
253 | 267 | |
254 | 268 | function get_last_child() { |
255 | 269 | $c = $this->_frame->get_last_child(); |
256 | 270 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
258 | - $deco = $tmp; |
|
271 | + while ( $tmp = $deco->get_decorator() ) { |
|
272 | + $deco = $tmp; |
|
273 | + } |
|
259 | 274 | return $deco; |
260 | - } else if ( $c ) |
|
261 | - return $c; |
|
262 | - else |
|
263 | - return null; |
|
275 | + } else if ( $c ) { |
|
276 | + return $c; |
|
277 | + } else { |
|
278 | + return null; |
|
279 | + } |
|
264 | 280 | } |
265 | 281 | |
266 | 282 | function get_prev_sibling() { |
267 | 283 | $s = $this->_frame->get_prev_sibling(); |
268 | 284 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
270 | - $deco = $tmp; |
|
285 | + while ( $tmp = $deco->get_decorator() ) { |
|
286 | + $deco = $tmp; |
|
287 | + } |
|
271 | 288 | return $deco; |
272 | - } else if ( $s ) |
|
273 | - return $s; |
|
274 | - else |
|
275 | - return null; |
|
289 | + } else if ( $s ) { |
|
290 | + return $s; |
|
291 | + } else { |
|
292 | + return null; |
|
293 | + } |
|
276 | 294 | } |
277 | 295 | |
278 | 296 | function get_next_sibling() { |
279 | 297 | $s = $this->_frame->get_next_sibling(); |
280 | 298 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
282 | - $deco = $tmp; |
|
299 | + while ( $tmp = $deco->get_decorator() ) { |
|
300 | + $deco = $tmp; |
|
301 | + } |
|
283 | 302 | return $deco; |
284 | - } else if ( $s ) |
|
285 | - return $s; |
|
286 | - else |
|
287 | - return null; |
|
303 | + } else if ( $s ) { |
|
304 | + return $s; |
|
305 | + } else { |
|
306 | + return null; |
|
307 | + } |
|
288 | 308 | } |
289 | 309 | |
290 | 310 | function get_children() { |
@@ -299,16 +319,18 @@ discard block |
||
299 | 319 | |
300 | 320 | function set_positioner(Positioner $posn) { |
301 | 321 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
303 | - $this->_frame->set_positioner($posn); |
|
322 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
323 | + $this->_frame->set_positioner($posn); |
|
324 | + } |
|
304 | 325 | } |
305 | 326 | |
306 | 327 | //........................................................................ |
307 | 328 | |
308 | 329 | function set_reflower(Frame_Reflower $reflower) { |
309 | 330 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
331 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
332 | + $this->_frame->set_reflower( $reflower ); |
|
333 | + } |
|
312 | 334 | } |
313 | 335 | |
314 | 336 | function get_reflower() { return $this->_reflower; } |
@@ -317,8 +339,9 @@ discard block |
||
317 | 339 | |
318 | 340 | function set_root(Frame $root) { |
319 | 341 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | - $this->_frame->set_root($root); |
|
342 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
343 | + $this->_frame->set_root($root); |
|
344 | + } |
|
322 | 345 | } |
323 | 346 | |
324 | 347 | function get_root() { return $this->_root; } |
@@ -331,8 +354,9 @@ discard block |
||
331 | 354 | $p = $this->get_parent(); |
332 | 355 | |
333 | 356 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | - break; |
|
357 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) { |
|
358 | + break; |
|
359 | + } |
|
336 | 360 | |
337 | 361 | $p = $p->get_parent(); |
338 | 362 | } |
@@ -358,8 +382,9 @@ discard block |
||
358 | 382 | return; |
359 | 383 | } |
360 | 384 | |
361 | - if ( $child->get_parent() !== $this ) |
|
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
385 | + if ( $child->get_parent() !== $this ) { |
|
386 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
387 | + } |
|
363 | 388 | |
364 | 389 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 390 | $split->reset(); |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-06-02 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-06-02 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,62 +46,62 @@ discard block |
||
47 | 46 | */ |
48 | 47 | abstract class Frame_Decorator extends Frame { |
49 | 48 | |
50 | - /** |
|
51 | - * The root node of the DOM tree |
|
52 | - * |
|
53 | - * @var Frame |
|
54 | - */ |
|
55 | - protected $_root; |
|
56 | - |
|
57 | - /** |
|
58 | - * The decorated frame |
|
59 | - * |
|
60 | - * @var Frame |
|
61 | - */ |
|
62 | - protected $_frame; |
|
63 | - |
|
64 | - /** |
|
65 | - * Positioner object used to position this frame (Strategy pattern) |
|
66 | - * |
|
67 | - * @var Positioner |
|
68 | - */ |
|
69 | - protected $_positioner; |
|
70 | - |
|
71 | - /** |
|
72 | - * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
73 | - * |
|
74 | - * @var Frame_Reflower |
|
75 | - */ |
|
76 | - protected $_reflower; |
|
49 | + /** |
|
50 | + * The root node of the DOM tree |
|
51 | + * |
|
52 | + * @var Frame |
|
53 | + */ |
|
54 | + protected $_root; |
|
55 | + |
|
56 | + /** |
|
57 | + * The decorated frame |
|
58 | + * |
|
59 | + * @var Frame |
|
60 | + */ |
|
61 | + protected $_frame; |
|
62 | + |
|
63 | + /** |
|
64 | + * Positioner object used to position this frame (Strategy pattern) |
|
65 | + * |
|
66 | + * @var Positioner |
|
67 | + */ |
|
68 | + protected $_positioner; |
|
69 | + |
|
70 | + /** |
|
71 | + * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
72 | + * |
|
73 | + * @var Frame_Reflower |
|
74 | + */ |
|
75 | + protected $_reflower; |
|
77 | 76 | |
78 | - /** |
|
79 | - * Reference to the current dompdf instance |
|
80 | - * |
|
81 | - * @var DOMPDF |
|
82 | - */ |
|
83 | - protected $_dompdf; |
|
84 | - |
|
85 | - /** |
|
86 | - * Class constructor |
|
87 | - * |
|
88 | - * @param Frame $frame the decoration target |
|
89 | - */ |
|
90 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
77 | + /** |
|
78 | + * Reference to the current dompdf instance |
|
79 | + * |
|
80 | + * @var DOMPDF |
|
81 | + */ |
|
82 | + protected $_dompdf; |
|
83 | + |
|
84 | + /** |
|
85 | + * Class constructor |
|
86 | + * |
|
87 | + * @param Frame $frame the decoration target |
|
88 | + */ |
|
89 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
91 | 90 | $this->_frame = $frame; |
92 | 91 | $this->_root = null; |
93 | 92 | $this->_dompdf = $dompdf; |
94 | 93 | $frame->set_decorator($this); |
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * "Destructor": foribly free all references held by this object |
|
99 | - * |
|
100 | - * @param bool $recursive if true, call dispose on all children |
|
101 | - */ |
|
102 | - function dispose($recursive = false) { |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * "Destructor": foribly free all references held by this object |
|
98 | + * |
|
99 | + * @param bool $recursive if true, call dispose on all children |
|
100 | + */ |
|
101 | + function dispose($recursive = false) { |
|
103 | 102 | |
104 | 103 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + while ( $child = $this->get_first_child() ) |
|
106 | 105 | $child->dispose(true); |
107 | 106 | } |
108 | 107 | |
@@ -112,52 +111,52 @@ discard block |
||
112 | 111 | unset($this->_positioner); |
113 | 112 | unset($this->_reflower); |
114 | 113 | |
115 | - } |
|
114 | + } |
|
116 | 115 | |
117 | - // Return a copy of this frame with $node as its node |
|
118 | - function copy(DomNode $node) { |
|
116 | + // Return a copy of this frame with $node as its node |
|
117 | + function copy(DomNode $node) { |
|
119 | 118 | $frame = new Frame($node); |
120 | 119 | $frame->set_style(clone $this->_frame->get_original_style()); |
121 | 120 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
122 | 121 | $deco->set_root($this->_root); |
123 | 122 | return $deco; |
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Create a deep copy: copy this node and all children |
|
128 | - * |
|
129 | - * @return Frame |
|
130 | - */ |
|
131 | - function deep_copy() { |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Create a deep copy: copy this node and all children |
|
127 | + * |
|
128 | + * @return Frame |
|
129 | + */ |
|
130 | + function deep_copy() { |
|
132 | 131 | $frame = new Frame($this->get_node()->cloneNode()); |
133 | 132 | $frame->set_style(clone $this->_frame->get_original_style()); |
134 | 133 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 134 | $deco->set_root($this->_root); |
136 | 135 | |
137 | 136 | foreach ($this->get_children() as $child) |
138 | - $deco->append_child($child->deep_copy()); |
|
137 | + $deco->append_child($child->deep_copy()); |
|
139 | 138 | |
140 | 139 | return $deco; |
141 | - } |
|
142 | - //........................................................................ |
|
140 | + } |
|
141 | + //........................................................................ |
|
143 | 142 | |
144 | - // Delegate calls to decorated frame object |
|
145 | - function reset() { |
|
143 | + // Delegate calls to decorated frame object |
|
144 | + function reset() { |
|
146 | 145 | $this->_frame->reset(); |
147 | 146 | |
148 | 147 | // Reset all children |
149 | 148 | foreach ($this->get_children() as $child) |
150 | - $child->reset(); |
|
149 | + $child->reset(); |
|
151 | 150 | |
152 | - } |
|
151 | + } |
|
153 | 152 | |
154 | - function get_node() { return $this->_frame->get_node(); } |
|
155 | - function get_id() { return $this->_frame->get_id(); } |
|
156 | - function get_style() { return $this->_frame->get_style(); } |
|
157 | - function get_original_style() { return $this->_frame->get_original_style(); } |
|
158 | - function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
159 | - function get_position($i = null) { return $this->_frame->get_position($i); } |
|
160 | - function get_dompdf() { return $this->_dompdf; } |
|
153 | + function get_node() { return $this->_frame->get_node(); } |
|
154 | + function get_id() { return $this->_frame->get_id(); } |
|
155 | + function get_style() { return $this->_frame->get_style(); } |
|
156 | + function get_original_style() { return $this->_frame->get_original_style(); } |
|
157 | + function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
158 | + function get_position($i = null) { return $this->_frame->get_position($i); } |
|
159 | + function get_dompdf() { return $this->_dompdf; } |
|
161 | 160 | // function get_decorator() { |
162 | 161 | // if ( isset($this->_decorator) ) |
163 | 162 | // return $this->_decorator; |
@@ -165,201 +164,201 @@ discard block |
||
165 | 164 | // return $this; |
166 | 165 | // } |
167 | 166 | |
168 | - function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
169 | - function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
170 | - function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
171 | - function get_border_box() { return $this->_frame->get_border_box(); } |
|
167 | + function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
168 | + function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
169 | + function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
170 | + function get_border_box() { return $this->_frame->get_border_box(); } |
|
172 | 171 | |
173 | - function set_id($id) { $this->_frame->set_id($id); } |
|
174 | - function set_style(Style $style) { $this->_frame->set_style($style); } |
|
172 | + function set_id($id) { $this->_frame->set_id($id); } |
|
173 | + function set_style(Style $style) { $this->_frame->set_style($style); } |
|
175 | 174 | |
176 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
175 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
177 | 176 | $this->_frame->set_containing_block($x, $y, $w, $h); |
178 | - } |
|
177 | + } |
|
179 | 178 | |
180 | - function set_position($x = null, $y = null) { |
|
179 | + function set_position($x = null, $y = null) { |
|
181 | 180 | $this->_frame->set_position($x, $y); |
182 | - } |
|
183 | - function __toString() { return $this->_frame->__toString(); } |
|
181 | + } |
|
182 | + function __toString() { return $this->_frame->__toString(); } |
|
184 | 183 | |
185 | - function prepend_child(Frame $child, $update_node = true) { |
|
184 | + function prepend_child(Frame $child, $update_node = true) { |
|
186 | 185 | while ( $child instanceof Frame_Decorator ) |
187 | - $child = $child->_frame; |
|
186 | + $child = $child->_frame; |
|
188 | 187 | |
189 | 188 | $this->_frame->prepend_child($child, $update_node); |
190 | - } |
|
189 | + } |
|
191 | 190 | |
192 | - function append_child(Frame $child, $update_node = true) { |
|
191 | + function append_child(Frame $child, $update_node = true) { |
|
193 | 192 | while ( $child instanceof Frame_Decorator ) |
194 | - $child = $child->_frame; |
|
193 | + $child = $child->_frame; |
|
195 | 194 | |
196 | 195 | $this->_frame->append_child($child, $update_node); |
197 | - } |
|
196 | + } |
|
198 | 197 | |
199 | - function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
198 | + function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
200 | 199 | while ( $new_child instanceof Frame_Decorator ) |
201 | - $new_child = $new_child->_frame; |
|
200 | + $new_child = $new_child->_frame; |
|
202 | 201 | |
203 | 202 | if ( $ref instanceof Frame_Decorator ) |
204 | - $ref = $ref->_frame; |
|
203 | + $ref = $ref->_frame; |
|
205 | 204 | |
206 | 205 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | - function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
208 | + function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
210 | 209 | while ( $new_child instanceof Frame_Decorator ) |
211 | - $new_child = $new_child->_frame; |
|
210 | + $new_child = $new_child->_frame; |
|
212 | 211 | |
213 | 212 | while ( $ref instanceof Frame_Decorator ) |
214 | - $ref = $ref->_frame; |
|
213 | + $ref = $ref->_frame; |
|
215 | 214 | |
216 | 215 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | - } |
|
216 | + } |
|
218 | 217 | |
219 | - function remove_child(Frame $child, $update_node = true) { |
|
218 | + function remove_child(Frame $child, $update_node = true) { |
|
220 | 219 | while ( $child instanceof Frame_Decorator ) |
221 | - $child = $new_child->_frame; |
|
220 | + $child = $new_child->_frame; |
|
222 | 221 | |
223 | 222 | $this->_frame->remove_child($child, $update_node); |
224 | - } |
|
223 | + } |
|
225 | 224 | |
226 | - //........................................................................ |
|
225 | + //........................................................................ |
|
227 | 226 | |
228 | - function get_parent() { |
|
227 | + function get_parent() { |
|
229 | 228 | |
230 | 229 | $p = $this->_frame->get_parent(); |
231 | 230 | |
232 | 231 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + while ( $tmp = $deco->get_decorator() ) |
|
234 | 233 | $deco = $tmp; |
235 | - return $deco; |
|
234 | + return $deco; |
|
236 | 235 | } else if ( $p ) |
237 | - return $p; |
|
236 | + return $p; |
|
238 | 237 | else |
239 | - return null; |
|
240 | - } |
|
238 | + return null; |
|
239 | + } |
|
241 | 240 | |
242 | - function get_first_child() { |
|
241 | + function get_first_child() { |
|
243 | 242 | $c = $this->_frame->get_first_child(); |
244 | 243 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + while ( $tmp = $deco->get_decorator() ) |
|
246 | 245 | $deco = $tmp; |
247 | - return $deco; |
|
246 | + return $deco; |
|
248 | 247 | } else if ( $c ) |
249 | - return $c; |
|
248 | + return $c; |
|
250 | 249 | else |
251 | - return null; |
|
252 | - } |
|
250 | + return null; |
|
251 | + } |
|
253 | 252 | |
254 | - function get_last_child() { |
|
253 | + function get_last_child() { |
|
255 | 254 | $c = $this->_frame->get_last_child(); |
256 | 255 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + while ( $tmp = $deco->get_decorator() ) |
|
258 | 257 | $deco = $tmp; |
259 | - return $deco; |
|
258 | + return $deco; |
|
260 | 259 | } else if ( $c ) |
261 | - return $c; |
|
260 | + return $c; |
|
262 | 261 | else |
263 | - return null; |
|
264 | - } |
|
262 | + return null; |
|
263 | + } |
|
265 | 264 | |
266 | - function get_prev_sibling() { |
|
265 | + function get_prev_sibling() { |
|
267 | 266 | $s = $this->_frame->get_prev_sibling(); |
268 | 267 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + while ( $tmp = $deco->get_decorator() ) |
|
270 | 269 | $deco = $tmp; |
271 | - return $deco; |
|
270 | + return $deco; |
|
272 | 271 | } else if ( $s ) |
273 | - return $s; |
|
272 | + return $s; |
|
274 | 273 | else |
275 | - return null; |
|
276 | - } |
|
274 | + return null; |
|
275 | + } |
|
277 | 276 | |
278 | - function get_next_sibling() { |
|
277 | + function get_next_sibling() { |
|
279 | 278 | $s = $this->_frame->get_next_sibling(); |
280 | 279 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + while ( $tmp = $deco->get_decorator() ) |
|
282 | 281 | $deco = $tmp; |
283 | - return $deco; |
|
282 | + return $deco; |
|
284 | 283 | } else if ( $s ) |
285 | - return $s; |
|
284 | + return $s; |
|
286 | 285 | else |
287 | - return null; |
|
288 | - } |
|
286 | + return null; |
|
287 | + } |
|
289 | 288 | |
290 | - function get_children() { |
|
289 | + function get_children() { |
|
291 | 290 | return new FrameList($this); |
292 | - } |
|
291 | + } |
|
293 | 292 | |
294 | - function get_subtree() { |
|
293 | + function get_subtree() { |
|
295 | 294 | return new FrameTreeList($this); |
296 | - } |
|
295 | + } |
|
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_positioner(Positioner $posn) { |
|
299 | + function set_positioner(Positioner $posn) { |
|
301 | 300 | $this->_positioner = $posn; |
302 | 301 | if ( $this->_frame instanceof Frame_Decorator ) |
303 | - $this->_frame->set_positioner($posn); |
|
304 | - } |
|
302 | + $this->_frame->set_positioner($posn); |
|
303 | + } |
|
305 | 304 | |
306 | - //........................................................................ |
|
305 | + //........................................................................ |
|
307 | 306 | |
308 | - function set_reflower(Frame_Reflower $reflower) { |
|
307 | + function set_reflower(Frame_Reflower $reflower) { |
|
309 | 308 | $this->_reflower = $reflower; |
310 | 309 | if ( $this->_frame instanceof Frame_Decorator ) |
311 | - $this->_frame->set_reflower( $reflower ); |
|
312 | - } |
|
310 | + $this->_frame->set_reflower( $reflower ); |
|
311 | + } |
|
313 | 312 | |
314 | - function get_reflower() { return $this->_reflower; } |
|
313 | + function get_reflower() { return $this->_reflower; } |
|
315 | 314 | |
316 | - //........................................................................ |
|
315 | + //........................................................................ |
|
317 | 316 | |
318 | - function set_root(Frame $root) { |
|
317 | + function set_root(Frame $root) { |
|
319 | 318 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
319 | + if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | 320 | $this->_frame->set_root($root); |
322 | - } |
|
321 | + } |
|
323 | 322 | |
324 | - function get_root() { return $this->_root; } |
|
323 | + function get_root() { return $this->_root; } |
|
325 | 324 | |
326 | - //........................................................................ |
|
325 | + //........................................................................ |
|
327 | 326 | |
328 | - function find_block_parent() { |
|
327 | + function find_block_parent() { |
|
329 | 328 | |
330 | 329 | // Find our nearest block level parent |
331 | 330 | $p = $this->get_parent(); |
332 | 331 | |
333 | 332 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | 334 | break; |
336 | 335 | |
337 | - $p = $p->get_parent(); |
|
336 | + $p = $p->get_parent(); |
|
338 | 337 | } |
339 | 338 | |
340 | 339 | return $p; |
341 | - } |
|
340 | + } |
|
342 | 341 | |
343 | - //........................................................................ |
|
342 | + //........................................................................ |
|
344 | 343 | |
345 | - /** |
|
346 | - * split this frame at $child. |
|
347 | - * |
|
348 | - * The current frame is cloned and $child and all children following |
|
349 | - * $child are added to the clone. The clone is then passed to the |
|
350 | - * current frame's parent->split() method. |
|
351 | - * |
|
352 | - * @param Frame $child |
|
353 | - */ |
|
354 | - function split($child = null) { |
|
344 | + /** |
|
345 | + * split this frame at $child. |
|
346 | + * |
|
347 | + * The current frame is cloned and $child and all children following |
|
348 | + * $child are added to the clone. The clone is then passed to the |
|
349 | + * current frame's parent->split() method. |
|
350 | + * |
|
351 | + * @param Frame $child |
|
352 | + */ |
|
353 | + function split($child = null) { |
|
355 | 354 | |
356 | 355 | if ( is_null( $child ) ) { |
357 | - $this->get_parent()->split($this); |
|
358 | - return; |
|
356 | + $this->get_parent()->split($this); |
|
357 | + return; |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | if ( $child->get_parent() !== $this ) |
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
361 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
363 | 362 | |
364 | 363 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 364 | $split->reset(); |
@@ -368,29 +367,29 @@ discard block |
||
368 | 367 | // Add $frame and all following siblings to the new split node |
369 | 368 | $iter = $child; |
370 | 369 | while ($iter) { |
371 | - $frame = $iter; |
|
372 | - $iter = $iter->get_next_sibling(); |
|
373 | - $frame->reset(); |
|
374 | - $split->append_child($frame); |
|
370 | + $frame = $iter; |
|
371 | + $iter = $iter->get_next_sibling(); |
|
372 | + $frame->reset(); |
|
373 | + $split->append_child($frame); |
|
375 | 374 | } |
376 | 375 | |
377 | 376 | $this->get_parent()->split($split); |
378 | - } |
|
377 | + } |
|
379 | 378 | |
380 | - //........................................................................ |
|
379 | + //........................................................................ |
|
381 | 380 | |
382 | - final function position() { $this->_positioner->position(); } |
|
381 | + final function position() { $this->_positioner->position(); } |
|
383 | 382 | |
384 | - final function reflow() { |
|
383 | + final function reflow() { |
|
385 | 384 | // Uncomment this to see the frames before they're laid out, instead of |
386 | 385 | // during rendering. |
387 | 386 | //echo $this->_frame; flush(); |
388 | 387 | $this->_reflower->reflow(); |
389 | - } |
|
388 | + } |
|
390 | 389 | |
391 | - final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
390 | + final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
392 | 391 | |
393 | - //........................................................................ |
|
392 | + //........................................................................ |
|
394 | 393 | |
395 | 394 | |
396 | 395 | } |
@@ -60,6 +60,10 @@ |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | + |
|
64 | + /** |
|
65 | + * @param DOMPDF $dompdf |
|
66 | + */ |
|
63 | 67 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | 68 | if ( is_null($dompdf) ) |
65 | 69 | throw new Exception("foo"); |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -52,119 +51,119 @@ discard block |
||
52 | 51 | */ |
53 | 52 | class Frame_Factory { |
54 | 53 | |
55 | - static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
54 | + static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
56 | 55 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | 56 | $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
58 | 57 | $root->set_decorator($frame); |
59 | 58 | return $frame; |
60 | - } |
|
59 | + } |
|
61 | 60 | |
62 | - // FIXME: this is admittedly a little smelly... |
|
63 | - static function decorate_frame(Frame $frame, $dompdf) { |
|
61 | + // FIXME: this is admittedly a little smelly... |
|
62 | + static function decorate_frame(Frame $frame, $dompdf) { |
|
64 | 63 | if ( is_null($dompdf) ) |
65 | - throw new Exception("foo"); |
|
64 | + throw new Exception("foo"); |
|
66 | 65 | switch ($frame->get_style()->display) { |
67 | 66 | |
68 | 67 | case "block": |
69 | 68 | $positioner = "Block"; |
70 | - $decorator = "Block"; |
|
71 | - $reflower = "Block"; |
|
72 | - break; |
|
69 | + $decorator = "Block"; |
|
70 | + $reflower = "Block"; |
|
71 | + break; |
|
73 | 72 | |
74 | 73 | case "inline-block": |
75 | 74 | $positioner = "Inline"; |
76 | - $decorator = "Block"; |
|
77 | - $reflower = "Block"; |
|
78 | - break; |
|
75 | + $decorator = "Block"; |
|
76 | + $reflower = "Block"; |
|
77 | + break; |
|
79 | 78 | |
80 | 79 | case "inline": |
81 | 80 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
81 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | 82 | $decorator = "Text"; |
84 | 83 | $reflower = "Text"; |
85 | - } else { |
|
84 | + } else { |
|
86 | 85 | $decorator = "Inline"; |
87 | 86 | $reflower = "Inline"; |
88 | - } |
|
89 | - break; |
|
87 | + } |
|
88 | + break; |
|
90 | 89 | |
91 | 90 | case "table": |
92 | 91 | $positioner = "Block"; |
93 | - $decorator = "Table"; |
|
94 | - $reflower = "Table"; |
|
95 | - break; |
|
92 | + $decorator = "Table"; |
|
93 | + $reflower = "Table"; |
|
94 | + break; |
|
96 | 95 | |
97 | 96 | case "inline-table": |
98 | 97 | $positioner = "Inline"; |
99 | - $decorator = "Table"; |
|
100 | - $reflower = "Table"; |
|
101 | - break; |
|
98 | + $decorator = "Table"; |
|
99 | + $reflower = "Table"; |
|
100 | + break; |
|
102 | 101 | |
103 | 102 | case "table-row-group": |
104 | 103 | case "table-header-group": |
105 | 104 | case "table-footer-group": |
106 | 105 | $positioner = "Null"; |
107 | - $decorator = "Table_Row_Group"; |
|
108 | - $reflower = "Table_Row_Group"; |
|
109 | - break; |
|
106 | + $decorator = "Table_Row_Group"; |
|
107 | + $reflower = "Table_Row_Group"; |
|
108 | + break; |
|
110 | 109 | |
111 | 110 | case "table-row": |
112 | 111 | $positioner = "Null"; |
113 | - $decorator = "Table_Row"; |
|
114 | - $reflower = "Table_Row"; |
|
115 | - break; |
|
112 | + $decorator = "Table_Row"; |
|
113 | + $reflower = "Table_Row"; |
|
114 | + break; |
|
116 | 115 | |
117 | 116 | case "table-cell": |
118 | 117 | $positioner = "Table_Cell"; |
119 | - $decorator = "Table_Cell"; |
|
120 | - $reflower = "Table_Cell"; |
|
121 | - break; |
|
118 | + $decorator = "Table_Cell"; |
|
119 | + $reflower = "Table_Cell"; |
|
120 | + break; |
|
122 | 121 | |
123 | 122 | case "list-item": |
124 | 123 | $positioner = "Block"; |
125 | - $decorator = "Block"; |
|
126 | - $reflower = "Block"; |
|
127 | - break; |
|
124 | + $decorator = "Block"; |
|
125 | + $reflower = "Block"; |
|
126 | + break; |
|
128 | 127 | |
129 | 128 | case "-dompdf-list-bullet": |
130 | 129 | if ( $frame->get_style()->list_style_position === "inside" ) |
131 | 130 | $positioner = "Inline"; |
132 | - else |
|
131 | + else |
|
133 | 132 | $positioner = "List_Bullet"; |
134 | 133 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
134 | + if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | 135 | $decorator = "List_Bullet_Image"; |
137 | - else |
|
136 | + else |
|
138 | 137 | $decorator = "List_Bullet"; |
139 | 138 | |
140 | - $reflower = "List_Bullet"; |
|
141 | - break; |
|
139 | + $reflower = "List_Bullet"; |
|
140 | + break; |
|
142 | 141 | |
143 | 142 | case "-dompdf-image": |
144 | 143 | $positioner = "Inline"; |
145 | - $decorator = "Image"; |
|
146 | - $reflower = "Image"; |
|
147 | - break; |
|
144 | + $decorator = "Image"; |
|
145 | + $reflower = "Image"; |
|
146 | + break; |
|
148 | 147 | |
149 | 148 | case "-dompdf-br": |
150 | 149 | $positioner = "Inline"; |
151 | - $decorator = "Inline"; |
|
152 | - $reflower = "Inline"; |
|
153 | - break; |
|
150 | + $decorator = "Inline"; |
|
151 | + $reflower = "Inline"; |
|
152 | + break; |
|
154 | 153 | |
155 | 154 | default: |
156 | 155 | // FIXME: should throw some sort of warning or something? |
157 | 156 | case "none": |
158 | 157 | $positioner = "Null"; |
159 | - $decorator = "Null"; |
|
160 | - $reflower = "Null"; |
|
161 | - break; |
|
158 | + $decorator = "Null"; |
|
159 | + $reflower = "Null"; |
|
160 | + break; |
|
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | 164 | if ( $frame->get_style()->position === "absolute" || |
166 | 165 | $frame->get_style()->position === "fixed" ) |
167 | - $positioner = "Absolute"; |
|
166 | + $positioner = "Absolute"; |
|
168 | 167 | |
169 | 168 | $positioner .= "_Positioner"; |
170 | 169 | $decorator .= "_Frame_Decorator"; |
@@ -176,10 +175,10 @@ discard block |
||
176 | 175 | |
177 | 176 | // Generated content is a special case |
178 | 177 | if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
179 | - // Decorate the reflower |
|
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
182 | - $reflow = $gen; |
|
178 | + // Decorate the reflower |
|
179 | + $gen = new Generated_Frame_Reflower( $deco ); |
|
180 | + $gen->set_reflower( $reflow ); |
|
181 | + $reflow = $gen; |
|
183 | 182 | } |
184 | 183 | |
185 | 184 | $deco->set_reflower( $reflow ); |
@@ -204,6 +203,6 @@ discard block |
||
204 | 203 | // } |
205 | 204 | |
206 | 205 | return $deco; |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | 208 | } |
@@ -65,100 +65,100 @@ |
||
65 | 65 | throw new Exception("foo"); |
66 | 66 | switch ($frame->get_style()->display) { |
67 | 67 | |
68 | - case "block": |
|
69 | - $positioner = "Block"; |
|
70 | - $decorator = "Block"; |
|
71 | - $reflower = "Block"; |
|
72 | - break; |
|
68 | + case "block": |
|
69 | + $positioner = "Block"; |
|
70 | + $decorator = "Block"; |
|
71 | + $reflower = "Block"; |
|
72 | + break; |
|
73 | 73 | |
74 | - case "inline-block": |
|
75 | - $positioner = "Inline"; |
|
76 | - $decorator = "Block"; |
|
77 | - $reflower = "Block"; |
|
78 | - break; |
|
79 | - |
|
80 | - case "inline": |
|
81 | - $positioner = "Inline"; |
|
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | - $decorator = "Text"; |
|
84 | - $reflower = "Text"; |
|
85 | - } else { |
|
86 | - $decorator = "Inline"; |
|
87 | - $reflower = "Inline"; |
|
88 | - } |
|
89 | - break; |
|
90 | - |
|
91 | - case "table": |
|
92 | - $positioner = "Block"; |
|
93 | - $decorator = "Table"; |
|
94 | - $reflower = "Table"; |
|
95 | - break; |
|
74 | + case "inline-block": |
|
75 | + $positioner = "Inline"; |
|
76 | + $decorator = "Block"; |
|
77 | + $reflower = "Block"; |
|
78 | + break; |
|
79 | + |
|
80 | + case "inline": |
|
81 | + $positioner = "Inline"; |
|
82 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | + $decorator = "Text"; |
|
84 | + $reflower = "Text"; |
|
85 | + } else { |
|
86 | + $decorator = "Inline"; |
|
87 | + $reflower = "Inline"; |
|
88 | + } |
|
89 | + break; |
|
90 | + |
|
91 | + case "table": |
|
92 | + $positioner = "Block"; |
|
93 | + $decorator = "Table"; |
|
94 | + $reflower = "Table"; |
|
95 | + break; |
|
96 | 96 | |
97 | - case "inline-table": |
|
98 | - $positioner = "Inline"; |
|
99 | - $decorator = "Table"; |
|
100 | - $reflower = "Table"; |
|
101 | - break; |
|
102 | - |
|
103 | - case "table-row-group": |
|
104 | - case "table-header-group": |
|
105 | - case "table-footer-group": |
|
106 | - $positioner = "Null"; |
|
107 | - $decorator = "Table_Row_Group"; |
|
108 | - $reflower = "Table_Row_Group"; |
|
109 | - break; |
|
97 | + case "inline-table": |
|
98 | + $positioner = "Inline"; |
|
99 | + $decorator = "Table"; |
|
100 | + $reflower = "Table"; |
|
101 | + break; |
|
102 | + |
|
103 | + case "table-row-group": |
|
104 | + case "table-header-group": |
|
105 | + case "table-footer-group": |
|
106 | + $positioner = "Null"; |
|
107 | + $decorator = "Table_Row_Group"; |
|
108 | + $reflower = "Table_Row_Group"; |
|
109 | + break; |
|
110 | 110 | |
111 | - case "table-row": |
|
112 | - $positioner = "Null"; |
|
113 | - $decorator = "Table_Row"; |
|
114 | - $reflower = "Table_Row"; |
|
115 | - break; |
|
116 | - |
|
117 | - case "table-cell": |
|
118 | - $positioner = "Table_Cell"; |
|
119 | - $decorator = "Table_Cell"; |
|
120 | - $reflower = "Table_Cell"; |
|
121 | - break; |
|
111 | + case "table-row": |
|
112 | + $positioner = "Null"; |
|
113 | + $decorator = "Table_Row"; |
|
114 | + $reflower = "Table_Row"; |
|
115 | + break; |
|
116 | + |
|
117 | + case "table-cell": |
|
118 | + $positioner = "Table_Cell"; |
|
119 | + $decorator = "Table_Cell"; |
|
120 | + $reflower = "Table_Cell"; |
|
121 | + break; |
|
122 | 122 | |
123 | - case "list-item": |
|
124 | - $positioner = "Block"; |
|
125 | - $decorator = "Block"; |
|
126 | - $reflower = "Block"; |
|
127 | - break; |
|
128 | - |
|
129 | - 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"; |
|
123 | + case "list-item": |
|
124 | + $positioner = "Block"; |
|
125 | + $decorator = "Block"; |
|
126 | + $reflower = "Block"; |
|
127 | + break; |
|
128 | + |
|
129 | + 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"; |
|
139 | 139 | |
140 | - $reflower = "List_Bullet"; |
|
141 | - break; |
|
142 | - |
|
143 | - case "-dompdf-image": |
|
144 | - $positioner = "Inline"; |
|
145 | - $decorator = "Image"; |
|
146 | - $reflower = "Image"; |
|
147 | - break; |
|
140 | + $reflower = "List_Bullet"; |
|
141 | + break; |
|
142 | + |
|
143 | + case "-dompdf-image": |
|
144 | + $positioner = "Inline"; |
|
145 | + $decorator = "Image"; |
|
146 | + $reflower = "Image"; |
|
147 | + break; |
|
148 | 148 | |
149 | - case "-dompdf-br": |
|
150 | - $positioner = "Inline"; |
|
151 | - $decorator = "Inline"; |
|
152 | - $reflower = "Inline"; |
|
153 | - break; |
|
154 | - |
|
155 | - default: |
|
156 | - // FIXME: should throw some sort of warning or something? |
|
157 | - case "none": |
|
158 | - $positioner = "Null"; |
|
159 | - $decorator = "Null"; |
|
160 | - $reflower = "Null"; |
|
161 | - break; |
|
149 | + case "-dompdf-br": |
|
150 | + $positioner = "Inline"; |
|
151 | + $decorator = "Inline"; |
|
152 | + $reflower = "Inline"; |
|
153 | + break; |
|
154 | + |
|
155 | + default: |
|
156 | + // FIXME: should throw some sort of warning or something? |
|
157 | + case "none": |
|
158 | + $positioner = "Null"; |
|
159 | + $decorator = "Null"; |
|
160 | + $reflower = "Null"; |
|
161 | + break; |
|
162 | 162 | |
163 | 163 | } |
164 | 164 |
@@ -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" ) { |
@@ -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"; |
@@ -305,6 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | |
307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
308 | + |
|
309 | + /** |
|
310 | + * @param string|null $to_encoding |
|
311 | + */ |
|
308 | 312 | function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
309 | 313 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | 314 | return utf8_encode($data); |
@@ -327,6 +331,10 @@ discard block |
||
327 | 331 | } |
328 | 332 | |
329 | 333 | if ( !function_exists("mb_internal_encoding") ) { |
334 | + |
|
335 | + /** |
|
336 | + * @param string $encoding |
|
337 | + */ |
|
330 | 338 | function mb_internal_encoding($encoding=NULL) { |
331 | 339 | if (isset($encoding)) { |
332 | 340 | return true; |
@@ -365,6 +373,10 @@ discard block |
||
365 | 373 | } |
366 | 374 | |
367 | 375 | if ( !function_exists("mb_strtoupper") ) { |
376 | + |
|
377 | + /** |
|
378 | + * @param string $str |
|
379 | + */ |
|
368 | 380 | function mb_strtoupper($str) { |
369 | 381 | return strtoupper($str); |
370 | 382 | } |
@@ -380,6 +392,10 @@ discard block |
||
380 | 392 | } |
381 | 393 | |
382 | 394 | if ( !function_exists("mb_substr_count") ) { |
395 | + |
|
396 | + /** |
|
397 | + * @param string $needle |
|
398 | + */ |
|
383 | 399 | function mb_substr_count($haystack, $needle) { |
384 | 400 | return substr_count($haystack, $needle); |
385 | 401 | } |
@@ -442,6 +458,7 @@ discard block |
||
442 | 458 | * Print debug messages |
443 | 459 | * |
444 | 460 | * @param string $type The type of debug messages to print |
461 | + * @param string $msg |
|
445 | 462 | */ |
446 | 463 | function dompdf_debug($type, $msg) { |
447 | 464 | global $_DOMPDF_DEBUG_TYPES; |
@@ -273,20 +273,20 @@ |
||
273 | 273 | $ret = ""; |
274 | 274 | switch (mb_strlen($num)) { |
275 | 275 | |
276 | - case 4: |
|
277 | - $ret .= $thou[$num[3]]; |
|
276 | + case 4: |
|
277 | + $ret .= $thou[$num[3]]; |
|
278 | 278 | |
279 | - case 3: |
|
280 | - $ret .= $hund[$num[2]]; |
|
279 | + case 3: |
|
280 | + $ret .= $hund[$num[2]]; |
|
281 | 281 | |
282 | - case 2: |
|
283 | - $ret .= $tens[$num[1]]; |
|
282 | + case 2: |
|
283 | + $ret .= $tens[$num[1]]; |
|
284 | 284 | |
285 | - case 1: |
|
286 | - $ret .= $ones[$num[0]]; |
|
285 | + case 1: |
|
286 | + $ret .= $ones[$num[0]]; |
|
287 | 287 | |
288 | - default: |
|
289 | - break; |
|
288 | + default: |
|
289 | + break; |
|
290 | 290 | } |
291 | 291 | return $ret; |
292 | 292 |
@@ -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)); |
@@ -63,17 +63,20 @@ discard block |
||
63 | 63 | */ |
64 | 64 | if ( !function_exists("pre_r") ) { |
65 | 65 | function pre_r($mixed, $return = false) { |
66 | - if ($return) |
|
67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
66 | + if ($return) { |
|
67 | + return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
68 | + } |
|
68 | 69 | |
69 | - if ( php_sapi_name() !== "cli") |
|
70 | - echo ("<pre>"); |
|
70 | + if ( php_sapi_name() !== "cli") { |
|
71 | + echo ("<pre>"); |
|
72 | + } |
|
71 | 73 | print_r($mixed); |
72 | 74 | |
73 | - if ( php_sapi_name() !== "cli") |
|
74 | - echo("</pre>"); |
|
75 | - else |
|
76 | - echo ("\n"); |
|
75 | + if ( php_sapi_name() !== "cli") { |
|
76 | + echo("</pre>"); |
|
77 | + } else { |
|
78 | + echo ("\n"); |
|
79 | + } |
|
77 | 80 | flush(); |
78 | 81 | |
79 | 82 | } |
@@ -89,12 +92,14 @@ discard block |
||
89 | 92 | */ |
90 | 93 | if ( !function_exists("pre_var_dump") ) { |
91 | 94 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
93 | - echo("<pre>"); |
|
95 | + if ( php_sapi_name() !== "cli") { |
|
96 | + echo("<pre>"); |
|
97 | + } |
|
94 | 98 | var_dump($mixed); |
95 | - if ( php_sapi_name() !== "cli") |
|
96 | - echo("</pre>"); |
|
97 | -} |
|
99 | + if ( php_sapi_name() !== "cli") { |
|
100 | + echo("</pre>"); |
|
101 | + } |
|
102 | + } |
|
98 | 103 | } |
99 | 104 | |
100 | 105 | /** |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | // Is the url already fully qualified? |
124 | - if ( mb_strpos($url, "://") !== false ) |
|
125 | - return $url; |
|
129 | + if ( mb_strpos($url, "://") !== false ) { |
|
130 | + return $url; |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $ret = $protocol; |
128 | 134 | |
@@ -170,24 +176,29 @@ discard block |
||
170 | 176 | |
171 | 177 | if ( isset($arr["scheme"]) && |
172 | 178 | $arr["scheme"] !== "file" && |
173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
179 | + mb_strlen($arr["scheme"]) > 1 ) { |
|
180 | + // Exclude windows drive letters... |
|
174 | 181 | { |
175 | 182 | $protocol = $arr["scheme"] . "://"; |
183 | + } |
|
176 | 184 | |
177 | 185 | if ( isset($arr["user"]) ) { |
178 | 186 | $host .= $arr["user"]; |
179 | 187 | |
180 | - if ( isset($arr["pass"]) ) |
|
181 | - $host .= "@" . $arr["pass"]; |
|
188 | + if ( isset($arr["pass"]) ) { |
|
189 | + $host .= "@" . $arr["pass"]; |
|
190 | + } |
|
182 | 191 | |
183 | 192 | $host .= ":"; |
184 | 193 | } |
185 | 194 | |
186 | - if ( isset($arr["host"]) ) |
|
187 | - $host .= $arr["host"]; |
|
195 | + if ( isset($arr["host"]) ) { |
|
196 | + $host .= $arr["host"]; |
|
197 | + } |
|
188 | 198 | |
189 | - if ( isset($arr["port"]) ) |
|
190 | - $host .= ":" . $arr["port"]; |
|
199 | + if ( isset($arr["port"]) ) { |
|
200 | + $host .= ":" . $arr["port"]; |
|
201 | + } |
|
191 | 202 | |
192 | 203 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
193 | 204 | // Do we have a trailing slash? |
@@ -200,17 +211,20 @@ discard block |
||
200 | 211 | } |
201 | 212 | } |
202 | 213 | |
203 | - if ( isset($arr["query"]) ) |
|
204 | - $file .= "?" . $arr["query"]; |
|
214 | + if ( isset($arr["query"]) ) { |
|
215 | + $file .= "?" . $arr["query"]; |
|
216 | + } |
|
205 | 217 | |
206 | - if ( isset($arr["fragment"]) ) |
|
207 | - $file .= "#" . $arr["fragment"]; |
|
218 | + if ( isset($arr["fragment"]) ) { |
|
219 | + $file .= "#" . $arr["fragment"]; |
|
220 | + } |
|
208 | 221 | |
209 | 222 | } else { |
210 | 223 | |
211 | 224 | $i = mb_strpos($url, "file://"); |
212 | - if ( $i !== false) |
|
213 | - $url = mb_substr($url, $i + 7); |
|
225 | + if ( $i !== false) { |
|
226 | + $url = mb_substr($url, $i + 7); |
|
227 | + } |
|
214 | 228 | |
215 | 229 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
216 | 230 | // network filenames like //COMPU/SHARENAME |
@@ -262,11 +276,13 @@ discard block |
||
262 | 276 | "dc", "dcc", "dccc", "cm"); |
263 | 277 | static $thou = array("", "m", "mm", "mmm"); |
264 | 278 | |
265 | - if ( !is_numeric($num) ) |
|
266 | - throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
279 | + if ( !is_numeric($num) ) { |
|
280 | + throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
281 | + } |
|
267 | 282 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
269 | - return "(out of range)"; |
|
283 | + if ( $num > 4000 || $num < 0 ) { |
|
284 | + return "(out of range)"; |
|
285 | + } |
|
270 | 286 | |
271 | 287 | $num = strrev((string)$num); |
272 | 288 | |
@@ -372,10 +388,11 @@ discard block |
||
372 | 388 | |
373 | 389 | if ( !function_exists("mb_substr") ) { |
374 | 390 | function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
375 | - if ( is_null($length) ) |
|
376 | - return substr($str, $start); |
|
377 | - else |
|
378 | - return substr($str, $start, $length); |
|
391 | + if ( is_null($length) ) { |
|
392 | + return substr($str, $start); |
|
393 | + } else { |
|
394 | + return substr($str, $start, $length); |
|
395 | + } |
|
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
@@ -402,14 +419,17 @@ discard block |
||
402 | 419 | */ |
403 | 420 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 421 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
422 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) { |
|
423 | + // Not a warning or notice |
|
406 | 424 | throw new DOMPDF_Exception($errstr . " $errno"); |
425 | + } |
|
407 | 426 | |
408 | 427 | global $_dompdf_warnings; |
409 | 428 | global $_dompdf_show_warnings; |
410 | 429 | |
411 | - if ( $_dompdf_show_warnings ) |
|
412 | - echo $errstr . "\n"; |
|
430 | + if ( $_dompdf_show_warnings ) { |
|
431 | + echo $errstr . "\n"; |
|
432 | + } |
|
413 | 433 | |
414 | 434 | $_dompdf_warnings[] = $errstr; |
415 | 435 | } |
@@ -496,9 +516,10 @@ discard block |
||
496 | 516 | if ( !function_exists("mark_memusage") ) { |
497 | 517 | function mark_memusage($location) { |
498 | 518 | global $memusage; |
499 | - if ( isset($memusage) ) |
|
500 | - $memusage[$location] = memory_get_usage(); |
|
501 | -} |
|
519 | + if ( isset($memusage) ) { |
|
520 | + $memusage[$location] = memory_get_usage(); |
|
521 | + } |
|
522 | + } |
|
502 | 523 | } |
503 | 524 | |
504 | 525 | /** |
@@ -1,52 +1,52 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: functions.inc.php,v $ |
|
6 | - * Created on: 2004-08-04 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - * |
|
39 | - * Changes |
|
40 | - * @contributor Helmut Tischer <[email protected]> |
|
41 | - * @version 0.5.1.htischer.20090507 |
|
42 | - * - trailing slash of base_path in build_url is no longer optional when |
|
43 | - * required. This allows paths not ending in a slash, e.g. on dynamically |
|
44 | - * created sites with page id in the url parameters. |
|
45 | - * @version 20090601 |
|
46 | - * - fix windows paths |
|
47 | - * @version 20090610 |
|
48 | - * - relax windows path syntax, use uniform path delimiter. Used for background images. |
|
49 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: functions.inc.php,v $ |
|
6 | + * Created on: 2004-08-04 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 0.5.1.htischer.20090507 |
|
42 | + * - trailing slash of base_path in build_url is no longer optional when |
|
43 | + * required. This allows paths not ending in a slash, e.g. on dynamically |
|
44 | + * created sites with page id in the url parameters. |
|
45 | + * @version 20090601 |
|
46 | + * - fix windows paths |
|
47 | + * @version 20090610 |
|
48 | + * - relax windows path syntax, use uniform path delimiter. Used for background images. |
|
49 | + */ |
|
50 | 50 | |
51 | 51 | /* $Id: functions.inc.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
52 | 52 | |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | */ |
64 | 64 | if ( !function_exists("pre_r") ) { |
65 | 65 | function pre_r($mixed, $return = false) { |
66 | - if ($return) |
|
66 | + if ($return) |
|
67 | 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 | - print_r($mixed); |
|
71 | + print_r($mixed); |
|
72 | 72 | |
73 | - if ( php_sapi_name() !== "cli") |
|
73 | + if ( php_sapi_name() !== "cli") |
|
74 | 74 | echo("</pre>"); |
75 | - else |
|
75 | + else |
|
76 | 76 | echo ("\n"); |
77 | - flush(); |
|
77 | + flush(); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 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 | - var_dump($mixed); |
|
95 | - if ( php_sapi_name() !== "cli") |
|
94 | + var_dump($mixed); |
|
95 | + if ( php_sapi_name() !== "cli") |
|
96 | 96 | echo("</pre>"); |
97 | 97 | } |
98 | 98 | } |
@@ -115,41 +115,41 @@ 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 | 120 | return $protocol . $host . $base_path; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - // Is the url already fully qualified? |
|
124 | - if ( mb_strpos($url, "://") !== false ) |
|
123 | + // Is the url already fully qualified? |
|
124 | + if ( mb_strpos($url, "://") !== false ) |
|
125 | 125 | return $url; |
126 | 126 | |
127 | - $ret = $protocol; |
|
127 | + $ret = $protocol; |
|
128 | 128 | |
129 | - if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
129 | + if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
130 | 130 | //On Windows local file, an abs path can begin also with a '\' or a drive letter and colon |
131 | 131 | //drive: followed by a relative path would be a drive specific default folder. |
132 | 132 | //not known in php app code, treat as abs path |
133 | 133 | //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/')) |
134 | 134 | if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':'))) { |
135 | - // For rel path and local acess we ignore the host, and run the path through realpath() |
|
136 | - $ret .= realpath($base_path).'/'; |
|
135 | + // For rel path and local acess we ignore the host, and run the path through realpath() |
|
136 | + $ret .= realpath($base_path).'/'; |
|
137 | 137 | } |
138 | 138 | $ret .= $url; |
139 | 139 | return $ret; |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | - //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
142 | + //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
143 | + if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
144 | 144 | // Absolute path |
145 | 145 | $ret .= $host . $url; |
146 | - } else { |
|
146 | + } else { |
|
147 | 147 | // Relative path |
148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
149 | 149 | $ret .= $host . $base_path . $url; |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | - return $ret; |
|
152 | + return $ret; |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
@@ -161,56 +161,56 @@ discard block |
||
161 | 161 | * @return array |
162 | 162 | */ |
163 | 163 | function explode_url($url) { |
164 | - $protocol = ""; |
|
165 | - $host = ""; |
|
166 | - $path = ""; |
|
167 | - $file = ""; |
|
164 | + $protocol = ""; |
|
165 | + $host = ""; |
|
166 | + $path = ""; |
|
167 | + $file = ""; |
|
168 | 168 | |
169 | - $arr = parse_url($url); |
|
169 | + $arr = parse_url($url); |
|
170 | 170 | |
171 | - if ( isset($arr["scheme"]) && |
|
171 | + if ( isset($arr["scheme"]) && |
|
172 | 172 | $arr["scheme"] !== "file" && |
173 | 173 | mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
174 | 174 | { |
175 | 175 | $protocol = $arr["scheme"] . "://"; |
176 | 176 | |
177 | 177 | if ( isset($arr["user"]) ) { |
178 | - $host .= $arr["user"]; |
|
178 | + $host .= $arr["user"]; |
|
179 | 179 | |
180 | - if ( isset($arr["pass"]) ) |
|
180 | + if ( isset($arr["pass"]) ) |
|
181 | 181 | $host .= "@" . $arr["pass"]; |
182 | 182 | |
183 | - $host .= ":"; |
|
183 | + $host .= ":"; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | if ( isset($arr["host"]) ) |
187 | - $host .= $arr["host"]; |
|
187 | + $host .= $arr["host"]; |
|
188 | 188 | |
189 | 189 | if ( isset($arr["port"]) ) |
190 | - $host .= ":" . $arr["port"]; |
|
190 | + $host .= ":" . $arr["port"]; |
|
191 | 191 | |
192 | 192 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
193 | - // Do we have a trailing slash? |
|
194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
193 | + // Do we have a trailing slash? |
|
194 | + if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
195 | 195 | $path = $arr["path"]; |
196 | 196 | $file = ""; |
197 | - } else { |
|
197 | + } else { |
|
198 | 198 | $path = dirname($arr["path"]) . "/"; |
199 | 199 | $file = basename($arr["path"]); |
200 | - } |
|
200 | + } |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | if ( isset($arr["query"]) ) |
204 | - $file .= "?" . $arr["query"]; |
|
204 | + $file .= "?" . $arr["query"]; |
|
205 | 205 | |
206 | 206 | if ( isset($arr["fragment"]) ) |
207 | - $file .= "#" . $arr["fragment"]; |
|
207 | + $file .= "#" . $arr["fragment"]; |
|
208 | 208 | |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | |
211 | 211 | $i = mb_strpos($url, "file://"); |
212 | 212 | if ( $i !== false) |
213 | - $url = mb_substr($url, $i + 7); |
|
213 | + $url = mb_substr($url, $i + 7); |
|
214 | 214 | |
215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
216 | 216 | // network filenames like //COMPU/SHARENAME |
@@ -222,28 +222,28 @@ discard block |
||
222 | 222 | |
223 | 223 | // Check that the path exists |
224 | 224 | if ( $path !== false ) { |
225 | - $path .= '/'; |
|
225 | + $path .= '/'; |
|
226 | 226 | |
227 | 227 | } else { |
228 | - // generate a url to access the file if no real path found. |
|
229 | - $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
228 | + // generate a url to access the file if no real path found. |
|
229 | + $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
230 | 230 | |
231 | - $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
|
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 | - } else { |
|
235 | + } else { |
|
236 | 236 | $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
237 | - } |
|
237 | + } |
|
238 | + } |
|
238 | 239 | } |
239 | - } |
|
240 | - |
|
241 | - $ret = array($protocol, $host, $path, $file, |
|
242 | - "protocol" => $protocol, |
|
243 | - "host" => $host, |
|
244 | - "path" => $path, |
|
245 | - "file" => $file); |
|
246 | - return $ret; |
|
240 | + |
|
241 | + $ret = array($protocol, $host, $path, $file, |
|
242 | + "protocol" => $protocol, |
|
243 | + "host" => $host, |
|
244 | + "path" => $path, |
|
245 | + "file" => $file); |
|
246 | + return $ret; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -254,41 +254,41 @@ discard block |
||
254 | 254 | */ |
255 | 255 | function dec2roman($num) { |
256 | 256 | |
257 | - static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
258 | - "vi", "vii", "viii", "ix"); |
|
259 | - static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
260 | - "lx", "lxx", "lxxx", "xc"); |
|
261 | - static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
262 | - "dc", "dcc", "dccc", "cm"); |
|
263 | - static $thou = array("", "m", "mm", "mmm"); |
|
257 | + static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
258 | + "vi", "vii", "viii", "ix"); |
|
259 | + static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
260 | + "lx", "lxx", "lxxx", "xc"); |
|
261 | + static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
262 | + "dc", "dcc", "dccc", "cm"); |
|
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 | - $ret = ""; |
|
274 | - switch (mb_strlen($num)) { |
|
273 | + $ret = ""; |
|
274 | + switch (mb_strlen($num)) { |
|
275 | 275 | |
276 | - case 4: |
|
276 | + case 4: |
|
277 | 277 | $ret .= $thou[$num[3]]; |
278 | 278 | |
279 | - case 3: |
|
279 | + case 3: |
|
280 | 280 | $ret .= $hund[$num[2]]; |
281 | 281 | |
282 | - case 2: |
|
282 | + case 2: |
|
283 | 283 | $ret .= $tens[$num[1]]; |
284 | 284 | |
285 | - case 1: |
|
285 | + case 1: |
|
286 | 286 | $ret .= $ones[$num[0]]; |
287 | 287 | |
288 | - default: |
|
288 | + default: |
|
289 | 289 | break; |
290 | - } |
|
291 | - return $ret; |
|
290 | + } |
|
291 | + return $ret; |
|
292 | 292 | |
293 | 293 | } |
294 | 294 | |
@@ -305,84 +305,84 @@ discard block |
||
305 | 305 | */ |
306 | 306 | |
307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | - return utf8_encode($data); |
|
310 | + return utf8_encode($data); |
|
311 | 311 | } else { |
312 | - return utf8_decode($data); |
|
312 | + return utf8_decode($data); |
|
313 | + } |
|
313 | 314 | } |
314 | - } |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if ( !function_exists("mb_detect_encoding") ) { |
318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
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 | 323 | if ( !function_exists("mb_detect_order") ) { |
324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
324 | + function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
325 | 325 | return 'iso-8859-1'; |
326 | - } |
|
326 | + } |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | if ( !function_exists("mb_internal_encoding") ) { |
330 | - function mb_internal_encoding($encoding=NULL) { |
|
330 | + function mb_internal_encoding($encoding=NULL) { |
|
331 | 331 | if (isset($encoding)) { |
332 | - return true; |
|
332 | + return true; |
|
333 | 333 | } else { |
334 | - return 'iso-8859-1'; |
|
334 | + return 'iso-8859-1'; |
|
335 | + } |
|
335 | 336 | } |
336 | - } |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | if ( !function_exists("mb_strlen") ) { |
340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
340 | + function mb_strlen($str, $encoding='iso-8859-1') { |
|
341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
342 | - return strlen(utf8_encode($data)); |
|
342 | + return strlen(utf8_encode($data)); |
|
343 | 343 | } else { |
344 | - return strlen(utf8_decode($data)); |
|
344 | + return strlen(utf8_decode($data)); |
|
345 | + } |
|
345 | 346 | } |
346 | - } |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | if ( !function_exists("mb_strpos") ) { |
350 | - function mb_strpos($haystack, $needle, $offset = 0) { |
|
350 | + function mb_strpos($haystack, $needle, $offset = 0) { |
|
351 | 351 | return strpos($haystack, $needle, $offset); |
352 | - } |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | if ( !function_exists("mb_strrpos") ) { |
356 | - function mb_strrpos($haystack, $needle, $offset = 0) { |
|
356 | + function mb_strrpos($haystack, $needle, $offset = 0) { |
|
357 | 357 | return strrpos($haystack, $needle, $offset); |
358 | - } |
|
358 | + } |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | if ( !function_exists("mb_strtolower") ) { |
362 | - function mb_strtolower($str) { |
|
362 | + function mb_strtolower($str) { |
|
363 | 363 | return strtolower($str); |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | if ( !function_exists("mb_strtoupper") ) { |
368 | - function mb_strtoupper($str) { |
|
368 | + function mb_strtoupper($str) { |
|
369 | 369 | return strtoupper($str); |
370 | - } |
|
370 | + } |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | if ( !function_exists("mb_substr") ) { |
374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
374 | + function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
375 | 375 | if ( is_null($length) ) |
376 | - return substr($str, $start); |
|
376 | + return substr($str, $start); |
|
377 | 377 | else |
378 | - return substr($str, $start, $length); |
|
379 | - } |
|
378 | + return substr($str, $start, $length); |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | if ( !function_exists("mb_substr_count") ) { |
383 | - function mb_substr_count($haystack, $needle) { |
|
383 | + function mb_substr_count($haystack, $needle) { |
|
384 | 384 | return substr_count($haystack, $needle); |
385 | - } |
|
385 | + } |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -402,40 +402,40 @@ 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 |
|
405 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
406 | 406 | throw new DOMPDF_Exception($errstr . " $errno"); |
407 | 407 | |
408 | - global $_dompdf_warnings; |
|
409 | - global $_dompdf_show_warnings; |
|
408 | + global $_dompdf_warnings; |
|
409 | + global $_dompdf_show_warnings; |
|
410 | 410 | |
411 | - if ( $_dompdf_show_warnings ) |
|
411 | + if ( $_dompdf_show_warnings ) |
|
412 | 412 | echo $errstr . "\n"; |
413 | 413 | |
414 | - $_dompdf_warnings[] = $errstr; |
|
414 | + $_dompdf_warnings[] = $errstr; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
418 | 418 | * Print a useful backtrace |
419 | 419 | */ |
420 | 420 | function bt() { |
421 | - $bt = debug_backtrace(); |
|
421 | + $bt = debug_backtrace(); |
|
422 | 422 | |
423 | - array_shift($bt); // remove actual bt() call |
|
424 | - echo "\n"; |
|
423 | + array_shift($bt); // remove actual bt() call |
|
424 | + echo "\n"; |
|
425 | 425 | |
426 | - $i = 0; |
|
427 | - foreach ($bt as $call) { |
|
426 | + $i = 0; |
|
427 | + foreach ($bt as $call) { |
|
428 | 428 | $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
429 | 429 | if ( isset($call["class"]) ) { |
430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
430 | + $func = $call["class"] . "->" . $call["function"] . "()"; |
|
431 | 431 | } else { |
432 | - $func = $call["function"] . "()"; |
|
432 | + $func = $call["function"] . "()"; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
436 | 436 | $i++; |
437 | - } |
|
438 | - echo "\n"; |
|
437 | + } |
|
438 | + echo "\n"; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -444,15 +444,15 @@ discard block |
||
444 | 444 | * @param string $type The type of debug messages to print |
445 | 445 | */ |
446 | 446 | function dompdf_debug($type, $msg) { |
447 | - global $_DOMPDF_DEBUG_TYPES; |
|
448 | - global $_dompdf_show_warnings; |
|
449 | - global $_dompdf_debug; |
|
450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
447 | + global $_DOMPDF_DEBUG_TYPES; |
|
448 | + global $_dompdf_show_warnings; |
|
449 | + global $_dompdf_debug; |
|
450 | + if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
451 | 451 | $arr = debug_backtrace(); |
452 | 452 | |
453 | 453 | echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
454 | 454 | pre_r($msg); |
455 | - } |
|
455 | + } |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -460,20 +460,20 @@ discard block |
||
460 | 460 | */ |
461 | 461 | if ( !function_exists("print_memusage") ) { |
462 | 462 | function print_memusage() { |
463 | - global $memusage; |
|
464 | - echo ("Memory Usage\n"); |
|
465 | - $prev = 0; |
|
466 | - $initial = reset($memusage); |
|
467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
463 | + global $memusage; |
|
464 | + echo ("Memory Usage\n"); |
|
465 | + $prev = 0; |
|
466 | + $initial = reset($memusage); |
|
467 | + echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
468 | 468 | |
469 | - foreach ($memusage as $key=>$mem) { |
|
469 | + foreach ($memusage as $key=>$mem) { |
|
470 | 470 | $mem -= $initial; |
471 | 471 | echo (str_pad("$key:" , 40)); |
472 | 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 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | */ |
496 | 496 | if ( !function_exists("mark_memusage") ) { |
497 | 497 | function mark_memusage($location) { |
498 | - global $memusage; |
|
499 | - if ( isset($memusage) ) |
|
498 | + global $memusage; |
|
499 | + if ( isset($memusage) ) |
|
500 | 500 | $memusage[$location] = memory_get_usage(); |
501 | 501 | } |
502 | 502 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
508 | 508 | */ |
509 | 509 | if ( !function_exists('sys_get_temp_dir')) { |
510 | - function sys_get_temp_dir() { |
|
510 | + function sys_get_temp_dir() { |
|
511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
512 | 512 | if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
513 | 513 | if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
@@ -516,5 +516,5 @@ discard block |
||
516 | 516 | unlink($tempfile); |
517 | 517 | return realpath(dirname($tempfile)); |
518 | 518 | } |
519 | - } |
|
519 | + } |
|
520 | 520 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
98 | 98 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
99 | + * @param integer $aa_factor Anti-aliasing factor, 1 for no AA |
|
100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
101 | 101 | */ |
102 | 102 | function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | * @param string $font the font file to use |
537 | 537 | * @param float $size the font size, in points |
538 | 538 | * @param array $color |
539 | - * @param float $adjust word spacing adjustment |
|
540 | - * @param float $angle Text angle |
|
539 | + * @param integer $adjust word spacing adjustment |
|
540 | + * @param integer $angle Text angle |
|
541 | 541 | */ |
542 | 542 | function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
543 | 543 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @param string $text the text to be sized |
591 | 591 | * @param string $font the desired font |
592 | 592 | * @param float $size the desired font size |
593 | - * @param float $spacing word spacing, if any |
|
593 | + * @param integer $spacing word spacing, if any |
|
594 | 594 | * @return float |
595 | 595 | */ |
596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -49,73 +48,73 @@ discard block |
||
49 | 48 | */ |
50 | 49 | class GD_Adapter implements Canvas { |
51 | 50 | |
52 | - /** |
|
53 | - * Resoure handle for the image |
|
54 | - * |
|
55 | - * @var resource |
|
56 | - */ |
|
57 | - private $_img; |
|
58 | - |
|
59 | - /** |
|
60 | - * Image width in pixels |
|
61 | - * |
|
62 | - * @var int |
|
63 | - */ |
|
64 | - private $_width; |
|
65 | - |
|
66 | - /** |
|
67 | - * Image height in pixels |
|
68 | - * |
|
69 | - * @var int |
|
70 | - */ |
|
71 | - private $_height; |
|
72 | - |
|
73 | - /** |
|
74 | - * Image antialias factor |
|
75 | - * |
|
76 | - * @var float |
|
77 | - */ |
|
78 | - private $_aa_factor; |
|
79 | - |
|
80 | - /** |
|
81 | - * Allocated colors |
|
82 | - * |
|
83 | - * @var array |
|
84 | - */ |
|
85 | - private $_colors; |
|
86 | - |
|
87 | - /** |
|
88 | - * Background color |
|
89 | - * |
|
90 | - * @var int |
|
91 | - */ |
|
92 | - private $_bg_color; |
|
51 | + /** |
|
52 | + * Resoure handle for the image |
|
53 | + * |
|
54 | + * @var resource |
|
55 | + */ |
|
56 | + private $_img; |
|
57 | + |
|
58 | + /** |
|
59 | + * Image width in pixels |
|
60 | + * |
|
61 | + * @var int |
|
62 | + */ |
|
63 | + private $_width; |
|
64 | + |
|
65 | + /** |
|
66 | + * Image height in pixels |
|
67 | + * |
|
68 | + * @var int |
|
69 | + */ |
|
70 | + private $_height; |
|
71 | + |
|
72 | + /** |
|
73 | + * Image antialias factor |
|
74 | + * |
|
75 | + * @var float |
|
76 | + */ |
|
77 | + private $_aa_factor; |
|
78 | + |
|
79 | + /** |
|
80 | + * Allocated colors |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + private $_colors; |
|
85 | + |
|
86 | + /** |
|
87 | + * Background color |
|
88 | + * |
|
89 | + * @var int |
|
90 | + */ |
|
91 | + private $_bg_color; |
|
93 | 92 | |
94 | - /** |
|
95 | - * Class constructor |
|
96 | - * |
|
97 | - * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
98 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
100 | - * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
101 | - */ |
|
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
93 | + /** |
|
94 | + * Class constructor |
|
95 | + * |
|
96 | + * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
97 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
98 | + * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
99 | + * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
100 | + */ |
|
101 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
103 | 102 | |
104 | 103 | if ( !is_array($size) ) { |
105 | 104 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
105 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | 106 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | - else |
|
107 | + else |
|
109 | 108 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 109 | |
111 | 110 | } |
112 | 111 | |
113 | 112 | if ( strtolower($orientation) === "landscape" ) { |
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + list($size[2],$size[3]) = array($size[3],$size[2]); |
|
115 | 114 | } |
116 | 115 | |
117 | 116 | if ( $aa_factor < 1 ) |
118 | - $aa_factor = 1; |
|
117 | + $aa_factor = 1; |
|
119 | 118 | |
120 | 119 | $this->_aa_factor = $aa_factor; |
121 | 120 | |
@@ -128,8 +127,8 @@ discard block |
||
128 | 127 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 128 | |
130 | 129 | if ( is_null($bg_color) || !is_array($bg_color) ) { |
131 | - // Pure white bg |
|
132 | - $bg_color = array(1,1,1,0); |
|
130 | + // Pure white bg |
|
131 | + $bg_color = array(1,1,1,0); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -137,68 +136,68 @@ discard block |
||
137 | 136 | imagesavealpha($this->_img, true); |
138 | 137 | imagefill($this->_img, 0, 0, $this->_bg_color); |
139 | 138 | |
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Return the GF image resource |
|
144 | - * |
|
145 | - * @return resource |
|
146 | - */ |
|
147 | - function get_image() { return $this->_img; } |
|
148 | - |
|
149 | - /** |
|
150 | - * Return the image's width in pixels |
|
151 | - * |
|
152 | - * @return float |
|
153 | - */ |
|
154 | - function get_width() { return $this->_width / $this->_aa_factor; } |
|
155 | - |
|
156 | - /** |
|
157 | - * Return the image's height in pixels |
|
158 | - * |
|
159 | - * @return float |
|
160 | - */ |
|
161 | - function get_height() { return $this->_height / $this->_aa_factor; } |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Return the GF image resource |
|
143 | + * |
|
144 | + * @return resource |
|
145 | + */ |
|
146 | + function get_image() { return $this->_img; } |
|
147 | + |
|
148 | + /** |
|
149 | + * Return the image's width in pixels |
|
150 | + * |
|
151 | + * @return float |
|
152 | + */ |
|
153 | + function get_width() { return $this->_width / $this->_aa_factor; } |
|
154 | + |
|
155 | + /** |
|
156 | + * Return the image's height in pixels |
|
157 | + * |
|
158 | + * @return float |
|
159 | + */ |
|
160 | + function get_height() { return $this->_height / $this->_aa_factor; } |
|
162 | 161 | |
163 | - /** |
|
164 | - * Returns the current page number |
|
165 | - * |
|
166 | - * @return int |
|
167 | - */ |
|
168 | - function get_page_number() { |
|
162 | + /** |
|
163 | + * Returns the current page number |
|
164 | + * |
|
165 | + * @return int |
|
166 | + */ |
|
167 | + function get_page_number() { |
|
169 | 168 | // FIXME |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - /** |
|
173 | - * Returns the total number of pages |
|
174 | - * |
|
175 | - * @return int |
|
176 | - */ |
|
177 | - function get_page_count() { |
|
171 | + /** |
|
172 | + * Returns the total number of pages |
|
173 | + * |
|
174 | + * @return int |
|
175 | + */ |
|
176 | + function get_page_count() { |
|
178 | 177 | // FIXME |
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Sets the total number of pages |
|
183 | - * |
|
184 | - * @param int $count |
|
185 | - */ |
|
186 | - function set_page_count($count) { |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Sets the total number of pages |
|
182 | + * |
|
183 | + * @param int $count |
|
184 | + */ |
|
185 | + function set_page_count($count) { |
|
187 | 186 | // FIXME |
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Allocate a new color. Allocate with GD as needed and store |
|
192 | - * previously allocated colors in $this->_colors. |
|
193 | - * |
|
194 | - * @param array $color The new current color |
|
195 | - * @return int The allocated color |
|
196 | - */ |
|
197 | - private function _allocate_color($color) { |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Allocate a new color. Allocate with GD as needed and store |
|
191 | + * previously allocated colors in $this->_colors. |
|
192 | + * |
|
193 | + * @param array $color The new current color |
|
194 | + * @return int The allocated color |
|
195 | + */ |
|
196 | + private function _allocate_color($color) { |
|
198 | 197 | |
199 | 198 | // Full opacity if no alpha set |
200 | 199 | if ( !isset($color[3]) ) |
201 | - $color[3] = 0; |
|
200 | + $color[3] = 0; |
|
202 | 201 | |
203 | 202 | list($r,$g,$b,$a) = $color; |
204 | 203 | |
@@ -221,33 +220,33 @@ discard block |
||
221 | 220 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 221 | |
223 | 222 | if ( isset($this->_colors[$key]) ) |
224 | - return $this->_colors[$key]; |
|
223 | + return $this->_colors[$key]; |
|
225 | 224 | |
226 | 225 | if ( $a != 0 ) |
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
226 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | 227 | else |
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
228 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | 229 | |
231 | 230 | return $this->_colors[$key]; |
232 | 231 | |
233 | - } |
|
232 | + } |
|
234 | 233 | |
235 | - /** |
|
236 | - * Draws a line from x1,y1 to x2,y2 |
|
237 | - * |
|
238 | - * See {@link Style::munge_color()} for the format of the color array. |
|
239 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
240 | - * $style parameter (aka dash). |
|
241 | - * |
|
242 | - * @param float $x1 |
|
243 | - * @param float $y1 |
|
244 | - * @param float $x2 |
|
245 | - * @param float $y2 |
|
246 | - * @param array $color |
|
247 | - * @param float $width |
|
248 | - * @param array $style |
|
249 | - */ |
|
250 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
234 | + /** |
|
235 | + * Draws a line from x1,y1 to x2,y2 |
|
236 | + * |
|
237 | + * See {@link Style::munge_color()} for the format of the color array. |
|
238 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
239 | + * $style parameter (aka dash). |
|
240 | + * |
|
241 | + * @param float $x1 |
|
242 | + * @param float $y1 |
|
243 | + * @param float $x2 |
|
244 | + * @param float $y2 |
|
245 | + * @param array $color |
|
246 | + * @param float $width |
|
247 | + * @param array $style |
|
248 | + */ |
|
249 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
251 | 250 | |
252 | 251 | // Scale by the AA factor |
253 | 252 | $x1 *= $this->_aa_factor; |
@@ -260,63 +259,63 @@ discard block |
||
260 | 259 | |
261 | 260 | // Convert the style array if required |
262 | 261 | if ( !is_null($style) ) { |
263 | - $gd_style = array(); |
|
262 | + $gd_style = array(); |
|
264 | 263 | |
265 | - if ( count($style) == 1 ) { |
|
264 | + if ( count($style) == 1 ) { |
|
266 | 265 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | - $gd_style[] = $c; |
|
266 | + $gd_style[] = $c; |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
271 | - $gd_style[] = $this->_bg_color; |
|
270 | + $gd_style[] = $this->_bg_color; |
|
272 | 271 | } |
273 | 272 | |
274 | - } else { |
|
273 | + } else { |
|
275 | 274 | |
276 | 275 | $i = 0; |
277 | 276 | foreach ($style as $length) { |
278 | 277 | |
279 | - if ( $i % 2 == 0 ) { |
|
278 | + if ( $i % 2 == 0 ) { |
|
280 | 279 | // 'On' pattern |
281 | 280 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | - $gd_style[] = $c; |
|
281 | + $gd_style[] = $c; |
|
283 | 282 | |
284 | - } else { |
|
283 | + } else { |
|
285 | 284 | // Off pattern |
286 | 285 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
287 | - $gd_style[] = $this->_bg_color; |
|
286 | + $gd_style[] = $this->_bg_color; |
|
288 | 287 | |
289 | - } |
|
290 | - $i++; |
|
288 | + } |
|
289 | + $i++; |
|
290 | + } |
|
291 | 291 | } |
292 | - } |
|
293 | 292 | |
294 | - imagesetstyle($this->_img, $gd_style); |
|
295 | - $c = IMG_COLOR_STYLED; |
|
293 | + imagesetstyle($this->_img, $gd_style); |
|
294 | + $c = IMG_COLOR_STYLED; |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | imagesetthickness($this->_img, $width); |
299 | 298 | |
300 | 299 | imageline($this->_img, $x1, $y1, $x2, $y2, $c); |
301 | 300 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Draws a rectangle at x1,y1 with width w and height h |
|
306 | - * |
|
307 | - * See {@link Style::munge_color()} for the format of the color array. |
|
308 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
309 | - * parameter (aka dash) |
|
310 | - * |
|
311 | - * @param float $x1 |
|
312 | - * @param float $y1 |
|
313 | - * @param float $w |
|
314 | - * @param float $h |
|
315 | - * @param array $color |
|
316 | - * @param float $width |
|
317 | - * @param array $style |
|
318 | - */ |
|
319 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Draws a rectangle at x1,y1 with width w and height h |
|
305 | + * |
|
306 | + * See {@link Style::munge_color()} for the format of the color array. |
|
307 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
308 | + * parameter (aka dash) |
|
309 | + * |
|
310 | + * @param float $x1 |
|
311 | + * @param float $y1 |
|
312 | + * @param float $w |
|
313 | + * @param float $h |
|
314 | + * @param array $color |
|
315 | + * @param float $width |
|
316 | + * @param array $style |
|
317 | + */ |
|
318 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
320 | 319 | |
321 | 320 | // Scale by the AA factor |
322 | 321 | $x1 *= $this->_aa_factor; |
@@ -328,36 +327,36 @@ discard block |
||
328 | 327 | |
329 | 328 | // Convert the style array if required |
330 | 329 | if ( !is_null($style) ) { |
331 | - $gd_style = array(); |
|
330 | + $gd_style = array(); |
|
332 | 331 | |
333 | - foreach ($style as $length) { |
|
332 | + foreach ($style as $length) { |
|
334 | 333 | for ($i = 0; $i < $length; $i++) { |
335 | - $gd_style[] = $c; |
|
334 | + $gd_style[] = $c; |
|
335 | + } |
|
336 | 336 | } |
337 | - } |
|
338 | 337 | |
339 | - imagesetstyle($this->_img, $gd_style); |
|
340 | - $c = IMG_COLOR_STYLED; |
|
338 | + imagesetstyle($this->_img, $gd_style); |
|
339 | + $c = IMG_COLOR_STYLED; |
|
341 | 340 | } |
342 | 341 | |
343 | 342 | imagesetthickness($this->_img, $width); |
344 | 343 | |
345 | 344 | imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
346 | 345 | |
347 | - } |
|
348 | - |
|
349 | - /** |
|
350 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
351 | - * |
|
352 | - * See {@link Style::munge_color()} for the format of the color array. |
|
353 | - * |
|
354 | - * @param float $x1 |
|
355 | - * @param float $y1 |
|
356 | - * @param float $w |
|
357 | - * @param float $h |
|
358 | - * @param array $color |
|
359 | - */ |
|
360 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
350 | + * |
|
351 | + * See {@link Style::munge_color()} for the format of the color array. |
|
352 | + * |
|
353 | + * @param float $x1 |
|
354 | + * @param float $y1 |
|
355 | + * @param float $w |
|
356 | + * @param float $h |
|
357 | + * @param array $color |
|
358 | + */ |
|
359 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
361 | 360 | |
362 | 361 | // Scale by the AA factor |
363 | 362 | $x1 *= $this->_aa_factor; |
@@ -369,79 +368,79 @@ discard block |
||
369 | 368 | |
370 | 369 | imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
371 | 370 | |
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Draws a polygon |
|
376 | - * |
|
377 | - * The polygon is formed by joining all the points stored in the $points |
|
378 | - * array. $points has the following structure: |
|
379 | - * <code> |
|
380 | - * array(0 => x1, |
|
381 | - * 1 => y1, |
|
382 | - * 2 => x2, |
|
383 | - * 3 => y2, |
|
384 | - * ... |
|
385 | - * ); |
|
386 | - * </code> |
|
387 | - * |
|
388 | - * See {@link Style::munge_color()} for the format of the color array. |
|
389 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
390 | - * parameter (aka dash) |
|
391 | - * |
|
392 | - * @param array $points |
|
393 | - * @param array $color |
|
394 | - * @param float $width |
|
395 | - * @param array $style |
|
396 | - * @param bool $fill Fills the polygon if true |
|
397 | - */ |
|
398 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Draws a polygon |
|
375 | + * |
|
376 | + * The polygon is formed by joining all the points stored in the $points |
|
377 | + * array. $points has the following structure: |
|
378 | + * <code> |
|
379 | + * array(0 => x1, |
|
380 | + * 1 => y1, |
|
381 | + * 2 => x2, |
|
382 | + * 3 => y2, |
|
383 | + * ... |
|
384 | + * ); |
|
385 | + * </code> |
|
386 | + * |
|
387 | + * See {@link Style::munge_color()} for the format of the color array. |
|
388 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
389 | + * parameter (aka dash) |
|
390 | + * |
|
391 | + * @param array $points |
|
392 | + * @param array $color |
|
393 | + * @param float $width |
|
394 | + * @param array $style |
|
395 | + * @param bool $fill Fills the polygon if true |
|
396 | + */ |
|
397 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
399 | 398 | |
400 | 399 | // Scale each point by the AA factor |
401 | 400 | foreach (array_keys($points) as $i) |
402 | - $points[$i] *= $this->_aa_factor; |
|
401 | + $points[$i] *= $this->_aa_factor; |
|
403 | 402 | |
404 | 403 | $c = $this->_allocate_color($color); |
405 | 404 | |
406 | 405 | // Convert the style array if required |
407 | 406 | if ( !is_null($style) && !$fill ) { |
408 | - $gd_style = array(); |
|
407 | + $gd_style = array(); |
|
409 | 408 | |
410 | - foreach ($style as $length) { |
|
409 | + foreach ($style as $length) { |
|
411 | 410 | for ($i = 0; $i < $length; $i++) { |
412 | - $gd_style[] = $c; |
|
411 | + $gd_style[] = $c; |
|
412 | + } |
|
413 | 413 | } |
414 | - } |
|
415 | 414 | |
416 | - imagesetstyle($this->_img, $gd_style); |
|
417 | - $c = IMG_COLOR_STYLED; |
|
415 | + imagesetstyle($this->_img, $gd_style); |
|
416 | + $c = IMG_COLOR_STYLED; |
|
418 | 417 | } |
419 | 418 | |
420 | 419 | imagesetthickness($this->_img, $width); |
421 | 420 | |
422 | 421 | if ( $fill ) |
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
422 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | 423 | else |
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
426 | 425 | |
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Draws a circle at $x,$y with radius $r |
|
431 | - * |
|
432 | - * See {@link Style::munge_color()} for the format of the color array. |
|
433 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
434 | - * parameter (aka dash) |
|
435 | - * |
|
436 | - * @param float $x |
|
437 | - * @param float $y |
|
438 | - * @param float $r |
|
439 | - * @param array $color |
|
440 | - * @param float $width |
|
441 | - * @param array $style |
|
442 | - * @param bool $fill Fills the circle if true |
|
443 | - */ |
|
444 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Draws a circle at $x,$y with radius $r |
|
430 | + * |
|
431 | + * See {@link Style::munge_color()} for the format of the color array. |
|
432 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
433 | + * parameter (aka dash) |
|
434 | + * |
|
435 | + * @param float $x |
|
436 | + * @param float $y |
|
437 | + * @param float $r |
|
438 | + * @param array $color |
|
439 | + * @param float $width |
|
440 | + * @param array $style |
|
441 | + * @param bool $fill Fills the circle if true |
|
442 | + */ |
|
443 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
445 | 444 | |
446 | 445 | // Scale by the AA factor |
447 | 446 | $x *= $this->_aa_factor; |
@@ -452,55 +451,55 @@ discard block |
||
452 | 451 | |
453 | 452 | // Convert the style array if required |
454 | 453 | if ( !is_null($style) && !$fill ) { |
455 | - $gd_style = array(); |
|
454 | + $gd_style = array(); |
|
456 | 455 | |
457 | - foreach ($style as $length) { |
|
456 | + foreach ($style as $length) { |
|
458 | 457 | for ($i = 0; $i < $length; $i++) { |
459 | - $gd_style[] = $c; |
|
458 | + $gd_style[] = $c; |
|
459 | + } |
|
460 | 460 | } |
461 | - } |
|
462 | 461 | |
463 | - imagesetstyle($this->_img, $gd_style); |
|
464 | - $c = IMG_COLOR_STYLED; |
|
462 | + imagesetstyle($this->_img, $gd_style); |
|
463 | + $c = IMG_COLOR_STYLED; |
|
465 | 464 | } |
466 | 465 | |
467 | 466 | imagesetthickness($this->_img, $width); |
468 | 467 | |
469 | 468 | if ( $fill ) |
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
469 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | 470 | else |
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
473 | 472 | |
474 | - } |
|
475 | - |
|
476 | - /** |
|
477 | - * Add an image to the pdf. |
|
478 | - * |
|
479 | - * The image is placed at the specified x and y coordinates with the |
|
480 | - * given width and height. |
|
481 | - * |
|
482 | - * @param string $img_url the path to the image |
|
483 | - * @param string $img_type the type (e.g. extension) of the image |
|
484 | - * @param float $x x position |
|
485 | - * @param float $y y position |
|
486 | - * @param int $w width (in pixels) |
|
487 | - * @param int $h height (in pixels) |
|
488 | - */ |
|
489 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * Add an image to the pdf. |
|
477 | + * |
|
478 | + * The image is placed at the specified x and y coordinates with the |
|
479 | + * given width and height. |
|
480 | + * |
|
481 | + * @param string $img_url the path to the image |
|
482 | + * @param string $img_type the type (e.g. extension) of the image |
|
483 | + * @param float $x x position |
|
484 | + * @param float $y y position |
|
485 | + * @param int $w width (in pixels) |
|
486 | + * @param int $h height (in pixels) |
|
487 | + */ |
|
488 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
490 | 489 | |
491 | 490 | switch ($img_type) { |
492 | 491 | case "png": |
493 | 492 | $src = @imagecreatefrompng($img_url); |
494 | - break; |
|
493 | + break; |
|
495 | 494 | |
496 | 495 | case "gif": |
497 | 496 | $src = @imagecreatefromgif($img_url); |
498 | - break; |
|
497 | + break; |
|
499 | 498 | |
500 | 499 | case "jpg": |
501 | 500 | case "jpeg": |
502 | 501 | $src = @imagecreatefromjpeg($img_url); |
503 | - break; |
|
502 | + break; |
|
504 | 503 | |
505 | 504 | default: |
506 | 505 | break; |
@@ -508,7 +507,7 @@ discard block |
||
508 | 507 | } |
509 | 508 | |
510 | 509 | if ( !$src ) |
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
510 | + return; // Probably should add to $_dompdf_errors or whatever here |
|
512 | 511 | |
513 | 512 | // Scale by the AA factor |
514 | 513 | $x *= $this->_aa_factor; |
@@ -523,23 +522,23 @@ discard block |
||
523 | 522 | |
524 | 523 | imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h); |
525 | 524 | |
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * Writes text at the specified x and y coordinates |
|
530 | - * |
|
531 | - * See {@link Style::munge_color()} for the format of the color array. |
|
532 | - * |
|
533 | - * @param float $x |
|
534 | - * @param float $y |
|
535 | - * @param string $text the text to write |
|
536 | - * @param string $font the font file to use |
|
537 | - * @param float $size the font size, in points |
|
538 | - * @param array $color |
|
539 | - * @param float $adjust word spacing adjustment |
|
540 | - * @param float $angle Text angle |
|
541 | - */ |
|
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * Writes text at the specified x and y coordinates |
|
529 | + * |
|
530 | + * See {@link Style::munge_color()} for the format of the color array. |
|
531 | + * |
|
532 | + * @param float $x |
|
533 | + * @param float $y |
|
534 | + * @param string $text the text to write |
|
535 | + * @param string $font the font file to use |
|
536 | + * @param float $size the font size, in points |
|
537 | + * @param array $color |
|
538 | + * @param float $adjust word spacing adjustment |
|
539 | + * @param float $angle Text angle |
|
540 | + */ |
|
541 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
543 | 542 | |
544 | 543 | // Scale by the AA factor |
545 | 544 | $x *= $this->_aa_factor; |
@@ -551,106 +550,106 @@ discard block |
||
551 | 550 | $c = $this->_allocate_color($color); |
552 | 551 | |
553 | 552 | if ( strpos($font, '.ttf') === false ) |
554 | - $font .= ".ttf"; |
|
553 | + $font .= ".ttf"; |
|
555 | 554 | |
556 | 555 | // FIXME: word spacing |
557 | 556 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
558 | 557 | |
559 | - } |
|
558 | + } |
|
560 | 559 | |
561 | - function javascript($code) { |
|
560 | + function javascript($code) { |
|
562 | 561 | // Not implemented |
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
567 | - * |
|
568 | - * @param string $anchorname The name of the named destination |
|
569 | - */ |
|
570 | - function add_named_dest($anchorname) { |
|
562 | + } |
|
563 | + |
|
564 | + /** |
|
565 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
566 | + * |
|
567 | + * @param string $anchorname The name of the named destination |
|
568 | + */ |
|
569 | + function add_named_dest($anchorname) { |
|
571 | 570 | // Not implemented |
572 | - } |
|
573 | - |
|
574 | - /** |
|
575 | - * Add a link to the pdf |
|
576 | - * |
|
577 | - * @param string $url The url to link to |
|
578 | - * @param float $x The x position of the link |
|
579 | - * @param float $y The y position of the link |
|
580 | - * @param float $width The width of the link |
|
581 | - * @param float $height The height of the link |
|
582 | - */ |
|
583 | - function add_link($url, $x, $y, $width, $height) { |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * Add a link to the pdf |
|
575 | + * |
|
576 | + * @param string $url The url to link to |
|
577 | + * @param float $x The x position of the link |
|
578 | + * @param float $y The y position of the link |
|
579 | + * @param float $width The width of the link |
|
580 | + * @param float $height The height of the link |
|
581 | + */ |
|
582 | + function add_link($url, $x, $y, $width, $height) { |
|
584 | 583 | // Not implemented |
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Calculates text size, in points |
|
589 | - * |
|
590 | - * @param string $text the text to be sized |
|
591 | - * @param string $font the desired font |
|
592 | - * @param float $size the desired font size |
|
593 | - * @param float $spacing word spacing, if any |
|
594 | - * @return float |
|
595 | - */ |
|
596 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
584 | + } |
|
585 | + |
|
586 | + /** |
|
587 | + * Calculates text size, in points |
|
588 | + * |
|
589 | + * @param string $text the text to be sized |
|
590 | + * @param string $font the desired font |
|
591 | + * @param float $size the desired font size |
|
592 | + * @param float $spacing word spacing, if any |
|
593 | + * @return float |
|
594 | + */ |
|
595 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
597 | 596 | |
598 | 597 | if ( strpos($font, '.ttf') === false ) |
599 | - $font .= ".ttf"; |
|
598 | + $font .= ".ttf"; |
|
600 | 599 | |
601 | 600 | // FIXME: word spacing |
602 | 601 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
603 | 602 | return $x2 - $x1; |
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Calculates font height, in points |
|
608 | - * |
|
609 | - * @param string $font |
|
610 | - * @param float $size |
|
611 | - * @return float |
|
612 | - */ |
|
613 | - function get_font_height($font, $size) { |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Calculates font height, in points |
|
607 | + * |
|
608 | + * @param string $font |
|
609 | + * @param float $size |
|
610 | + * @return float |
|
611 | + */ |
|
612 | + function get_font_height($font, $size) { |
|
614 | 613 | if ( strpos($font, '.ttf') === false ) |
615 | - $font .= ".ttf"; |
|
614 | + $font .= ".ttf"; |
|
616 | 615 | |
617 | 616 | // FIXME: word spacing |
618 | 617 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
619 | 618 | return $y2 - $y1; |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | 621 | |
623 | - /** |
|
624 | - * Starts a new page |
|
625 | - * |
|
626 | - * Subsequent drawing operations will appear on the new page. |
|
627 | - */ |
|
628 | - function new_page() { |
|
622 | + /** |
|
623 | + * Starts a new page |
|
624 | + * |
|
625 | + * Subsequent drawing operations will appear on the new page. |
|
626 | + */ |
|
627 | + function new_page() { |
|
629 | 628 | // FIXME |
630 | - } |
|
629 | + } |
|
631 | 630 | |
632 | - /** |
|
633 | - * Streams the image directly to the browser |
|
634 | - * |
|
635 | - * @param string $filename the name of the image file (ignored) |
|
636 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
637 | - */ |
|
638 | - function stream($filename, $options = null) { |
|
631 | + /** |
|
632 | + * Streams the image directly to the browser |
|
633 | + * |
|
634 | + * @param string $filename the name of the image file (ignored) |
|
635 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
636 | + */ |
|
637 | + function stream($filename, $options = null) { |
|
639 | 638 | |
640 | 639 | // Perform any antialiasing |
641 | 640 | if ( $this->_aa_factor != 1 ) { |
642 | - $dst_w = $this->_width / $this->_aa_factor; |
|
643 | - $dst_h = $this->_height / $this->_aa_factor; |
|
644 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
645 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
646 | - $dst_w, $dst_h, |
|
647 | - $this->_width, $this->_height); |
|
641 | + $dst_w = $this->_width / $this->_aa_factor; |
|
642 | + $dst_h = $this->_height / $this->_aa_factor; |
|
643 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
644 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
645 | + $dst_w, $dst_h, |
|
646 | + $this->_width, $this->_height); |
|
648 | 647 | } else { |
649 | - $dst = $this->_img; |
|
648 | + $dst = $this->_img; |
|
650 | 649 | } |
651 | 650 | |
652 | 651 | if ( !isset($options["type"]) ) |
653 | - $options["type"] = "png"; |
|
652 | + $options["type"] = "png"; |
|
654 | 653 | |
655 | 654 | $type = strtolower($options["type"]); |
656 | 655 | |
@@ -663,42 +662,42 @@ discard block |
||
663 | 662 | if ( !isset($options["quality"]) ) |
664 | 663 | $options["quality"] = 75; |
665 | 664 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
665 | + header("Content-type: image/jpeg"); |
|
666 | + imagejpeg($dst, '', $options["quality"]); |
|
667 | + break; |
|
669 | 668 | |
670 | 669 | case "png": |
671 | 670 | default: |
672 | 671 | header("Content-type: image/png"); |
673 | - imagepng($dst); |
|
674 | - break; |
|
672 | + imagepng($dst); |
|
673 | + break; |
|
675 | 674 | } |
676 | 675 | |
677 | 676 | if ( $this->_aa_factor != 1 ) |
678 | - imagedestroy($dst); |
|
679 | - } |
|
677 | + imagedestroy($dst); |
|
678 | + } |
|
680 | 679 | |
681 | - /** |
|
682 | - * Returns the PNG as a string |
|
683 | - * |
|
684 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
685 | - * @return string |
|
686 | - */ |
|
687 | - function output($options = null) { |
|
680 | + /** |
|
681 | + * Returns the PNG as a string |
|
682 | + * |
|
683 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
684 | + * @return string |
|
685 | + */ |
|
686 | + function output($options = null) { |
|
688 | 687 | |
689 | 688 | if ( $this->_aa_factor != 1 ) { |
690 | - $dst_w = $this->_width / $this->_aa_factor; |
|
691 | - $dst_h = $this->_height / $this->_aa_factor; |
|
692 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
693 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
694 | - $dst_w, $dst_h, |
|
695 | - $this->_width, $this->_height); |
|
689 | + $dst_w = $this->_width / $this->_aa_factor; |
|
690 | + $dst_h = $this->_height / $this->_aa_factor; |
|
691 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
692 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
693 | + $dst_w, $dst_h, |
|
694 | + $this->_width, $this->_height); |
|
696 | 695 | } else { |
697 | - $dst = $this->_img; |
|
696 | + $dst = $this->_img; |
|
698 | 697 | } |
699 | 698 | |
700 | 699 | if ( !isset($options["type"]) ) |
701 | - $options["type"] = "png"; |
|
700 | + $options["type"] = "png"; |
|
702 | 701 | |
703 | 702 | $type = $options["type"]; |
704 | 703 | |
@@ -711,23 +710,23 @@ discard block |
||
711 | 710 | if ( !isset($options["quality"]) ) |
712 | 711 | $options["quality"] = 75; |
713 | 712 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
713 | + imagejpeg($dst, '', $options["quality"]); |
|
714 | + break; |
|
716 | 715 | |
717 | 716 | case "png": |
718 | 717 | default: |
719 | 718 | imagepng($dst); |
720 | - break; |
|
719 | + break; |
|
721 | 720 | } |
722 | 721 | |
723 | 722 | $image = ob_get_contents(); |
724 | 723 | ob_end_clean(); |
725 | 724 | |
726 | 725 | if ( $this->_aa_factor != 1 ) |
727 | - imagedestroy($dst); |
|
726 | + imagedestroy($dst); |
|
728 | 727 | |
729 | 728 | return $image; |
730 | - } |
|
729 | + } |
|
731 | 730 | |
732 | 731 | |
733 | 732 | } |
@@ -489,21 +489,21 @@ discard block |
||
489 | 489 | function image($img_url, $img_type, $x, $y, $w, $h) { |
490 | 490 | |
491 | 491 | switch ($img_type) { |
492 | - case "png": |
|
493 | - $src = @imagecreatefrompng($img_url); |
|
494 | - break; |
|
492 | + case "png": |
|
493 | + $src = @imagecreatefrompng($img_url); |
|
494 | + break; |
|
495 | 495 | |
496 | - case "gif": |
|
497 | - $src = @imagecreatefromgif($img_url); |
|
498 | - break; |
|
496 | + case "gif": |
|
497 | + $src = @imagecreatefromgif($img_url); |
|
498 | + break; |
|
499 | 499 | |
500 | - case "jpg": |
|
501 | - case "jpeg": |
|
502 | - $src = @imagecreatefromjpeg($img_url); |
|
503 | - break; |
|
500 | + case "jpg": |
|
501 | + case "jpeg": |
|
502 | + $src = @imagecreatefromjpeg($img_url); |
|
503 | + break; |
|
504 | 504 | |
505 | - default: |
|
506 | - break; |
|
505 | + default: |
|
506 | + break; |
|
507 | 507 | |
508 | 508 | } |
509 | 509 | |
@@ -658,20 +658,20 @@ discard block |
||
658 | 658 | |
659 | 659 | switch ($type) { |
660 | 660 | |
661 | - case "jpg": |
|
662 | - case "jpeg": |
|
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
661 | + case "jpg": |
|
662 | + case "jpeg": |
|
663 | + if ( !isset($options["quality"]) ) |
|
664 | + $options["quality"] = 75; |
|
665 | 665 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
669 | - |
|
670 | - case "png": |
|
671 | - default: |
|
672 | - header("Content-type: image/png"); |
|
673 | - imagepng($dst); |
|
674 | - break; |
|
666 | + header("Content-type: image/jpeg"); |
|
667 | + imagejpeg($dst, '', $options["quality"]); |
|
668 | + break; |
|
669 | + |
|
670 | + case "png": |
|
671 | + default: |
|
672 | + header("Content-type: image/png"); |
|
673 | + imagepng($dst); |
|
674 | + break; |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if ( $this->_aa_factor != 1 ) |
@@ -706,18 +706,18 @@ discard block |
||
706 | 706 | |
707 | 707 | switch ($type) { |
708 | 708 | |
709 | - case "jpg": |
|
710 | - case "jpeg": |
|
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
709 | + case "jpg": |
|
710 | + case "jpeg": |
|
711 | + if ( !isset($options["quality"]) ) |
|
712 | + $options["quality"] = 75; |
|
713 | 713 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
714 | + imagejpeg($dst, '', $options["quality"]); |
|
715 | + break; |
|
716 | 716 | |
717 | - case "png": |
|
718 | - default: |
|
719 | - imagepng($dst); |
|
720 | - break; |
|
717 | + case "png": |
|
718 | + default: |
|
719 | + imagepng($dst); |
|
720 | + break; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | $image = ob_get_contents(); |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
101 | 101 | */ |
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
102 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1, 1, 1, 0)) { |
|
103 | 103 | |
104 | - if ( !is_array($size) ) { |
|
104 | + if (!is_array($size)) { |
|
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
106 | + if (isset(CPDF_Adapter::$PAPER_SIZES[strtolower($size)])) |
|
107 | 107 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | 108 | else |
109 | 109 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - if ( strtolower($orientation) === "landscape" ) { |
|
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + if (strtolower($orientation) === "landscape") { |
|
114 | + list($size[2], $size[3]) = array($size[3], $size[2]); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $aa_factor < 1 ) |
|
117 | + if ($aa_factor < 1) |
|
118 | 118 | $aa_factor = 1; |
119 | 119 | |
120 | 120 | $this->_aa_factor = $aa_factor; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 129 | |
130 | - if ( is_null($bg_color) || !is_array($bg_color) ) { |
|
130 | + if (is_null($bg_color) || !is_array($bg_color)) { |
|
131 | 131 | // Pure white bg |
132 | - $bg_color = array(1,1,1,0); |
|
132 | + $bg_color = array(1, 1, 1, 0); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | private function _allocate_color($color) { |
198 | 198 | |
199 | 199 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
200 | + if (!isset($color[3])) |
|
201 | 201 | $color[3] = 0; |
202 | 202 | |
203 | - list($r,$g,$b,$a) = $color; |
|
203 | + list($r, $g, $b, $a) = $color; |
|
204 | 204 | |
205 | 205 | $r *= 255; |
206 | 206 | $g *= 255; |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | |
221 | 221 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 222 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
223 | + if (isset($this->_colors[$key])) |
|
224 | 224 | return $this->_colors[$key]; |
225 | 225 | |
226 | - if ( $a != 0 ) |
|
226 | + if ($a != 0) |
|
227 | 227 | $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
228 | 228 | else |
229 | 229 | $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | $c = $this->_allocate_color($color); |
260 | 260 | |
261 | 261 | // Convert the style array if required |
262 | - if ( !is_null($style) ) { |
|
262 | + if (!is_null($style)) { |
|
263 | 263 | $gd_style = array(); |
264 | 264 | |
265 | - if ( count($style) == 1 ) { |
|
265 | + if (count($style) == 1) { |
|
266 | 266 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | 267 | $gd_style[] = $c; |
268 | 268 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $i = 0; |
277 | 277 | foreach ($style as $length) { |
278 | 278 | |
279 | - if ( $i % 2 == 0 ) { |
|
279 | + if ($i % 2 == 0) { |
|
280 | 280 | // 'On' pattern |
281 | 281 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | 282 | $gd_style[] = $c; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $c = $this->_allocate_color($color); |
328 | 328 | |
329 | 329 | // Convert the style array if required |
330 | - if ( !is_null($style) ) { |
|
330 | + if (!is_null($style)) { |
|
331 | 331 | $gd_style = array(); |
332 | 332 | |
333 | 333 | foreach ($style as $length) { |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $c = $this->_allocate_color($color); |
405 | 405 | |
406 | 406 | // Convert the style array if required |
407 | - if ( !is_null($style) && !$fill ) { |
|
407 | + if (!is_null($style) && !$fill) { |
|
408 | 408 | $gd_style = array(); |
409 | 409 | |
410 | 410 | foreach ($style as $length) { |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | imagesetthickness($this->_img, $width); |
421 | 421 | |
422 | - if ( $fill ) |
|
422 | + if ($fill) |
|
423 | 423 | imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
424 | 424 | else |
425 | 425 | imagepolygon($this->_img, $points, count($points) / 2, $c); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $c = $this->_allocate_color($color); |
452 | 452 | |
453 | 453 | // Convert the style array if required |
454 | - if ( !is_null($style) && !$fill ) { |
|
454 | + if (!is_null($style) && !$fill) { |
|
455 | 455 | $gd_style = array(); |
456 | 456 | |
457 | 457 | foreach ($style as $length) { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | imagesetthickness($this->_img, $width); |
468 | 468 | |
469 | - if ( $fill ) |
|
469 | + if ($fill) |
|
470 | 470 | imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
471 | 471 | else |
472 | 472 | imageellipse($this->_img, $x, $y, $r, $r, $c); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - if ( !$src ) |
|
510 | + if (!$src) |
|
511 | 511 | return; // Probably should add to $_dompdf_errors or whatever here |
512 | 512 | |
513 | 513 | // Scale by the AA factor |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param float $adjust word spacing adjustment |
540 | 540 | * @param float $angle Text angle |
541 | 541 | */ |
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
542 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
543 | 543 | |
544 | 544 | // Scale by the AA factor |
545 | 545 | $x *= $this->_aa_factor; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | $c = $this->_allocate_color($color); |
552 | 552 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
553 | + if (strpos($font, '.ttf') === false) |
|
554 | 554 | $font .= ".ttf"; |
555 | 555 | |
556 | 556 | // FIXME: word spacing |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 597 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
598 | + if (strpos($font, '.ttf') === false) |
|
599 | 599 | $font .= ".ttf"; |
600 | 600 | |
601 | 601 | // FIXME: word spacing |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | * @return float |
612 | 612 | */ |
613 | 613 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
614 | + if (strpos($font, '.ttf') === false) |
|
615 | 615 | $font .= ".ttf"; |
616 | 616 | |
617 | 617 | // FIXME: word spacing |
618 | - list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
618 | + list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
619 | 619 | return $y2 - $y1; |
620 | 620 | } |
621 | 621 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | function stream($filename, $options = null) { |
639 | 639 | |
640 | 640 | // Perform any antialiasing |
641 | - if ( $this->_aa_factor != 1 ) { |
|
641 | + if ($this->_aa_factor != 1) { |
|
642 | 642 | $dst_w = $this->_width / $this->_aa_factor; |
643 | 643 | $dst_h = $this->_height / $this->_aa_factor; |
644 | 644 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | $dst = $this->_img; |
650 | 650 | } |
651 | 651 | |
652 | - if ( !isset($options["type"]) ) |
|
652 | + if (!isset($options["type"])) |
|
653 | 653 | $options["type"] = "png"; |
654 | 654 | |
655 | 655 | $type = strtolower($options["type"]); |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | |
661 | 661 | case "jpg": |
662 | 662 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
663 | + if (!isset($options["quality"])) |
|
664 | 664 | $options["quality"] = 75; |
665 | 665 | |
666 | 666 | header("Content-type: image/jpeg"); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | break; |
675 | 675 | } |
676 | 676 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
677 | + if ($this->_aa_factor != 1) |
|
678 | 678 | imagedestroy($dst); |
679 | 679 | } |
680 | 680 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | function output($options = null) { |
688 | 688 | |
689 | - if ( $this->_aa_factor != 1 ) { |
|
689 | + if ($this->_aa_factor != 1) { |
|
690 | 690 | $dst_w = $this->_width / $this->_aa_factor; |
691 | 691 | $dst_h = $this->_height / $this->_aa_factor; |
692 | 692 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | $dst = $this->_img; |
698 | 698 | } |
699 | 699 | |
700 | - if ( !isset($options["type"]) ) |
|
700 | + if (!isset($options["type"])) |
|
701 | 701 | $options["type"] = "png"; |
702 | 702 | |
703 | 703 | $type = $options["type"]; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | case "jpg": |
710 | 710 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
711 | + if (!isset($options["quality"])) |
|
712 | 712 | $options["quality"] = 75; |
713 | 713 | |
714 | 714 | imagejpeg($dst, '', $options["quality"]); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $image = ob_get_contents(); |
724 | 724 | ob_end_clean(); |
725 | 725 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
726 | + if ($this->_aa_factor != 1) |
|
727 | 727 | imagedestroy($dst); |
728 | 728 | |
729 | 729 | return $image; |
@@ -103,10 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | if ( !is_array($size) ) { |
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | - $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | - else |
|
109 | - $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
106 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) { |
|
107 | + $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | + } else { |
|
109 | + $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
110 | + } |
|
110 | 111 | |
111 | 112 | } |
112 | 113 | |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | list($size[2],$size[3]) = array($size[3],$size[2]); |
115 | 116 | } |
116 | 117 | |
117 | - if ( $aa_factor < 1 ) |
|
118 | - $aa_factor = 1; |
|
118 | + if ( $aa_factor < 1 ) { |
|
119 | + $aa_factor = 1; |
|
120 | + } |
|
119 | 121 | |
120 | 122 | $this->_aa_factor = $aa_factor; |
121 | 123 | |
@@ -197,8 +199,9 @@ discard block |
||
197 | 199 | private function _allocate_color($color) { |
198 | 200 | |
199 | 201 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
201 | - $color[3] = 0; |
|
202 | + if ( !isset($color[3]) ) { |
|
203 | + $color[3] = 0; |
|
204 | + } |
|
202 | 205 | |
203 | 206 | list($r,$g,$b,$a) = $color; |
204 | 207 | |
@@ -220,13 +223,15 @@ discard block |
||
220 | 223 | |
221 | 224 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 225 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
224 | - return $this->_colors[$key]; |
|
226 | + if ( isset($this->_colors[$key]) ) { |
|
227 | + return $this->_colors[$key]; |
|
228 | + } |
|
225 | 229 | |
226 | - if ( $a != 0 ) |
|
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | - else |
|
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | + if ( $a != 0 ) { |
|
231 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
232 | + } else { |
|
233 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
234 | + } |
|
230 | 235 | |
231 | 236 | return $this->_colors[$key]; |
232 | 237 | |
@@ -278,13 +283,15 @@ discard block |
||
278 | 283 | |
279 | 284 | if ( $i % 2 == 0 ) { |
280 | 285 | // 'On' pattern |
281 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
282 | - $gd_style[] = $c; |
|
286 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
287 | + $gd_style[] = $c; |
|
288 | + } |
|
283 | 289 | |
284 | 290 | } else { |
285 | 291 | // Off pattern |
286 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
287 | - $gd_style[] = $this->_bg_color; |
|
292 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
293 | + $gd_style[] = $this->_bg_color; |
|
294 | + } |
|
288 | 295 | |
289 | 296 | } |
290 | 297 | $i++; |
@@ -398,8 +405,9 @@ discard block |
||
398 | 405 | function polygon($points, $color, $width = null, $style = null, $fill = false) { |
399 | 406 | |
400 | 407 | // Scale each point by the AA factor |
401 | - foreach (array_keys($points) as $i) |
|
402 | - $points[$i] *= $this->_aa_factor; |
|
408 | + foreach (array_keys($points) as $i) { |
|
409 | + $points[$i] *= $this->_aa_factor; |
|
410 | + } |
|
403 | 411 | |
404 | 412 | $c = $this->_allocate_color($color); |
405 | 413 | |
@@ -419,10 +427,11 @@ discard block |
||
419 | 427 | |
420 | 428 | imagesetthickness($this->_img, $width); |
421 | 429 | |
422 | - if ( $fill ) |
|
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | - else |
|
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
430 | + if ( $fill ) { |
|
431 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
432 | + } else { |
|
433 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
434 | + } |
|
426 | 435 | |
427 | 436 | } |
428 | 437 | |
@@ -466,10 +475,11 @@ discard block |
||
466 | 475 | |
467 | 476 | imagesetthickness($this->_img, $width); |
468 | 477 | |
469 | - if ( $fill ) |
|
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | - else |
|
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
478 | + if ( $fill ) { |
|
479 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
480 | + } else { |
|
481 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
482 | + } |
|
473 | 483 | |
474 | 484 | } |
475 | 485 | |
@@ -507,8 +517,10 @@ discard block |
||
507 | 517 | |
508 | 518 | } |
509 | 519 | |
510 | - if ( !$src ) |
|
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
520 | + if ( !$src ) { |
|
521 | + return; |
|
522 | + } |
|
523 | + // Probably should add to $_dompdf_errors or whatever here |
|
512 | 524 | |
513 | 525 | // Scale by the AA factor |
514 | 526 | $x *= $this->_aa_factor; |
@@ -550,8 +562,9 @@ discard block |
||
550 | 562 | |
551 | 563 | $c = $this->_allocate_color($color); |
552 | 564 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
554 | - $font .= ".ttf"; |
|
565 | + if ( strpos($font, '.ttf') === false ) { |
|
566 | + $font .= ".ttf"; |
|
567 | + } |
|
555 | 568 | |
556 | 569 | // FIXME: word spacing |
557 | 570 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
@@ -595,8 +608,9 @@ discard block |
||
595 | 608 | */ |
596 | 609 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 610 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
599 | - $font .= ".ttf"; |
|
611 | + if ( strpos($font, '.ttf') === false ) { |
|
612 | + $font .= ".ttf"; |
|
613 | + } |
|
600 | 614 | |
601 | 615 | // FIXME: word spacing |
602 | 616 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
@@ -611,8 +625,9 @@ discard block |
||
611 | 625 | * @return float |
612 | 626 | */ |
613 | 627 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
615 | - $font .= ".ttf"; |
|
628 | + if ( strpos($font, '.ttf') === false ) { |
|
629 | + $font .= ".ttf"; |
|
630 | + } |
|
616 | 631 | |
617 | 632 | // FIXME: word spacing |
618 | 633 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
@@ -649,8 +664,9 @@ discard block |
||
649 | 664 | $dst = $this->_img; |
650 | 665 | } |
651 | 666 | |
652 | - if ( !isset($options["type"]) ) |
|
653 | - $options["type"] = "png"; |
|
667 | + if ( !isset($options["type"]) ) { |
|
668 | + $options["type"] = "png"; |
|
669 | + } |
|
654 | 670 | |
655 | 671 | $type = strtolower($options["type"]); |
656 | 672 | |
@@ -660,8 +676,9 @@ discard block |
||
660 | 676 | |
661 | 677 | case "jpg": |
662 | 678 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
679 | + if ( !isset($options["quality"]) ) { |
|
680 | + $options["quality"] = 75; |
|
681 | + } |
|
665 | 682 | |
666 | 683 | header("Content-type: image/jpeg"); |
667 | 684 | imagejpeg($dst, '', $options["quality"]); |
@@ -674,8 +691,9 @@ discard block |
||
674 | 691 | break; |
675 | 692 | } |
676 | 693 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
678 | - imagedestroy($dst); |
|
694 | + if ( $this->_aa_factor != 1 ) { |
|
695 | + imagedestroy($dst); |
|
696 | + } |
|
679 | 697 | } |
680 | 698 | |
681 | 699 | /** |
@@ -697,8 +715,9 @@ discard block |
||
697 | 715 | $dst = $this->_img; |
698 | 716 | } |
699 | 717 | |
700 | - if ( !isset($options["type"]) ) |
|
701 | - $options["type"] = "png"; |
|
718 | + if ( !isset($options["type"]) ) { |
|
719 | + $options["type"] = "png"; |
|
720 | + } |
|
702 | 721 | |
703 | 722 | $type = $options["type"]; |
704 | 723 | |
@@ -708,8 +727,9 @@ discard block |
||
708 | 727 | |
709 | 728 | case "jpg": |
710 | 729 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
730 | + if ( !isset($options["quality"]) ) { |
|
731 | + $options["quality"] = 75; |
|
732 | + } |
|
713 | 733 | |
714 | 734 | imagejpeg($dst, '', $options["quality"]); |
715 | 735 | break; |
@@ -723,8 +743,9 @@ discard block |
||
723 | 743 | $image = ob_get_contents(); |
724 | 744 | ob_end_clean(); |
725 | 745 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
727 | - imagedestroy($dst); |
|
746 | + if ( $this->_aa_factor != 1 ) { |
|
747 | + imagedestroy($dst); |
|
748 | + } |
|
728 | 749 | |
729 | 750 | return $image; |
730 | 751 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Return the bullet's width |
111 | 111 | * |
112 | - * @return int |
|
112 | + * @return double |
|
113 | 113 | */ |
114 | 114 | function get_width() { |
115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * Override get_margin_height() |
161 | 161 | * |
162 | - * @return int |
|
162 | + * @return double |
|
163 | 163 | */ |
164 | 164 | function get_margin_height() { |
165 | 165 | //Hits only on "inset" lists items, to increase height of box |
@@ -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. |
@@ -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. |
@@ -1,46 +1,46 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: list_bullet_image_frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2005-06-28 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - * |
|
39 | - * Changes |
|
40 | - * @contributor Helmut Tischer <[email protected]> |
|
41 | - * @version 0.5.1.htischer.20090507 |
|
42 | - * - added comment |
|
43 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: list_bullet_image_frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2005-06-28 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 0.5.1.htischer.20090507 |
|
42 | + * - added comment |
|
43 | + */ |
|
44 | 44 | |
45 | 45 | /* $Id: list_bullet_image_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
46 | 46 | |
@@ -52,34 +52,34 @@ discard block |
||
52 | 52 | */ |
53 | 53 | class List_Bullet_Image_Frame_Decorator extends Frame_Decorator { |
54 | 54 | |
55 | - /** |
|
56 | - * The underlying image frame |
|
57 | - * |
|
58 | - * @var Image_Frame_Decorator |
|
59 | - */ |
|
60 | - protected $_img; |
|
55 | + /** |
|
56 | + * The underlying image frame |
|
57 | + * |
|
58 | + * @var Image_Frame_Decorator |
|
59 | + */ |
|
60 | + protected $_img; |
|
61 | 61 | |
62 | - /** |
|
63 | - * The image's width in pixels |
|
64 | - * |
|
65 | - * @var int |
|
66 | - */ |
|
67 | - protected $_width; |
|
62 | + /** |
|
63 | + * The image's width in pixels |
|
64 | + * |
|
65 | + * @var int |
|
66 | + */ |
|
67 | + protected $_width; |
|
68 | 68 | |
69 | - /** |
|
70 | - * The image's height in pixels |
|
71 | - * |
|
72 | - * @var int |
|
73 | - */ |
|
74 | - protected $_height; |
|
69 | + /** |
|
70 | + * The image's height in pixels |
|
71 | + * |
|
72 | + * @var int |
|
73 | + */ |
|
74 | + protected $_height; |
|
75 | 75 | |
76 | - /** |
|
77 | - * Class constructor |
|
78 | - * |
|
79 | - * @param Frame $frame the bullet frame to decorate |
|
80 | - * @param DOMPDF $dompdf the document's dompdf object |
|
81 | - */ |
|
82 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
76 | + /** |
|
77 | + * Class constructor |
|
78 | + * |
|
79 | + * @param Frame $frame the bullet frame to decorate |
|
80 | + * @param DOMPDF $dompdf the document's dompdf object |
|
81 | + */ |
|
82 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
83 | 83 | $style = $frame->get_style(); |
84 | 84 | $url = $style->list_style_image; |
85 | 85 | $frame->get_node()->setAttribute("src", $url); |
@@ -104,38 +104,38 @@ discard block |
||
104 | 104 | // $style->min_height = $this->_height; |
105 | 105 | //} |
106 | 106 | //$style->height = "auto"; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Return the bullet's width |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - function get_width() { |
|
109 | + /** |
|
110 | + * Return the bullet's width |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + function get_width() { |
|
115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
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 | 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 | |
123 | - /** |
|
124 | - * Return the bullet's height |
|
125 | - * |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - function get_height() { |
|
123 | + /** |
|
124 | + * Return the bullet's height |
|
125 | + * |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + function get_height() { |
|
129 | 129 | //based on image height |
130 | 130 | return $this->_height; |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Override get_margin_width |
|
135 | - * |
|
136 | - * @return int |
|
137 | - */ |
|
138 | - function get_margin_width() { |
|
133 | + /** |
|
134 | + * Override get_margin_width |
|
135 | + * |
|
136 | + * @return int |
|
137 | + */ |
|
138 | + function get_margin_width() { |
|
139 | 139 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
140 | 140 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
141 | 141 | //This controls the extra indentation of text to make room for the bullet image. |
@@ -147,42 +147,42 @@ discard block |
||
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 | 149 | $this->_width == 0) |
150 | - return 0; |
|
150 | + return 0; |
|
151 | 151 | //This aligns the "inside" image position with the text. |
152 | 152 | //The text starts to the right of the image. |
153 | 153 | //Between the image and the text there is an added margin of image width. |
154 | 154 | //Where this comes from is unknown. |
155 | 155 | //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size? |
156 | 156 | return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Override get_margin_height() |
|
161 | - * |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - function get_margin_height() { |
|
159 | + /** |
|
160 | + * Override get_margin_height() |
|
161 | + * |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + function get_margin_height() { |
|
165 | 165 | //Hits only on "inset" lists items, to increase height of box |
166 | 166 | //based on image height |
167 | 167 | return $this->_height + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return image url |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - function get_image_url() { |
|
170 | + /** |
|
171 | + * Return image url |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + function get_image_url() { |
|
176 | 176 | return $this->_img->get_image_url(); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Return the image extension |
|
181 | - * |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - function get_image_ext() { |
|
179 | + /** |
|
180 | + * Return the image extension |
|
181 | + * |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + function get_image_ext() { |
|
185 | 185 | return $this->_img->get_image_ext(); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -70,12 +70,19 @@ |
||
70 | 70 | |
71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 72 | |
73 | + /** |
|
74 | + * @param string $sql |
|
75 | + */ |
|
73 | 76 | private static function __query($sql) { |
74 | 77 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
75 | 78 | throw new Exception(pg_last_error(self::$__connection)); |
76 | 79 | return $res; |
77 | 80 | } |
78 | 81 | |
82 | + /** |
|
83 | + * @param integer $page_num |
|
84 | + * @param string|null $data |
|
85 | + */ |
|
79 | 86 | static function store_page($id, $page_num, $data) { |
80 | 87 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
81 | 88 | "page_num=". pg_escape_string($page_num); |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: page_cache.cls.php,v $ |
|
6 | - * Created on: 2004-07-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: page_cache.cls.php,v $ |
|
6 | + * Created on: 2004-07-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: page_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -50,59 +49,59 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Page_Cache { |
52 | 51 | |
53 | - const DB_USER = "dompdf_page_cache"; |
|
54 | - const DB_PASS = "some meaningful password"; |
|
55 | - const DB_NAME = "dompdf_page_cache"; |
|
52 | + const DB_USER = "dompdf_page_cache"; |
|
53 | + const DB_PASS = "some meaningful password"; |
|
54 | + const DB_NAME = "dompdf_page_cache"; |
|
56 | 55 | |
57 | - static private $__connection = null; |
|
56 | + static private $__connection = null; |
|
58 | 57 | |
59 | - function init() { |
|
58 | + function init() { |
|
60 | 59 | if ( is_null(self::$__connection) ) { |
61 | - $con_str = "host=" . DB_HOST . |
|
60 | + $con_str = "host=" . DB_HOST . |
|
62 | 61 | " dbname=" . self::DB_NAME . |
63 | 62 | " user=" . self::DB_USER . |
64 | 63 | " password=" . self::DB_PASS; |
65 | 64 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
65 | + if ( !self::$__connection = pg_connect($con_str) ) |
|
67 | 66 | throw new Exception("Database connection failed."); |
68 | 67 | } |
69 | - } |
|
68 | + } |
|
70 | 69 | |
71 | - function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
70 | + function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
72 | 71 | |
73 | - private static function __query($sql) { |
|
72 | + private static function __query($sql) { |
|
74 | 73 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
74 | + throw new Exception(pg_last_error(self::$__connection)); |
|
76 | 75 | return $res; |
77 | - } |
|
76 | + } |
|
78 | 77 | |
79 | - static function store_page($id, $page_num, $data) { |
|
78 | + static function store_page($id, $page_num, $data) { |
|
80 | 79 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + "page_num=". pg_escape_string($page_num); |
|
82 | 81 | |
83 | 82 | $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
84 | 83 | |
85 | 84 | $row = pg_fetch_assoc($res); |
86 | 85 | |
87 | 86 | if ( $row ) |
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
89 | 88 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
89 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
90 | + pg_escape_string($page_num) . ", ". |
|
91 | + "'". pg_escape_string($data) . "')"); |
|
93 | 92 | |
94 | - } |
|
93 | + } |
|
95 | 94 | |
96 | - static function store_fonts($id, $fonts) { |
|
95 | + static function store_fonts($id, $fonts) { |
|
97 | 96 | self::__query("BEGIN"); |
98 | 97 | // Update the font information |
99 | 98 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
100 | 99 | |
101 | 100 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
101 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | 102 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
104 | 103 | self::__query("COMMIT"); |
105 | - } |
|
104 | + } |
|
106 | 105 | |
107 | 106 | // static function retrieve_page($id, $page_num) { |
108 | 107 | |
@@ -115,45 +114,45 @@ discard block |
||
115 | 114 | |
116 | 115 | // } |
117 | 116 | |
118 | - static function get_page_timestamp($id, $page_num) { |
|
117 | + static function get_page_timestamp($id, $page_num) { |
|
119 | 118 | $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + "page_num=". pg_escape_string($page_num)); |
|
121 | 120 | |
122 | 121 | $row = pg_fetch_assoc($res); |
123 | 122 | |
124 | 123 | return $row["timestamp"]; |
125 | 124 | |
126 | - } |
|
125 | + } |
|
127 | 126 | |
128 | - // Adds the cached document referenced by $id to the provided pdf |
|
129 | - static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
127 | + // Adds the cached document referenced by $id to the provided pdf |
|
128 | + static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
130 | 129 | $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
131 | 130 | |
132 | 131 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 132 | // the pdf |
134 | 133 | while ($row = pg_fetch_assoc($res)) |
135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
134 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
136 | 135 | |
137 | 136 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
138 | 137 | |
139 | 138 | if ( $new_page ) |
140 | - $pdf->new_page(); |
|
139 | + $pdf->new_page(); |
|
141 | 140 | |
142 | 141 | $first = true; |
143 | 142 | while ($row = pg_fetch_assoc($res)) { |
144 | 143 | |
145 | - if ( !$first ) |
|
144 | + if ( !$first ) |
|
146 | 145 | $pdf->new_page(); |
147 | - else |
|
146 | + else |
|
148 | 147 | $first = false; |
149 | 148 | |
150 | - $page = $pdf->reopen_serialized_object($row["data"]); |
|
151 | - //$pdf->close_object(); |
|
152 | - $pdf->add_object($page, "add"); |
|
149 | + $page = $pdf->reopen_serialized_object($row["data"]); |
|
150 | + //$pdf->close_object(); |
|
151 | + $pdf->add_object($page, "add"); |
|
153 | 152 | |
154 | 153 | } |
155 | 154 | |
156 | - } |
|
155 | + } |
|
157 | 156 | } |
158 | 157 | |
159 | 158 | Page_Cache::init(); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | static private $__connection = null; |
58 | 58 | |
59 | 59 | function init() { |
60 | - if ( is_null(self::$__connection) ) { |
|
61 | - $con_str = "host=" . DB_HOST . |
|
62 | - " dbname=" . self::DB_NAME . |
|
63 | - " user=" . self::DB_USER . |
|
64 | - " password=" . self::DB_PASS; |
|
60 | + if (is_null(self::$__connection)) { |
|
61 | + $con_str = "host=".DB_HOST. |
|
62 | + " dbname=".self::DB_NAME. |
|
63 | + " user=".self::DB_USER. |
|
64 | + " password=".self::DB_PASS; |
|
65 | 65 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
66 | + if (!self::$__connection = pg_connect($con_str)) |
|
67 | 67 | throw new Exception("Database connection failed."); |
68 | 68 | } |
69 | 69 | } |
@@ -71,36 +71,36 @@ discard block |
||
71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 72 | |
73 | 73 | private static function __query($sql) { |
74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
74 | + if (!($res = pg_query(self::$__connection, $sql))) |
|
75 | 75 | throw new Exception(pg_last_error(self::$__connection)); |
76 | 76 | return $res; |
77 | 77 | } |
78 | 78 | |
79 | 79 | static function store_page($id, $page_num, $data) { |
80 | - $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
|
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + $where = "WHERE id='".pg_escape_string($id)."' AND ". |
|
81 | + "page_num=".pg_escape_string($page_num); |
|
82 | 82 | |
83 | - $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
|
83 | + $res = self::__query("SELECT timestamp FROM page_cache ".$where); |
|
84 | 84 | |
85 | 85 | $row = pg_fetch_assoc($res); |
86 | 86 | |
87 | - if ( $row ) |
|
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + if ($row) |
|
88 | + self::__query("UPDATE page_cache SET data='".pg_escape_string($data)."' ".$where); |
|
89 | 89 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
90 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('".pg_escape_string($id)."', ". |
|
91 | + pg_escape_string($page_num).", ". |
|
92 | + "'".pg_escape_string($data)."')"); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | 96 | static function store_fonts($id, $fonts) { |
97 | 97 | self::__query("BEGIN"); |
98 | 98 | // Update the font information |
99 | - self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
99 | + self::__query("DELETE FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
100 | 100 | |
101 | 101 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | - pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
|
102 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('". |
|
103 | + pg_escape_string($id)."', '".pg_escape_string($font)."')"); |
|
104 | 104 | self::__query("COMMIT"); |
105 | 105 | } |
106 | 106 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | // } |
117 | 117 | |
118 | 118 | static function get_page_timestamp($id, $page_num) { |
119 | - $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
|
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + $res = self::__query("SELECT timestamp FROM page_cache WHERE id='".pg_escape_string($id)."' AND ". |
|
120 | + "page_num=".pg_escape_string($page_num)); |
|
121 | 121 | |
122 | 122 | $row = pg_fetch_assoc($res); |
123 | 123 | |
@@ -127,22 +127,22 @@ discard block |
||
127 | 127 | |
128 | 128 | // Adds the cached document referenced by $id to the provided pdf |
129 | 129 | static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
130 | - $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
130 | + $res = self::__query("SELECT font_name FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
131 | 131 | |
132 | 132 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 133 | // the pdf |
134 | 134 | while ($row = pg_fetch_assoc($res)) |
135 | 135 | $pdf->get_cpdf()->selectFont($row["font_name"]); |
136 | 136 | |
137 | - $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
|
137 | + $res = self::__query("SELECT data FROM page_cache WHERE id='".pg_escape_string($id)."'"); |
|
138 | 138 | |
139 | - if ( $new_page ) |
|
139 | + if ($new_page) |
|
140 | 140 | $pdf->new_page(); |
141 | 141 | |
142 | 142 | $first = true; |
143 | 143 | while ($row = pg_fetch_assoc($res)) { |
144 | 144 | |
145 | - if ( !$first ) |
|
145 | + if (!$first) |
|
146 | 146 | $pdf->new_page(); |
147 | 147 | else |
148 | 148 | $first = false; |
@@ -63,16 +63,18 @@ discard block |
||
63 | 63 | " user=" . self::DB_USER . |
64 | 64 | " password=" . self::DB_PASS; |
65 | 65 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
67 | - throw new Exception("Database connection failed."); |
|
66 | + if ( !self::$__connection = pg_connect($con_str) ) { |
|
67 | + throw new Exception("Database connection failed."); |
|
68 | + } |
|
68 | 69 | } |
69 | 70 | } |
70 | 71 | |
71 | 72 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 73 | |
73 | 74 | private static function __query($sql) { |
74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
75 | + if ( !($res = pg_query(self::$__connection, $sql)) ) { |
|
76 | + throw new Exception(pg_last_error(self::$__connection)); |
|
77 | + } |
|
76 | 78 | return $res; |
77 | 79 | } |
78 | 80 | |
@@ -84,12 +86,13 @@ discard block |
||
84 | 86 | |
85 | 87 | $row = pg_fetch_assoc($res); |
86 | 88 | |
87 | - if ( $row ) |
|
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
89 | - else |
|
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
89 | + if ( $row ) { |
|
90 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
91 | + } else { |
|
92 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | 93 | pg_escape_string($page_num) . ", ". |
92 | 94 | "'". pg_escape_string($data) . "')"); |
95 | + } |
|
93 | 96 | |
94 | 97 | } |
95 | 98 | |
@@ -98,9 +101,10 @@ discard block |
||
98 | 101 | // Update the font information |
99 | 102 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
100 | 103 | |
101 | - foreach (array_keys($fonts) as $font) |
|
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
104 | + foreach (array_keys($fonts) as $font) { |
|
105 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | 106 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
107 | + } |
|
104 | 108 | self::__query("COMMIT"); |
105 | 109 | } |
106 | 110 | |
@@ -131,21 +135,24 @@ discard block |
||
131 | 135 | |
132 | 136 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 137 | // the pdf |
134 | - while ($row = pg_fetch_assoc($res)) |
|
135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
138 | + while ($row = pg_fetch_assoc($res)) { |
|
139 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
140 | + } |
|
136 | 141 | |
137 | 142 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
138 | 143 | |
139 | - if ( $new_page ) |
|
140 | - $pdf->new_page(); |
|
144 | + if ( $new_page ) { |
|
145 | + $pdf->new_page(); |
|
146 | + } |
|
141 | 147 | |
142 | 148 | $first = true; |
143 | 149 | while ($row = pg_fetch_assoc($res)) { |
144 | 150 | |
145 | - if ( !$first ) |
|
146 | - $pdf->new_page(); |
|
147 | - else |
|
148 | - $first = false; |
|
151 | + if ( !$first ) { |
|
152 | + $pdf->new_page(); |
|
153 | + } else { |
|
154 | + $first = false; |
|
155 | + } |
|
149 | 156 | |
150 | 157 | $page = $pdf->reopen_serialized_object($row["data"]); |
151 | 158 | //$pdf->close_object(); |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | * @link http://www.w3.org/TR/CSS21/page.html#forced |
172 | 172 | * |
173 | 173 | * @param Frame $frame the frame to check |
174 | - * @return bool true if a page break occured |
|
174 | + * @return null|boolean true if a page break occured |
|
175 | 175 | */ |
176 | 176 | function check_forced_page_break(Frame $frame) { |
177 | 177 | |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * correct location. |
427 | 427 | * |
428 | 428 | * @param Frame $frame the frame to check |
429 | - * @return Frame the frame following the page break |
|
429 | + * @return boolean the frame following the page break |
|
430 | 430 | */ |
431 | 431 | function check_page_break(Frame $frame) { |
432 | 432 | // Do not split if we have already |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | * @param float $h |
118 | 118 | */ |
119 | 119 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
120 | - parent::set_containing_block($x,$y,$w,$h); |
|
120 | + parent::set_containing_block($x, $y, $w, $h); |
|
121 | 121 | $w = $this->get_containing_block("w"); |
122 | - if ( isset($h) ) |
|
122 | + if (isset($h)) |
|
123 | 123 | $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
124 | 124 | } |
125 | 125 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | function check_forced_page_break(Frame $frame) { |
177 | 177 | |
178 | 178 | // Skip check if page is already split |
179 | - if ( $this->_page_full ) |
|
179 | + if ($this->_page_full) |
|
180 | 180 | return; |
181 | 181 | |
182 | 182 | $block_types = array("block", "list-item", "table"); |
@@ -184,15 +184,15 @@ discard block |
||
184 | 184 | |
185 | 185 | $style = $frame->get_style(); |
186 | 186 | |
187 | - if ( !in_array($style->display, $block_types) ) |
|
187 | + if (!in_array($style->display, $block_types)) |
|
188 | 188 | return false; |
189 | 189 | |
190 | 190 | // Find the previous block-level sibling |
191 | 191 | $prev = $frame->get_prev_sibling(); |
192 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
192 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
193 | 193 | $prev = $prev->get_prev_sibling(); |
194 | 194 | |
195 | - if ( in_array($style->page_break_before, $page_breaks) ) { |
|
195 | + if (in_array($style->page_break_before, $page_breaks)) { |
|
196 | 196 | |
197 | 197 | // Prevent cascading splits |
198 | 198 | $frame->split(); |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | return true; |
204 | 204 | } |
205 | 205 | |
206 | - if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
|
206 | + if (($prev && in_array($prev->get_style()->page_break_after, $page_breaks))) { |
|
207 | 207 | // Prevent cascading splits |
208 | 208 | $frame->split(); |
209 | 209 | $prev->get_style()->page_break_after = "auto"; |
@@ -270,32 +270,32 @@ discard block |
||
270 | 270 | */ |
271 | 271 | |
272 | 272 | $block_types = array("block", "list-item", "table"); |
273 | - dompdf_debug("page-break", "_page_break_allowed(" . $frame->get_node()->nodeName. ")"); |
|
273 | + dompdf_debug("page-break", "_page_break_allowed(".$frame->get_node()->nodeName.")"); |
|
274 | 274 | $display = $frame->get_style()->display; |
275 | 275 | |
276 | 276 | // Block Frames (1): |
277 | - if ( in_array($display, $block_types) ) { |
|
277 | + if (in_array($display, $block_types)) { |
|
278 | 278 | |
279 | 279 | // Avoid breaks within table-cells |
280 | - if ( $this->_in_table ) { |
|
281 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
280 | + if ($this->_in_table) { |
|
281 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | 285 | // Rules A & B |
286 | 286 | |
287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
287 | + if ($frame->get_style()->page_break_before === "avoid") { |
|
288 | 288 | dompdf_debug("page-break", "before: avoid"); |
289 | 289 | return false; |
290 | 290 | } |
291 | 291 | |
292 | 292 | // Find the preceeding block-level sibling |
293 | 293 | $prev = $frame->get_prev_sibling(); |
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
294 | + while ($prev && !in_array($prev->get_style()->display, $block_types)) |
|
295 | 295 | $prev = $prev->get_prev_sibling(); |
296 | 296 | |
297 | 297 | // Does the previous element allow a page break after? |
298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
298 | + if ($prev && $prev->get_style()->page_break_after === "avoid") { |
|
299 | 299 | dompdf_debug("page-break", "after: avoid"); |
300 | 300 | return false; |
301 | 301 | } |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | // If both $prev & $frame have the same parent, check the parent's |
304 | 304 | // page_break_inside property. |
305 | 305 | $parent = $frame->get_parent(); |
306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
306 | + if ($prev && $parent && $parent->get_style()->page_break_inside === "avoid") { |
|
307 | 307 | dompdf_debug("page-break", "parent inside: avoid"); |
308 | 308 | return false; |
309 | 309 | } |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | // To prevent cascading page breaks when a top-level element has |
312 | 312 | // page-break-inside: avoid, ensure that at least one frame is |
313 | 313 | // on the page before splitting. |
314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
314 | + if ($parent->get_node()->nodeName === "body" && !$prev) { |
|
315 | 315 | // We are the body's first child |
316 | 316 | dompdf_debug("page-break", "Body's first child."); |
317 | 317 | return false; |
@@ -319,8 +319,8 @@ discard block |
||
319 | 319 | |
320 | 320 | // If the frame is the first block-level frame, use the value from |
321 | 321 | // $frame's parent instead. |
322 | - if ( !$prev && $parent ) |
|
323 | - return $this->_page_break_allowed( $parent ); |
|
322 | + if (!$prev && $parent) |
|
323 | + return $this->_page_break_allowed($parent); |
|
324 | 324 | |
325 | 325 | dompdf_debug("page-break", "block: break allowed"); |
326 | 326 | return true; |
@@ -328,17 +328,17 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | // Inline frames (2): |
331 | - else if ( in_array($display, Style::$INLINE_TYPES) ) { |
|
331 | + else if (in_array($display, Style::$INLINE_TYPES)) { |
|
332 | 332 | |
333 | 333 | // Avoid breaks within table-cells |
334 | - if ( $this->_in_table ) { |
|
335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
334 | + if ($this->_in_table) { |
|
335 | + dompdf_debug("page-break", "In table: ".$this->_in_table); |
|
336 | 336 | return false; |
337 | 337 | } |
338 | 338 | |
339 | 339 | // Rule C |
340 | 340 | $block_parent = $frame->find_block_parent(); |
341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
341 | + if (count($block_parent->get_lines()) < $frame->get_style()->orphans) { |
|
342 | 342 | dompdf_debug("page-break", "orphans"); |
343 | 343 | return false; |
344 | 344 | } |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | // Rule D |
350 | 350 | $p = $block_parent; |
351 | 351 | while ($p) { |
352 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
352 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
353 | 353 | dompdf_debug("page-break", "parent->inside: avoid"); |
354 | 354 | return false; |
355 | 355 | } |
@@ -360,32 +360,32 @@ discard block |
||
360 | 360 | // page-break-inside: avoid, ensure that at least one frame with |
361 | 361 | // some content is on the page before splitting. |
362 | 362 | $prev = $frame->get_prev_sibling(); |
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
363 | + while ($prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "")) |
|
364 | 364 | $prev = $prev->get_prev_sibling(); |
365 | 365 | |
366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
366 | + if ($block_parent->get_node()->nodeName === "body" && !$prev) { |
|
367 | 367 | // We are the body's first child |
368 | 368 | dompdf_debug("page-break", "Body's first child."); |
369 | 369 | return false; |
370 | 370 | } |
371 | 371 | |
372 | 372 | // Skip breaks on empty text nodes |
373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
374 | - $frame->get_node()->nodeValue == "" ) |
|
373 | + if ($frame->get_node()->nodeName === "#text" && |
|
374 | + $frame->get_node()->nodeValue == "") |
|
375 | 375 | return false; |
376 | 376 | |
377 | 377 | dompdf_debug("page-break", "inline: break allowed"); |
378 | 378 | return true; |
379 | 379 | |
380 | 380 | // Table-rows |
381 | - } else if ( $display === "table-row" ) { |
|
381 | + } else if ($display === "table-row") { |
|
382 | 382 | |
383 | 383 | // Simply check if the parent table's page_break_inside property is |
384 | 384 | // not 'avoid' |
385 | 385 | $p = Table_Frame_Decorator::find_parent_table($frame); |
386 | 386 | |
387 | 387 | while ($p) { |
388 | - if ( $p->get_style()->page_break_inside === "avoid" ) { |
|
388 | + if ($p->get_style()->page_break_inside === "avoid") { |
|
389 | 389 | dompdf_debug("page-break", "parent->inside: avoid"); |
390 | 390 | return false; |
391 | 391 | } |
@@ -393,28 +393,28 @@ discard block |
||
393 | 393 | } |
394 | 394 | |
395 | 395 | // Avoid breaking after the first row of a table |
396 | - if ( $p && $p->get_first_child() === $frame) { |
|
396 | + if ($p && $p->get_first_child() === $frame) { |
|
397 | 397 | dompdf_debug("page-break", "table: first-row"); |
398 | 398 | return false; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // If this is a nested table, prevent the page from breaking |
402 | - if ( $this->_in_table > 1 ) { |
|
402 | + if ($this->_in_table > 1) { |
|
403 | 403 | dompdf_debug("page-break", "table: nested table"); |
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
407 | + dompdf_debug("page-break", "table-row/row-groups: break allowed"); |
|
408 | 408 | return true; |
409 | 409 | |
410 | - } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
|
410 | + } else if (in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) { |
|
411 | 411 | |
412 | 412 | // Disallow breaks at row-groups: only split at row boundaries |
413 | 413 | return false; |
414 | 414 | |
415 | 415 | } else { |
416 | 416 | |
417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
417 | + dompdf_debug("page-break", "? ".$frame->get_style()->display.""); |
|
418 | 418 | return false; |
419 | 419 | } |
420 | 420 | |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | */ |
431 | 431 | function check_page_break(Frame $frame) { |
432 | 432 | // Do not split if we have already |
433 | - if ( $this->_page_full ) |
|
433 | + if ($this->_page_full) |
|
434 | 434 | return false; |
435 | 435 | |
436 | 436 | // Determine the frame's maximum y value |
@@ -439,7 +439,7 @@ discard block |
||
439 | 439 | // If a split is to occur here, then the bottom margins & paddings of all |
440 | 440 | // parents of $frame must fit on the page as well: |
441 | 441 | $p = $frame->get_parent(); |
442 | - while ( $p ) { |
|
442 | + while ($p) { |
|
443 | 443 | $style = $p->get_style(); |
444 | 444 | $max_y += $style->length_in_pt(array($style->margin_bottom, |
445 | 445 | $style->padding_bottom, |
@@ -449,12 +449,12 @@ discard block |
||
449 | 449 | |
450 | 450 | |
451 | 451 | // Check if $frame flows off the page |
452 | - if ( $max_y <= $this->_bottom_page_margin ) |
|
452 | + if ($max_y <= $this->_bottom_page_margin) |
|
453 | 453 | // no: do nothing |
454 | 454 | return false; |
455 | 455 | |
456 | 456 | dompdf_debug("page-break", "check_page_break"); |
457 | - dompdf_debug("page-break", "in_table: " . $this->_in_table); |
|
457 | + dompdf_debug("page-break", "in_table: ".$this->_in_table); |
|
458 | 458 | |
459 | 459 | |
460 | 460 | // yes: determine page break location |
@@ -463,42 +463,42 @@ discard block |
||
463 | 463 | |
464 | 464 | $in_table = $this->_in_table; |
465 | 465 | |
466 | - dompdf_debug("page-break","Starting search"); |
|
467 | - while ( $iter ) { |
|
466 | + dompdf_debug("page-break", "Starting search"); |
|
467 | + while ($iter) { |
|
468 | 468 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
469 | - if ( $iter === $this ) { |
|
469 | + if ($iter === $this) { |
|
470 | 470 | dompdf_debug("page-break", "reached root."); |
471 | 471 | // We've reached the root in our search. Just split at $frame. |
472 | 472 | break; |
473 | 473 | } |
474 | 474 | |
475 | - if ( $this->_page_break_allowed($iter) ) { |
|
476 | - dompdf_debug("page-break","break allowed, splitting."); |
|
475 | + if ($this->_page_break_allowed($iter)) { |
|
476 | + dompdf_debug("page-break", "break allowed, splitting."); |
|
477 | 477 | $iter->split(); |
478 | 478 | $this->_page_full = true; |
479 | 479 | $this->_in_table = $in_table; |
480 | 480 | return true; |
481 | 481 | } |
482 | 482 | |
483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
483 | + if (!$flg && $next = $iter->get_last_child()) { |
|
484 | 484 | dompdf_debug("page-break", "following last child."); |
485 | 485 | |
486 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
|
486 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES)) |
|
487 | 487 | $this->_in_table++; |
488 | 488 | |
489 | 489 | $iter = $next; |
490 | 490 | continue; |
491 | 491 | } |
492 | 492 | |
493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
493 | + if ($next = $iter->get_prev_sibling()) { |
|
494 | 494 | dompdf_debug("page-break", "following prev sibling."); |
495 | 495 | |
496 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
497 | - !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
496 | + if (in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
497 | + !in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
498 | 498 | $this->_in_table++; |
499 | 499 | |
500 | - else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
501 | - in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
500 | + else if (!in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
501 | + in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
502 | 502 | $this->_in_table--; |
503 | 503 | |
504 | 504 | $iter = $next; |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | continue; |
507 | 507 | } |
508 | 508 | |
509 | - if ( $next = $iter->get_parent() ) { |
|
509 | + if ($next = $iter->get_parent()) { |
|
510 | 510 | dompdf_debug("page-break", "following parent."); |
511 | 511 | |
512 | - if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
512 | + if (in_array($iter->get_style()->display, Style::$TABLE_TYPES)) |
|
513 | 513 | $this->_in_table--; |
514 | 514 | |
515 | 515 | $iter = $next; |
@@ -527,17 +527,17 @@ discard block |
||
527 | 527 | dompdf_debug("page-break", "no valid break found, just splitting."); |
528 | 528 | |
529 | 529 | // If we are in a table, backtrack to the nearest top-level table row |
530 | - if ( $this->_in_table ) { |
|
530 | + if ($this->_in_table) { |
|
531 | 531 | $num_tables = $this->_in_table - 1; |
532 | 532 | |
533 | 533 | $iter = $frame; |
534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
534 | + while ($iter && $num_tables && $iter->get_style->display !== "table") { |
|
535 | 535 | $iter = $iter->get_parent(); |
536 | 536 | $num_tables--; |
537 | 537 | } |
538 | 538 | |
539 | 539 | $iter = $frame; |
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
540 | + while ($iter && $iter->get_style()->display !== "table-row") |
|
541 | 541 | $iter = $iter->get_parent(); |
542 | 542 | |
543 | 543 | $iter->split(); |
@@ -119,8 +119,10 @@ discard block |
||
119 | 119 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
120 | 120 | parent::set_containing_block($x,$y,$w,$h); |
121 | 121 | $w = $this->get_containing_block("w"); |
122 | - if ( isset($h) ) |
|
123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
122 | + if ( isset($h) ) { |
|
123 | + $this->_bottom_page_margin = $h; |
|
124 | + } |
|
125 | + // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
124 | 126 | } |
125 | 127 | |
126 | 128 | /** |
@@ -176,21 +178,24 @@ discard block |
||
176 | 178 | function check_forced_page_break(Frame $frame) { |
177 | 179 | |
178 | 180 | // Skip check if page is already split |
179 | - if ( $this->_page_full ) |
|
180 | - return; |
|
181 | + if ( $this->_page_full ) { |
|
182 | + return; |
|
183 | + } |
|
181 | 184 | |
182 | 185 | $block_types = array("block", "list-item", "table"); |
183 | 186 | $page_breaks = array("always", "left", "right"); |
184 | 187 | |
185 | 188 | $style = $frame->get_style(); |
186 | 189 | |
187 | - if ( !in_array($style->display, $block_types) ) |
|
188 | - return false; |
|
190 | + if ( !in_array($style->display, $block_types) ) { |
|
191 | + return false; |
|
192 | + } |
|
189 | 193 | |
190 | 194 | // Find the previous block-level sibling |
191 | 195 | $prev = $frame->get_prev_sibling(); |
192 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
193 | - $prev = $prev->get_prev_sibling(); |
|
196 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) { |
|
197 | + $prev = $prev->get_prev_sibling(); |
|
198 | + } |
|
194 | 199 | |
195 | 200 | if ( in_array($style->page_break_before, $page_breaks) ) { |
196 | 201 | |
@@ -291,8 +296,9 @@ discard block |
||
291 | 296 | |
292 | 297 | // Find the preceeding block-level sibling |
293 | 298 | $prev = $frame->get_prev_sibling(); |
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
295 | - $prev = $prev->get_prev_sibling(); |
|
299 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) { |
|
300 | + $prev = $prev->get_prev_sibling(); |
|
301 | + } |
|
296 | 302 | |
297 | 303 | // Does the previous element allow a page break after? |
298 | 304 | if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
@@ -319,8 +325,9 @@ discard block |
||
319 | 325 | |
320 | 326 | // If the frame is the first block-level frame, use the value from |
321 | 327 | // $frame's parent instead. |
322 | - if ( !$prev && $parent ) |
|
323 | - return $this->_page_break_allowed( $parent ); |
|
328 | + if ( !$prev && $parent ) { |
|
329 | + return $this->_page_break_allowed( $parent ); |
|
330 | + } |
|
324 | 331 | |
325 | 332 | dompdf_debug("page-break", "block: break allowed"); |
326 | 333 | return true; |
@@ -360,8 +367,9 @@ discard block |
||
360 | 367 | // page-break-inside: avoid, ensure that at least one frame with |
361 | 368 | // some content is on the page before splitting. |
362 | 369 | $prev = $frame->get_prev_sibling(); |
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
364 | - $prev = $prev->get_prev_sibling(); |
|
370 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) { |
|
371 | + $prev = $prev->get_prev_sibling(); |
|
372 | + } |
|
365 | 373 | |
366 | 374 | if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
367 | 375 | // We are the body's first child |
@@ -371,8 +379,9 @@ discard block |
||
371 | 379 | |
372 | 380 | // Skip breaks on empty text nodes |
373 | 381 | if ( $frame->get_node()->nodeName === "#text" && |
374 | - $frame->get_node()->nodeValue == "" ) |
|
375 | - return false; |
|
382 | + $frame->get_node()->nodeValue == "" ) { |
|
383 | + return false; |
|
384 | + } |
|
376 | 385 | |
377 | 386 | dompdf_debug("page-break", "inline: break allowed"); |
378 | 387 | return true; |
@@ -430,8 +439,9 @@ discard block |
||
430 | 439 | */ |
431 | 440 | function check_page_break(Frame $frame) { |
432 | 441 | // Do not split if we have already |
433 | - if ( $this->_page_full ) |
|
434 | - return false; |
|
442 | + if ( $this->_page_full ) { |
|
443 | + return false; |
|
444 | + } |
|
435 | 445 | |
436 | 446 | // Determine the frame's maximum y value |
437 | 447 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -449,9 +459,10 @@ discard block |
||
449 | 459 | |
450 | 460 | |
451 | 461 | // Check if $frame flows off the page |
452 | - if ( $max_y <= $this->_bottom_page_margin ) |
|
453 | - // no: do nothing |
|
462 | + if ( $max_y <= $this->_bottom_page_margin ) { |
|
463 | + // no: do nothing |
|
454 | 464 | return false; |
465 | + } |
|
455 | 466 | |
456 | 467 | dompdf_debug("page-break", "check_page_break"); |
457 | 468 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -483,8 +494,9 @@ discard block |
||
483 | 494 | if ( !$flg && $next = $iter->get_last_child() ) { |
484 | 495 | dompdf_debug("page-break", "following last child."); |
485 | 496 | |
486 | - if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
|
487 | - $this->_in_table++; |
|
497 | + if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) { |
|
498 | + $this->_in_table++; |
|
499 | + } |
|
488 | 500 | |
489 | 501 | $iter = $next; |
490 | 502 | continue; |
@@ -494,12 +506,12 @@ discard block |
||
494 | 506 | dompdf_debug("page-break", "following prev sibling."); |
495 | 507 | |
496 | 508 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
497 | - !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
498 | - $this->_in_table++; |
|
499 | - |
|
500 | - else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
501 | - in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
502 | - $this->_in_table--; |
|
509 | + !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
510 | + $this->_in_table++; |
|
511 | + } else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
|
512 | + in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
513 | + $this->_in_table--; |
|
514 | + } |
|
503 | 515 | |
504 | 516 | $iter = $next; |
505 | 517 | $flg = false; |
@@ -509,8 +521,9 @@ discard block |
||
509 | 521 | if ( $next = $iter->get_parent() ) { |
510 | 522 | dompdf_debug("page-break", "following parent."); |
511 | 523 | |
512 | - if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
|
513 | - $this->_in_table--; |
|
524 | + if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) { |
|
525 | + $this->_in_table--; |
|
526 | + } |
|
514 | 527 | |
515 | 528 | $iter = $next; |
516 | 529 | $flg = true; |
@@ -537,8 +550,9 @@ discard block |
||
537 | 550 | } |
538 | 551 | |
539 | 552 | $iter = $frame; |
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
541 | - $iter = $iter->get_parent(); |
|
553 | + while ($iter && $iter->get_style()->display !== "table-row" ) { |
|
554 | + $iter = $iter->get_parent(); |
|
555 | + } |
|
542 | 556 | |
543 | 557 | $iter->split(); |
544 | 558 | $this->_page_full = true; |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: page_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,137 +46,137 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Page_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - /** |
|
51 | - * y value of bottom page margin |
|
52 | - * |
|
53 | - * @var float |
|
54 | - */ |
|
55 | - protected $_bottom_page_margin; |
|
56 | - |
|
57 | - /** |
|
58 | - * Flag indicating page is full. |
|
59 | - * |
|
60 | - * @var bool |
|
61 | - */ |
|
62 | - protected $_page_full; |
|
63 | - |
|
64 | - /** |
|
65 | - * Number of tables currently being reflowed |
|
66 | - * |
|
67 | - * @var int |
|
68 | - */ |
|
69 | - protected $_in_table; |
|
70 | - |
|
71 | - /** |
|
72 | - * The pdf renderer |
|
73 | - * |
|
74 | - * @var Renderer |
|
75 | - */ |
|
76 | - protected $_renderer; |
|
77 | - |
|
78 | - //........................................................................ |
|
79 | - |
|
80 | - /** |
|
81 | - * Class constructor |
|
82 | - * |
|
83 | - * @param Frame $frame the frame to decorate |
|
84 | - */ |
|
85 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
49 | + /** |
|
50 | + * y value of bottom page margin |
|
51 | + * |
|
52 | + * @var float |
|
53 | + */ |
|
54 | + protected $_bottom_page_margin; |
|
55 | + |
|
56 | + /** |
|
57 | + * Flag indicating page is full. |
|
58 | + * |
|
59 | + * @var bool |
|
60 | + */ |
|
61 | + protected $_page_full; |
|
62 | + |
|
63 | + /** |
|
64 | + * Number of tables currently being reflowed |
|
65 | + * |
|
66 | + * @var int |
|
67 | + */ |
|
68 | + protected $_in_table; |
|
69 | + |
|
70 | + /** |
|
71 | + * The pdf renderer |
|
72 | + * |
|
73 | + * @var Renderer |
|
74 | + */ |
|
75 | + protected $_renderer; |
|
76 | + |
|
77 | + //........................................................................ |
|
78 | + |
|
79 | + /** |
|
80 | + * Class constructor |
|
81 | + * |
|
82 | + * @param Frame $frame the frame to decorate |
|
83 | + */ |
|
84 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
86 | 85 | parent::__construct($frame, $dompdf); |
87 | 86 | $this->_page_full = false; |
88 | 87 | $this->_in_table = 0; |
89 | 88 | $this->_bottom_page_margin = null; |
90 | - } |
|
89 | + } |
|
91 | 90 | |
92 | 91 | |
93 | - /** |
|
94 | - * Set the renderer used for this pdf |
|
95 | - * |
|
96 | - * @param Renderer $renderer the renderer to use |
|
97 | - */ |
|
98 | - function set_renderer($renderer) { |
|
92 | + /** |
|
93 | + * Set the renderer used for this pdf |
|
94 | + * |
|
95 | + * @param Renderer $renderer the renderer to use |
|
96 | + */ |
|
97 | + function set_renderer($renderer) { |
|
99 | 98 | $this->_renderer = $renderer; |
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Return the renderer used for this pdf |
|
104 | - * |
|
105 | - * @return Renderer |
|
106 | - */ |
|
107 | - function get_renderer() { |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Return the renderer used for this pdf |
|
103 | + * |
|
104 | + * @return Renderer |
|
105 | + */ |
|
106 | + function get_renderer() { |
|
108 | 107 | return $this->_renderer; |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
113 | - * |
|
114 | - * @param float $x |
|
115 | - * @param float $y |
|
116 | - * @param float $w |
|
117 | - * @param float $h |
|
118 | - */ |
|
119 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
112 | + * |
|
113 | + * @param float $x |
|
114 | + * @param float $y |
|
115 | + * @param float $w |
|
116 | + * @param float $h |
|
117 | + */ |
|
118 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
120 | 119 | parent::set_containing_block($x,$y,$w,$h); |
121 | 120 | $w = $this->get_containing_block("w"); |
122 | 121 | if ( isset($h) ) |
123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns true if the page is full and is no longer accepting frames. |
|
128 | - * |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - function is_full() { |
|
122 | + $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns true if the page is full and is no longer accepting frames. |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + function is_full() { |
|
132 | 131 | return $this->_page_full; |
133 | - } |
|
132 | + } |
|
134 | 133 | |
135 | - /** |
|
136 | - * Start a new page by resetting the full flag. |
|
137 | - */ |
|
138 | - function next_page() { |
|
134 | + /** |
|
135 | + * Start a new page by resetting the full flag. |
|
136 | + */ |
|
137 | + function next_page() { |
|
139 | 138 | $this->_renderer->new_page(); |
140 | 139 | $this->_page_full = false; |
141 | - } |
|
140 | + } |
|
142 | 141 | |
143 | - /** |
|
144 | - * Indicate to the page that a table is currently being reflowed. |
|
145 | - */ |
|
146 | - function table_reflow_start() { |
|
142 | + /** |
|
143 | + * Indicate to the page that a table is currently being reflowed. |
|
144 | + */ |
|
145 | + function table_reflow_start() { |
|
147 | 146 | $this->_in_table++; |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - /** |
|
151 | - * Indicate to the page that table reflow is finished. |
|
152 | - */ |
|
153 | - function table_reflow_end() { |
|
149 | + /** |
|
150 | + * Indicate to the page that table reflow is finished. |
|
151 | + */ |
|
152 | + function table_reflow_end() { |
|
154 | 153 | $this->_in_table--; |
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Return whether we are currently in a nested table or not |
|
159 | - * |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - function in_nested_table() { |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Return whether we are currently in a nested table or not |
|
158 | + * |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + function in_nested_table() { |
|
163 | 162 | return $this->_in_table > 1; |
164 | - } |
|
163 | + } |
|
165 | 164 | |
166 | - /** |
|
167 | - * Check if a forced page break is required before $frame. This uses the |
|
168 | - * frame's page_break_before property as well as the preceeding frame's |
|
169 | - * page_break_after property. |
|
170 | - * |
|
171 | - * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
172 | - * |
|
173 | - * @param Frame $frame the frame to check |
|
174 | - * @return bool true if a page break occured |
|
175 | - */ |
|
176 | - function check_forced_page_break(Frame $frame) { |
|
165 | + /** |
|
166 | + * Check if a forced page break is required before $frame. This uses the |
|
167 | + * frame's page_break_before property as well as the preceeding frame's |
|
168 | + * page_break_after property. |
|
169 | + * |
|
170 | + * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
171 | + * |
|
172 | + * @param Frame $frame the frame to check |
|
173 | + * @return bool true if a page break occured |
|
174 | + */ |
|
175 | + function check_forced_page_break(Frame $frame) { |
|
177 | 176 | |
178 | 177 | // Skip check if page is already split |
179 | 178 | if ( $this->_page_full ) |
180 | - return; |
|
179 | + return; |
|
181 | 180 | |
182 | 181 | $block_types = array("block", "list-item", "table"); |
183 | 182 | $page_breaks = array("always", "left", "right"); |
@@ -185,42 +184,42 @@ discard block |
||
185 | 184 | $style = $frame->get_style(); |
186 | 185 | |
187 | 186 | if ( !in_array($style->display, $block_types) ) |
188 | - return false; |
|
187 | + return false; |
|
189 | 188 | |
190 | 189 | // Find the previous block-level sibling |
191 | 190 | $prev = $frame->get_prev_sibling(); |
192 | 191 | while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
193 | - $prev = $prev->get_prev_sibling(); |
|
192 | + $prev = $prev->get_prev_sibling(); |
|
194 | 193 | |
195 | 194 | if ( in_array($style->page_break_before, $page_breaks) ) { |
196 | 195 | |
197 | - // Prevent cascading splits |
|
198 | - $frame->split(); |
|
199 | - // We have to grab the style again here because split() resets |
|
200 | - // $frame->style to the frame's orignal style. |
|
201 | - $frame->get_style()->page_break_before = "auto"; |
|
202 | - $this->_page_full = true; |
|
203 | - return true; |
|
196 | + // Prevent cascading splits |
|
197 | + $frame->split(); |
|
198 | + // We have to grab the style again here because split() resets |
|
199 | + // $frame->style to the frame's orignal style. |
|
200 | + $frame->get_style()->page_break_before = "auto"; |
|
201 | + $this->_page_full = true; |
|
202 | + return true; |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
207 | - // Prevent cascading splits |
|
208 | - $frame->split(); |
|
209 | - $prev->get_style()->page_break_after = "auto"; |
|
210 | - $this->_page_full = true; |
|
211 | - return true; |
|
206 | + // Prevent cascading splits |
|
207 | + $frame->split(); |
|
208 | + $prev->get_style()->page_break_after = "auto"; |
|
209 | + $this->_page_full = true; |
|
210 | + return true; |
|
212 | 211 | } |
213 | 212 | |
214 | 213 | return false; |
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Determine if a page break is allowed before $frame |
|
219 | - * |
|
220 | - * @param Frame $frame the frame to check |
|
221 | - * @return bool true if a break is allowed, false otherwise |
|
222 | - */ |
|
223 | - protected function _page_break_allowed(Frame $frame) { |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Determine if a page break is allowed before $frame |
|
218 | + * |
|
219 | + * @param Frame $frame the frame to check |
|
220 | + * @return bool true if a break is allowed, false otherwise |
|
221 | + */ |
|
222 | + protected function _page_break_allowed(Frame $frame) { |
|
224 | 223 | /** |
225 | 224 | * |
226 | 225 | * http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks |
@@ -276,162 +275,162 @@ discard block |
||
276 | 275 | // Block Frames (1): |
277 | 276 | if ( in_array($display, $block_types) ) { |
278 | 277 | |
279 | - // Avoid breaks within table-cells |
|
280 | - if ( $this->_in_table ) { |
|
278 | + // Avoid breaks within table-cells |
|
279 | + if ( $this->_in_table ) { |
|
281 | 280 | dompdf_debug("page-break", "In table: " . $this->_in_table); |
282 | 281 | return false; |
283 | - } |
|
282 | + } |
|
284 | 283 | |
285 | - // Rules A & B |
|
284 | + // Rules A & B |
|
286 | 285 | |
287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
286 | + if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
288 | 287 | dompdf_debug("page-break", "before: avoid"); |
289 | 288 | return false; |
290 | - } |
|
289 | + } |
|
291 | 290 | |
292 | - // Find the preceeding block-level sibling |
|
293 | - $prev = $frame->get_prev_sibling(); |
|
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
291 | + // Find the preceeding block-level sibling |
|
292 | + $prev = $frame->get_prev_sibling(); |
|
293 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
295 | 294 | $prev = $prev->get_prev_sibling(); |
296 | 295 | |
297 | - // Does the previous element allow a page break after? |
|
298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
296 | + // Does the previous element allow a page break after? |
|
297 | + if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
299 | 298 | dompdf_debug("page-break", "after: avoid"); |
300 | 299 | return false; |
301 | - } |
|
300 | + } |
|
302 | 301 | |
303 | - // If both $prev & $frame have the same parent, check the parent's |
|
304 | - // page_break_inside property. |
|
305 | - $parent = $frame->get_parent(); |
|
306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
307 | - dompdf_debug("page-break", "parent inside: avoid"); |
|
302 | + // If both $prev & $frame have the same parent, check the parent's |
|
303 | + // page_break_inside property. |
|
304 | + $parent = $frame->get_parent(); |
|
305 | + if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
306 | + dompdf_debug("page-break", "parent inside: avoid"); |
|
308 | 307 | return false; |
309 | - } |
|
308 | + } |
|
310 | 309 | |
311 | - // To prevent cascading page breaks when a top-level element has |
|
312 | - // page-break-inside: avoid, ensure that at least one frame is |
|
313 | - // on the page before splitting. |
|
314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
310 | + // To prevent cascading page breaks when a top-level element has |
|
311 | + // page-break-inside: avoid, ensure that at least one frame is |
|
312 | + // on the page before splitting. |
|
313 | + if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
315 | 314 | // We are the body's first child |
316 | - dompdf_debug("page-break", "Body's first child."); |
|
315 | + dompdf_debug("page-break", "Body's first child."); |
|
317 | 316 | return false; |
318 | - } |
|
317 | + } |
|
319 | 318 | |
320 | - // If the frame is the first block-level frame, use the value from |
|
321 | - // $frame's parent instead. |
|
322 | - if ( !$prev && $parent ) |
|
319 | + // If the frame is the first block-level frame, use the value from |
|
320 | + // $frame's parent instead. |
|
321 | + if ( !$prev && $parent ) |
|
323 | 322 | return $this->_page_break_allowed( $parent ); |
324 | 323 | |
325 | - dompdf_debug("page-break", "block: break allowed"); |
|
326 | - return true; |
|
324 | + dompdf_debug("page-break", "block: break allowed"); |
|
325 | + return true; |
|
327 | 326 | |
328 | 327 | } |
329 | 328 | |
330 | 329 | // Inline frames (2): |
331 | 330 | else if ( in_array($display, Style::$INLINE_TYPES) ) { |
332 | 331 | |
333 | - // Avoid breaks within table-cells |
|
334 | - if ( $this->_in_table ) { |
|
335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
332 | + // Avoid breaks within table-cells |
|
333 | + if ( $this->_in_table ) { |
|
334 | + dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
336 | 335 | return false; |
337 | - } |
|
336 | + } |
|
338 | 337 | |
339 | - // Rule C |
|
340 | - $block_parent = $frame->find_block_parent(); |
|
341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
342 | - dompdf_debug("page-break", "orphans"); |
|
338 | + // Rule C |
|
339 | + $block_parent = $frame->find_block_parent(); |
|
340 | + if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
341 | + dompdf_debug("page-break", "orphans"); |
|
343 | 342 | return false; |
344 | - } |
|
343 | + } |
|
345 | 344 | |
346 | - // FIXME: Checking widows is tricky without having laid out the |
|
347 | - // remaining line boxes. Just ignore it for now... |
|
345 | + // FIXME: Checking widows is tricky without having laid out the |
|
346 | + // remaining line boxes. Just ignore it for now... |
|
348 | 347 | |
349 | - // Rule D |
|
350 | - $p = $block_parent; |
|
351 | - while ($p) { |
|
348 | + // Rule D |
|
349 | + $p = $block_parent; |
|
350 | + while ($p) { |
|
352 | 351 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
353 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
354 | - return false; |
|
352 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
353 | + return false; |
|
355 | 354 | } |
356 | 355 | $p = $p->find_block_parent(); |
357 | - } |
|
356 | + } |
|
358 | 357 | |
359 | - // To prevent cascading page breaks when a top-level element has |
|
360 | - // page-break-inside: avoid, ensure that at least one frame with |
|
361 | - // some content is on the page before splitting. |
|
362 | - $prev = $frame->get_prev_sibling(); |
|
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
358 | + // To prevent cascading page breaks when a top-level element has |
|
359 | + // page-break-inside: avoid, ensure that at least one frame with |
|
360 | + // some content is on the page before splitting. |
|
361 | + $prev = $frame->get_prev_sibling(); |
|
362 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
364 | 363 | $prev = $prev->get_prev_sibling(); |
365 | 364 | |
366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
365 | + if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
367 | 366 | // We are the body's first child |
368 | - dompdf_debug("page-break", "Body's first child."); |
|
367 | + dompdf_debug("page-break", "Body's first child."); |
|
369 | 368 | return false; |
370 | - } |
|
369 | + } |
|
371 | 370 | |
372 | - // Skip breaks on empty text nodes |
|
373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
371 | + // Skip breaks on empty text nodes |
|
372 | + if ( $frame->get_node()->nodeName === "#text" && |
|
374 | 373 | $frame->get_node()->nodeValue == "" ) |
375 | 374 | return false; |
376 | 375 | |
377 | - dompdf_debug("page-break", "inline: break allowed"); |
|
378 | - return true; |
|
376 | + dompdf_debug("page-break", "inline: break allowed"); |
|
377 | + return true; |
|
379 | 378 | |
380 | 379 | // Table-rows |
381 | 380 | } else if ( $display === "table-row" ) { |
382 | 381 | |
383 | - // Simply check if the parent table's page_break_inside property is |
|
384 | - // not 'avoid' |
|
385 | - $p = Table_Frame_Decorator::find_parent_table($frame); |
|
382 | + // Simply check if the parent table's page_break_inside property is |
|
383 | + // not 'avoid' |
|
384 | + $p = Table_Frame_Decorator::find_parent_table($frame); |
|
386 | 385 | |
387 | - while ($p) { |
|
386 | + while ($p) { |
|
388 | 387 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
389 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
390 | - return false; |
|
388 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
389 | + return false; |
|
391 | 390 | } |
392 | 391 | $p = $p->find_block_parent(); |
393 | - } |
|
392 | + } |
|
394 | 393 | |
395 | - // Avoid breaking after the first row of a table |
|
396 | - if ( $p && $p->get_first_child() === $frame) { |
|
397 | - dompdf_debug("page-break", "table: first-row"); |
|
394 | + // Avoid breaking after the first row of a table |
|
395 | + if ( $p && $p->get_first_child() === $frame) { |
|
396 | + dompdf_debug("page-break", "table: first-row"); |
|
398 | 397 | return false; |
399 | - } |
|
398 | + } |
|
400 | 399 | |
401 | - // If this is a nested table, prevent the page from breaking |
|
402 | - if ( $this->_in_table > 1 ) { |
|
400 | + // If this is a nested table, prevent the page from breaking |
|
401 | + if ( $this->_in_table > 1 ) { |
|
403 | 402 | dompdf_debug("page-break", "table: nested table"); |
404 | 403 | return false; |
405 | - } |
|
404 | + } |
|
406 | 405 | |
407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
408 | - return true; |
|
406 | + dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
407 | + return true; |
|
409 | 408 | |
410 | 409 | } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
411 | 410 | |
412 | - // Disallow breaks at row-groups: only split at row boundaries |
|
413 | - return false; |
|
411 | + // Disallow breaks at row-groups: only split at row boundaries |
|
412 | + return false; |
|
414 | 413 | |
415 | 414 | } else { |
416 | 415 | |
417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
418 | - return false; |
|
416 | + dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
417 | + return false; |
|
419 | 418 | } |
420 | 419 | |
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Check if $frame will fit on the page. If the frame does not fit, |
|
425 | - * the frame tree is modified so that a page break occurs in the |
|
426 | - * correct location. |
|
427 | - * |
|
428 | - * @param Frame $frame the frame to check |
|
429 | - * @return Frame the frame following the page break |
|
430 | - */ |
|
431 | - function check_page_break(Frame $frame) { |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Check if $frame will fit on the page. If the frame does not fit, |
|
424 | + * the frame tree is modified so that a page break occurs in the |
|
425 | + * correct location. |
|
426 | + * |
|
427 | + * @param Frame $frame the frame to check |
|
428 | + * @return Frame the frame following the page break |
|
429 | + */ |
|
430 | + function check_page_break(Frame $frame) { |
|
432 | 431 | // Do not split if we have already |
433 | 432 | if ( $this->_page_full ) |
434 | - return false; |
|
433 | + return false; |
|
435 | 434 | |
436 | 435 | // Determine the frame's maximum y value |
437 | 436 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -440,18 +439,18 @@ discard block |
||
440 | 439 | // parents of $frame must fit on the page as well: |
441 | 440 | $p = $frame->get_parent(); |
442 | 441 | while ( $p ) { |
443 | - $style = $p->get_style(); |
|
444 | - $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
445 | - $style->padding_bottom, |
|
446 | - $style->border_bottom_width)); |
|
447 | - $p = $p->get_parent(); |
|
442 | + $style = $p->get_style(); |
|
443 | + $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
444 | + $style->padding_bottom, |
|
445 | + $style->border_bottom_width)); |
|
446 | + $p = $p->get_parent(); |
|
448 | 447 | } |
449 | 448 | |
450 | 449 | |
451 | 450 | // Check if $frame flows off the page |
452 | 451 | if ( $max_y <= $this->_bottom_page_margin ) |
453 | - // no: do nothing |
|
454 | - return false; |
|
452 | + // no: do nothing |
|
453 | + return false; |
|
455 | 454 | |
456 | 455 | dompdf_debug("page-break", "check_page_break"); |
457 | 456 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -466,58 +465,58 @@ discard block |
||
466 | 465 | dompdf_debug("page-break","Starting search"); |
467 | 466 | while ( $iter ) { |
468 | 467 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
469 | - if ( $iter === $this ) { |
|
470 | - dompdf_debug("page-break", "reached root."); |
|
468 | + if ( $iter === $this ) { |
|
469 | + dompdf_debug("page-break", "reached root."); |
|
471 | 470 | // We've reached the root in our search. Just split at $frame. |
472 | 471 | break; |
473 | - } |
|
472 | + } |
|
474 | 473 | |
475 | - if ( $this->_page_break_allowed($iter) ) { |
|
474 | + if ( $this->_page_break_allowed($iter) ) { |
|
476 | 475 | dompdf_debug("page-break","break allowed, splitting."); |
477 | 476 | $iter->split(); |
478 | 477 | $this->_page_full = true; |
479 | 478 | $this->_in_table = $in_table; |
480 | 479 | return true; |
481 | - } |
|
480 | + } |
|
482 | 481 | |
483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
484 | - dompdf_debug("page-break", "following last child."); |
|
482 | + if ( !$flg && $next = $iter->get_last_child() ) { |
|
483 | + dompdf_debug("page-break", "following last child."); |
|
485 | 484 | |
486 | 485 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
487 | - $this->_in_table++; |
|
486 | + $this->_in_table++; |
|
488 | 487 | |
489 | 488 | $iter = $next; |
490 | 489 | continue; |
491 | - } |
|
490 | + } |
|
492 | 491 | |
493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
494 | - dompdf_debug("page-break", "following prev sibling."); |
|
492 | + if ( $next = $iter->get_prev_sibling() ) { |
|
493 | + dompdf_debug("page-break", "following prev sibling."); |
|
495 | 494 | |
496 | 495 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
497 | 496 | !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
498 | - $this->_in_table++; |
|
497 | + $this->_in_table++; |
|
499 | 498 | |
500 | 499 | else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
501 | 500 | in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
502 | - $this->_in_table--; |
|
501 | + $this->_in_table--; |
|
503 | 502 | |
504 | 503 | $iter = $next; |
505 | 504 | $flg = false; |
506 | 505 | continue; |
507 | - } |
|
506 | + } |
|
508 | 507 | |
509 | - if ( $next = $iter->get_parent() ) { |
|
510 | - dompdf_debug("page-break", "following parent."); |
|
508 | + if ( $next = $iter->get_parent() ) { |
|
509 | + dompdf_debug("page-break", "following parent."); |
|
511 | 510 | |
512 | 511 | if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
513 | - $this->_in_table--; |
|
512 | + $this->_in_table--; |
|
514 | 513 | |
515 | 514 | $iter = $next; |
516 | 515 | $flg = true; |
517 | 516 | continue; |
518 | - } |
|
517 | + } |
|
519 | 518 | |
520 | - break; |
|
519 | + break; |
|
521 | 520 | |
522 | 521 | } |
523 | 522 | |
@@ -528,33 +527,33 @@ discard block |
||
528 | 527 | |
529 | 528 | // If we are in a table, backtrack to the nearest top-level table row |
530 | 529 | if ( $this->_in_table ) { |
531 | - $num_tables = $this->_in_table - 1; |
|
530 | + $num_tables = $this->_in_table - 1; |
|
532 | 531 | |
533 | - $iter = $frame; |
|
534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
532 | + $iter = $frame; |
|
533 | + while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
535 | 534 | $iter = $iter->get_parent(); |
536 | 535 | $num_tables--; |
537 | - } |
|
536 | + } |
|
538 | 537 | |
539 | - $iter = $frame; |
|
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
538 | + $iter = $frame; |
|
539 | + while ($iter && $iter->get_style()->display !== "table-row" ) |
|
541 | 540 | $iter = $iter->get_parent(); |
542 | 541 | |
543 | - $iter->split(); |
|
544 | - $this->_page_full = true; |
|
545 | - return true; |
|
542 | + $iter->split(); |
|
543 | + $this->_page_full = true; |
|
544 | + return true; |
|
546 | 545 | } |
547 | 546 | |
548 | 547 | $frame->split(); |
549 | 548 | $this->_page_full = true; |
550 | 549 | return true; |
551 | 550 | |
552 | - } |
|
551 | + } |
|
553 | 552 | |
554 | - //........................................................................ |
|
553 | + //........................................................................ |
|
555 | 554 | |
556 | - function split($frame = null) { |
|
555 | + function split($frame = null) { |
|
557 | 556 | // Do nothing |
558 | - } |
|
557 | + } |
|
559 | 558 | |
560 | 559 | } |
@@ -442,6 +442,9 @@ discard block |
||
442 | 442 | * @param string corner |
443 | 443 | * @param string join |
444 | 444 | * @param array dash |
445 | + * @param double $width |
|
446 | + * @param string $cap |
|
447 | + * @param string $join |
|
445 | 448 | */ |
446 | 449 | protected function _set_line_style($width, $cap, $join, $dash) { |
447 | 450 | |
@@ -795,8 +798,8 @@ discard block |
||
795 | 798 | * @param string $font the font file to use |
796 | 799 | * @param float $size the font size, in points |
797 | 800 | * @param array $color |
798 | - * @param float $adjust word spacing adjustment |
|
799 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
801 | + * @param integer $adjust word spacing adjustment |
|
802 | + * @param integer $angle angle to write the text at, measured CW starting from the x-axis |
|
800 | 803 | */ |
801 | 804 | function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
802 | 805 | $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
@@ -1,46 +1,46 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: pdflib_adapter.cls.php,v $ |
|
6 | - * Created on: 2005-02-28 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @contributor Helmut Tischer <[email protected]> |
|
37 | - * @package dompdf |
|
38 | - * |
|
39 | - * Changes |
|
40 | - * @contributor Helmut Tischer <[email protected]> |
|
41 | - * @version 0.5.1.htischer.20090507 |
|
42 | - * - Clarify temp file name, optional debug output for temp file tracking |
|
43 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: pdflib_adapter.cls.php,v $ |
|
6 | + * Created on: 2005-02-28 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @contributor Helmut Tischer <[email protected]> |
|
37 | + * @package dompdf |
|
38 | + * |
|
39 | + * Changes |
|
40 | + * @contributor Helmut Tischer <[email protected]> |
|
41 | + * @version 0.5.1.htischer.20090507 |
|
42 | + * - Clarify temp file name, optional debug output for temp file tracking |
|
43 | + */ |
|
44 | 44 | |
45 | 45 | /* $Id: pdflib_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
46 | 46 | |
@@ -61,170 +61,170 @@ discard block |
||
61 | 61 | */ |
62 | 62 | class PDFLib_Adapter implements Canvas { |
63 | 63 | |
64 | - /** |
|
65 | - * Dimensions of paper sizes in points |
|
66 | - * |
|
67 | - * @var array; |
|
68 | - */ |
|
69 | - static public $PAPER_SIZES = array(); // Set to |
|
64 | + /** |
|
65 | + * Dimensions of paper sizes in points |
|
66 | + * |
|
67 | + * @var array; |
|
68 | + */ |
|
69 | + static public $PAPER_SIZES = array(); // Set to |
|
70 | 70 | // CPDF_Adapter::$PAPER_SIZES below. |
71 | 71 | |
72 | - /** |
|
73 | - * Fudge factor to adjust reported font heights |
|
74 | - * |
|
75 | - * CPDF reports larger font heights than PDFLib. This factor |
|
76 | - * adjusts the height reported by get_font_height(). |
|
77 | - * |
|
78 | - * @var float |
|
79 | - */ |
|
80 | - const FONT_HEIGHT_SCALE = 1.2; |
|
81 | - |
|
82 | - /** |
|
83 | - * Whether to create PDFs in memory or on disk |
|
84 | - * |
|
85 | - * @var bool |
|
86 | - */ |
|
87 | - static $IN_MEMORY = true; |
|
88 | - |
|
89 | - /** |
|
90 | - * Instance of PDFLib class |
|
91 | - * |
|
92 | - * @var PDFlib |
|
93 | - */ |
|
94 | - private $_pdf; |
|
95 | - |
|
96 | - /** |
|
97 | - * Name of temporary file used for PDFs created on disk |
|
98 | - * |
|
99 | - * @var string |
|
100 | - */ |
|
101 | - private $_file; |
|
102 | - |
|
103 | - /** |
|
104 | - * PDF width, in points |
|
105 | - * |
|
106 | - * @var float |
|
107 | - */ |
|
108 | - private $_width; |
|
109 | - |
|
110 | - /** |
|
111 | - * PDF height, in points |
|
112 | - * |
|
113 | - * @var height |
|
114 | - */ |
|
115 | - private $_height; |
|
116 | - |
|
117 | - /** |
|
118 | - * Last fill colour used |
|
119 | - * |
|
120 | - * @var array |
|
121 | - */ |
|
122 | - private $_last_fill_color; |
|
123 | - |
|
124 | - /** |
|
125 | - * Last stroke colour used |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - private $_last_stroke_color; |
|
130 | - |
|
131 | - /** |
|
132 | - * Cache of image handles |
|
133 | - * |
|
134 | - * @var array |
|
135 | - */ |
|
136 | - private $_imgs; |
|
137 | - |
|
138 | - /** |
|
139 | - * Cache of font handles |
|
140 | - * |
|
141 | - * @var array |
|
142 | - */ |
|
143 | - private $_fonts; |
|
144 | - |
|
145 | - /** |
|
146 | - * List of objects (templates) to add to multiple pages |
|
147 | - * |
|
148 | - * @var array |
|
149 | - */ |
|
150 | - private $_objs; |
|
151 | - |
|
152 | - /** |
|
153 | - * Current page number |
|
154 | - * |
|
155 | - * @var int |
|
156 | - */ |
|
157 | - private $_page_number; |
|
158 | - |
|
159 | - /** |
|
160 | - * Total number of pages |
|
161 | - * |
|
162 | - * @var int |
|
163 | - */ |
|
164 | - private $_page_count; |
|
165 | - |
|
166 | - /** |
|
167 | - * Text to display on every page |
|
168 | - * |
|
169 | - * @var array |
|
170 | - */ |
|
171 | - private $_page_text; |
|
172 | - |
|
173 | - /** |
|
174 | - * Array of pages for accesing after rendering is initially complete |
|
175 | - * |
|
176 | - * @var array |
|
177 | - */ |
|
178 | - private $_pages; |
|
179 | - |
|
180 | - /** |
|
181 | - * Class constructor |
|
182 | - * |
|
183 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
184 | - * an array(xmin,ymin,xmax,ymax) |
|
185 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
186 | - */ |
|
187 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
72 | + /** |
|
73 | + * Fudge factor to adjust reported font heights |
|
74 | + * |
|
75 | + * CPDF reports larger font heights than PDFLib. This factor |
|
76 | + * adjusts the height reported by get_font_height(). |
|
77 | + * |
|
78 | + * @var float |
|
79 | + */ |
|
80 | + const FONT_HEIGHT_SCALE = 1.2; |
|
81 | + |
|
82 | + /** |
|
83 | + * Whether to create PDFs in memory or on disk |
|
84 | + * |
|
85 | + * @var bool |
|
86 | + */ |
|
87 | + static $IN_MEMORY = true; |
|
88 | + |
|
89 | + /** |
|
90 | + * Instance of PDFLib class |
|
91 | + * |
|
92 | + * @var PDFlib |
|
93 | + */ |
|
94 | + private $_pdf; |
|
95 | + |
|
96 | + /** |
|
97 | + * Name of temporary file used for PDFs created on disk |
|
98 | + * |
|
99 | + * @var string |
|
100 | + */ |
|
101 | + private $_file; |
|
102 | + |
|
103 | + /** |
|
104 | + * PDF width, in points |
|
105 | + * |
|
106 | + * @var float |
|
107 | + */ |
|
108 | + private $_width; |
|
109 | + |
|
110 | + /** |
|
111 | + * PDF height, in points |
|
112 | + * |
|
113 | + * @var height |
|
114 | + */ |
|
115 | + private $_height; |
|
116 | + |
|
117 | + /** |
|
118 | + * Last fill colour used |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + private $_last_fill_color; |
|
123 | + |
|
124 | + /** |
|
125 | + * Last stroke colour used |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_last_stroke_color; |
|
130 | + |
|
131 | + /** |
|
132 | + * Cache of image handles |
|
133 | + * |
|
134 | + * @var array |
|
135 | + */ |
|
136 | + private $_imgs; |
|
137 | + |
|
138 | + /** |
|
139 | + * Cache of font handles |
|
140 | + * |
|
141 | + * @var array |
|
142 | + */ |
|
143 | + private $_fonts; |
|
144 | + |
|
145 | + /** |
|
146 | + * List of objects (templates) to add to multiple pages |
|
147 | + * |
|
148 | + * @var array |
|
149 | + */ |
|
150 | + private $_objs; |
|
151 | + |
|
152 | + /** |
|
153 | + * Current page number |
|
154 | + * |
|
155 | + * @var int |
|
156 | + */ |
|
157 | + private $_page_number; |
|
158 | + |
|
159 | + /** |
|
160 | + * Total number of pages |
|
161 | + * |
|
162 | + * @var int |
|
163 | + */ |
|
164 | + private $_page_count; |
|
165 | + |
|
166 | + /** |
|
167 | + * Text to display on every page |
|
168 | + * |
|
169 | + * @var array |
|
170 | + */ |
|
171 | + private $_page_text; |
|
172 | + |
|
173 | + /** |
|
174 | + * Array of pages for accesing after rendering is initially complete |
|
175 | + * |
|
176 | + * @var array |
|
177 | + */ |
|
178 | + private $_pages; |
|
179 | + |
|
180 | + /** |
|
181 | + * Class constructor |
|
182 | + * |
|
183 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
184 | + * an array(xmin,ymin,xmax,ymax) |
|
185 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
186 | + */ |
|
187 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
188 | 188 | if ( is_array($paper) ) |
189 | - $size = $paper; |
|
189 | + $size = $paper; |
|
190 | 190 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | 192 | else |
193 | - $size = self::$PAPER_SIZES["letter"]; |
|
193 | + $size = self::$PAPER_SIZES["letter"]; |
|
194 | 194 | |
195 | 195 | if ( mb_strtolower($orientation) === "landscape" ) { |
196 | - $a = $size[3]; |
|
197 | - $size[3] = $size[2]; |
|
198 | - $size[2] = $a; |
|
196 | + $a = $size[3]; |
|
197 | + $size[3] = $size[2]; |
|
198 | + $size[2] = $a; |
|
199 | 199 | } |
200 | 200 | $this->_width = $size[2] - $size[0]; |
201 | 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 | - $this->_pdf->set_parameter("textformat", "utf8"); |
|
208 | + $this->_pdf->set_parameter("textformat", "utf8"); |
|
209 | 209 | $this->_pdf->set_parameter("fontwarning", "false"); |
210 | 210 | |
211 | 211 | $this->_pdf->set_info("Creator", "DOMPDF Converter"); |
212 | 212 | |
213 | 213 | // Silence pedantic warnings about missing TZ settings |
214 | 214 | if ( function_exists("date_default_timezone_get") ) { |
215 | - $tz = @date_default_timezone_get(); |
|
216 | - date_default_timezone_set("UTC"); |
|
217 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
218 | - date_default_timezone_set($tz); |
|
215 | + $tz = @date_default_timezone_get(); |
|
216 | + date_default_timezone_set("UTC"); |
|
217 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
218 | + date_default_timezone_set($tz); |
|
219 | 219 | } else { |
220 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
220 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | if ( self::$IN_MEMORY ) |
224 | - $this->_pdf->begin_document("",""); |
|
224 | + $this->_pdf->begin_document("",""); |
|
225 | 225 | else { |
226 | - $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
227 | - $this->_pdf->begin_document($this->_file,""); |
|
226 | + $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
227 | + $this->_pdf->begin_document($this->_file,""); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
@@ -239,155 +239,155 @@ discard block |
||
239 | 239 | // Set up font paths |
240 | 240 | $families = Font_Metrics::get_font_families(); |
241 | 241 | foreach ($families as $family => $files) { |
242 | - foreach ($files as $style => $file) { |
|
242 | + foreach ($files as $style => $file) { |
|
243 | 243 | $face = basename($file); |
244 | 244 | |
245 | 245 | // Prefer ttfs to afms |
246 | 246 | if ( file_exists($file.".ttf") ) { |
247 | - $outline = "$file.ttf"; |
|
248 | - $afm = null; |
|
247 | + $outline = "$file.ttf"; |
|
248 | + $afm = null; |
|
249 | 249 | |
250 | 250 | } else if ( file_exists($file .".TTF") ) { |
251 | - $outline = "$file.TTF"; |
|
252 | - $afm = null; |
|
251 | + $outline = "$file.TTF"; |
|
252 | + $afm = null; |
|
253 | 253 | |
254 | 254 | } else if ( file_exists($file . ".pfb") ) { |
255 | - $outline = "$file.pfb"; |
|
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 | 260 | } else if ( file_exists($file . ".PFB") ) { |
261 | - $outline = "$file.PFB"; |
|
262 | - if ( file_exists($file . ".AFM") ) |
|
261 | + $outline = "$file.PFB"; |
|
262 | + if ( file_exists($file . ".AFM") ) |
|
263 | 263 | $afm = "$file.AFM"; |
264 | 264 | } else |
265 | - continue; |
|
265 | + continue; |
|
266 | 266 | |
267 | 267 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
268 | 268 | if ( !is_null($afm) ) |
269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
270 | - } |
|
269 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
270 | + } |
|
271 | + } |
|
271 | 272 | } |
272 | - } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Close the pdf |
|
276 | - */ |
|
277 | - protected function _close() { |
|
274 | + /** |
|
275 | + * Close the pdf |
|
276 | + */ |
|
277 | + protected function _close() { |
|
278 | 278 | $this->_place_objects(); |
279 | 279 | |
280 | 280 | // Close all pages |
281 | 281 | $this->_pdf->suspend_page(""); |
282 | 282 | for ($p = 1; $p <= $this->_page_count; $p++) { |
283 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
284 | - $this->_pdf->end_page_ext(""); |
|
283 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
284 | + $this->_pdf->end_page_ext(""); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | $this->_pdf->end_document(""); |
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Returns the PDFLib instance |
|
293 | - * |
|
294 | - * @return PDFLib |
|
295 | - */ |
|
296 | - function get_pdflib() { return $this->_pdf; } |
|
297 | - |
|
298 | - /** |
|
299 | - * Add meta information to the PDF |
|
300 | - * |
|
301 | - * @param string $label label of the value (Creator, Producter, etc.) |
|
302 | - * @param string $value the text to set |
|
303 | - */ |
|
304 | - function add_info($label, $value) { |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Returns the PDFLib instance |
|
293 | + * |
|
294 | + * @return PDFLib |
|
295 | + */ |
|
296 | + function get_pdflib() { return $this->_pdf; } |
|
297 | + |
|
298 | + /** |
|
299 | + * Add meta information to the PDF |
|
300 | + * |
|
301 | + * @param string $label label of the value (Creator, Producter, etc.) |
|
302 | + * @param string $value the text to set |
|
303 | + */ |
|
304 | + function add_info($label, $value) { |
|
305 | 305 | $this->_pdf->set_info($label, $value); |
306 | - } |
|
306 | + } |
|
307 | 307 | |
308 | - /** |
|
309 | - * Opens a new 'object' (template in PDFLib-speak) |
|
310 | - * |
|
311 | - * While an object is open, all drawing actions are recorded to the |
|
312 | - * object instead of being drawn on the current page. Objects can |
|
313 | - * be added later to a specific page or to several pages. |
|
314 | - * |
|
315 | - * The return value is an integer ID for the new object. |
|
316 | - * |
|
317 | - * @see PDFLib_Adapter::close_object() |
|
318 | - * @see PDFLib_Adapter::add_object() |
|
319 | - * |
|
320 | - * @return int |
|
321 | - */ |
|
322 | - function open_object() { |
|
308 | + /** |
|
309 | + * Opens a new 'object' (template in PDFLib-speak) |
|
310 | + * |
|
311 | + * While an object is open, all drawing actions are recorded to the |
|
312 | + * object instead of being drawn on the current page. Objects can |
|
313 | + * be added later to a specific page or to several pages. |
|
314 | + * |
|
315 | + * The return value is an integer ID for the new object. |
|
316 | + * |
|
317 | + * @see PDFLib_Adapter::close_object() |
|
318 | + * @see PDFLib_Adapter::add_object() |
|
319 | + * |
|
320 | + * @return int |
|
321 | + */ |
|
322 | + function open_object() { |
|
323 | 323 | $this->_pdf->suspend_page(""); |
324 | 324 | $ret = $this->_pdf->begin_template($this->_width, $this->_height); |
325 | 325 | $this->_pdf->save(); |
326 | 326 | $this->_objs[$ret] = array("start_page" => $this->_page_number); |
327 | 327 | return $ret; |
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Reopen an existing object (NOT IMPLEMENTED) |
|
332 | - * |
|
333 | - * PDFLib does not seem to support reopening templates. |
|
334 | - * |
|
335 | - * @param int $object the ID of a previously opened object |
|
336 | - */ |
|
337 | - function reopen_object($object) { |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Reopen an existing object (NOT IMPLEMENTED) |
|
332 | + * |
|
333 | + * PDFLib does not seem to support reopening templates. |
|
334 | + * |
|
335 | + * @param int $object the ID of a previously opened object |
|
336 | + */ |
|
337 | + function reopen_object($object) { |
|
338 | 338 | throw new DOMPDF_Exception("PDFLib does not support reopening objects."); |
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Close the current template |
|
343 | - * |
|
344 | - * @see PDFLib_Adapter::open_object() |
|
345 | - */ |
|
346 | - function close_object() { |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Close the current template |
|
343 | + * |
|
344 | + * @see PDFLib_Adapter::open_object() |
|
345 | + */ |
|
346 | + function close_object() { |
|
347 | 347 | $this->_pdf->restore(); |
348 | 348 | $this->_pdf->end_template(); |
349 | 349 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Adds the specified object to the document |
|
354 | - * |
|
355 | - * $where can be one of: |
|
356 | - * - 'add' add to current page only |
|
357 | - * - 'all' add to every page from the current one onwards |
|
358 | - * - 'odd' add to all odd numbered pages from now on |
|
359 | - * - 'even' add to all even numbered pages from now on |
|
360 | - * - 'next' add the object to the next page only |
|
361 | - * - 'nextodd' add to all odd numbered pages from the next one |
|
362 | - * - 'nexteven' add to all even numbered pages from the next one |
|
363 | - * |
|
364 | - * @param int $object the object handle returned by open_object() |
|
365 | - * @param string $where |
|
366 | - */ |
|
367 | - function add_object($object, $where = 'all') { |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Adds the specified object to the document |
|
354 | + * |
|
355 | + * $where can be one of: |
|
356 | + * - 'add' add to current page only |
|
357 | + * - 'all' add to every page from the current one onwards |
|
358 | + * - 'odd' add to all odd numbered pages from now on |
|
359 | + * - 'even' add to all even numbered pages from now on |
|
360 | + * - 'next' add the object to the next page only |
|
361 | + * - 'nextodd' add to all odd numbered pages from the next one |
|
362 | + * - 'nexteven' add to all even numbered pages from the next one |
|
363 | + * |
|
364 | + * @param int $object the object handle returned by open_object() |
|
365 | + * @param string $where |
|
366 | + */ |
|
367 | + function add_object($object, $where = 'all') { |
|
368 | 368 | |
369 | 369 | if ( mb_strpos($where, "next") !== false ) { |
370 | - $this->_objs[$object]["start_page"]++; |
|
371 | - $where = str_replace("next", "", $where); |
|
372 | - if ( $where == "" ) |
|
370 | + $this->_objs[$object]["start_page"]++; |
|
371 | + $where = str_replace("next", "", $where); |
|
372 | + if ( $where == "" ) |
|
373 | 373 | $where = "add"; |
374 | 374 | } |
375 | 375 | |
376 | 376 | $this->_objs[$object]["where"] = $where; |
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Stops the specified template from appearing in the document. |
|
381 | - * |
|
382 | - * The object will stop being displayed on the page following the |
|
383 | - * current one. |
|
384 | - * |
|
385 | - * @param int $object |
|
386 | - */ |
|
387 | - function stop_object($object) { |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Stops the specified template from appearing in the document. |
|
381 | + * |
|
382 | + * The object will stop being displayed on the page following the |
|
383 | + * current one. |
|
384 | + * |
|
385 | + * @param int $object |
|
386 | + */ |
|
387 | + function stop_object($object) { |
|
388 | 388 | |
389 | 389 | if ( !isset($this->_objs[$object]) ) |
390 | - return; |
|
390 | + return; |
|
391 | 391 | |
392 | 392 | $start = $this->_objs[$object]["start_page"]; |
393 | 393 | $where = $this->_objs[$object]["where"]; |
@@ -397,74 +397,74 @@ discard block |
||
397 | 397 | (($this->_page_number % 2 == 0 && $where === "even") || |
398 | 398 | ($this->_page_number % 2 == 1 && $where === "odd") || |
399 | 399 | ($where === "all")) ) |
400 | - $this->_pdf->fit_image($object,0,0,""); |
|
400 | + $this->_pdf->fit_image($object,0,0,""); |
|
401 | 401 | |
402 | 402 | unset($this->_objs[$object]); |
403 | - } |
|
403 | + } |
|
404 | 404 | |
405 | - /** |
|
406 | - * Add all active objects to the current page |
|
407 | - */ |
|
408 | - protected function _place_objects() { |
|
405 | + /** |
|
406 | + * Add all active objects to the current page |
|
407 | + */ |
|
408 | + protected function _place_objects() { |
|
409 | 409 | |
410 | 410 | foreach ( $this->_objs as $obj => $props ) { |
411 | - $start = $props["start_page"]; |
|
412 | - $where = $props["where"]; |
|
411 | + $start = $props["start_page"]; |
|
412 | + $where = $props["where"]; |
|
413 | 413 | |
414 | - // Place the object on this page if required |
|
415 | - if ( $this->_page_number >= $start && |
|
414 | + // Place the object on this page if required |
|
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 | 418 | ($where === "all")) ) { |
419 | 419 | $this->_pdf->fit_image($obj,0,0,""); |
420 | - } |
|
420 | + } |
|
421 | 421 | } |
422 | 422 | |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | - function get_width() { return $this->_width; } |
|
425 | + function get_width() { return $this->_width; } |
|
426 | 426 | |
427 | - function get_height() { return $this->_height; } |
|
427 | + function get_height() { return $this->_height; } |
|
428 | 428 | |
429 | - function get_page_number() { return $this->_page_number; } |
|
429 | + function get_page_number() { return $this->_page_number; } |
|
430 | 430 | |
431 | - function get_page_count() { return $this->_page_count; } |
|
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 | - /** |
|
439 | - * Sets the line style |
|
440 | - * |
|
441 | - * @param float width |
|
442 | - * @param string corner |
|
443 | - * @param string join |
|
444 | - * @param array dash |
|
445 | - */ |
|
446 | - protected function _set_line_style($width, $cap, $join, $dash) { |
|
438 | + /** |
|
439 | + * Sets the line style |
|
440 | + * |
|
441 | + * @param float width |
|
442 | + * @param string corner |
|
443 | + * @param string join |
|
444 | + * @param array dash |
|
445 | + */ |
|
446 | + protected function _set_line_style($width, $cap, $join, $dash) { |
|
447 | 447 | |
448 | 448 | if ( count($dash) == 1 ) |
449 | - $dash[] = $dash[0]; |
|
449 | + $dash[] = $dash[0]; |
|
450 | 450 | |
451 | 451 | if ( count($dash) > 1 ) |
452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
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 | 456 | switch ( $join ) { |
457 | 457 | case "miter": |
458 | 458 | $this->_pdf->setlinejoin(0); |
459 | - break; |
|
459 | + break; |
|
460 | 460 | |
461 | 461 | case "round": |
462 | 462 | $this->_pdf->setlinejoin(1); |
463 | - break; |
|
463 | + break; |
|
464 | 464 | |
465 | 465 | case "bevel": |
466 | 466 | $this->_pdf->setlinejoin(2); |
467 | - break; |
|
467 | + break; |
|
468 | 468 | |
469 | 469 | default: |
470 | 470 | break; |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | switch ( $cap ) { |
474 | 474 | case "butt": |
475 | 475 | $this->_pdf->setlinecap(0); |
476 | - break; |
|
476 | + break; |
|
477 | 477 | |
478 | 478 | case "round": |
479 | 479 | $this->_pdf->setlinecap(1); |
480 | - break; |
|
480 | + break; |
|
481 | 481 | |
482 | 482 | case "square": |
483 | 483 | $this->_pdf->setlinecap(2); |
484 | - break; |
|
484 | + break; |
|
485 | 485 | |
486 | 486 | default: |
487 | 487 | break; |
@@ -489,69 +489,69 @@ discard block |
||
489 | 489 | |
490 | 490 | $this->_pdf->setlinewidth($width); |
491 | 491 | |
492 | - } |
|
492 | + } |
|
493 | 493 | |
494 | - /** |
|
495 | - * Sets the line color |
|
496 | - * |
|
497 | - * @param array $color array(r,g,b) |
|
498 | - */ |
|
499 | - protected function _set_stroke_color($color) { |
|
494 | + /** |
|
495 | + * Sets the line color |
|
496 | + * |
|
497 | + * @param array $color array(r,g,b) |
|
498 | + */ |
|
499 | + protected function _set_stroke_color($color) { |
|
500 | 500 | if($this->_last_stroke_color == $color) |
501 | - return; |
|
501 | + return; |
|
502 | 502 | |
503 | 503 | $this->_last_stroke_color = $color; |
504 | 504 | |
505 | 505 | list($r,$g,$b) = $color; |
506 | 506 | $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0); |
507 | - } |
|
508 | - |
|
509 | - /** |
|
510 | - * Sets the fill color |
|
511 | - * |
|
512 | - * @param array $color array(r,g,b) |
|
513 | - */ |
|
514 | - protected function _set_fill_color($color) { |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * Sets the fill color |
|
511 | + * |
|
512 | + * @param array $color array(r,g,b) |
|
513 | + */ |
|
514 | + protected function _set_fill_color($color) { |
|
515 | 515 | if($this->_last_fill_color == $color) |
516 | - return; |
|
516 | + return; |
|
517 | 517 | |
518 | 518 | $this->_last_fill_color = $color; |
519 | 519 | |
520 | 520 | list($r,$g,$b) = $color; |
521 | 521 | $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0); |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - /** |
|
525 | - * Loads a specific font and stores the corresponding descriptor. |
|
526 | - * |
|
527 | - * @param string $font |
|
528 | - * @return int the font descriptor for the font |
|
529 | - */ |
|
530 | - protected function _load_font($font, $encoding = null, $options = "") { |
|
524 | + /** |
|
525 | + * Loads a specific font and stores the corresponding descriptor. |
|
526 | + * |
|
527 | + * @param string $font |
|
528 | + * @return int the font descriptor for the font |
|
529 | + */ |
|
530 | + protected function _load_font($font, $encoding = null, $options = "") { |
|
531 | 531 | |
532 | 532 | // Check if the font is a native PDF font |
533 | 533 | // Embed non-native fonts |
534 | 534 | $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique", |
535 | - "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
536 | - "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
537 | - "symbol", "zapfdinbats"); |
|
535 | + "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
536 | + "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
537 | + "symbol", "zapfdinbats"); |
|
538 | 538 | |
539 | 539 | $test = strtolower(basename($font)); |
540 | 540 | if ( in_array($test, $native_fonts) ) { |
541 | - $font = basename($font); |
|
541 | + $font = basename($font); |
|
542 | 542 | |
543 | 543 | } else { |
544 | - // Embed non-native fonts |
|
545 | - $options .= " embedding=true"; |
|
544 | + // Embed non-native fonts |
|
545 | + $options .= " embedding=true"; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | if ( is_null($encoding) ) { |
549 | 549 | |
550 | - // Unicode encoding is only available for the commerical |
|
551 | - // version of PDFlib and not PDFlib-Lite |
|
552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
550 | + // Unicode encoding is only available for the commerical |
|
551 | + // version of PDFlib and not PDFlib-Lite |
|
552 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
553 | 553 | $encoding = "unicode"; |
554 | - else |
|
554 | + else |
|
555 | 555 | $encoding = "auto"; |
556 | 556 | |
557 | 557 | } |
@@ -559,28 +559,28 @@ discard block |
||
559 | 559 | $key = $font .":". $encoding .":". $options; |
560 | 560 | |
561 | 561 | if ( isset($this->_fonts[$key]) ) |
562 | - return $this->_fonts[$key]; |
|
562 | + return $this->_fonts[$key]; |
|
563 | 563 | |
564 | 564 | else { |
565 | 565 | |
566 | - $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
567 | - return $this->_fonts[$key]; |
|
566 | + $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
567 | + return $this->_fonts[$key]; |
|
568 | 568 | |
569 | 569 | } |
570 | 570 | |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | - /** |
|
574 | - * Remaps y coords from 4th to 1st quadrant |
|
575 | - * |
|
576 | - * @param float $y |
|
577 | - * @return float |
|
578 | - */ |
|
579 | - protected function y($y) { return $this->_height - $y; } |
|
573 | + /** |
|
574 | + * Remaps y coords from 4th to 1st quadrant |
|
575 | + * |
|
576 | + * @param float $y |
|
577 | + * @return float |
|
578 | + */ |
|
579 | + protected function y($y) { return $this->_height - $y; } |
|
580 | 580 | |
581 | - //........................................................................ |
|
581 | + //........................................................................ |
|
582 | 582 | |
583 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
583 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
584 | 584 | $this->_set_line_style($width, "butt", "", $style); |
585 | 585 | $this->_set_stroke_color($color); |
586 | 586 | |
@@ -590,11 +590,11 @@ discard block |
||
590 | 590 | $this->_pdf->moveto($x1,$y1); |
591 | 591 | $this->_pdf->lineto($x2, $y2); |
592 | 592 | $this->_pdf->stroke(); |
593 | - } |
|
593 | + } |
|
594 | 594 | |
595 | - //........................................................................ |
|
595 | + //........................................................................ |
|
596 | 596 | |
597 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
597 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
598 | 598 | $this->_set_stroke_color($color); |
599 | 599 | $this->_set_line_style($width, "square", "miter", $style); |
600 | 600 | |
@@ -602,93 +602,93 @@ discard block |
||
602 | 602 | |
603 | 603 | $this->_pdf->rect($x1, $y1, $w, $h); |
604 | 604 | $this->_pdf->stroke(); |
605 | - } |
|
605 | + } |
|
606 | 606 | |
607 | - //........................................................................ |
|
607 | + //........................................................................ |
|
608 | 608 | |
609 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
609 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
610 | 610 | $this->_set_fill_color($color); |
611 | 611 | |
612 | 612 | $y1 = $this->y($y1) - $h; |
613 | 613 | |
614 | 614 | $this->_pdf->rect($x1, $y1, $w, $h); |
615 | 615 | $this->_pdf->fill(); |
616 | - } |
|
616 | + } |
|
617 | 617 | |
618 | - //........................................................................ |
|
618 | + //........................................................................ |
|
619 | 619 | |
620 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
620 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
621 | 621 | |
622 | 622 | $this->_set_fill_color($color); |
623 | 623 | $this->_set_stroke_color($color); |
624 | 624 | |
625 | 625 | if ( !$fill && isset($width) ) |
626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
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 | 630 | $this->_pdf->moveto($x,$y); |
631 | 631 | |
632 | 632 | while (count($points) > 1) { |
633 | - $y = $this->y(array_pop($points)); |
|
634 | - $x = array_pop($points); |
|
635 | - $this->_pdf->lineto($x,$y); |
|
633 | + $y = $this->y(array_pop($points)); |
|
634 | + $x = array_pop($points); |
|
635 | + $this->_pdf->lineto($x,$y); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | if ( $fill ) |
639 | - $this->_pdf->fill(); |
|
639 | + $this->_pdf->fill(); |
|
640 | 640 | else |
641 | - $this->_pdf->closepath_stroke(); |
|
642 | - } |
|
641 | + $this->_pdf->closepath_stroke(); |
|
642 | + } |
|
643 | 643 | |
644 | - //........................................................................ |
|
644 | + //........................................................................ |
|
645 | 645 | |
646 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
646 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
647 | 647 | |
648 | 648 | $this->_set_fill_color($color); |
649 | 649 | $this->_set_stroke_color($color); |
650 | 650 | |
651 | 651 | if ( !$fill && isset($width) ) |
652 | - $this->_set_line_style($width, "round", "round", $style); |
|
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 | 658 | if ( $fill ) |
659 | - $this->_pdf->fill(); |
|
659 | + $this->_pdf->fill(); |
|
660 | 660 | else |
661 | - $this->_pdf->stroke(); |
|
661 | + $this->_pdf->stroke(); |
|
662 | 662 | |
663 | - } |
|
663 | + } |
|
664 | 664 | |
665 | - //........................................................................ |
|
665 | + //........................................................................ |
|
666 | 666 | |
667 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
667 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
668 | 668 | $w = (int)$w; |
669 | 669 | $h = (int)$h; |
670 | 670 | |
671 | 671 | $img_type = strtolower($img_type); |
672 | 672 | |
673 | 673 | if ( $img_type === "jpg" ) |
674 | - $img_type = "jpeg"; |
|
674 | + $img_type = "jpeg"; |
|
675 | 675 | |
676 | 676 | if ( isset($this->_imgs[$img_url]) ) |
677 | - $img = $this->_imgs[$img_url]; |
|
677 | + $img = $this->_imgs[$img_url]; |
|
678 | 678 | |
679 | 679 | else { |
680 | 680 | |
681 | - $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
681 | + $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | $y = $this->y($y) - $h; |
685 | 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); |
@@ -701,72 +701,72 @@ discard block |
||
701 | 701 | |
702 | 702 | $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust"); |
703 | 703 | |
704 | - } |
|
704 | + } |
|
705 | 705 | |
706 | - //........................................................................ |
|
706 | + //........................................................................ |
|
707 | 707 | |
708 | - function javascript($code) { |
|
708 | + function javascript($code) { |
|
709 | 709 | // Not implemented |
710 | - } |
|
710 | + } |
|
711 | 711 | |
712 | - //........................................................................ |
|
712 | + //........................................................................ |
|
713 | 713 | |
714 | - /** |
|
715 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
716 | - * |
|
717 | - * @param string $anchorname The name of the named destination |
|
718 | - */ |
|
719 | - function add_named_dest($anchorname) { |
|
714 | + /** |
|
715 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
716 | + * |
|
717 | + * @param string $anchorname The name of the named destination |
|
718 | + */ |
|
719 | + function add_named_dest($anchorname) { |
|
720 | 720 | $this->_pdf->add_nameddest($anchorname,""); |
721 | - } |
|
721 | + } |
|
722 | 722 | |
723 | - //........................................................................ |
|
723 | + //........................................................................ |
|
724 | 724 | |
725 | - /** |
|
726 | - * Add a link to the pdf |
|
727 | - * |
|
728 | - * @param string $url The url to link to |
|
729 | - * @param float $x The x position of the link |
|
730 | - * @param float $y The y position of the link |
|
731 | - * @param float $width The width of the link |
|
732 | - * @param float $height The height of the link |
|
733 | - */ |
|
734 | - function add_link($url, $x, $y, $width, $height) { |
|
725 | + /** |
|
726 | + * Add a link to the pdf |
|
727 | + * |
|
728 | + * @param string $url The url to link to |
|
729 | + * @param float $x The x position of the link |
|
730 | + * @param float $y The y position of the link |
|
731 | + * @param float $width The width of the link |
|
732 | + * @param float $height The height of the link |
|
733 | + */ |
|
734 | + function add_link($url, $x, $y, $width, $height) { |
|
735 | 735 | |
736 | 736 | $y = $this->y($y) - $height; |
737 | 737 | if ( strpos($url, '#') === 0 ) { |
738 | - // Local link |
|
739 | - $name = substr($url,1); |
|
740 | - if ( $name ) |
|
738 | + // Local link |
|
739 | + $name = substr($url,1); |
|
740 | + if ( $name ) |
|
741 | 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 | - list($proto, $host, $path, $file) = explode_url($url); |
|
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 | - $url = build_url($proto, $host, $path, $file); |
|
749 | - $url = '{' . rawurldecode($url) . '}'; |
|
748 | + $url = build_url($proto, $host, $path, $file); |
|
749 | + $url = '{' . rawurldecode($url) . '}'; |
|
750 | 750 | |
751 | - $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
752 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
751 | + $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
752 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
753 | + } |
|
753 | 754 | } |
754 | - } |
|
755 | 755 | |
756 | - //........................................................................ |
|
756 | + //........................................................................ |
|
757 | 757 | |
758 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
758 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
759 | 759 | $fh = $this->_load_font($font); |
760 | 760 | |
761 | 761 | // Determine the additional width due to extra spacing |
762 | 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 | + } |
|
766 | 766 | |
767 | - //........................................................................ |
|
767 | + //........................................................................ |
|
768 | 768 | |
769 | - function get_font_height($font, $size) { |
|
769 | + function get_font_height($font, $size) { |
|
770 | 770 | |
771 | 771 | $fh = $this->_load_font($font); |
772 | 772 | |
@@ -777,54 +777,54 @@ discard block |
||
777 | 777 | |
778 | 778 | // $desc is usually < 0, |
779 | 779 | return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc); |
780 | - } |
|
781 | - |
|
782 | - //........................................................................ |
|
783 | - |
|
784 | - /** |
|
785 | - * Writes text at the specified x and y coordinates on every page |
|
786 | - * |
|
787 | - * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
788 | - * with their current values. |
|
789 | - * |
|
790 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
791 | - * |
|
792 | - * @param float $x |
|
793 | - * @param float $y |
|
794 | - * @param string $text the text to write |
|
795 | - * @param string $font the font file to use |
|
796 | - * @param float $size the font size, in points |
|
797 | - * @param array $color |
|
798 | - * @param float $adjust word spacing adjustment |
|
799 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
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) { |
|
780 | + } |
|
781 | + |
|
782 | + //........................................................................ |
|
783 | + |
|
784 | + /** |
|
785 | + * Writes text at the specified x and y coordinates on every page |
|
786 | + * |
|
787 | + * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
788 | + * with their current values. |
|
789 | + * |
|
790 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
791 | + * |
|
792 | + * @param float $x |
|
793 | + * @param float $y |
|
794 | + * @param string $text the text to write |
|
795 | + * @param string $font the font file to use |
|
796 | + * @param float $size the font size, in points |
|
797 | + * @param array $color |
|
798 | + * @param float $adjust word spacing adjustment |
|
799 | + * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
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) { |
|
803 | 803 | $_t = "text"; |
804 | 804 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
805 | - } |
|
806 | - |
|
807 | - //........................................................................ |
|
808 | - |
|
809 | - /** |
|
810 | - * Processes a script on every page |
|
811 | - * |
|
812 | - * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
813 | - * |
|
814 | - * This function can be used to add page numbers to all pages |
|
815 | - * after the first one, for example. |
|
816 | - * |
|
817 | - * @param string $code the script code |
|
818 | - * @param string $type the language type for script |
|
819 | - */ |
|
820 | - function page_script($code, $type = "text/php") { |
|
805 | + } |
|
806 | + |
|
807 | + //........................................................................ |
|
808 | + |
|
809 | + /** |
|
810 | + * Processes a script on every page |
|
811 | + * |
|
812 | + * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
813 | + * |
|
814 | + * This function can be used to add page numbers to all pages |
|
815 | + * after the first one, for example. |
|
816 | + * |
|
817 | + * @param string $code the script code |
|
818 | + * @param string $type the language type for script |
|
819 | + */ |
|
820 | + function page_script($code, $type = "text/php") { |
|
821 | 821 | $_t = "script"; |
822 | 822 | $this->_page_text[] = compact("_t", "code", "type"); |
823 | - } |
|
823 | + } |
|
824 | 824 | |
825 | - //........................................................................ |
|
825 | + //........................................................................ |
|
826 | 826 | |
827 | - function new_page() { |
|
827 | + function new_page() { |
|
828 | 828 | |
829 | 829 | // Add objects to the current page |
830 | 830 | $this->_place_objects(); |
@@ -833,69 +833,69 @@ discard block |
||
833 | 833 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
834 | 834 | $this->_page_number = ++$this->_page_count; |
835 | 835 | |
836 | - } |
|
836 | + } |
|
837 | 837 | |
838 | - //........................................................................ |
|
838 | + //........................................................................ |
|
839 | 839 | |
840 | - /** |
|
841 | - * Add text to each page after rendering is complete |
|
842 | - */ |
|
843 | - protected function _add_page_text() { |
|
840 | + /** |
|
841 | + * Add text to each page after rendering is complete |
|
842 | + */ |
|
843 | + protected function _add_page_text() { |
|
844 | 844 | |
845 | 845 | if ( !count($this->_page_text) ) |
846 | - return; |
|
846 | + return; |
|
847 | 847 | |
848 | 848 | $this->_pdf->suspend_page(""); |
849 | 849 | |
850 | 850 | for ($p = 1; $p <= $this->_page_count; $p++) { |
851 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
851 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
852 | 852 | |
853 | - foreach ($this->_page_text as $pt) { |
|
853 | + foreach ($this->_page_text as $pt) { |
|
854 | 854 | extract($pt); |
855 | 855 | |
856 | 856 | switch ($_t) { |
857 | 857 | |
858 | 858 | case "text": |
859 | 859 | $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
860 | - array($p, $this->_page_count), $text); |
|
861 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | - break; |
|
860 | + array($p, $this->_page_count), $text); |
|
861 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | + break; |
|
863 | 863 | |
864 | 864 | case "script": |
865 | 865 | if (!$eval) { |
866 | 866 | $eval = new PHP_Evaluator($this); |
867 | - } |
|
868 | - $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | - break; |
|
867 | + } |
|
868 | + $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | + break; |
|
870 | + } |
|
870 | 871 | } |
871 | - } |
|
872 | 872 | |
873 | - $this->_pdf->suspend_page(""); |
|
873 | + $this->_pdf->suspend_page(""); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - //........................................................................ |
|
879 | + //........................................................................ |
|
880 | 880 | |
881 | - function stream($filename, $options = null) { |
|
881 | + function stream($filename, $options = null) { |
|
882 | 882 | |
883 | 883 | // Add page text |
884 | 884 | $this->_add_page_text(); |
885 | 885 | |
886 | 886 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
887 | - $this->_pdf->set_value("compress", 0); |
|
887 | + $this->_pdf->set_value("compress", 0); |
|
888 | 888 | else |
889 | - $this->_pdf->set_value("compress", 6); |
|
889 | + $this->_pdf->set_value("compress", 6); |
|
890 | 890 | |
891 | 891 | $this->_close(); |
892 | 892 | |
893 | 893 | if ( self::$IN_MEMORY ) { |
894 | - $data = $this->_pdf->get_buffer(); |
|
895 | - $size = strlen($data); |
|
894 | + $data = $this->_pdf->get_buffer(); |
|
895 | + $size = strlen($data); |
|
896 | 896 | |
897 | 897 | } else |
898 | - $size = filesize($this->_file); |
|
898 | + $size = filesize($this->_file); |
|
899 | 899 | |
900 | 900 | |
901 | 901 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -908,63 +908,63 @@ discard block |
||
908 | 908 | //header("Content-length: " . $size); |
909 | 909 | |
910 | 910 | if ( self::$IN_MEMORY ) |
911 | - echo $data; |
|
911 | + echo $data; |
|
912 | 912 | |
913 | 913 | else { |
914 | 914 | |
915 | - // Chunked readfile() |
|
916 | - $chunk = (1 << 21); // 2 MB |
|
917 | - $fh = fopen($this->_file, "rb"); |
|
918 | - if ( !$fh ) |
|
915 | + // Chunked readfile() |
|
916 | + $chunk = (1 << 21); // 2 MB |
|
917 | + $fh = fopen($this->_file, "rb"); |
|
918 | + if ( !$fh ) |
|
919 | 919 | throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
920 | 920 | |
921 | - while ( !feof($fh) ) |
|
921 | + while ( !feof($fh) ) |
|
922 | 922 | echo fread($fh,$chunk); |
923 | - fclose($fh); |
|
923 | + fclose($fh); |
|
924 | 924 | |
925 | - //debugpng |
|
926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | - if (!DEBUGKEEPTEMP) |
|
925 | + //debugpng |
|
926 | + if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | + if (!DEBUGKEEPTEMP) |
|
928 | 928 | |
929 | - unlink($this->_file); |
|
930 | - $this->_file = null; |
|
929 | + unlink($this->_file); |
|
930 | + $this->_file = null; |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | flush(); |
934 | 934 | |
935 | 935 | |
936 | - } |
|
936 | + } |
|
937 | 937 | |
938 | - //........................................................................ |
|
938 | + //........................................................................ |
|
939 | 939 | |
940 | - function output($options = null) { |
|
940 | + function output($options = null) { |
|
941 | 941 | |
942 | 942 | // Add page text |
943 | 943 | $this->_add_page_text(); |
944 | 944 | |
945 | 945 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
946 | - $this->_pdf->set_value("compress", 0); |
|
946 | + $this->_pdf->set_value("compress", 0); |
|
947 | 947 | else |
948 | - $this->_pdf->set_value("compress", 6); |
|
948 | + $this->_pdf->set_value("compress", 6); |
|
949 | 949 | |
950 | 950 | $this->_close(); |
951 | 951 | |
952 | 952 | if ( self::$IN_MEMORY ) |
953 | - $data = $this->_pdf->get_buffer(); |
|
953 | + $data = $this->_pdf->get_buffer(); |
|
954 | 954 | |
955 | 955 | else { |
956 | - $data = file_get_contents($this->_file); |
|
956 | + $data = file_get_contents($this->_file); |
|
957 | 957 | |
958 | - //debugpng |
|
959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | - if (!DEBUGKEEPTEMP) |
|
958 | + //debugpng |
|
959 | + if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | + if (!DEBUGKEEPTEMP) |
|
961 | 961 | |
962 | - unlink($this->_file); |
|
963 | - $this->_file = null; |
|
962 | + unlink($this->_file); |
|
963 | + $this->_file = null; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | return $data; |
967 | - } |
|
967 | + } |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | // Workaround for idiotic limitation on statics... |
@@ -454,37 +454,37 @@ discard block |
||
454 | 454 | $this->_pdf->setdash(0,0); |
455 | 455 | |
456 | 456 | switch ( $join ) { |
457 | - case "miter": |
|
458 | - $this->_pdf->setlinejoin(0); |
|
459 | - break; |
|
457 | + case "miter": |
|
458 | + $this->_pdf->setlinejoin(0); |
|
459 | + break; |
|
460 | 460 | |
461 | - case "round": |
|
462 | - $this->_pdf->setlinejoin(1); |
|
463 | - break; |
|
461 | + case "round": |
|
462 | + $this->_pdf->setlinejoin(1); |
|
463 | + break; |
|
464 | 464 | |
465 | - case "bevel": |
|
466 | - $this->_pdf->setlinejoin(2); |
|
467 | - break; |
|
465 | + case "bevel": |
|
466 | + $this->_pdf->setlinejoin(2); |
|
467 | + break; |
|
468 | 468 | |
469 | - default: |
|
470 | - break; |
|
469 | + default: |
|
470 | + break; |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | switch ( $cap ) { |
474 | - case "butt": |
|
475 | - $this->_pdf->setlinecap(0); |
|
476 | - break; |
|
474 | + case "butt": |
|
475 | + $this->_pdf->setlinecap(0); |
|
476 | + break; |
|
477 | 477 | |
478 | - case "round": |
|
479 | - $this->_pdf->setlinecap(1); |
|
480 | - break; |
|
478 | + case "round": |
|
479 | + $this->_pdf->setlinecap(1); |
|
480 | + break; |
|
481 | 481 | |
482 | - case "square": |
|
483 | - $this->_pdf->setlinecap(2); |
|
484 | - break; |
|
482 | + case "square": |
|
483 | + $this->_pdf->setlinecap(2); |
|
484 | + break; |
|
485 | 485 | |
486 | - default: |
|
487 | - break; |
|
486 | + default: |
|
487 | + break; |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | $this->_pdf->setlinewidth($width); |
@@ -855,18 +855,18 @@ discard block |
||
855 | 855 | |
856 | 856 | switch ($_t) { |
857 | 857 | |
858 | - case "text": |
|
859 | - $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
860 | - array($p, $this->_page_count), $text); |
|
861 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | - break; |
|
863 | - |
|
864 | - case "script": |
|
865 | - if (!$eval) { |
|
866 | - $eval = new PHP_Evaluator($this); |
|
867 | - } |
|
868 | - $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | - break; |
|
858 | + case "text": |
|
859 | + $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
|
860 | + array($p, $this->_page_count), $text); |
|
861 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | + break; |
|
863 | + |
|
864 | + case "script": |
|
865 | + if (!$eval) { |
|
866 | + $eval = new PHP_Evaluator($this); |
|
867 | + } |
|
868 | + $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | + break; |
|
870 | 870 | } |
871 | 871 | } |
872 | 872 |
@@ -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 { |
@@ -185,12 +185,13 @@ discard block |
||
185 | 185 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
186 | 186 | */ |
187 | 187 | function __construct($paper = "letter", $orientation = "portrait") { |
188 | - if ( is_array($paper) ) |
|
189 | - $size = $paper; |
|
190 | - else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
|
191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | - else |
|
193 | - $size = self::$PAPER_SIZES["letter"]; |
|
188 | + if ( is_array($paper) ) { |
|
189 | + $size = $paper; |
|
190 | + } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) { |
|
191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | + } else { |
|
193 | + $size = self::$PAPER_SIZES["letter"]; |
|
194 | + } |
|
194 | 195 | |
195 | 196 | if ( mb_strtolower($orientation) === "landscape" ) { |
196 | 197 | $a = $size[3]; |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | |
203 | 204 | $this->_pdf = new PDFLib(); |
204 | 205 | |
205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
206 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
207 | + $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
208 | + } |
|
207 | 209 | |
208 | 210 | $this->_pdf->set_parameter("textformat", "utf8"); |
209 | 211 | $this->_pdf->set_parameter("fontwarning", "false"); |
@@ -220,9 +222,9 @@ discard block |
||
220 | 222 | $this->_pdf->set_info("Date", date("Y-m-d")); |
221 | 223 | } |
222 | 224 | |
223 | - if ( self::$IN_MEMORY ) |
|
224 | - $this->_pdf->begin_document("",""); |
|
225 | - else { |
|
225 | + if ( self::$IN_MEMORY ) { |
|
226 | + $this->_pdf->begin_document("",""); |
|
227 | + } else { |
|
226 | 228 | $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
227 | 229 | $this->_pdf->begin_document($this->_file,""); |
228 | 230 | } |
@@ -254,19 +256,23 @@ discard block |
||
254 | 256 | } else if ( file_exists($file . ".pfb") ) { |
255 | 257 | $outline = "$file.pfb"; |
256 | 258 | |
257 | - if ( file_exists($file . ".afm") ) |
|
258 | - $afm = "$file.afm"; |
|
259 | + if ( file_exists($file . ".afm") ) { |
|
260 | + $afm = "$file.afm"; |
|
261 | + } |
|
259 | 262 | |
260 | 263 | } else if ( file_exists($file . ".PFB") ) { |
261 | 264 | $outline = "$file.PFB"; |
262 | - if ( file_exists($file . ".AFM") ) |
|
263 | - $afm = "$file.AFM"; |
|
264 | - } else |
|
265 | - continue; |
|
265 | + if ( file_exists($file . ".AFM") ) { |
|
266 | + $afm = "$file.AFM"; |
|
267 | + } |
|
268 | + } else { |
|
269 | + continue; |
|
270 | + } |
|
266 | 271 | |
267 | 272 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
268 | - if ( !is_null($afm) ) |
|
269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
273 | + if ( !is_null($afm) ) { |
|
274 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
275 | + } |
|
270 | 276 | } |
271 | 277 | } |
272 | 278 | } |
@@ -369,8 +375,9 @@ discard block |
||
369 | 375 | if ( mb_strpos($where, "next") !== false ) { |
370 | 376 | $this->_objs[$object]["start_page"]++; |
371 | 377 | $where = str_replace("next", "", $where); |
372 | - if ( $where == "" ) |
|
373 | - $where = "add"; |
|
378 | + if ( $where == "" ) { |
|
379 | + $where = "add"; |
|
380 | + } |
|
374 | 381 | } |
375 | 382 | |
376 | 383 | $this->_objs[$object]["where"] = $where; |
@@ -386,8 +393,9 @@ discard block |
||
386 | 393 | */ |
387 | 394 | function stop_object($object) { |
388 | 395 | |
389 | - if ( !isset($this->_objs[$object]) ) |
|
390 | - return; |
|
396 | + if ( !isset($this->_objs[$object]) ) { |
|
397 | + return; |
|
398 | + } |
|
391 | 399 | |
392 | 400 | $start = $this->_objs[$object]["start_page"]; |
393 | 401 | $where = $this->_objs[$object]["where"]; |
@@ -396,8 +404,9 @@ discard block |
||
396 | 404 | if ( $this->_page_number >= $start && |
397 | 405 | (($this->_page_number % 2 == 0 && $where === "even") || |
398 | 406 | ($this->_page_number % 2 == 1 && $where === "odd") || |
399 | - ($where === "all")) ) |
|
400 | - $this->_pdf->fit_image($object,0,0,""); |
|
407 | + ($where === "all")) ) { |
|
408 | + $this->_pdf->fit_image($object,0,0,""); |
|
409 | + } |
|
401 | 410 | |
402 | 411 | unset($this->_objs[$object]); |
403 | 412 | } |
@@ -445,13 +454,15 @@ discard block |
||
445 | 454 | */ |
446 | 455 | protected function _set_line_style($width, $cap, $join, $dash) { |
447 | 456 | |
448 | - if ( count($dash) == 1 ) |
|
449 | - $dash[] = $dash[0]; |
|
457 | + if ( count($dash) == 1 ) { |
|
458 | + $dash[] = $dash[0]; |
|
459 | + } |
|
450 | 460 | |
451 | - if ( count($dash) > 1 ) |
|
452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
453 | - else |
|
454 | - $this->_pdf->setdash(0,0); |
|
461 | + if ( count($dash) > 1 ) { |
|
462 | + $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
463 | + } else { |
|
464 | + $this->_pdf->setdash(0,0); |
|
465 | + } |
|
455 | 466 | |
456 | 467 | switch ( $join ) { |
457 | 468 | case "miter": |
@@ -497,8 +508,9 @@ discard block |
||
497 | 508 | * @param array $color array(r,g,b) |
498 | 509 | */ |
499 | 510 | protected function _set_stroke_color($color) { |
500 | - if($this->_last_stroke_color == $color) |
|
501 | - return; |
|
511 | + if($this->_last_stroke_color == $color) { |
|
512 | + return; |
|
513 | + } |
|
502 | 514 | |
503 | 515 | $this->_last_stroke_color = $color; |
504 | 516 | |
@@ -512,8 +524,9 @@ discard block |
||
512 | 524 | * @param array $color array(r,g,b) |
513 | 525 | */ |
514 | 526 | protected function _set_fill_color($color) { |
515 | - if($this->_last_fill_color == $color) |
|
516 | - return; |
|
527 | + if($this->_last_fill_color == $color) { |
|
528 | + return; |
|
529 | + } |
|
517 | 530 | |
518 | 531 | $this->_last_fill_color = $color; |
519 | 532 | |
@@ -549,19 +562,19 @@ discard block |
||
549 | 562 | |
550 | 563 | // Unicode encoding is only available for the commerical |
551 | 564 | // version of PDFlib and not PDFlib-Lite |
552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
553 | - $encoding = "unicode"; |
|
554 | - else |
|
555 | - $encoding = "auto"; |
|
565 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) { |
|
566 | + $encoding = "unicode"; |
|
567 | + } else { |
|
568 | + $encoding = "auto"; |
|
569 | + } |
|
556 | 570 | |
557 | 571 | } |
558 | 572 | |
559 | 573 | $key = $font .":". $encoding .":". $options; |
560 | 574 | |
561 | - if ( isset($this->_fonts[$key]) ) |
|
562 | - return $this->_fonts[$key]; |
|
563 | - |
|
564 | - else { |
|
575 | + if ( isset($this->_fonts[$key]) ) { |
|
576 | + return $this->_fonts[$key]; |
|
577 | + } else { |
|
565 | 578 | |
566 | 579 | $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
567 | 580 | return $this->_fonts[$key]; |
@@ -622,8 +635,9 @@ discard block |
||
622 | 635 | $this->_set_fill_color($color); |
623 | 636 | $this->_set_stroke_color($color); |
624 | 637 | |
625 | - if ( !$fill && isset($width) ) |
|
626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
638 | + if ( !$fill && isset($width) ) { |
|
639 | + $this->_set_line_style($width, "square", "miter", $style); |
|
640 | + } |
|
627 | 641 | |
628 | 642 | $y = $this->y(array_pop($points)); |
629 | 643 | $x = array_pop($points); |
@@ -635,10 +649,11 @@ discard block |
||
635 | 649 | $this->_pdf->lineto($x,$y); |
636 | 650 | } |
637 | 651 | |
638 | - if ( $fill ) |
|
639 | - $this->_pdf->fill(); |
|
640 | - else |
|
641 | - $this->_pdf->closepath_stroke(); |
|
652 | + if ( $fill ) { |
|
653 | + $this->_pdf->fill(); |
|
654 | + } else { |
|
655 | + $this->_pdf->closepath_stroke(); |
|
656 | + } |
|
642 | 657 | } |
643 | 658 | |
644 | 659 | //........................................................................ |
@@ -648,17 +663,19 @@ discard block |
||
648 | 663 | $this->_set_fill_color($color); |
649 | 664 | $this->_set_stroke_color($color); |
650 | 665 | |
651 | - if ( !$fill && isset($width) ) |
|
652 | - $this->_set_line_style($width, "round", "round", $style); |
|
666 | + if ( !$fill && isset($width) ) { |
|
667 | + $this->_set_line_style($width, "round", "round", $style); |
|
668 | + } |
|
653 | 669 | |
654 | 670 | $y = $this->y($y); |
655 | 671 | |
656 | 672 | $this->_pdf->circle($x, $y, $r); |
657 | 673 | |
658 | - if ( $fill ) |
|
659 | - $this->_pdf->fill(); |
|
660 | - else |
|
661 | - $this->_pdf->stroke(); |
|
674 | + if ( $fill ) { |
|
675 | + $this->_pdf->fill(); |
|
676 | + } else { |
|
677 | + $this->_pdf->stroke(); |
|
678 | + } |
|
662 | 679 | |
663 | 680 | } |
664 | 681 | |
@@ -670,13 +687,13 @@ discard block |
||
670 | 687 | |
671 | 688 | $img_type = strtolower($img_type); |
672 | 689 | |
673 | - if ( $img_type === "jpg" ) |
|
674 | - $img_type = "jpeg"; |
|
675 | - |
|
676 | - if ( isset($this->_imgs[$img_url]) ) |
|
677 | - $img = $this->_imgs[$img_url]; |
|
690 | + if ( $img_type === "jpg" ) { |
|
691 | + $img_type = "jpeg"; |
|
692 | + } |
|
678 | 693 | |
679 | - else { |
|
694 | + if ( isset($this->_imgs[$img_url]) ) { |
|
695 | + $img = $this->_imgs[$img_url]; |
|
696 | + } else { |
|
680 | 697 | |
681 | 698 | $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
682 | 699 | } |
@@ -737,14 +754,17 @@ discard block |
||
737 | 754 | if ( strpos($url, '#') === 0 ) { |
738 | 755 | // Local link |
739 | 756 | $name = substr($url,1); |
740 | - if ( $name ) |
|
741 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
757 | + if ( $name ) { |
|
758 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
|
759 | + } |
|
742 | 760 | } else { |
743 | 761 | |
744 | 762 | list($proto, $host, $path, $file) = explode_url($url); |
745 | 763 | |
746 | - if ( $proto == "" || $proto === "file://" ) |
|
747 | - return; // Local links are not allowed |
|
764 | + if ( $proto == "" || $proto === "file://" ) { |
|
765 | + return; |
|
766 | + } |
|
767 | + // Local links are not allowed |
|
748 | 768 | $url = build_url($proto, $host, $path, $file); |
749 | 769 | $url = '{' . rawurldecode($url) . '}'; |
750 | 770 | |
@@ -842,8 +862,9 @@ discard block |
||
842 | 862 | */ |
843 | 863 | protected function _add_page_text() { |
844 | 864 | |
845 | - if ( !count($this->_page_text) ) |
|
846 | - return; |
|
865 | + if ( !count($this->_page_text) ) { |
|
866 | + return; |
|
867 | + } |
|
847 | 868 | |
848 | 869 | $this->_pdf->suspend_page(""); |
849 | 870 | |
@@ -883,10 +904,11 @@ discard block |
||
883 | 904 | // Add page text |
884 | 905 | $this->_add_page_text(); |
885 | 906 | |
886 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
887 | - $this->_pdf->set_value("compress", 0); |
|
888 | - else |
|
889 | - $this->_pdf->set_value("compress", 6); |
|
907 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
908 | + $this->_pdf->set_value("compress", 0); |
|
909 | + } else { |
|
910 | + $this->_pdf->set_value("compress", 6); |
|
911 | + } |
|
890 | 912 | |
891 | 913 | $this->_close(); |
892 | 914 | |
@@ -894,8 +916,9 @@ discard block |
||
894 | 916 | $data = $this->_pdf->get_buffer(); |
895 | 917 | $size = strlen($data); |
896 | 918 | |
897 | - } else |
|
898 | - $size = filesize($this->_file); |
|
919 | + } else { |
|
920 | + $size = filesize($this->_file); |
|
921 | + } |
|
899 | 922 | |
900 | 923 | |
901 | 924 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -907,26 +930,30 @@ discard block |
||
907 | 930 | |
908 | 931 | //header("Content-length: " . $size); |
909 | 932 | |
910 | - if ( self::$IN_MEMORY ) |
|
911 | - echo $data; |
|
912 | - |
|
913 | - else { |
|
933 | + if ( self::$IN_MEMORY ) { |
|
934 | + echo $data; |
|
935 | + } else { |
|
914 | 936 | |
915 | 937 | // Chunked readfile() |
916 | 938 | $chunk = (1 << 21); // 2 MB |
917 | 939 | $fh = fopen($this->_file, "rb"); |
918 | - if ( !$fh ) |
|
919 | - throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
940 | + if ( !$fh ) { |
|
941 | + throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
|
942 | + } |
|
920 | 943 | |
921 | - while ( !feof($fh) ) |
|
922 | - echo fread($fh,$chunk); |
|
944 | + while ( !feof($fh) ) { |
|
945 | + echo fread($fh,$chunk); |
|
946 | + } |
|
923 | 947 | fclose($fh); |
924 | 948 | |
925 | 949 | //debugpng |
926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | - if (!DEBUGKEEPTEMP) |
|
928 | - |
|
950 | + if (DEBUGPNG) { |
|
951 | + print '[pdflib stream unlink '.$this->_file.']'; |
|
952 | + } |
|
953 | + if (!DEBUGKEEPTEMP) { |
|
954 | + |
|
929 | 955 | unlink($this->_file); |
956 | + } |
|
930 | 957 | $this->_file = null; |
931 | 958 | } |
932 | 959 | |
@@ -942,24 +969,27 @@ discard block |
||
942 | 969 | // Add page text |
943 | 970 | $this->_add_page_text(); |
944 | 971 | |
945 | - if ( isset($options["compress"]) && $options["compress"] != 1 ) |
|
946 | - $this->_pdf->set_value("compress", 0); |
|
947 | - else |
|
948 | - $this->_pdf->set_value("compress", 6); |
|
972 | + if ( isset($options["compress"]) && $options["compress"] != 1 ) { |
|
973 | + $this->_pdf->set_value("compress", 0); |
|
974 | + } else { |
|
975 | + $this->_pdf->set_value("compress", 6); |
|
976 | + } |
|
949 | 977 | |
950 | 978 | $this->_close(); |
951 | 979 | |
952 | - if ( self::$IN_MEMORY ) |
|
953 | - $data = $this->_pdf->get_buffer(); |
|
954 | - |
|
955 | - else { |
|
980 | + if ( self::$IN_MEMORY ) { |
|
981 | + $data = $this->_pdf->get_buffer(); |
|
982 | + } else { |
|
956 | 983 | $data = file_get_contents($this->_file); |
957 | 984 | |
958 | 985 | //debugpng |
959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | - if (!DEBUGKEEPTEMP) |
|
961 | - |
|
986 | + if (DEBUGPNG) { |
|
987 | + print '[pdflib output unlink '.$this->_file.']'; |
|
988 | + } |
|
989 | + if (!DEBUGKEEPTEMP) { |
|
990 | + |
|
962 | 991 | unlink($this->_file); |
992 | + } |
|
963 | 993 | $this->_file = null; |
964 | 994 | } |
965 | 995 |