@@ -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*/ { |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_cell_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,54 +46,54 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Cell_Frame_Decorator extends Block_Frame_Decorator { |
49 | 48 | |
50 | - protected $_resolved_borders; |
|
51 | - protected $_content_height; |
|
49 | + protected $_resolved_borders; |
|
50 | + protected $_content_height; |
|
52 | 51 | |
53 | - //........................................................................ |
|
52 | + //........................................................................ |
|
54 | 53 | |
55 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
54 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
56 | 55 | parent::__construct($frame, $dompdf); |
57 | 56 | $this->_resolved_borders = array(); |
58 | 57 | $this->_content_height = 0; |
59 | - } |
|
58 | + } |
|
60 | 59 | |
61 | - //........................................................................ |
|
60 | + //........................................................................ |
|
62 | 61 | |
63 | - function reset() { |
|
62 | + function reset() { |
|
64 | 63 | parent::reset(); |
65 | 64 | $this->_resolved_borders = array(); |
66 | 65 | $this->_content_height = 0; |
67 | 66 | $this->_frame->reset(); |
68 | - } |
|
67 | + } |
|
69 | 68 | |
70 | - function get_content_height() { |
|
69 | + function get_content_height() { |
|
71 | 70 | return $this->_content_height; |
72 | - } |
|
71 | + } |
|
73 | 72 | |
74 | - function set_content_height($height) { |
|
73 | + function set_content_height($height) { |
|
75 | 74 | $this->_content_height = $height; |
76 | - } |
|
75 | + } |
|
77 | 76 | |
78 | - function set_cell_height($height) { |
|
77 | + function set_cell_height($height) { |
|
79 | 78 | $style = $this->get_style(); |
80 | 79 | $v_space = $style->length_in_pt(array($style->margin_top, |
81 | - $style->padding_top, |
|
82 | - $style->border_top_width, |
|
83 | - $style->border_bottom_width, |
|
84 | - $style->padding_bottom, |
|
85 | - $style->margin_bottom), |
|
80 | + $style->padding_top, |
|
81 | + $style->border_top_width, |
|
82 | + $style->border_bottom_width, |
|
83 | + $style->padding_bottom, |
|
84 | + $style->margin_bottom), |
|
86 | 85 | $style->width); |
87 | 86 | |
88 | 87 | $new_height = $height - $v_space; |
89 | 88 | $style->height = $new_height; |
90 | 89 | |
91 | 90 | if ( $new_height > $this->_content_height ) { |
92 | - // Adjust our vertical alignment |
|
93 | - $valign = $style->vertical_align; |
|
91 | + // Adjust our vertical alignment |
|
92 | + $valign = $style->vertical_align; |
|
94 | 93 | |
95 | - switch ($valign) { |
|
94 | + switch ($valign) { |
|
96 | 95 | |
97 | - default: |
|
96 | + default: |
|
98 | 97 | case "baseline": |
99 | 98 | // FIXME: this isn't right |
100 | 99 | |
@@ -102,34 +101,34 @@ discard block |
||
102 | 101 | // Don't need to do anything |
103 | 102 | return; |
104 | 103 | |
105 | - case "middle": |
|
104 | + case "middle": |
|
106 | 105 | $delta = ($new_height - $this->_content_height) / 2; |
107 | 106 | break; |
108 | 107 | |
109 | - case "bottom": |
|
108 | + case "bottom": |
|
110 | 109 | $delta = $new_height - $this->_content_height; |
111 | 110 | break; |
112 | 111 | |
113 | - } |
|
112 | + } |
|
114 | 113 | |
115 | - // Move our children |
|
116 | - foreach ( $this->get_lines() as $i => $line ) { |
|
114 | + // Move our children |
|
115 | + foreach ( $this->get_lines() as $i => $line ) { |
|
117 | 116 | foreach ( $line["frames"] as $frame ) |
118 | - $frame->set_position( null, $frame->get_position("y") + $delta ); |
|
119 | - } |
|
120 | - } |
|
117 | + $frame->set_position( null, $frame->get_position("y") + $delta ); |
|
118 | + } |
|
119 | + } |
|
121 | 120 | |
122 | - } |
|
121 | + } |
|
123 | 122 | |
124 | - function set_resolved_border($side, $border_spec) { |
|
123 | + function set_resolved_border($side, $border_spec) { |
|
125 | 124 | $this->_resolved_borders[$side] = $border_spec; |
126 | - } |
|
125 | + } |
|
127 | 126 | |
128 | - //........................................................................ |
|
127 | + //........................................................................ |
|
129 | 128 | |
130 | - function get_resolved_border($side) { |
|
129 | + function get_resolved_border($side) { |
|
131 | 130 | return $this->_resolved_borders[$side]; |
132 | - } |
|
131 | + } |
|
133 | 132 | |
134 | - function get_resolved_borders() { return $this->_resolved_borders; } |
|
133 | + function get_resolved_borders() { return $this->_resolved_borders; } |
|
135 | 134 | } |
@@ -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: renderer.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -50,38 +49,38 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Renderer extends Abstract_Renderer { |
52 | 51 | |
53 | - /** |
|
54 | - * Array of renderers for specific frame types |
|
55 | - * |
|
56 | - * @var array |
|
57 | - */ |
|
58 | - protected $_renderers; |
|
52 | + /** |
|
53 | + * Array of renderers for specific frame types |
|
54 | + * |
|
55 | + * @var array |
|
56 | + */ |
|
57 | + protected $_renderers; |
|
59 | 58 | |
60 | - /** |
|
61 | - * Cache of the callbacks array |
|
62 | - * |
|
63 | - * @var array |
|
64 | - */ |
|
65 | - private $_callbacks; |
|
59 | + /** |
|
60 | + * Cache of the callbacks array |
|
61 | + * |
|
62 | + * @var array |
|
63 | + */ |
|
64 | + private $_callbacks; |
|
66 | 65 | |
67 | - /** |
|
68 | - * Advance the canvas to the next page |
|
69 | - */ |
|
70 | - function new_page() { |
|
66 | + /** |
|
67 | + * Advance the canvas to the next page |
|
68 | + */ |
|
69 | + function new_page() { |
|
71 | 70 | $this->_canvas->new_page(); |
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Render frames recursively |
|
76 | - * |
|
77 | - * @param Frame $frame the frame to render |
|
78 | - */ |
|
79 | - function render(Frame $frame) { |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * Render frames recursively |
|
75 | + * |
|
76 | + * @param Frame $frame the frame to render |
|
77 | + */ |
|
78 | + function render(Frame $frame) { |
|
80 | 79 | global $_dompdf_debug; |
81 | 80 | |
82 | 81 | if ( $_dompdf_debug ) { |
83 | - echo $frame; |
|
84 | - flush(); |
|
82 | + echo $frame; |
|
83 | + flush(); |
|
85 | 84 | } |
86 | 85 | |
87 | 86 | $display = $frame->get_style()->display; |
@@ -97,46 +96,46 @@ discard block |
||
97 | 96 | case "table-footer-group": |
98 | 97 | case "inline-table": |
99 | 98 | $this->_render_frame("block", $frame); |
100 | - break; |
|
99 | + break; |
|
101 | 100 | |
102 | 101 | case "inline": |
103 | 102 | if ( $frame->get_node()->nodeName === "#text" ) |
104 | 103 | $this->_render_frame("text", $frame); |
105 | - else |
|
104 | + else |
|
106 | 105 | $this->_render_frame("inline", $frame); |
107 | - break; |
|
106 | + break; |
|
108 | 107 | |
109 | 108 | case "table-cell": |
110 | 109 | $this->_render_frame("table-cell", $frame); |
111 | - break; |
|
110 | + break; |
|
112 | 111 | |
113 | 112 | case "-dompdf-list-bullet": |
114 | 113 | $this->_render_frame("list-bullet", $frame); |
115 | - break; |
|
114 | + break; |
|
116 | 115 | |
117 | 116 | case "-dompdf-image": |
118 | 117 | $this->_render_frame("image", $frame); |
119 | - break; |
|
118 | + break; |
|
120 | 119 | |
121 | 120 | case "none": |
122 | 121 | $node = $frame->get_node(); |
123 | 122 | |
124 | - if ( $node->nodeName === "script" ) { |
|
123 | + if ( $node->nodeName === "script" ) { |
|
125 | 124 | if ( $node->getAttribute("type") === "text/php" || |
126 | 125 | $node->getAttribute("language") === "php" ) { |
127 | - // Evaluate embedded php scripts |
|
128 | - $this->_render_frame("php", $frame); |
|
126 | + // Evaluate embedded php scripts |
|
127 | + $this->_render_frame("php", $frame); |
|
129 | 128 | } |
130 | 129 | |
131 | 130 | elseif ( $node->getAttribute("type") === "text/javascript" || |
132 | 131 | $node->getAttribute("language") === "javascript" ) { |
133 | - // Insert JavaScript |
|
134 | - $this->_render_frame("javascript", $frame); |
|
132 | + // Insert JavaScript |
|
133 | + $this->_render_frame("javascript", $frame); |
|
134 | + } |
|
135 | 135 | } |
136 | - } |
|
137 | 136 | |
138 | - // Don't render children, so skip to next iter |
|
139 | - return; |
|
137 | + // Don't render children, so skip to next iter |
|
138 | + return; |
|
140 | 139 | |
141 | 140 | default: |
142 | 141 | break; |
@@ -147,90 +146,90 @@ discard block |
||
147 | 146 | $this->_check_callbacks("begin_frame", $frame); |
148 | 147 | |
149 | 148 | foreach ($frame->get_children() as $child) |
150 | - $this->render($child); |
|
149 | + $this->render($child); |
|
151 | 150 | |
152 | 151 | // Check for end frame callback |
153 | 152 | $this->_check_callbacks("end_frame", $frame); |
154 | 153 | |
155 | - } |
|
154 | + } |
|
156 | 155 | |
157 | - /** |
|
158 | - * Check for callbacks that need to be performed when a given event |
|
159 | - * gets triggered on a frame |
|
160 | - * |
|
161 | - * @param string $event the type of event |
|
162 | - * @param Frame $frame the frame that event is triggered on |
|
163 | - */ |
|
164 | - protected function _check_callbacks($event, $frame) { |
|
156 | + /** |
|
157 | + * Check for callbacks that need to be performed when a given event |
|
158 | + * gets triggered on a frame |
|
159 | + * |
|
160 | + * @param string $event the type of event |
|
161 | + * @param Frame $frame the frame that event is triggered on |
|
162 | + */ |
|
163 | + protected function _check_callbacks($event, $frame) { |
|
165 | 164 | if (!isset($this->_callbacks)) { |
166 | - $this->_callbacks = $this->_dompdf->get_callbacks(); |
|
165 | + $this->_callbacks = $this->_dompdf->get_callbacks(); |
|
167 | 166 | } |
168 | 167 | |
169 | 168 | if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) { |
170 | - $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, |
|
169 | + $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, |
|
171 | 170 | 1 => $frame, "frame" => $frame); |
172 | - $fs = $this->_callbacks[$event]; |
|
173 | - foreach ($fs as $f) { |
|
171 | + $fs = $this->_callbacks[$event]; |
|
172 | + foreach ($fs as $f) { |
|
174 | 173 | if (is_callable($f)) { |
175 | - if (is_array($f)) { |
|
174 | + if (is_array($f)) { |
|
176 | 175 | $f[0]->$f[1]($info); |
177 | - } else { |
|
176 | + } else { |
|
178 | 177 | $f($info); |
179 | - } |
|
178 | + } |
|
180 | 179 | } |
181 | - } |
|
180 | + } |
|
181 | + } |
|
182 | 182 | } |
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Render a single frame |
|
187 | - * |
|
188 | - * Creates Renderer objects on demand |
|
189 | - * |
|
190 | - * @param string $type type of renderer to use |
|
191 | - * @param Frame $frame the frame to render |
|
192 | - */ |
|
193 | - protected function _render_frame($type, $frame) { |
|
183 | + |
|
184 | + /** |
|
185 | + * Render a single frame |
|
186 | + * |
|
187 | + * Creates Renderer objects on demand |
|
188 | + * |
|
189 | + * @param string $type type of renderer to use |
|
190 | + * @param Frame $frame the frame to render |
|
191 | + */ |
|
192 | + protected function _render_frame($type, $frame) { |
|
194 | 193 | |
195 | 194 | if ( !isset($this->_renderers[$type]) ) { |
196 | 195 | |
197 | - switch ($type) { |
|
198 | - case "block": |
|
196 | + switch ($type) { |
|
197 | + case "block": |
|
199 | 198 | $this->_renderers["block"] = new Block_Renderer($this->_dompdf); |
200 | 199 | break; |
201 | 200 | |
202 | - case "inline": |
|
201 | + case "inline": |
|
203 | 202 | $this->_renderers["inline"] = new Inline_Renderer($this->_dompdf); |
204 | 203 | break; |
205 | 204 | |
206 | - case "text": |
|
205 | + case "text": |
|
207 | 206 | $this->_renderers["text"] = new Text_Renderer($this->_dompdf); |
208 | 207 | break; |
209 | 208 | |
210 | - case "image": |
|
209 | + case "image": |
|
211 | 210 | $this->_renderers["image"] = new Image_Renderer($this->_dompdf); |
212 | 211 | break; |
213 | 212 | |
214 | - case "table-cell": |
|
213 | + case "table-cell": |
|
215 | 214 | $this->_renderers["table-cell"] = new Table_Cell_Renderer($this->_dompdf); |
216 | 215 | break; |
217 | 216 | |
218 | - case "list-bullet": |
|
217 | + case "list-bullet": |
|
219 | 218 | $this->_renderers["list-bullet"] = new List_Bullet_Renderer($this->_dompdf); |
220 | 219 | break; |
221 | 220 | |
222 | - case "php": |
|
221 | + case "php": |
|
223 | 222 | $this->_renderers["php"] = new PHP_Evaluator($this->_canvas); |
224 | 223 | break; |
225 | 224 | |
226 | - case "javascript": |
|
225 | + case "javascript": |
|
227 | 226 | $this->_renderers["javascript"] = new Javascript_Embedder($this->_dompdf); |
228 | 227 | break; |
229 | 228 | |
230 | - } |
|
229 | + } |
|
231 | 230 | } |
232 | 231 | |
233 | 232 | $this->_renderers[$type]->render($frame); |
234 | 233 | |
235 | - } |
|
234 | + } |
|
236 | 235 | } |
@@ -16,7 +16,6 @@ |
||
16 | 16 | * @author Patrick Cool |
17 | 17 | * @author René Haentjens, added CSV file import (October 2004) |
18 | 18 | * @package chamilo.link |
19 | - |
|
20 | 19 | */ |
21 | 20 | |
22 | 21 | // Including libraries |