@@ -61,170 +61,170 @@ discard block |
||
61 | 61 | */ |
62 | 62 | class PDFLib_Adapter implements Canvas { |
63 | 63 | |
64 | - /** |
|
65 | - * Dimensions of paper sizes in points |
|
66 | - * |
|
67 | - * @var array; |
|
68 | - */ |
|
69 | - static public $PAPER_SIZES = array(); // Set to |
|
64 | + /** |
|
65 | + * Dimensions of paper sizes in points |
|
66 | + * |
|
67 | + * @var array; |
|
68 | + */ |
|
69 | + static public $PAPER_SIZES = array(); // Set to |
|
70 | 70 | // CPDF_Adapter::$PAPER_SIZES below. |
71 | 71 | |
72 | - /** |
|
73 | - * Fudge factor to adjust reported font heights |
|
74 | - * |
|
75 | - * CPDF reports larger font heights than PDFLib. This factor |
|
76 | - * adjusts the height reported by get_font_height(). |
|
77 | - * |
|
78 | - * @var float |
|
79 | - */ |
|
80 | - const FONT_HEIGHT_SCALE = 1.2; |
|
81 | - |
|
82 | - /** |
|
83 | - * Whether to create PDFs in memory or on disk |
|
84 | - * |
|
85 | - * @var bool |
|
86 | - */ |
|
87 | - static $IN_MEMORY = true; |
|
88 | - |
|
89 | - /** |
|
90 | - * Instance of PDFLib class |
|
91 | - * |
|
92 | - * @var PDFlib |
|
93 | - */ |
|
94 | - private $_pdf; |
|
95 | - |
|
96 | - /** |
|
97 | - * Name of temporary file used for PDFs created on disk |
|
98 | - * |
|
99 | - * @var string |
|
100 | - */ |
|
101 | - private $_file; |
|
102 | - |
|
103 | - /** |
|
104 | - * PDF width, in points |
|
105 | - * |
|
106 | - * @var float |
|
107 | - */ |
|
108 | - private $_width; |
|
109 | - |
|
110 | - /** |
|
111 | - * PDF height, in points |
|
112 | - * |
|
113 | - * @var height |
|
114 | - */ |
|
115 | - private $_height; |
|
116 | - |
|
117 | - /** |
|
118 | - * Last fill colour used |
|
119 | - * |
|
120 | - * @var array |
|
121 | - */ |
|
122 | - private $_last_fill_color; |
|
123 | - |
|
124 | - /** |
|
125 | - * Last stroke colour used |
|
126 | - * |
|
127 | - * @var array |
|
128 | - */ |
|
129 | - private $_last_stroke_color; |
|
130 | - |
|
131 | - /** |
|
132 | - * Cache of image handles |
|
133 | - * |
|
134 | - * @var array |
|
135 | - */ |
|
136 | - private $_imgs; |
|
137 | - |
|
138 | - /** |
|
139 | - * Cache of font handles |
|
140 | - * |
|
141 | - * @var array |
|
142 | - */ |
|
143 | - private $_fonts; |
|
144 | - |
|
145 | - /** |
|
146 | - * List of objects (templates) to add to multiple pages |
|
147 | - * |
|
148 | - * @var array |
|
149 | - */ |
|
150 | - private $_objs; |
|
151 | - |
|
152 | - /** |
|
153 | - * Current page number |
|
154 | - * |
|
155 | - * @var int |
|
156 | - */ |
|
157 | - private $_page_number; |
|
158 | - |
|
159 | - /** |
|
160 | - * Total number of pages |
|
161 | - * |
|
162 | - * @var int |
|
163 | - */ |
|
164 | - private $_page_count; |
|
165 | - |
|
166 | - /** |
|
167 | - * Text to display on every page |
|
168 | - * |
|
169 | - * @var array |
|
170 | - */ |
|
171 | - private $_page_text; |
|
172 | - |
|
173 | - /** |
|
174 | - * Array of pages for accesing after rendering is initially complete |
|
175 | - * |
|
176 | - * @var array |
|
177 | - */ |
|
178 | - private $_pages; |
|
179 | - |
|
180 | - /** |
|
181 | - * Class constructor |
|
182 | - * |
|
183 | - * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
184 | - * an array(xmin,ymin,xmax,ymax) |
|
185 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
186 | - */ |
|
187 | - function __construct($paper = "letter", $orientation = "portrait") { |
|
72 | + /** |
|
73 | + * Fudge factor to adjust reported font heights |
|
74 | + * |
|
75 | + * CPDF reports larger font heights than PDFLib. This factor |
|
76 | + * adjusts the height reported by get_font_height(). |
|
77 | + * |
|
78 | + * @var float |
|
79 | + */ |
|
80 | + const FONT_HEIGHT_SCALE = 1.2; |
|
81 | + |
|
82 | + /** |
|
83 | + * Whether to create PDFs in memory or on disk |
|
84 | + * |
|
85 | + * @var bool |
|
86 | + */ |
|
87 | + static $IN_MEMORY = true; |
|
88 | + |
|
89 | + /** |
|
90 | + * Instance of PDFLib class |
|
91 | + * |
|
92 | + * @var PDFlib |
|
93 | + */ |
|
94 | + private $_pdf; |
|
95 | + |
|
96 | + /** |
|
97 | + * Name of temporary file used for PDFs created on disk |
|
98 | + * |
|
99 | + * @var string |
|
100 | + */ |
|
101 | + private $_file; |
|
102 | + |
|
103 | + /** |
|
104 | + * PDF width, in points |
|
105 | + * |
|
106 | + * @var float |
|
107 | + */ |
|
108 | + private $_width; |
|
109 | + |
|
110 | + /** |
|
111 | + * PDF height, in points |
|
112 | + * |
|
113 | + * @var height |
|
114 | + */ |
|
115 | + private $_height; |
|
116 | + |
|
117 | + /** |
|
118 | + * Last fill colour used |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + private $_last_fill_color; |
|
123 | + |
|
124 | + /** |
|
125 | + * Last stroke colour used |
|
126 | + * |
|
127 | + * @var array |
|
128 | + */ |
|
129 | + private $_last_stroke_color; |
|
130 | + |
|
131 | + /** |
|
132 | + * Cache of image handles |
|
133 | + * |
|
134 | + * @var array |
|
135 | + */ |
|
136 | + private $_imgs; |
|
137 | + |
|
138 | + /** |
|
139 | + * Cache of font handles |
|
140 | + * |
|
141 | + * @var array |
|
142 | + */ |
|
143 | + private $_fonts; |
|
144 | + |
|
145 | + /** |
|
146 | + * List of objects (templates) to add to multiple pages |
|
147 | + * |
|
148 | + * @var array |
|
149 | + */ |
|
150 | + private $_objs; |
|
151 | + |
|
152 | + /** |
|
153 | + * Current page number |
|
154 | + * |
|
155 | + * @var int |
|
156 | + */ |
|
157 | + private $_page_number; |
|
158 | + |
|
159 | + /** |
|
160 | + * Total number of pages |
|
161 | + * |
|
162 | + * @var int |
|
163 | + */ |
|
164 | + private $_page_count; |
|
165 | + |
|
166 | + /** |
|
167 | + * Text to display on every page |
|
168 | + * |
|
169 | + * @var array |
|
170 | + */ |
|
171 | + private $_page_text; |
|
172 | + |
|
173 | + /** |
|
174 | + * Array of pages for accesing after rendering is initially complete |
|
175 | + * |
|
176 | + * @var array |
|
177 | + */ |
|
178 | + private $_pages; |
|
179 | + |
|
180 | + /** |
|
181 | + * Class constructor |
|
182 | + * |
|
183 | + * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or |
|
184 | + * an array(xmin,ymin,xmax,ymax) |
|
185 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
186 | + */ |
|
187 | + function __construct($paper = "letter", $orientation = "portrait") { |
|
188 | 188 | if ( is_array($paper) ) |
189 | - $size = $paper; |
|
189 | + $size = $paper; |
|
190 | 190 | else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) |
191 | - $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
191 | + $size = self::$PAPER_SIZES[mb_strtolower($paper)]; |
|
192 | 192 | else |
193 | - $size = self::$PAPER_SIZES["letter"]; |
|
193 | + $size = self::$PAPER_SIZES["letter"]; |
|
194 | 194 | |
195 | 195 | if ( mb_strtolower($orientation) === "landscape" ) { |
196 | - $a = $size[3]; |
|
197 | - $size[3] = $size[2]; |
|
198 | - $size[2] = $a; |
|
196 | + $a = $size[3]; |
|
197 | + $size[3] = $size[2]; |
|
198 | + $size[2] = $a; |
|
199 | 199 | } |
200 | 200 | $this->_width = $size[2] - $size[0]; |
201 | 201 | $this->_height= $size[3] - $size[1]; |
202 | 202 | |
203 | 203 | $this->_pdf = new PDFLib(); |
204 | 204 | |
205 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
206 | - $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
205 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
206 | + $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE); |
|
207 | 207 | |
208 | - $this->_pdf->set_parameter("textformat", "utf8"); |
|
208 | + $this->_pdf->set_parameter("textformat", "utf8"); |
|
209 | 209 | $this->_pdf->set_parameter("fontwarning", "false"); |
210 | 210 | |
211 | 211 | $this->_pdf->set_info("Creator", "DOMPDF Converter"); |
212 | 212 | |
213 | 213 | // Silence pedantic warnings about missing TZ settings |
214 | 214 | if ( function_exists("date_default_timezone_get") ) { |
215 | - $tz = @date_default_timezone_get(); |
|
216 | - date_default_timezone_set("UTC"); |
|
217 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
218 | - date_default_timezone_set($tz); |
|
215 | + $tz = @date_default_timezone_get(); |
|
216 | + date_default_timezone_set("UTC"); |
|
217 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
218 | + date_default_timezone_set($tz); |
|
219 | 219 | } else { |
220 | - $this->_pdf->set_info("Date", date("Y-m-d")); |
|
220 | + $this->_pdf->set_info("Date", date("Y-m-d")); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | if ( self::$IN_MEMORY ) |
224 | - $this->_pdf->begin_document("",""); |
|
224 | + $this->_pdf->begin_document("",""); |
|
225 | 225 | else { |
226 | - $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
227 | - $this->_pdf->begin_document($this->_file,""); |
|
226 | + $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf'; |
|
227 | + $this->_pdf->begin_document($this->_file,""); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
@@ -239,155 +239,155 @@ discard block |
||
239 | 239 | // Set up font paths |
240 | 240 | $families = Font_Metrics::get_font_families(); |
241 | 241 | foreach ($families as $family => $files) { |
242 | - foreach ($files as $style => $file) { |
|
242 | + foreach ($files as $style => $file) { |
|
243 | 243 | $face = basename($file); |
244 | 244 | |
245 | 245 | // Prefer ttfs to afms |
246 | 246 | if ( file_exists($file.".ttf") ) { |
247 | - $outline = "$file.ttf"; |
|
248 | - $afm = null; |
|
247 | + $outline = "$file.ttf"; |
|
248 | + $afm = null; |
|
249 | 249 | |
250 | 250 | } else if ( file_exists($file .".TTF") ) { |
251 | - $outline = "$file.TTF"; |
|
252 | - $afm = null; |
|
251 | + $outline = "$file.TTF"; |
|
252 | + $afm = null; |
|
253 | 253 | |
254 | 254 | } else if ( file_exists($file . ".pfb") ) { |
255 | - $outline = "$file.pfb"; |
|
255 | + $outline = "$file.pfb"; |
|
256 | 256 | |
257 | - if ( file_exists($file . ".afm") ) |
|
257 | + if ( file_exists($file . ".afm") ) |
|
258 | 258 | $afm = "$file.afm"; |
259 | 259 | |
260 | 260 | } else if ( file_exists($file . ".PFB") ) { |
261 | - $outline = "$file.PFB"; |
|
262 | - if ( file_exists($file . ".AFM") ) |
|
261 | + $outline = "$file.PFB"; |
|
262 | + if ( file_exists($file . ".AFM") ) |
|
263 | 263 | $afm = "$file.AFM"; |
264 | 264 | } else |
265 | - continue; |
|
265 | + continue; |
|
266 | 266 | |
267 | 267 | $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}"); |
268 | 268 | if ( !is_null($afm) ) |
269 | - $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
270 | - } |
|
269 | + $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}"); |
|
270 | + } |
|
271 | + } |
|
271 | 272 | } |
272 | - } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Close the pdf |
|
276 | - */ |
|
277 | - protected function _close() { |
|
274 | + /** |
|
275 | + * Close the pdf |
|
276 | + */ |
|
277 | + protected function _close() { |
|
278 | 278 | $this->_place_objects(); |
279 | 279 | |
280 | 280 | // Close all pages |
281 | 281 | $this->_pdf->suspend_page(""); |
282 | 282 | for ($p = 1; $p <= $this->_page_count; $p++) { |
283 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
284 | - $this->_pdf->end_page_ext(""); |
|
283 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
284 | + $this->_pdf->end_page_ext(""); |
|
285 | 285 | } |
286 | 286 | |
287 | 287 | $this->_pdf->end_document(""); |
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Returns the PDFLib instance |
|
293 | - * |
|
294 | - * @return PDFLib |
|
295 | - */ |
|
296 | - function get_pdflib() { return $this->_pdf; } |
|
297 | - |
|
298 | - /** |
|
299 | - * Add meta information to the PDF |
|
300 | - * |
|
301 | - * @param string $label label of the value (Creator, Producter, etc.) |
|
302 | - * @param string $value the text to set |
|
303 | - */ |
|
304 | - function add_info($label, $value) { |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Returns the PDFLib instance |
|
293 | + * |
|
294 | + * @return PDFLib |
|
295 | + */ |
|
296 | + function get_pdflib() { return $this->_pdf; } |
|
297 | + |
|
298 | + /** |
|
299 | + * Add meta information to the PDF |
|
300 | + * |
|
301 | + * @param string $label label of the value (Creator, Producter, etc.) |
|
302 | + * @param string $value the text to set |
|
303 | + */ |
|
304 | + function add_info($label, $value) { |
|
305 | 305 | $this->_pdf->set_info($label, $value); |
306 | - } |
|
306 | + } |
|
307 | 307 | |
308 | - /** |
|
309 | - * Opens a new 'object' (template in PDFLib-speak) |
|
310 | - * |
|
311 | - * While an object is open, all drawing actions are recorded to the |
|
312 | - * object instead of being drawn on the current page. Objects can |
|
313 | - * be added later to a specific page or to several pages. |
|
314 | - * |
|
315 | - * The return value is an integer ID for the new object. |
|
316 | - * |
|
317 | - * @see PDFLib_Adapter::close_object() |
|
318 | - * @see PDFLib_Adapter::add_object() |
|
319 | - * |
|
320 | - * @return int |
|
321 | - */ |
|
322 | - function open_object() { |
|
308 | + /** |
|
309 | + * Opens a new 'object' (template in PDFLib-speak) |
|
310 | + * |
|
311 | + * While an object is open, all drawing actions are recorded to the |
|
312 | + * object instead of being drawn on the current page. Objects can |
|
313 | + * be added later to a specific page or to several pages. |
|
314 | + * |
|
315 | + * The return value is an integer ID for the new object. |
|
316 | + * |
|
317 | + * @see PDFLib_Adapter::close_object() |
|
318 | + * @see PDFLib_Adapter::add_object() |
|
319 | + * |
|
320 | + * @return int |
|
321 | + */ |
|
322 | + function open_object() { |
|
323 | 323 | $this->_pdf->suspend_page(""); |
324 | 324 | $ret = $this->_pdf->begin_template($this->_width, $this->_height); |
325 | 325 | $this->_pdf->save(); |
326 | 326 | $this->_objs[$ret] = array("start_page" => $this->_page_number); |
327 | 327 | return $ret; |
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Reopen an existing object (NOT IMPLEMENTED) |
|
332 | - * |
|
333 | - * PDFLib does not seem to support reopening templates. |
|
334 | - * |
|
335 | - * @param int $object the ID of a previously opened object |
|
336 | - */ |
|
337 | - function reopen_object($object) { |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Reopen an existing object (NOT IMPLEMENTED) |
|
332 | + * |
|
333 | + * PDFLib does not seem to support reopening templates. |
|
334 | + * |
|
335 | + * @param int $object the ID of a previously opened object |
|
336 | + */ |
|
337 | + function reopen_object($object) { |
|
338 | 338 | throw new DOMPDF_Exception("PDFLib does not support reopening objects."); |
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Close the current template |
|
343 | - * |
|
344 | - * @see PDFLib_Adapter::open_object() |
|
345 | - */ |
|
346 | - function close_object() { |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Close the current template |
|
343 | + * |
|
344 | + * @see PDFLib_Adapter::open_object() |
|
345 | + */ |
|
346 | + function close_object() { |
|
347 | 347 | $this->_pdf->restore(); |
348 | 348 | $this->_pdf->end_template(); |
349 | 349 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Adds the specified object to the document |
|
354 | - * |
|
355 | - * $where can be one of: |
|
356 | - * - 'add' add to current page only |
|
357 | - * - 'all' add to every page from the current one onwards |
|
358 | - * - 'odd' add to all odd numbered pages from now on |
|
359 | - * - 'even' add to all even numbered pages from now on |
|
360 | - * - 'next' add the object to the next page only |
|
361 | - * - 'nextodd' add to all odd numbered pages from the next one |
|
362 | - * - 'nexteven' add to all even numbered pages from the next one |
|
363 | - * |
|
364 | - * @param int $object the object handle returned by open_object() |
|
365 | - * @param string $where |
|
366 | - */ |
|
367 | - function add_object($object, $where = 'all') { |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Adds the specified object to the document |
|
354 | + * |
|
355 | + * $where can be one of: |
|
356 | + * - 'add' add to current page only |
|
357 | + * - 'all' add to every page from the current one onwards |
|
358 | + * - 'odd' add to all odd numbered pages from now on |
|
359 | + * - 'even' add to all even numbered pages from now on |
|
360 | + * - 'next' add the object to the next page only |
|
361 | + * - 'nextodd' add to all odd numbered pages from the next one |
|
362 | + * - 'nexteven' add to all even numbered pages from the next one |
|
363 | + * |
|
364 | + * @param int $object the object handle returned by open_object() |
|
365 | + * @param string $where |
|
366 | + */ |
|
367 | + function add_object($object, $where = 'all') { |
|
368 | 368 | |
369 | 369 | if ( mb_strpos($where, "next") !== false ) { |
370 | - $this->_objs[$object]["start_page"]++; |
|
371 | - $where = str_replace("next", "", $where); |
|
372 | - if ( $where == "" ) |
|
370 | + $this->_objs[$object]["start_page"]++; |
|
371 | + $where = str_replace("next", "", $where); |
|
372 | + if ( $where == "" ) |
|
373 | 373 | $where = "add"; |
374 | 374 | } |
375 | 375 | |
376 | 376 | $this->_objs[$object]["where"] = $where; |
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Stops the specified template from appearing in the document. |
|
381 | - * |
|
382 | - * The object will stop being displayed on the page following the |
|
383 | - * current one. |
|
384 | - * |
|
385 | - * @param int $object |
|
386 | - */ |
|
387 | - function stop_object($object) { |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Stops the specified template from appearing in the document. |
|
381 | + * |
|
382 | + * The object will stop being displayed on the page following the |
|
383 | + * current one. |
|
384 | + * |
|
385 | + * @param int $object |
|
386 | + */ |
|
387 | + function stop_object($object) { |
|
388 | 388 | |
389 | 389 | if ( !isset($this->_objs[$object]) ) |
390 | - return; |
|
390 | + return; |
|
391 | 391 | |
392 | 392 | $start = $this->_objs[$object]["start_page"]; |
393 | 393 | $where = $this->_objs[$object]["where"]; |
@@ -397,74 +397,74 @@ discard block |
||
397 | 397 | (($this->_page_number % 2 == 0 && $where === "even") || |
398 | 398 | ($this->_page_number % 2 == 1 && $where === "odd") || |
399 | 399 | ($where === "all")) ) |
400 | - $this->_pdf->fit_image($object,0,0,""); |
|
400 | + $this->_pdf->fit_image($object,0,0,""); |
|
401 | 401 | |
402 | 402 | unset($this->_objs[$object]); |
403 | - } |
|
403 | + } |
|
404 | 404 | |
405 | - /** |
|
406 | - * Add all active objects to the current page |
|
407 | - */ |
|
408 | - protected function _place_objects() { |
|
405 | + /** |
|
406 | + * Add all active objects to the current page |
|
407 | + */ |
|
408 | + protected function _place_objects() { |
|
409 | 409 | |
410 | 410 | foreach ( $this->_objs as $obj => $props ) { |
411 | - $start = $props["start_page"]; |
|
412 | - $where = $props["where"]; |
|
411 | + $start = $props["start_page"]; |
|
412 | + $where = $props["where"]; |
|
413 | 413 | |
414 | - // Place the object on this page if required |
|
415 | - if ( $this->_page_number >= $start && |
|
414 | + // Place the object on this page if required |
|
415 | + if ( $this->_page_number >= $start && |
|
416 | 416 | (($this->_page_number % 2 == 0 && $where === "even") || |
417 | 417 | ($this->_page_number % 2 == 1 && $where === "odd") || |
418 | 418 | ($where === "all")) ) { |
419 | 419 | $this->_pdf->fit_image($obj,0,0,""); |
420 | - } |
|
420 | + } |
|
421 | 421 | } |
422 | 422 | |
423 | - } |
|
423 | + } |
|
424 | 424 | |
425 | - function get_width() { return $this->_width; } |
|
425 | + function get_width() { return $this->_width; } |
|
426 | 426 | |
427 | - function get_height() { return $this->_height; } |
|
427 | + function get_height() { return $this->_height; } |
|
428 | 428 | |
429 | - function get_page_number() { return $this->_page_number; } |
|
429 | + function get_page_number() { return $this->_page_number; } |
|
430 | 430 | |
431 | - function get_page_count() { return $this->_page_count; } |
|
431 | + function get_page_count() { return $this->_page_count; } |
|
432 | 432 | |
433 | - function set_page_number($num) { $this->_page_number = (int)$num; } |
|
433 | + function set_page_number($num) { $this->_page_number = (int)$num; } |
|
434 | 434 | |
435 | - function set_page_count($count) { $this->_page_count = (int)$count; } |
|
435 | + function set_page_count($count) { $this->_page_count = (int)$count; } |
|
436 | 436 | |
437 | 437 | |
438 | - /** |
|
439 | - * Sets the line style |
|
440 | - * |
|
441 | - * @param float width |
|
442 | - * @param string corner |
|
443 | - * @param string join |
|
444 | - * @param array dash |
|
445 | - */ |
|
446 | - protected function _set_line_style($width, $cap, $join, $dash) { |
|
438 | + /** |
|
439 | + * Sets the line style |
|
440 | + * |
|
441 | + * @param float width |
|
442 | + * @param string corner |
|
443 | + * @param string join |
|
444 | + * @param array dash |
|
445 | + */ |
|
446 | + protected function _set_line_style($width, $cap, $join, $dash) { |
|
447 | 447 | |
448 | 448 | if ( count($dash) == 1 ) |
449 | - $dash[] = $dash[0]; |
|
449 | + $dash[] = $dash[0]; |
|
450 | 450 | |
451 | 451 | if ( count($dash) > 1 ) |
452 | - $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
452 | + $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}"); |
|
453 | 453 | else |
454 | - $this->_pdf->setdash(0,0); |
|
454 | + $this->_pdf->setdash(0,0); |
|
455 | 455 | |
456 | 456 | switch ( $join ) { |
457 | 457 | case "miter": |
458 | 458 | $this->_pdf->setlinejoin(0); |
459 | - break; |
|
459 | + break; |
|
460 | 460 | |
461 | 461 | case "round": |
462 | 462 | $this->_pdf->setlinejoin(1); |
463 | - break; |
|
463 | + break; |
|
464 | 464 | |
465 | 465 | case "bevel": |
466 | 466 | $this->_pdf->setlinejoin(2); |
467 | - break; |
|
467 | + break; |
|
468 | 468 | |
469 | 469 | default: |
470 | 470 | break; |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | switch ( $cap ) { |
474 | 474 | case "butt": |
475 | 475 | $this->_pdf->setlinecap(0); |
476 | - break; |
|
476 | + break; |
|
477 | 477 | |
478 | 478 | case "round": |
479 | 479 | $this->_pdf->setlinecap(1); |
480 | - break; |
|
480 | + break; |
|
481 | 481 | |
482 | 482 | case "square": |
483 | 483 | $this->_pdf->setlinecap(2); |
484 | - break; |
|
484 | + break; |
|
485 | 485 | |
486 | 486 | default: |
487 | 487 | break; |
@@ -489,69 +489,69 @@ discard block |
||
489 | 489 | |
490 | 490 | $this->_pdf->setlinewidth($width); |
491 | 491 | |
492 | - } |
|
492 | + } |
|
493 | 493 | |
494 | - /** |
|
495 | - * Sets the line color |
|
496 | - * |
|
497 | - * @param array $color array(r,g,b) |
|
498 | - */ |
|
499 | - protected function _set_stroke_color($color) { |
|
494 | + /** |
|
495 | + * Sets the line color |
|
496 | + * |
|
497 | + * @param array $color array(r,g,b) |
|
498 | + */ |
|
499 | + protected function _set_stroke_color($color) { |
|
500 | 500 | if($this->_last_stroke_color == $color) |
501 | - return; |
|
501 | + return; |
|
502 | 502 | |
503 | 503 | $this->_last_stroke_color = $color; |
504 | 504 | |
505 | 505 | list($r,$g,$b) = $color; |
506 | 506 | $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0); |
507 | - } |
|
508 | - |
|
509 | - /** |
|
510 | - * Sets the fill color |
|
511 | - * |
|
512 | - * @param array $color array(r,g,b) |
|
513 | - */ |
|
514 | - protected function _set_fill_color($color) { |
|
507 | + } |
|
508 | + |
|
509 | + /** |
|
510 | + * Sets the fill color |
|
511 | + * |
|
512 | + * @param array $color array(r,g,b) |
|
513 | + */ |
|
514 | + protected function _set_fill_color($color) { |
|
515 | 515 | if($this->_last_fill_color == $color) |
516 | - return; |
|
516 | + return; |
|
517 | 517 | |
518 | 518 | $this->_last_fill_color = $color; |
519 | 519 | |
520 | 520 | list($r,$g,$b) = $color; |
521 | 521 | $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0); |
522 | - } |
|
522 | + } |
|
523 | 523 | |
524 | - /** |
|
525 | - * Loads a specific font and stores the corresponding descriptor. |
|
526 | - * |
|
527 | - * @param string $font |
|
528 | - * @return int the font descriptor for the font |
|
529 | - */ |
|
530 | - protected function _load_font($font, $encoding = null, $options = "") { |
|
524 | + /** |
|
525 | + * Loads a specific font and stores the corresponding descriptor. |
|
526 | + * |
|
527 | + * @param string $font |
|
528 | + * @return int the font descriptor for the font |
|
529 | + */ |
|
530 | + protected function _load_font($font, $encoding = null, $options = "") { |
|
531 | 531 | |
532 | 532 | // Check if the font is a native PDF font |
533 | 533 | // Embed non-native fonts |
534 | 534 | $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique", |
535 | - "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
536 | - "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
537 | - "symbol", "zapfdinbats"); |
|
535 | + "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique", |
|
536 | + "times-roman", "times-bold", "times-italic", "times-bolditalic", |
|
537 | + "symbol", "zapfdinbats"); |
|
538 | 538 | |
539 | 539 | $test = strtolower(basename($font)); |
540 | 540 | if ( in_array($test, $native_fonts) ) { |
541 | - $font = basename($font); |
|
541 | + $font = basename($font); |
|
542 | 542 | |
543 | 543 | } else { |
544 | - // Embed non-native fonts |
|
545 | - $options .= " embedding=true"; |
|
544 | + // Embed non-native fonts |
|
545 | + $options .= " embedding=true"; |
|
546 | 546 | } |
547 | 547 | |
548 | 548 | if ( is_null($encoding) ) { |
549 | 549 | |
550 | - // Unicode encoding is only available for the commerical |
|
551 | - // version of PDFlib and not PDFlib-Lite |
|
552 | - if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
550 | + // Unicode encoding is only available for the commerical |
|
551 | + // version of PDFlib and not PDFlib-Lite |
|
552 | + if ( defined("DOMPDF_PDFLIB_LICENSE") ) |
|
553 | 553 | $encoding = "unicode"; |
554 | - else |
|
554 | + else |
|
555 | 555 | $encoding = "auto"; |
556 | 556 | |
557 | 557 | } |
@@ -559,28 +559,28 @@ discard block |
||
559 | 559 | $key = $font .":". $encoding .":". $options; |
560 | 560 | |
561 | 561 | if ( isset($this->_fonts[$key]) ) |
562 | - return $this->_fonts[$key]; |
|
562 | + return $this->_fonts[$key]; |
|
563 | 563 | |
564 | 564 | else { |
565 | 565 | |
566 | - $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
567 | - return $this->_fonts[$key]; |
|
566 | + $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options); |
|
567 | + return $this->_fonts[$key]; |
|
568 | 568 | |
569 | 569 | } |
570 | 570 | |
571 | - } |
|
571 | + } |
|
572 | 572 | |
573 | - /** |
|
574 | - * Remaps y coords from 4th to 1st quadrant |
|
575 | - * |
|
576 | - * @param float $y |
|
577 | - * @return float |
|
578 | - */ |
|
579 | - protected function y($y) { return $this->_height - $y; } |
|
573 | + /** |
|
574 | + * Remaps y coords from 4th to 1st quadrant |
|
575 | + * |
|
576 | + * @param float $y |
|
577 | + * @return float |
|
578 | + */ |
|
579 | + protected function y($y) { return $this->_height - $y; } |
|
580 | 580 | |
581 | - //........................................................................ |
|
581 | + //........................................................................ |
|
582 | 582 | |
583 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
583 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
584 | 584 | $this->_set_line_style($width, "butt", "", $style); |
585 | 585 | $this->_set_stroke_color($color); |
586 | 586 | |
@@ -590,11 +590,11 @@ discard block |
||
590 | 590 | $this->_pdf->moveto($x1,$y1); |
591 | 591 | $this->_pdf->lineto($x2, $y2); |
592 | 592 | $this->_pdf->stroke(); |
593 | - } |
|
593 | + } |
|
594 | 594 | |
595 | - //........................................................................ |
|
595 | + //........................................................................ |
|
596 | 596 | |
597 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
597 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
598 | 598 | $this->_set_stroke_color($color); |
599 | 599 | $this->_set_line_style($width, "square", "miter", $style); |
600 | 600 | |
@@ -602,93 +602,93 @@ discard block |
||
602 | 602 | |
603 | 603 | $this->_pdf->rect($x1, $y1, $w, $h); |
604 | 604 | $this->_pdf->stroke(); |
605 | - } |
|
605 | + } |
|
606 | 606 | |
607 | - //........................................................................ |
|
607 | + //........................................................................ |
|
608 | 608 | |
609 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
609 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
610 | 610 | $this->_set_fill_color($color); |
611 | 611 | |
612 | 612 | $y1 = $this->y($y1) - $h; |
613 | 613 | |
614 | 614 | $this->_pdf->rect($x1, $y1, $w, $h); |
615 | 615 | $this->_pdf->fill(); |
616 | - } |
|
616 | + } |
|
617 | 617 | |
618 | - //........................................................................ |
|
618 | + //........................................................................ |
|
619 | 619 | |
620 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
620 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
621 | 621 | |
622 | 622 | $this->_set_fill_color($color); |
623 | 623 | $this->_set_stroke_color($color); |
624 | 624 | |
625 | 625 | if ( !$fill && isset($width) ) |
626 | - $this->_set_line_style($width, "square", "miter", $style); |
|
626 | + $this->_set_line_style($width, "square", "miter", $style); |
|
627 | 627 | |
628 | 628 | $y = $this->y(array_pop($points)); |
629 | 629 | $x = array_pop($points); |
630 | 630 | $this->_pdf->moveto($x,$y); |
631 | 631 | |
632 | 632 | while (count($points) > 1) { |
633 | - $y = $this->y(array_pop($points)); |
|
634 | - $x = array_pop($points); |
|
635 | - $this->_pdf->lineto($x,$y); |
|
633 | + $y = $this->y(array_pop($points)); |
|
634 | + $x = array_pop($points); |
|
635 | + $this->_pdf->lineto($x,$y); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | if ( $fill ) |
639 | - $this->_pdf->fill(); |
|
639 | + $this->_pdf->fill(); |
|
640 | 640 | else |
641 | - $this->_pdf->closepath_stroke(); |
|
642 | - } |
|
641 | + $this->_pdf->closepath_stroke(); |
|
642 | + } |
|
643 | 643 | |
644 | - //........................................................................ |
|
644 | + //........................................................................ |
|
645 | 645 | |
646 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
646 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
647 | 647 | |
648 | 648 | $this->_set_fill_color($color); |
649 | 649 | $this->_set_stroke_color($color); |
650 | 650 | |
651 | 651 | if ( !$fill && isset($width) ) |
652 | - $this->_set_line_style($width, "round", "round", $style); |
|
652 | + $this->_set_line_style($width, "round", "round", $style); |
|
653 | 653 | |
654 | 654 | $y = $this->y($y); |
655 | 655 | |
656 | 656 | $this->_pdf->circle($x, $y, $r); |
657 | 657 | |
658 | 658 | if ( $fill ) |
659 | - $this->_pdf->fill(); |
|
659 | + $this->_pdf->fill(); |
|
660 | 660 | else |
661 | - $this->_pdf->stroke(); |
|
661 | + $this->_pdf->stroke(); |
|
662 | 662 | |
663 | - } |
|
663 | + } |
|
664 | 664 | |
665 | - //........................................................................ |
|
665 | + //........................................................................ |
|
666 | 666 | |
667 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
667 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
668 | 668 | $w = (int)$w; |
669 | 669 | $h = (int)$h; |
670 | 670 | |
671 | 671 | $img_type = strtolower($img_type); |
672 | 672 | |
673 | 673 | if ( $img_type === "jpg" ) |
674 | - $img_type = "jpeg"; |
|
674 | + $img_type = "jpeg"; |
|
675 | 675 | |
676 | 676 | if ( isset($this->_imgs[$img_url]) ) |
677 | - $img = $this->_imgs[$img_url]; |
|
677 | + $img = $this->_imgs[$img_url]; |
|
678 | 678 | |
679 | 679 | else { |
680 | 680 | |
681 | - $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
681 | + $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, ""); |
|
682 | 682 | } |
683 | 683 | |
684 | 684 | $y = $this->y($y) - $h; |
685 | 685 | $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire'); |
686 | 686 | |
687 | - } |
|
687 | + } |
|
688 | 688 | |
689 | - //........................................................................ |
|
689 | + //........................................................................ |
|
690 | 690 | |
691 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
691 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
692 | 692 | $fh = $this->_load_font($font); |
693 | 693 | |
694 | 694 | $this->_pdf->setfont($fh, $size); |
@@ -701,72 +701,72 @@ discard block |
||
701 | 701 | |
702 | 702 | $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust"); |
703 | 703 | |
704 | - } |
|
704 | + } |
|
705 | 705 | |
706 | - //........................................................................ |
|
706 | + //........................................................................ |
|
707 | 707 | |
708 | - function javascript($code) { |
|
708 | + function javascript($code) { |
|
709 | 709 | // Not implemented |
710 | - } |
|
710 | + } |
|
711 | 711 | |
712 | - //........................................................................ |
|
712 | + //........................................................................ |
|
713 | 713 | |
714 | - /** |
|
715 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
716 | - * |
|
717 | - * @param string $anchorname The name of the named destination |
|
718 | - */ |
|
719 | - function add_named_dest($anchorname) { |
|
714 | + /** |
|
715 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
716 | + * |
|
717 | + * @param string $anchorname The name of the named destination |
|
718 | + */ |
|
719 | + function add_named_dest($anchorname) { |
|
720 | 720 | $this->_pdf->add_nameddest($anchorname,""); |
721 | - } |
|
721 | + } |
|
722 | 722 | |
723 | - //........................................................................ |
|
723 | + //........................................................................ |
|
724 | 724 | |
725 | - /** |
|
726 | - * Add a link to the pdf |
|
727 | - * |
|
728 | - * @param string $url The url to link to |
|
729 | - * @param float $x The x position of the link |
|
730 | - * @param float $y The y position of the link |
|
731 | - * @param float $width The width of the link |
|
732 | - * @param float $height The height of the link |
|
733 | - */ |
|
734 | - function add_link($url, $x, $y, $width, $height) { |
|
725 | + /** |
|
726 | + * Add a link to the pdf |
|
727 | + * |
|
728 | + * @param string $url The url to link to |
|
729 | + * @param float $x The x position of the link |
|
730 | + * @param float $y The y position of the link |
|
731 | + * @param float $width The width of the link |
|
732 | + * @param float $height The height of the link |
|
733 | + */ |
|
734 | + function add_link($url, $x, $y, $width, $height) { |
|
735 | 735 | |
736 | 736 | $y = $this->y($y) - $height; |
737 | 737 | if ( strpos($url, '#') === 0 ) { |
738 | - // Local link |
|
739 | - $name = substr($url,1); |
|
740 | - if ( $name ) |
|
738 | + // Local link |
|
739 | + $name = substr($url,1); |
|
740 | + if ( $name ) |
|
741 | 741 | $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0"); |
742 | 742 | } else { |
743 | 743 | |
744 | - list($proto, $host, $path, $file) = explode_url($url); |
|
744 | + list($proto, $host, $path, $file) = explode_url($url); |
|
745 | 745 | |
746 | - if ( $proto == "" || $proto === "file://" ) |
|
746 | + if ( $proto == "" || $proto === "file://" ) |
|
747 | 747 | return; // Local links are not allowed |
748 | - $url = build_url($proto, $host, $path, $file); |
|
749 | - $url = '{' . rawurldecode($url) . '}'; |
|
748 | + $url = build_url($proto, $host, $path, $file); |
|
749 | + $url = '{' . rawurldecode($url) . '}'; |
|
750 | 750 | |
751 | - $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
752 | - $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
751 | + $action = $this->_pdf->create_action("URI", "url=" . $url); |
|
752 | + $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0"); |
|
753 | + } |
|
753 | 754 | } |
754 | - } |
|
755 | 755 | |
756 | - //........................................................................ |
|
756 | + //........................................................................ |
|
757 | 757 | |
758 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
758 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
759 | 759 | $fh = $this->_load_font($font); |
760 | 760 | |
761 | 761 | // Determine the additional width due to extra spacing |
762 | 762 | $num_spaces = mb_substr_count($text," "); |
763 | 763 | $delta = $spacing * $num_spaces; |
764 | 764 | return $this->_pdf->stringwidth($text, $fh, $size) + $delta; |
765 | - } |
|
765 | + } |
|
766 | 766 | |
767 | - //........................................................................ |
|
767 | + //........................................................................ |
|
768 | 768 | |
769 | - function get_font_height($font, $size) { |
|
769 | + function get_font_height($font, $size) { |
|
770 | 770 | |
771 | 771 | $fh = $this->_load_font($font); |
772 | 772 | |
@@ -777,54 +777,54 @@ discard block |
||
777 | 777 | |
778 | 778 | // $desc is usually < 0, |
779 | 779 | return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc); |
780 | - } |
|
781 | - |
|
782 | - //........................................................................ |
|
783 | - |
|
784 | - /** |
|
785 | - * Writes text at the specified x and y coordinates on every page |
|
786 | - * |
|
787 | - * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
788 | - * with their current values. |
|
789 | - * |
|
790 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
791 | - * |
|
792 | - * @param float $x |
|
793 | - * @param float $y |
|
794 | - * @param string $text the text to write |
|
795 | - * @param string $font the font file to use |
|
796 | - * @param float $size the font size, in points |
|
797 | - * @param array $color |
|
798 | - * @param float $adjust word spacing adjustment |
|
799 | - * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
800 | - */ |
|
801 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
802 | - $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
780 | + } |
|
781 | + |
|
782 | + //........................................................................ |
|
783 | + |
|
784 | + /** |
|
785 | + * Writes text at the specified x and y coordinates on every page |
|
786 | + * |
|
787 | + * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced |
|
788 | + * with their current values. |
|
789 | + * |
|
790 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
791 | + * |
|
792 | + * @param float $x |
|
793 | + * @param float $y |
|
794 | + * @param string $text the text to write |
|
795 | + * @param string $font the font file to use |
|
796 | + * @param float $size the font size, in points |
|
797 | + * @param array $color |
|
798 | + * @param float $adjust word spacing adjustment |
|
799 | + * @param float $angle angle to write the text at, measured CW starting from the x-axis |
|
800 | + */ |
|
801 | + function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), |
|
802 | + $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) { |
|
803 | 803 | $_t = "text"; |
804 | 804 | $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle"); |
805 | - } |
|
806 | - |
|
807 | - //........................................................................ |
|
808 | - |
|
809 | - /** |
|
810 | - * Processes a script on every page |
|
811 | - * |
|
812 | - * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
813 | - * |
|
814 | - * This function can be used to add page numbers to all pages |
|
815 | - * after the first one, for example. |
|
816 | - * |
|
817 | - * @param string $code the script code |
|
818 | - * @param string $type the language type for script |
|
819 | - */ |
|
820 | - function page_script($code, $type = "text/php") { |
|
805 | + } |
|
806 | + |
|
807 | + //........................................................................ |
|
808 | + |
|
809 | + /** |
|
810 | + * Processes a script on every page |
|
811 | + * |
|
812 | + * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available. |
|
813 | + * |
|
814 | + * This function can be used to add page numbers to all pages |
|
815 | + * after the first one, for example. |
|
816 | + * |
|
817 | + * @param string $code the script code |
|
818 | + * @param string $type the language type for script |
|
819 | + */ |
|
820 | + function page_script($code, $type = "text/php") { |
|
821 | 821 | $_t = "script"; |
822 | 822 | $this->_page_text[] = compact("_t", "code", "type"); |
823 | - } |
|
823 | + } |
|
824 | 824 | |
825 | - //........................................................................ |
|
825 | + //........................................................................ |
|
826 | 826 | |
827 | - function new_page() { |
|
827 | + function new_page() { |
|
828 | 828 | |
829 | 829 | // Add objects to the current page |
830 | 830 | $this->_place_objects(); |
@@ -833,69 +833,69 @@ discard block |
||
833 | 833 | $this->_pdf->begin_page_ext($this->_width, $this->_height, ""); |
834 | 834 | $this->_page_number = ++$this->_page_count; |
835 | 835 | |
836 | - } |
|
836 | + } |
|
837 | 837 | |
838 | - //........................................................................ |
|
838 | + //........................................................................ |
|
839 | 839 | |
840 | - /** |
|
841 | - * Add text to each page after rendering is complete |
|
842 | - */ |
|
843 | - protected function _add_page_text() { |
|
840 | + /** |
|
841 | + * Add text to each page after rendering is complete |
|
842 | + */ |
|
843 | + protected function _add_page_text() { |
|
844 | 844 | |
845 | 845 | if ( !count($this->_page_text) ) |
846 | - return; |
|
846 | + return; |
|
847 | 847 | |
848 | 848 | $this->_pdf->suspend_page(""); |
849 | 849 | |
850 | 850 | for ($p = 1; $p <= $this->_page_count; $p++) { |
851 | - $this->_pdf->resume_page("pagenumber=$p"); |
|
851 | + $this->_pdf->resume_page("pagenumber=$p"); |
|
852 | 852 | |
853 | - foreach ($this->_page_text as $pt) { |
|
853 | + foreach ($this->_page_text as $pt) { |
|
854 | 854 | extract($pt); |
855 | 855 | |
856 | 856 | switch ($_t) { |
857 | 857 | |
858 | 858 | case "text": |
859 | 859 | $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), |
860 | - array($p, $this->_page_count), $text); |
|
861 | - $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | - break; |
|
860 | + array($p, $this->_page_count), $text); |
|
861 | + $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
|
862 | + break; |
|
863 | 863 | |
864 | 864 | case "script": |
865 | 865 | if (!$eval) { |
866 | 866 | $eval = new PHP_Evaluator($this); |
867 | - } |
|
868 | - $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | - break; |
|
867 | + } |
|
868 | + $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); |
|
869 | + break; |
|
870 | + } |
|
870 | 871 | } |
871 | - } |
|
872 | 872 | |
873 | - $this->_pdf->suspend_page(""); |
|
873 | + $this->_pdf->suspend_page(""); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | $this->_pdf->resume_page("pagenumber=".$this->_page_number); |
877 | - } |
|
877 | + } |
|
878 | 878 | |
879 | - //........................................................................ |
|
879 | + //........................................................................ |
|
880 | 880 | |
881 | - function stream($filename, $options = null) { |
|
881 | + function stream($filename, $options = null) { |
|
882 | 882 | |
883 | 883 | // Add page text |
884 | 884 | $this->_add_page_text(); |
885 | 885 | |
886 | 886 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
887 | - $this->_pdf->set_value("compress", 0); |
|
887 | + $this->_pdf->set_value("compress", 0); |
|
888 | 888 | else |
889 | - $this->_pdf->set_value("compress", 6); |
|
889 | + $this->_pdf->set_value("compress", 6); |
|
890 | 890 | |
891 | 891 | $this->_close(); |
892 | 892 | |
893 | 893 | if ( self::$IN_MEMORY ) { |
894 | - $data = $this->_pdf->get_buffer(); |
|
895 | - $size = strlen($data); |
|
894 | + $data = $this->_pdf->get_buffer(); |
|
895 | + $size = strlen($data); |
|
896 | 896 | |
897 | 897 | } else |
898 | - $size = filesize($this->_file); |
|
898 | + $size = filesize($this->_file); |
|
899 | 899 | |
900 | 900 | |
901 | 901 | $filename = str_replace(array("\n","'"),"", $filename); |
@@ -908,63 +908,63 @@ discard block |
||
908 | 908 | //header("Content-length: " . $size); |
909 | 909 | |
910 | 910 | if ( self::$IN_MEMORY ) |
911 | - echo $data; |
|
911 | + echo $data; |
|
912 | 912 | |
913 | 913 | else { |
914 | 914 | |
915 | - // Chunked readfile() |
|
916 | - $chunk = (1 << 21); // 2 MB |
|
917 | - $fh = fopen($this->_file, "rb"); |
|
918 | - if ( !$fh ) |
|
915 | + // Chunked readfile() |
|
916 | + $chunk = (1 << 21); // 2 MB |
|
917 | + $fh = fopen($this->_file, "rb"); |
|
918 | + if ( !$fh ) |
|
919 | 919 | throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file); |
920 | 920 | |
921 | - while ( !feof($fh) ) |
|
921 | + while ( !feof($fh) ) |
|
922 | 922 | echo fread($fh,$chunk); |
923 | - fclose($fh); |
|
923 | + fclose($fh); |
|
924 | 924 | |
925 | - //debugpng |
|
926 | - if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | - if (!DEBUGKEEPTEMP) |
|
925 | + //debugpng |
|
926 | + if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']'; |
|
927 | + if (!DEBUGKEEPTEMP) |
|
928 | 928 | |
929 | - unlink($this->_file); |
|
930 | - $this->_file = null; |
|
929 | + unlink($this->_file); |
|
930 | + $this->_file = null; |
|
931 | 931 | } |
932 | 932 | |
933 | 933 | flush(); |
934 | 934 | |
935 | 935 | |
936 | - } |
|
936 | + } |
|
937 | 937 | |
938 | - //........................................................................ |
|
938 | + //........................................................................ |
|
939 | 939 | |
940 | - function output($options = null) { |
|
940 | + function output($options = null) { |
|
941 | 941 | |
942 | 942 | // Add page text |
943 | 943 | $this->_add_page_text(); |
944 | 944 | |
945 | 945 | if ( isset($options["compress"]) && $options["compress"] != 1 ) |
946 | - $this->_pdf->set_value("compress", 0); |
|
946 | + $this->_pdf->set_value("compress", 0); |
|
947 | 947 | else |
948 | - $this->_pdf->set_value("compress", 6); |
|
948 | + $this->_pdf->set_value("compress", 6); |
|
949 | 949 | |
950 | 950 | $this->_close(); |
951 | 951 | |
952 | 952 | if ( self::$IN_MEMORY ) |
953 | - $data = $this->_pdf->get_buffer(); |
|
953 | + $data = $this->_pdf->get_buffer(); |
|
954 | 954 | |
955 | 955 | else { |
956 | - $data = file_get_contents($this->_file); |
|
956 | + $data = file_get_contents($this->_file); |
|
957 | 957 | |
958 | - //debugpng |
|
959 | - if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | - if (!DEBUGKEEPTEMP) |
|
958 | + //debugpng |
|
959 | + if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']'; |
|
960 | + if (!DEBUGKEEPTEMP) |
|
961 | 961 | |
962 | - unlink($this->_file); |
|
963 | - $this->_file = null; |
|
962 | + unlink($this->_file); |
|
963 | + $this->_file = null; |
|
964 | 964 | } |
965 | 965 | |
966 | 966 | return $data; |
967 | - } |
|
967 | + } |
|
968 | 968 | } |
969 | 969 | |
970 | 970 | // Workaround for idiotic limitation on statics... |
@@ -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: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -50,12 +49,12 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Cellmap { |
52 | 51 | |
53 | - /** |
|
54 | - * Border style weight lookup for collapsed border resolution. |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
52 | + /** |
|
53 | + * Border style weight lookup for collapsed border resolution. |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + static protected $_BORDER_STYLE_SCORE = array("inset" => 1, |
|
59 | 58 | "groove" => 2, |
60 | 59 | "outset" => 3, |
61 | 60 | "ridge" => 4, |
@@ -65,87 +64,87 @@ discard block |
||
65 | 64 | "double" => 8, |
66 | 65 | "none" => 0); |
67 | 66 | |
68 | - /** |
|
69 | - * The table object this cellmap is attached to. |
|
70 | - * |
|
71 | - * @var Table_Frame_Decorator |
|
72 | - */ |
|
73 | - protected $_table; |
|
74 | - |
|
75 | - /** |
|
76 | - * The total number of rows in the table |
|
77 | - * |
|
78 | - * @var int |
|
79 | - */ |
|
80 | - protected $_num_rows; |
|
81 | - |
|
82 | - /** |
|
83 | - * The total number of columns in the table |
|
84 | - * |
|
85 | - * @var int |
|
86 | - */ |
|
87 | - protected $_num_cols; |
|
88 | - |
|
89 | - /** |
|
90 | - * 2D array mapping <row,column> to frames |
|
91 | - * |
|
92 | - * @var array |
|
93 | - */ |
|
94 | - protected $_cells; |
|
95 | - |
|
96 | - /** |
|
97 | - * 1D array of column dimensions |
|
98 | - * |
|
99 | - * @var array |
|
100 | - */ |
|
101 | - protected $_columns; |
|
102 | - |
|
103 | - /** |
|
104 | - * 1D array of row dimensions |
|
105 | - * |
|
106 | - * @var array |
|
107 | - */ |
|
108 | - protected $_rows; |
|
109 | - |
|
110 | - /** |
|
111 | - * 2D array of border specs |
|
112 | - * |
|
113 | - * @var array |
|
114 | - */ |
|
115 | - protected $_borders; |
|
116 | - |
|
117 | - /** |
|
118 | - * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
119 | - * frame_id. |
|
120 | - * |
|
121 | - * @var array |
|
122 | - */ |
|
123 | - protected $_frames; |
|
124 | - |
|
125 | - /** |
|
126 | - * Current column when adding cells, 0-based |
|
127 | - * |
|
128 | - * @var int |
|
129 | - */ |
|
130 | - private $__col; |
|
131 | - |
|
132 | - /** |
|
133 | - * Current row when adding cells, 0-based |
|
134 | - * |
|
135 | - * @var int |
|
136 | - */ |
|
137 | - private $__row; |
|
138 | - |
|
139 | - //........................................................................ |
|
140 | - |
|
141 | - function __construct(Table_Frame_Decorator $table) { |
|
67 | + /** |
|
68 | + * The table object this cellmap is attached to. |
|
69 | + * |
|
70 | + * @var Table_Frame_Decorator |
|
71 | + */ |
|
72 | + protected $_table; |
|
73 | + |
|
74 | + /** |
|
75 | + * The total number of rows in the table |
|
76 | + * |
|
77 | + * @var int |
|
78 | + */ |
|
79 | + protected $_num_rows; |
|
80 | + |
|
81 | + /** |
|
82 | + * The total number of columns in the table |
|
83 | + * |
|
84 | + * @var int |
|
85 | + */ |
|
86 | + protected $_num_cols; |
|
87 | + |
|
88 | + /** |
|
89 | + * 2D array mapping <row,column> to frames |
|
90 | + * |
|
91 | + * @var array |
|
92 | + */ |
|
93 | + protected $_cells; |
|
94 | + |
|
95 | + /** |
|
96 | + * 1D array of column dimensions |
|
97 | + * |
|
98 | + * @var array |
|
99 | + */ |
|
100 | + protected $_columns; |
|
101 | + |
|
102 | + /** |
|
103 | + * 1D array of row dimensions |
|
104 | + * |
|
105 | + * @var array |
|
106 | + */ |
|
107 | + protected $_rows; |
|
108 | + |
|
109 | + /** |
|
110 | + * 2D array of border specs |
|
111 | + * |
|
112 | + * @var array |
|
113 | + */ |
|
114 | + protected $_borders; |
|
115 | + |
|
116 | + /** |
|
117 | + * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on |
|
118 | + * frame_id. |
|
119 | + * |
|
120 | + * @var array |
|
121 | + */ |
|
122 | + protected $_frames; |
|
123 | + |
|
124 | + /** |
|
125 | + * Current column when adding cells, 0-based |
|
126 | + * |
|
127 | + * @var int |
|
128 | + */ |
|
129 | + private $__col; |
|
130 | + |
|
131 | + /** |
|
132 | + * Current row when adding cells, 0-based |
|
133 | + * |
|
134 | + * @var int |
|
135 | + */ |
|
136 | + private $__row; |
|
137 | + |
|
138 | + //........................................................................ |
|
139 | + |
|
140 | + function __construct(Table_Frame_Decorator $table) { |
|
142 | 141 | $this->_table = $table; |
143 | 142 | $this->reset(); |
144 | - } |
|
143 | + } |
|
145 | 144 | |
146 | - //........................................................................ |
|
145 | + //........................................................................ |
|
147 | 146 | |
148 | - function reset() { |
|
147 | + function reset() { |
|
149 | 148 | $this->_num_rows = 0; |
150 | 149 | $this->_num_cols = 0; |
151 | 150 | |
@@ -158,54 +157,54 @@ discard block |
||
158 | 157 | $this->_borders = array(); |
159 | 158 | |
160 | 159 | $this->__col = $this->__row = 0; |
161 | - } |
|
160 | + } |
|
162 | 161 | |
163 | - //........................................................................ |
|
162 | + //........................................................................ |
|
164 | 163 | |
165 | - function get_num_rows() { return $this->_num_rows; } |
|
166 | - function get_num_cols() { return $this->_num_cols; } |
|
164 | + function get_num_rows() { return $this->_num_rows; } |
|
165 | + function get_num_cols() { return $this->_num_cols; } |
|
167 | 166 | |
168 | - function &get_columns() { |
|
167 | + function &get_columns() { |
|
169 | 168 | return $this->_columns; |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - function &get_column($i) { |
|
171 | + function &get_column($i) { |
|
173 | 172 | if ( !isset($this->_columns[$i]) ) |
174 | - $this->_columns[$i] = array("x" => 0, |
|
175 | - "min-width" => 0, |
|
176 | - "max-width" => 0, |
|
177 | - "used-width" => null, |
|
178 | - "absolute" => 0, |
|
179 | - "percent" => 0, |
|
180 | - "auto" => true); |
|
173 | + $this->_columns[$i] = array("x" => 0, |
|
174 | + "min-width" => 0, |
|
175 | + "max-width" => 0, |
|
176 | + "used-width" => null, |
|
177 | + "absolute" => 0, |
|
178 | + "percent" => 0, |
|
179 | + "auto" => true); |
|
181 | 180 | |
182 | 181 | return $this->_columns[$i]; |
183 | - } |
|
182 | + } |
|
184 | 183 | |
185 | - function &get_rows() { |
|
184 | + function &get_rows() { |
|
186 | 185 | return $this->_rows; |
187 | - } |
|
186 | + } |
|
188 | 187 | |
189 | - function &get_row($j) { |
|
188 | + function &get_row($j) { |
|
190 | 189 | if ( !isset($this->_rows[$j]) ) |
191 | - $this->_rows[$j] = array("y" => 0, |
|
192 | - "first-column" => 0, |
|
193 | - "height" => null); |
|
190 | + $this->_rows[$j] = array("y" => 0, |
|
191 | + "first-column" => 0, |
|
192 | + "height" => null); |
|
194 | 193 | return $this->_rows[$j]; |
195 | - } |
|
194 | + } |
|
196 | 195 | |
197 | - function get_border($i, $j, $h_v, $prop = null) { |
|
196 | + function get_border($i, $j, $h_v, $prop = null) { |
|
198 | 197 | if ( !isset($this->_borders[$i][$j][$h_v]) ) |
199 | - $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
200 | - "style" => "solid", |
|
201 | - "color" => "black"); |
|
198 | + $this->_borders[$i][$j][$h_v] = array("width" => 0, |
|
199 | + "style" => "solid", |
|
200 | + "color" => "black"); |
|
202 | 201 | if ( isset($prop) ) |
203 | - return $this->_borders[$i][$j][$h_v][$prop]; |
|
202 | + return $this->_borders[$i][$j][$h_v][$prop]; |
|
204 | 203 | |
205 | 204 | return $this->_borders[$i][$j][$h_v]; |
206 | - } |
|
205 | + } |
|
207 | 206 | |
208 | - function get_border_properties($i, $j) { |
|
207 | + function get_border_properties($i, $j) { |
|
209 | 208 | |
210 | 209 | $left = $this->get_border($i, $j, "vertical"); |
211 | 210 | $right = $this->get_border($i, $j+1, "vertical"); |
@@ -213,119 +212,119 @@ discard block |
||
213 | 212 | $bottom = $this->get_border($i+1, $j, "horizontal"); |
214 | 213 | |
215 | 214 | return compact("top", "bottom", "left", "right"); |
216 | - } |
|
215 | + } |
|
217 | 216 | |
218 | - //........................................................................ |
|
217 | + //........................................................................ |
|
219 | 218 | |
220 | - function get_spanned_cells($frame) { |
|
219 | + function get_spanned_cells($frame) { |
|
221 | 220 | $key = $frame->get_id(); |
222 | 221 | |
223 | 222 | if ( !isset($this->_frames[$key]) ) { |
224 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
223 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
225 | 224 | } |
226 | 225 | |
227 | 226 | return $this->_frames[$key]; |
228 | 227 | |
229 | - } |
|
228 | + } |
|
230 | 229 | |
231 | - function frame_exists_in_cellmap($frame) { |
|
230 | + function frame_exists_in_cellmap($frame) { |
|
232 | 231 | $key = $frame->get_id(); |
233 | 232 | return isset($this->_frames[$key]); |
234 | - } |
|
233 | + } |
|
235 | 234 | |
236 | - function get_frame_position($frame) { |
|
235 | + function get_frame_position($frame) { |
|
237 | 236 | global $_dompdf_warnings; |
238 | 237 | |
239 | 238 | $key = $frame->get_id(); |
240 | 239 | |
241 | 240 | if ( !isset($this->_frames[$key]) ) { |
242 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
241 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
243 | 242 | } |
244 | 243 | |
245 | 244 | $col = $this->_frames[$key]["columns"][0]; |
246 | 245 | $row = $this->_frames[$key]["rows"][0]; |
247 | 246 | |
248 | 247 | if ( !isset($this->_columns[$col])) { |
249 | - $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
250 | - $x = 0; |
|
248 | + $_dompdf_warnings[] = "Frame not found in columns array. Check your table layout for missing or extra TDs."; |
|
249 | + $x = 0; |
|
251 | 250 | } else |
252 | - $x = $this->_columns[$col]["x"]; |
|
251 | + $x = $this->_columns[$col]["x"]; |
|
253 | 252 | |
254 | 253 | if ( !isset($this->_rows[$row])) { |
255 | - $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
256 | - $y = 0; |
|
254 | + $_dompdf_warnings[] = "Frame not found in row array. Check your table layout for missing or extra TDs."; |
|
255 | + $y = 0; |
|
257 | 256 | } else |
258 | - $y = $this->_rows[$row]["y"]; |
|
257 | + $y = $this->_rows[$row]["y"]; |
|
259 | 258 | |
260 | 259 | return array($x, $y, "x" => $x, "y" => $y); |
261 | - } |
|
260 | + } |
|
262 | 261 | |
263 | - function get_frame_width($frame) { |
|
262 | + function get_frame_width($frame) { |
|
264 | 263 | $key = $frame->get_id(); |
265 | 264 | |
266 | 265 | if ( !isset($this->_frames[$key]) ) { |
267 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
266 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | $cols = $this->_frames[$key]["columns"]; |
271 | 270 | $w = 0; |
272 | 271 | foreach ($cols as $i) |
273 | - $w += $this->_columns[$i]["used-width"]; |
|
272 | + $w += $this->_columns[$i]["used-width"]; |
|
274 | 273 | |
275 | 274 | return $w; |
276 | 275 | |
277 | - } |
|
276 | + } |
|
278 | 277 | |
279 | - function get_frame_height($frame) { |
|
278 | + function get_frame_height($frame) { |
|
280 | 279 | $key = $frame->get_id(); |
281 | 280 | |
282 | 281 | if ( !isset($this->_frames[$key]) ) |
283 | - throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
282 | + throw new DOMPDF_Internal_Exception("Frame not found in cellmap"); |
|
284 | 283 | |
285 | 284 | $rows = $this->_frames[$key]["rows"]; |
286 | 285 | $h = 0; |
287 | 286 | foreach ($rows as $i) { |
288 | - if ( !isset($this->_rows[$i]) ) { |
|
287 | + if ( !isset($this->_rows[$i]) ) { |
|
289 | 288 | throw new Exception("foo"); |
290 | - } |
|
291 | - $h += $this->_rows[$i]["height"]; |
|
289 | + } |
|
290 | + $h += $this->_rows[$i]["height"]; |
|
292 | 291 | } |
293 | 292 | return $h; |
294 | 293 | |
295 | - } |
|
294 | + } |
|
296 | 295 | |
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_column_width($j, $width) { |
|
299 | + function set_column_width($j, $width) { |
|
301 | 300 | $col =& $this->get_column($j); |
302 | 301 | $col["used-width"] = $width; |
303 | 302 | $next_col =& $this->get_column($j+1); |
304 | 303 | $next_col["x"] = $next_col["x"] + $width; |
305 | - } |
|
304 | + } |
|
306 | 305 | |
307 | - function set_row_height($i, $height) { |
|
306 | + function set_row_height($i, $height) { |
|
308 | 307 | $row =& $this->get_row($i); |
309 | 308 | if ( $height <= $row["height"] ) |
310 | - return; |
|
309 | + return; |
|
311 | 310 | |
312 | 311 | $row["height"] = $height; |
313 | 312 | $next_row =& $this->get_row($i+1); |
314 | 313 | $next_row["y"] = $row["y"] + $height; |
315 | 314 | |
316 | - } |
|
315 | + } |
|
317 | 316 | |
318 | - //........................................................................ |
|
317 | + //........................................................................ |
|
319 | 318 | |
320 | 319 | |
321 | - protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
320 | + protected function _resolve_border($i, $j, $h_v, $border_spec) { |
|
322 | 321 | $n_width = $border_spec["width"]; |
323 | 322 | $n_style = $border_spec["style"]; |
324 | 323 | $n_color = $border_spec["color"]; |
325 | 324 | |
326 | 325 | if ( !isset($this->_borders[$i][$j][$h_v]) ) { |
327 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
328 | - return $this->_borders[$i][$j][$h_v]["width"]; |
|
326 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
327 | + return $this->_borders[$i][$j][$h_v]["width"]; |
|
329 | 328 | } |
330 | 329 | |
331 | 330 | $o_width = $this->_borders[$i][$j][$h_v]["width"]; |
@@ -341,14 +340,14 @@ discard block |
||
341 | 340 | ($o_width == $n_width && |
342 | 341 | in_array($n_style, self::$_BORDER_STYLE_SCORE) && |
343 | 342 | self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) |
344 | - $this->_borders[$i][$j][$h_v] = $border_spec; |
|
343 | + $this->_borders[$i][$j][$h_v] = $border_spec; |
|
345 | 344 | |
346 | 345 | return $this->_borders[$i][$j][$h_v]["width"]; |
347 | - } |
|
346 | + } |
|
348 | 347 | |
349 | - //........................................................................ |
|
348 | + //........................................................................ |
|
350 | 349 | |
351 | - function add_frame(Frame $frame) { |
|
350 | + function add_frame(Frame $frame) { |
|
352 | 351 | |
353 | 352 | $style = $frame->get_style(); |
354 | 353 | $display = $style->display; |
@@ -361,39 +360,39 @@ discard block |
||
361 | 360 | $display == "inline-table" || |
362 | 361 | in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
363 | 362 | |
364 | - $start_row = $this->__row; |
|
365 | - foreach ( $frame->get_children() as $child ) |
|
363 | + $start_row = $this->__row; |
|
364 | + foreach ( $frame->get_children() as $child ) |
|
366 | 365 | $this->add_frame( $child ); |
367 | 366 | |
368 | - if ( $display == "table-row" ) |
|
367 | + if ( $display == "table-row" ) |
|
369 | 368 | $this->add_row(); |
370 | 369 | |
371 | - $num_rows = $this->__row - $start_row - 1; |
|
372 | - $key = $frame->get_id(); |
|
370 | + $num_rows = $this->__row - $start_row - 1; |
|
371 | + $key = $frame->get_id(); |
|
373 | 372 | |
374 | - // Row groups always span across the entire table |
|
375 | - $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
376 | - $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
377 | - $this->_frames[ $key ]["frame"] = $frame; |
|
373 | + // Row groups always span across the entire table |
|
374 | + $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1)); |
|
375 | + $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1)); |
|
376 | + $this->_frames[ $key ]["frame"] = $frame; |
|
378 | 377 | |
379 | - if ( $display != "table-row" && $collapse ) { |
|
378 | + if ( $display != "table-row" && $collapse ) { |
|
380 | 379 | |
381 | 380 | $bp = $style->get_border_properties(); |
382 | 381 | |
383 | 382 | // Resolve the borders |
384 | 383 | for ( $i = 0; $i < $num_rows+1; $i++) { |
385 | - $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
386 | - $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
384 | + $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]); |
|
385 | + $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]); |
|
387 | 386 | } |
388 | 387 | |
389 | 388 | for ( $j = 0; $j < $this->_num_cols; $j++) { |
390 | - $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
391 | - $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
389 | + $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]); |
|
390 | + $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]); |
|
391 | + } |
|
392 | 392 | } |
393 | - } |
|
394 | 393 | |
395 | 394 | |
396 | - return; |
|
395 | + return; |
|
397 | 396 | } |
398 | 397 | |
399 | 398 | // Determine where this cell is going |
@@ -401,13 +400,13 @@ discard block |
||
401 | 400 | $rowspan = $frame->get_node()->getAttribute("rowspan"); |
402 | 401 | |
403 | 402 | if ( !$colspan ) { |
404 | - $colspan = 1; |
|
405 | - $frame->get_node()->setAttribute("colspan",1); |
|
403 | + $colspan = 1; |
|
404 | + $frame->get_node()->setAttribute("colspan",1); |
|
406 | 405 | } |
407 | 406 | |
408 | 407 | if ( !$rowspan ) { |
409 | - $rowspan = 1; |
|
410 | - $frame->get_node()->setAttribute("rowspan",1); |
|
408 | + $rowspan = 1; |
|
409 | + $frame->get_node()->setAttribute("rowspan",1); |
|
411 | 410 | } |
412 | 411 | $key = $frame->get_id(); |
413 | 412 | |
@@ -420,60 +419,60 @@ discard block |
||
420 | 419 | // Find the next available column (fix by Ciro Mondueri) |
421 | 420 | $ac = $this->__col; |
422 | 421 | while ( isset($this->_cells[$this->__row][$ac]) ) |
423 | - $ac++; |
|
422 | + $ac++; |
|
424 | 423 | $this->__col = $ac; |
425 | 424 | |
426 | 425 | // Rows: |
427 | 426 | for ( $i = 0; $i < $rowspan; $i++ ) { |
428 | - $row = $this->__row + $i; |
|
427 | + $row = $this->__row + $i; |
|
429 | 428 | |
430 | - $this->_frames[ $key ]["rows"][] = $row; |
|
429 | + $this->_frames[ $key ]["rows"][] = $row; |
|
431 | 430 | |
432 | - for ( $j = 0; $j < $colspan; $j++) |
|
431 | + for ( $j = 0; $j < $colspan; $j++) |
|
433 | 432 | $this->_cells[$row][$this->__col + $j] = $frame; |
434 | 433 | |
435 | - if ( $collapse ) { |
|
434 | + if ( $collapse ) { |
|
436 | 435 | // Resolve vertical borders |
437 | 436 | $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"])); |
438 | 437 | $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"])); |
439 | - } |
|
438 | + } |
|
440 | 439 | } |
441 | 440 | |
442 | 441 | $max_top = $max_bottom = 0; |
443 | 442 | |
444 | 443 | // Columns: |
445 | 444 | for ( $j = 0; $j < $colspan; $j++ ) { |
446 | - $col = $this->__col + $j; |
|
447 | - $this->_frames[ $key ]["columns"][] = $col; |
|
445 | + $col = $this->__col + $j; |
|
446 | + $this->_frames[ $key ]["columns"][] = $col; |
|
448 | 447 | |
449 | - if ( $collapse ) { |
|
448 | + if ( $collapse ) { |
|
450 | 449 | // Resolve horizontal borders |
451 | 450 | $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"])); |
452 | 451 | $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"])); |
453 | - } |
|
452 | + } |
|
454 | 453 | } |
455 | 454 | |
456 | 455 | $this->_frames[ $key ]["frame"] = $frame; |
457 | 456 | |
458 | 457 | // Handle seperated border model |
459 | 458 | if ( !$collapse ) { |
460 | - list($h, $v) = $this->_table->get_style()->border_spacing; |
|
459 | + list($h, $v) = $this->_table->get_style()->border_spacing; |
|
461 | 460 | |
462 | - // Border spacing is effectively a margin between cells |
|
463 | - $v = $style->length_in_pt($v) / 2; |
|
464 | - $h = $style->length_in_pt($h) / 2; |
|
465 | - $style->margin = "$v $h"; |
|
461 | + // Border spacing is effectively a margin between cells |
|
462 | + $v = $style->length_in_pt($v) / 2; |
|
463 | + $h = $style->length_in_pt($h) / 2; |
|
464 | + $style->margin = "$v $h"; |
|
466 | 465 | |
467 | - // The additional 1/2 width gets added to the table proper |
|
466 | + // The additional 1/2 width gets added to the table proper |
|
468 | 467 | |
469 | 468 | } else { |
470 | 469 | |
471 | - // Drop the frame's actual border |
|
472 | - $style->border_left_width = $max_left / 2; |
|
473 | - $style->border_right_width = $max_right / 2; |
|
474 | - $style->border_top_width = $max_top / 2; |
|
475 | - $style->border_bottom_width = $max_bottom / 2; |
|
476 | - $style->margin = "none"; |
|
470 | + // Drop the frame's actual border |
|
471 | + $style->border_left_width = $max_left / 2; |
|
472 | + $style->border_right_width = $max_right / 2; |
|
473 | + $style->border_top_width = $max_top / 2; |
|
474 | + $style->border_bottom_width = $max_bottom / 2; |
|
475 | + $style->margin = "none"; |
|
477 | 476 | } |
478 | 477 | |
479 | 478 | // Resolve the frame's width |
@@ -482,60 +481,60 @@ discard block |
||
482 | 481 | $width = $style->width; |
483 | 482 | |
484 | 483 | if ( is_percent($width) ) { |
485 | - $var = "percent"; |
|
486 | - $val = (float)rtrim($width, "% ") / $colspan; |
|
484 | + $var = "percent"; |
|
485 | + $val = (float)rtrim($width, "% ") / $colspan; |
|
487 | 486 | |
488 | 487 | } else if ( $width !== "auto" ) { |
489 | - $var = "absolute"; |
|
490 | - $val = $style->length_in_pt($frame_min) / $colspan; |
|
488 | + $var = "absolute"; |
|
489 | + $val = $style->length_in_pt($frame_min) / $colspan; |
|
491 | 490 | } |
492 | 491 | |
493 | 492 | $min = 0; |
494 | 493 | $max = 0; |
495 | 494 | for ( $cs = 0; $cs < $colspan; $cs++ ) { |
496 | 495 | |
497 | - // Resolve the frame's width(s) with other cells |
|
498 | - $col =& $this->get_column( $this->__col + $cs ); |
|
496 | + // Resolve the frame's width(s) with other cells |
|
497 | + $col =& $this->get_column( $this->__col + $cs ); |
|
499 | 498 | |
500 | - // Note: $var is either 'percent' or 'absolute'. We compare the |
|
501 | - // requested percentage or absolute values with the existing widths |
|
502 | - // and adjust accordingly. |
|
503 | - if ( isset($var) && $val > $col[$var] ) { |
|
499 | + // Note: $var is either 'percent' or 'absolute'. We compare the |
|
500 | + // requested percentage or absolute values with the existing widths |
|
501 | + // and adjust accordingly. |
|
502 | + if ( isset($var) && $val > $col[$var] ) { |
|
504 | 503 | $col[$var] = $val; |
505 | 504 | $col["auto"] = false; |
506 | - } |
|
505 | + } |
|
507 | 506 | |
508 | - $min += $col["min-width"]; |
|
509 | - $max += $col["max-width"]; |
|
507 | + $min += $col["min-width"]; |
|
508 | + $max += $col["max-width"]; |
|
510 | 509 | } |
511 | 510 | |
512 | 511 | |
513 | 512 | if ( $frame_min > $min ) { |
514 | - // The frame needs more space. Expand each sub-column |
|
515 | - $inc = ($frame_min - $min) / $colspan; |
|
516 | - for ($c = 0; $c < $colspan; $c++) { |
|
513 | + // The frame needs more space. Expand each sub-column |
|
514 | + $inc = ($frame_min - $min) / $colspan; |
|
515 | + for ($c = 0; $c < $colspan; $c++) { |
|
517 | 516 | $col =& $this->get_column($this->__col + $c); |
518 | 517 | $col["min-width"] += $inc; |
519 | - } |
|
518 | + } |
|
520 | 519 | } |
521 | 520 | |
522 | 521 | if ( $frame_max > $max ) { |
523 | - $inc = ($frame_max - $max) / $colspan; |
|
524 | - for ($c = 0; $c < $colspan; $c++) { |
|
522 | + $inc = ($frame_max - $max) / $colspan; |
|
523 | + for ($c = 0; $c < $colspan; $c++) { |
|
525 | 524 | $col =& $this->get_column($this->__col + $c); |
526 | 525 | $col["max-width"] += $inc; |
527 | - } |
|
526 | + } |
|
528 | 527 | } |
529 | 528 | |
530 | 529 | $this->__col += $colspan; |
531 | 530 | if ( $this->__col > $this->_num_cols ) |
532 | - $this->_num_cols = $this->__col; |
|
531 | + $this->_num_cols = $this->__col; |
|
533 | 532 | |
534 | - } |
|
533 | + } |
|
535 | 534 | |
536 | - //........................................................................ |
|
535 | + //........................................................................ |
|
537 | 536 | |
538 | - function add_row() { |
|
537 | + function add_row() { |
|
539 | 538 | |
540 | 539 | $this->__row++; |
541 | 540 | $this->_num_rows++; |
@@ -543,24 +542,24 @@ discard block |
||
543 | 542 | // Find the next available column |
544 | 543 | $i = 0; |
545 | 544 | while ( isset($this->_cells[$this->__row][$i]) ) |
546 | - $i++; |
|
545 | + $i++; |
|
547 | 546 | |
548 | 547 | $this->__col = $i; |
549 | 548 | |
550 | - } |
|
549 | + } |
|
551 | 550 | |
552 | - //........................................................................ |
|
551 | + //........................................................................ |
|
553 | 552 | |
554 | - /** |
|
555 | - * Remove a row from the cellmap. |
|
556 | - * |
|
557 | - * @param Frame |
|
558 | - */ |
|
559 | - function remove_row(Frame $row) { |
|
553 | + /** |
|
554 | + * Remove a row from the cellmap. |
|
555 | + * |
|
556 | + * @param Frame |
|
557 | + */ |
|
558 | + function remove_row(Frame $row) { |
|
560 | 559 | |
561 | 560 | $key = $row->get_id(); |
562 | 561 | if ( !isset($this->_frames[$key]) ) |
563 | - return; // Presumably this row has alredy been removed |
|
562 | + return; // Presumably this row has alredy been removed |
|
564 | 563 | |
565 | 564 | $this->_row = $this->_num_rows--; |
566 | 565 | |
@@ -569,47 +568,47 @@ discard block |
||
569 | 568 | |
570 | 569 | // Remove all frames from this row |
571 | 570 | foreach ( $rows as $r ) { |
572 | - foreach ( $columns as $c ) { |
|
571 | + foreach ( $columns as $c ) { |
|
573 | 572 | if ( isset($this->_cells[$r][$c]) ) { |
574 | - $frame = $this->_cells[$r][$c]; |
|
575 | - unset($this->_frames[ $frame->get_id() ]); |
|
576 | - unset($this->_cells[$r][$c]); |
|
573 | + $frame = $this->_cells[$r][$c]; |
|
574 | + unset($this->_frames[ $frame->get_id() ]); |
|
575 | + unset($this->_cells[$r][$c]); |
|
576 | + } |
|
577 | 577 | } |
578 | - } |
|
579 | - unset($this->_rows[$r]); |
|
578 | + unset($this->_rows[$r]); |
|
580 | 579 | } |
581 | 580 | |
582 | 581 | unset($this->_frames[$key]); |
583 | 582 | |
584 | - } |
|
583 | + } |
|
585 | 584 | |
586 | - /** |
|
587 | - * Remove a row group from the cellmap. |
|
588 | - * |
|
589 | - * @param Frame $group The group to remove |
|
590 | - */ |
|
591 | - function remove_row_group(Frame $group) { |
|
585 | + /** |
|
586 | + * Remove a row group from the cellmap. |
|
587 | + * |
|
588 | + * @param Frame $group The group to remove |
|
589 | + */ |
|
590 | + function remove_row_group(Frame $group) { |
|
592 | 591 | |
593 | 592 | $key = $group->get_id(); |
594 | 593 | if ( !isset($this->_frames[$key]) ) |
595 | - return; // Presumably this row has alredy been removed |
|
594 | + return; // Presumably this row has alredy been removed |
|
596 | 595 | |
597 | 596 | $iter = $group->get_first_child(); |
598 | 597 | while ($iter) { |
599 | - $this->remove_row($iter); |
|
600 | - $iter = $iter->get_next_sibling(); |
|
598 | + $this->remove_row($iter); |
|
599 | + $iter = $iter->get_next_sibling(); |
|
601 | 600 | } |
602 | 601 | |
603 | 602 | unset($this->_frames[$key]); |
604 | - } |
|
603 | + } |
|
605 | 604 | |
606 | - /** |
|
607 | - * Update a row group after rows have been removed |
|
608 | - * |
|
609 | - * @param Frame $group The group to update |
|
610 | - * @param Frame $last_row The last row in the row group |
|
611 | - */ |
|
612 | - function update_row_group(Frame $group, Frame $last_row) { |
|
605 | + /** |
|
606 | + * Update a row group after rows have been removed |
|
607 | + * |
|
608 | + * @param Frame $group The group to update |
|
609 | + * @param Frame $last_row The last row in the row group |
|
610 | + */ |
|
611 | + function update_row_group(Frame $group, Frame $last_row) { |
|
613 | 612 | |
614 | 613 | $g_key = $group->get_id(); |
615 | 614 | $r_key = $last_row->get_id(); |
@@ -617,80 +616,80 @@ discard block |
||
617 | 616 | $r_rows = $this->_frames[$r_key]["rows"]; |
618 | 617 | $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) ); |
619 | 618 | |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | - //........................................................................ |
|
621 | + //........................................................................ |
|
623 | 622 | |
624 | - function assign_x_positions() { |
|
623 | + function assign_x_positions() { |
|
625 | 624 | // Pre-condition: widths must be resolved and assigned to columns and |
626 | 625 | // column[0]["x"] must be set. |
627 | 626 | |
628 | 627 | $x = $this->_columns[0]["x"]; |
629 | 628 | foreach ( array_keys($this->_columns) as $j ) { |
630 | - $this->_columns[$j]["x"] = $x; |
|
631 | - $x += $this->_columns[$j]["used-width"]; |
|
629 | + $this->_columns[$j]["x"] = $x; |
|
630 | + $x += $this->_columns[$j]["used-width"]; |
|
632 | 631 | |
633 | 632 | } |
634 | 633 | |
635 | - } |
|
634 | + } |
|
636 | 635 | |
637 | - function assign_frame_heights() { |
|
636 | + function assign_frame_heights() { |
|
638 | 637 | // Pre-condition: widths and heights of each column & row must be |
639 | 638 | // calcluated |
640 | 639 | |
641 | 640 | foreach ( $this->_frames as $arr ) { |
642 | - $frame = $arr["frame"]; |
|
641 | + $frame = $arr["frame"]; |
|
643 | 642 | |
644 | - $h = 0; |
|
645 | - foreach( $arr["rows"] as $row ) { |
|
643 | + $h = 0; |
|
644 | + foreach( $arr["rows"] as $row ) { |
|
646 | 645 | if ( !isset($this->_rows[$row]) ) |
647 | - // The row has been removed because of a page split, so skip it. |
|
648 | - continue; |
|
646 | + // The row has been removed because of a page split, so skip it. |
|
647 | + continue; |
|
649 | 648 | $h += $this->_rows[$row]["height"]; |
650 | - } |
|
649 | + } |
|
651 | 650 | |
652 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
651 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
653 | 652 | $frame->set_cell_height($h); |
654 | - else |
|
653 | + else |
|
655 | 654 | $frame->get_style()->height = $h; |
656 | 655 | } |
657 | 656 | |
658 | - } |
|
657 | + } |
|
659 | 658 | |
660 | - //........................................................................ |
|
659 | + //........................................................................ |
|
661 | 660 | |
662 | - /** |
|
663 | - * Re-adjust frame height if the table height is larger than its content |
|
664 | - */ |
|
665 | - function set_frame_heights($table_height, $content_height) { |
|
661 | + /** |
|
662 | + * Re-adjust frame height if the table height is larger than its content |
|
663 | + */ |
|
664 | + function set_frame_heights($table_height, $content_height) { |
|
666 | 665 | |
667 | 666 | |
668 | 667 | // Distribute the increased height proportionally amongst each row |
669 | 668 | foreach ( $this->_frames as $arr ) { |
670 | - $frame = $arr["frame"]; |
|
669 | + $frame = $arr["frame"]; |
|
671 | 670 | |
672 | - $h = 0; |
|
673 | - foreach ($arr["rows"] as $row ) { |
|
671 | + $h = 0; |
|
672 | + foreach ($arr["rows"] as $row ) { |
|
674 | 673 | if ( !isset($this->_rows[$row]) ) |
675 | - continue; |
|
674 | + continue; |
|
676 | 675 | |
677 | 676 | $h += $this->_rows[$row]["height"]; |
678 | - } |
|
677 | + } |
|
679 | 678 | |
680 | - $new_height = ($h / $content_height) * $table_height; |
|
679 | + $new_height = ($h / $content_height) * $table_height; |
|
681 | 680 | |
682 | - if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
681 | + if ( $frame instanceof Table_Cell_Frame_Decorator ) |
|
683 | 682 | $frame->set_cell_height($new_height); |
684 | - else |
|
683 | + else |
|
685 | 684 | $frame->get_style()->height = $new_height; |
686 | 685 | } |
687 | 686 | |
688 | - } |
|
687 | + } |
|
689 | 688 | |
690 | - //........................................................................ |
|
689 | + //........................................................................ |
|
691 | 690 | |
692 | - // Used for debugging: |
|
693 | - function __toString() { |
|
691 | + // Used for debugging: |
|
692 | + function __toString() { |
|
694 | 693 | $str = ""; |
695 | 694 | $str .= "Columns:<br/>"; |
696 | 695 | $str .= pre_r($this->_columns, true); |
@@ -700,14 +699,14 @@ discard block |
||
700 | 699 | $str .= "Frames:<br/>"; |
701 | 700 | $arr = array(); |
702 | 701 | foreach ( $this->_frames as $key => $val ) |
703 | - $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
702 | + $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]); |
|
704 | 703 | |
705 | 704 | $str .= pre_r($arr, true); |
706 | 705 | |
707 | 706 | if ( php_sapi_name() == "cli" ) |
708 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
707 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
709 | 708 | array("\n",chr(27)."[01;33m", chr(27)."[0m"), |
710 | 709 | $str)); |
711 | 710 | return $str; |
712 | - } |
|
711 | + } |
|
713 | 712 | } |
@@ -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.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -89,90 +88,90 @@ discard block |
||
89 | 88 | class DOMPDF { |
90 | 89 | |
91 | 90 | |
92 | - /** |
|
93 | - * DomDocument representing the HTML document |
|
94 | - * |
|
95 | - * @var DomDocument |
|
96 | - */ |
|
97 | - protected $_xml; |
|
98 | - |
|
99 | - /** |
|
100 | - * Frame_Tree derived from the DOM tree |
|
101 | - * |
|
102 | - * @var Frame_Tree |
|
103 | - */ |
|
104 | - protected $_tree; |
|
105 | - |
|
106 | - /** |
|
107 | - * Stylesheet for the document |
|
108 | - * |
|
109 | - * @var Stylesheet |
|
110 | - */ |
|
111 | - protected $_css; |
|
112 | - |
|
113 | - /** |
|
114 | - * Actual PDF renderer |
|
115 | - * |
|
116 | - * @var Canvas |
|
117 | - */ |
|
118 | - protected $_pdf; |
|
119 | - |
|
120 | - /** |
|
121 | - * Desired paper size ('letter', 'legal', 'A4', etc.) |
|
122 | - * |
|
123 | - * @var string |
|
124 | - */ |
|
125 | - protected $_paper_size; |
|
126 | - |
|
127 | - /** |
|
128 | - * Paper orientation ('portrait' or 'landscape') |
|
129 | - * |
|
130 | - * @var string |
|
131 | - */ |
|
132 | - protected $_paper_orientation; |
|
133 | - |
|
134 | - /** |
|
135 | - * Callbacks on new page and new element |
|
136 | - * |
|
137 | - * @var array |
|
138 | - */ |
|
139 | - protected $_callbacks; |
|
140 | - |
|
141 | - /** |
|
142 | - * Experimental caching capability |
|
143 | - * |
|
144 | - * @var string |
|
145 | - */ |
|
146 | - private $_cache_id; |
|
147 | - |
|
148 | - /** |
|
149 | - * Base hostname |
|
150 | - * |
|
151 | - * Used for relative paths/urls |
|
152 | - * @var string |
|
153 | - */ |
|
154 | - protected $_base_host; |
|
155 | - |
|
156 | - /** |
|
157 | - * Absolute base path |
|
158 | - * |
|
159 | - * Used for relative paths/urls |
|
160 | - * @var string |
|
161 | - */ |
|
162 | - protected $_base_path; |
|
163 | - |
|
164 | - /** |
|
165 | - * Protcol used to request file (file://, http://, etc) |
|
166 | - * |
|
167 | - * @var string |
|
168 | - */ |
|
169 | - protected $_protocol; |
|
170 | - |
|
171 | - |
|
172 | - /** |
|
173 | - * Class constructor |
|
174 | - */ |
|
175 | - function __construct() { |
|
91 | + /** |
|
92 | + * DomDocument representing the HTML document |
|
93 | + * |
|
94 | + * @var DomDocument |
|
95 | + */ |
|
96 | + protected $_xml; |
|
97 | + |
|
98 | + /** |
|
99 | + * Frame_Tree derived from the DOM tree |
|
100 | + * |
|
101 | + * @var Frame_Tree |
|
102 | + */ |
|
103 | + protected $_tree; |
|
104 | + |
|
105 | + /** |
|
106 | + * Stylesheet for the document |
|
107 | + * |
|
108 | + * @var Stylesheet |
|
109 | + */ |
|
110 | + protected $_css; |
|
111 | + |
|
112 | + /** |
|
113 | + * Actual PDF renderer |
|
114 | + * |
|
115 | + * @var Canvas |
|
116 | + */ |
|
117 | + protected $_pdf; |
|
118 | + |
|
119 | + /** |
|
120 | + * Desired paper size ('letter', 'legal', 'A4', etc.) |
|
121 | + * |
|
122 | + * @var string |
|
123 | + */ |
|
124 | + protected $_paper_size; |
|
125 | + |
|
126 | + /** |
|
127 | + * Paper orientation ('portrait' or 'landscape') |
|
128 | + * |
|
129 | + * @var string |
|
130 | + */ |
|
131 | + protected $_paper_orientation; |
|
132 | + |
|
133 | + /** |
|
134 | + * Callbacks on new page and new element |
|
135 | + * |
|
136 | + * @var array |
|
137 | + */ |
|
138 | + protected $_callbacks; |
|
139 | + |
|
140 | + /** |
|
141 | + * Experimental caching capability |
|
142 | + * |
|
143 | + * @var string |
|
144 | + */ |
|
145 | + private $_cache_id; |
|
146 | + |
|
147 | + /** |
|
148 | + * Base hostname |
|
149 | + * |
|
150 | + * Used for relative paths/urls |
|
151 | + * @var string |
|
152 | + */ |
|
153 | + protected $_base_host; |
|
154 | + |
|
155 | + /** |
|
156 | + * Absolute base path |
|
157 | + * |
|
158 | + * Used for relative paths/urls |
|
159 | + * @var string |
|
160 | + */ |
|
161 | + protected $_base_path; |
|
162 | + |
|
163 | + /** |
|
164 | + * Protcol used to request file (file://, http://, etc) |
|
165 | + * |
|
166 | + * @var string |
|
167 | + */ |
|
168 | + protected $_protocol; |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * Class constructor |
|
173 | + */ |
|
174 | + function __construct() { |
|
176 | 175 | $this->_messages = array(); |
177 | 176 | $this->_xml = new DOMDocument(); |
178 | 177 | $this->_xml->preserveWhiteSpace = true; |
@@ -186,203 +185,203 @@ discard block |
||
186 | 185 | $this->_base_path = ""; |
187 | 186 | $this->_callbacks = array(); |
188 | 187 | $this->_cache_id = null; |
189 | - } |
|
190 | - |
|
191 | - /** |
|
192 | - * Returns the underlying {@link Frame_Tree} object |
|
193 | - * |
|
194 | - * @return Frame_Tree |
|
195 | - */ |
|
196 | - function get_tree() { return $this->_tree; } |
|
197 | - |
|
198 | - //........................................................................ |
|
199 | - |
|
200 | - /** |
|
201 | - * Sets the protocol to use |
|
202 | - * |
|
203 | - * @param string $proto |
|
204 | - */ |
|
205 | - // FIXME: validate these |
|
206 | - function set_protocol($proto) { $this->_protocol = $proto; } |
|
207 | - |
|
208 | - /** |
|
209 | - * Sets the base hostname |
|
210 | - * |
|
211 | - * @param string $host |
|
212 | - */ |
|
213 | - function set_host($host) { $this->_base_host = $host; } |
|
214 | - |
|
215 | - /** |
|
216 | - * Sets the base path |
|
217 | - * |
|
218 | - * @param string $path |
|
219 | - */ |
|
220 | - function set_base_path($path) { $this->_base_path = $path; } |
|
221 | - |
|
222 | - /** |
|
223 | - * Returns the protocol in use |
|
224 | - * |
|
225 | - * @return string |
|
226 | - */ |
|
227 | - function get_protocol() { return $this->_protocol; } |
|
228 | - |
|
229 | - /** |
|
230 | - * Returns the base hostname |
|
231 | - * |
|
232 | - * @return string |
|
233 | - */ |
|
234 | - function get_host() { return $this->_base_host; } |
|
235 | - |
|
236 | - /** |
|
237 | - * Returns the base path |
|
238 | - * |
|
239 | - * @return string |
|
240 | - */ |
|
241 | - function get_base_path() { return $this->_base_path; } |
|
242 | - |
|
243 | - /** |
|
244 | - * Return the underlying Canvas instance (e.g. CPDF_Adapter, GD_Adapter) |
|
245 | - * |
|
246 | - * @return Canvas |
|
247 | - */ |
|
248 | - function get_canvas() { return $this->_pdf; } |
|
249 | - |
|
250 | - /** |
|
251 | - * Returns the callbacks array |
|
252 | - * |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - function get_callbacks() { return $this->_callbacks; } |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Returns the underlying {@link Frame_Tree} object |
|
192 | + * |
|
193 | + * @return Frame_Tree |
|
194 | + */ |
|
195 | + function get_tree() { return $this->_tree; } |
|
196 | + |
|
197 | + //........................................................................ |
|
198 | + |
|
199 | + /** |
|
200 | + * Sets the protocol to use |
|
201 | + * |
|
202 | + * @param string $proto |
|
203 | + */ |
|
204 | + // FIXME: validate these |
|
205 | + function set_protocol($proto) { $this->_protocol = $proto; } |
|
206 | + |
|
207 | + /** |
|
208 | + * Sets the base hostname |
|
209 | + * |
|
210 | + * @param string $host |
|
211 | + */ |
|
212 | + function set_host($host) { $this->_base_host = $host; } |
|
213 | + |
|
214 | + /** |
|
215 | + * Sets the base path |
|
216 | + * |
|
217 | + * @param string $path |
|
218 | + */ |
|
219 | + function set_base_path($path) { $this->_base_path = $path; } |
|
220 | + |
|
221 | + /** |
|
222 | + * Returns the protocol in use |
|
223 | + * |
|
224 | + * @return string |
|
225 | + */ |
|
226 | + function get_protocol() { return $this->_protocol; } |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the base hostname |
|
230 | + * |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + function get_host() { return $this->_base_host; } |
|
234 | + |
|
235 | + /** |
|
236 | + * Returns the base path |
|
237 | + * |
|
238 | + * @return string |
|
239 | + */ |
|
240 | + function get_base_path() { return $this->_base_path; } |
|
241 | + |
|
242 | + /** |
|
243 | + * Return the underlying Canvas instance (e.g. CPDF_Adapter, GD_Adapter) |
|
244 | + * |
|
245 | + * @return Canvas |
|
246 | + */ |
|
247 | + function get_canvas() { return $this->_pdf; } |
|
248 | + |
|
249 | + /** |
|
250 | + * Returns the callbacks array |
|
251 | + * |
|
252 | + * @return array |
|
253 | + */ |
|
254 | + function get_callbacks() { return $this->_callbacks; } |
|
256 | 255 | |
257 | - //........................................................................ |
|
258 | - |
|
259 | - /** |
|
260 | - * Loads an HTML file |
|
261 | - * |
|
262 | - * Parse errors are stored in the global array _dompdf_warnings. |
|
263 | - * |
|
264 | - * @param string $file a filename or url to load |
|
265 | - */ |
|
266 | - function load_html_file($file) { |
|
256 | + //........................................................................ |
|
257 | + |
|
258 | + /** |
|
259 | + * Loads an HTML file |
|
260 | + * |
|
261 | + * Parse errors are stored in the global array _dompdf_warnings. |
|
262 | + * |
|
263 | + * @param string $file a filename or url to load |
|
264 | + */ |
|
265 | + function load_html_file($file) { |
|
267 | 266 | // Store parsing warnings as messages (this is to prevent output to the |
268 | 267 | // browser if the html is ugly and the dom extension complains, |
269 | 268 | // preventing the pdf from being streamed.) |
270 | 269 | if ( !$this->_protocol && !$this->_base_host && !$this->_base_path ) |
271 | - list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file); |
|
270 | + list($this->_protocol, $this->_base_host, $this->_base_path) = explode_url($file); |
|
272 | 271 | |
273 | 272 | if ( !DOMPDF_ENABLE_REMOTE && |
274 | 273 | ($this->_protocol != "" && $this->_protocol !== "file://" ) ) |
275 | - throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false."); |
|
274 | + throw new DOMPDF_Exception("Remote file requested, but DOMPDF_ENABLE_REMOTE is false."); |
|
276 | 275 | |
277 | 276 | if ($this->_protocol == "" || $this->_protocol === "file://") { |
278 | 277 | |
279 | - $realfile = realpath($file); |
|
280 | - if ( !$file ) |
|
278 | + $realfile = realpath($file); |
|
279 | + if ( !$file ) |
|
281 | 280 | throw new DOMPDF_Exception("File '$file' not found."); |
282 | 281 | |
283 | - if ( strpos($realfile, DOMPDF_CHROOT) !== 0 ) |
|
282 | + if ( strpos($realfile, DOMPDF_CHROOT) !== 0 ) |
|
284 | 283 | throw new DOMPDF_Exception("Permission denied on $file."); |
285 | 284 | |
286 | - // Exclude dot files (e.g. .htaccess) |
|
287 | - if ( substr(basename($realfile),0,1) === "." ) |
|
285 | + // Exclude dot files (e.g. .htaccess) |
|
286 | + if ( substr(basename($realfile),0,1) === "." ) |
|
288 | 287 | throw new DOMPDF_Exception("Permission denied on $file."); |
289 | 288 | |
290 | - $file = $realfile; |
|
289 | + $file = $realfile; |
|
291 | 290 | } |
292 | 291 | |
293 | 292 | $this->load_html(file_get_contents($file)); |
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Loads an HTML string |
|
298 | - * |
|
299 | - * Parse errors are stored in the global array _dompdf_warnings. |
|
300 | - * |
|
301 | - * @param string $str HTML text to load |
|
302 | - */ |
|
303 | - function load_html($str) { |
|
293 | + } |
|
294 | + |
|
295 | + /** |
|
296 | + * Loads an HTML string |
|
297 | + * |
|
298 | + * Parse errors are stored in the global array _dompdf_warnings. |
|
299 | + * |
|
300 | + * @param string $str HTML text to load |
|
301 | + */ |
|
302 | + function load_html($str) { |
|
304 | 303 | // FIXME: Determine character encoding, switch to UTF8, update meta tag. Need better http/file stream encoding detection, currently relies on text or meta tag. |
305 | 304 | mb_detect_order('auto'); |
306 | 305 | if (mb_detect_encoding($str) != 'UTF-8') { |
307 | - if (mb_detect_encoding($str) == '') { |
|
306 | + if (mb_detect_encoding($str) == '') { |
|
308 | 307 | if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) { |
309 | - $encoding = strtoupper($matches[3]); |
|
308 | + $encoding = strtoupper($matches[3]); |
|
310 | 309 | } else { |
311 | - $encoding = 'UTF-8'; |
|
310 | + $encoding = 'UTF-8'; |
|
312 | 311 | } |
313 | - } else { |
|
312 | + } else { |
|
314 | 313 | if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s*?charset=([^\s"]+))?@i',$str,$matches)) { |
315 | - $encoding = strtoupper($matches[3]); |
|
314 | + $encoding = strtoupper($matches[3]); |
|
316 | 315 | } else { |
317 | - $encoding = 'auto'; |
|
316 | + $encoding = 'auto'; |
|
317 | + } |
|
318 | 318 | } |
319 | - } |
|
320 | - if ($encoding != 'UTF-8') { $str = mb_convert_encoding($str, 'UTF-8', $encoding); } |
|
321 | - if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',$str,$matches)) { |
|
319 | + if ($encoding != 'UTF-8') { $str = mb_convert_encoding($str, 'UTF-8', $encoding); } |
|
320 | + if (preg_match('@<meta\s+http-equiv="Content-Type"\s+content="([\w/]+)(;\s+charset=([^\s"]+))?@i',$str,$matches)) { |
|
322 | 321 | $str = preg_replace('/charset=([^\s"]+)/i','charset=UTF-8',$str); |
323 | - } else { |
|
322 | + } else { |
|
324 | 323 | $str = str_replace('<head>', '<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">', $str); |
325 | - } |
|
324 | + } |
|
326 | 325 | } |
327 | 326 | |
328 | 327 | // Parse embedded php, first-pass |
329 | 328 | if ( DOMPDF_ENABLE_PHP ) { |
330 | - ob_start(); |
|
331 | - eval("?" . ">$str"); |
|
332 | - $str = ob_get_contents(); |
|
333 | - ob_end_clean(); |
|
329 | + ob_start(); |
|
330 | + eval("?" . ">$str"); |
|
331 | + $str = ob_get_contents(); |
|
332 | + ob_end_clean(); |
|
334 | 333 | } |
335 | 334 | |
336 | 335 | // Store parsing warnings as messages |
337 | 336 | set_error_handler("record_warnings"); |
338 | 337 | $this->_xml->loadHTML($str); |
339 | 338 | restore_error_handler(); |
340 | - } |
|
339 | + } |
|
341 | 340 | |
342 | - /** |
|
343 | - * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to |
|
344 | - * the {@link Frame_Tree} |
|
345 | - */ |
|
346 | - protected function _process_html() { |
|
341 | + /** |
|
342 | + * Builds the {@link Frame_Tree}, loads any CSS and applies the styles to |
|
343 | + * the {@link Frame_Tree} |
|
344 | + */ |
|
345 | + protected function _process_html() { |
|
347 | 346 | $this->_tree->build_tree(); |
348 | 347 | |
349 | 348 | $this->_css->load_css_file(Stylesheet::DEFAULT_STYLESHEET); |
350 | 349 | |
351 | 350 | $acceptedmedia = Stylesheet::$ACCEPTED_GENERIC_MEDIA_TYPES; |
352 | 351 | if ( defined("DOMPDF_DEFAULT_MEDIA_TYPE") ) { |
353 | - $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
|
352 | + $acceptedmedia[] = DOMPDF_DEFAULT_MEDIA_TYPE; |
|
354 | 353 | } else { |
355 | - $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
|
354 | + $acceptedmedia[] = Stylesheet::$ACCEPTED_DEFAULT_MEDIA_TYPE; |
|
356 | 355 | } |
357 | 356 | |
358 | 357 | // load <link rel="STYLESHEET" ... /> tags |
359 | 358 | $links = $this->_xml->getElementsByTagName("link"); |
360 | 359 | foreach ($links as $link) { |
361 | - if ( mb_strtolower($link->getAttribute("rel")) === "stylesheet" || |
|
360 | + if ( mb_strtolower($link->getAttribute("rel")) === "stylesheet" || |
|
362 | 361 | mb_strtolower($link->getAttribute("type")) === "text/css" ) { |
363 | 362 | //Check if the css file is for an accepted media type |
364 | 363 | //media not given then always valid |
365 | 364 | $formedialist = preg_split("/[\s\n,]/", $link->getAttribute("media"),-1, PREG_SPLIT_NO_EMPTY); |
366 | 365 | if ( count($formedialist) > 0 ) { |
367 | - $accept = false; |
|
368 | - foreach ( $formedialist as $type ) { |
|
366 | + $accept = false; |
|
367 | + foreach ( $formedialist as $type ) { |
|
369 | 368 | if ( in_array(mb_strtolower(trim($type)), $acceptedmedia) ) { |
370 | - $accept = true; |
|
371 | - break; |
|
369 | + $accept = true; |
|
370 | + break; |
|
371 | + } |
|
372 | 372 | } |
373 | - } |
|
374 | - if (!$accept) { |
|
373 | + if (!$accept) { |
|
375 | 374 | //found at least one mediatype, but none of the accepted ones |
376 | 375 | //Skip this css file. |
377 | 376 | continue; |
378 | - } |
|
377 | + } |
|
379 | 378 | } |
380 | 379 | |
381 | 380 | $url = $link->getAttribute("href"); |
382 | 381 | $url = build_url($this->_protocol, $this->_base_host, $this->_base_path, $url); |
383 | 382 | |
384 | 383 | $this->_css->load_css_file($url); |
385 | - } |
|
384 | + } |
|
386 | 385 | |
387 | 386 | } |
388 | 387 | |
@@ -390,94 +389,94 @@ discard block |
||
390 | 389 | $styles = $this->_xml->getElementsByTagName("style"); |
391 | 390 | foreach ($styles as $style) { |
392 | 391 | |
393 | - // Accept all <style> tags by default (note this is contrary to W3C |
|
394 | - // HTML 4.0 spec: |
|
395 | - // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media |
|
396 | - // which states that the default media type is 'screen' |
|
397 | - if ( $style->hasAttributes() && |
|
392 | + // Accept all <style> tags by default (note this is contrary to W3C |
|
393 | + // HTML 4.0 spec: |
|
394 | + // http://www.w3.org/TR/REC-html40/present/styles.html#adef-media |
|
395 | + // which states that the default media type is 'screen' |
|
396 | + if ( $style->hasAttributes() && |
|
398 | 397 | ($media = $style->getAttribute("media")) && |
399 | 398 | !in_array($media, $acceptedmedia) ) |
400 | 399 | continue; |
401 | 400 | |
402 | - $css = ""; |
|
403 | - if ( $style->hasChildNodes() ) { |
|
401 | + $css = ""; |
|
402 | + if ( $style->hasChildNodes() ) { |
|
404 | 403 | |
405 | 404 | $child = $style->firstChild; |
406 | 405 | while ( $child ) { |
407 | - $css .= $child->nodeValue; // Handle <style><!-- blah --></style> |
|
408 | - $child = $child->nextSibling; |
|
406 | + $css .= $child->nodeValue; // Handle <style><!-- blah --></style> |
|
407 | + $child = $child->nextSibling; |
|
409 | 408 | } |
410 | 409 | |
411 | - } else |
|
410 | + } else |
|
412 | 411 | $css = $style->nodeValue; |
413 | 412 | |
414 | - // Set the base path of the Stylesheet to that of the file being processed |
|
415 | - $this->_css->set_protocol($this->_protocol); |
|
416 | - $this->_css->set_host($this->_base_host); |
|
417 | - $this->_css->set_base_path($this->_base_path); |
|
413 | + // Set the base path of the Stylesheet to that of the file being processed |
|
414 | + $this->_css->set_protocol($this->_protocol); |
|
415 | + $this->_css->set_host($this->_base_host); |
|
416 | + $this->_css->set_base_path($this->_base_path); |
|
418 | 417 | |
419 | - $this->_css->load_css($css); |
|
418 | + $this->_css->load_css($css); |
|
420 | 419 | } |
421 | 420 | |
422 | - } |
|
421 | + } |
|
423 | 422 | |
424 | - //........................................................................ |
|
423 | + //........................................................................ |
|
425 | 424 | |
426 | - /** |
|
427 | - * Sets the paper size & orientation |
|
428 | - * |
|
429 | - * @param string $size 'letter', 'legal', 'A4', etc. {@link CPDF_Adapter::$PAPER_SIZES} |
|
430 | - * @param string $orientation 'portrait' or 'landscape' |
|
431 | - */ |
|
432 | - function set_paper($size, $orientation = "portrait") { |
|
425 | + /** |
|
426 | + * Sets the paper size & orientation |
|
427 | + * |
|
428 | + * @param string $size 'letter', 'legal', 'A4', etc. {@link CPDF_Adapter::$PAPER_SIZES} |
|
429 | + * @param string $orientation 'portrait' or 'landscape' |
|
430 | + */ |
|
431 | + function set_paper($size, $orientation = "portrait") { |
|
433 | 432 | $this->_paper_size = $size; |
434 | 433 | $this->_paper_orientation = $orientation; |
435 | - } |
|
434 | + } |
|
436 | 435 | |
437 | - //........................................................................ |
|
436 | + //........................................................................ |
|
438 | 437 | |
439 | - /** |
|
440 | - * Enable experimental caching capability |
|
441 | - * @access private |
|
442 | - */ |
|
443 | - function enable_caching($cache_id) { |
|
438 | + /** |
|
439 | + * Enable experimental caching capability |
|
440 | + * @access private |
|
441 | + */ |
|
442 | + function enable_caching($cache_id) { |
|
444 | 443 | $this->_cache_id = $cache_id; |
445 | - } |
|
446 | - |
|
447 | - //........................................................................ |
|
448 | - |
|
449 | - /** |
|
450 | - * Sets callbacks for events like rendering of pages and elements. |
|
451 | - * The callbacks array contains arrays with 'event' set to 'begin_page', |
|
452 | - * 'end_page', 'begin_frame', or 'end_frame' and 'f' set to a function or |
|
453 | - * object plus method to be called. |
|
454 | - * |
|
455 | - * The function 'f' must take an array as argument, which contains info |
|
456 | - * about the event. |
|
457 | - * |
|
458 | - * @param array $callbacks the set of callbacks to set |
|
459 | - */ |
|
460 | - function set_callbacks($callbacks) { |
|
444 | + } |
|
445 | + |
|
446 | + //........................................................................ |
|
447 | + |
|
448 | + /** |
|
449 | + * Sets callbacks for events like rendering of pages and elements. |
|
450 | + * The callbacks array contains arrays with 'event' set to 'begin_page', |
|
451 | + * 'end_page', 'begin_frame', or 'end_frame' and 'f' set to a function or |
|
452 | + * object plus method to be called. |
|
453 | + * |
|
454 | + * The function 'f' must take an array as argument, which contains info |
|
455 | + * about the event. |
|
456 | + * |
|
457 | + * @param array $callbacks the set of callbacks to set |
|
458 | + */ |
|
459 | + function set_callbacks($callbacks) { |
|
461 | 460 | if (is_array($callbacks)) { |
462 | - $this->_callbacks = array(); |
|
463 | - foreach ($callbacks as $c) { |
|
461 | + $this->_callbacks = array(); |
|
462 | + foreach ($callbacks as $c) { |
|
464 | 463 | if (is_array($c) && isset($c['event']) && isset($c['f'])) { |
465 | - $event = $c['event']; |
|
466 | - $f = $c['f']; |
|
467 | - if (is_callable($f) && is_string($event)) { |
|
464 | + $event = $c['event']; |
|
465 | + $f = $c['f']; |
|
466 | + if (is_callable($f) && is_string($event)) { |
|
468 | 467 | $this->_callbacks[$event][] = $f; |
469 | - } |
|
468 | + } |
|
470 | 469 | } |
471 | - } |
|
470 | + } |
|
471 | + } |
|
472 | 472 | } |
473 | - } |
|
474 | 473 | |
475 | - //........................................................................ |
|
474 | + //........................................................................ |
|
476 | 475 | |
477 | - /** |
|
478 | - * Renders the HTML to PDF |
|
479 | - */ |
|
480 | - function render() { |
|
476 | + /** |
|
477 | + * Renders the HTML to PDF |
|
478 | + */ |
|
479 | + function render() { |
|
481 | 480 | |
482 | 481 | //enable_mem_profile(); |
483 | 482 | |
@@ -488,19 +487,19 @@ discard block |
||
488 | 487 | $root = null; |
489 | 488 | |
490 | 489 | foreach ($this->_tree->get_frames() as $frame) { |
491 | - // Set up the root frame |
|
490 | + // Set up the root frame |
|
492 | 491 | |
493 | - if ( is_null($root) ) { |
|
492 | + if ( is_null($root) ) { |
|
494 | 493 | $root = Frame_Factory::decorate_root( $this->_tree->get_root(), $this ); |
495 | 494 | continue; |
496 | - } |
|
495 | + } |
|
497 | 496 | |
498 | - // Create the appropriate decorators, reflowers & positioners. |
|
499 | - $deco = Frame_Factory::decorate_frame($frame, $this); |
|
500 | - $deco->set_root($root); |
|
497 | + // Create the appropriate decorators, reflowers & positioners. |
|
498 | + $deco = Frame_Factory::decorate_frame($frame, $this); |
|
499 | + $deco->set_root($root); |
|
501 | 500 | |
502 | - // FIXME: handle generated content |
|
503 | - if ( $frame->get_style()->display === "list-item" ) { |
|
501 | + // FIXME: handle generated content |
|
502 | + if ( $frame->get_style()->display === "list-item" ) { |
|
504 | 503 | |
505 | 504 | // Insert a list-bullet frame |
506 | 505 | $node = $this->_xml->createElement("bullet"); // arbitrary choice |
@@ -512,7 +511,7 @@ discard block |
||
512 | 511 | $b_f->set_style($style); |
513 | 512 | |
514 | 513 | $deco->prepend_child( Frame_Factory::decorate_frame($b_f, $this) ); |
515 | - } |
|
514 | + } |
|
516 | 515 | |
517 | 516 | } |
518 | 517 | |
@@ -529,83 +528,83 @@ discard block |
||
529 | 528 | |
530 | 529 | global $_dompdf_warnings, $_dompdf_show_warnings; |
531 | 530 | if ( $_dompdf_show_warnings ) { |
532 | - echo '<b>DOMPDF Warnings</b><br><pre>'; |
|
533 | - foreach ($_dompdf_warnings as $msg) |
|
531 | + echo '<b>DOMPDF Warnings</b><br><pre>'; |
|
532 | + foreach ($_dompdf_warnings as $msg) |
|
534 | 533 | echo $msg . "\n"; |
535 | - echo $this->get_canvas()->get_cpdf()->messages; |
|
536 | - echo '</pre>'; |
|
537 | - flush(); |
|
534 | + echo $this->get_canvas()->get_cpdf()->messages; |
|
535 | + echo '</pre>'; |
|
536 | + flush(); |
|
537 | + } |
|
538 | 538 | } |
539 | - } |
|
540 | 539 | |
541 | - //........................................................................ |
|
540 | + //........................................................................ |
|
542 | 541 | |
543 | - /** |
|
544 | - * Add meta information to the PDF after rendering |
|
545 | - */ |
|
546 | - function add_info($label, $value) { |
|
542 | + /** |
|
543 | + * Add meta information to the PDF after rendering |
|
544 | + */ |
|
545 | + function add_info($label, $value) { |
|
547 | 546 | if (!is_null($this->_pdf)) |
548 | - $this->_pdf->add_info($label, $value); |
|
549 | - } |
|
547 | + $this->_pdf->add_info($label, $value); |
|
548 | + } |
|
550 | 549 | |
551 | - //........................................................................ |
|
552 | - |
|
553 | - /** |
|
554 | - * Streams the PDF to the client |
|
555 | - * |
|
556 | - * The file will open a download dialog by default. The options |
|
557 | - * parameter controls the output. Accepted options are: |
|
558 | - * |
|
559 | - * 'Accept-Ranges' => 1 or 0 - if this is not set to 1, then this |
|
560 | - * header is not included, off by default this header seems to |
|
561 | - * have caused some problems despite the fact that it is supposed |
|
562 | - * to solve them, so I am leaving it off by default. |
|
563 | - * |
|
564 | - * 'compress' = > 1 or 0 - apply content stream compression, this is |
|
565 | - * on (1) by default |
|
566 | - * |
|
567 | - * 'Attachment' => 1 or 0 - if 1, force the browser to open a |
|
568 | - * download dialog, on (1) by default |
|
569 | - * |
|
570 | - * @param string $filename the name of the streamed file |
|
571 | - * @param array $options header options (see above) |
|
572 | - */ |
|
573 | - function stream($filename, $options = null) { |
|
550 | + //........................................................................ |
|
551 | + |
|
552 | + /** |
|
553 | + * Streams the PDF to the client |
|
554 | + * |
|
555 | + * The file will open a download dialog by default. The options |
|
556 | + * parameter controls the output. Accepted options are: |
|
557 | + * |
|
558 | + * 'Accept-Ranges' => 1 or 0 - if this is not set to 1, then this |
|
559 | + * header is not included, off by default this header seems to |
|
560 | + * have caused some problems despite the fact that it is supposed |
|
561 | + * to solve them, so I am leaving it off by default. |
|
562 | + * |
|
563 | + * 'compress' = > 1 or 0 - apply content stream compression, this is |
|
564 | + * on (1) by default |
|
565 | + * |
|
566 | + * 'Attachment' => 1 or 0 - if 1, force the browser to open a |
|
567 | + * download dialog, on (1) by default |
|
568 | + * |
|
569 | + * @param string $filename the name of the streamed file |
|
570 | + * @param array $options header options (see above) |
|
571 | + */ |
|
572 | + function stream($filename, $options = null) { |
|
574 | 573 | if (!is_null($this->_pdf)) |
575 | - $this->_pdf->stream($filename, $options); |
|
576 | - } |
|
577 | - |
|
578 | - /** |
|
579 | - * Returns the PDF as a string |
|
580 | - * |
|
581 | - * The file will open a download dialog by default. The options |
|
582 | - * parameter controls the output. Accepted options are: |
|
583 | - * |
|
584 | - * |
|
585 | - * 'compress' = > 1 or 0 - apply content stream compression, this is |
|
586 | - * on (1) by default |
|
587 | - * |
|
588 | - * |
|
589 | - * @param array $options options (see above) |
|
590 | - * @return string |
|
591 | - */ |
|
592 | - function output($options = null) { |
|
574 | + $this->_pdf->stream($filename, $options); |
|
575 | + } |
|
576 | + |
|
577 | + /** |
|
578 | + * Returns the PDF as a string |
|
579 | + * |
|
580 | + * The file will open a download dialog by default. The options |
|
581 | + * parameter controls the output. Accepted options are: |
|
582 | + * |
|
583 | + * |
|
584 | + * 'compress' = > 1 or 0 - apply content stream compression, this is |
|
585 | + * on (1) by default |
|
586 | + * |
|
587 | + * |
|
588 | + * @param array $options options (see above) |
|
589 | + * @return string |
|
590 | + */ |
|
591 | + function output($options = null) { |
|
593 | 592 | |
594 | 593 | if ( is_null($this->_pdf) ) |
595 | - return null; |
|
594 | + return null; |
|
596 | 595 | |
597 | 596 | return $this->_pdf->output( $options ); |
598 | - } |
|
597 | + } |
|
599 | 598 | |
600 | 599 | |
601 | - /** |
|
602 | - * Returns the underlying HTML document as a string |
|
603 | - * |
|
604 | - * @return string |
|
605 | - */ |
|
606 | - function output_html() { |
|
600 | + /** |
|
601 | + * Returns the underlying HTML document as a string |
|
602 | + * |
|
603 | + * @return string |
|
604 | + */ |
|
605 | + function output_html() { |
|
607 | 606 | return $this->_xml->saveHTML(); |
608 | - } |
|
609 | - //........................................................................ |
|
607 | + } |
|
608 | + //........................................................................ |
|
610 | 609 | |
611 | 610 | } |
@@ -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: null_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,8 +46,8 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Null_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 | - function reflow() { return; } |
|
51 | + function reflow() { return; } |
|
53 | 52 | |
54 | 53 | } |
@@ -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: cached_pdf_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -53,90 +52,90 @@ discard block |
||
53 | 52 | * @package dompdf |
54 | 53 | */ |
55 | 54 | class Cached_PDF_Decorator extends CPDF_Adapter implements Canvas { |
56 | - protected $_pdf; |
|
57 | - protected $_cache_id; |
|
58 | - protected $_current_page_id; |
|
59 | - protected $_fonts; // fonts used in this document |
|
55 | + protected $_pdf; |
|
56 | + protected $_cache_id; |
|
57 | + protected $_current_page_id; |
|
58 | + protected $_fonts; // fonts used in this document |
|
60 | 59 | |
61 | - function __construct($cache_id, CPDF_Adapter $pdf) { |
|
60 | + function __construct($cache_id, CPDF_Adapter $pdf) { |
|
62 | 61 | $this->_pdf = $pdf; |
63 | 62 | $this->_cache_id = $cache_id; |
64 | 63 | $this->_fonts = array(); |
65 | 64 | |
66 | 65 | $this->_current_page_id = $this->_pdf->open_object(); |
67 | - } |
|
66 | + } |
|
68 | 67 | |
69 | - //........................................................................ |
|
68 | + //........................................................................ |
|
70 | 69 | |
71 | - function get_cpdf() { return $this->_pdf->get_cpdf(); } |
|
70 | + function get_cpdf() { return $this->_pdf->get_cpdf(); } |
|
72 | 71 | |
73 | - function open_object() { $this->_pdf->open_object(); } |
|
74 | - function reopen_object() { return $this->_pdf->reopen_object(); } |
|
72 | + function open_object() { $this->_pdf->open_object(); } |
|
73 | + function reopen_object() { return $this->_pdf->reopen_object(); } |
|
75 | 74 | |
76 | - function close_object() { $this->_pdf->close_object(); } |
|
75 | + function close_object() { $this->_pdf->close_object(); } |
|
77 | 76 | |
78 | - function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); } |
|
77 | + function add_object($object, $where = 'all') { $this->_pdf->add_object($object, $where); } |
|
79 | 78 | |
80 | - function serialize_object($id) { $this->_pdf->serialize_object($id); } |
|
79 | + function serialize_object($id) { $this->_pdf->serialize_object($id); } |
|
81 | 80 | |
82 | - function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); } |
|
81 | + function reopen_serialized_object($obj) { $this->_pdf->reopen_serialized_object($obj); } |
|
83 | 82 | |
84 | - //........................................................................ |
|
83 | + //........................................................................ |
|
85 | 84 | |
86 | - function get_width() { return $this->_pdf->get_width(); } |
|
87 | - function get_height() { return $this->_pdf->get_height(); } |
|
88 | - function get_page_number() { return $this->_pdf->get_page_number(); } |
|
89 | - function get_page_count() { return $this->_pdf->get_page_count(); } |
|
85 | + function get_width() { return $this->_pdf->get_width(); } |
|
86 | + function get_height() { return $this->_pdf->get_height(); } |
|
87 | + function get_page_number() { return $this->_pdf->get_page_number(); } |
|
88 | + function get_page_count() { return $this->_pdf->get_page_count(); } |
|
90 | 89 | |
91 | - function set_page_number($num) { $this->_pdf->set_page_number($num); } |
|
92 | - function set_page_count($count) { $this->_pdf->set_page_count($count); } |
|
90 | + function set_page_number($num) { $this->_pdf->set_page_number($num); } |
|
91 | + function set_page_count($count) { $this->_pdf->set_page_count($count); } |
|
93 | 92 | |
94 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) { |
|
93 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = array()) { |
|
95 | 94 | $this->_pdf->line($x1, $y1, $x2, $y2, $color, $width, $style); |
96 | - } |
|
95 | + } |
|
97 | 96 | |
98 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) { |
|
97 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = array()) { |
|
99 | 98 | $this->_pdf->rectangle($x1, $y1, $w, $h, $color, $width, $style); |
100 | - } |
|
99 | + } |
|
101 | 100 | |
102 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
101 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
103 | 102 | $this->_pdf->filled_rectangle($x1, $y1, $w, $h, $color); |
104 | - } |
|
103 | + } |
|
105 | 104 | |
106 | - function polygon($points, $color, $width = null, $style = array(), $fill = false) { |
|
105 | + function polygon($points, $color, $width = null, $style = array(), $fill = false) { |
|
107 | 106 | $this->_pdf->polygon($points, $color, $width, $style, $fill); |
108 | - } |
|
107 | + } |
|
109 | 108 | |
110 | - function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) { |
|
109 | + function circle($x, $y, $r1, $color, $width = null, $style = null, $fill = false) { |
|
111 | 110 | $this->_pdf->circle($x, $y, $r1, $color, $width, $style, $fill); |
112 | - } |
|
111 | + } |
|
113 | 112 | |
114 | - function image($img_url, $x, $y, $w = null, $h = null) { |
|
113 | + function image($img_url, $x, $y, $w = null, $h = null) { |
|
115 | 114 | $this->_pdf->image($img_url, $x, $y, $w, $h); |
116 | - } |
|
115 | + } |
|
117 | 116 | |
118 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
117 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
119 | 118 | $this->_fonts[$font] = true; |
120 | 119 | $this->_pdf->text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
121 | - } |
|
120 | + } |
|
122 | 121 | |
123 | - function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
122 | + function page_text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
124 | 123 | |
125 | 124 | // We want to remove this from cached pages since it may not be correct |
126 | 125 | $this->_pdf->close_object(); |
127 | 126 | $this->_pdf->page_text($x, $y, $text, $font, $size, $color, $adjust, $angle); |
128 | 127 | $this->_pdf->reopen_object($this->_current_page_id); |
129 | - } |
|
128 | + } |
|
130 | 129 | |
131 | - function page_script($script, $type = 'text/php') { |
|
130 | + function page_script($script, $type = 'text/php') { |
|
132 | 131 | |
133 | 132 | // We want to remove this from cached pages since it may not be correct |
134 | 133 | $this->_pdf->close_object(); |
135 | 134 | $this->_pdf->page_script($script, $type); |
136 | 135 | $this->_pdf->reopen_object($this->_current_page_id); |
137 | - } |
|
136 | + } |
|
138 | 137 | |
139 | - function new_page() { |
|
138 | + function new_page() { |
|
140 | 139 | $this->_pdf->close_object(); |
141 | 140 | |
142 | 141 | // Add the object to the current page |
@@ -144,43 +143,43 @@ discard block |
||
144 | 143 | $this->_pdf->new_page(); |
145 | 144 | |
146 | 145 | Page_Cache::store_page($this->_cache_id, |
147 | - $this->_pdf->get_page_number() - 1, |
|
148 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
146 | + $this->_pdf->get_page_number() - 1, |
|
147 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
149 | 148 | |
150 | 149 | $this->_current_page_id = $this->_pdf->open_object(); |
151 | 150 | return $this->_current_page_id; |
152 | - } |
|
151 | + } |
|
153 | 152 | |
154 | - function stream($filename) { |
|
153 | + function stream($filename) { |
|
155 | 154 | // Store the last page in the page cache |
156 | 155 | if ( !is_null($this->_current_page_id) ) { |
157 | - $this->_pdf->close_object(); |
|
158 | - $this->_pdf->add_object($this->_current_page_id, "add"); |
|
159 | - Page_Cache::store_page($this->_cache_id, |
|
160 | - $this->_pdf->get_page_number(), |
|
161 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
162 | - Page_Cache::store_fonts($this->_cache_id, $this->_fonts); |
|
163 | - $this->_current_page_id = null; |
|
156 | + $this->_pdf->close_object(); |
|
157 | + $this->_pdf->add_object($this->_current_page_id, "add"); |
|
158 | + Page_Cache::store_page($this->_cache_id, |
|
159 | + $this->_pdf->get_page_number(), |
|
160 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
161 | + Page_Cache::store_fonts($this->_cache_id, $this->_fonts); |
|
162 | + $this->_current_page_id = null; |
|
164 | 163 | } |
165 | 164 | |
166 | 165 | $this->_pdf->stream($filename); |
167 | 166 | |
168 | - } |
|
167 | + } |
|
169 | 168 | |
170 | - function &output() { |
|
169 | + function &output() { |
|
171 | 170 | // Store the last page in the page cache |
172 | 171 | if ( !is_null($this->_current_page_id) ) { |
173 | - $this->_pdf->close_object(); |
|
174 | - $this->_pdf->add_object($this->_current_page_id, "add"); |
|
175 | - Page_Cache::store_page($this->_cache_id, |
|
176 | - $this->_pdf->get_page_number(), |
|
177 | - $this->_pdf->serialize_object($this->_current_page_id)); |
|
178 | - $this->_current_page_id = null; |
|
172 | + $this->_pdf->close_object(); |
|
173 | + $this->_pdf->add_object($this->_current_page_id, "add"); |
|
174 | + Page_Cache::store_page($this->_cache_id, |
|
175 | + $this->_pdf->get_page_number(), |
|
176 | + $this->_pdf->serialize_object($this->_current_page_id)); |
|
177 | + $this->_current_page_id = null; |
|
179 | 178 | } |
180 | 179 | |
181 | 180 | return $this->_pdf->output(); |
182 | - } |
|
181 | + } |
|
183 | 182 | |
184 | - function get_messages() { return $this->_pdf->get_messages(); } |
|
183 | + function get_messages() { return $this->_pdf->get_messages(); } |
|
185 | 184 | |
186 | 185 | } |
@@ -35,7 +35,6 @@ discard block |
||
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @contributor Helmut Tischer <[email protected]> |
37 | 37 | * @package dompdf |
38 | - |
|
39 | 38 | * |
40 | 39 | * Changes |
41 | 40 | * @contributor Helmut Tischer <[email protected]> |
@@ -53,17 +52,17 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class Inline_Frame_Decorator extends Frame_Decorator { |
55 | 54 | |
56 | - function __construct(Frame $frame, DOMPDF $dompdf) { parent::__construct($frame, $dompdf); } |
|
55 | + function __construct(Frame $frame, DOMPDF $dompdf) { parent::__construct($frame, $dompdf); } |
|
57 | 56 | |
58 | - function split($frame = null) { |
|
57 | + function split($frame = null) { |
|
59 | 58 | |
60 | 59 | if ( is_null($frame) ) { |
61 | - $this->get_parent()->split($this); |
|
62 | - return; |
|
60 | + $this->get_parent()->split($this); |
|
61 | + return; |
|
63 | 62 | } |
64 | 63 | |
65 | 64 | if ( $frame->get_parent() !== $this ) |
66 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
65 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
67 | 66 | |
68 | 67 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
69 | 68 | $this->get_parent()->insert_child_after($split, $this); |
@@ -86,18 +85,18 @@ discard block |
||
86 | 85 | //See e.g. in testcase image_variants, long desriptions |
87 | 86 | if ( ($url = $style->background_image) && $url !== "none" |
88 | 87 | && ($repeat = $style->background_repeat) && $repeat !== "repeat" && $repeat !== "repeat-y" |
89 | - ) { |
|
90 | - $style->background_image = "none"; |
|
88 | + ) { |
|
89 | + $style->background_image = "none"; |
|
91 | 90 | } |
92 | 91 | |
93 | 92 | // Add $frame and all following siblings to the new split node |
94 | 93 | $iter = $frame; |
95 | 94 | while ($iter) { |
96 | - $frame = $iter; |
|
97 | - $iter = $iter->get_next_sibling(); |
|
98 | - $frame->reset(); |
|
99 | - $split->append_child($frame); |
|
95 | + $frame = $iter; |
|
96 | + $iter = $iter->get_next_sibling(); |
|
97 | + $frame->reset(); |
|
98 | + $split->append_child($frame); |
|
99 | + } |
|
100 | 100 | } |
101 | - } |
|
102 | 101 | |
103 | 102 | } |
@@ -48,26 +48,26 @@ discard block |
||
48 | 48 | */ |
49 | 49 | class Table_Row_Group_Frame_Decorator extends Frame_Decorator { |
50 | 50 | |
51 | - /** |
|
52 | - * Class constructor |
|
53 | - * |
|
54 | - * @param Frame $frame Frame to decorate |
|
55 | - * @param DOMPDF $dompdf Current dompdf instance |
|
56 | - */ |
|
57 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
51 | + /** |
|
52 | + * Class constructor |
|
53 | + * |
|
54 | + * @param Frame $frame Frame to decorate |
|
55 | + * @param DOMPDF $dompdf Current dompdf instance |
|
56 | + */ |
|
57 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
58 | 58 | parent::__construct($frame, $dompdf); |
59 | - } |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Override split() to remove all child rows and this element from the cellmap |
|
63 | - * |
|
64 | - * @param Frame $child |
|
65 | - */ |
|
66 | - function split($child = null) { |
|
61 | + /** |
|
62 | + * Override split() to remove all child rows and this element from the cellmap |
|
63 | + * |
|
64 | + * @param Frame $child |
|
65 | + */ |
|
66 | + function split($child = null) { |
|
67 | 67 | |
68 | 68 | if ( is_null($child) ) { |
69 | - parent::split(); |
|
70 | - return; |
|
69 | + parent::split(); |
|
70 | + return; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | $iter = $child; |
77 | 77 | |
78 | 78 | while ( $iter ) { |
79 | - $cellmap->remove_row($iter); |
|
80 | - $iter = $iter->get_next_sibling(); |
|
79 | + $cellmap->remove_row($iter); |
|
80 | + $iter = $iter->get_next_sibling(); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | // If we are splitting at the first child remove the |
84 | 84 | // table-row-group from the cellmap as well |
85 | 85 | if ( $child === $this->get_first_child() ) { |
86 | - $cellmap->remove_row_group($this); |
|
87 | - parent::split(); |
|
88 | - return; |
|
86 | + $cellmap->remove_row_group($this); |
|
87 | + parent::split(); |
|
88 | + return; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | $cellmap->update_row_group($this, $child->get_prev_sibling()); |
92 | 92 | parent::split($child); |
93 | 93 | |
94 | - } |
|
94 | + } |
|
95 | 95 | } |
96 | 96 |
@@ -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 | } |
@@ -85,114 +85,114 @@ discard block |
||
85 | 85 | */ |
86 | 86 | class Style { |
87 | 87 | |
88 | - /** |
|
89 | - * Default font size, in points. |
|
90 | - * |
|
91 | - * @var float |
|
92 | - */ |
|
93 | - static $default_font_size = 12; |
|
94 | - |
|
95 | - /** |
|
96 | - * Default line height, as a fraction of the font size. |
|
97 | - * |
|
98 | - * @var float |
|
99 | - */ |
|
100 | - static $default_line_height = 1.2; |
|
101 | - |
|
102 | - /** |
|
103 | - * List of all inline types. Should really be a constant. |
|
104 | - * |
|
105 | - * @var array |
|
106 | - */ |
|
107 | - static $INLINE_TYPES = array("inline"); |
|
108 | - |
|
109 | - /** |
|
110 | - * List of all block types. Should really be a constant. |
|
111 | - * |
|
112 | - * @var array |
|
113 | - */ |
|
114 | - static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item"); |
|
115 | - |
|
116 | - /** |
|
117 | - * List of all table types. Should really be a constant. |
|
118 | - * |
|
119 | - * @var array; |
|
120 | - */ |
|
121 | - static $TABLE_TYPES = array("table", "inline-table"); |
|
122 | - |
|
123 | - /** |
|
124 | - * List of valid border styles. Should also really be a constant. |
|
125 | - * |
|
126 | - * @var array |
|
127 | - */ |
|
128 | - static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid", |
|
88 | + /** |
|
89 | + * Default font size, in points. |
|
90 | + * |
|
91 | + * @var float |
|
92 | + */ |
|
93 | + static $default_font_size = 12; |
|
94 | + |
|
95 | + /** |
|
96 | + * Default line height, as a fraction of the font size. |
|
97 | + * |
|
98 | + * @var float |
|
99 | + */ |
|
100 | + static $default_line_height = 1.2; |
|
101 | + |
|
102 | + /** |
|
103 | + * List of all inline types. Should really be a constant. |
|
104 | + * |
|
105 | + * @var array |
|
106 | + */ |
|
107 | + static $INLINE_TYPES = array("inline"); |
|
108 | + |
|
109 | + /** |
|
110 | + * List of all block types. Should really be a constant. |
|
111 | + * |
|
112 | + * @var array |
|
113 | + */ |
|
114 | + static $BLOCK_TYPES = array("block","inline-block", "table-cell", "list-item"); |
|
115 | + |
|
116 | + /** |
|
117 | + * List of all table types. Should really be a constant. |
|
118 | + * |
|
119 | + * @var array; |
|
120 | + */ |
|
121 | + static $TABLE_TYPES = array("table", "inline-table"); |
|
122 | + |
|
123 | + /** |
|
124 | + * List of valid border styles. Should also really be a constant. |
|
125 | + * |
|
126 | + * @var array |
|
127 | + */ |
|
128 | + static $BORDER_STYLES = array("none", "hidden", "dotted", "dashed", "solid", |
|
129 | 129 | "double", "groove", "ridge", "inset", "outset"); |
130 | 130 | |
131 | - /** |
|
132 | - * Default style values. |
|
133 | - * |
|
134 | - * @link http://www.w3.org/TR/CSS21/propidx.html |
|
135 | - * |
|
136 | - * @var array |
|
137 | - */ |
|
138 | - static protected $_defaults = null; |
|
139 | - |
|
140 | - /** |
|
141 | - * List of inherited properties |
|
142 | - * |
|
143 | - * @link http://www.w3.org/TR/CSS21/propidx.html |
|
144 | - * |
|
145 | - * @var array |
|
146 | - */ |
|
147 | - static protected $_inherited = null; |
|
148 | - |
|
149 | - /** |
|
150 | - * The stylesheet this style belongs to |
|
151 | - * |
|
152 | - * @see Stylesheet |
|
153 | - * @var Stylesheet |
|
154 | - */ |
|
155 | - protected $_stylesheet; // stylesheet this style is attached to |
|
156 | - |
|
157 | - /** |
|
158 | - * Main array of all CSS properties & values |
|
159 | - * |
|
160 | - * @var array |
|
161 | - */ |
|
162 | - protected $_props; |
|
163 | - |
|
164 | - /* var instead of protected would allow access outside of class */ |
|
165 | - protected $_important_props; |
|
166 | - |
|
167 | - /** |
|
168 | - * Cached property values |
|
169 | - * |
|
170 | - * @var array |
|
171 | - */ |
|
172 | - protected $_prop_cache; |
|
131 | + /** |
|
132 | + * Default style values. |
|
133 | + * |
|
134 | + * @link http://www.w3.org/TR/CSS21/propidx.html |
|
135 | + * |
|
136 | + * @var array |
|
137 | + */ |
|
138 | + static protected $_defaults = null; |
|
139 | + |
|
140 | + /** |
|
141 | + * List of inherited properties |
|
142 | + * |
|
143 | + * @link http://www.w3.org/TR/CSS21/propidx.html |
|
144 | + * |
|
145 | + * @var array |
|
146 | + */ |
|
147 | + static protected $_inherited = null; |
|
148 | + |
|
149 | + /** |
|
150 | + * The stylesheet this style belongs to |
|
151 | + * |
|
152 | + * @see Stylesheet |
|
153 | + * @var Stylesheet |
|
154 | + */ |
|
155 | + protected $_stylesheet; // stylesheet this style is attached to |
|
156 | + |
|
157 | + /** |
|
158 | + * Main array of all CSS properties & values |
|
159 | + * |
|
160 | + * @var array |
|
161 | + */ |
|
162 | + protected $_props; |
|
163 | + |
|
164 | + /* var instead of protected would allow access outside of class */ |
|
165 | + protected $_important_props; |
|
166 | + |
|
167 | + /** |
|
168 | + * Cached property values |
|
169 | + * |
|
170 | + * @var array |
|
171 | + */ |
|
172 | + protected $_prop_cache; |
|
173 | 173 | |
174 | - /** |
|
175 | - * Font size of parent element in document tree. Used for relative font |
|
176 | - * size resolution. |
|
177 | - * |
|
178 | - * @var float |
|
179 | - */ |
|
180 | - protected $_parent_font_size; // Font size of parent element |
|
174 | + /** |
|
175 | + * Font size of parent element in document tree. Used for relative font |
|
176 | + * size resolution. |
|
177 | + * |
|
178 | + * @var float |
|
179 | + */ |
|
180 | + protected $_parent_font_size; // Font size of parent element |
|
181 | 181 | |
182 | - // private members |
|
183 | - /** |
|
184 | - * True once the font size is resolved absolutely |
|
185 | - * |
|
186 | - * @var bool |
|
187 | - */ |
|
188 | - private $__font_size_calculated; // Cache flag |
|
182 | + // private members |
|
183 | + /** |
|
184 | + * True once the font size is resolved absolutely |
|
185 | + * |
|
186 | + * @var bool |
|
187 | + */ |
|
188 | + private $__font_size_calculated; // Cache flag |
|
189 | 189 | |
190 | - /** |
|
191 | - * Class constructor |
|
192 | - * |
|
193 | - * @param Stylesheet $stylesheet the stylesheet this Style is associated with. |
|
194 | - */ |
|
195 | - function __construct(Stylesheet $stylesheet) { |
|
190 | + /** |
|
191 | + * Class constructor |
|
192 | + * |
|
193 | + * @param Stylesheet $stylesheet the stylesheet this Style is associated with. |
|
194 | + */ |
|
195 | + function __construct(Stylesheet $stylesheet) { |
|
196 | 196 | $this->_props = array(); |
197 | 197 | $this->_important_props = array(); |
198 | 198 | $this->_stylesheet = $stylesheet; |
@@ -201,330 +201,330 @@ discard block |
||
201 | 201 | |
202 | 202 | if ( !isset(self::$_defaults) ) { |
203 | 203 | |
204 | - // Shorthand |
|
205 | - $d =& self::$_defaults; |
|
204 | + // Shorthand |
|
205 | + $d =& self::$_defaults; |
|
206 | 206 | |
207 | - // All CSS 2.1 properties, and their default values |
|
208 | - $d["azimuth"] = "center"; |
|
209 | - $d["background_attachment"] = "scroll"; |
|
210 | - $d["background_color"] = "transparent"; |
|
211 | - $d["background_image"] = "none"; |
|
212 | - $d["background_position"] = "0% 0%"; |
|
213 | - $d["background_repeat"] = "repeat"; |
|
214 | - $d["background"] = ""; |
|
215 | - $d["border_collapse"] = "separate"; |
|
216 | - $d["border_color"] = ""; |
|
217 | - $d["border_spacing"] = "0"; |
|
218 | - $d["border_style"] = ""; |
|
219 | - $d["border_top"] = ""; |
|
220 | - $d["border_right"] = ""; |
|
221 | - $d["border_bottom"] = ""; |
|
222 | - $d["border_left"] = ""; |
|
223 | - $d["border_top_color"] = ""; |
|
224 | - $d["border_right_color"] = ""; |
|
225 | - $d["border_bottom_color"] = ""; |
|
226 | - $d["border_left_color"] = ""; |
|
227 | - $d["border_top_style"] = "none"; |
|
228 | - $d["border_right_style"] = "none"; |
|
229 | - $d["border_bottom_style"] = "none"; |
|
230 | - $d["border_left_style"] = "none"; |
|
231 | - $d["border_top_width"] = "medium"; |
|
232 | - $d["border_right_width"] = "medium"; |
|
233 | - $d["border_bottom_width"] = "medium"; |
|
234 | - $d["border_left_width"] = "medium"; |
|
235 | - $d["border_width"] = "medium"; |
|
236 | - $d["border"] = ""; |
|
237 | - $d["bottom"] = "auto"; |
|
238 | - $d["caption_side"] = "top"; |
|
239 | - $d["clear"] = "none"; |
|
240 | - $d["clip"] = "auto"; |
|
241 | - $d["color"] = "#000000"; |
|
242 | - $d["content"] = "normal"; |
|
243 | - $d["counter_increment"] = "none"; |
|
244 | - $d["counter_reset"] = "none"; |
|
245 | - $d["cue_after"] = "none"; |
|
246 | - $d["cue_before"] = "none"; |
|
247 | - $d["cue"] = ""; |
|
248 | - $d["cursor"] = "auto"; |
|
249 | - $d["direction"] = "ltr"; |
|
250 | - $d["display"] = "inline"; |
|
251 | - $d["elevation"] = "level"; |
|
252 | - $d["empty_cells"] = "show"; |
|
253 | - $d["float"] = "none"; |
|
254 | - $d["font_family"] = "serif"; |
|
255 | - $d["font_size"] = "medium"; |
|
256 | - $d["font_style"] = "normal"; |
|
257 | - $d["font_variant"] = "normal"; |
|
258 | - $d["font_weight"] = "normal"; |
|
259 | - $d["font"] = ""; |
|
260 | - $d["height"] = "auto"; |
|
261 | - $d["left"] = "auto"; |
|
262 | - $d["letter_spacing"] = "normal"; |
|
263 | - $d["line_height"] = "normal"; |
|
264 | - $d["list_style_image"] = "none"; |
|
265 | - $d["list_style_position"] = "outside"; |
|
266 | - $d["list_style_type"] = "disc"; |
|
267 | - $d["list_style"] = ""; |
|
268 | - $d["margin_right"] = "0"; |
|
269 | - $d["margin_left"] = "0"; |
|
270 | - $d["margin_top"] = "0"; |
|
271 | - $d["margin_bottom"] = "0"; |
|
272 | - $d["margin"] = ""; |
|
273 | - $d["max_height"] = "none"; |
|
274 | - $d["max_width"] = "none"; |
|
275 | - $d["min_height"] = "0"; |
|
276 | - $d["min_width"] = "0"; |
|
277 | - $d["orphans"] = "2"; |
|
278 | - $d["outline_color"] = "invert"; |
|
279 | - $d["outline_style"] = "none"; |
|
280 | - $d["outline_width"] = "medium"; |
|
281 | - $d["outline"] = ""; |
|
282 | - $d["overflow"] = "visible"; |
|
283 | - $d["padding_top"] = "0"; |
|
284 | - $d["padding_right"] = "0"; |
|
285 | - $d["padding_bottom"] = "0"; |
|
286 | - $d["padding_left"] = "0"; |
|
287 | - $d["padding"] = ""; |
|
288 | - $d["page_break_after"] = "auto"; |
|
289 | - $d["page_break_before"] = "auto"; |
|
290 | - $d["page_break_inside"] = "auto"; |
|
291 | - $d["pause_after"] = "0"; |
|
292 | - $d["pause_before"] = "0"; |
|
293 | - $d["pause"] = ""; |
|
294 | - $d["pitch_range"] = "50"; |
|
295 | - $d["pitch"] = "medium"; |
|
296 | - $d["play_during"] = "auto"; |
|
297 | - $d["position"] = "static"; |
|
298 | - $d["quotes"] = ""; |
|
299 | - $d["richness"] = "50"; |
|
300 | - $d["right"] = "auto"; |
|
301 | - $d["speak_header"] = "once"; |
|
302 | - $d["speak_numeral"] = "continuous"; |
|
303 | - $d["speak_punctuation"] = "none"; |
|
304 | - $d["speak"] = "normal"; |
|
305 | - $d["speech_rate"] = "medium"; |
|
306 | - $d["stress"] = "50"; |
|
307 | - $d["table_layout"] = "auto"; |
|
308 | - $d["text_align"] = "left"; |
|
309 | - $d["text_decoration"] = "none"; |
|
310 | - $d["text_indent"] = "0"; |
|
311 | - $d["text_transform"] = "none"; |
|
312 | - $d["top"] = "auto"; |
|
313 | - $d["unicode_bidi"] = "normal"; |
|
314 | - $d["vertical_align"] = "baseline"; |
|
315 | - $d["visibility"] = "visible"; |
|
316 | - $d["voice_family"] = ""; |
|
317 | - $d["volume"] = "medium"; |
|
318 | - $d["white_space"] = "normal"; |
|
319 | - $d["widows"] = "2"; |
|
320 | - $d["width"] = "auto"; |
|
321 | - $d["word_spacing"] = "normal"; |
|
322 | - $d["z_index"] = "auto"; |
|
323 | - |
|
324 | - // Properties that inherit by default |
|
325 | - self::$_inherited = array("azimuth", |
|
326 | - "border_collapse", |
|
327 | - "border_spacing", |
|
328 | - "caption_side", |
|
329 | - "color", |
|
330 | - "cursor", |
|
331 | - "direction", |
|
332 | - "elevation", |
|
333 | - "empty_cells", |
|
334 | - "font_family", |
|
335 | - "font_size", |
|
336 | - "font_style", |
|
337 | - "font_variant", |
|
338 | - "font_weight", |
|
339 | - "font", |
|
340 | - "letter_spacing", |
|
341 | - "line_height", |
|
342 | - "list_style_image", |
|
343 | - "list_style_position", |
|
344 | - "list_style_type", |
|
345 | - "list_style", |
|
346 | - "orphans", |
|
347 | - "page_break_inside", |
|
348 | - "pitch_range", |
|
349 | - "pitch", |
|
350 | - "quotes", |
|
351 | - "richness", |
|
352 | - "speak_header", |
|
353 | - "speak_numeral", |
|
354 | - "speak_punctuation", |
|
355 | - "speak", |
|
356 | - "speech_rate", |
|
357 | - "stress", |
|
358 | - "text_align", |
|
359 | - "text_indent", |
|
360 | - "text_transform", |
|
361 | - "visibility", |
|
362 | - "voice_family", |
|
363 | - "volume", |
|
364 | - "white_space", |
|
365 | - "widows", |
|
366 | - "word_spacing"); |
|
367 | - } |
|
368 | - |
|
369 | - } |
|
370 | - |
|
371 | - /** |
|
372 | - * "Destructor": forcibly free all references held by this object |
|
373 | - */ |
|
374 | - function dispose() { |
|
207 | + // All CSS 2.1 properties, and their default values |
|
208 | + $d["azimuth"] = "center"; |
|
209 | + $d["background_attachment"] = "scroll"; |
|
210 | + $d["background_color"] = "transparent"; |
|
211 | + $d["background_image"] = "none"; |
|
212 | + $d["background_position"] = "0% 0%"; |
|
213 | + $d["background_repeat"] = "repeat"; |
|
214 | + $d["background"] = ""; |
|
215 | + $d["border_collapse"] = "separate"; |
|
216 | + $d["border_color"] = ""; |
|
217 | + $d["border_spacing"] = "0"; |
|
218 | + $d["border_style"] = ""; |
|
219 | + $d["border_top"] = ""; |
|
220 | + $d["border_right"] = ""; |
|
221 | + $d["border_bottom"] = ""; |
|
222 | + $d["border_left"] = ""; |
|
223 | + $d["border_top_color"] = ""; |
|
224 | + $d["border_right_color"] = ""; |
|
225 | + $d["border_bottom_color"] = ""; |
|
226 | + $d["border_left_color"] = ""; |
|
227 | + $d["border_top_style"] = "none"; |
|
228 | + $d["border_right_style"] = "none"; |
|
229 | + $d["border_bottom_style"] = "none"; |
|
230 | + $d["border_left_style"] = "none"; |
|
231 | + $d["border_top_width"] = "medium"; |
|
232 | + $d["border_right_width"] = "medium"; |
|
233 | + $d["border_bottom_width"] = "medium"; |
|
234 | + $d["border_left_width"] = "medium"; |
|
235 | + $d["border_width"] = "medium"; |
|
236 | + $d["border"] = ""; |
|
237 | + $d["bottom"] = "auto"; |
|
238 | + $d["caption_side"] = "top"; |
|
239 | + $d["clear"] = "none"; |
|
240 | + $d["clip"] = "auto"; |
|
241 | + $d["color"] = "#000000"; |
|
242 | + $d["content"] = "normal"; |
|
243 | + $d["counter_increment"] = "none"; |
|
244 | + $d["counter_reset"] = "none"; |
|
245 | + $d["cue_after"] = "none"; |
|
246 | + $d["cue_before"] = "none"; |
|
247 | + $d["cue"] = ""; |
|
248 | + $d["cursor"] = "auto"; |
|
249 | + $d["direction"] = "ltr"; |
|
250 | + $d["display"] = "inline"; |
|
251 | + $d["elevation"] = "level"; |
|
252 | + $d["empty_cells"] = "show"; |
|
253 | + $d["float"] = "none"; |
|
254 | + $d["font_family"] = "serif"; |
|
255 | + $d["font_size"] = "medium"; |
|
256 | + $d["font_style"] = "normal"; |
|
257 | + $d["font_variant"] = "normal"; |
|
258 | + $d["font_weight"] = "normal"; |
|
259 | + $d["font"] = ""; |
|
260 | + $d["height"] = "auto"; |
|
261 | + $d["left"] = "auto"; |
|
262 | + $d["letter_spacing"] = "normal"; |
|
263 | + $d["line_height"] = "normal"; |
|
264 | + $d["list_style_image"] = "none"; |
|
265 | + $d["list_style_position"] = "outside"; |
|
266 | + $d["list_style_type"] = "disc"; |
|
267 | + $d["list_style"] = ""; |
|
268 | + $d["margin_right"] = "0"; |
|
269 | + $d["margin_left"] = "0"; |
|
270 | + $d["margin_top"] = "0"; |
|
271 | + $d["margin_bottom"] = "0"; |
|
272 | + $d["margin"] = ""; |
|
273 | + $d["max_height"] = "none"; |
|
274 | + $d["max_width"] = "none"; |
|
275 | + $d["min_height"] = "0"; |
|
276 | + $d["min_width"] = "0"; |
|
277 | + $d["orphans"] = "2"; |
|
278 | + $d["outline_color"] = "invert"; |
|
279 | + $d["outline_style"] = "none"; |
|
280 | + $d["outline_width"] = "medium"; |
|
281 | + $d["outline"] = ""; |
|
282 | + $d["overflow"] = "visible"; |
|
283 | + $d["padding_top"] = "0"; |
|
284 | + $d["padding_right"] = "0"; |
|
285 | + $d["padding_bottom"] = "0"; |
|
286 | + $d["padding_left"] = "0"; |
|
287 | + $d["padding"] = ""; |
|
288 | + $d["page_break_after"] = "auto"; |
|
289 | + $d["page_break_before"] = "auto"; |
|
290 | + $d["page_break_inside"] = "auto"; |
|
291 | + $d["pause_after"] = "0"; |
|
292 | + $d["pause_before"] = "0"; |
|
293 | + $d["pause"] = ""; |
|
294 | + $d["pitch_range"] = "50"; |
|
295 | + $d["pitch"] = "medium"; |
|
296 | + $d["play_during"] = "auto"; |
|
297 | + $d["position"] = "static"; |
|
298 | + $d["quotes"] = ""; |
|
299 | + $d["richness"] = "50"; |
|
300 | + $d["right"] = "auto"; |
|
301 | + $d["speak_header"] = "once"; |
|
302 | + $d["speak_numeral"] = "continuous"; |
|
303 | + $d["speak_punctuation"] = "none"; |
|
304 | + $d["speak"] = "normal"; |
|
305 | + $d["speech_rate"] = "medium"; |
|
306 | + $d["stress"] = "50"; |
|
307 | + $d["table_layout"] = "auto"; |
|
308 | + $d["text_align"] = "left"; |
|
309 | + $d["text_decoration"] = "none"; |
|
310 | + $d["text_indent"] = "0"; |
|
311 | + $d["text_transform"] = "none"; |
|
312 | + $d["top"] = "auto"; |
|
313 | + $d["unicode_bidi"] = "normal"; |
|
314 | + $d["vertical_align"] = "baseline"; |
|
315 | + $d["visibility"] = "visible"; |
|
316 | + $d["voice_family"] = ""; |
|
317 | + $d["volume"] = "medium"; |
|
318 | + $d["white_space"] = "normal"; |
|
319 | + $d["widows"] = "2"; |
|
320 | + $d["width"] = "auto"; |
|
321 | + $d["word_spacing"] = "normal"; |
|
322 | + $d["z_index"] = "auto"; |
|
323 | + |
|
324 | + // Properties that inherit by default |
|
325 | + self::$_inherited = array("azimuth", |
|
326 | + "border_collapse", |
|
327 | + "border_spacing", |
|
328 | + "caption_side", |
|
329 | + "color", |
|
330 | + "cursor", |
|
331 | + "direction", |
|
332 | + "elevation", |
|
333 | + "empty_cells", |
|
334 | + "font_family", |
|
335 | + "font_size", |
|
336 | + "font_style", |
|
337 | + "font_variant", |
|
338 | + "font_weight", |
|
339 | + "font", |
|
340 | + "letter_spacing", |
|
341 | + "line_height", |
|
342 | + "list_style_image", |
|
343 | + "list_style_position", |
|
344 | + "list_style_type", |
|
345 | + "list_style", |
|
346 | + "orphans", |
|
347 | + "page_break_inside", |
|
348 | + "pitch_range", |
|
349 | + "pitch", |
|
350 | + "quotes", |
|
351 | + "richness", |
|
352 | + "speak_header", |
|
353 | + "speak_numeral", |
|
354 | + "speak_punctuation", |
|
355 | + "speak", |
|
356 | + "speech_rate", |
|
357 | + "stress", |
|
358 | + "text_align", |
|
359 | + "text_indent", |
|
360 | + "text_transform", |
|
361 | + "visibility", |
|
362 | + "voice_family", |
|
363 | + "volume", |
|
364 | + "white_space", |
|
365 | + "widows", |
|
366 | + "word_spacing"); |
|
367 | + } |
|
368 | + |
|
369 | + } |
|
370 | + |
|
371 | + /** |
|
372 | + * "Destructor": forcibly free all references held by this object |
|
373 | + */ |
|
374 | + function dispose() { |
|
375 | 375 | unset($this->_stylesheet); |
376 | - } |
|
376 | + } |
|
377 | 377 | |
378 | - /** |
|
379 | - * returns the {@link Stylesheet} this Style is associated with. |
|
380 | - * |
|
381 | - * @return Stylesheet |
|
382 | - */ |
|
383 | - function get_stylesheet() { return $this->_stylesheet; } |
|
378 | + /** |
|
379 | + * returns the {@link Stylesheet} this Style is associated with. |
|
380 | + * |
|
381 | + * @return Stylesheet |
|
382 | + */ |
|
383 | + function get_stylesheet() { return $this->_stylesheet; } |
|
384 | 384 | |
385 | - /** |
|
386 | - * Converts any CSS length value into an absolute length in points. |
|
387 | - * |
|
388 | - * length_in_pt() takes a single length (e.g. '1em') or an array of |
|
389 | - * lengths and returns an absolute length. If an array is passed, then |
|
390 | - * the return value is the sum of all elements. |
|
391 | - * |
|
392 | - * If a reference size is not provided, the default font size is used |
|
393 | - * ({@link Style::$default_font_size}). |
|
394 | - * |
|
395 | - * @param float|array $length the length or array of lengths to resolve |
|
396 | - * @param float $ref_size an absolute reference size to resolve percentage lengths |
|
397 | - * @return float |
|
398 | - */ |
|
399 | - function length_in_pt($length, $ref_size = null) { |
|
385 | + /** |
|
386 | + * Converts any CSS length value into an absolute length in points. |
|
387 | + * |
|
388 | + * length_in_pt() takes a single length (e.g. '1em') or an array of |
|
389 | + * lengths and returns an absolute length. If an array is passed, then |
|
390 | + * the return value is the sum of all elements. |
|
391 | + * |
|
392 | + * If a reference size is not provided, the default font size is used |
|
393 | + * ({@link Style::$default_font_size}). |
|
394 | + * |
|
395 | + * @param float|array $length the length or array of lengths to resolve |
|
396 | + * @param float $ref_size an absolute reference size to resolve percentage lengths |
|
397 | + * @return float |
|
398 | + */ |
|
399 | + function length_in_pt($length, $ref_size = null) { |
|
400 | 400 | |
401 | 401 | if ( !is_array($length) ) |
402 | - $length = array($length); |
|
402 | + $length = array($length); |
|
403 | 403 | |
404 | 404 | if ( !isset($ref_size) ) |
405 | - $ref_size = self::$default_font_size; |
|
405 | + $ref_size = self::$default_font_size; |
|
406 | 406 | |
407 | 407 | $ret = 0; |
408 | 408 | foreach ($length as $l) { |
409 | 409 | |
410 | - if ( $l === "auto" ) |
|
410 | + if ( $l === "auto" ) |
|
411 | 411 | return "auto"; |
412 | 412 | |
413 | - if ( $l === "none" ) |
|
413 | + if ( $l === "none" ) |
|
414 | 414 | return "none"; |
415 | 415 | |
416 | - // Assume numeric values are already in points |
|
417 | - if ( is_numeric($l) ) { |
|
416 | + // Assume numeric values are already in points |
|
417 | + if ( is_numeric($l) ) { |
|
418 | 418 | $ret += $l; |
419 | 419 | continue; |
420 | - } |
|
420 | + } |
|
421 | 421 | |
422 | - if ( $l === "normal" ) { |
|
422 | + if ( $l === "normal" ) { |
|
423 | 423 | $ret += $ref_size; |
424 | 424 | continue; |
425 | - } |
|
425 | + } |
|
426 | 426 | |
427 | - // Border lengths |
|
428 | - if ( $l === "thin" ) { |
|
427 | + // Border lengths |
|
428 | + if ( $l === "thin" ) { |
|
429 | 429 | $ret += 0.5; |
430 | 430 | continue; |
431 | - } |
|
431 | + } |
|
432 | 432 | |
433 | - if ( $l === "medium" ) { |
|
433 | + if ( $l === "medium" ) { |
|
434 | 434 | $ret += 1.5; |
435 | 435 | continue; |
436 | - } |
|
436 | + } |
|
437 | 437 | |
438 | - if ( $l === "thick" ) { |
|
438 | + if ( $l === "thick" ) { |
|
439 | 439 | $ret += 2.5; |
440 | 440 | continue; |
441 | - } |
|
441 | + } |
|
442 | 442 | |
443 | - if ( ($i = mb_strpos($l, "pt")) !== false ) { |
|
443 | + if ( ($i = mb_strpos($l, "pt")) !== false ) { |
|
444 | 444 | $ret += mb_substr($l, 0, $i); |
445 | 445 | continue; |
446 | - } |
|
446 | + } |
|
447 | 447 | |
448 | - if ( ($i = mb_strpos($l, "px")) !== false ) { |
|
448 | + if ( ($i = mb_strpos($l, "px")) !== false ) { |
|
449 | 449 | $ret += ( mb_substr($l, 0, $i) * 72 ) / DOMPDF_DPI; |
450 | 450 | continue; |
451 | - } |
|
451 | + } |
|
452 | 452 | |
453 | - if ( ($i = mb_strpos($l, "em")) !== false ) { |
|
453 | + if ( ($i = mb_strpos($l, "em")) !== false ) { |
|
454 | 454 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
455 | 455 | continue; |
456 | - } |
|
456 | + } |
|
457 | 457 | |
458 | - // FIXME: em:ex ratio? |
|
459 | - if ( ($i = mb_strpos($l, "ex")) !== false ) { |
|
458 | + // FIXME: em:ex ratio? |
|
459 | + if ( ($i = mb_strpos($l, "ex")) !== false ) { |
|
460 | 460 | $ret += mb_substr($l, 0, $i) * $this->__get("font_size"); |
461 | 461 | continue; |
462 | - } |
|
462 | + } |
|
463 | 463 | |
464 | - if ( ($i = mb_strpos($l, "%")) !== false ) { |
|
464 | + if ( ($i = mb_strpos($l, "%")) !== false ) { |
|
465 | 465 | $ret += mb_substr($l, 0, $i)/100 * $ref_size; |
466 | 466 | continue; |
467 | - } |
|
467 | + } |
|
468 | 468 | |
469 | - if ( ($i = mb_strpos($l, "in")) !== false ) { |
|
469 | + if ( ($i = mb_strpos($l, "in")) !== false ) { |
|
470 | 470 | $ret += mb_substr($l, 0, $i) * 72; |
471 | 471 | continue; |
472 | - } |
|
472 | + } |
|
473 | 473 | |
474 | - if ( ($i = mb_strpos($l, "cm")) !== false ) { |
|
474 | + if ( ($i = mb_strpos($l, "cm")) !== false ) { |
|
475 | 475 | $ret += mb_substr($l, 0, $i) * 72 / 2.54; |
476 | 476 | continue; |
477 | - } |
|
477 | + } |
|
478 | 478 | |
479 | - if ( ($i = mb_strpos($l, "mm")) !== false ) { |
|
479 | + if ( ($i = mb_strpos($l, "mm")) !== false ) { |
|
480 | 480 | $ret += mb_substr($l, 0, $i) * 72 / 25.4; |
481 | 481 | continue; |
482 | - } |
|
482 | + } |
|
483 | 483 | |
484 | - if ( ($i = mb_strpos($l, "pc")) !== false ) { |
|
484 | + if ( ($i = mb_strpos($l, "pc")) !== false ) { |
|
485 | 485 | $ret += mb_substr($l, 0, $i) / 12; |
486 | 486 | continue; |
487 | - } |
|
487 | + } |
|
488 | 488 | |
489 | - // Bogus value |
|
490 | - $ret += $ref_size; |
|
489 | + // Bogus value |
|
490 | + $ret += $ref_size; |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | return $ret; |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | |
497 | - /** |
|
498 | - * Set inherited properties in this style using values in $parent |
|
499 | - * |
|
500 | - * @param Style $parent |
|
501 | - */ |
|
502 | - function inherit(Style $parent) { |
|
497 | + /** |
|
498 | + * Set inherited properties in this style using values in $parent |
|
499 | + * |
|
500 | + * @param Style $parent |
|
501 | + */ |
|
502 | + function inherit(Style $parent) { |
|
503 | 503 | |
504 | 504 | // Set parent font size |
505 | 505 | $this->_parent_font_size = $parent->get_font_size(); |
506 | 506 | |
507 | 507 | foreach (self::$_inherited as $prop) { |
508 | - //inherit the !important property also. |
|
509 | - //if local property is also !important, don't inherit. |
|
510 | - if ( isset($parent->_props[$prop]) && |
|
508 | + //inherit the !important property also. |
|
509 | + //if local property is also !important, don't inherit. |
|
510 | + if ( isset($parent->_props[$prop]) && |
|
511 | 511 | ( !isset($this->_props[$prop]) || |
512 | 512 | ( isset($parent->_important_props[$prop]) && !isset($this->_important_props[$prop]) ) |
513 | - ) |
|
514 | - ) { |
|
513 | + ) |
|
514 | + ) { |
|
515 | 515 | if ( isset($parent->_important_props[$prop]) ) { |
516 | - $this->_important_props[$prop] = true; |
|
516 | + $this->_important_props[$prop] = true; |
|
517 | 517 | } |
518 | 518 | //see __set and __get, on all assignments clear cache! |
519 | - $this->_prop_cache[$prop] = null; |
|
520 | - $this->_props[$prop] = $parent->_props[$prop]; |
|
521 | - } |
|
519 | + $this->_prop_cache[$prop] = null; |
|
520 | + $this->_props[$prop] = $parent->_props[$prop]; |
|
521 | + } |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | foreach (array_keys($this->_props) as $prop) { |
525 | - if ( $this->_props[$prop] === "inherit" ) { |
|
525 | + if ( $this->_props[$prop] === "inherit" ) { |
|
526 | 526 | if ( isset($parent->_important_props[$prop]) ) { |
527 | - $this->_important_props[$prop] = true; |
|
527 | + $this->_important_props[$prop] = true; |
|
528 | 528 | } |
529 | 529 | //do not assign direct, but |
530 | 530 | //implicite assignment through __set, redirect to specialized, get value with __get |
@@ -532,58 +532,58 @@ discard block |
||
532 | 532 | //Therefore do not directly assign the value without __set |
533 | 533 | //set _important_props before that to be able to propagate. |
534 | 534 | //see __set and __get, on all assignments clear cache! |
535 | - //$this->_prop_cache[$prop] = null; |
|
536 | - //$this->_props[$prop] = $parent->_props[$prop]; |
|
535 | + //$this->_prop_cache[$prop] = null; |
|
536 | + //$this->_props[$prop] = $parent->_props[$prop]; |
|
537 | 537 | //props_set for more obvious explicite assignment not implemented, because |
538 | 538 | //too many implicite uses. |
539 | 539 | // $this->props_set($prop, $parent->$prop); |
540 | 540 | $this->$prop = $parent->$prop; |
541 | - } |
|
541 | + } |
|
542 | 542 | } |
543 | 543 | |
544 | 544 | return $this; |
545 | - } |
|
545 | + } |
|
546 | 546 | |
547 | 547 | |
548 | - /** |
|
549 | - * Override properties in this style with those in $style |
|
550 | - * |
|
551 | - * @param Style $style |
|
552 | - */ |
|
553 | - function merge(Style $style) { |
|
548 | + /** |
|
549 | + * Override properties in this style with those in $style |
|
550 | + * |
|
551 | + * @param Style $style |
|
552 | + */ |
|
553 | + function merge(Style $style) { |
|
554 | 554 | //treat the !important attribute |
555 | 555 | //if old rule has !important attribute, override with new rule only if |
556 | 556 | //the new rule is also !important |
557 | 557 | foreach($style->_props as $prop => $val ) { |
558 | - if (isset($style->_important_props[$prop])) { |
|
559 | - $this->_important_props[$prop] = true; |
|
558 | + if (isset($style->_important_props[$prop])) { |
|
559 | + $this->_important_props[$prop] = true; |
|
560 | 560 | //see __set and __get, on all assignments clear cache! |
561 | - $this->_prop_cache[$prop] = null; |
|
562 | - $this->_props[$prop] = $val; |
|
563 | - } else if ( !isset($this->_important_props[$prop]) ) { |
|
561 | + $this->_prop_cache[$prop] = null; |
|
562 | + $this->_props[$prop] = $val; |
|
563 | + } else if ( !isset($this->_important_props[$prop]) ) { |
|
564 | 564 | //see __set and __get, on all assignments clear cache! |
565 | - $this->_prop_cache[$prop] = null; |
|
566 | - $this->_props[$prop] = $val; |
|
567 | - } |
|
568 | - } |
|
565 | + $this->_prop_cache[$prop] = null; |
|
566 | + $this->_props[$prop] = $val; |
|
567 | + } |
|
568 | + } |
|
569 | 569 | |
570 | 570 | if ( isset($style->_props["font_size"]) ) |
571 | - $this->__font_size_calculated = false; |
|
572 | - } |
|
571 | + $this->__font_size_calculated = false; |
|
572 | + } |
|
573 | 573 | |
574 | 574 | |
575 | - /** |
|
576 | - * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb") |
|
577 | - * based on the provided CSS colour value. |
|
578 | - * |
|
579 | - * @param string $colour |
|
580 | - * @return array |
|
581 | - */ |
|
582 | - function munge_colour($colour) { |
|
575 | + /** |
|
576 | + * Returns an array(r, g, b, "r"=> r, "g"=>g, "b"=>b, "hex"=>"#rrggbb") |
|
577 | + * based on the provided CSS colour value. |
|
578 | + * |
|
579 | + * @param string $colour |
|
580 | + * @return array |
|
581 | + */ |
|
582 | + function munge_colour($colour) { |
|
583 | 583 | if ( is_array($colour) ) |
584 | - // Assume the array has the right format... |
|
585 | - // FIXME: should/could verify this. |
|
586 | - return $colour; |
|
584 | + // Assume the array has the right format... |
|
585 | + // FIXME: should/could verify this. |
|
586 | + return $colour; |
|
587 | 587 | |
588 | 588 | $r = 0; |
589 | 589 | $g = 0; |
@@ -594,78 +594,78 @@ discard block |
||
594 | 594 | |
595 | 595 | case "maroon": |
596 | 596 | $r = 0x80; |
597 | - break; |
|
597 | + break; |
|
598 | 598 | |
599 | 599 | case "red": |
600 | 600 | $r = 0xff; |
601 | - break; |
|
601 | + break; |
|
602 | 602 | |
603 | 603 | case "orange": |
604 | 604 | $r = 0xff; |
605 | - $g = 0xa5; |
|
606 | - break; |
|
605 | + $g = 0xa5; |
|
606 | + break; |
|
607 | 607 | |
608 | 608 | case "yellow": |
609 | 609 | $r = 0xff; |
610 | - $g = 0xff; |
|
611 | - break; |
|
610 | + $g = 0xff; |
|
611 | + break; |
|
612 | 612 | |
613 | 613 | case "olive": |
614 | 614 | $r = 0x80; |
615 | - $g = 0x80; |
|
616 | - break; |
|
615 | + $g = 0x80; |
|
616 | + break; |
|
617 | 617 | |
618 | 618 | case "purple": |
619 | 619 | $r = 0x80; |
620 | - $b = 0x80; |
|
621 | - break; |
|
620 | + $b = 0x80; |
|
621 | + break; |
|
622 | 622 | |
623 | 623 | case "fuchsia": |
624 | 624 | $r = 0xff; |
625 | - $b = 0xff; |
|
626 | - break; |
|
625 | + $b = 0xff; |
|
626 | + break; |
|
627 | 627 | |
628 | 628 | case "white": |
629 | 629 | $r = $g = $b = 0xff; |
630 | - break; |
|
630 | + break; |
|
631 | 631 | |
632 | 632 | case "lime": |
633 | 633 | $g = 0xff; |
634 | - break; |
|
634 | + break; |
|
635 | 635 | |
636 | 636 | case "green": |
637 | 637 | $g = 0x80; |
638 | - break; |
|
638 | + break; |
|
639 | 639 | |
640 | 640 | case "navy": |
641 | 641 | $b = 0x80; |
642 | - break; |
|
642 | + break; |
|
643 | 643 | |
644 | 644 | case "blue": |
645 | 645 | $b = 0xff; |
646 | - break; |
|
646 | + break; |
|
647 | 647 | |
648 | 648 | case "aqua": |
649 | 649 | $g = 0xff; |
650 | - $b = 0xff; |
|
651 | - break; |
|
650 | + $b = 0xff; |
|
651 | + break; |
|
652 | 652 | |
653 | 653 | case "teal": |
654 | 654 | $g = 0x80; |
655 | - $b = 0x80; |
|
656 | - break; |
|
655 | + $b = 0x80; |
|
656 | + break; |
|
657 | 657 | |
658 | 658 | case "black": |
659 | 659 | break; |
660 | 660 | |
661 | 661 | case "sliver": |
662 | 662 | $r = $g = $b = 0xc0; |
663 | - break; |
|
663 | + break; |
|
664 | 664 | |
665 | 665 | case "gray": |
666 | 666 | case "grey": |
667 | 667 | $r = $g = $b = 0x80; |
668 | - break; |
|
668 | + break; |
|
669 | 669 | |
670 | 670 | case "transparent": |
671 | 671 | return "transparent"; |
@@ -677,177 +677,177 @@ discard block |
||
677 | 677 | $g = hexdec($colour[2] . $colour[2]); |
678 | 678 | $b = hexdec($colour[3] . $colour[3]); |
679 | 679 | |
680 | - } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
680 | + } else if ( mb_strlen($colour) == 7 && $colour[0] === "#" ) { |
|
681 | 681 | // #rrggbb format |
682 | 682 | $r = hexdec(mb_substr($colour, 1, 2)); |
683 | 683 | $g = hexdec(mb_substr($colour, 3, 2)); |
684 | 684 | $b = hexdec(mb_substr($colour, 5, 2)); |
685 | 685 | |
686 | - } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
686 | + } else if ( mb_strpos($colour, "rgb") !== false ) { |
|
687 | 687 | // rgb( r,g,b ) format |
688 | 688 | $i = mb_strpos($colour, "("); |
689 | 689 | $j = mb_strpos($colour, ")"); |
690 | 690 | |
691 | 691 | // Bad colour value |
692 | 692 | if ($i === false || $j === false) |
693 | - return null; |
|
693 | + return null; |
|
694 | 694 | |
695 | 695 | $triplet = explode(",", mb_substr($colour, $i+1, $j-$i-1)); |
696 | 696 | |
697 | 697 | if (count($triplet) != 3) |
698 | - return null; |
|
698 | + return null; |
|
699 | 699 | |
700 | 700 | foreach (array_keys($triplet) as $c) { |
701 | - $triplet[$c] = trim($triplet[$c]); |
|
701 | + $triplet[$c] = trim($triplet[$c]); |
|
702 | 702 | |
703 | - if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
703 | + if ( $triplet[$c]{mb_strlen($triplet[$c]) - 1} === "%" ) |
|
704 | 704 | $triplet[$c] = round($triplet[$c] * 0.255); |
705 | 705 | } |
706 | 706 | |
707 | 707 | list($r, $g, $b) = $triplet; |
708 | 708 | |
709 | - } else { |
|
709 | + } else { |
|
710 | 710 | // Who knows? |
711 | 711 | return null; |
712 | - } |
|
712 | + } |
|
713 | 713 | |
714 | - // Clip to 0 - 1 |
|
715 | - $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
716 | - $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
717 | - $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
718 | - break; |
|
714 | + // Clip to 0 - 1 |
|
715 | + $r = $r < 0 ? 0 : ($r > 255 ? 255 : $r); |
|
716 | + $g = $g < 0 ? 0 : ($g > 255 ? 255 : $g); |
|
717 | + $b = $b < 0 ? 0 : ($b > 255 ? 255 : $b); |
|
718 | + break; |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
722 | 722 | // Form array |
723 | 723 | $arr = array(0 => $r / 0xff, 1 => $g / 0xff, 2 => $b / 0xff, |
724 | - "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff, |
|
725 | - "hex" => sprintf("#%02X%02X%02X", $r, $g, $b)); |
|
724 | + "r"=>$r / 0xff, "g"=>$g / 0xff, "b"=>$b / 0xff, |
|
725 | + "hex" => sprintf("#%02X%02X%02X", $r, $g, $b)); |
|
726 | 726 | return $arr; |
727 | 727 | |
728 | - } |
|
728 | + } |
|
729 | 729 | |
730 | 730 | |
731 | - /** |
|
732 | - * Alias for {@link Style::munge_colour()} |
|
733 | - * |
|
734 | - * @param string $color |
|
735 | - * @return array |
|
736 | - */ |
|
737 | - function munge_color($color) { return CSS_Color::parse($color); } |
|
738 | - |
|
739 | - /* direct access to _important_props array from outside would work only when declared as |
|
731 | + /** |
|
732 | + * Alias for {@link Style::munge_colour()} |
|
733 | + * |
|
734 | + * @param string $color |
|
735 | + * @return array |
|
736 | + */ |
|
737 | + function munge_color($color) { return CSS_Color::parse($color); } |
|
738 | + |
|
739 | + /* direct access to _important_props array from outside would work only when declared as |
|
740 | 740 | * 'var $_important_props;' instead of 'protected $_important_props;' |
741 | 741 | * Don't call _set/__get on missing attribute. Therefore need a special access. |
742 | 742 | * Assume that __set will be also called when this is called, so do not check validity again. |
743 | 743 | * Only created, if !important exists -> always set true. |
744 | 744 | */ |
745 | - function important_set($prop) { |
|
746 | - $prop = str_replace("-", "_", $prop); |
|
747 | - $this->_important_props[$prop] = true; |
|
748 | - } |
|
745 | + function important_set($prop) { |
|
746 | + $prop = str_replace("-", "_", $prop); |
|
747 | + $this->_important_props[$prop] = true; |
|
748 | + } |
|
749 | 749 | |
750 | - function important_get($prop) { |
|
751 | - isset($this->_important_props[$prop]); |
|
752 | - } |
|
750 | + function important_get($prop) { |
|
751 | + isset($this->_important_props[$prop]); |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * PHP5 overloaded setter |
|
756 | - * |
|
757 | - * This function along with {@link Style::__get()} permit a user of the |
|
758 | - * Style class to access any (CSS) property using the following syntax: |
|
759 | - * <code> |
|
760 | - * Style->margin_top = "1em"; |
|
761 | - * echo (Style->margin_top); |
|
762 | - * </code> |
|
763 | - * |
|
764 | - * __set() automatically calls the provided set function, if one exists, |
|
765 | - * otherwise it sets the property directly. Typically, __set() is not |
|
766 | - * called directly from outside of this class. |
|
767 | - * |
|
768 | - * On each modification clear cache to return accurate setting. |
|
769 | - * Also affects direct settings not using __set |
|
770 | - * For easier finding all assignments, attempted to allowing only explicite assignment: |
|
771 | - * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is |
|
772 | - * function __set($prop, $val) { |
|
773 | - * throw new DOMPDF_Exception("Implicite replacement of assignment by __set. Not good."); |
|
774 | - * } |
|
775 | - * function props_set($prop, $val) { ... } |
|
776 | - * |
|
777 | - * @param string $prop the property to set |
|
778 | - * @param mixed $val the value of the property |
|
779 | - * |
|
780 | - */ |
|
781 | - function __set($prop, $val) { |
|
754 | + /** |
|
755 | + * PHP5 overloaded setter |
|
756 | + * |
|
757 | + * This function along with {@link Style::__get()} permit a user of the |
|
758 | + * Style class to access any (CSS) property using the following syntax: |
|
759 | + * <code> |
|
760 | + * Style->margin_top = "1em"; |
|
761 | + * echo (Style->margin_top); |
|
762 | + * </code> |
|
763 | + * |
|
764 | + * __set() automatically calls the provided set function, if one exists, |
|
765 | + * otherwise it sets the property directly. Typically, __set() is not |
|
766 | + * called directly from outside of this class. |
|
767 | + * |
|
768 | + * On each modification clear cache to return accurate setting. |
|
769 | + * Also affects direct settings not using __set |
|
770 | + * For easier finding all assignments, attempted to allowing only explicite assignment: |
|
771 | + * Very many uses, e.g. frame_reflower.cls.php -> for now leave as it is |
|
772 | + * function __set($prop, $val) { |
|
773 | + * throw new DOMPDF_Exception("Implicite replacement of assignment by __set. Not good."); |
|
774 | + * } |
|
775 | + * function props_set($prop, $val) { ... } |
|
776 | + * |
|
777 | + * @param string $prop the property to set |
|
778 | + * @param mixed $val the value of the property |
|
779 | + * |
|
780 | + */ |
|
781 | + function __set($prop, $val) { |
|
782 | 782 | global $_dompdf_warnings; |
783 | 783 | |
784 | 784 | $prop = str_replace("-", "_", $prop); |
785 | 785 | $this->_prop_cache[$prop] = null; |
786 | 786 | |
787 | 787 | if ( !isset(self::$_defaults[$prop]) ) { |
788 | - $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property."; |
|
789 | - return; |
|
788 | + $_dompdf_warnings[] = "'$prop' is not a valid CSS2 property."; |
|
789 | + return; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | if ( $prop !== "content" && is_string($val) && mb_strpos($val, "url") === false ) { |
793 | - $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val))); |
|
794 | - $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val); |
|
793 | + $val = mb_strtolower(trim(str_replace(array("\n", "\t"), array(" "), $val))); |
|
794 | + $val = preg_replace("/([0-9]+) (pt|px|pc|em|ex|in|cm|mm|%)/S", "\\1\\2", $val); |
|
795 | 795 | } |
796 | 796 | |
797 | 797 | $method = "set_$prop"; |
798 | 798 | |
799 | 799 | if ( method_exists($this, $method) ) |
800 | - $this->$method($val); |
|
800 | + $this->$method($val); |
|
801 | 801 | else |
802 | - $this->_props[$prop] = $val; |
|
802 | + $this->_props[$prop] = $val; |
|
803 | 803 | |
804 | - } |
|
804 | + } |
|
805 | 805 | |
806 | - /** |
|
807 | - * PHP5 overloaded getter |
|
808 | - * |
|
809 | - * Along with {@link Style::__set()} __get() provides access to all CSS |
|
810 | - * properties directly. Typically __get() is not called directly outside |
|
811 | - * of this class. |
|
812 | - * |
|
813 | - * On each modification clear cache to return accurate setting. |
|
814 | - * Also affects direct settings not using __set |
|
815 | - * |
|
816 | - * @param string $prop |
|
817 | - * @return mixed |
|
818 | - */ |
|
819 | - function __get($prop) { |
|
806 | + /** |
|
807 | + * PHP5 overloaded getter |
|
808 | + * |
|
809 | + * Along with {@link Style::__set()} __get() provides access to all CSS |
|
810 | + * properties directly. Typically __get() is not called directly outside |
|
811 | + * of this class. |
|
812 | + * |
|
813 | + * On each modification clear cache to return accurate setting. |
|
814 | + * Also affects direct settings not using __set |
|
815 | + * |
|
816 | + * @param string $prop |
|
817 | + * @return mixed |
|
818 | + */ |
|
819 | + function __get($prop) { |
|
820 | 820 | |
821 | 821 | if ( !isset(self::$_defaults[$prop]) ) |
822 | - throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
822 | + throw new DOMPDF_Exception("'$prop' is not a valid CSS2 property."); |
|
823 | 823 | |
824 | 824 | if ( isset($this->_prop_cache[$prop]) && $this->_prop_cache[$prop] != null) |
825 | - return $this->_prop_cache[$prop]; |
|
825 | + return $this->_prop_cache[$prop]; |
|
826 | 826 | |
827 | 827 | $method = "get_$prop"; |
828 | 828 | |
829 | 829 | // Fall back on defaults if property is not set |
830 | 830 | if ( !isset($this->_props[$prop]) ) |
831 | - $this->_props[$prop] = self::$_defaults[$prop]; |
|
831 | + $this->_props[$prop] = self::$_defaults[$prop]; |
|
832 | 832 | |
833 | 833 | if ( method_exists($this, $method) ) |
834 | - return $this->_prop_cache[$prop] = $this->$method(); |
|
834 | + return $this->_prop_cache[$prop] = $this->$method(); |
|
835 | 835 | |
836 | 836 | |
837 | 837 | return $this->_prop_cache[$prop] = $this->_props[$prop]; |
838 | - } |
|
838 | + } |
|
839 | 839 | |
840 | 840 | |
841 | - /** |
|
842 | - * Getter for the 'font-family' CSS property. |
|
843 | - * |
|
844 | - * Uses the {@link Font_Metrics} class to resolve the font family into an |
|
845 | - * actual font file. |
|
846 | - * |
|
847 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family |
|
848 | - * @return string |
|
849 | - */ |
|
850 | - function get_font_family() { |
|
841 | + /** |
|
842 | + * Getter for the 'font-family' CSS property. |
|
843 | + * |
|
844 | + * Uses the {@link Font_Metrics} class to resolve the font family into an |
|
845 | + * actual font file. |
|
846 | + * |
|
847 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-family |
|
848 | + * @return string |
|
849 | + */ |
|
850 | + function get_font_family() { |
|
851 | 851 | |
852 | 852 | $DEBUGCSS=DEBUGCSS; //=DEBUGCSS; Allow override of global setting for ad hoc debug |
853 | 853 | |
@@ -859,16 +859,16 @@ discard block |
||
859 | 859 | |
860 | 860 | if ( is_numeric($weight) ) { |
861 | 861 | |
862 | - if ( $weight < 600 ) |
|
862 | + if ( $weight < 600 ) |
|
863 | 863 | $weight = "normal"; |
864 | - else |
|
864 | + else |
|
865 | 865 | $weight = "bold"; |
866 | 866 | |
867 | 867 | } else if ( $weight === "bold" || $weight === "bolder" ) { |
868 | - $weight = "bold"; |
|
868 | + $weight = "bold"; |
|
869 | 869 | |
870 | 870 | } else { |
871 | - $weight = "normal"; |
|
871 | + $weight = "normal"; |
|
872 | 872 | |
873 | 873 | } |
874 | 874 | |
@@ -876,18 +876,18 @@ discard block |
||
876 | 876 | $font_style = $this->__get("font_style"); |
877 | 877 | |
878 | 878 | if ( $weight === "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
879 | - $subtype = "bold_italic"; |
|
879 | + $subtype = "bold_italic"; |
|
880 | 880 | else if ( $weight === "bold" && $font_style !== "italic" && $font_style !== "oblique" ) |
881 | - $subtype = "bold"; |
|
881 | + $subtype = "bold"; |
|
882 | 882 | else if ( $weight !== "bold" && ($font_style === "italic" || $font_style === "oblique") ) |
883 | - $subtype = "italic"; |
|
883 | + $subtype = "italic"; |
|
884 | 884 | else |
885 | - $subtype = "normal"; |
|
885 | + $subtype = "normal"; |
|
886 | 886 | |
887 | 887 | // Resolve the font family |
888 | 888 | if ($DEBUGCSS) { |
889 | - print "<pre>[get_font_family:"; |
|
890 | - print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; |
|
889 | + print "<pre>[get_font_family:"; |
|
890 | + print '('.$this->_props["font_family"].'.'.$font_style.'.'.$this->__get("font_weight").'.'.$weight.'.'.$subtype.')'; |
|
891 | 891 | } |
892 | 892 | $families = explode(",", $this->_props["font_family"]); |
893 | 893 | $families = array_map('trim',$families); |
@@ -895,17 +895,17 @@ discard block |
||
895 | 895 | |
896 | 896 | $font = null; |
897 | 897 | while ( current($families) ) { |
898 | - list(,$family) = each($families); |
|
899 | - //remove leading and trailing string delimiters, e.g. on font names with spaces; |
|
900 | - //remove leading and trailing whitespace |
|
901 | - $family=trim($family," \t\n\r\x0B\"'"); |
|
902 | - if ($DEBUGCSS) print '('.$family.')'; |
|
903 | - $font = Font_Metrics::get_font($family, $subtype); |
|
904 | - |
|
905 | - if ( $font ) { |
|
898 | + list(,$family) = each($families); |
|
899 | + //remove leading and trailing string delimiters, e.g. on font names with spaces; |
|
900 | + //remove leading and trailing whitespace |
|
901 | + $family=trim($family," \t\n\r\x0B\"'"); |
|
902 | + if ($DEBUGCSS) print '('.$family.')'; |
|
903 | + $font = Font_Metrics::get_font($family, $subtype); |
|
904 | + |
|
905 | + if ( $font ) { |
|
906 | 906 | if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
907 | 907 | return $font; |
908 | - } |
|
908 | + } |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | $family = null; |
@@ -913,63 +913,63 @@ discard block |
||
913 | 913 | $font = Font_Metrics::get_font($family, $subtype); |
914 | 914 | |
915 | 915 | if ( $font ) { |
916 | - if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
917 | - return $font; |
|
916 | + if ($DEBUGCSS) print '('.$font.")get_font_family]\n</pre>"; |
|
917 | + return $font; |
|
918 | 918 | } |
919 | 919 | throw new DOMPDF_Exception("Unable to find a suitable font replacement for: '" . $this->_props["font_family"] ."'"); |
920 | 920 | |
921 | - } |
|
921 | + } |
|
922 | 922 | |
923 | - /** |
|
924 | - * Returns the resolved font size, in points |
|
925 | - * |
|
926 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
927 | - * @return float |
|
928 | - */ |
|
929 | - function get_font_size() { |
|
923 | + /** |
|
924 | + * Returns the resolved font size, in points |
|
925 | + * |
|
926 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
927 | + * @return float |
|
928 | + */ |
|
929 | + function get_font_size() { |
|
930 | 930 | |
931 | 931 | if ( $this->__font_size_calculated ) |
932 | - return $this->_props["font_size"]; |
|
932 | + return $this->_props["font_size"]; |
|
933 | 933 | |
934 | 934 | if ( !isset($this->_props["font_size"]) ) |
935 | - $fs = self::$_defaults["font_size"]; |
|
935 | + $fs = self::$_defaults["font_size"]; |
|
936 | 936 | else |
937 | - $fs = $this->_props["font_size"]; |
|
937 | + $fs = $this->_props["font_size"]; |
|
938 | 938 | |
939 | 939 | if ( !isset($this->_parent_font_size) ) |
940 | - $this->_parent_font_size = self::$default_font_size; |
|
940 | + $this->_parent_font_size = self::$default_font_size; |
|
941 | 941 | |
942 | 942 | switch ($fs) { |
943 | 943 | |
944 | 944 | case "xx-small": |
945 | 945 | $fs = 3/5 * $this->_parent_font_size; |
946 | - break; |
|
946 | + break; |
|
947 | 947 | |
948 | 948 | case "x-small": |
949 | 949 | $fs = 3/4 * $this->_parent_font_size; |
950 | - break; |
|
950 | + break; |
|
951 | 951 | |
952 | 952 | case "smaller": |
953 | 953 | case "small": |
954 | 954 | $fs = 8/9 * $this->_parent_font_size; |
955 | - break; |
|
955 | + break; |
|
956 | 956 | |
957 | 957 | case "medium": |
958 | 958 | $fs = $this->_parent_font_size; |
959 | - break; |
|
959 | + break; |
|
960 | 960 | |
961 | 961 | case "larger": |
962 | 962 | case "large": |
963 | 963 | $fs = 6/5 * $this->_parent_font_size; |
964 | - break; |
|
964 | + break; |
|
965 | 965 | |
966 | 966 | case "x-large": |
967 | 967 | $fs = 3/2 * $this->_parent_font_size; |
968 | - break; |
|
968 | + break; |
|
969 | 969 | |
970 | 970 | case "xx-large": |
971 | 971 | $fs = 2/1 * $this->_parent_font_size; |
972 | - break; |
|
972 | + break; |
|
973 | 973 | |
974 | 974 | default: |
975 | 975 | break; |
@@ -977,82 +977,82 @@ discard block |
||
977 | 977 | |
978 | 978 | // Ensure relative sizes resolve to something |
979 | 979 | if ( ($i = mb_strpos($fs, "em")) !== false ) |
980 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
980 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
981 | 981 | |
982 | 982 | else if ( ($i = mb_strpos($fs, "ex")) !== false ) |
983 | - $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
983 | + $fs = mb_substr($fs, 0, $i) * $this->_parent_font_size; |
|
984 | 984 | |
985 | 985 | else |
986 | - $fs = $this->length_in_pt($fs); |
|
986 | + $fs = $this->length_in_pt($fs); |
|
987 | 987 | |
988 | 988 | //see __set and __get, on all assignments clear cache! |
989 | - $this->_prop_cache["font_size"] = null; |
|
989 | + $this->_prop_cache["font_size"] = null; |
|
990 | 990 | $this->_props["font_size"] = $fs; |
991 | 991 | $this->__font_size_calculated = true; |
992 | 992 | return $this->_props["font_size"]; |
993 | 993 | |
994 | - } |
|
994 | + } |
|
995 | 995 | |
996 | - /** |
|
997 | - * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing |
|
998 | - * @return float |
|
999 | - */ |
|
1000 | - function get_word_spacing() { |
|
996 | + /** |
|
997 | + * @link http://www.w3.org/TR/CSS21/text.html#propdef-word-spacing |
|
998 | + * @return float |
|
999 | + */ |
|
1000 | + function get_word_spacing() { |
|
1001 | 1001 | if ( $this->_props["word_spacing"] === "normal" ) |
1002 | - return 0; |
|
1002 | + return 0; |
|
1003 | 1003 | |
1004 | 1004 | return $this->_props["word_spacing"]; |
1005 | - } |
|
1005 | + } |
|
1006 | 1006 | |
1007 | - /** |
|
1008 | - * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height |
|
1009 | - * @return float |
|
1010 | - */ |
|
1011 | - function get_line_height() { |
|
1007 | + /** |
|
1008 | + * @link http://www.w3.org/TR/CSS21/visudet.html#propdef-line-height |
|
1009 | + * @return float |
|
1010 | + */ |
|
1011 | + function get_line_height() { |
|
1012 | 1012 | if ( $this->_props["line_height"] === "normal" ) |
1013 | - return self::$default_line_height * $this->get_font_size(); |
|
1013 | + return self::$default_line_height * $this->get_font_size(); |
|
1014 | 1014 | |
1015 | 1015 | if ( is_numeric($this->_props["line_height"]) ) |
1016 | - return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
1016 | + return $this->length_in_pt( $this->_props["line_height"] . "%", $this->get_font_size()); |
|
1017 | 1017 | |
1018 | 1018 | return $this->length_in_pt( $this->_props["line_height"], $this->get_font_size() ); |
1019 | - } |
|
1019 | + } |
|
1020 | 1020 | |
1021 | - /** |
|
1022 | - * Returns the colour as an array |
|
1023 | - * |
|
1024 | - * The array has the following format: |
|
1025 | - * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code> |
|
1026 | - * |
|
1027 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
1028 | - * @return array |
|
1029 | - */ |
|
1030 | - function get_color() { |
|
1021 | + /** |
|
1022 | + * Returns the colour as an array |
|
1023 | + * |
|
1024 | + * The array has the following format: |
|
1025 | + * <code>array(r,g,b, "r" => r, "g" => g, "b" => b, "hex" => "#rrggbb")</code> |
|
1026 | + * |
|
1027 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
1028 | + * @return array |
|
1029 | + */ |
|
1030 | + function get_color() { |
|
1031 | 1031 | return $this->munge_color( $this->_props["color"] ); |
1032 | - } |
|
1032 | + } |
|
1033 | 1033 | |
1034 | - /** |
|
1035 | - * Returns the background colour as an array |
|
1036 | - * |
|
1037 | - * The returned array has the same format as {@link Style::get_color()} |
|
1038 | - * |
|
1039 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
1040 | - * @return array |
|
1041 | - */ |
|
1042 | - function get_background_color() { |
|
1034 | + /** |
|
1035 | + * Returns the background colour as an array |
|
1036 | + * |
|
1037 | + * The returned array has the same format as {@link Style::get_color()} |
|
1038 | + * |
|
1039 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
1040 | + * @return array |
|
1041 | + */ |
|
1042 | + function get_background_color() { |
|
1043 | 1043 | return $this->munge_color( $this->_props["background_color"] ); |
1044 | - } |
|
1044 | + } |
|
1045 | 1045 | |
1046 | - /** |
|
1047 | - * Returns the background position as an array |
|
1048 | - * |
|
1049 | - * The returned array has the following format: |
|
1050 | - * <code>array(x,y, "x" => x, "y" => y)</code> |
|
1051 | - * |
|
1052 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
1053 | - * @return array |
|
1054 | - */ |
|
1055 | - function get_background_position() { |
|
1046 | + /** |
|
1047 | + * Returns the background position as an array |
|
1048 | + * |
|
1049 | + * The returned array has the following format: |
|
1050 | + * <code>array(x,y, "x" => x, "y" => y)</code> |
|
1051 | + * |
|
1052 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
1053 | + * @return array |
|
1054 | + */ |
|
1055 | + function get_background_position() { |
|
1056 | 1056 | |
1057 | 1057 | $tmp = explode(" ", $this->_props["background_position"]); |
1058 | 1058 | |
@@ -1060,119 +1060,119 @@ discard block |
||
1060 | 1060 | |
1061 | 1061 | case "left": |
1062 | 1062 | $x = "0%"; |
1063 | - break; |
|
1063 | + break; |
|
1064 | 1064 | |
1065 | 1065 | case "right": |
1066 | 1066 | $x = "100%"; |
1067 | - break; |
|
1067 | + break; |
|
1068 | 1068 | |
1069 | 1069 | case "top": |
1070 | 1070 | $y = "0%"; |
1071 | - break; |
|
1071 | + break; |
|
1072 | 1072 | |
1073 | 1073 | case "bottom": |
1074 | 1074 | $y = "100%"; |
1075 | - break; |
|
1075 | + break; |
|
1076 | 1076 | |
1077 | 1077 | case "center": |
1078 | 1078 | $x = "50%"; |
1079 | - $y = "50%"; |
|
1080 | - break; |
|
1079 | + $y = "50%"; |
|
1080 | + break; |
|
1081 | 1081 | |
1082 | 1082 | default: |
1083 | 1083 | $x = $tmp[0]; |
1084 | - break; |
|
1084 | + break; |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | if ( isset($tmp[1]) ) { |
1088 | 1088 | |
1089 | - switch ($tmp[1]) { |
|
1090 | - case "left": |
|
1089 | + switch ($tmp[1]) { |
|
1090 | + case "left": |
|
1091 | 1091 | $x = "0%"; |
1092 | 1092 | break; |
1093 | 1093 | |
1094 | - case "right": |
|
1094 | + case "right": |
|
1095 | 1095 | $x = "100%"; |
1096 | 1096 | break; |
1097 | 1097 | |
1098 | - case "top": |
|
1098 | + case "top": |
|
1099 | 1099 | $y = "0%"; |
1100 | 1100 | break; |
1101 | 1101 | |
1102 | - case "bottom": |
|
1102 | + case "bottom": |
|
1103 | 1103 | $y = "100%"; |
1104 | 1104 | break; |
1105 | 1105 | |
1106 | - case "center": |
|
1106 | + case "center": |
|
1107 | 1107 | if ( $tmp[0] === "left" || $tmp[0] === "right" || $tmp[0] === "center" ) |
1108 | - $y = "50%"; |
|
1108 | + $y = "50%"; |
|
1109 | 1109 | else |
1110 | - $x = "50%"; |
|
1110 | + $x = "50%"; |
|
1111 | 1111 | break; |
1112 | 1112 | |
1113 | - default: |
|
1113 | + default: |
|
1114 | 1114 | $y = $tmp[1]; |
1115 | 1115 | break; |
1116 | - } |
|
1116 | + } |
|
1117 | 1117 | |
1118 | 1118 | } else { |
1119 | - $y = "50%"; |
|
1119 | + $y = "50%"; |
|
1120 | 1120 | } |
1121 | 1121 | |
1122 | 1122 | if ( !isset($x) ) |
1123 | - $x = "0%"; |
|
1123 | + $x = "0%"; |
|
1124 | 1124 | |
1125 | 1125 | if ( !isset($y) ) |
1126 | - $y = "0%"; |
|
1126 | + $y = "0%"; |
|
1127 | 1127 | |
1128 | 1128 | return array( 0 => $x, "x" => $x, |
1129 | - 1 => $y, "y" => $y ); |
|
1130 | - } |
|
1129 | + 1 => $y, "y" => $y ); |
|
1130 | + } |
|
1131 | 1131 | |
1132 | 1132 | |
1133 | - /** |
|
1134 | - * Returns the background as it is currently stored |
|
1135 | - * |
|
1136 | - * (currently anyway only for completeness. |
|
1137 | - * not used for further processing) |
|
1138 | - * |
|
1139 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
1140 | - * @return string |
|
1141 | - */ |
|
1142 | - function get_background_attachment() { |
|
1133 | + /** |
|
1134 | + * Returns the background as it is currently stored |
|
1135 | + * |
|
1136 | + * (currently anyway only for completeness. |
|
1137 | + * not used for further processing) |
|
1138 | + * |
|
1139 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
1140 | + * @return string |
|
1141 | + */ |
|
1142 | + function get_background_attachment() { |
|
1143 | 1143 | return $this->_props["background_attachment"]; |
1144 | - } |
|
1144 | + } |
|
1145 | 1145 | |
1146 | 1146 | |
1147 | - /** |
|
1148 | - * Returns the background_repeat as it is currently stored |
|
1149 | - * |
|
1150 | - * (currently anyway only for completeness. |
|
1151 | - * not used for further processing) |
|
1152 | - * |
|
1153 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
1154 | - * @return string |
|
1155 | - */ |
|
1156 | - function get_background_repeat() { |
|
1147 | + /** |
|
1148 | + * Returns the background_repeat as it is currently stored |
|
1149 | + * |
|
1150 | + * (currently anyway only for completeness. |
|
1151 | + * not used for further processing) |
|
1152 | + * |
|
1153 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
1154 | + * @return string |
|
1155 | + */ |
|
1156 | + function get_background_repeat() { |
|
1157 | 1157 | return $this->_props["background_repeat"]; |
1158 | - } |
|
1158 | + } |
|
1159 | 1159 | |
1160 | 1160 | |
1161 | - /** |
|
1162 | - * Returns the background as it is currently stored |
|
1163 | - * |
|
1164 | - * (currently anyway only for completeness. |
|
1165 | - * not used for further processing, but the individual get_background_xxx) |
|
1166 | - * |
|
1167 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
1168 | - * @return string |
|
1169 | - */ |
|
1170 | - function get_background() { |
|
1161 | + /** |
|
1162 | + * Returns the background as it is currently stored |
|
1163 | + * |
|
1164 | + * (currently anyway only for completeness. |
|
1165 | + * not used for further processing, but the individual get_background_xxx) |
|
1166 | + * |
|
1167 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
1168 | + * @return string |
|
1169 | + */ |
|
1170 | + function get_background() { |
|
1171 | 1171 | return $this->_props["background"]; |
1172 | - } |
|
1172 | + } |
|
1173 | 1173 | |
1174 | 1174 | |
1175 | - /**#@+ |
|
1175 | + /**#@+ |
|
1176 | 1176 | * Returns the border colour as an array |
1177 | 1177 | * |
1178 | 1178 | * See {@link Style::get_color()} |
@@ -1180,112 +1180,112 @@ discard block |
||
1180 | 1180 | * @link http://www.w3.org/TR/CSS21/box.html#border-color-properties |
1181 | 1181 | * @return array |
1182 | 1182 | */ |
1183 | - function get_border_top_color() { |
|
1183 | + function get_border_top_color() { |
|
1184 | 1184 | if ( $this->_props["border_top_color"] === "" ) { |
1185 | - //see __set and __get, on all assignments clear cache! |
|
1186 | - $this->_prop_cache["border_top_color"] = null; |
|
1187 | - $this->_props["border_top_color"] = $this->__get("color"); |
|
1185 | + //see __set and __get, on all assignments clear cache! |
|
1186 | + $this->_prop_cache["border_top_color"] = null; |
|
1187 | + $this->_props["border_top_color"] = $this->__get("color"); |
|
1188 | 1188 | } |
1189 | 1189 | return $this->munge_color($this->_props["border_top_color"]); |
1190 | - } |
|
1190 | + } |
|
1191 | 1191 | |
1192 | - function get_border_right_color() { |
|
1192 | + function get_border_right_color() { |
|
1193 | 1193 | if ( $this->_props["border_right_color"] === "" ) { |
1194 | - //see __set and __get, on all assignments clear cache! |
|
1195 | - $this->_prop_cache["border_right_color"] = null; |
|
1196 | - $this->_props["border_right_color"] = $this->__get("color"); |
|
1194 | + //see __set and __get, on all assignments clear cache! |
|
1195 | + $this->_prop_cache["border_right_color"] = null; |
|
1196 | + $this->_props["border_right_color"] = $this->__get("color"); |
|
1197 | 1197 | } |
1198 | 1198 | return $this->munge_color($this->_props["border_right_color"]); |
1199 | - } |
|
1199 | + } |
|
1200 | 1200 | |
1201 | - function get_border_bottom_color() { |
|
1201 | + function get_border_bottom_color() { |
|
1202 | 1202 | if ( $this->_props["border_bottom_color"] === "" ) { |
1203 | - //see __set and __get, on all assignments clear cache! |
|
1204 | - $this->_prop_cache["border_bottom_color"] = null; |
|
1205 | - $this->_props["border_bottom_color"] = $this->__get("color"); |
|
1203 | + //see __set and __get, on all assignments clear cache! |
|
1204 | + $this->_prop_cache["border_bottom_color"] = null; |
|
1205 | + $this->_props["border_bottom_color"] = $this->__get("color"); |
|
1206 | 1206 | } |
1207 | 1207 | return $this->munge_color($this->_props["border_bottom_color"]);; |
1208 | - } |
|
1208 | + } |
|
1209 | 1209 | |
1210 | - function get_border_left_color() { |
|
1210 | + function get_border_left_color() { |
|
1211 | 1211 | if ( $this->_props["border_left_color"] === "" ) { |
1212 | - //see __set and __get, on all assignments clear cache! |
|
1213 | - $this->_prop_cache["border_left_color"] = null; |
|
1214 | - $this->_props["border_left_color"] = $this->__get("color"); |
|
1212 | + //see __set and __get, on all assignments clear cache! |
|
1213 | + $this->_prop_cache["border_left_color"] = null; |
|
1214 | + $this->_props["border_left_color"] = $this->__get("color"); |
|
1215 | 1215 | } |
1216 | 1216 | return $this->munge_color($this->_props["border_left_color"]); |
1217 | - } |
|
1217 | + } |
|
1218 | 1218 | |
1219 | - /**#@-*/ |
|
1219 | + /**#@-*/ |
|
1220 | 1220 | |
1221 | - /**#@+ |
|
1221 | + /**#@+ |
|
1222 | 1222 | * Returns the border width, as it is currently stored |
1223 | 1223 | * |
1224 | 1224 | * @link http://www.w3.org/TR/CSS21/box.html#border-width-properties |
1225 | 1225 | * @return float|string |
1226 | 1226 | */ |
1227 | - function get_border_top_width() { |
|
1227 | + function get_border_top_width() { |
|
1228 | 1228 | $style = $this->__get("border_top_style"); |
1229 | 1229 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_top_width"]) : 0; |
1230 | - } |
|
1230 | + } |
|
1231 | 1231 | |
1232 | - function get_border_right_width() { |
|
1232 | + function get_border_right_width() { |
|
1233 | 1233 | $style = $this->__get("border_right_style"); |
1234 | 1234 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_right_width"]) : 0; |
1235 | - } |
|
1235 | + } |
|
1236 | 1236 | |
1237 | - function get_border_bottom_width() { |
|
1237 | + function get_border_bottom_width() { |
|
1238 | 1238 | $style = $this->__get("border_bottom_style"); |
1239 | 1239 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_bottom_width"]) : 0; |
1240 | - } |
|
1240 | + } |
|
1241 | 1241 | |
1242 | - function get_border_left_width() { |
|
1242 | + function get_border_left_width() { |
|
1243 | 1243 | $style = $this->__get("border_left_style"); |
1244 | 1244 | return $style !== "none" && $style !== "hidden" ? $this->length_in_pt($this->_props["border_left_width"]) : 0; |
1245 | - } |
|
1246 | - /**#@-*/ |
|
1247 | - |
|
1248 | - /** |
|
1249 | - * Return an array of all border properties. |
|
1250 | - * |
|
1251 | - * The returned array has the following structure: |
|
1252 | - * <code> |
|
1253 | - * array("top" => array("width" => [border-width], |
|
1254 | - * "style" => [border-style], |
|
1255 | - * "color" => [border-color (array)]), |
|
1256 | - * "bottom" ... ) |
|
1257 | - * </code> |
|
1258 | - * |
|
1259 | - * @return array |
|
1260 | - */ |
|
1261 | - function get_border_properties() { |
|
1245 | + } |
|
1246 | + /**#@-*/ |
|
1247 | + |
|
1248 | + /** |
|
1249 | + * Return an array of all border properties. |
|
1250 | + * |
|
1251 | + * The returned array has the following structure: |
|
1252 | + * <code> |
|
1253 | + * array("top" => array("width" => [border-width], |
|
1254 | + * "style" => [border-style], |
|
1255 | + * "color" => [border-color (array)]), |
|
1256 | + * "bottom" ... ) |
|
1257 | + * </code> |
|
1258 | + * |
|
1259 | + * @return array |
|
1260 | + */ |
|
1261 | + function get_border_properties() { |
|
1262 | 1262 | return array("top" => array("width" => $this->__get("border_top_width"), |
1263 | 1263 | "style" => $this->__get("border_top_style"), |
1264 | 1264 | "color" => $this->__get("border_top_color")), |
1265 | - "bottom" => array("width" => $this->__get("border_bottom_width"), |
|
1266 | - "style" => $this->__get("border_bottom_style"), |
|
1267 | - "color" => $this->__get("border_bottom_color")), |
|
1268 | - "right" => array("width" => $this->__get("border_right_width"), |
|
1269 | - "style" => $this->__get("border_right_style"), |
|
1270 | - "color" => $this->__get("border_right_color")), |
|
1271 | - "left" => array("width" => $this->__get("border_left_width"), |
|
1272 | - "style" => $this->__get("border_left_style"), |
|
1273 | - "color" => $this->__get("border_left_color"))); |
|
1274 | - } |
|
1275 | - |
|
1276 | - /** |
|
1277 | - * Return a single border property |
|
1278 | - * |
|
1279 | - * @return mixed |
|
1280 | - */ |
|
1281 | - protected function _get_border($side) { |
|
1265 | + "bottom" => array("width" => $this->__get("border_bottom_width"), |
|
1266 | + "style" => $this->__get("border_bottom_style"), |
|
1267 | + "color" => $this->__get("border_bottom_color")), |
|
1268 | + "right" => array("width" => $this->__get("border_right_width"), |
|
1269 | + "style" => $this->__get("border_right_style"), |
|
1270 | + "color" => $this->__get("border_right_color")), |
|
1271 | + "left" => array("width" => $this->__get("border_left_width"), |
|
1272 | + "style" => $this->__get("border_left_style"), |
|
1273 | + "color" => $this->__get("border_left_color"))); |
|
1274 | + } |
|
1275 | + |
|
1276 | + /** |
|
1277 | + * Return a single border property |
|
1278 | + * |
|
1279 | + * @return mixed |
|
1280 | + */ |
|
1281 | + protected function _get_border($side) { |
|
1282 | 1282 | $color = $this->__get("border_" . $side . "_color"); |
1283 | 1283 | |
1284 | 1284 | return $this->__get("border_" . $side . "_width") . " " . |
1285 | - $this->__get("border_" . $side . "_style") . " " . $color["hex"]; |
|
1286 | - } |
|
1285 | + $this->__get("border_" . $side . "_style") . " " . $color["hex"]; |
|
1286 | + } |
|
1287 | 1287 | |
1288 | - /**#@+ |
|
1288 | + /**#@+ |
|
1289 | 1289 | * Return full border properties as a string |
1290 | 1290 | * |
1291 | 1291 | * Border properties are returned just as specified in CSS: |
@@ -1295,28 +1295,28 @@ discard block |
||
1295 | 1295 | * @link http://www.w3.org/TR/CSS21/box.html#border-shorthand-properties |
1296 | 1296 | * @return string |
1297 | 1297 | */ |
1298 | - function get_border_top() { return $this->_get_border("top"); } |
|
1299 | - function get_border_right() { return $this->_get_border("right"); } |
|
1300 | - function get_border_bottom() { return $this->_get_border("bottom"); } |
|
1301 | - function get_border_left() { return $this->_get_border("left"); } |
|
1302 | - /**#@-*/ |
|
1303 | - |
|
1304 | - |
|
1305 | - /** |
|
1306 | - * Returns border spacing as an array |
|
1307 | - * |
|
1308 | - * The array has the format (h_space,v_space) |
|
1309 | - * |
|
1310 | - * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing |
|
1311 | - * @return array |
|
1312 | - */ |
|
1313 | - function get_border_spacing() { |
|
1298 | + function get_border_top() { return $this->_get_border("top"); } |
|
1299 | + function get_border_right() { return $this->_get_border("right"); } |
|
1300 | + function get_border_bottom() { return $this->_get_border("bottom"); } |
|
1301 | + function get_border_left() { return $this->_get_border("left"); } |
|
1302 | + /**#@-*/ |
|
1303 | + |
|
1304 | + |
|
1305 | + /** |
|
1306 | + * Returns border spacing as an array |
|
1307 | + * |
|
1308 | + * The array has the format (h_space,v_space) |
|
1309 | + * |
|
1310 | + * @link http://www.w3.org/TR/CSS21/tables.html#propdef-border-spacing |
|
1311 | + * @return array |
|
1312 | + */ |
|
1313 | + function get_border_spacing() { |
|
1314 | 1314 | return explode(" ", $this->_props["border_spacing"]); |
1315 | - } |
|
1315 | + } |
|
1316 | 1316 | |
1317 | 1317 | /*==============================*/ |
1318 | 1318 | |
1319 | - /* |
|
1319 | + /* |
|
1320 | 1320 | !important attribute |
1321 | 1321 | For basic functionality of the !important attribute with overloading |
1322 | 1322 | of several styles of an element, changes in inherit(), merge() and _parse_properties() |
@@ -1358,419 +1358,419 @@ discard block |
||
1358 | 1358 | Related functionality for background, padding, margin, font, list_style |
1359 | 1359 | */ |
1360 | 1360 | |
1361 | - /* Generalized set function for individual attribute of combined style. |
|
1361 | + /* Generalized set function for individual attribute of combined style. |
|
1362 | 1362 | * With check for !important |
1363 | 1363 | * Applicable for background, border, padding, margin, font, list_style |
1364 | 1364 | * Note: $type has a leading underscore (or is empty), the others not. |
1365 | 1365 | */ |
1366 | - protected function _set_style_side_type($style,$side,$type,$val,$important) { |
|
1366 | + protected function _set_style_side_type($style,$side,$type,$val,$important) { |
|
1367 | 1367 | if ( !isset($this->_important_props[$style.'_'.$side.$type]) || $important) { |
1368 | - //see __set and __get, on all assignments clear cache! |
|
1369 | - $this->_prop_cache[$style.'_'.$side.$type] = null; |
|
1370 | - if ($important) { |
|
1368 | + //see __set and __get, on all assignments clear cache! |
|
1369 | + $this->_prop_cache[$style.'_'.$side.$type] = null; |
|
1370 | + if ($important) { |
|
1371 | 1371 | $this->_important_props[$style.'_'.$side.$type] = true; |
1372 | - } |
|
1373 | - $this->_props[$style.'_'.$side.$type] = $val; |
|
1372 | + } |
|
1373 | + $this->_props[$style.'_'.$side.$type] = $val; |
|
1374 | + } |
|
1374 | 1375 | } |
1375 | - } |
|
1376 | 1376 | |
1377 | - protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) { |
|
1378 | - $this->_set_style_side_type($style,'top',$type,$top,$important); |
|
1379 | - $this->_set_style_side_type($style,'right',$type,$right,$important); |
|
1380 | - $this->_set_style_side_type($style,'bottom',$type,$bottom,$important); |
|
1381 | - $this->_set_style_side_type($style,'left',$type,$left,$important); |
|
1382 | - } |
|
1377 | + protected function _set_style_sides_type($style,$top,$right,$bottom,$left,$type,$important) { |
|
1378 | + $this->_set_style_side_type($style,'top',$type,$top,$important); |
|
1379 | + $this->_set_style_side_type($style,'right',$type,$right,$important); |
|
1380 | + $this->_set_style_side_type($style,'bottom',$type,$bottom,$important); |
|
1381 | + $this->_set_style_side_type($style,'left',$type,$left,$important); |
|
1382 | + } |
|
1383 | 1383 | |
1384 | - protected function _set_style_type($style,$type,$val,$important) { |
|
1384 | + protected function _set_style_type($style,$type,$val,$important) { |
|
1385 | 1385 | $arr = explode(" ", $val); |
1386 | 1386 | switch (count($arr)) { |
1387 | 1387 | case 1: |
1388 | 1388 | $this->_set_style_sides_type($style,$arr[0],$arr[0],$arr[0],$arr[0],$type,$important); |
1389 | - break; |
|
1389 | + break; |
|
1390 | 1390 | case 2: |
1391 | 1391 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[0],$arr[1],$type,$important); |
1392 | - break; |
|
1392 | + break; |
|
1393 | 1393 | case 3: |
1394 | 1394 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[1],$arr[2],$type,$important); |
1395 | - break; |
|
1395 | + break; |
|
1396 | 1396 | case 4: |
1397 | 1397 | $this->_set_style_sides_type($style,$arr[0],$arr[1],$arr[2],$arr[3],$type,$important); |
1398 | - break; |
|
1398 | + break; |
|
1399 | 1399 | default: |
1400 | 1400 | break; |
1401 | 1401 | } |
1402 | 1402 | //see __set and __get, on all assignments clear cache! |
1403 | - $this->_prop_cache[$style.$type] = null; |
|
1403 | + $this->_prop_cache[$style.$type] = null; |
|
1404 | 1404 | $this->_props[$style.$type] = $val; |
1405 | - } |
|
1405 | + } |
|
1406 | 1406 | |
1407 | - protected function _set_style_type_important($style,$type,$val) { |
|
1407 | + protected function _set_style_type_important($style,$type,$val) { |
|
1408 | 1408 | $this->_set_style_type($style,$type,$val,isset($this->_important_props[$style.$type])); |
1409 | - } |
|
1409 | + } |
|
1410 | 1410 | |
1411 | - /* Anyway only called if _important matches and is assigned |
|
1411 | + /* Anyway only called if _important matches and is assigned |
|
1412 | 1412 | * E.g. _set_style_side_type($style,$side,'',str_replace("none", "0px", $val),isset($this->_important_props[$style.'_'.$side])); |
1413 | 1413 | */ |
1414 | - protected function _set_style_side_width_important($style,$side,$val) { |
|
1414 | + protected function _set_style_side_width_important($style,$side,$val) { |
|
1415 | 1415 | //see __set and __get, on all assignments clear cache! |
1416 | 1416 | $this->_prop_cache[$style.'_'.$side] = null; |
1417 | 1417 | $this->_props[$style.'_'.$side] = str_replace("none", "0px", $val); |
1418 | - } |
|
1418 | + } |
|
1419 | 1419 | |
1420 | - protected function _set_style($style,$val,$important) { |
|
1420 | + protected function _set_style($style,$val,$important) { |
|
1421 | 1421 | if ( !isset($this->_important_props[$style]) || $important) { |
1422 | - if ($important) { |
|
1422 | + if ($important) { |
|
1423 | 1423 | $this->_important_props[$style] = true; |
1424 | - } |
|
1425 | - //see __set and __get, on all assignments clear cache! |
|
1426 | - $this->_prop_cache[$style] = null; |
|
1427 | - $this->_props[$style] = $val; |
|
1424 | + } |
|
1425 | + //see __set and __get, on all assignments clear cache! |
|
1426 | + $this->_prop_cache[$style] = null; |
|
1427 | + $this->_props[$style] = $val; |
|
1428 | + } |
|
1428 | 1429 | } |
1429 | - } |
|
1430 | 1430 | |
1431 | - protected function _image($val) { |
|
1431 | + protected function _image($val) { |
|
1432 | 1432 | $DEBUGCSS=DEBUGCSS; |
1433 | 1433 | |
1434 | 1434 | if ( mb_strpos($val, "url") === false ) { |
1435 | - $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
1435 | + $path = "none"; //Don't resolve no image -> otherwise would prefix path and no longer recognize as none |
|
1436 | 1436 | } else { |
1437 | - $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
1437 | + $val = preg_replace("/url\(['\"]?([^'\")]+)['\"]?\)/","\\1", trim($val)); |
|
1438 | 1438 | |
1439 | - // Resolve the url now in the context of the current stylesheet |
|
1440 | - $parsed_url = explode_url($val); |
|
1441 | - if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) { |
|
1439 | + // Resolve the url now in the context of the current stylesheet |
|
1440 | + $parsed_url = explode_url($val); |
|
1441 | + if ( $parsed_url["protocol"] == "" && $this->_stylesheet->get_protocol() == "" ) { |
|
1442 | 1442 | if ($parsed_url["path"]{0} === '/' || $parsed_url["path"]{0} === '\\' ) { |
1443 | - $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
1443 | + $path = $_SERVER["DOCUMENT_ROOT"].'/'; |
|
1444 | 1444 | } else { |
1445 | - $path = $this->_stylesheet->get_base_path(); |
|
1445 | + $path = $this->_stylesheet->get_base_path(); |
|
1446 | 1446 | } |
1447 | 1447 | $path .= $parsed_url["path"] . $parsed_url["file"]; |
1448 | 1448 | $path = realpath($path); |
1449 | 1449 | // If realpath returns FALSE then specifically state that there is no background image |
1450 | 1450 | if (!$path) { $path = 'none'; } |
1451 | - } else { |
|
1451 | + } else { |
|
1452 | 1452 | $path = build_url($this->_stylesheet->get_protocol(), |
1453 | - $this->_stylesheet->get_host(), |
|
1454 | - $this->_stylesheet->get_base_path(), |
|
1455 | - $val); |
|
1456 | - } |
|
1453 | + $this->_stylesheet->get_host(), |
|
1454 | + $this->_stylesheet->get_base_path(), |
|
1455 | + $val); |
|
1456 | + } |
|
1457 | 1457 | } |
1458 | 1458 | if ($DEBUGCSS) { |
1459 | - print "<pre>[_image\n"; |
|
1460 | - print_r($parsed_url); |
|
1461 | - print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n"; |
|
1462 | - print "_image]</pre>";; |
|
1459 | + print "<pre>[_image\n"; |
|
1460 | + print_r($parsed_url); |
|
1461 | + print $this->_stylesheet->get_protocol()."\n".$this->_stylesheet->get_base_path()."\n".$path."\n"; |
|
1462 | + print "_image]</pre>";; |
|
1463 | 1463 | } |
1464 | 1464 | return $path; |
1465 | - } |
|
1465 | + } |
|
1466 | 1466 | |
1467 | 1467 | /*======================*/ |
1468 | 1468 | |
1469 | - /** |
|
1470 | - * Sets colour |
|
1471 | - * |
|
1472 | - * The colour parameter can be any valid CSS colour value |
|
1473 | - * |
|
1474 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
1475 | - * @param string $colour |
|
1476 | - */ |
|
1477 | - function set_color($colour) { |
|
1469 | + /** |
|
1470 | + * Sets colour |
|
1471 | + * |
|
1472 | + * The colour parameter can be any valid CSS colour value |
|
1473 | + * |
|
1474 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-color |
|
1475 | + * @param string $colour |
|
1476 | + */ |
|
1477 | + function set_color($colour) { |
|
1478 | 1478 | $col = $this->munge_colour($colour); |
1479 | 1479 | |
1480 | 1480 | if ( is_null($col) ) |
1481 | - $col = self::$_defaults["color"]; |
|
1481 | + $col = self::$_defaults["color"]; |
|
1482 | 1482 | |
1483 | 1483 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1484 | - $this->_prop_cache["color"] = null; |
|
1484 | + $this->_prop_cache["color"] = null; |
|
1485 | 1485 | $this->_props["color"] = $col["hex"]; |
1486 | - } |
|
1486 | + } |
|
1487 | 1487 | |
1488 | - /** |
|
1489 | - * Sets the background colour |
|
1490 | - * |
|
1491 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
1492 | - * @param string $colour |
|
1493 | - */ |
|
1494 | - function set_background_color($colour) { |
|
1488 | + /** |
|
1489 | + * Sets the background colour |
|
1490 | + * |
|
1491 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-color |
|
1492 | + * @param string $colour |
|
1493 | + */ |
|
1494 | + function set_background_color($colour) { |
|
1495 | 1495 | $col = $this->munge_colour($colour); |
1496 | 1496 | if ( is_null($col) ) |
1497 | - $col = self::$_defaults["background_color"]; |
|
1497 | + $col = self::$_defaults["background_color"]; |
|
1498 | 1498 | |
1499 | 1499 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1500 | - $this->_prop_cache["background_color"] = null; |
|
1500 | + $this->_prop_cache["background_color"] = null; |
|
1501 | 1501 | $this->_props["background_color"] = is_array($col) ? $col["hex"] : $col; |
1502 | - } |
|
1502 | + } |
|
1503 | 1503 | |
1504 | - /** |
|
1505 | - * Set the background image url |
|
1506 | - * |
|
1507 | - * @link http://www.w3.org/TR/CSS21/colors.html#background-properties |
|
1508 | - * @param string $url |
|
1509 | - */ |
|
1510 | - function set_background_image($val) { |
|
1504 | + /** |
|
1505 | + * Set the background image url |
|
1506 | + * |
|
1507 | + * @link http://www.w3.org/TR/CSS21/colors.html#background-properties |
|
1508 | + * @param string $url |
|
1509 | + */ |
|
1510 | + function set_background_image($val) { |
|
1511 | 1511 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1512 | - $this->_prop_cache["background_image"] = null; |
|
1512 | + $this->_prop_cache["background_image"] = null; |
|
1513 | 1513 | $this->_props["background_image"] = $this->_image($val); |
1514 | - } |
|
1514 | + } |
|
1515 | 1515 | |
1516 | - /** |
|
1517 | - * Sets the background repeat |
|
1518 | - * |
|
1519 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
1520 | - * @param string $val |
|
1521 | - */ |
|
1522 | - function set_background_repeat($val) { |
|
1516 | + /** |
|
1517 | + * Sets the background repeat |
|
1518 | + * |
|
1519 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-repeat |
|
1520 | + * @param string $val |
|
1521 | + */ |
|
1522 | + function set_background_repeat($val) { |
|
1523 | 1523 | if ( is_null($val) ) |
1524 | - $val = self::$_defaults["background_repeat"]; |
|
1524 | + $val = self::$_defaults["background_repeat"]; |
|
1525 | 1525 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1526 | 1526 | $this->_prop_cache["background_repeat"] = null; |
1527 | 1527 | $this->_props["background_repeat"] = $val; |
1528 | - } |
|
1528 | + } |
|
1529 | 1529 | |
1530 | - /** |
|
1531 | - * Sets the background attachment |
|
1532 | - * |
|
1533 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
1534 | - * @param string $val |
|
1535 | - */ |
|
1536 | - function set_background_attachment($val) { |
|
1530 | + /** |
|
1531 | + * Sets the background attachment |
|
1532 | + * |
|
1533 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-attachment |
|
1534 | + * @param string $val |
|
1535 | + */ |
|
1536 | + function set_background_attachment($val) { |
|
1537 | 1537 | if ( is_null($val) ) |
1538 | - $val = self::$_defaults["background_attachment"]; |
|
1538 | + $val = self::$_defaults["background_attachment"]; |
|
1539 | 1539 | |
1540 | 1540 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1541 | - $this->_prop_cache["background_attachment"] = null; |
|
1541 | + $this->_prop_cache["background_attachment"] = null; |
|
1542 | 1542 | $this->_props["background_attachment"] = $val; |
1543 | - } |
|
1543 | + } |
|
1544 | 1544 | |
1545 | - /** |
|
1546 | - * Sets the background position |
|
1547 | - * |
|
1548 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
1549 | - * @param string $val |
|
1550 | - */ |
|
1551 | - function set_background_position($val) { |
|
1545 | + /** |
|
1546 | + * Sets the background position |
|
1547 | + * |
|
1548 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background-position |
|
1549 | + * @param string $val |
|
1550 | + */ |
|
1551 | + function set_background_position($val) { |
|
1552 | 1552 | if ( is_null($val) ) |
1553 | - $val = self::$_defaults["background_position"]; |
|
1553 | + $val = self::$_defaults["background_position"]; |
|
1554 | 1554 | |
1555 | 1555 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1556 | - $this->_prop_cache["background_position"] = null; |
|
1556 | + $this->_prop_cache["background_position"] = null; |
|
1557 | 1557 | $this->_props["background_position"] = $val; |
1558 | - } |
|
1558 | + } |
|
1559 | 1559 | |
1560 | - /** |
|
1561 | - * Sets the background - combined options |
|
1562 | - * |
|
1563 | - * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
1564 | - * @param string $val |
|
1565 | - */ |
|
1566 | - function set_background($val) { |
|
1560 | + /** |
|
1561 | + * Sets the background - combined options |
|
1562 | + * |
|
1563 | + * @link http://www.w3.org/TR/CSS21/colors.html#propdef-background |
|
1564 | + * @param string $val |
|
1565 | + */ |
|
1566 | + function set_background($val) { |
|
1567 | 1567 | $col = null; |
1568 | 1568 | $pos = array(); |
1569 | 1569 | $tmp = explode(" ", $val); |
1570 | 1570 | $important = isset($this->_important_props["background"]); |
1571 | 1571 | foreach($tmp as $attr) { |
1572 | - if (mb_substr($attr, 0, 3) === "url" || $attr === "none") { |
|
1573 | - $this->_set_style("background_image", $this->_image($attr), $important); |
|
1574 | - } else if ($attr === "fixed" || $attr === "scroll") { |
|
1575 | - $this->_set_style("background_attachment", $attr, $important); |
|
1576 | - } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") { |
|
1577 | - $this->_set_style("background_repeat", $attr, $important); |
|
1578 | - } else if (($col = $this->munge_color($attr)) != null ) { |
|
1579 | - $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important); |
|
1580 | - } else { |
|
1581 | - $pos[] = $attr; |
|
1582 | - } |
|
1583 | - } |
|
1584 | - if (count($pos)) { |
|
1585 | - $this->_set_style("background_position",implode(' ',$pos), $important); |
|
1586 | - } |
|
1572 | + if (mb_substr($attr, 0, 3) === "url" || $attr === "none") { |
|
1573 | + $this->_set_style("background_image", $this->_image($attr), $important); |
|
1574 | + } else if ($attr === "fixed" || $attr === "scroll") { |
|
1575 | + $this->_set_style("background_attachment", $attr, $important); |
|
1576 | + } else if ($attr === "repeat" || $attr === "repeat-x" || $attr === "repeat-y" || $attr === "no-repeat") { |
|
1577 | + $this->_set_style("background_repeat", $attr, $important); |
|
1578 | + } else if (($col = $this->munge_color($attr)) != null ) { |
|
1579 | + $this->_set_style("background_color", is_array($col) ? $col["hex"] : $col, $important); |
|
1580 | + } else { |
|
1581 | + $pos[] = $attr; |
|
1582 | + } |
|
1583 | + } |
|
1584 | + if (count($pos)) { |
|
1585 | + $this->_set_style("background_position",implode(' ',$pos), $important); |
|
1586 | + } |
|
1587 | 1587 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1588 | - $this->_prop_cache["background"] = null; |
|
1589 | - $this->_props["background"] = $val; |
|
1590 | - } |
|
1588 | + $this->_prop_cache["background"] = null; |
|
1589 | + $this->_props["background"] = $val; |
|
1590 | + } |
|
1591 | 1591 | |
1592 | - /** |
|
1593 | - * Sets the font size |
|
1594 | - * |
|
1595 | - * $size can be any acceptable CSS size |
|
1596 | - * |
|
1597 | - * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
1598 | - * @param string|float $size |
|
1599 | - */ |
|
1600 | - function set_font_size($size) { |
|
1592 | + /** |
|
1593 | + * Sets the font size |
|
1594 | + * |
|
1595 | + * $size can be any acceptable CSS size |
|
1596 | + * |
|
1597 | + * @link http://www.w3.org/TR/CSS21/fonts.html#propdef-font-size |
|
1598 | + * @param string|float $size |
|
1599 | + */ |
|
1600 | + function set_font_size($size) { |
|
1601 | 1601 | $this->__font_size_calculated = false; |
1602 | 1602 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1603 | - $this->_prop_cache["font_size"] = null; |
|
1603 | + $this->_prop_cache["font_size"] = null; |
|
1604 | 1604 | $this->_props["font_size"] = $size; |
1605 | - } |
|
1605 | + } |
|
1606 | 1606 | |
1607 | - /** |
|
1608 | - * Sets the font style |
|
1609 | - * |
|
1610 | - * combined attributes |
|
1611 | - * set individual attributes also, respecting !important mark |
|
1612 | - * exactly this order, separate by space. Multiple fonts separated by comma: |
|
1613 | - * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
1614 | - * |
|
1615 | - * Other than with border and list, existing partial attributes should |
|
1616 | - * reset when starting here, even when not mentioned. |
|
1617 | - * If individual attribute is !important and explicite or implicite replacement is not, |
|
1618 | - * keep individual attribute |
|
1619 | - * |
|
1620 | - * require whitespace as delimiters for single value attributes |
|
1621 | - * On delimiter "/" treat first as font height, second as line height |
|
1622 | - * treat all remaining at the end of line as font |
|
1623 | - * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
1624 | - * |
|
1625 | - * missing font-size and font-family might be not allowed, but accept it here and |
|
1626 | - * use default (medium size, enpty font name) |
|
1627 | - * |
|
1628 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
1629 | - * @param $val |
|
1630 | - */ |
|
1631 | - function set_font($val) { |
|
1607 | + /** |
|
1608 | + * Sets the font style |
|
1609 | + * |
|
1610 | + * combined attributes |
|
1611 | + * set individual attributes also, respecting !important mark |
|
1612 | + * exactly this order, separate by space. Multiple fonts separated by comma: |
|
1613 | + * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
1614 | + * |
|
1615 | + * Other than with border and list, existing partial attributes should |
|
1616 | + * reset when starting here, even when not mentioned. |
|
1617 | + * If individual attribute is !important and explicite or implicite replacement is not, |
|
1618 | + * keep individual attribute |
|
1619 | + * |
|
1620 | + * require whitespace as delimiters for single value attributes |
|
1621 | + * On delimiter "/" treat first as font height, second as line height |
|
1622 | + * treat all remaining at the end of line as font |
|
1623 | + * font-style, font-variant, font-weight, font-size, line-height, font-family |
|
1624 | + * |
|
1625 | + * missing font-size and font-family might be not allowed, but accept it here and |
|
1626 | + * use default (medium size, enpty font name) |
|
1627 | + * |
|
1628 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
1629 | + * @param $val |
|
1630 | + */ |
|
1631 | + function set_font($val) { |
|
1632 | 1632 | $this->__font_size_calculated = false; |
1633 | 1633 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1634 | - $this->_prop_cache["font"] = null; |
|
1635 | - $this->_props["font"] = $val; |
|
1634 | + $this->_prop_cache["font"] = null; |
|
1635 | + $this->_props["font"] = $val; |
|
1636 | 1636 | |
1637 | 1637 | $important = isset($this->_important_props["font"]); |
1638 | 1638 | |
1639 | - if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { |
|
1640 | - $this->_set_style("font_style", $match[1], $important); |
|
1641 | - $val = $match[2]; |
|
1642 | - } else { |
|
1643 | - $this->_set_style("font_style", self::$_defaults["font_style"], $important); |
|
1644 | - } |
|
1639 | + if ( preg_match("/^(italic|oblique|normal)\s*(.*)$/i",$val,$match) ) { |
|
1640 | + $this->_set_style("font_style", $match[1], $important); |
|
1641 | + $val = $match[2]; |
|
1642 | + } else { |
|
1643 | + $this->_set_style("font_style", self::$_defaults["font_style"], $important); |
|
1644 | + } |
|
1645 | 1645 | |
1646 | - if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { |
|
1647 | - $this->_set_style("font_variant", $match[1], $important); |
|
1648 | - $val = $match[2]; |
|
1649 | - } else { |
|
1650 | - $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); |
|
1651 | - } |
|
1646 | + if ( preg_match("/^(small-caps|normal)\s*(.*)$/i",$val,$match) ) { |
|
1647 | + $this->_set_style("font_variant", $match[1], $important); |
|
1648 | + $val = $match[2]; |
|
1649 | + } else { |
|
1650 | + $this->_set_style("font_variant", self::$_defaults["font_variant"], $important); |
|
1651 | + } |
|
1652 | 1652 | |
1653 | 1653 | //matching numeric value followed by unit -> this is indeed a subsequent font size. Skip! |
1654 | - if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && |
|
1654 | + if ( preg_match("/^(bold|bolder|lighter|100|200|300|400|500|600|700|800|900|normal)\s*(.*)$/i",$val,$match) && |
|
1655 | 1655 | !preg_match("/^(?:pt|px|pc|em|ex|in|cm|mm|%)/",$match[2]) |
1656 | - ) { |
|
1657 | - $this->_set_style("font_weight", $match[1], $important); |
|
1658 | - $val = $match[2]; |
|
1659 | - } else { |
|
1660 | - $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); |
|
1661 | - } |
|
1662 | - |
|
1663 | - if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
1664 | - $this->_set_style("font_size", $match[1], $important); |
|
1665 | - $val = $match[2]; |
|
1656 | + ) { |
|
1657 | + $this->_set_style("font_weight", $match[1], $important); |
|
1658 | + $val = $match[2]; |
|
1659 | + } else { |
|
1660 | + $this->_set_style("font_weight", self::$_defaults["font_weight"], $important); |
|
1661 | + } |
|
1662 | + |
|
1663 | + if ( preg_match("/^(xx-small|x-small|small|medium|large|x-large|xx-large|smaller|larger|\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
|
1664 | + $this->_set_style("font_size", $match[1], $important); |
|
1665 | + $val = $match[2]; |
|
1666 | 1666 | if (preg_match("/^\/\s*(\d+\s*(?:pt|px|pc|em|ex|in|cm|mm|%))\s*(.*)$/i",$val,$match) ) { |
1667 | - $this->_set_style("line_height", $match[1], $important); |
|
1668 | - $val = $match[2]; |
|
1667 | + $this->_set_style("line_height", $match[1], $important); |
|
1668 | + $val = $match[2]; |
|
1669 | 1669 | } else { |
1670 | - $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
1670 | + $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
1671 | 1671 | } |
1672 | - } else { |
|
1673 | - $this->_set_style("font_size", self::$_defaults["font_size"], $important); |
|
1674 | - $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
1675 | - } |
|
1676 | - |
|
1677 | - if(strlen($val) != 0) { |
|
1678 | - $this->_set_style("font_family", $val, $important); |
|
1679 | - } else { |
|
1680 | - $this->_set_style("font_family", self::$_defaults["font_family"], $important); |
|
1681 | - } |
|
1682 | - } |
|
1683 | - |
|
1684 | - /**#@+ |
|
1672 | + } else { |
|
1673 | + $this->_set_style("font_size", self::$_defaults["font_size"], $important); |
|
1674 | + $this->_set_style("line_height", self::$_defaults["line_height"], $important); |
|
1675 | + } |
|
1676 | + |
|
1677 | + if(strlen($val) != 0) { |
|
1678 | + $this->_set_style("font_family", $val, $important); |
|
1679 | + } else { |
|
1680 | + $this->_set_style("font_family", self::$_defaults["font_family"], $important); |
|
1681 | + } |
|
1682 | + } |
|
1683 | + |
|
1684 | + /**#@+ |
|
1685 | 1685 | * Sets page break properties |
1686 | 1686 | * |
1687 | 1687 | * @link http://www.w3.org/TR/CSS21/page.html#page-breaks |
1688 | 1688 | * @param string $break |
1689 | 1689 | */ |
1690 | - function set_page_break_before($break) { |
|
1690 | + function set_page_break_before($break) { |
|
1691 | 1691 | if ($break === "left" || $break === "right") |
1692 | - $break = "always"; |
|
1692 | + $break = "always"; |
|
1693 | 1693 | |
1694 | 1694 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1695 | - $this->_prop_cache["page_break_before"] = null; |
|
1695 | + $this->_prop_cache["page_break_before"] = null; |
|
1696 | 1696 | $this->_props["page_break_before"] = $break; |
1697 | - } |
|
1697 | + } |
|
1698 | 1698 | |
1699 | - function set_page_break_after($break) { |
|
1699 | + function set_page_break_after($break) { |
|
1700 | 1700 | if ($break === "left" || $break === "right") |
1701 | - $break = "always"; |
|
1701 | + $break = "always"; |
|
1702 | 1702 | |
1703 | 1703 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1704 | - $this->_prop_cache["page_break_after"] = null; |
|
1704 | + $this->_prop_cache["page_break_after"] = null; |
|
1705 | 1705 | $this->_props["page_break_after"] = $break; |
1706 | - } |
|
1707 | - /**#@-*/ |
|
1706 | + } |
|
1707 | + /**#@-*/ |
|
1708 | 1708 | |
1709 | - //........................................................................ |
|
1709 | + //........................................................................ |
|
1710 | 1710 | |
1711 | - /**#@+ |
|
1711 | + /**#@+ |
|
1712 | 1712 | * Sets the margin size |
1713 | 1713 | * |
1714 | 1714 | * @link http://www.w3.org/TR/CSS21/box.html#margin-properties |
1715 | 1715 | * @param $val |
1716 | 1716 | */ |
1717 | - function set_margin_top($val) { |
|
1717 | + function set_margin_top($val) { |
|
1718 | 1718 | $this->_set_style_side_width_important('margin','top',$val); |
1719 | - } |
|
1719 | + } |
|
1720 | 1720 | |
1721 | - function set_margin_right($val) { |
|
1721 | + function set_margin_right($val) { |
|
1722 | 1722 | $this->_set_style_side_width_important('margin','right',$val); |
1723 | - } |
|
1723 | + } |
|
1724 | 1724 | |
1725 | - function set_margin_bottom($val) { |
|
1725 | + function set_margin_bottom($val) { |
|
1726 | 1726 | $this->_set_style_side_width_important('margin','bottom',$val); |
1727 | - } |
|
1727 | + } |
|
1728 | 1728 | |
1729 | - function set_margin_left($val) { |
|
1729 | + function set_margin_left($val) { |
|
1730 | 1730 | $this->_set_style_side_width_important('margin','left',$val); |
1731 | - } |
|
1731 | + } |
|
1732 | 1732 | |
1733 | - function set_margin($val) { |
|
1733 | + function set_margin($val) { |
|
1734 | 1734 | $val = str_replace("none", "0px", $val); |
1735 | 1735 | $this->_set_style_type_important('margin','',$val); |
1736 | - } |
|
1737 | - /**#@-*/ |
|
1736 | + } |
|
1737 | + /**#@-*/ |
|
1738 | 1738 | |
1739 | - /**#@+ |
|
1739 | + /**#@+ |
|
1740 | 1740 | * Sets the padding size |
1741 | 1741 | * |
1742 | 1742 | * @link http://www.w3.org/TR/CSS21/box.html#padding-properties |
1743 | 1743 | * @param $val |
1744 | 1744 | */ |
1745 | - function set_padding_top($val) { |
|
1745 | + function set_padding_top($val) { |
|
1746 | 1746 | $this->_set_style_side_width_important('padding','top',$val); |
1747 | - } |
|
1747 | + } |
|
1748 | 1748 | |
1749 | - function set_padding_right($val) { |
|
1749 | + function set_padding_right($val) { |
|
1750 | 1750 | $this->_set_style_side_width_important('padding','right',$val); |
1751 | - } |
|
1751 | + } |
|
1752 | 1752 | |
1753 | - function set_padding_bottom($val) { |
|
1753 | + function set_padding_bottom($val) { |
|
1754 | 1754 | $this->_set_style_side_width_important('padding','bottom',$val); |
1755 | - } |
|
1755 | + } |
|
1756 | 1756 | |
1757 | - function set_padding_left($val) { |
|
1757 | + function set_padding_left($val) { |
|
1758 | 1758 | $this->_set_style_side_width_important('padding','left',$val); |
1759 | - } |
|
1759 | + } |
|
1760 | 1760 | |
1761 | - function set_padding($val) { |
|
1761 | + function set_padding($val) { |
|
1762 | 1762 | $val = str_replace("none", "0px", $val); |
1763 | 1763 | $this->_set_style_type_important('padding','',$val); |
1764 | - } |
|
1765 | - /**#@-*/ |
|
1766 | - |
|
1767 | - /** |
|
1768 | - * Sets a single border |
|
1769 | - * |
|
1770 | - * @param string $side |
|
1771 | - * @param string $border_spec ([width] [style] [color]) |
|
1772 | - */ |
|
1773 | - protected function _set_border($side, $border_spec, $important) { |
|
1764 | + } |
|
1765 | + /**#@-*/ |
|
1766 | + |
|
1767 | + /** |
|
1768 | + * Sets a single border |
|
1769 | + * |
|
1770 | + * @param string $side |
|
1771 | + * @param string $border_spec ([width] [style] [color]) |
|
1772 | + */ |
|
1773 | + protected function _set_border($side, $border_spec, $important) { |
|
1774 | 1774 | $border_spec = str_replace(",", " ", $border_spec); |
1775 | 1775 | $arr = explode(" ", $border_spec); |
1776 | 1776 | |
@@ -1783,155 +1783,155 @@ discard block |
||
1783 | 1783 | $this->_set_style_side_type('border',$side,'_color',self::$_defaults['border_'.$side.'_color'],$important); |
1784 | 1784 | |
1785 | 1785 | foreach ($arr as $value) { |
1786 | - $value = trim($value); |
|
1787 | - if ( in_array($value, self::$BORDER_STYLES) ) { |
|
1786 | + $value = trim($value); |
|
1787 | + if ( in_array($value, self::$BORDER_STYLES) ) { |
|
1788 | 1788 | $this->_set_style_side_type('border',$side,'_style',$value,$important); |
1789 | 1789 | |
1790 | - } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) { |
|
1790 | + } else if ( preg_match("/[.0-9]+(?:px|pt|pc|em|ex|%|in|mm|cm)|(?:thin|medium|thick)/", $value ) ) { |
|
1791 | 1791 | $this->_set_style_side_type('border',$side,'_width',$value,$important); |
1792 | 1792 | |
1793 | - } else { |
|
1793 | + } else { |
|
1794 | 1794 | // must be colour |
1795 | 1795 | $this->_set_style_side_type('border',$side,'_color',$value,$important); |
1796 | - } |
|
1796 | + } |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | //see __set and __get, on all assignments clear cache! |
1800 | - $this->_prop_cache['border_'.$side] = null; |
|
1800 | + $this->_prop_cache['border_'.$side] = null; |
|
1801 | 1801 | $this->_props['border_'.$side] = $border_spec; |
1802 | - } |
|
1802 | + } |
|
1803 | 1803 | |
1804 | - /**#@+ |
|
1804 | + /**#@+ |
|
1805 | 1805 | * Sets the border styles |
1806 | 1806 | * |
1807 | 1807 | * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
1808 | 1808 | * @param string $val |
1809 | 1809 | */ |
1810 | - function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); } |
|
1811 | - function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); } |
|
1812 | - function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); } |
|
1813 | - function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); } |
|
1810 | + function set_border_top($val) { $this->_set_border("top", $val, isset($this->_important_props['border_top'])); } |
|
1811 | + function set_border_right($val) { $this->_set_border("right", $val, isset($this->_important_props['border_right'])); } |
|
1812 | + function set_border_bottom($val) { $this->_set_border("bottom", $val, isset($this->_important_props['border_bottom'])); } |
|
1813 | + function set_border_left($val) { $this->_set_border("left", $val, isset($this->_important_props['border_left'])); } |
|
1814 | 1814 | |
1815 | - function set_border($val) { |
|
1815 | + function set_border($val) { |
|
1816 | 1816 | $important = isset($this->_important_props["border"]); |
1817 | 1817 | $this->_set_border("top", $val, $important); |
1818 | 1818 | $this->_set_border("right", $val, $important); |
1819 | 1819 | $this->_set_border("bottom", $val, $important); |
1820 | 1820 | $this->_set_border("left", $val, $important); |
1821 | 1821 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1822 | - $this->_prop_cache["border"] = null; |
|
1822 | + $this->_prop_cache["border"] = null; |
|
1823 | 1823 | $this->_props["border"] = $val; |
1824 | - } |
|
1824 | + } |
|
1825 | 1825 | |
1826 | - function set_border_width($val) { |
|
1826 | + function set_border_width($val) { |
|
1827 | 1827 | $this->_set_style_type_important('border','_width',$val); |
1828 | - } |
|
1828 | + } |
|
1829 | 1829 | |
1830 | - function set_border_color($val) { |
|
1830 | + function set_border_color($val) { |
|
1831 | 1831 | $this->_set_style_type_important('border','_color',$val); |
1832 | - } |
|
1832 | + } |
|
1833 | 1833 | |
1834 | - function set_border_style($val) { |
|
1834 | + function set_border_style($val) { |
|
1835 | 1835 | $this->_set_style_type_important('border','_style',$val); |
1836 | - } |
|
1837 | - /**#@-*/ |
|
1836 | + } |
|
1837 | + /**#@-*/ |
|
1838 | 1838 | |
1839 | 1839 | |
1840 | - /** |
|
1841 | - * Sets the border spacing |
|
1842 | - * |
|
1843 | - * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
|
1844 | - * @param float $val |
|
1845 | - */ |
|
1846 | - function set_border_spacing($val) { |
|
1840 | + /** |
|
1841 | + * Sets the border spacing |
|
1842 | + * |
|
1843 | + * @link http://www.w3.org/TR/CSS21/box.html#border-properties |
|
1844 | + * @param float $val |
|
1845 | + */ |
|
1846 | + function set_border_spacing($val) { |
|
1847 | 1847 | |
1848 | 1848 | $arr = explode(" ", $val); |
1849 | 1849 | |
1850 | 1850 | if ( count($arr) == 1 ) |
1851 | - $arr[1] = $arr[0]; |
|
1851 | + $arr[1] = $arr[0]; |
|
1852 | 1852 | |
1853 | 1853 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1854 | - $this->_prop_cache["border_spacing"] = null; |
|
1854 | + $this->_prop_cache["border_spacing"] = null; |
|
1855 | 1855 | $this->_props["border_spacing"] = $arr[0] . " " . $arr[1]; |
1856 | - } |
|
1856 | + } |
|
1857 | 1857 | |
1858 | - /** |
|
1859 | - * Sets the list style image |
|
1860 | - * |
|
1861 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image |
|
1862 | - * @param $val |
|
1863 | - */ |
|
1864 | - function set_list_style_image($val) { |
|
1858 | + /** |
|
1859 | + * Sets the list style image |
|
1860 | + * |
|
1861 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style-image |
|
1862 | + * @param $val |
|
1863 | + */ |
|
1864 | + function set_list_style_image($val) { |
|
1865 | 1865 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1866 | - $this->_prop_cache["list_style_image"] = null; |
|
1866 | + $this->_prop_cache["list_style_image"] = null; |
|
1867 | 1867 | $this->_props["list_style_image"] = $this->_image($val); |
1868 | - } |
|
1868 | + } |
|
1869 | 1869 | |
1870 | - /** |
|
1871 | - * Sets the list style |
|
1872 | - * |
|
1873 | - * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
1874 | - * @param $val |
|
1875 | - */ |
|
1876 | - function set_list_style($val) { |
|
1870 | + /** |
|
1871 | + * Sets the list style |
|
1872 | + * |
|
1873 | + * @link http://www.w3.org/TR/CSS21/generate.html#propdef-list-style |
|
1874 | + * @param $val |
|
1875 | + */ |
|
1876 | + function set_list_style($val) { |
|
1877 | 1877 | $important = isset($this->_important_props["list_style"]); |
1878 | 1878 | $arr = explode(" ", str_replace(",", " ", $val)); |
1879 | 1879 | |
1880 | 1880 | static $types = array("disc", "circle", "square", "decimal", |
1881 | - "decimal-leading-zero", "lower-roman", |
|
1882 | - "upper-roman", "lower-greek", "lower-latin", |
|
1883 | - "upper-latin", "armenian", "georgian", |
|
1884 | - "lower-alpha", "upper-alpha", "hebrew", |
|
1885 | - "cjk-ideographic", "hiragana", "katakana", |
|
1886 | - "hiragana-iroha", "katakana-iroha", "none"); |
|
1881 | + "decimal-leading-zero", "lower-roman", |
|
1882 | + "upper-roman", "lower-greek", "lower-latin", |
|
1883 | + "upper-latin", "armenian", "georgian", |
|
1884 | + "lower-alpha", "upper-alpha", "hebrew", |
|
1885 | + "cjk-ideographic", "hiragana", "katakana", |
|
1886 | + "hiragana-iroha", "katakana-iroha", "none"); |
|
1887 | 1887 | |
1888 | 1888 | static $positions = array("inside", "outside"); |
1889 | 1889 | |
1890 | 1890 | foreach ($arr as $value) { |
1891 | - /* http://www.w3.org/TR/CSS21/generate.html#list-style |
|
1891 | + /* http://www.w3.org/TR/CSS21/generate.html#list-style |
|
1892 | 1892 | * A value of 'none' for the 'list-style' property sets both 'list-style-type' and 'list-style-image' to 'none' |
1893 | 1893 | */ |
1894 | - if ($value === "none") { |
|
1895 | - $this->_set_style("list_style_type", $value, $important); |
|
1896 | - $this->_set_style("list_style_image", $value, $important); |
|
1894 | + if ($value === "none") { |
|
1895 | + $this->_set_style("list_style_type", $value, $important); |
|
1896 | + $this->_set_style("list_style_image", $value, $important); |
|
1897 | 1897 | continue; |
1898 | - } |
|
1898 | + } |
|
1899 | 1899 | |
1900 | - //On setting or merging or inheriting list_style_image as well as list_style_type, |
|
1901 | - //and url exists, then url has precedence, otherwise fall back to list_style_type |
|
1902 | - //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type) |
|
1903 | - //Internet Explorer 7/8 and dompdf is right. |
|
1900 | + //On setting or merging or inheriting list_style_image as well as list_style_type, |
|
1901 | + //and url exists, then url has precedence, otherwise fall back to list_style_type |
|
1902 | + //Firefox is wrong here (list_style_image gets overwritten on explicite list_style_type) |
|
1903 | + //Internet Explorer 7/8 and dompdf is right. |
|
1904 | 1904 | |
1905 | - if (mb_substr($value, 0, 3) === "url") { |
|
1906 | - $this->_set_style("list_style_image", $this->_image($value), $important); |
|
1905 | + if (mb_substr($value, 0, 3) === "url") { |
|
1906 | + $this->_set_style("list_style_image", $this->_image($value), $important); |
|
1907 | 1907 | continue; |
1908 | - } |
|
1908 | + } |
|
1909 | 1909 | |
1910 | - if ( in_array($value, $types) ) { |
|
1911 | - $this->_set_style("list_style_type", $value, $important); |
|
1912 | - } else if ( in_array($value, $positions) ) { |
|
1913 | - $this->_set_style("list_style_position", $value, $important); |
|
1914 | - } |
|
1910 | + if ( in_array($value, $types) ) { |
|
1911 | + $this->_set_style("list_style_type", $value, $important); |
|
1912 | + } else if ( in_array($value, $positions) ) { |
|
1913 | + $this->_set_style("list_style_position", $value, $important); |
|
1914 | + } |
|
1915 | 1915 | } |
1916 | 1916 | |
1917 | 1917 | //see __set and __get, on all assignments clear cache, not needed on direct set through __set |
1918 | - $this->_prop_cache["list_style"] = null; |
|
1919 | - $this->_props["list_style"] = $val; |
|
1920 | - } |
|
1918 | + $this->_prop_cache["list_style"] = null; |
|
1919 | + $this->_props["list_style"] = $val; |
|
1920 | + } |
|
1921 | 1921 | |
1922 | - /** |
|
1923 | - * Generate a string representation of the Style |
|
1924 | - * |
|
1925 | - * This dumps the entire property array into a string via print_r. Useful |
|
1926 | - * for debugging. |
|
1927 | - * |
|
1928 | - * @return string |
|
1929 | - */ |
|
1930 | - /*DEBUGCSS print: see below additional debugging util*/ |
|
1931 | - function __toString() { |
|
1922 | + /** |
|
1923 | + * Generate a string representation of the Style |
|
1924 | + * |
|
1925 | + * This dumps the entire property array into a string via print_r. Useful |
|
1926 | + * for debugging. |
|
1927 | + * |
|
1928 | + * @return string |
|
1929 | + */ |
|
1930 | + /*DEBUGCSS print: see below additional debugging util*/ |
|
1931 | + function __toString() { |
|
1932 | 1932 | return print_r(array_merge(array("parent_font_size" => $this->_parent_font_size), |
1933 | - $this->_props), true); |
|
1934 | - } |
|
1933 | + $this->_props), true); |
|
1934 | + } |
|
1935 | 1935 | |
1936 | 1936 | /*DEBUGCSS*/ function debug_print() |
1937 | 1937 | /*DEBUGCSS*/ { |