@@ -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 */ |
@@ -44,9 +43,9 @@ discard block |
||
44 | 43 | */ |
45 | 44 | class Absolute_Positioner extends Positioner { |
46 | 45 | |
47 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
46 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
48 | 47 | |
49 | - function position() { |
|
48 | + function position() { |
|
50 | 49 | |
51 | 50 | $cb = $this->_frame->get_containing_block(); |
52 | 51 | |
@@ -61,27 +60,27 @@ discard block |
||
61 | 60 | |
62 | 61 | if ( $p ) { |
63 | 62 | |
64 | - // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
63 | + // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
65 | 64 | |
66 | - list($x, $y, $w, $h) = $p->get_padding_box(); |
|
65 | + list($x, $y, $w, $h) = $p->get_padding_box(); |
|
67 | 66 | |
68 | 67 | } else { |
69 | 68 | |
70 | - $x = $cb["x"]; |
|
71 | - $y = $cb["y"]; |
|
69 | + $x = $cb["x"]; |
|
70 | + $y = $cb["y"]; |
|
72 | 71 | |
73 | 72 | } |
74 | 73 | |
75 | 74 | if ( isset($top) ) { |
76 | - $y += $top; |
|
75 | + $y += $top; |
|
77 | 76 | } else if ( isset($bottom) ) { |
78 | - // FIXME: need to know this frame's height before we can do this correctly |
|
77 | + // FIXME: need to know this frame's height before we can do this correctly |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | $x += $left; |
82 | 81 | |
83 | 82 | $this->_frame->set_position($x, $y); |
84 | 83 | |
85 | - } |
|
84 | + } |
|
86 | 85 | |
87 | 86 | } |
88 | 87 | \ No newline at end of file |
@@ -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: inline_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,11 +46,11 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Inline_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - function __construct(Frame $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function reflow() { |
|
53 | + function reflow() { |
|
55 | 54 | $style = $this->_frame->get_style(); |
56 | 55 | $this->_frame->position(); |
57 | 56 | |
@@ -59,23 +58,23 @@ discard block |
||
59 | 58 | |
60 | 59 | // Add our margin, padding & border to the first and last children |
61 | 60 | if ( ($f = $this->_frame->get_first_child()) && $f instanceof Text_Frame_Decorator ) { |
62 | - $f->get_style()->margin_left = $style->margin_left; |
|
63 | - $f->get_style()->padding_left = $style->padding_left; |
|
64 | - $f->get_style()->border_left = $style->border_left; |
|
61 | + $f->get_style()->margin_left = $style->margin_left; |
|
62 | + $f->get_style()->padding_left = $style->padding_left; |
|
63 | + $f->get_style()->border_left = $style->border_left; |
|
65 | 64 | } |
66 | 65 | |
67 | 66 | if ( ($l = $this->_frame->get_last_child()) && $l instanceof Text_Frame_Decorator ) { |
68 | - $f->get_style()->margin_right = $style->margin_right; |
|
69 | - $f->get_style()->padding_right = $style->padding_right; |
|
70 | - $f->get_style()->border_right = $style->border_right; |
|
67 | + $f->get_style()->margin_right = $style->margin_right; |
|
68 | + $f->get_style()->padding_right = $style->padding_right; |
|
69 | + $f->get_style()->border_right = $style->border_right; |
|
71 | 70 | } |
72 | 71 | |
73 | 72 | // Set the containing blocks and reflow each child. The containing |
74 | 73 | // block is not changed by line boxes. |
75 | 74 | foreach ( $this->_frame->get_children() as $child ) { |
76 | 75 | |
77 | - $child->set_containing_block($cb); |
|
78 | - $child->reflow(); |
|
76 | + $child->set_containing_block($cb); |
|
77 | + $child->reflow(); |
|
78 | + } |
|
79 | 79 | } |
80 | - } |
|
81 | 80 | } |
@@ -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: tcpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -57,98 +56,98 @@ discard block |
||
57 | 56 | */ |
58 | 57 | class TCPDF_Adapter implements Canvas { |
59 | 58 | |
60 | - /** |
|
61 | - * Dimensions of paper sizes in points |
|
62 | - * |
|
63 | - * @var array; |
|
64 | - */ |
|
65 | - static public $PAPER_SIZES = array(); // Set to |
|
59 | + /** |
|
60 | + * Dimensions of paper sizes in points |
|
61 | + * |
|
62 | + * @var array; |
|
63 | + */ |
|
64 | + static public $PAPER_SIZES = array(); // Set to |
|
66 | 65 | // CPDF_Adapter::$PAPER_SIZES below. |
67 | 66 | |
68 | 67 | |
69 | - /** |
|
70 | - * Instance of the TCPDF class |
|
71 | - * |
|
72 | - * @var TCPDF |
|
73 | - */ |
|
74 | - private $_pdf; |
|
75 | - |
|
76 | - /** |
|
77 | - * PDF width in points |
|
78 | - * |
|
79 | - * @var float |
|
80 | - */ |
|
81 | - private $_width; |
|
82 | - |
|
83 | - /** |
|
84 | - * PDF height in points |
|
85 | - * |
|
86 | - * @var float |
|
87 | - */ |
|
88 | - private $_height; |
|
89 | - |
|
90 | - /** |
|
91 | - * Last fill colour used |
|
92 | - * |
|
93 | - * @var array |
|
94 | - */ |
|
95 | - private $_last_fill_color; |
|
96 | - |
|
97 | - /** |
|
98 | - * Last stroke colour used |
|
99 | - * |
|
100 | - * @var array |
|
101 | - */ |
|
102 | - private $_last_stroke_color; |
|
103 | - |
|
104 | - /** |
|
105 | - * Last line width used |
|
106 | - * |
|
107 | - * @var float |
|
108 | - */ |
|
109 | - private $_last_line_width; |
|
68 | + /** |
|
69 | + * Instance of the TCPDF class |
|
70 | + * |
|
71 | + * @var TCPDF |
|
72 | + */ |
|
73 | + private $_pdf; |
|
74 | + |
|
75 | + /** |
|
76 | + * PDF width in points |
|
77 | + * |
|
78 | + * @var float |
|
79 | + */ |
|
80 | + private $_width; |
|
81 | + |
|
82 | + /** |
|
83 | + * PDF height in points |
|
84 | + * |
|
85 | + * @var float |
|
86 | + */ |
|
87 | + private $_height; |
|
88 | + |
|
89 | + /** |
|
90 | + * Last fill colour used |
|
91 | + * |
|
92 | + * @var array |
|
93 | + */ |
|
94 | + private $_last_fill_color; |
|
95 | + |
|
96 | + /** |
|
97 | + * Last stroke colour used |
|
98 | + * |
|
99 | + * @var array |
|
100 | + */ |
|
101 | + private $_last_stroke_color; |
|
102 | + |
|
103 | + /** |
|
104 | + * Last line width used |
|
105 | + * |
|
106 | + * @var float |
|
107 | + */ |
|
108 | + private $_last_line_width; |
|
110 | 109 | |
111 | - /** |
|
112 | - * Total number of pages |
|
113 | - * |
|
114 | - * @var int |
|
115 | - */ |
|
116 | - private $_page_count; |
|
117 | - |
|
118 | - /** |
|
119 | - * Text to display on every page |
|
120 | - * |
|
121 | - * @var array |
|
122 | - */ |
|
123 | - private $_page_text; |
|
124 | - |
|
125 | - /** |
|
126 | - * Array of pages for accessing after initial rendering is complete |
|
127 | - * |
|
128 | - * @var array |
|
129 | - */ |
|
130 | - private $_pages; |
|
131 | - |
|
132 | - /** |
|
133 | - * Class constructor |
|
134 | - * |
|
135 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
136 | - * an array(xmin,ymin,xmax,ymax) |
|
137 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
138 | - */ |
|
139 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
110 | + /** |
|
111 | + * Total number of pages |
|
112 | + * |
|
113 | + * @var int |
|
114 | + */ |
|
115 | + private $_page_count; |
|
116 | + |
|
117 | + /** |
|
118 | + * Text to display on every page |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + private $_page_text; |
|
123 | + |
|
124 | + /** |
|
125 | + * Array of pages for accessing after initial rendering is complete |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_pages; |
|
130 | + |
|
131 | + /** |
|
132 | + * Class constructor |
|
133 | + * |
|
134 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
135 | + * an array(xmin,ymin,xmax,ymax) |
|
136 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
137 | + */ |
|
138 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
140 | 139 | |
141 | 140 | if ( is_array($paper) ) |
142 | - $size = $paper; |
|
141 | + $size = $paper; |
|
143 | 142 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
144 | - $size = self::$PAPER_SIZE[$paper]; |
|
143 | + $size = self::$PAPER_SIZE[$paper]; |
|
145 | 144 | else |
146 | - $size = self::$PAPER_SIZE["letter"]; |
|
145 | + $size = self::$PAPER_SIZE["letter"]; |
|
147 | 146 | |
148 | 147 | if ( mb_strtolower($orientation) === "landscape" ) { |
149 | - $a = $size[3]; |
|
150 | - $size[3] = $size[2]; |
|
151 | - $size[2] = $a; |
|
148 | + $a = $size[3]; |
|
149 | + $size[3] = $size[2]; |
|
150 | + $size[2] = $a; |
|
152 | 151 | } |
153 | 152 | |
154 | 153 | $this->_width = $size[2] - $size[0]; |
@@ -163,135 +162,135 @@ discard block |
||
163 | 162 | $this->_page_text = array(); |
164 | 163 | |
165 | 164 | $this->_last_fill_color = |
166 | - $this->_last_stroke_color = |
|
167 | - $this->_last_line_width = null; |
|
165 | + $this->_last_stroke_color = |
|
166 | + $this->_last_line_width = null; |
|
168 | 167 | |
169 | - } |
|
168 | + } |
|
170 | 169 | |
171 | - /** |
|
172 | - * Remaps y coords from 4th to 1st quadrant |
|
173 | - * |
|
174 | - * @param float $y |
|
175 | - * @return float |
|
176 | - */ |
|
177 | - protected function y($y) { return $this->_height - $y; } |
|
178 | - |
|
179 | - /** |
|
180 | - * Sets the stroke colour |
|
181 | - * |
|
182 | - * @param array $color |
|
183 | - */ |
|
184 | - protected function _set_stroke_colour($colour) { |
|
170 | + /** |
|
171 | + * Remaps y coords from 4th to 1st quadrant |
|
172 | + * |
|
173 | + * @param float $y |
|
174 | + * @return float |
|
175 | + */ |
|
176 | + protected function y($y) { return $this->_height - $y; } |
|
177 | + |
|
178 | + /** |
|
179 | + * Sets the stroke colour |
|
180 | + * |
|
181 | + * @param array $color |
|
182 | + */ |
|
183 | + protected function _set_stroke_colour($colour) { |
|
185 | 184 | $colour[0] = round(255 * $colour[0]); |
186 | 185 | $colour[1] = round(255 * $colour[1]); |
187 | 186 | $colour[2] = round(255 * $colour[2]); |
188 | 187 | |
189 | 188 | if ( is_null($this->_last_stroke_color) || $color != $this->_last_stroke_color ) { |
190 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
191 | - $this->_last_stroke_color = $color; |
|
189 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
190 | + $this->_last_stroke_color = $color; |
|
192 | 191 | } |
193 | 192 | |
194 | - } |
|
193 | + } |
|
195 | 194 | |
196 | - /** |
|
197 | - * Sets the fill colour |
|
198 | - * |
|
199 | - * @param array $color |
|
200 | - */ |
|
201 | - protected function _set_fill_colour($colour) { |
|
195 | + /** |
|
196 | + * Sets the fill colour |
|
197 | + * |
|
198 | + * @param array $color |
|
199 | + */ |
|
200 | + protected function _set_fill_colour($colour) { |
|
202 | 201 | $colour[0] = round(255 * $colour[0]); |
203 | 202 | $colour[1] = round(255 * $colour[1]); |
204 | 203 | $colour[2] = round(255 * $colour[2]); |
205 | 204 | |
206 | 205 | if ( is_null($this->_last_fill_color) || $color != $this->_last_fill_color ) { |
207 | - $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
208 | - $this->_last_fill_color = $color; |
|
206 | + $this->_pdf->SetDrawColor($color[0],$color[1],$color[2]); |
|
207 | + $this->_last_fill_color = $color; |
|
209 | 208 | } |
210 | 209 | |
211 | - } |
|
210 | + } |
|
212 | 211 | |
213 | - /** |
|
214 | - * Return the TCPDF instance |
|
215 | - * |
|
216 | - * @return TCPDF |
|
217 | - */ |
|
218 | - function get_tcpdf() { return $this->_pdf; } |
|
212 | + /** |
|
213 | + * Return the TCPDF instance |
|
214 | + * |
|
215 | + * @return TCPDF |
|
216 | + */ |
|
217 | + function get_tcpdf() { return $this->_pdf; } |
|
219 | 218 | |
220 | - /** |
|
221 | - * Returns the current page number |
|
222 | - * |
|
223 | - * @return int |
|
224 | - */ |
|
225 | - function get_page_number() { |
|
219 | + /** |
|
220 | + * Returns the current page number |
|
221 | + * |
|
222 | + * @return int |
|
223 | + */ |
|
224 | + function get_page_number() { |
|
226 | 225 | return $this->_page_number; |
227 | - } |
|
228 | - |
|
229 | - /** |
|
230 | - * Returns the total number of pages |
|
231 | - * |
|
232 | - * @return int |
|
233 | - */ |
|
234 | - function get_page_count() { |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the total number of pages |
|
230 | + * |
|
231 | + * @return int |
|
232 | + */ |
|
233 | + function get_page_count() { |
|
235 | 234 | return $this->_page_count; |
236 | - } |
|
237 | - |
|
238 | - /** |
|
239 | - * Sets the total number of pages |
|
240 | - * |
|
241 | - * @param int $count |
|
242 | - */ |
|
243 | - function set_page_count($count) { |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Sets the total number of pages |
|
239 | + * |
|
240 | + * @param int $count |
|
241 | + */ |
|
242 | + function set_page_count($count) { |
|
244 | 243 | $this->_page_count = (int)$count; |
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Draws a line from x1,y1 to x2,y2 |
|
249 | - * |
|
250 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
251 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
252 | - * $style parameter (aka dash). |
|
253 | - * |
|
254 | - * @param float $x1 |
|
255 | - * @param float $y1 |
|
256 | - * @param float $x2 |
|
257 | - * @param float $y2 |
|
258 | - * @param array $color |
|
259 | - * @param float $width |
|
260 | - * @param array $style |
|
261 | - */ |
|
262 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
244 | + } |
|
245 | + |
|
246 | + /** |
|
247 | + * Draws a line from x1,y1 to x2,y2 |
|
248 | + * |
|
249 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
250 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
251 | + * $style parameter (aka dash). |
|
252 | + * |
|
253 | + * @param float $x1 |
|
254 | + * @param float $y1 |
|
255 | + * @param float $x2 |
|
256 | + * @param float $y2 |
|
257 | + * @param array $color |
|
258 | + * @param float $width |
|
259 | + * @param array $style |
|
260 | + */ |
|
261 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
263 | 262 | |
264 | 263 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
265 | - $this->_pdf->SetLineWidth($width); |
|
266 | - $this->_last_line_width = $width; |
|
264 | + $this->_pdf->SetLineWidth($width); |
|
265 | + $this->_last_line_width = $width; |
|
267 | 266 | } |
268 | 267 | |
269 | 268 | $this->_set_stroke_colour($color); |
270 | 269 | |
271 | 270 | // FIXME: ugh, need to handle different styles here |
272 | 271 | $this->_pdf->line($x1, $y1, $x2, $y2); |
273 | - } |
|
274 | - |
|
275 | - /** |
|
276 | - * Draws a rectangle at x1,y1 with width w and height h |
|
277 | - * |
|
278 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
279 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
280 | - * parameter (aka dash) |
|
281 | - * |
|
282 | - * @param float $x1 |
|
283 | - * @param float $y1 |
|
284 | - * @param float $w |
|
285 | - * @param float $h |
|
286 | - * @param array $color |
|
287 | - * @param float $width |
|
288 | - * @param array $style |
|
289 | - */ |
|
290 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
272 | + } |
|
273 | + |
|
274 | + /** |
|
275 | + * Draws a rectangle at x1,y1 with width w and height h |
|
276 | + * |
|
277 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
278 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
279 | + * parameter (aka dash) |
|
280 | + * |
|
281 | + * @param float $x1 |
|
282 | + * @param float $y1 |
|
283 | + * @param float $w |
|
284 | + * @param float $h |
|
285 | + * @param array $color |
|
286 | + * @param float $width |
|
287 | + * @param array $style |
|
288 | + */ |
|
289 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
291 | 290 | |
292 | 291 | if ( is_null($this->_last_line_width) || $width != $this->_last_line_width ) { |
293 | - $this->_pdf->SetLineWidth($width); |
|
294 | - $this->_last_line_width = $width; |
|
292 | + $this->_pdf->SetLineWidth($width); |
|
293 | + $this->_last_line_width = $width; |
|
295 | 294 | } |
296 | 295 | |
297 | 296 | $this->_set_stroke_colour($color); |
@@ -299,165 +298,165 @@ discard block |
||
299 | 298 | // FIXME: ugh, need to handle styles here |
300 | 299 | $this->_pdf->rect($x1, $y1, $w, $h); |
301 | 300 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
306 | - * |
|
307 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
308 | - * |
|
309 | - * @param float $x1 |
|
310 | - * @param float $y1 |
|
311 | - * @param float $w |
|
312 | - * @param float $h |
|
313 | - * @param array $color |
|
314 | - */ |
|
315 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
305 | + * |
|
306 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
307 | + * |
|
308 | + * @param float $x1 |
|
309 | + * @param float $y1 |
|
310 | + * @param float $w |
|
311 | + * @param float $h |
|
312 | + * @param array $color |
|
313 | + */ |
|
314 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
316 | 315 | |
317 | 316 | $this->_set_fill_colour($color); |
318 | 317 | |
319 | 318 | // FIXME: ugh, need to handle styles here |
320 | 319 | $this->_pdf->rect($x1, $y1, $w, $h, "F"); |
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Draws a polygon |
|
325 | - * |
|
326 | - * The polygon is formed by joining all the points stored in the $points |
|
327 | - * array. $points has the following structure: |
|
328 | - * <code> |
|
329 | - * array(0 => x1, |
|
330 | - * 1 => y1, |
|
331 | - * 2 => x2, |
|
332 | - * 3 => y2, |
|
333 | - * ... |
|
334 | - * ); |
|
335 | - * </code> |
|
336 | - * |
|
337 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
338 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
339 | - * parameter (aka dash) |
|
340 | - * |
|
341 | - * @param array $points |
|
342 | - * @param array $color |
|
343 | - * @param float $width |
|
344 | - * @param array $style |
|
345 | - * @param bool $fill Fills the polygon if true |
|
346 | - */ |
|
347 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Draws a polygon |
|
324 | + * |
|
325 | + * The polygon is formed by joining all the points stored in the $points |
|
326 | + * array. $points has the following structure: |
|
327 | + * <code> |
|
328 | + * array(0 => x1, |
|
329 | + * 1 => y1, |
|
330 | + * 2 => x2, |
|
331 | + * 3 => y2, |
|
332 | + * ... |
|
333 | + * ); |
|
334 | + * </code> |
|
335 | + * |
|
336 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
337 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
338 | + * parameter (aka dash) |
|
339 | + * |
|
340 | + * @param array $points |
|
341 | + * @param array $color |
|
342 | + * @param float $width |
|
343 | + * @param array $style |
|
344 | + * @param bool $fill Fills the polygon if true |
|
345 | + */ |
|
346 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
348 | 347 | // FIXME: FPDF sucks |
349 | - } |
|
350 | - |
|
351 | - /** |
|
352 | - * Draws a circle at $x,$y with radius $r |
|
353 | - * |
|
354 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
355 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
356 | - * parameter (aka dash) |
|
357 | - * |
|
358 | - * @param float $x |
|
359 | - * @param float $y |
|
360 | - * @param float $r |
|
361 | - * @param array $color |
|
362 | - * @param float $width |
|
363 | - * @param array $style |
|
364 | - * @param bool $fill Fills the circle if true |
|
365 | - */ |
|
366 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
367 | - |
|
368 | - /** |
|
369 | - * Add an image to the pdf. |
|
370 | - * |
|
371 | - * The image is placed at the specified x and y coordinates with the |
|
372 | - * given width and height. |
|
373 | - * |
|
374 | - * @param string $img_url the path to the image |
|
375 | - * @param string $img_type the type (e.g. extension) of the image |
|
376 | - * @param float $x x position |
|
377 | - * @param float $y y position |
|
378 | - * @param int $w width (in pixels) |
|
379 | - * @param int $h height (in pixels) |
|
380 | - */ |
|
381 | - function image($img_url, $img_type, $x, $y, $w, $h){} |
|
382 | - |
|
383 | - /** |
|
384 | - * Writes text at the specified x and y coordinates |
|
385 | - * |
|
386 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
387 | - * |
|
388 | - * @param float $x |
|
389 | - * @param float $y |
|
390 | - * @param string $text the text to write |
|
391 | - * @param string $font the font file to use |
|
392 | - * @param float $size the font size, in points |
|
393 | - * @param array $color |
|
394 | - * @param float $adjust word spacing adjustment |
|
395 | - */ |
|
396 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
397 | - |
|
398 | - function javascript($code){} |
|
348 | + } |
|
349 | + |
|
350 | + /** |
|
351 | + * Draws a circle at $x,$y with radius $r |
|
352 | + * |
|
353 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
354 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
355 | + * parameter (aka dash) |
|
356 | + * |
|
357 | + * @param float $x |
|
358 | + * @param float $y |
|
359 | + * @param float $r |
|
360 | + * @param array $color |
|
361 | + * @param float $width |
|
362 | + * @param array $style |
|
363 | + * @param bool $fill Fills the circle if true |
|
364 | + */ |
|
365 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false){} |
|
366 | + |
|
367 | + /** |
|
368 | + * Add an image to the pdf. |
|
369 | + * |
|
370 | + * The image is placed at the specified x and y coordinates with the |
|
371 | + * given width and height. |
|
372 | + * |
|
373 | + * @param string $img_url the path to the image |
|
374 | + * @param string $img_type the type (e.g. extension) of the image |
|
375 | + * @param float $x x position |
|
376 | + * @param float $y y position |
|
377 | + * @param int $w width (in pixels) |
|
378 | + * @param int $h height (in pixels) |
|
379 | + */ |
|
380 | + function image($img_url, $img_type, $x, $y, $w, $h){} |
|
381 | + |
|
382 | + /** |
|
383 | + * Writes text at the specified x and y coordinates |
|
384 | + * |
|
385 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
386 | + * |
|
387 | + * @param float $x |
|
388 | + * @param float $y |
|
389 | + * @param string $text the text to write |
|
390 | + * @param string $font the font file to use |
|
391 | + * @param float $size the font size, in points |
|
392 | + * @param array $color |
|
393 | + * @param float $adjust word spacing adjustment |
|
394 | + */ |
|
395 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0){} |
|
396 | + |
|
397 | + function javascript($code){} |
|
399 | 398 | |
400 | - /** |
|
401 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
402 | - * |
|
403 | - * @param string $anchorname The name of the named destination |
|
404 | - */ |
|
405 | - function add_named_dest($anchorname){} |
|
406 | - |
|
407 | - /** |
|
408 | - * Add a link to the pdf |
|
409 | - * |
|
410 | - * @param string $url The url to link to |
|
411 | - * @param float $x The x position of the link |
|
412 | - * @param float $y The y position of the link |
|
413 | - * @param float $width The width of the link |
|
414 | - * @param float $height The height of the link |
|
415 | - */ |
|
416 | - function add_link($url, $x, $y, $width, $height){} |
|
399 | + /** |
|
400 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
401 | + * |
|
402 | + * @param string $anchorname The name of the named destination |
|
403 | + */ |
|
404 | + function add_named_dest($anchorname){} |
|
405 | + |
|
406 | + /** |
|
407 | + * Add a link to the pdf |
|
408 | + * |
|
409 | + * @param string $url The url to link to |
|
410 | + * @param float $x The x position of the link |
|
411 | + * @param float $y The y position of the link |
|
412 | + * @param float $width The width of the link |
|
413 | + * @param float $height The height of the link |
|
414 | + */ |
|
415 | + function add_link($url, $x, $y, $width, $height){} |
|
417 | 416 | |
418 | - /** |
|
419 | - * Calculates text size, in points |
|
420 | - * |
|
421 | - * @param string $text the text to be sized |
|
422 | - * @param string $font the desired font |
|
423 | - * @param float $size the desired font size |
|
424 | - * @param float $spacing word spacing, if any |
|
425 | - * @return float |
|
426 | - */ |
|
427 | - function get_text_width($text, $font, $size, $spacing = 0){} |
|
428 | - |
|
429 | - /** |
|
430 | - * Calculates font height, in points |
|
431 | - * |
|
432 | - * @param string $font |
|
433 | - * @param float $size |
|
434 | - * @return float |
|
435 | - */ |
|
436 | - function get_font_height($font, $size){} |
|
417 | + /** |
|
418 | + * Calculates text size, in points |
|
419 | + * |
|
420 | + * @param string $text the text to be sized |
|
421 | + * @param string $font the desired font |
|
422 | + * @param float $size the desired font size |
|
423 | + * @param float $spacing word spacing, if any |
|
424 | + * @return float |
|
425 | + */ |
|
426 | + function get_text_width($text, $font, $size, $spacing = 0){} |
|
427 | + |
|
428 | + /** |
|
429 | + * Calculates font height, in points |
|
430 | + * |
|
431 | + * @param string $font |
|
432 | + * @param float $size |
|
433 | + * @return float |
|
434 | + */ |
|
435 | + function get_font_height($font, $size){} |
|
437 | 436 | |
438 | 437 | |
439 | - /** |
|
440 | - * Starts a new page |
|
441 | - * |
|
442 | - * Subsequent drawing operations will appear on the new page. |
|
443 | - */ |
|
444 | - function new_page(){} |
|
445 | - |
|
446 | - /** |
|
447 | - * Streams the PDF directly to the browser |
|
448 | - * |
|
449 | - * @param string $filename the name of the PDF file |
|
450 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
451 | - */ |
|
452 | - function stream($filename, $options = null){} |
|
453 | - |
|
454 | - /** |
|
455 | - * Returns the PDF as a string |
|
456 | - * |
|
457 | - * @param array $options associative array: 'compress' => 1 or 0 |
|
458 | - * @return string |
|
459 | - */ |
|
460 | - function output($options = null){} |
|
438 | + /** |
|
439 | + * Starts a new page |
|
440 | + * |
|
441 | + * Subsequent drawing operations will appear on the new page. |
|
442 | + */ |
|
443 | + function new_page(){} |
|
444 | + |
|
445 | + /** |
|
446 | + * Streams the PDF directly to the browser |
|
447 | + * |
|
448 | + * @param string $filename the name of the PDF file |
|
449 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
450 | + */ |
|
451 | + function stream($filename, $options = null){} |
|
452 | + |
|
453 | + /** |
|
454 | + * Returns the PDF as a string |
|
455 | + * |
|
456 | + * @param array $options associative array: 'compress' => 1 or 0 |
|
457 | + * @return string |
|
458 | + */ |
|
459 | + function output($options = null){} |
|
461 | 460 | |
462 | 461 | } |
463 | 462 |
@@ -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 | } |
@@ -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: text_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,34 +46,34 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Text_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - // protected members |
|
51 | - protected $_text_spacing; |
|
49 | + // protected members |
|
50 | + protected $_text_spacing; |
|
52 | 51 | |
53 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
52 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
54 | 53 | if ( $frame->get_node()->nodeName !== "#text" ) |
55 | - throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
54 | + throw new DOMPDF_Exception("Text_Decorator can only be applied to #text nodes."); |
|
56 | 55 | |
57 | 56 | parent::__construct($frame, $dompdf); |
58 | 57 | $this->_text_spacing = null; |
59 | - } |
|
58 | + } |
|
60 | 59 | |
61 | - //........................................................................ |
|
60 | + //........................................................................ |
|
62 | 61 | |
63 | - function reset() { |
|
62 | + function reset() { |
|
64 | 63 | parent::reset(); |
65 | 64 | $this->_text_spacing = null; |
66 | - } |
|
65 | + } |
|
67 | 66 | |
68 | - //........................................................................ |
|
67 | + //........................................................................ |
|
69 | 68 | |
70 | - // Accessor methods |
|
71 | - function get_text_spacing() { return $this->_text_spacing; } |
|
69 | + // Accessor methods |
|
70 | + function get_text_spacing() { return $this->_text_spacing; } |
|
72 | 71 | |
73 | - function get_text() { |
|
72 | + function get_text() { |
|
74 | 73 | // FIXME: this should be in a child class (and is incorrect) |
75 | 74 | if ( $this->_frame->get_style()->content !== "normal" ) { |
76 | - $this->_frame->get_node()->data = $this->_frame->get_style()->content; |
|
77 | - $this->_frame->get_style()->content = "normal"; |
|
75 | + $this->_frame->get_node()->data = $this->_frame->get_style()->content; |
|
76 | + $this->_frame->get_style()->content = "normal"; |
|
78 | 77 | } |
79 | 78 | |
80 | 79 | // pre_r("---"); |
@@ -86,19 +85,19 @@ discard block |
||
86 | 85 | // pre_r("width: " . Font_Metrics::get_text_width($text, $style->font_family, $style->font_size)); |
87 | 86 | |
88 | 87 | return $this->_frame->get_node()->data; |
89 | - } |
|
88 | + } |
|
90 | 89 | |
91 | - //........................................................................ |
|
90 | + //........................................................................ |
|
92 | 91 | |
93 | - // Vertical margins & padding do not apply to text frames |
|
92 | + // Vertical margins & padding do not apply to text frames |
|
94 | 93 | |
95 | - // http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced: |
|
96 | - // |
|
97 | - // The vertical padding, border and margin of an inline, non-replaced box |
|
98 | - // start at the top and bottom of the content area, not the |
|
99 | - // 'line-height'. But only the 'line-height' is used to calculate the |
|
100 | - // height of the line box. |
|
101 | - function get_margin_height() { |
|
94 | + // http://www.w3.org/TR/CSS21/visudet.html#inline-non-replaced: |
|
95 | + // |
|
96 | + // The vertical padding, border and margin of an inline, non-replaced box |
|
97 | + // start at the top and bottom of the content area, not the |
|
98 | + // 'line-height'. But only the 'line-height' is used to calculate the |
|
99 | + // height of the line box. |
|
100 | + function get_margin_height() { |
|
102 | 101 | // This function is called in add_frame_to_line() and is used to |
103 | 102 | // determine the line height, so we actually want to return the |
104 | 103 | // 'line-height' property, not the actual margin box |
@@ -116,28 +115,28 @@ discard block |
||
116 | 115 | |
117 | 116 | return ($style->line_height / $size) * Font_Metrics::get_font_height($font, $size); |
118 | 117 | |
119 | - } |
|
118 | + } |
|
120 | 119 | |
121 | - function get_padding_box() { |
|
120 | + function get_padding_box() { |
|
122 | 121 | $pb = $this->_frame->get_padding_box(); |
123 | 122 | $pb[3] = $pb["h"] = $this->_frame->get_style()->height; |
124 | 123 | return $pb; |
125 | - } |
|
126 | - //........................................................................ |
|
124 | + } |
|
125 | + //........................................................................ |
|
127 | 126 | |
128 | - // Set method |
|
129 | - function set_text_spacing($spacing) { |
|
127 | + // Set method |
|
128 | + function set_text_spacing($spacing) { |
|
130 | 129 | $this->_text_spacing = $spacing; |
131 | 130 | |
132 | 131 | $style = $this->_frame->get_style(); |
133 | 132 | // Re-adjust our width to account for the change in spacing |
134 | 133 | $style->width = Font_Metrics::get_text_width($this->get_text(), $style->font_family, $style->font_size, $spacing); |
135 | - } |
|
134 | + } |
|
136 | 135 | |
137 | - //........................................................................ |
|
136 | + //........................................................................ |
|
138 | 137 | |
139 | - // Recalculate the text width |
|
140 | - function recalculate_width() { |
|
138 | + // Recalculate the text width |
|
139 | + function recalculate_width() { |
|
141 | 140 | $style = $this->get_style(); |
142 | 141 | $text = $this->get_text(); |
143 | 142 | $size = $style->font_size; |
@@ -145,17 +144,17 @@ discard block |
||
145 | 144 | $word_spacing = $style->length_in_pt($style->word_spacing); |
146 | 145 | |
147 | 146 | $style->width = Font_Metrics::get_text_width($text, $font, $size, $word_spacing); |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - //........................................................................ |
|
149 | + //........................................................................ |
|
151 | 150 | |
152 | - // Text manipulation methods |
|
151 | + // Text manipulation methods |
|
153 | 152 | |
154 | - // split the text in this frame at the offset specified. The remaining |
|
155 | - // text is added a sibling frame following this one and is returned. |
|
156 | - function split_text($offset) { |
|
153 | + // split the text in this frame at the offset specified. The remaining |
|
154 | + // text is added a sibling frame following this one and is returned. |
|
155 | + function split_text($offset) { |
|
157 | 156 | if ( $offset == 0 ) |
158 | - return; |
|
157 | + return; |
|
159 | 158 | |
160 | 159 | $split = $this->_frame->get_node()->splitText($offset); |
161 | 160 | $deco = $this->copy($split); |
@@ -164,20 +163,20 @@ discard block |
||
164 | 163 | $p->insert_child_after($deco, $this, false); |
165 | 164 | |
166 | 165 | if ( $p instanceof Inline_Frame_Decorator ) |
167 | - $p->split($deco); |
|
166 | + $p->split($deco); |
|
168 | 167 | |
169 | - } |
|
168 | + } |
|
170 | 169 | |
171 | - //........................................................................ |
|
170 | + //........................................................................ |
|
172 | 171 | |
173 | - function delete_text($offset, $count) { |
|
172 | + function delete_text($offset, $count) { |
|
174 | 173 | $this->_frame->get_node()->deleteData($offset, $count); |
175 | - } |
|
174 | + } |
|
176 | 175 | |
177 | - //........................................................................ |
|
176 | + //........................................................................ |
|
178 | 177 | |
179 | - function set_text($text) { |
|
178 | + function set_text($text) { |
|
180 | 179 | $this->_frame->get_node()->data = $text; |
181 | - } |
|
180 | + } |
|
182 | 181 | |
183 | 182 | } |
@@ -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: attribute_translator.cls.php 219 2010-03-11 23:18:31Z ryan.masten $ */ |
@@ -47,84 +46,84 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Attribute_Translator { |
49 | 48 | |
50 | - // Munged data originally from |
|
51 | - // http://www.w3.org/TR/REC-html40/index/attributes.html |
|
52 | - // |
|
53 | - // thank you var_export() :D |
|
54 | - static private $__ATTRIBUTE_LOOKUP = |
|
49 | + // Munged data originally from |
|
50 | + // http://www.w3.org/TR/REC-html40/index/attributes.html |
|
51 | + // |
|
52 | + // thank you var_export() :D |
|
53 | + static private $__ATTRIBUTE_LOOKUP = |
|
55 | 54 | array (//'caption' => array ( 'align' => '', ), |
56 | - 'img_inner' => // img tags actually end up wrapping img_inner elements |
|
57 | - array ('align' => array('bottom' => 'vertical-align: baseline;', |
|
58 | - 'middle' => 'vertical-align: middle;', |
|
59 | - 'top' => 'vertical-align: top;', |
|
60 | - 'left' => 'float: left;', |
|
61 | - 'right' => 'float: right;'), |
|
62 | - 'border' => 'border-width: %0.2f px;', |
|
63 | - 'height' => 'height: %s px;', |
|
64 | - 'hspace' => 'padding-left: %1$0.2f px; padding-right: %1$0.2f px;', |
|
65 | - 'vspace' => 'padding-top: %1$0.2f px; padding-bottom: %1$0.2f px;', |
|
66 | - 'width' => 'width: %s px;', |
|
67 | - ), |
|
68 | - 'table' => |
|
69 | - array ("align" => array('left' => 'margin-left: 0; margin-right: auto;', |
|
55 | + 'img_inner' => // img tags actually end up wrapping img_inner elements |
|
56 | + array ('align' => array('bottom' => 'vertical-align: baseline;', |
|
57 | + 'middle' => 'vertical-align: middle;', |
|
58 | + 'top' => 'vertical-align: top;', |
|
59 | + 'left' => 'float: left;', |
|
60 | + 'right' => 'float: right;'), |
|
61 | + 'border' => 'border-width: %0.2f px;', |
|
62 | + 'height' => 'height: %s px;', |
|
63 | + 'hspace' => 'padding-left: %1$0.2f px; padding-right: %1$0.2f px;', |
|
64 | + 'vspace' => 'padding-top: %1$0.2f px; padding-bottom: %1$0.2f px;', |
|
65 | + 'width' => 'width: %s px;', |
|
66 | + ), |
|
67 | + 'table' => |
|
68 | + array ("align" => array('left' => 'margin-left: 0; margin-right: auto;', |
|
70 | 69 | 'center' => 'margin-left: auto; margin-right: auto;', |
71 | 70 | 'right' => 'margin-left: auto; margin-right: 0;' |
72 | 71 | ), |
73 | - 'bgcolor' => 'background-color: %s;', |
|
74 | - 'border' => '!set_table_border', |
|
75 | - 'cellpadding' => '!set_table_cellpadding', |
|
76 | - 'cellspacing' => 'border-spacing: %0.2f; border-collapse: separate;', |
|
77 | - 'frame' => array('void' => 'border-style: none;', |
|
78 | - 'above' => 'border-top-style: solid;', |
|
79 | - 'below' => 'border-bottom-style: solid;', |
|
80 | - 'hsides' => 'border-left-style: solid; border-right-style: solid;', |
|
81 | - 'vsides' => 'border-top-style: solid; border-bottom-style: solid;', |
|
82 | - 'lhs' => 'border-left-style: solid;', |
|
83 | - 'rhs' => 'border-right-style: solid;', |
|
84 | - 'box' => 'border-style: solid;', |
|
85 | - 'border' => 'border-style: solid;'), |
|
86 | - 'rules' => '!set_table_rules', |
|
87 | - 'width' => 'width: %s;', |
|
88 | - ), |
|
89 | - 'hr' => |
|
90 | - array ( |
|
91 | - 'align' => '!set_hr_align', // Need to grab width to set 'left' & 'right' correctly |
|
92 | - 'noshade' => 'border-style: solid;', |
|
93 | - 'size' => 'border-width: %0.2f px;', |
|
94 | - 'width' => 'width: %s;', |
|
95 | - ), |
|
96 | - 'div' => |
|
97 | - array ( |
|
98 | - 'align' => 'text-align: %s;', |
|
99 | - ), |
|
100 | - 'h1' => |
|
101 | - array ( |
|
102 | - 'align' => 'text-align: %s;', |
|
103 | - ), |
|
104 | - 'h2' => |
|
105 | - array ( |
|
106 | - 'align' => 'text-align: %s;', |
|
107 | - ), |
|
108 | - 'h3' => |
|
109 | - array ( |
|
110 | - 'align' => 'text-align: %s;', |
|
111 | - ), |
|
112 | - 'h4' => |
|
113 | - array ( |
|
114 | - 'align' => 'text-align: %s;', |
|
115 | - ), |
|
116 | - 'h5' => |
|
117 | - array ( |
|
118 | - 'align' => 'text-align: %s;', |
|
119 | - ), |
|
120 | - 'h6' => |
|
121 | - array ( |
|
122 | - 'align' => 'text-align: %s;', |
|
123 | - ), |
|
124 | - 'p' => |
|
125 | - array ( |
|
126 | - 'align' => 'text-align: %s;', |
|
127 | - ), |
|
72 | + 'bgcolor' => 'background-color: %s;', |
|
73 | + 'border' => '!set_table_border', |
|
74 | + 'cellpadding' => '!set_table_cellpadding', |
|
75 | + 'cellspacing' => 'border-spacing: %0.2f; border-collapse: separate;', |
|
76 | + 'frame' => array('void' => 'border-style: none;', |
|
77 | + 'above' => 'border-top-style: solid;', |
|
78 | + 'below' => 'border-bottom-style: solid;', |
|
79 | + 'hsides' => 'border-left-style: solid; border-right-style: solid;', |
|
80 | + 'vsides' => 'border-top-style: solid; border-bottom-style: solid;', |
|
81 | + 'lhs' => 'border-left-style: solid;', |
|
82 | + 'rhs' => 'border-right-style: solid;', |
|
83 | + 'box' => 'border-style: solid;', |
|
84 | + 'border' => 'border-style: solid;'), |
|
85 | + 'rules' => '!set_table_rules', |
|
86 | + 'width' => 'width: %s;', |
|
87 | + ), |
|
88 | + 'hr' => |
|
89 | + array ( |
|
90 | + 'align' => '!set_hr_align', // Need to grab width to set 'left' & 'right' correctly |
|
91 | + 'noshade' => 'border-style: solid;', |
|
92 | + 'size' => 'border-width: %0.2f px;', |
|
93 | + 'width' => 'width: %s;', |
|
94 | + ), |
|
95 | + 'div' => |
|
96 | + array ( |
|
97 | + 'align' => 'text-align: %s;', |
|
98 | + ), |
|
99 | + 'h1' => |
|
100 | + array ( |
|
101 | + 'align' => 'text-align: %s;', |
|
102 | + ), |
|
103 | + 'h2' => |
|
104 | + array ( |
|
105 | + 'align' => 'text-align: %s;', |
|
106 | + ), |
|
107 | + 'h3' => |
|
108 | + array ( |
|
109 | + 'align' => 'text-align: %s;', |
|
110 | + ), |
|
111 | + 'h4' => |
|
112 | + array ( |
|
113 | + 'align' => 'text-align: %s;', |
|
114 | + ), |
|
115 | + 'h5' => |
|
116 | + array ( |
|
117 | + 'align' => 'text-align: %s;', |
|
118 | + ), |
|
119 | + 'h6' => |
|
120 | + array ( |
|
121 | + 'align' => 'text-align: %s;', |
|
122 | + ), |
|
123 | + 'p' => |
|
124 | + array ( |
|
125 | + 'align' => 'text-align: %s;', |
|
126 | + ), |
|
128 | 127 | // 'col' => |
129 | 128 | // array ( |
130 | 129 | // 'align' => '', |
@@ -135,219 +134,219 @@ discard block |
||
135 | 134 | // 'align' => '', |
136 | 135 | // 'valign' => '', |
137 | 136 | // ), |
138 | - 'tbody' => |
|
139 | - array ( |
|
140 | - 'align' => '!set_table_row_align', |
|
141 | - 'valign' => '!set_table_row_valign', |
|
142 | - ), |
|
143 | - 'td' => |
|
144 | - array ( |
|
145 | - 'align' => 'text-align: %s;', |
|
146 | - 'bgcolor' => 'background-color: %s;', |
|
147 | - 'height' => 'height: %s;', |
|
148 | - 'nowrap' => 'white-space: nowrap;', |
|
149 | - 'valign' => 'vertical-align: %s;', |
|
150 | - 'width' => 'width: %s;', |
|
151 | - ), |
|
152 | - 'tfoot' => |
|
153 | - array ( |
|
154 | - 'align' => '!set_table_row_align', |
|
155 | - 'valign' => '!set_table_row_valign', |
|
156 | - ), |
|
157 | - 'th' => |
|
158 | - array ( |
|
159 | - 'align' => 'text-align: %s;', |
|
160 | - 'bgcolor' => 'background-color: %s;', |
|
161 | - 'height' => 'height: %s;', |
|
162 | - 'nowrap' => 'white-space: nowrap;', |
|
163 | - 'valign' => 'vertical-align: %s;', |
|
164 | - 'width' => 'width: %s;', |
|
165 | - ), |
|
166 | - 'thead' => |
|
167 | - array ( |
|
168 | - 'align' => '!set_table_row_align', |
|
169 | - 'valign' => '!set_table_row_valign', |
|
170 | - ), |
|
171 | - 'tr' => |
|
172 | - array ( |
|
173 | - 'align' => '!set_table_row_align', |
|
174 | - 'bgcolor' => '!set_table_row_bgcolor', |
|
175 | - 'valign' => '!set_table_row_valign', |
|
176 | - ), |
|
177 | - 'body' => |
|
178 | - array ( |
|
179 | - 'background' => 'background-image: url(%s);', |
|
180 | - 'bgcolor' => 'background-color: %s;', |
|
181 | - 'link' => '!set_body_link', |
|
182 | - 'text' => 'color: %s;', |
|
183 | - ), |
|
184 | - 'br' => |
|
185 | - array ( |
|
186 | - 'clear' => 'clear: %s;', |
|
187 | - ), |
|
188 | - 'basefont' => |
|
189 | - array ( |
|
190 | - 'color' => 'color: %s;', |
|
191 | - 'face' => 'font-family: %s;', |
|
192 | - 'size' => '!set_basefont_size', |
|
193 | - ), |
|
194 | - 'font' => |
|
195 | - array ( |
|
196 | - 'color' => 'color: %s;', |
|
197 | - 'face' => 'font-family: %s;', |
|
198 | - 'size' => '!set_font_size', |
|
199 | - ), |
|
200 | - 'dir' => |
|
201 | - array ( |
|
202 | - 'compact' => 'margin: 0.5em 0;', |
|
203 | - ), |
|
204 | - 'dl' => |
|
205 | - array ( |
|
206 | - 'compact' => 'margin: 0.5em 0;', |
|
207 | - ), |
|
208 | - 'menu' => |
|
209 | - array ( |
|
210 | - 'compact' => 'margin: 0.5em 0;', |
|
211 | - ), |
|
212 | - 'ol' => |
|
213 | - array ( |
|
214 | - 'compact' => 'margin: 0.5em 0;', |
|
215 | - 'start' => 'counter-reset: -dompdf-default-counter %d;', |
|
216 | - 'type' => 'list-style-type: %s;', |
|
217 | - ), |
|
218 | - 'ul' => |
|
219 | - array ( |
|
220 | - 'compact' => 'margin: 0.5em 0;', |
|
221 | - 'type' => 'list-style-type: %s;', |
|
222 | - ), |
|
223 | - 'li' => |
|
224 | - array ( |
|
225 | - 'type' => 'list-style-type: %s;', |
|
226 | - 'value' => 'counter-reset: -dompdf-default-counter %d;', |
|
227 | - ), |
|
228 | - 'pre' => |
|
229 | - array ( |
|
230 | - 'width' => 'width: %s;', |
|
231 | - ), |
|
232 | - ); |
|
137 | + 'tbody' => |
|
138 | + array ( |
|
139 | + 'align' => '!set_table_row_align', |
|
140 | + 'valign' => '!set_table_row_valign', |
|
141 | + ), |
|
142 | + 'td' => |
|
143 | + array ( |
|
144 | + 'align' => 'text-align: %s;', |
|
145 | + 'bgcolor' => 'background-color: %s;', |
|
146 | + 'height' => 'height: %s;', |
|
147 | + 'nowrap' => 'white-space: nowrap;', |
|
148 | + 'valign' => 'vertical-align: %s;', |
|
149 | + 'width' => 'width: %s;', |
|
150 | + ), |
|
151 | + 'tfoot' => |
|
152 | + array ( |
|
153 | + 'align' => '!set_table_row_align', |
|
154 | + 'valign' => '!set_table_row_valign', |
|
155 | + ), |
|
156 | + 'th' => |
|
157 | + array ( |
|
158 | + 'align' => 'text-align: %s;', |
|
159 | + 'bgcolor' => 'background-color: %s;', |
|
160 | + 'height' => 'height: %s;', |
|
161 | + 'nowrap' => 'white-space: nowrap;', |
|
162 | + 'valign' => 'vertical-align: %s;', |
|
163 | + 'width' => 'width: %s;', |
|
164 | + ), |
|
165 | + 'thead' => |
|
166 | + array ( |
|
167 | + 'align' => '!set_table_row_align', |
|
168 | + 'valign' => '!set_table_row_valign', |
|
169 | + ), |
|
170 | + 'tr' => |
|
171 | + array ( |
|
172 | + 'align' => '!set_table_row_align', |
|
173 | + 'bgcolor' => '!set_table_row_bgcolor', |
|
174 | + 'valign' => '!set_table_row_valign', |
|
175 | + ), |
|
176 | + 'body' => |
|
177 | + array ( |
|
178 | + 'background' => 'background-image: url(%s);', |
|
179 | + 'bgcolor' => 'background-color: %s;', |
|
180 | + 'link' => '!set_body_link', |
|
181 | + 'text' => 'color: %s;', |
|
182 | + ), |
|
183 | + 'br' => |
|
184 | + array ( |
|
185 | + 'clear' => 'clear: %s;', |
|
186 | + ), |
|
187 | + 'basefont' => |
|
188 | + array ( |
|
189 | + 'color' => 'color: %s;', |
|
190 | + 'face' => 'font-family: %s;', |
|
191 | + 'size' => '!set_basefont_size', |
|
192 | + ), |
|
193 | + 'font' => |
|
194 | + array ( |
|
195 | + 'color' => 'color: %s;', |
|
196 | + 'face' => 'font-family: %s;', |
|
197 | + 'size' => '!set_font_size', |
|
198 | + ), |
|
199 | + 'dir' => |
|
200 | + array ( |
|
201 | + 'compact' => 'margin: 0.5em 0;', |
|
202 | + ), |
|
203 | + 'dl' => |
|
204 | + array ( |
|
205 | + 'compact' => 'margin: 0.5em 0;', |
|
206 | + ), |
|
207 | + 'menu' => |
|
208 | + array ( |
|
209 | + 'compact' => 'margin: 0.5em 0;', |
|
210 | + ), |
|
211 | + 'ol' => |
|
212 | + array ( |
|
213 | + 'compact' => 'margin: 0.5em 0;', |
|
214 | + 'start' => 'counter-reset: -dompdf-default-counter %d;', |
|
215 | + 'type' => 'list-style-type: %s;', |
|
216 | + ), |
|
217 | + 'ul' => |
|
218 | + array ( |
|
219 | + 'compact' => 'margin: 0.5em 0;', |
|
220 | + 'type' => 'list-style-type: %s;', |
|
221 | + ), |
|
222 | + 'li' => |
|
223 | + array ( |
|
224 | + 'type' => 'list-style-type: %s;', |
|
225 | + 'value' => 'counter-reset: -dompdf-default-counter %d;', |
|
226 | + ), |
|
227 | + 'pre' => |
|
228 | + array ( |
|
229 | + 'width' => 'width: %s;', |
|
230 | + ), |
|
231 | + ); |
|
233 | 232 | |
234 | 233 | |
235 | - static protected $_last_basefont_size = 3; |
|
236 | - static protected $_font_size_lookup = array(1=>"xx-small", |
|
237 | - 2=>"x-small", |
|
238 | - 3=>"medium", |
|
239 | - 4=>"large", |
|
240 | - 5=>"x-large", |
|
241 | - 6=>"xx-large", |
|
242 | - 7=>"300%"); |
|
234 | + static protected $_last_basefont_size = 3; |
|
235 | + static protected $_font_size_lookup = array(1=>"xx-small", |
|
236 | + 2=>"x-small", |
|
237 | + 3=>"medium", |
|
238 | + 4=>"large", |
|
239 | + 5=>"x-large", |
|
240 | + 6=>"xx-large", |
|
241 | + 7=>"300%"); |
|
243 | 242 | |
244 | 243 | |
245 | - static function translate_attributes($frame) { |
|
244 | + static function translate_attributes($frame) { |
|
246 | 245 | $node = $frame->get_node(); |
247 | 246 | $tag = $node->tagName; |
248 | 247 | |
249 | 248 | if ( !isset(self::$__ATTRIBUTE_LOOKUP[$tag]) ) |
250 | - return; |
|
249 | + return; |
|
251 | 250 | |
252 | 251 | $valid_attrs = self::$__ATTRIBUTE_LOOKUP[$tag]; |
253 | 252 | $attrs = $node->attributes; |
254 | 253 | $style = rtrim($node->getAttribute("style"), "; "); |
255 | 254 | if ( $style != "" ) |
256 | - $style .= ";"; |
|
255 | + $style .= ";"; |
|
257 | 256 | |
258 | 257 | foreach ($attrs as $attr => $attr_node ) { |
259 | - if ( !isset($valid_attrs[$attr]) ) |
|
258 | + if ( !isset($valid_attrs[$attr]) ) |
|
260 | 259 | continue; |
261 | 260 | |
262 | - $value = $attr_node->value; |
|
261 | + $value = $attr_node->value; |
|
263 | 262 | |
264 | - $target = $valid_attrs[$attr]; |
|
263 | + $target = $valid_attrs[$attr]; |
|
265 | 264 | |
266 | - // Look up $value in $target, if $target is an array: |
|
267 | - if ( is_array($target) ) { |
|
265 | + // Look up $value in $target, if $target is an array: |
|
266 | + if ( is_array($target) ) { |
|
268 | 267 | |
269 | 268 | if ( isset($target[$value]) ) |
270 | - $style .= " " . self::_resolve_target($node, $target[$value], $value); |
|
269 | + $style .= " " . self::_resolve_target($node, $target[$value], $value); |
|
271 | 270 | |
272 | - } else { |
|
271 | + } else { |
|
273 | 272 | // otherwise use target directly |
274 | 273 | $style .= " " . self::_resolve_target($node, $target, $value); |
275 | - } |
|
274 | + } |
|
276 | 275 | } |
277 | 276 | if ( !is_null($style) ) { |
278 | - $style = ltrim($style); |
|
279 | - $node->setAttribute("style", $style); |
|
277 | + $style = ltrim($style); |
|
278 | + $node->setAttribute("style", $style); |
|
280 | 279 | } |
281 | 280 | |
282 | - } |
|
281 | + } |
|
283 | 282 | |
284 | - static protected function _resolve_target($node, $target, $value) { |
|
283 | + static protected function _resolve_target($node, $target, $value) { |
|
285 | 284 | if ( $target[0] === "!" ) { |
286 | - // Function call |
|
287 | - $func = "_" . mb_substr($target, 1); |
|
288 | - return self::$func($node, $value); |
|
285 | + // Function call |
|
286 | + $func = "_" . mb_substr($target, 1); |
|
287 | + return self::$func($node, $value); |
|
289 | 288 | } |
290 | 289 | |
291 | 290 | return $value ? sprintf($target, $value) : ""; |
292 | - } |
|
291 | + } |
|
293 | 292 | |
294 | - //..................................................................... |
|
293 | + //..................................................................... |
|
295 | 294 | |
296 | - static protected function _set_table_cellpadding($node, $value) { |
|
295 | + static protected function _set_table_cellpadding($node, $value) { |
|
297 | 296 | |
298 | 297 | $td_list = $node->getElementsByTagName("td"); |
299 | 298 | foreach ($td_list as $td) { |
300 | - $style = rtrim($td->getAttribute("style"), ";"); |
|
301 | - $style .= "; padding: $value" . "px;"; |
|
302 | - $style = ltrim($style, ";"); |
|
303 | - $td->setAttribute("style", $style); |
|
299 | + $style = rtrim($td->getAttribute("style"), ";"); |
|
300 | + $style .= "; padding: $value" . "px;"; |
|
301 | + $style = ltrim($style, ";"); |
|
302 | + $td->setAttribute("style", $style); |
|
304 | 303 | } |
305 | 304 | return null; |
306 | - } |
|
305 | + } |
|
307 | 306 | |
308 | - static protected function _set_table_border($node, $value) { |
|
307 | + static protected function _set_table_border($node, $value) { |
|
309 | 308 | $td_list = $node->getElementsByTagName("td"); |
310 | 309 | foreach ($td_list as $td) { |
311 | - $style = $td->getAttribute("style"); |
|
312 | - if ( strpos($style, "border") !== false ) |
|
310 | + $style = $td->getAttribute("style"); |
|
311 | + if ( strpos($style, "border") !== false ) |
|
313 | 312 | continue; |
314 | - $style = rtrim($style, ";"); |
|
315 | - $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
316 | - $style = ltrim($style, ";"); |
|
317 | - $td->setAttribute("style", $style); |
|
313 | + $style = rtrim($style, ";"); |
|
314 | + $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
315 | + $style = ltrim($style, ";"); |
|
316 | + $td->setAttribute("style", $style); |
|
318 | 317 | } |
319 | 318 | $th_list = $node->getElementsByTagName("th"); |
320 | 319 | foreach ($th_list as $th) { |
321 | - $style = $th->getAttribute("style"); |
|
322 | - if ( strpos($style, "border") !== false ) |
|
320 | + $style = $th->getAttribute("style"); |
|
321 | + if ( strpos($style, "border") !== false ) |
|
323 | 322 | continue; |
324 | - $style = rtrim($style, ";"); |
|
325 | - $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
326 | - $style = ltrim($style, ";"); |
|
327 | - $th->setAttribute("style", $style); |
|
323 | + $style = rtrim($style, ";"); |
|
324 | + $style .= "; border-width: $value" . "px; border-style: ridge;"; |
|
325 | + $style = ltrim($style, ";"); |
|
326 | + $th->setAttribute("style", $style); |
|
328 | 327 | } |
329 | 328 | |
330 | 329 | return null; |
331 | - } |
|
330 | + } |
|
332 | 331 | |
333 | - static protected function _set_table_cellspacing($node, $value) { |
|
332 | + static protected function _set_table_cellspacing($node, $value) { |
|
334 | 333 | $style = rtrim($td->getAttribute($style), ";"); |
335 | 334 | |
336 | 335 | if ( $value == 0 ) |
337 | - $style .= "; border-collapse: collapse;"; |
|
336 | + $style .= "; border-collapse: collapse;"; |
|
338 | 337 | |
339 | 338 | else |
340 | - $style = "; border-collapse: separate;"; |
|
339 | + $style = "; border-collapse: separate;"; |
|
341 | 340 | |
342 | 341 | return ltrim($style, ";"); |
343 | - } |
|
342 | + } |
|
344 | 343 | |
345 | - static protected function _set_table_rules($node, $value) { |
|
344 | + static protected function _set_table_rules($node, $value) { |
|
346 | 345 | $new_style = "; border-collapse: collapse;"; |
347 | 346 | switch ($value) { |
348 | 347 | case "none": |
349 | 348 | $new_style .= "border-style: none;"; |
350 | - break; |
|
349 | + break; |
|
351 | 350 | |
352 | 351 | case "groups": |
353 | 352 | // FIXME: unsupported |
@@ -355,15 +354,15 @@ discard block |
||
355 | 354 | |
356 | 355 | case "rows": |
357 | 356 | $new_style .= "border-style: solid none solid none; border-width: 1px; "; |
358 | - break; |
|
357 | + break; |
|
359 | 358 | |
360 | 359 | case "cols": |
361 | 360 | $new_style .= "border-style: none solid none solid; border-width: 1px; "; |
362 | - break; |
|
361 | + break; |
|
363 | 362 | |
364 | 363 | case "all": |
365 | 364 | $new_style .= "border-style: solid; border-width: 1px; "; |
366 | - break; |
|
365 | + break; |
|
367 | 366 | |
368 | 367 | default: |
369 | 368 | // Invalid value |
@@ -373,118 +372,118 @@ discard block |
||
373 | 372 | $td_list = $node->getElementsByTagName("td"); |
374 | 373 | |
375 | 374 | foreach ($td_list as $td) { |
376 | - $style = $td->getAttribute("style"); |
|
377 | - $style .= $new_style; |
|
378 | - $td->setAttribute("style", $style); |
|
375 | + $style = $td->getAttribute("style"); |
|
376 | + $style .= $new_style; |
|
377 | + $td->setAttribute("style", $style); |
|
379 | 378 | } |
380 | 379 | return null; |
381 | - } |
|
380 | + } |
|
382 | 381 | |
383 | - static protected function _set_hr_align($node, $value) { |
|
382 | + static protected function _set_hr_align($node, $value) { |
|
384 | 383 | |
385 | 384 | $style = rtrim($node->getAttribute("style"),";"); |
386 | 385 | $width = $node->getAttribute("width"); |
387 | 386 | if ( $width == "" ) |
388 | - $width = "100%"; |
|
387 | + $width = "100%"; |
|
389 | 388 | |
390 | 389 | $remainder = 100 - (double)rtrim($width, "% "); |
391 | 390 | |
392 | 391 | switch ($value) { |
393 | 392 | case "left": |
394 | 393 | $style .= "; margin-right: $remainder %;"; |
395 | - break; |
|
394 | + break; |
|
396 | 395 | |
397 | 396 | case "right": |
398 | 397 | $style .= "; margin-left: $remainder %;"; |
399 | - break; |
|
398 | + break; |
|
400 | 399 | |
401 | 400 | case "center": |
402 | 401 | $style .= "; margin-left: auto; margin-right: auto;"; |
403 | - break; |
|
402 | + break; |
|
404 | 403 | |
405 | 404 | default: |
406 | 405 | return null; |
407 | 406 | } |
408 | 407 | return ltrim($style, "; "); |
409 | 408 | |
410 | - } |
|
409 | + } |
|
411 | 410 | |
412 | - static protected function _set_table_row_align($node, $value) { |
|
411 | + static protected function _set_table_row_align($node, $value) { |
|
413 | 412 | |
414 | 413 | $td_list = $node->getElementsByTagName("td"); |
415 | 414 | |
416 | 415 | foreach ($td_list as $td) { |
417 | - $style = rtrim($td->getAttribute("style"), ";"); |
|
418 | - $style .= "; text-align: $value;"; |
|
419 | - $style = ltrim($style, "; "); |
|
420 | - $td->setAttribute("style", $style); |
|
416 | + $style = rtrim($td->getAttribute("style"), ";"); |
|
417 | + $style .= "; text-align: $value;"; |
|
418 | + $style = ltrim($style, "; "); |
|
419 | + $td->setAttribute("style", $style); |
|
421 | 420 | } |
422 | 421 | |
423 | 422 | return null; |
424 | - } |
|
423 | + } |
|
425 | 424 | |
426 | - static protected function _set_table_row_valign($node, $value) { |
|
425 | + static protected function _set_table_row_valign($node, $value) { |
|
427 | 426 | |
428 | 427 | $td_list = $node->getElementsByTagName("td"); |
429 | 428 | |
430 | 429 | foreach ($td_list as $td) { |
431 | - $style = rtrim($td->getAttribute("style"), ";"); |
|
432 | - $style .= "; vertical-align: $value;"; |
|
433 | - $style = ltrim($style, "; "); |
|
434 | - $td->setAttribute("style", $style); |
|
430 | + $style = rtrim($td->getAttribute("style"), ";"); |
|
431 | + $style .= "; vertical-align: $value;"; |
|
432 | + $style = ltrim($style, "; "); |
|
433 | + $td->setAttribute("style", $style); |
|
435 | 434 | } |
436 | 435 | |
437 | 436 | return null; |
438 | - } |
|
437 | + } |
|
439 | 438 | |
440 | - static protected function _set_table_row_bgcolor($node, $value) { |
|
439 | + static protected function _set_table_row_bgcolor($node, $value) { |
|
441 | 440 | |
442 | 441 | $td_list = $node->getElementsByTagName("td"); |
443 | 442 | |
444 | 443 | foreach ($td_list as $td) { |
445 | - $style = rtrim($td->getAttribute("style"), ";"); |
|
446 | - $style .= "; background-color: $value;"; |
|
447 | - $style = ltrim($style, "; "); |
|
448 | - $td->setAttribute("style", $style); |
|
444 | + $style = rtrim($td->getAttribute("style"), ";"); |
|
445 | + $style .= "; background-color: $value;"; |
|
446 | + $style = ltrim($style, "; "); |
|
447 | + $td->setAttribute("style", $style); |
|
449 | 448 | } |
450 | 449 | |
451 | 450 | return null; |
452 | - } |
|
451 | + } |
|
453 | 452 | |
454 | - static protected function _set_body_link($node, $value) { |
|
453 | + static protected function _set_body_link($node, $value) { |
|
455 | 454 | |
456 | 455 | $a_list = $node->getElementsByTagName("a"); |
457 | 456 | |
458 | 457 | foreach ($a_list as $a) { |
459 | - $style = rtrim($a->getAttribute("style"), ";"); |
|
460 | - $style .= "; color: $value;"; |
|
461 | - $style = ltrim($style, "; "); |
|
462 | - $a->setAttribute("style", $style); |
|
458 | + $style = rtrim($a->getAttribute("style"), ";"); |
|
459 | + $style .= "; color: $value;"; |
|
460 | + $style = ltrim($style, "; "); |
|
461 | + $a->setAttribute("style", $style); |
|
463 | 462 | } |
464 | 463 | |
465 | 464 | return null; |
466 | - } |
|
465 | + } |
|
467 | 466 | |
468 | - static protected function _set_basefont_size($node, $value) { |
|
467 | + static protected function _set_basefont_size($node, $value) { |
|
469 | 468 | // FIXME: ? we don't actually set the font size of anything here, just |
470 | 469 | // the base size for later modification by <font> tags. |
471 | 470 | self::$_last_basefont_size = $value; |
472 | 471 | return null; |
473 | - } |
|
472 | + } |
|
474 | 473 | |
475 | - static protected function _set_font_size($node, $value) { |
|
474 | + static protected function _set_font_size($node, $value) { |
|
476 | 475 | $style = $node->getAttribute("style"); |
477 | 476 | |
478 | 477 | if ( $value[0] === "-" || $value[0] === "+" ) |
479 | - $value = self::$_last_basefont_size + (int)$value; |
|
478 | + $value = self::$_last_basefont_size + (int)$value; |
|
480 | 479 | |
481 | 480 | if ( isset(self::$_font_size_lookup[$value]) ) |
482 | - $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";"; |
|
481 | + $style .= "; font-size: " . self::$_font_size_lookup[$value] . ";"; |
|
483 | 482 | else |
484 | - $style .= "; font-size: $value;"; |
|
483 | + $style .= "; font-size: $value;"; |
|
485 | 484 | |
486 | 485 | return ltrim($style, "; "); |
487 | 486 | |
488 | - } |
|
487 | + } |
|
489 | 488 | |
490 | 489 | } |
@@ -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: table_cell_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,15 +46,15 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Cell_Positioner extends Positioner { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function position() { |
|
53 | + function position() { |
|
55 | 54 | |
56 | 55 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
57 | 56 | $cellmap = $table->get_cellmap(); |
58 | 57 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
59 | 58 | |
60 | - } |
|
59 | + } |
|
61 | 60 | } |
@@ -71,201 +71,201 @@ discard block |
||
71 | 71 | |
72 | 72 | |
73 | 73 | |
74 | - /** |
|
75 | - * the location of the default built-in CSS file. |
|
76 | - * |
|
77 | - */ |
|
78 | - const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't |
|
79 | - // concatenate stuff in |
|
80 | - // const declarations, |
|
81 | - // but I can do this? |
|
82 | - // protected members |
|
83 | - |
|
84 | - /** |
|
85 | - * array of currently defined styles |
|
86 | - * @var array |
|
87 | - */ |
|
88 | - private $_styles; |
|
89 | - |
|
90 | - /** |
|
91 | - * base protocol of the document being parsed |
|
92 | - * |
|
93 | - * Used to handle relative urls. |
|
94 | - * |
|
95 | - * @var string |
|
96 | - */ |
|
97 | - private $_protocol; |
|
98 | - |
|
99 | - /** |
|
100 | - * base hostname of the document being parsed |
|
101 | - * |
|
102 | - * Used to handle relative urls. |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - private $_base_host; |
|
106 | - |
|
107 | - /** |
|
108 | - * base path of the document being parsed |
|
109 | - * |
|
110 | - * Used to handle relative urls. |
|
111 | - * @var string |
|
112 | - */ |
|
113 | - private $_base_path; |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * the style defined by @page rules |
|
118 | - * |
|
119 | - * @var Style |
|
120 | - */ |
|
121 | - private $_page_style; |
|
122 | - |
|
123 | - |
|
124 | - /** |
|
125 | - * list of loaded files, used to prevent recursion |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - private $_loaded_files; |
|
130 | - |
|
131 | - /** |
|
132 | - * accepted CSS media types |
|
133 | - * List of types and parsing rules for future extensions: |
|
134 | - * http://www.w3.org/TR/REC-html40/types.html |
|
135 | - * screen, tty, tv, projection, handheld, print, braille, aural, all |
|
136 | - * The following are non standard extensions for undocumented specific environments. |
|
137 | - * static, visual, bitmap, paged |
|
138 | - * Note, even though the generated pdf file is intended for print output, |
|
139 | - * the desired content might be different (e.g. screen or projection view of html file). |
|
140 | - * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE. |
|
141 | - * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE. |
|
142 | - * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE) |
|
143 | - */ |
|
144 | - static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print"; |
|
145 | - static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged"); |
|
146 | - |
|
147 | - /** |
|
148 | - * The class constructor. |
|
149 | - * |
|
150 | - * The base protocol, host & path are initialized to those of |
|
151 | - * the current script. |
|
152 | - */ |
|
153 | - function __construct() { |
|
74 | + /** |
|
75 | + * the location of the default built-in CSS file. |
|
76 | + * |
|
77 | + */ |
|
78 | + const DEFAULT_STYLESHEET = __DEFAULT_STYLESHEET; // Hack: can't |
|
79 | + // concatenate stuff in |
|
80 | + // const declarations, |
|
81 | + // but I can do this? |
|
82 | + // protected members |
|
83 | + |
|
84 | + /** |
|
85 | + * array of currently defined styles |
|
86 | + * @var array |
|
87 | + */ |
|
88 | + private $_styles; |
|
89 | + |
|
90 | + /** |
|
91 | + * base protocol of the document being parsed |
|
92 | + * |
|
93 | + * Used to handle relative urls. |
|
94 | + * |
|
95 | + * @var string |
|
96 | + */ |
|
97 | + private $_protocol; |
|
98 | + |
|
99 | + /** |
|
100 | + * base hostname of the document being parsed |
|
101 | + * |
|
102 | + * Used to handle relative urls. |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + private $_base_host; |
|
106 | + |
|
107 | + /** |
|
108 | + * base path of the document being parsed |
|
109 | + * |
|
110 | + * Used to handle relative urls. |
|
111 | + * @var string |
|
112 | + */ |
|
113 | + private $_base_path; |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * the style defined by @page rules |
|
118 | + * |
|
119 | + * @var Style |
|
120 | + */ |
|
121 | + private $_page_style; |
|
122 | + |
|
123 | + |
|
124 | + /** |
|
125 | + * list of loaded files, used to prevent recursion |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_loaded_files; |
|
130 | + |
|
131 | + /** |
|
132 | + * accepted CSS media types |
|
133 | + * List of types and parsing rules for future extensions: |
|
134 | + * http://www.w3.org/TR/REC-html40/types.html |
|
135 | + * screen, tty, tv, projection, handheld, print, braille, aural, all |
|
136 | + * The following are non standard extensions for undocumented specific environments. |
|
137 | + * static, visual, bitmap, paged |
|
138 | + * Note, even though the generated pdf file is intended for print output, |
|
139 | + * the desired content might be different (e.g. screen or projection view of html file). |
|
140 | + * Therefore allow specification of content by dompdf setting DOMPDF_DEFAULT_MEDIA_TYPE. |
|
141 | + * If given, replace media "print" by DOMPDF_DEFAULT_MEDIA_TYPE. |
|
142 | + * (Previous version $ACCEPTED_MEDIA_TYPES = $ACCEPTED_GENERIC_MEDIA_TYPES + $ACCEPTED_DEFAULT_MEDIA_TYPE) |
|
143 | + */ |
|
144 | + static $ACCEPTED_DEFAULT_MEDIA_TYPE = "print"; |
|
145 | + static $ACCEPTED_GENERIC_MEDIA_TYPES = array("all", "static", "visual", "bitmap", "paged"); |
|
146 | + |
|
147 | + /** |
|
148 | + * The class constructor. |
|
149 | + * |
|
150 | + * The base protocol, host & path are initialized to those of |
|
151 | + * the current script. |
|
152 | + */ |
|
153 | + function __construct() { |
|
154 | 154 | $this->_styles = array(); |
155 | 155 | $this->_loaded_files = array(); |
156 | 156 | list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($_SERVER["SCRIPT_FILENAME"]); |
157 | 157 | $this->_page_style = null; |
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Set the base protocol |
|
162 | - * |
|
163 | - * @param string $proto |
|
164 | - */ |
|
165 | - function set_protocol($proto) { $this->_protocol = $proto; } |
|
166 | - |
|
167 | - /** |
|
168 | - * Set the base host |
|
169 | - * |
|
170 | - * @param string $host |
|
171 | - */ |
|
172 | - function set_host($host) { $this->_base_host = $host; } |
|
173 | - |
|
174 | - /** |
|
175 | - * Set the base path |
|
176 | - * |
|
177 | - * @param string $path |
|
178 | - */ |
|
179 | - function set_base_path($path) { $this->_base_path = $path; } |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * Return the base protocol for this stylesheet |
|
184 | - * |
|
185 | - * @return string |
|
186 | - */ |
|
187 | - function get_protocol() { return $this->_protocol; } |
|
188 | - |
|
189 | - /** |
|
190 | - * Return the base host for this stylesheet |
|
191 | - * |
|
192 | - * @return string |
|
193 | - */ |
|
194 | - function get_host() { return $this->_base_host; } |
|
195 | - |
|
196 | - /** |
|
197 | - * Return the base path for this stylesheet |
|
198 | - * |
|
199 | - * @return string |
|
200 | - */ |
|
201 | - function get_base_path() { return $this->_base_path; } |
|
202 | - |
|
203 | - /** |
|
204 | - * add a new Style object to the stylesheet |
|
205 | - * |
|
206 | - * add_style() adds a new Style object to the current stylesheet, or |
|
207 | - * merges a new Style with an existing one. |
|
208 | - * |
|
209 | - * @param string $key the Style's selector |
|
210 | - * @param Style $style the Style to be added |
|
211 | - */ |
|
212 | - function add_style($key, Style $style) { |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Set the base protocol |
|
162 | + * |
|
163 | + * @param string $proto |
|
164 | + */ |
|
165 | + function set_protocol($proto) { $this->_protocol = $proto; } |
|
166 | + |
|
167 | + /** |
|
168 | + * Set the base host |
|
169 | + * |
|
170 | + * @param string $host |
|
171 | + */ |
|
172 | + function set_host($host) { $this->_base_host = $host; } |
|
173 | + |
|
174 | + /** |
|
175 | + * Set the base path |
|
176 | + * |
|
177 | + * @param string $path |
|
178 | + */ |
|
179 | + function set_base_path($path) { $this->_base_path = $path; } |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * Return the base protocol for this stylesheet |
|
184 | + * |
|
185 | + * @return string |
|
186 | + */ |
|
187 | + function get_protocol() { return $this->_protocol; } |
|
188 | + |
|
189 | + /** |
|
190 | + * Return the base host for this stylesheet |
|
191 | + * |
|
192 | + * @return string |
|
193 | + */ |
|
194 | + function get_host() { return $this->_base_host; } |
|
195 | + |
|
196 | + /** |
|
197 | + * Return the base path for this stylesheet |
|
198 | + * |
|
199 | + * @return string |
|
200 | + */ |
|
201 | + function get_base_path() { return $this->_base_path; } |
|
202 | + |
|
203 | + /** |
|
204 | + * add a new Style object to the stylesheet |
|
205 | + * |
|
206 | + * add_style() adds a new Style object to the current stylesheet, or |
|
207 | + * merges a new Style with an existing one. |
|
208 | + * |
|
209 | + * @param string $key the Style's selector |
|
210 | + * @param Style $style the Style to be added |
|
211 | + */ |
|
212 | + function add_style($key, Style $style) { |
|
213 | 213 | if (!is_string($key)) |
214 | - throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
214 | + throw new DOMPDF_Exception("CSS rule must be keyed by a string."); |
|
215 | 215 | |
216 | 216 | if ( isset($this->_styles[$key]) ) |
217 | - $this->_styles[$key]->merge($style); |
|
217 | + $this->_styles[$key]->merge($style); |
|
218 | 218 | else |
219 | - $this->_styles[$key] = clone $style; |
|
220 | - } |
|
221 | - |
|
222 | - |
|
223 | - /** |
|
224 | - * lookup a specifc Style object |
|
225 | - * |
|
226 | - * lookup() returns the Style specified by $key, or null if the Style is |
|
227 | - * not found. |
|
228 | - * |
|
229 | - * @param string $key the selector of the requested Style |
|
230 | - * @return Style |
|
231 | - */ |
|
232 | - function lookup($key) { |
|
219 | + $this->_styles[$key] = clone $style; |
|
220 | + } |
|
221 | + |
|
222 | + |
|
223 | + /** |
|
224 | + * lookup a specifc Style object |
|
225 | + * |
|
226 | + * lookup() returns the Style specified by $key, or null if the Style is |
|
227 | + * not found. |
|
228 | + * |
|
229 | + * @param string $key the selector of the requested Style |
|
230 | + * @return Style |
|
231 | + */ |
|
232 | + function lookup($key) { |
|
233 | 233 | if ( !isset($this->_styles[$key]) ) |
234 | - return null; |
|
234 | + return null; |
|
235 | 235 | |
236 | 236 | return $this->_styles[$key]; |
237 | - } |
|
238 | - |
|
239 | - /** |
|
240 | - * create a new Style object associated with this stylesheet |
|
241 | - * |
|
242 | - * @param Style $parent The style of this style's parent in the DOM tree |
|
243 | - * @return Style |
|
244 | - */ |
|
245 | - function create_style($parent = null) { |
|
237 | + } |
|
238 | + |
|
239 | + /** |
|
240 | + * create a new Style object associated with this stylesheet |
|
241 | + * |
|
242 | + * @param Style $parent The style of this style's parent in the DOM tree |
|
243 | + * @return Style |
|
244 | + */ |
|
245 | + function create_style($parent = null) { |
|
246 | 246 | return new Style($this, $parent); |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * load and parse a CSS string |
|
252 | - * |
|
253 | - * @param string $css |
|
254 | - */ |
|
255 | - function load_css(&$css) { $this->_parse_css($css); } |
|
250 | + /** |
|
251 | + * load and parse a CSS string |
|
252 | + * |
|
253 | + * @param string $css |
|
254 | + */ |
|
255 | + function load_css(&$css) { $this->_parse_css($css); } |
|
256 | 256 | |
257 | 257 | |
258 | - /** |
|
259 | - * load and parse a CSS file |
|
260 | - * |
|
261 | - * @param string $file |
|
262 | - */ |
|
263 | - function load_css_file($file) { |
|
258 | + /** |
|
259 | + * load and parse a CSS file |
|
260 | + * |
|
261 | + * @param string $file |
|
262 | + */ |
|
263 | + function load_css_file($file) { |
|
264 | 264 | global $_dompdf_warnings; |
265 | 265 | |
266 | 266 | // Prevent circular references |
267 | 267 | if ( isset($this->_loaded_files[$file]) ) |
268 | - return; |
|
268 | + return; |
|
269 | 269 | |
270 | 270 | $this->_loaded_files[$file] = true; |
271 | 271 | $parsed_url = explode_url($file); |
@@ -274,36 +274,36 @@ discard block |
||
274 | 274 | |
275 | 275 | if ( !DOMPDF_ENABLE_REMOTE && |
276 | 276 | ($this->_protocol != "" && $this->_protocol !== "file://") ) { |
277 | - record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__); |
|
278 | - return; |
|
277 | + record_warnings(E_USER_WARNING, "Remote CSS file '$file' requested, but DOMPDF_ENABLE_REMOTE is false.", __FILE__, __LINE__); |
|
278 | + return; |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Fix submitted by Nick Oostveen for aliased directory support: |
282 | 282 | if ( $this->_protocol == "" ) |
283 | - $file = $this->_base_path . $filename; |
|
283 | + $file = $this->_base_path . $filename; |
|
284 | 284 | else |
285 | - $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
285 | + $file = build_url($this->_protocol, $this->_base_host, $this->_base_path, $filename); |
|
286 | 286 | |
287 | 287 | set_error_handler("record_warnings"); |
288 | 288 | $css = file_get_contents($file); |
289 | 289 | restore_error_handler(); |
290 | 290 | |
291 | 291 | if ( $css == "" ) { |
292 | - record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);; |
|
293 | - return; |
|
292 | + record_warnings(E_USER_WARNING, "Unable to load css file $file", __FILE__, __LINE__);; |
|
293 | + return; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $this->_parse_css($css); |
297 | 297 | |
298 | - } |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * @link http://www.w3.org/TR/CSS21/cascade.html#specificity} |
|
302 | - * |
|
303 | - * @param string $selector |
|
304 | - * @return int |
|
305 | - */ |
|
306 | - private function _specificity($selector) { |
|
300 | + /** |
|
301 | + * @link http://www.w3.org/TR/CSS21/cascade.html#specificity} |
|
302 | + * |
|
303 | + * @param string $selector |
|
304 | + * @return int |
|
305 | + */ |
|
306 | + private function _specificity($selector) { |
|
307 | 307 | // http://www.w3.org/TR/CSS21/cascade.html#specificity |
308 | 308 | // ignoring the ":" pseudoclass modifyers |
309 | 309 | // also ignored in _css_selector_to_xpath |
@@ -325,26 +325,26 @@ discard block |
||
325 | 325 | //see _css_selector_to_xpath |
326 | 326 | |
327 | 327 | if ( !in_array($selector[0], array(" ", ">", ".", "#", "+", ":", "[")) ) { |
328 | - $d++; |
|
328 | + $d++; |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | if (DEBUGCSS) { |
332 | - /*DEBUGCSS*/ print "<pre>\n"; |
|
333 | - /*DEBUGCSS*/ printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector); |
|
334 | - /*DEBUGCSS*/ print "</pre>"; |
|
332 | + /*DEBUGCSS*/ print "<pre>\n"; |
|
333 | + /*DEBUGCSS*/ printf("_specificity(): 0x%08x \"%s\"\n", ($a << 24) | ($b << 16) | ($c << 8) | ($d), $selector); |
|
334 | + /*DEBUGCSS*/ print "</pre>"; |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | return ($a << 24) | ($b << 16) | ($c << 8) | ($d); |
338 | - } |
|
338 | + } |
|
339 | 339 | |
340 | 340 | |
341 | - /** |
|
342 | - * converts a CSS selector to an XPath query. |
|
343 | - * |
|
344 | - * @param string $selector |
|
345 | - * @return string |
|
346 | - */ |
|
347 | - private function _css_selector_to_xpath($selector) { |
|
341 | + /** |
|
342 | + * converts a CSS selector to an XPath query. |
|
343 | + * |
|
344 | + * @param string $selector |
|
345 | + * @return string |
|
346 | + */ |
|
347 | + private function _css_selector_to_xpath($selector) { |
|
348 | 348 | |
349 | 349 | // Collapse white space and strip whitespace around delimiters |
350 | 350 | // $search = array("/\\s+/", "/\\s+([.>#+:])\\s+/"); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | // Add an implicit space at the beginning of the selector if there is no |
363 | 363 | // delimiter there already. |
364 | 364 | if ( !in_array($selector[0], $delimiters) ) |
365 | - $selector = " $selector"; |
|
365 | + $selector = " $selector"; |
|
366 | 366 | |
367 | 367 | $tok = ""; |
368 | 368 | $len = mb_strlen($selector); |
@@ -370,37 +370,37 @@ discard block |
||
370 | 370 | |
371 | 371 | while ( $i < $len ) { |
372 | 372 | |
373 | - $s = $selector[$i]; |
|
374 | - $i++; |
|
373 | + $s = $selector[$i]; |
|
374 | + $i++; |
|
375 | 375 | |
376 | - // Eat characters up to the next delimiter |
|
377 | - $tok = ""; |
|
376 | + // Eat characters up to the next delimiter |
|
377 | + $tok = ""; |
|
378 | 378 | |
379 | - while ($i < $len) { |
|
379 | + while ($i < $len) { |
|
380 | 380 | if ( in_array($selector[$i], $delimiters) ) |
381 | - break; |
|
381 | + break; |
|
382 | 382 | $tok .= $selector[$i++]; |
383 | - } |
|
383 | + } |
|
384 | 384 | |
385 | - switch ($s) { |
|
385 | + switch ($s) { |
|
386 | 386 | |
387 | - case " ": |
|
387 | + case " ": |
|
388 | 388 | case ">": |
389 | 389 | // All elements matching the next token that are direct children of |
390 | 390 | // the current token |
391 | 391 | $expr = $s === " " ? "descendant" : "child"; |
392 | 392 | |
393 | 393 | if ( mb_substr($query, -1, 1) !== "/" ) |
394 | - $query .= "/"; |
|
394 | + $query .= "/"; |
|
395 | 395 | |
396 | 396 | if ( !$tok ) |
397 | - $tok = "*"; |
|
397 | + $tok = "*"; |
|
398 | 398 | |
399 | 399 | $query .= "$expr::$tok"; |
400 | 400 | $tok = ""; |
401 | 401 | break; |
402 | 402 | |
403 | - case ".": |
|
403 | + case ".": |
|
404 | 404 | case "#": |
405 | 405 | // All elements matching the current token with a class/id equal to |
406 | 406 | // the _next_ token. |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | |
410 | 410 | // empty class/id == * |
411 | 411 | if ( mb_substr($query, -1, 1) === "/" ) |
412 | - $query .= "*"; |
|
412 | + $query .= "*"; |
|
413 | 413 | |
414 | 414 | // Match multiple classes: $tok contains the current selected |
415 | 415 | // class. Search for class attributes with class="$tok", |
@@ -423,28 +423,28 @@ discard block |
||
423 | 423 | $tok = ""; |
424 | 424 | break; |
425 | 425 | |
426 | - case "+": |
|
426 | + case "+": |
|
427 | 427 | // All sibling elements that folow the current token |
428 | 428 | if ( mb_substr($query, -1, 1) !== "/" ) |
429 | - $query .= "/"; |
|
429 | + $query .= "/"; |
|
430 | 430 | |
431 | 431 | $query .= "following-sibling::$tok"; |
432 | 432 | $tok = ""; |
433 | 433 | break; |
434 | 434 | |
435 | - case ":": |
|
435 | + case ":": |
|
436 | 436 | // Pseudo-classes |
437 | 437 | switch ($tok) { |
438 | 438 | |
439 | 439 | case "first-child": |
440 | 440 | $query .= "[1]"; |
441 | - $tok = ""; |
|
442 | - break; |
|
441 | + $tok = ""; |
|
442 | + break; |
|
443 | 443 | |
444 | 444 | case "link": |
445 | 445 | $query .= "[@href]"; |
446 | - $tok = ""; |
|
447 | - break; |
|
446 | + $tok = ""; |
|
447 | + break; |
|
448 | 448 | |
449 | 449 | case "first-line": |
450 | 450 | break; |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | |
463 | 463 | break; |
464 | 464 | |
465 | - case "[": |
|
465 | + case "[": |
|
466 | 466 | // Attribute selectors. All with an attribute matching the following token(s) |
467 | 467 | $attr_delimiters = array("=", "]", "~", "|"); |
468 | 468 | $tok_len = mb_strlen($tok); |
@@ -473,9 +473,9 @@ discard block |
||
473 | 473 | $value = ""; |
474 | 474 | |
475 | 475 | while ( $j < $tok_len ) { |
476 | - if ( in_array($tok[$j], $attr_delimiters) ) |
|
476 | + if ( in_array($tok[$j], $attr_delimiters) ) |
|
477 | 477 | break; |
478 | - $attr .= $tok[$j++]; |
|
478 | + $attr .= $tok[$j++]; |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | switch ( $tok[$j] ) { |
@@ -484,67 +484,67 @@ discard block |
||
484 | 484 | case "|": |
485 | 485 | $op .= $tok[$j++]; |
486 | 486 | |
487 | - if ( $tok[$j] !== "=" ) |
|
487 | + if ( $tok[$j] !== "=" ) |
|
488 | 488 | throw new DOMPDF_Exception("Invalid CSS selector syntax: invalid attribute selector: $selector"); |
489 | 489 | |
490 | - $op .= $tok[$j]; |
|
491 | - break; |
|
490 | + $op .= $tok[$j]; |
|
491 | + break; |
|
492 | 492 | |
493 | 493 | case "=": |
494 | 494 | $op = "="; |
495 | - break; |
|
495 | + break; |
|
496 | 496 | |
497 | 497 | } |
498 | 498 | |
499 | 499 | // Read the attribute value, if required |
500 | 500 | if ( $op != "" ) { |
501 | - $j++; |
|
502 | - while ( $j < $tok_len ) { |
|
501 | + $j++; |
|
502 | + while ( $j < $tok_len ) { |
|
503 | 503 | if ( $tok[$j] === "]" ) |
504 | - break; |
|
504 | + break; |
|
505 | 505 | $value .= $tok[$j++]; |
506 | - } |
|
506 | + } |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | if ( $attr == "" ) |
510 | - throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
510 | + throw new DOMPDF_Exception("Invalid CSS selector syntax: missing attribute name"); |
|
511 | 511 | |
512 | 512 | switch ( $op ) { |
513 | 513 | |
514 | 514 | case "": |
515 | 515 | $query .= "[@$attr]"; |
516 | - break; |
|
516 | + break; |
|
517 | 517 | |
518 | 518 | case "=": |
519 | 519 | $query .= "[@$attr$op\"$value\"]"; |
520 | - break; |
|
520 | + break; |
|
521 | 521 | |
522 | 522 | case "~=": |
523 | 523 | // FIXME: this will break if $value contains quoted strings |
524 | 524 | // (e.g. [type~="a b c" "d e f"]) |
525 | 525 | $values = explode(" ", $value); |
526 | - $query .= "["; |
|
526 | + $query .= "["; |
|
527 | 527 | |
528 | - foreach ( $values as $val ) |
|
528 | + foreach ( $values as $val ) |
|
529 | 529 | $query .= "@$attr=\"$val\" or "; |
530 | 530 | |
531 | - $query = rtrim($query, " or ") . "]"; |
|
532 | - break; |
|
531 | + $query = rtrim($query, " or ") . "]"; |
|
532 | + break; |
|
533 | 533 | |
534 | 534 | case "|=": |
535 | 535 | $values = explode("-", $value); |
536 | - $query .= "["; |
|
536 | + $query .= "["; |
|
537 | 537 | |
538 | - foreach ($values as $val) |
|
538 | + foreach ($values as $val) |
|
539 | 539 | $query .= "starts-with(@$attr, \"$val\") or "; |
540 | 540 | |
541 | - $query = rtrim($query, " or ") . "]"; |
|
542 | - break; |
|
541 | + $query = rtrim($query, " or ") . "]"; |
|
542 | + break; |
|
543 | 543 | |
544 | 544 | } |
545 | 545 | |
546 | 546 | break; |
547 | - } |
|
547 | + } |
|
548 | 548 | } |
549 | 549 | $i++; |
550 | 550 | |
@@ -571,21 +571,21 @@ discard block |
||
571 | 571 | |
572 | 572 | // Trim the trailing '/' from the query |
573 | 573 | if ( mb_strlen($query) > 2 ) |
574 | - $query = rtrim($query, "/"); |
|
574 | + $query = rtrim($query, "/"); |
|
575 | 575 | |
576 | 576 | return $query; |
577 | - } |
|
578 | - |
|
579 | - /** |
|
580 | - * applies all current styles to a particular document tree |
|
581 | - * |
|
582 | - * apply_styles() applies all currently loaded styles to the provided |
|
583 | - * {@link Frame_Tree}. Aside from parsing CSS, this is the main purpose |
|
584 | - * of this class. |
|
585 | - * |
|
586 | - * @param Frame_Tree $tree |
|
587 | - */ |
|
588 | - function apply_styles(Frame_Tree $tree) { |
|
577 | + } |
|
578 | + |
|
579 | + /** |
|
580 | + * applies all current styles to a particular document tree |
|
581 | + * |
|
582 | + * apply_styles() applies all currently loaded styles to the provided |
|
583 | + * {@link Frame_Tree}. Aside from parsing CSS, this is the main purpose |
|
584 | + * of this class. |
|
585 | + * |
|
586 | + * @param Frame_Tree $tree |
|
587 | + */ |
|
588 | + function apply_styles(Frame_Tree $tree) { |
|
589 | 589 | |
590 | 590 | // Use XPath to select nodes. This would be easier if we could attach |
591 | 591 | // Frame objects directly to DOMNodes using the setUserData() method, but |
@@ -605,67 +605,67 @@ discard block |
||
605 | 605 | // Apply all styles in stylesheet |
606 | 606 | foreach ($this->_styles as $selector => $style) { |
607 | 607 | |
608 | - $query = $this->_css_selector_to_xpath($selector); |
|
608 | + $query = $this->_css_selector_to_xpath($selector); |
|
609 | 609 | // pre_var_dump($selector); |
610 | 610 | // pre_var_dump($query); |
611 | 611 | // echo ($style); |
612 | 612 | |
613 | - // Retrieve the nodes |
|
614 | - $nodes = $xp->query($query); |
|
613 | + // Retrieve the nodes |
|
614 | + $nodes = $xp->query($query); |
|
615 | 615 | |
616 | - foreach ($nodes as $node) { |
|
616 | + foreach ($nodes as $node) { |
|
617 | 617 | //echo $node->nodeName . "\n"; |
618 | 618 | // Retrieve the node id |
619 | 619 | if ( $node->nodeType != 1 ) // Only DOMElements get styles |
620 | - continue; |
|
620 | + continue; |
|
621 | 621 | |
622 | 622 | $id = $node->getAttribute("frame_id"); |
623 | 623 | |
624 | 624 | // Assign the current style to the scratch array |
625 | 625 | $spec = $this->_specificity($selector); |
626 | 626 | $styles[$id][$spec][] = $style; |
627 | - } |
|
627 | + } |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // Now create the styles and assign them to the appropriate frames. (We |
631 | 631 | // iterate over the tree using an implicit Frame_Tree iterator.) |
632 | 632 | $root_flg = false; |
633 | 633 | foreach ($tree->get_frames() as $frame) { |
634 | - // pre_r($frame->get_node()->nodeName . ":"); |
|
635 | - if ( !$root_flg && $this->_page_style ) { |
|
634 | + // pre_r($frame->get_node()->nodeName . ":"); |
|
635 | + if ( !$root_flg && $this->_page_style ) { |
|
636 | 636 | $style = $this->_page_style; |
637 | 637 | $root_flg = true; |
638 | - } else |
|
638 | + } else |
|
639 | 639 | $style = $this->create_style(); |
640 | 640 | |
641 | - // Find nearest DOMElement parent |
|
642 | - $p = $frame; |
|
643 | - while ( $p = $p->get_parent() ) |
|
641 | + // Find nearest DOMElement parent |
|
642 | + $p = $frame; |
|
643 | + while ( $p = $p->get_parent() ) |
|
644 | 644 | if ($p->get_node()->nodeType == 1 ) |
645 | - break; |
|
645 | + break; |
|
646 | 646 | |
647 | - // Styles can only be applied directly to DOMElements; anonymous |
|
648 | - // frames inherit from their parent |
|
649 | - if ( $frame->get_node()->nodeType != 1 ) { |
|
647 | + // Styles can only be applied directly to DOMElements; anonymous |
|
648 | + // frames inherit from their parent |
|
649 | + if ( $frame->get_node()->nodeType != 1 ) { |
|
650 | 650 | if ( $p ) |
651 | - $style->inherit($p->get_style()); |
|
651 | + $style->inherit($p->get_style()); |
|
652 | 652 | $frame->set_style($style); |
653 | 653 | continue; |
654 | - } |
|
654 | + } |
|
655 | 655 | |
656 | - $id = $frame->get_id(); |
|
656 | + $id = $frame->get_id(); |
|
657 | 657 | |
658 | - // Handle HTML 4.0 attributes |
|
659 | - Attribute_Translator::translate_attributes($frame); |
|
658 | + // Handle HTML 4.0 attributes |
|
659 | + Attribute_Translator::translate_attributes($frame); |
|
660 | 660 | |
661 | - // Locate any additional style attributes |
|
662 | - if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) { |
|
661 | + // Locate any additional style attributes |
|
662 | + if ( ($str = $frame->get_node()->getAttribute("style")) !== "" ) { |
|
663 | 663 | $spec = $this->_specificity("!style attribute"); |
664 | 664 | $styles[$id][$spec][] = $this->_parse_properties($str); |
665 | - } |
|
665 | + } |
|
666 | 666 | |
667 | - // Grab the applicable styles |
|
668 | - if ( isset($styles[$id]) ) { |
|
667 | + // Grab the applicable styles |
|
668 | + if ( isset($styles[$id]) ) { |
|
669 | 669 | |
670 | 670 | $applied_styles = $styles[ $frame->get_id() ]; |
671 | 671 | |
@@ -673,101 +673,101 @@ discard block |
||
673 | 673 | ksort($applied_styles); |
674 | 674 | |
675 | 675 | if (DEBUGCSS) { |
676 | - $debug_nodename = $frame->get_node()->nodeName; |
|
677 | - print "<pre>\n[$debug_nodename\n"; |
|
678 | - foreach ($applied_styles as $spec => $arr) { |
|
676 | + $debug_nodename = $frame->get_node()->nodeName; |
|
677 | + print "<pre>\n[$debug_nodename\n"; |
|
678 | + foreach ($applied_styles as $spec => $arr) { |
|
679 | 679 | printf("specificity: 0x%08x\n",$spec); |
680 | 680 | foreach ($arr as $s) { |
681 | - print "[\n"; |
|
682 | - $s->debug_print(); |
|
683 | - print "]\n"; |
|
681 | + print "[\n"; |
|
682 | + $s->debug_print(); |
|
683 | + print "]\n"; |
|
684 | + } |
|
684 | 685 | } |
685 | - } |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | // Merge the new styles with the inherited styles |
689 | 689 | foreach ($applied_styles as $arr) { |
690 | - foreach ($arr as $s) |
|
690 | + foreach ($arr as $s) |
|
691 | 691 | $style->merge($s); |
692 | 692 | } |
693 | - } |
|
693 | + } |
|
694 | 694 | |
695 | - // Inherit parent's styles if required |
|
696 | - if ( $p ) { |
|
695 | + // Inherit parent's styles if required |
|
696 | + if ( $p ) { |
|
697 | 697 | |
698 | 698 | if (DEBUGCSS) { |
699 | - print "inherit:\n"; |
|
700 | - print "[\n"; |
|
701 | - $p->get_style()->debug_print(); |
|
702 | - print "]\n"; |
|
699 | + print "inherit:\n"; |
|
700 | + print "[\n"; |
|
701 | + $p->get_style()->debug_print(); |
|
702 | + print "]\n"; |
|
703 | 703 | } |
704 | 704 | |
705 | 705 | $style->inherit( $p->get_style() ); |
706 | - } |
|
706 | + } |
|
707 | 707 | |
708 | - if (DEBUGCSS) { |
|
708 | + if (DEBUGCSS) { |
|
709 | 709 | print "DomElementStyle:\n"; |
710 | 710 | print "[\n"; |
711 | 711 | $style->debug_print(); |
712 | 712 | print "]\n"; |
713 | 713 | print "/$debug_nodename]\n</pre>"; |
714 | - } |
|
714 | + } |
|
715 | 715 | |
716 | - /*DEBUGCSS print: see below different print debugging method |
|
716 | + /*DEBUGCSS print: see below different print debugging method |
|
717 | 717 | pre_r($frame->get_node()->nodeName . ":"); |
718 | 718 | echo "<pre>"; |
719 | 719 | echo $style; |
720 | 720 | echo "</pre>";*/ |
721 | - $frame->set_style($style); |
|
721 | + $frame->set_style($style); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
725 | 725 | // We're done! Clean out the registry of all styles since we |
726 | 726 | // won't be needing this later. |
727 | 727 | foreach ( array_keys($this->_styles) as $key ) { |
728 | - unset($this->_styles[$key]); |
|
728 | + unset($this->_styles[$key]); |
|
729 | 729 | } |
730 | 730 | |
731 | - } |
|
731 | + } |
|
732 | 732 | |
733 | 733 | |
734 | - /** |
|
735 | - * parse a CSS string using a regex parser |
|
736 | - * |
|
737 | - * Called by {@link Stylesheet::parse_css()} |
|
738 | - * |
|
739 | - * @param string $str |
|
740 | - */ |
|
741 | - private function _parse_css($str) { |
|
734 | + /** |
|
735 | + * parse a CSS string using a regex parser |
|
736 | + * |
|
737 | + * Called by {@link Stylesheet::parse_css()} |
|
738 | + * |
|
739 | + * @param string $str |
|
740 | + */ |
|
741 | + private function _parse_css($str) { |
|
742 | 742 | |
743 | 743 | $str = trim($str); |
744 | 744 | |
745 | 745 | // Destroy comments and remove HTML comments |
746 | 746 | $css = preg_replace(array( |
747 | - "'/\*.*?\*/'si", |
|
748 | - "/^<!--/", |
|
749 | - "/-->$/" |
|
747 | + "'/\*.*?\*/'si", |
|
748 | + "/^<!--/", |
|
749 | + "/-->$/" |
|
750 | 750 | ), "", $str); |
751 | 751 | |
752 | 752 | // FIXME: handle '{' within strings, e.g. [attr="string {}"] |
753 | 753 | |
754 | 754 | // Something more legible: |
755 | 755 | $re = |
756 | - "/\s* # Skip leading whitespace \n". |
|
757 | - "( @([^\s]+)\s+([^{;]*) (?:;|({)) )? # Match @rules followed by ';' or '{' \n". |
|
758 | - "(?(1) # Only parse sub-sections if we're in an @rule... \n". |
|
759 | - " (?(4) # ...and if there was a leading '{' \n". |
|
760 | - " \s*( (?:(?>[^{}]+) ({)? # Parse rulesets and individual @page rules \n". |
|
761 | - " (?(6) (?>[^}]*) }) \s*)+? \n". |
|
762 | - " ) \n". |
|
763 | - " }) # Balancing '}' \n". |
|
764 | - "| # Branch to match regular rules (not preceeded by '@')\n". |
|
765 | - "([^{]*{[^}]*})) # Parse normal rulesets\n". |
|
766 | - "/xs"; |
|
756 | + "/\s* # Skip leading whitespace \n". |
|
757 | + "( @([^\s]+)\s+([^{;]*) (?:;|({)) )? # Match @rules followed by ';' or '{' \n". |
|
758 | + "(?(1) # Only parse sub-sections if we're in an @rule... \n". |
|
759 | + " (?(4) # ...and if there was a leading '{' \n". |
|
760 | + " \s*( (?:(?>[^{}]+) ({)? # Parse rulesets and individual @page rules \n". |
|
761 | + " (?(6) (?>[^}]*) }) \s*)+? \n". |
|
762 | + " ) \n". |
|
763 | + " }) # Balancing '}' \n". |
|
764 | + "| # Branch to match regular rules (not preceeded by '@')\n". |
|
765 | + "([^{]*{[^}]*})) # Parse normal rulesets\n". |
|
766 | + "/xs"; |
|
767 | 767 | |
768 | 768 | if ( preg_match_all($re, $css, $matches, PREG_SET_ORDER) === false ) |
769 | - // An error occured |
|
770 | - throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
|
769 | + // An error occured |
|
770 | + throw new DOMPDF_Exception("Error parsing css file: preg_match_all() failed."); |
|
771 | 771 | |
772 | 772 | // After matching, the array indicies are set as follows: |
773 | 773 | // |
@@ -782,27 +782,27 @@ discard block |
||
782 | 782 | // |
783 | 783 | //pre_r($matches); |
784 | 784 | foreach ( $matches as $match ) { |
785 | - $match[2] = trim($match[2]); |
|
785 | + $match[2] = trim($match[2]); |
|
786 | 786 | |
787 | - if ( $match[2] !== "" ) { |
|
787 | + if ( $match[2] !== "" ) { |
|
788 | 788 | // Handle @rules |
789 | 789 | switch ($match[2]) { |
790 | 790 | |
791 | 791 | case "import": |
792 | 792 | $this->_parse_import($match[3]); |
793 | - break; |
|
793 | + break; |
|
794 | 794 | |
795 | 795 | case "media": |
796 | 796 | $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
797 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
797 | + if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
798 | 798 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
799 | - } else { |
|
799 | + } else { |
|
800 | 800 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
801 | - } |
|
802 | - if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
801 | + } |
|
802 | + if ( in_array(mb_strtolower(trim($match[3])), $acceptedmedia ) ) { |
|
803 | 803 | $this->_parse_sections($match[5]); |
804 | - } |
|
805 | - break; |
|
804 | + } |
|
805 | + break; |
|
806 | 806 | |
807 | 807 | case "page": |
808 | 808 | //This handles @page to be applied to page oriented media |
@@ -827,9 +827,9 @@ discard block |
||
827 | 827 | // Store the style for later... |
828 | 828 | if ( is_null($this->_page_style) ) |
829 | 829 | $this->_page_style = $this->_parse_properties($match[5]); |
830 | - else |
|
830 | + else |
|
831 | 831 | $this->_page_style->merge($this->_parse_properties($match[5])); |
832 | - break; |
|
832 | + break; |
|
833 | 833 | |
834 | 834 | default: |
835 | 835 | // ignore everything else |
@@ -837,118 +837,118 @@ discard block |
||
837 | 837 | } |
838 | 838 | |
839 | 839 | continue; |
840 | - } |
|
840 | + } |
|
841 | 841 | |
842 | - if ( $match[7] !== "" ) |
|
842 | + if ( $match[7] !== "" ) |
|
843 | 843 | $this->_parse_sections($match[7]); |
844 | 844 | |
845 | 845 | } |
846 | - } |
|
846 | + } |
|
847 | 847 | |
848 | - /* See also style.cls Style::_image(), refactoring?, works also for imported css files */ |
|
849 | - protected function _image($val) { |
|
848 | + /* See also style.cls Style::_image(), refactoring?, works also for imported css files */ |
|
849 | + protected function _image($val) { |
|
850 | 850 | $DEBUGCSS=DEBUGCSS; |
851 | 851 | |
852 | 852 | if ( mb_strpos($val, "url") === false ) { |
853 | - $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
853 | + $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
854 | 854 | } |
855 | 855 | else { |
856 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
856 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
857 | 857 | |
858 | - // Resolve the url now in the context of the current stylesheet |
|
859 | - $parsed_url = explode_url($val); |
|
860 | - if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) { |
|
858 | + // Resolve the url now in the context of the current stylesheet |
|
859 | + $parsed_url = explode_url($val); |
|
860 | + if ( $parsed_url["protocol"] == "" && $this->get_protocol() == "" ) { |
|
861 | 861 | if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
862 | - $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
862 | + $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
863 | 863 | } else { |
864 | - $path = $this->get_base_path(); |
|
864 | + $path = $this->get_base_path(); |
|
865 | 865 | } |
866 | 866 | $path .= $parsed_url["path"] . $parsed_url["file"]; |
867 | 867 | $path = realpath($path); |
868 | 868 | // If realpath returns FALSE then specifically state that there is no background image |
869 | 869 | if (!$path) { $path = 'none'; } |
870 | - } else { |
|
870 | + } else { |
|
871 | 871 | $path = build_url($this->get_protocol(), |
872 | - $this->get_host(), |
|
873 | - $this->get_base_path(), |
|
874 | - $val); |
|
875 | - } |
|
872 | + $this->get_host(), |
|
873 | + $this->get_base_path(), |
|
874 | + $val); |
|
875 | + } |
|
876 | 876 | } |
877 | 877 | if ($DEBUGCSS) { |
878 | - print "<pre>[_image\n"; |
|
879 | - print_r($parsed_url); |
|
880 | - print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n"; |
|
881 | - print "_image]</pre>";; |
|
878 | + print "<pre>[_image\n"; |
|
879 | + print_r($parsed_url); |
|
880 | + print $this->get_protocol()."\n".$this->get_base_path()."\n".$path."\n"; |
|
881 | + print "_image]</pre>";; |
|
882 | 882 | } |
883 | 883 | return $path; |
884 | - } |
|
885 | - |
|
886 | - /** |
|
887 | - * parse @import{} sections |
|
888 | - * |
|
889 | - * @param string $url the url of the imported CSS file |
|
890 | - */ |
|
891 | - private function _parse_import($url) { |
|
884 | + } |
|
885 | + |
|
886 | + /** |
|
887 | + * parse @import{} sections |
|
888 | + * |
|
889 | + * @param string $url the url of the imported CSS file |
|
890 | + */ |
|
891 | + private function _parse_import($url) { |
|
892 | 892 | $arr = preg_split("/[\s\n,]/", $url,-1, PREG_SPLIT_NO_EMPTY); |
893 | 893 | $url = array_shift($arr); |
894 | 894 | $accept = false; |
895 | 895 | |
896 | 896 | if ( count($arr) > 0 ) { |
897 | 897 | |
898 | - $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
899 | - if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
898 | + $acceptedmedia = self::$ACCEPTED_GENERIC_MEDIA_TYPES; |
|
899 | + if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
|
900 | 900 | $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
901 | - } else { |
|
901 | + } else { |
|
902 | 902 | $acceptedmedia[] = self::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
903 | - } |
|
903 | + } |
|
904 | 904 | |
905 | - // @import url media_type [media_type...] |
|
906 | - foreach ( $arr as $type ) { |
|
905 | + // @import url media_type [media_type...] |
|
906 | + foreach ( $arr as $type ) { |
|
907 | 907 | if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) { |
908 | - $accept = true; |
|
909 | - break; |
|
908 | + $accept = true; |
|
909 | + break; |
|
910 | + } |
|
910 | 911 | } |
911 | - } |
|
912 | 912 | |
913 | 913 | } else { |
914 | - // unconditional import |
|
915 | - $accept = true; |
|
914 | + // unconditional import |
|
915 | + $accept = true; |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | if ( $accept ) { |
919 | - // Store our current base url properties in case the new url is elsewhere |
|
920 | - $protocol = $this->_protocol; |
|
921 | - $host = $this->_base_host; |
|
922 | - $path = $this->_base_path; |
|
919 | + // Store our current base url properties in case the new url is elsewhere |
|
920 | + $protocol = $this->_protocol; |
|
921 | + $host = $this->_base_host; |
|
922 | + $path = $this->_base_path; |
|
923 | 923 | |
924 | - // $url = str_replace(array('"',"url", "(", ")"), "", $url); |
|
925 | - // If the protocol is php, assume that we will import using file:// |
|
926 | - // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url); |
|
927 | - // Above does not work for subfolders and absolute urls. |
|
928 | - // Todo: As above, do we need to replace php or file to an empty protocol for local files? |
|
924 | + // $url = str_replace(array('"',"url", "(", ")"), "", $url); |
|
925 | + // If the protocol is php, assume that we will import using file:// |
|
926 | + // $url = build_url($protocol == "php://" ? "file://" : $protocol, $host, $path, $url); |
|
927 | + // Above does not work for subfolders and absolute urls. |
|
928 | + // Todo: As above, do we need to replace php or file to an empty protocol for local files? |
|
929 | 929 | |
930 | - $url = $this->_image($url); |
|
930 | + $url = $this->_image($url); |
|
931 | 931 | |
932 | - $this->load_css_file($url); |
|
932 | + $this->load_css_file($url); |
|
933 | + |
|
934 | + // Restore the current base url |
|
935 | + $this->_protocol = $protocol; |
|
936 | + $this->_base_host = $host; |
|
937 | + $this->_base_path = $path; |
|
938 | + } |
|
933 | 939 | |
934 | - // Restore the current base url |
|
935 | - $this->_protocol = $protocol; |
|
936 | - $this->_base_host = $host; |
|
937 | - $this->_base_path = $path; |
|
938 | 940 | } |
939 | 941 | |
940 | - } |
|
941 | - |
|
942 | - /** |
|
943 | - * parse regular CSS blocks |
|
944 | - * |
|
945 | - * _parse_properties() creates a new Style object based on the provided |
|
946 | - * CSS rules. |
|
947 | - * |
|
948 | - * @param string $str CSS rules |
|
949 | - * @return Style |
|
950 | - */ |
|
951 | - private function _parse_properties($str) { |
|
942 | + /** |
|
943 | + * parse regular CSS blocks |
|
944 | + * |
|
945 | + * _parse_properties() creates a new Style object based on the provided |
|
946 | + * CSS rules. |
|
947 | + * |
|
948 | + * @param string $str CSS rules |
|
949 | + * @return Style |
|
950 | + */ |
|
951 | + private function _parse_properties($str) { |
|
952 | 952 | $properties = explode(";", $str); |
953 | 953 | |
954 | 954 | if (DEBUGCSS) print '[_parse_properties'; |
@@ -956,71 +956,71 @@ discard block |
||
956 | 956 | // Create the style |
957 | 957 | $style = new Style($this); |
958 | 958 | foreach ($properties as $prop) { |
959 | - //A css property can have " ! important" appended (whitespace optional) |
|
960 | - //strip this off to decode core of the property correctly. |
|
961 | - //Pass on in the style to allow proper handling: |
|
962 | - //!important properties can only be overridden by other !important ones. |
|
963 | - //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);. |
|
964 | - //If no specific set function available, set _props["prop_name"] |
|
965 | - //style is always copied completely, or $_props handled separately |
|
966 | - //Therefore set a _important_props["prop_name"]=true to indicate the modifier |
|
967 | - |
|
968 | - /* Instead of short code, prefer the typical case with fast code |
|
959 | + //A css property can have " ! important" appended (whitespace optional) |
|
960 | + //strip this off to decode core of the property correctly. |
|
961 | + //Pass on in the style to allow proper handling: |
|
962 | + //!important properties can only be overridden by other !important ones. |
|
963 | + //$style->$prop_name = is a shortcut of $style->__set($prop_name,$value);. |
|
964 | + //If no specific set function available, set _props["prop_name"] |
|
965 | + //style is always copied completely, or $_props handled separately |
|
966 | + //Therefore set a _important_props["prop_name"]=true to indicate the modifier |
|
967 | + |
|
968 | + /* Instead of short code, prefer the typical case with fast code |
|
969 | 969 | $important = preg_match("/(.*?)!\s*important/",$prop,$match); |
970 | 970 | if ( $important ) { |
971 | 971 | $prop = $match[1]; |
972 | 972 | } |
973 | 973 | $prop = trim($prop); |
974 | 974 | */ |
975 | - if (DEBUGCSS) print '('; |
|
976 | - $important = false; |
|
977 | - $prop = trim($prop); |
|
978 | - if (substr($prop,-9) === 'important') { |
|
979 | - $prop_tmp = rtrim(substr($prop,0,-9)); |
|
980 | - if (substr($prop_tmp,-1) === '!') { |
|
981 | - $prop = rtrim(substr($prop_tmp,0,-1)); |
|
982 | - $important = true; |
|
983 | - } |
|
984 | - } |
|
975 | + if (DEBUGCSS) print '('; |
|
976 | + $important = false; |
|
977 | + $prop = trim($prop); |
|
978 | + if (substr($prop,-9) === 'important') { |
|
979 | + $prop_tmp = rtrim(substr($prop,0,-9)); |
|
980 | + if (substr($prop_tmp,-1) === '!') { |
|
981 | + $prop = rtrim(substr($prop_tmp,0,-1)); |
|
982 | + $important = true; |
|
983 | + } |
|
984 | + } |
|
985 | 985 | |
986 | - if ($prop == "") { |
|
986 | + if ($prop == "") { |
|
987 | 987 | if (DEBUGCSS) print 'empty)'; |
988 | 988 | continue; |
989 | - } |
|
989 | + } |
|
990 | 990 | |
991 | - $i = mb_strpos($prop, ":"); |
|
992 | - if ( $i === false ) { |
|
991 | + $i = mb_strpos($prop, ":"); |
|
992 | + if ( $i === false ) { |
|
993 | 993 | if (DEBUGCSS) print 'novalue'.$prop.')'; |
994 | 994 | continue; |
995 | - } |
|
995 | + } |
|
996 | 996 | |
997 | - $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
|
998 | - $value = ltrim(mb_substr($prop, $i+1)); |
|
999 | - if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1000 | - //New style, anyway empty |
|
1001 | - //if ($important || !$style->important_get($prop_name) ) { |
|
1002 | - //$style->$prop_name = array($value,$important); |
|
1003 | - //assignment might be replaced by overloading through __set, |
|
1004 | - //and overloaded functions might check _important_props, |
|
1005 | - //therefore set _important_props first. |
|
1006 | - if ($important) { |
|
997 | + $prop_name = rtrim(mb_strtolower(mb_substr($prop, 0, $i))); |
|
998 | + $value = ltrim(mb_substr($prop, $i+1)); |
|
999 | + if (DEBUGCSS) print $prop_name.':='.$value.($important?'!IMPORTANT':'').')'; |
|
1000 | + //New style, anyway empty |
|
1001 | + //if ($important || !$style->important_get($prop_name) ) { |
|
1002 | + //$style->$prop_name = array($value,$important); |
|
1003 | + //assignment might be replaced by overloading through __set, |
|
1004 | + //and overloaded functions might check _important_props, |
|
1005 | + //therefore set _important_props first. |
|
1006 | + if ($important) { |
|
1007 | 1007 | $style->important_set($prop_name); |
1008 | - } |
|
1009 | - //For easier debugging, don't use overloading of assignments with __set |
|
1010 | - $style->$prop_name = $value; |
|
1011 | - //$style->props_set($prop_name, $value); |
|
1008 | + } |
|
1009 | + //For easier debugging, don't use overloading of assignments with __set |
|
1010 | + $style->$prop_name = $value; |
|
1011 | + //$style->props_set($prop_name, $value); |
|
1012 | 1012 | } |
1013 | 1013 | if (DEBUGCSS) print '_parse_properties]'; |
1014 | 1014 | |
1015 | 1015 | return $style; |
1016 | - } |
|
1017 | - |
|
1018 | - /** |
|
1019 | - * parse selector + rulesets |
|
1020 | - * |
|
1021 | - * @param string $str CSS selectors and rulesets |
|
1022 | - */ |
|
1023 | - private function _parse_sections($str) { |
|
1016 | + } |
|
1017 | + |
|
1018 | + /** |
|
1019 | + * parse selector + rulesets |
|
1020 | + * |
|
1021 | + * @param string $str CSS selectors and rulesets |
|
1022 | + */ |
|
1023 | + private function _parse_sections($str) { |
|
1024 | 1024 | // Pre-process: collapse all whitespace and strip whitespace around '>', |
1025 | 1025 | // '.', ':', '+', '#' |
1026 | 1026 | |
@@ -1031,43 +1031,43 @@ discard block |
||
1031 | 1031 | $sections = explode("}", $str); |
1032 | 1032 | if (DEBUGCSS) print '[_parse_sections'; |
1033 | 1033 | foreach ($sections as $sect) { |
1034 | - $i = mb_strpos($sect, "{"); |
|
1034 | + $i = mb_strpos($sect, "{"); |
|
1035 | 1035 | |
1036 | - $selectors = explode(",", mb_substr($sect, 0, $i)); |
|
1037 | - if (DEBUGCSS) print '[section'; |
|
1038 | - $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
|
1036 | + $selectors = explode(",", mb_substr($sect, 0, $i)); |
|
1037 | + if (DEBUGCSS) print '[section'; |
|
1038 | + $style = $this->_parse_properties(trim(mb_substr($sect, $i+1))); |
|
1039 | 1039 | |
1040 | - // Assign it to the selected elements |
|
1041 | - foreach ($selectors as $selector) { |
|
1040 | + // Assign it to the selected elements |
|
1041 | + foreach ($selectors as $selector) { |
|
1042 | 1042 | $selector = trim($selector); |
1043 | 1043 | |
1044 | 1044 | if ($selector == "") { |
1045 | - if (DEBUGCSS) print '#empty#'; |
|
1046 | - continue; |
|
1045 | + if (DEBUGCSS) print '#empty#'; |
|
1046 | + continue; |
|
1047 | 1047 | } |
1048 | 1048 | if (DEBUGCSS) print '#'.$selector.'#'; |
1049 | 1049 | //if (DEBUGCSS) { if (strpos($selector,'p') !== false) print '!!!p!!!#'; } |
1050 | 1050 | |
1051 | 1051 | $this->add_style($selector, $style); |
1052 | - } |
|
1053 | - if (DEBUGCSS) print 'section]'; |
|
1052 | + } |
|
1053 | + if (DEBUGCSS) print 'section]'; |
|
1054 | 1054 | } |
1055 | 1055 | if (DEBUGCSS) print '_parse_sections]'; |
1056 | - } |
|
1057 | - |
|
1058 | - /** |
|
1059 | - * dumps the entire stylesheet as a string |
|
1060 | - * |
|
1061 | - * Generates a string of each selector and associated style in the |
|
1062 | - * Stylesheet. Useful for debugging. |
|
1063 | - * |
|
1064 | - * @return string |
|
1065 | - */ |
|
1066 | - function __toString() { |
|
1056 | + } |
|
1057 | + |
|
1058 | + /** |
|
1059 | + * dumps the entire stylesheet as a string |
|
1060 | + * |
|
1061 | + * Generates a string of each selector and associated style in the |
|
1062 | + * Stylesheet. Useful for debugging. |
|
1063 | + * |
|
1064 | + * @return string |
|
1065 | + */ |
|
1066 | + function __toString() { |
|
1067 | 1067 | $str = ""; |
1068 | 1068 | foreach ($this->_styles as $selector => $style) |
1069 | - $str .= "$selector => " . $style->__toString() . "\n"; |
|
1069 | + $str .= "$selector => " . $style->__toString() . "\n"; |
|
1070 | 1070 | |
1071 | 1071 | return $str; |
1072 | - } |
|
1072 | + } |
|
1073 | 1073 | } |
@@ -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: dompdf_internal_exception.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -46,14 +45,14 @@ discard block |
||
46 | 45 | */ |
47 | 46 | class DOMPDF_Internal_Exception extends Exception { |
48 | 47 | |
49 | - /** |
|
50 | - * Class constructor |
|
51 | - * |
|
52 | - * @param string $message Error message |
|
53 | - * @param int $code Error code |
|
54 | - */ |
|
55 | - function __construct($message = NULL, $code = 0) { |
|
48 | + /** |
|
49 | + * Class constructor |
|
50 | + * |
|
51 | + * @param string $message Error message |
|
52 | + * @param int $code Error code |
|
53 | + */ |
|
54 | + function __construct($message = NULL, $code = 0) { |
|
56 | 55 | parent::__construct($message, $code); |
57 | - } |
|
56 | + } |
|
58 | 57 | |
59 | 58 | } |