@@ -190,6 +190,9 @@ |
||
190 | 190 | "yellowgreen" => "9ACD32", |
191 | 191 | ); |
192 | 192 | |
193 | + /** |
|
194 | + * @param string $colour |
|
195 | + */ |
|
193 | 196 | static function parse($colour) { |
194 | 197 | if ( is_array($colour) ) |
195 | 198 | // Assume the array has the right format... |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param string $text the text to be sized |
118 | 118 | * @param string $font the desired font |
119 | 119 | * @param float $size the desired font size |
120 | - * @param float $spacing word spacing, if any |
|
120 | + * @param integer $spacing word spacing, if any |
|
121 | 121 | * @return float |
122 | 122 | */ |
123 | 123 | static function get_text_width($text, $font, $size, $spacing = 0) { |
@@ -234,6 +234,9 @@ discard block |
||
234 | 234 | return self::$_font_lookup; |
235 | 235 | } |
236 | 236 | |
237 | + /** |
|
238 | + * @param string $fontname |
|
239 | + */ |
|
237 | 240 | static function set_font_family($fontname, $entry) { |
238 | 241 | self::$_font_lookup[mb_strtolower($fontname)] = $entry; |
239 | 242 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | /* $Id: font_metrics.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
48 | 48 | |
49 | -require_once(DOMPDF_LIB_DIR . "/class.pdf.php"); |
|
49 | +require_once(DOMPDF_LIB_DIR."/class.pdf.php"); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Name of the font cache file |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | * |
60 | 60 | * Declared here because PHP5 prevents constants from being declared with expressions |
61 | 61 | */ |
62 | -if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) { |
|
63 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
62 | +if (file_exists(DOMPDF_FONT_DIR."dompdf_font_family_cache")) { |
|
63 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache"); |
|
64 | 64 | } else { |
65 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
65 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache.dist"); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -157,11 +157,11 @@ discard block |
||
157 | 157 | * Only on checking the fallback font, check various subtypes on same font. |
158 | 158 | */ |
159 | 159 | |
160 | - if ( $family ) { |
|
161 | - $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
160 | + if ($family) { |
|
161 | + $family = str_replace(array("'", '"'), "", mb_strtolower($family)); |
|
162 | 162 | $subtype = mb_strtolower($subtype); |
163 | 163 | |
164 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
164 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
165 | 165 | return self::$_font_lookup[$family][$subtype]; |
166 | 166 | } |
167 | 167 | return null; |
@@ -169,18 +169,18 @@ discard block |
||
169 | 169 | |
170 | 170 | $family = DOMPDF_DEFAULT_FONT; |
171 | 171 | |
172 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
172 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
173 | 173 | return self::$_font_lookup[$family][$subtype]; |
174 | 174 | } |
175 | 175 | |
176 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
176 | + foreach (self::$_font_lookup[$family] as $sub => $font) { |
|
177 | 177 | if (strpos($subtype, $sub) !== false) { |
178 | 178 | return $font; |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | if ($subtype !== "normal") { |
183 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
183 | + foreach (self::$_font_lookup[$family] as $sub => $font) { |
|
184 | 184 | if ($sub !== "normal") { |
185 | 185 | return $font; |
186 | 186 | } |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | |
190 | 190 | $subtype = "normal"; |
191 | 191 | |
192 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
192 | + if (isset(self::$_font_lookup[$family][$subtype])) { |
|
193 | 193 | return self::$_font_lookup[$family][$subtype]; |
194 | 194 | } |
195 | 195 | return null; |
@@ -216,13 +216,13 @@ discard block |
||
216 | 216 | * @see save_font_families() |
217 | 217 | */ |
218 | 218 | static function load_font_families() { |
219 | - if ( !is_readable(self::CACHE_FILE) ) |
|
219 | + if (!is_readable(self::CACHE_FILE)) |
|
220 | 220 | return; |
221 | 221 | |
222 | 222 | $data = file_get_contents(self::CACHE_FILE); |
223 | 223 | |
224 | - if ( $data != "" ) |
|
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
224 | + if ($data != "") |
|
225 | + eval ('self::$_font_lookup = '.$data.";"); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -216,13 +216,15 @@ |
||
216 | 216 | * @see save_font_families() |
217 | 217 | */ |
218 | 218 | static function load_font_families() { |
219 | - if ( !is_readable(self::CACHE_FILE) ) |
|
220 | - return; |
|
219 | + if ( !is_readable(self::CACHE_FILE) ) { |
|
220 | + return; |
|
221 | + } |
|
221 | 222 | |
222 | 223 | $data = file_get_contents(self::CACHE_FILE); |
223 | 224 | |
224 | - if ( $data != "" ) |
|
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
225 | + if ( $data != "" ) { |
|
226 | + eval ('self::$_font_lookup = ' . $data . ";"); |
|
227 | + } |
|
226 | 228 | } |
227 | 229 | |
228 | 230 | /** |
@@ -60,9 +60,9 @@ discard block |
||
60 | 60 | * Declared here because PHP5 prevents constants from being declared with expressions |
61 | 61 | */ |
62 | 62 | if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) { |
63 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
63 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache"); |
|
64 | 64 | } else { |
65 | - define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
65 | + define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist"); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -78,76 +78,76 @@ discard block |
||
78 | 78 | */ |
79 | 79 | class Font_Metrics { |
80 | 80 | |
81 | - /** |
|
82 | - * @see __DOMPDF_FONT_CACHE_FILE |
|
83 | - */ |
|
84 | - const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE; |
|
81 | + /** |
|
82 | + * @see __DOMPDF_FONT_CACHE_FILE |
|
83 | + */ |
|
84 | + const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE; |
|
85 | 85 | |
86 | - /** |
|
87 | - * Underlying {@link Cpdf} object to perform text size calculations |
|
88 | - * |
|
89 | - * @var Cpdf |
|
90 | - */ |
|
91 | - static protected $_pdf = null; |
|
92 | - |
|
93 | - /** |
|
94 | - * Array of font family names to font files |
|
95 | - * |
|
96 | - * Usually cached by the {@link load_font.php} script |
|
97 | - * |
|
98 | - * @var array |
|
99 | - */ |
|
100 | - static protected $_font_lookup = array(); |
|
86 | + /** |
|
87 | + * Underlying {@link Cpdf} object to perform text size calculations |
|
88 | + * |
|
89 | + * @var Cpdf |
|
90 | + */ |
|
91 | + static protected $_pdf = null; |
|
92 | + |
|
93 | + /** |
|
94 | + * Array of font family names to font files |
|
95 | + * |
|
96 | + * Usually cached by the {@link load_font.php} script |
|
97 | + * |
|
98 | + * @var array |
|
99 | + */ |
|
100 | + static protected $_font_lookup = array(); |
|
101 | 101 | |
102 | 102 | |
103 | - /** |
|
104 | - * Class initialization |
|
105 | - * |
|
106 | - */ |
|
107 | - static function init() { |
|
103 | + /** |
|
104 | + * Class initialization |
|
105 | + * |
|
106 | + */ |
|
107 | + static function init() { |
|
108 | 108 | if (!self::$_pdf) { |
109 | - self::load_font_families(); |
|
110 | - self::$_pdf = Canvas_Factory::get_instance(); |
|
109 | + self::load_font_families(); |
|
110 | + self::$_pdf = Canvas_Factory::get_instance(); |
|
111 | 111 | } |
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Calculates text size, in points |
|
116 | - * |
|
117 | - * @param string $text the text to be sized |
|
118 | - * @param string $font the desired font |
|
119 | - * @param float $size the desired font size |
|
120 | - * @param float $spacing word spacing, if any |
|
121 | - * @return float |
|
122 | - */ |
|
123 | - static function get_text_width($text, $font, $size, $spacing = 0) { |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Calculates text size, in points |
|
116 | + * |
|
117 | + * @param string $text the text to be sized |
|
118 | + * @param string $font the desired font |
|
119 | + * @param float $size the desired font size |
|
120 | + * @param float $spacing word spacing, if any |
|
121 | + * @return float |
|
122 | + */ |
|
123 | + static function get_text_width($text, $font, $size, $spacing = 0) { |
|
124 | 124 | return self::$_pdf->get_text_width($text, $font, $size, $spacing); |
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Calculates font height |
|
129 | - * |
|
130 | - * @param string $font |
|
131 | - * @param float $size |
|
132 | - * @return float |
|
133 | - */ |
|
134 | - static function get_font_height($font, $size) { |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Calculates font height |
|
129 | + * |
|
130 | + * @param string $font |
|
131 | + * @param float $size |
|
132 | + * @return float |
|
133 | + */ |
|
134 | + static function get_font_height($font, $size) { |
|
135 | 135 | return self::$_pdf->get_font_height($font, $size); |
136 | - } |
|
137 | - |
|
138 | - /** |
|
139 | - * Resolves a font family & subtype into an actual font file |
|
140 | - * |
|
141 | - * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'. If |
|
142 | - * the particular font family has no suitable font file, the default font |
|
143 | - * ({@link DOMPDF_DEFAULT_FONT}) is used. The font file returned |
|
144 | - * is the absolute pathname to the font file on the system. |
|
145 | - * |
|
146 | - * @param string $family |
|
147 | - * @param string $subtype |
|
148 | - * @return string |
|
149 | - */ |
|
150 | - static function get_font($family, $subtype = "normal") { |
|
136 | + } |
|
137 | + |
|
138 | + /** |
|
139 | + * Resolves a font family & subtype into an actual font file |
|
140 | + * |
|
141 | + * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'. If |
|
142 | + * the particular font family has no suitable font file, the default font |
|
143 | + * ({@link DOMPDF_DEFAULT_FONT}) is used. The font file returned |
|
144 | + * is the absolute pathname to the font file on the system. |
|
145 | + * |
|
146 | + * @param string $family |
|
147 | + * @param string $subtype |
|
148 | + * @return string |
|
149 | + */ |
|
150 | + static function get_font($family, $subtype = "normal") { |
|
151 | 151 | |
152 | 152 | /* Allow calling for various fonts in search path. Therefore not immediately |
153 | 153 | * return replacement on non match. |
@@ -158,85 +158,85 @@ discard block |
||
158 | 158 | */ |
159 | 159 | |
160 | 160 | if ( $family ) { |
161 | - $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
162 | - $subtype = mb_strtolower($subtype); |
|
161 | + $family = str_replace( array("'", '"'), "", mb_strtolower($family)); |
|
162 | + $subtype = mb_strtolower($subtype); |
|
163 | 163 | |
164 | - if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
164 | + if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
|
165 | 165 | return self::$_font_lookup[$family][$subtype]; |
166 | - } |
|
167 | - return null; |
|
166 | + } |
|
167 | + return null; |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $family = DOMPDF_DEFAULT_FONT; |
171 | 171 | |
172 | 172 | if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
173 | - return self::$_font_lookup[$family][$subtype]; |
|
173 | + return self::$_font_lookup[$family][$subtype]; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
177 | - if (strpos($subtype, $sub) !== false) { |
|
177 | + if (strpos($subtype, $sub) !== false) { |
|
178 | 178 | return $font; |
179 | - } |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | if ($subtype !== "normal") { |
183 | - foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
183 | + foreach ( self::$_font_lookup[$family] as $sub => $font ) { |
|
184 | 184 | if ($sub !== "normal") { |
185 | - return $font; |
|
185 | + return $font; |
|
186 | + } |
|
186 | 187 | } |
187 | - } |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | $subtype = "normal"; |
191 | 191 | |
192 | 192 | if ( isset(self::$_font_lookup[$family][$subtype]) ) { |
193 | - return self::$_font_lookup[$family][$subtype]; |
|
193 | + return self::$_font_lookup[$family][$subtype]; |
|
194 | 194 | } |
195 | 195 | return null; |
196 | - } |
|
197 | - |
|
198 | - /** |
|
199 | - * Saves the stored font family cache |
|
200 | - * |
|
201 | - * The name and location of the cache file are determined by {@link |
|
202 | - * Font_Metrics::CACHE_FILE}. This file should be writable by the |
|
203 | - * webserver process. |
|
204 | - * |
|
205 | - * @see Font_Metrics::load_font_families() |
|
206 | - */ |
|
207 | - static function save_font_families() { |
|
196 | + } |
|
197 | + |
|
198 | + /** |
|
199 | + * Saves the stored font family cache |
|
200 | + * |
|
201 | + * The name and location of the cache file are determined by {@link |
|
202 | + * Font_Metrics::CACHE_FILE}. This file should be writable by the |
|
203 | + * webserver process. |
|
204 | + * |
|
205 | + * @see Font_Metrics::load_font_families() |
|
206 | + */ |
|
207 | + static function save_font_families() { |
|
208 | 208 | |
209 | 209 | file_put_contents(self::CACHE_FILE, var_export(self::$_font_lookup, true)); |
210 | 210 | |
211 | - } |
|
212 | - |
|
213 | - /** |
|
214 | - * Loads the stored font family cache |
|
215 | - * |
|
216 | - * @see save_font_families() |
|
217 | - */ |
|
218 | - static function load_font_families() { |
|
211 | + } |
|
212 | + |
|
213 | + /** |
|
214 | + * Loads the stored font family cache |
|
215 | + * |
|
216 | + * @see save_font_families() |
|
217 | + */ |
|
218 | + static function load_font_families() { |
|
219 | 219 | if ( !is_readable(self::CACHE_FILE) ) |
220 | - return; |
|
220 | + return; |
|
221 | 221 | |
222 | 222 | $data = file_get_contents(self::CACHE_FILE); |
223 | 223 | |
224 | 224 | if ( $data != "" ) |
225 | - eval ('self::$_font_lookup = ' . $data . ";"); |
|
226 | - } |
|
227 | - |
|
228 | - /** |
|
229 | - * Returns the current font lookup table |
|
230 | - * |
|
231 | - * @return array |
|
232 | - */ |
|
233 | - static function get_font_families() { |
|
225 | + eval ('self::$_font_lookup = ' . $data . ";"); |
|
226 | + } |
|
227 | + |
|
228 | + /** |
|
229 | + * Returns the current font lookup table |
|
230 | + * |
|
231 | + * @return array |
|
232 | + */ |
|
233 | + static function get_font_families() { |
|
234 | 234 | return self::$_font_lookup; |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | - static function set_font_family($fontname, $entry) { |
|
237 | + static function set_font_family($fontname, $entry) { |
|
238 | 238 | self::$_font_lookup[mb_strtolower($fontname)] = $entry; |
239 | - } |
|
239 | + } |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | Font_Metrics::init(); |
@@ -662,6 +662,9 @@ |
||
662 | 662 | class FrameList implements IteratorAggregate { |
663 | 663 | protected $_frame; |
664 | 664 | |
665 | + /** |
|
666 | + * @param Frame $frame |
|
667 | + */ |
|
665 | 668 | function __construct($frame) { $this->_frame = $frame; } |
666 | 669 | function getIterator() { return new FrameListIterator($this->_frame); } |
667 | 670 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -53,105 +52,105 @@ discard block |
||
53 | 52 | */ |
54 | 53 | class Frame { |
55 | 54 | |
56 | - /** |
|
57 | - * The DOMNode object this frame represents |
|
58 | - * |
|
59 | - * @var DOMNode |
|
60 | - */ |
|
61 | - protected $_node; |
|
62 | - |
|
63 | - /** |
|
64 | - * Unique identifier for this frame. Used to reference this frame |
|
65 | - * via the node. |
|
66 | - * |
|
67 | - * @var string |
|
68 | - */ |
|
69 | - protected $_id; |
|
70 | - |
|
71 | - /** |
|
72 | - * Unique id counter |
|
73 | - */ |
|
74 | - static protected $ID_COUNTER = 0; |
|
55 | + /** |
|
56 | + * The DOMNode object this frame represents |
|
57 | + * |
|
58 | + * @var DOMNode |
|
59 | + */ |
|
60 | + protected $_node; |
|
61 | + |
|
62 | + /** |
|
63 | + * Unique identifier for this frame. Used to reference this frame |
|
64 | + * via the node. |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $_id; |
|
69 | + |
|
70 | + /** |
|
71 | + * Unique id counter |
|
72 | + */ |
|
73 | + static protected $ID_COUNTER = 0; |
|
75 | 74 | |
76 | - /** |
|
77 | - * This frame's calculated style |
|
78 | - * |
|
79 | - * @var Style |
|
80 | - */ |
|
81 | - protected $_style; |
|
82 | - |
|
83 | - /** |
|
84 | - * This frame's original style. Needed for cases where frames are |
|
85 | - * split across pages. |
|
86 | - * |
|
87 | - * @var Style |
|
88 | - */ |
|
89 | - protected $_original_style; |
|
75 | + /** |
|
76 | + * This frame's calculated style |
|
77 | + * |
|
78 | + * @var Style |
|
79 | + */ |
|
80 | + protected $_style; |
|
81 | + |
|
82 | + /** |
|
83 | + * This frame's original style. Needed for cases where frames are |
|
84 | + * split across pages. |
|
85 | + * |
|
86 | + * @var Style |
|
87 | + */ |
|
88 | + protected $_original_style; |
|
90 | 89 | |
91 | - /** |
|
92 | - * This frame's parent in the document tree. |
|
93 | - * |
|
94 | - * @var Frame |
|
95 | - */ |
|
96 | - protected $_parent; |
|
97 | - |
|
98 | - /** |
|
99 | - * This frame's first child. All children are handled as a |
|
100 | - * doubly-linked list. |
|
101 | - * |
|
102 | - * @var Frame |
|
103 | - */ |
|
104 | - protected $_first_child; |
|
105 | - |
|
106 | - /** |
|
107 | - * This frame's last child. |
|
108 | - * |
|
109 | - * @var Frame |
|
110 | - */ |
|
111 | - protected $_last_child; |
|
112 | - |
|
113 | - /** |
|
114 | - * This frame's previous sibling in the document tree. |
|
115 | - * |
|
116 | - * @var Frame |
|
117 | - */ |
|
118 | - protected $_prev_sibling; |
|
119 | - |
|
120 | - /** |
|
121 | - * This frame's next sibling in the document tree. |
|
122 | - * |
|
123 | - * @var Frame |
|
124 | - */ |
|
125 | - protected $_next_sibling; |
|
90 | + /** |
|
91 | + * This frame's parent in the document tree. |
|
92 | + * |
|
93 | + * @var Frame |
|
94 | + */ |
|
95 | + protected $_parent; |
|
96 | + |
|
97 | + /** |
|
98 | + * This frame's first child. All children are handled as a |
|
99 | + * doubly-linked list. |
|
100 | + * |
|
101 | + * @var Frame |
|
102 | + */ |
|
103 | + protected $_first_child; |
|
104 | + |
|
105 | + /** |
|
106 | + * This frame's last child. |
|
107 | + * |
|
108 | + * @var Frame |
|
109 | + */ |
|
110 | + protected $_last_child; |
|
111 | + |
|
112 | + /** |
|
113 | + * This frame's previous sibling in the document tree. |
|
114 | + * |
|
115 | + * @var Frame |
|
116 | + */ |
|
117 | + protected $_prev_sibling; |
|
118 | + |
|
119 | + /** |
|
120 | + * This frame's next sibling in the document tree. |
|
121 | + * |
|
122 | + * @var Frame |
|
123 | + */ |
|
124 | + protected $_next_sibling; |
|
126 | 125 | |
127 | - /** |
|
128 | - * This frame's containing block (used in layout): array(x, y, w, h) |
|
129 | - * |
|
130 | - * @var array |
|
131 | - */ |
|
132 | - protected $_containing_block; |
|
133 | - |
|
134 | - /** |
|
135 | - * Position on the page of the top-left corner of the margin box of |
|
136 | - * this frame: array(x,y) |
|
137 | - * |
|
138 | - * @var array |
|
139 | - */ |
|
140 | - protected $_position; |
|
141 | - |
|
142 | - /** |
|
143 | - * This frame's decorator |
|
144 | - * |
|
145 | - * @var Frame_Decorator |
|
146 | - */ |
|
147 | - protected $_decorator; |
|
148 | - |
|
149 | - /** |
|
150 | - * Class constructor |
|
151 | - * |
|
152 | - * @param DOMNode $node the DOMNode this frame represents |
|
153 | - */ |
|
154 | - function __construct(DomNode $node) { |
|
126 | + /** |
|
127 | + * This frame's containing block (used in layout): array(x, y, w, h) |
|
128 | + * |
|
129 | + * @var array |
|
130 | + */ |
|
131 | + protected $_containing_block; |
|
132 | + |
|
133 | + /** |
|
134 | + * Position on the page of the top-left corner of the margin box of |
|
135 | + * this frame: array(x,y) |
|
136 | + * |
|
137 | + * @var array |
|
138 | + */ |
|
139 | + protected $_position; |
|
140 | + |
|
141 | + /** |
|
142 | + * This frame's decorator |
|
143 | + * |
|
144 | + * @var Frame_Decorator |
|
145 | + */ |
|
146 | + protected $_decorator; |
|
147 | + |
|
148 | + /** |
|
149 | + * Class constructor |
|
150 | + * |
|
151 | + * @param DOMNode $node the DOMNode this frame represents |
|
152 | + */ |
|
153 | + function __construct(DomNode $node) { |
|
155 | 154 | $this->_node = $node; |
156 | 155 | |
157 | 156 | $this->_parent = null; |
@@ -163,48 +162,48 @@ discard block |
||
163 | 162 | $this->_original_style = null; |
164 | 163 | |
165 | 164 | $this->_containing_block = array("x" => null, |
166 | - "y" => null, |
|
167 | - "w" => null, |
|
168 | - "h" => null); |
|
165 | + "y" => null, |
|
166 | + "w" => null, |
|
167 | + "h" => null); |
|
169 | 168 | $this->_position = array("x" => null, |
170 | - "y" => null); |
|
169 | + "y" => null); |
|
171 | 170 | |
172 | 171 | $this->_decorator = null; |
173 | 172 | |
174 | 173 | $this->set_id( self::$ID_COUNTER++ ); |
175 | - } |
|
174 | + } |
|
176 | 175 | |
177 | - /** |
|
178 | - * "Destructor": forcibly free all references held by this frame |
|
179 | - * |
|
180 | - * @param bool $recursive if true, call dispose on all children |
|
181 | - */ |
|
182 | - function dispose($recursive = false) { |
|
176 | + /** |
|
177 | + * "Destructor": forcibly free all references held by this frame |
|
178 | + * |
|
179 | + * @param bool $recursive if true, call dispose on all children |
|
180 | + */ |
|
181 | + function dispose($recursive = false) { |
|
183 | 182 | |
184 | 183 | if ( $recursive ) { |
185 | - while ( $child = $this->_first_child ) |
|
184 | + while ( $child = $this->_first_child ) |
|
186 | 185 | $child->dispose(true); |
187 | 186 | } |
188 | 187 | |
189 | 188 | // Remove this frame from the tree |
190 | 189 | if ( $this->_prev_sibling ) { |
191 | - $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
|
190 | + $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
|
192 | 191 | } |
193 | 192 | |
194 | 193 | if ( $this->_next_sibling ) { |
195 | - $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
|
194 | + $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
|
196 | 195 | } |
197 | 196 | |
198 | 197 | if ( $this->_parent && $this->_parent->_first_child === $this ) { |
199 | - $this->_parent->_first_child = $this->_next_sibling; |
|
198 | + $this->_parent->_first_child = $this->_next_sibling; |
|
200 | 199 | } |
201 | 200 | |
202 | 201 | if ( $this->_parent && $this->_parent->_last_child === $this ) { |
203 | - $this->_parent->_last_child = $this->_prev_sibling; |
|
202 | + $this->_parent->_last_child = $this->_prev_sibling; |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | if ( $this->_parent ) { |
207 | - $this->_parent->get_node()->removeChild($this->_node); |
|
206 | + $this->_parent->get_node()->removeChild($this->_node); |
|
208 | 207 | } |
209 | 208 | |
210 | 209 | $this->_style->dispose(); |
@@ -212,369 +211,369 @@ discard block |
||
212 | 211 | $this->_original_style->dispose(); |
213 | 212 | unset($this->_original_style); |
214 | 213 | |
215 | - } |
|
214 | + } |
|
216 | 215 | |
217 | - // Re-initialize the frame |
|
218 | - function reset() { |
|
216 | + // Re-initialize the frame |
|
217 | + function reset() { |
|
219 | 218 | $this->_position = array("x" => null, |
220 | - "y" => null); |
|
219 | + "y" => null); |
|
221 | 220 | $this->_containing_block = array("x" => null, |
222 | - "y" => null, |
|
223 | - "w" => null, |
|
224 | - "h" => null); |
|
221 | + "y" => null, |
|
222 | + "w" => null, |
|
223 | + "h" => null); |
|
225 | 224 | |
226 | 225 | unset($this->_style); |
227 | 226 | $this->_style = clone $this->_original_style; |
228 | 227 | |
229 | - } |
|
228 | + } |
|
230 | 229 | |
231 | - //........................................................................ |
|
232 | - |
|
233 | - // Accessor methods |
|
234 | - function get_node() { return $this->_node; } |
|
235 | - function get_id() { return $this->_id; } |
|
236 | - function get_style() { return $this->_style; } |
|
237 | - function get_original_style() { return $this->_original_style; } |
|
238 | - function get_parent() { return $this->_parent; } |
|
239 | - function get_decorator() { return $this->_decorator; } |
|
240 | - function get_first_child() { return $this->_first_child; } |
|
241 | - function get_last_child() { return $this->_last_child; } |
|
242 | - function get_prev_sibling() { return $this->_prev_sibling; } |
|
243 | - function get_next_sibling() { return $this->_next_sibling; } |
|
244 | - |
|
245 | - function get_children() { return new FrameList($this); } |
|
230 | + //........................................................................ |
|
231 | + |
|
232 | + // Accessor methods |
|
233 | + function get_node() { return $this->_node; } |
|
234 | + function get_id() { return $this->_id; } |
|
235 | + function get_style() { return $this->_style; } |
|
236 | + function get_original_style() { return $this->_original_style; } |
|
237 | + function get_parent() { return $this->_parent; } |
|
238 | + function get_decorator() { return $this->_decorator; } |
|
239 | + function get_first_child() { return $this->_first_child; } |
|
240 | + function get_last_child() { return $this->_last_child; } |
|
241 | + function get_prev_sibling() { return $this->_prev_sibling; } |
|
242 | + function get_next_sibling() { return $this->_next_sibling; } |
|
243 | + |
|
244 | + function get_children() { return new FrameList($this); } |
|
246 | 245 | |
247 | - // Layout property accessors |
|
248 | - function get_containing_block($i = null) { |
|
246 | + // Layout property accessors |
|
247 | + function get_containing_block($i = null) { |
|
249 | 248 | if ( isset($i) ) |
250 | - return $this->_containing_block[$i]; |
|
249 | + return $this->_containing_block[$i]; |
|
251 | 250 | return $this->_containing_block; |
252 | - } |
|
251 | + } |
|
253 | 252 | |
254 | - function get_position($i = null) { |
|
253 | + function get_position($i = null) { |
|
255 | 254 | if ( isset($i) ) |
256 | - return $this->_position[$i]; |
|
255 | + return $this->_position[$i]; |
|
257 | 256 | return array($this->_position["x"], |
258 | - $this->_position["y"], |
|
259 | - "x"=>$this->_position["x"], |
|
260 | - "y"=>$this->_position["y"]); |
|
261 | - } |
|
257 | + $this->_position["y"], |
|
258 | + "x"=>$this->_position["x"], |
|
259 | + "y"=>$this->_position["y"]); |
|
260 | + } |
|
262 | 261 | |
263 | - //........................................................................ |
|
262 | + //........................................................................ |
|
264 | 263 | |
265 | - // Return the height of the margin box of the frame, in pt. Meaningless |
|
266 | - // unless the height has been calculated properly. |
|
267 | - function get_margin_height() { |
|
264 | + // Return the height of the margin box of the frame, in pt. Meaningless |
|
265 | + // unless the height has been calculated properly. |
|
266 | + function get_margin_height() { |
|
268 | 267 | return $this->_style->length_in_pt(array($this->_style->height, |
269 | - $this->_style->margin_top, |
|
270 | - $this->_style->margin_bottom, |
|
271 | - $this->_style->border_top_width, |
|
272 | - $this->_style->border_bottom_width, |
|
273 | - $this->_style->padding_top, |
|
274 | - $this->_style->padding_bottom), |
|
275 | - $this->_containing_block["w"]); |
|
276 | - } |
|
277 | - |
|
278 | - // Return the width of the margin box of the frame, in pt. Meaningless |
|
279 | - // unless the width has been calculted properly. |
|
280 | - function get_margin_width() { |
|
268 | + $this->_style->margin_top, |
|
269 | + $this->_style->margin_bottom, |
|
270 | + $this->_style->border_top_width, |
|
271 | + $this->_style->border_bottom_width, |
|
272 | + $this->_style->padding_top, |
|
273 | + $this->_style->padding_bottom), |
|
274 | + $this->_containing_block["w"]); |
|
275 | + } |
|
276 | + |
|
277 | + // Return the width of the margin box of the frame, in pt. Meaningless |
|
278 | + // unless the width has been calculted properly. |
|
279 | + function get_margin_width() { |
|
281 | 280 | return $this->_style->length_in_pt(array($this->_style->width, |
282 | - $this->_style->margin_left, |
|
283 | - $this->_style->margin_right, |
|
284 | - $this->_style->border_left_width, |
|
285 | - $this->_style->border_right_width, |
|
286 | - $this->_style->padding_left, |
|
287 | - $this->_style->padding_right), |
|
288 | - $this->_containing_block["w"]); |
|
289 | - } |
|
290 | - |
|
291 | - // Return the padding box (x,y,w,h) of the frame |
|
292 | - function get_padding_box() { |
|
281 | + $this->_style->margin_left, |
|
282 | + $this->_style->margin_right, |
|
283 | + $this->_style->border_left_width, |
|
284 | + $this->_style->border_right_width, |
|
285 | + $this->_style->padding_left, |
|
286 | + $this->_style->padding_right), |
|
287 | + $this->_containing_block["w"]); |
|
288 | + } |
|
289 | + |
|
290 | + // Return the padding box (x,y,w,h) of the frame |
|
291 | + function get_padding_box() { |
|
293 | 292 | $x = $this->_position["x"] + |
294 | 293 | $this->_style->length_in_pt(array($this->_style->margin_left, |
295 | 294 | $this->_style->border_left_width), |
296 | - $this->_containing_block["w"]); |
|
295 | + $this->_containing_block["w"]); |
|
297 | 296 | $y = $this->_position["y"] + |
298 | 297 | $this->_style->length_in_pt(array($this->_style->margin_top, |
299 | 298 | $this->_style->border_top_width), |
300 | - $this->_containing_block["w"]); |
|
299 | + $this->_containing_block["w"]); |
|
301 | 300 | |
302 | 301 | $w = $this->_style->length_in_pt(array($this->_style->padding_left, |
303 | - $this->_style->width, |
|
304 | - $this->_style->padding_right), |
|
305 | - $this->_containing_block["w"]); |
|
302 | + $this->_style->width, |
|
303 | + $this->_style->padding_right), |
|
304 | + $this->_containing_block["w"]); |
|
306 | 305 | |
307 | 306 | $h = $this->_style->length_in_pt(array($this->_style->padding_top, |
308 | - $this->_style->height, |
|
309 | - $this->_style->padding_bottom), |
|
310 | - $this->_containing_block["w"]); |
|
307 | + $this->_style->height, |
|
308 | + $this->_style->padding_bottom), |
|
309 | + $this->_containing_block["w"]); |
|
311 | 310 | |
312 | 311 | return array(0 => $x, "x" => $x, |
313 | - 1 => $y, "y" => $y, |
|
314 | - 2 => $w, "w" => $w, |
|
315 | - 3 => $h, "h" => $h); |
|
316 | - } |
|
312 | + 1 => $y, "y" => $y, |
|
313 | + 2 => $w, "w" => $w, |
|
314 | + 3 => $h, "h" => $h); |
|
315 | + } |
|
317 | 316 | |
318 | - // Return the border box of the frame |
|
319 | - function get_border_box() { |
|
317 | + // Return the border box of the frame |
|
318 | + function get_border_box() { |
|
320 | 319 | $x = $this->_position["x"] + |
321 | 320 | $this->_style->length_in_pt($this->_style->margin_left, |
322 | - $this->_containing_block["w"]); |
|
321 | + $this->_containing_block["w"]); |
|
323 | 322 | $y = $this->_position["y"] + |
324 | 323 | $this->_style->length_in_pt($this->_style->margin_top, |
325 | - $this->_containing_block["w"]); |
|
324 | + $this->_containing_block["w"]); |
|
326 | 325 | |
327 | 326 | $w = $this->_style->length_in_pt(array($this->_style->border_left_width, |
328 | - $this->_style->padding_left, |
|
329 | - $this->_style->width, |
|
330 | - $this->_style->padding_right, |
|
331 | - $this->_style->border_right_width), |
|
332 | - $this->_containing_block["w"]); |
|
327 | + $this->_style->padding_left, |
|
328 | + $this->_style->width, |
|
329 | + $this->_style->padding_right, |
|
330 | + $this->_style->border_right_width), |
|
331 | + $this->_containing_block["w"]); |
|
333 | 332 | |
334 | 333 | $h = $this->_style->length_in_pt(array($this->_style->border_top_width, |
335 | - $this->_style->padding_top, |
|
336 | - $this->_style->height, |
|
337 | - $this->_style->padding_bottom, |
|
338 | - $this->_style->border_bottom_width), |
|
339 | - $this->_containing_block["w"]); |
|
334 | + $this->_style->padding_top, |
|
335 | + $this->_style->height, |
|
336 | + $this->_style->padding_bottom, |
|
337 | + $this->_style->border_bottom_width), |
|
338 | + $this->_containing_block["w"]); |
|
340 | 339 | |
341 | 340 | return array(0 => $x, "x" => $x, |
342 | - 1 => $y, "y" => $y, |
|
343 | - 2 => $w, "w" => $w, |
|
344 | - 3 => $h, "h" => $h); |
|
341 | + 1 => $y, "y" => $y, |
|
342 | + 2 => $w, "w" => $w, |
|
343 | + 3 => $h, "h" => $h); |
|
345 | 344 | |
346 | - } |
|
345 | + } |
|
347 | 346 | |
348 | - //........................................................................ |
|
347 | + //........................................................................ |
|
349 | 348 | |
350 | - // Set methods |
|
351 | - function set_id($id) { |
|
349 | + // Set methods |
|
350 | + function set_id($id) { |
|
352 | 351 | $this->_id = $id; |
353 | 352 | |
354 | 353 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 354 | // Since these are the only objects that we can assign CSS rules to, |
356 | 355 | // this shortcoming is okay. |
357 | 356 | if ( $this->_node->nodeType == 1) |
358 | - $this->_node->setAttribute("frame_id", $id); |
|
359 | - } |
|
357 | + $this->_node->setAttribute("frame_id", $id); |
|
358 | + } |
|
360 | 359 | |
361 | - function set_style(Style $style) { |
|
360 | + function set_style(Style $style) { |
|
362 | 361 | if ( is_null($this->_style) ) |
363 | - $this->_original_style = clone $style; |
|
362 | + $this->_original_style = clone $style; |
|
364 | 363 | |
365 | 364 | $this->_style = $style; |
366 | - } |
|
365 | + } |
|
367 | 366 | |
368 | - function set_decorator(Frame_Decorator $decorator) { |
|
367 | + function set_decorator(Frame_Decorator $decorator) { |
|
369 | 368 | $this->_decorator = $decorator; |
370 | - } |
|
369 | + } |
|
371 | 370 | |
372 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
371 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
373 | 372 | if ( is_array($x) ){ |
374 | - foreach($x AS $key => $val){ |
|
375 | - $$key = $val; |
|
376 | - } |
|
373 | + foreach($x AS $key => $val){ |
|
374 | + $$key = $val; |
|
375 | + } |
|
377 | 376 | } |
378 | 377 | |
379 | 378 | if (is_numeric($x)) { |
380 | - $this->_containing_block[0] = $x; |
|
381 | - $this->_containing_block["x"] = $x; |
|
379 | + $this->_containing_block[0] = $x; |
|
380 | + $this->_containing_block["x"] = $x; |
|
382 | 381 | } |
383 | 382 | |
384 | 383 | if (is_numeric($y)) { |
385 | - $this->_containing_block[1] = $y; |
|
386 | - $this->_containing_block["y"] = $y; |
|
384 | + $this->_containing_block[1] = $y; |
|
385 | + $this->_containing_block["y"] = $y; |
|
387 | 386 | } |
388 | 387 | |
389 | 388 | if (is_numeric($w)) { |
390 | - $this->_containing_block[2] = $w; |
|
391 | - $this->_containing_block["w"] = $w; |
|
389 | + $this->_containing_block[2] = $w; |
|
390 | + $this->_containing_block["w"] = $w; |
|
392 | 391 | } |
393 | 392 | |
394 | 393 | if (is_numeric($h)) { |
395 | - $this->_containing_block[3] = $h; |
|
396 | - $this->_containing_block["h"] = $h; |
|
394 | + $this->_containing_block[3] = $h; |
|
395 | + $this->_containing_block["h"] = $h; |
|
397 | 396 | } |
398 | 397 | |
399 | - } |
|
398 | + } |
|
400 | 399 | |
401 | - function set_position($x = null, $y = null) { |
|
400 | + function set_position($x = null, $y = null) { |
|
402 | 401 | if ( is_array($x) ) |
403 | - extract($x); |
|
402 | + extract($x); |
|
404 | 403 | |
405 | 404 | if ( is_numeric($x) ) { |
406 | - $this->_position[0] = $x; |
|
407 | - $this->_position["x"] = $x; |
|
405 | + $this->_position[0] = $x; |
|
406 | + $this->_position["x"] = $x; |
|
408 | 407 | } |
409 | 408 | |
410 | 409 | if ( is_numeric($y) ) { |
411 | - $this->_position[1] = $y; |
|
412 | - $this->_position["y"] = $y; |
|
410 | + $this->_position[1] = $y; |
|
411 | + $this->_position["y"] = $y; |
|
412 | + } |
|
413 | 413 | } |
414 | - } |
|
415 | 414 | |
416 | - //........................................................................ |
|
415 | + //........................................................................ |
|
417 | 416 | |
418 | - function prepend_child(Frame $child, $update_node = true) { |
|
417 | + function prepend_child(Frame $child, $update_node = true) { |
|
419 | 418 | |
420 | 419 | if ( $update_node ) |
421 | - $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
420 | + $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
422 | 421 | |
423 | 422 | // Remove the child from its parent |
424 | 423 | if ( $child->_parent ) |
425 | - $child->_parent->remove_child($child, false); |
|
424 | + $child->_parent->remove_child($child, false); |
|
426 | 425 | |
427 | 426 | $child->_parent = $this; |
428 | 427 | $child->_prev_sibling = null; |
429 | 428 | |
430 | 429 | // Handle the first child |
431 | 430 | if ( !$this->_first_child ) { |
432 | - $this->_first_child = $child; |
|
433 | - $this->_last_child = $child; |
|
434 | - $child->_next_sibling = null; |
|
431 | + $this->_first_child = $child; |
|
432 | + $this->_last_child = $child; |
|
433 | + $child->_next_sibling = null; |
|
435 | 434 | |
436 | 435 | } else { |
437 | 436 | |
438 | - $this->_first_child->_prev_sibling = $child; |
|
439 | - $child->_next_sibling = $this->_first_child; |
|
440 | - $this->_first_child = $child; |
|
437 | + $this->_first_child->_prev_sibling = $child; |
|
438 | + $child->_next_sibling = $this->_first_child; |
|
439 | + $this->_first_child = $child; |
|
441 | 440 | |
442 | 441 | } |
443 | - } |
|
442 | + } |
|
444 | 443 | |
445 | - function append_child(Frame $child, $update_node = true) { |
|
444 | + function append_child(Frame $child, $update_node = true) { |
|
446 | 445 | |
447 | 446 | if ( $update_node ) |
448 | - $this->_node->appendChild($child->_node); |
|
447 | + $this->_node->appendChild($child->_node); |
|
449 | 448 | |
450 | 449 | // Remove the child from its parent |
451 | 450 | if ( $child->_parent ) |
452 | - $child->_parent->remove_child($child, false); |
|
451 | + $child->_parent->remove_child($child, false); |
|
453 | 452 | |
454 | 453 | $child->_parent = $this; |
455 | 454 | $child->_next_sibling = null; |
456 | 455 | |
457 | 456 | // Handle the first child |
458 | 457 | if ( !$this->_last_child ) { |
459 | - $this->_first_child = $child; |
|
460 | - $this->_last_child = $child; |
|
461 | - $child->_prev_sibling = null; |
|
458 | + $this->_first_child = $child; |
|
459 | + $this->_last_child = $child; |
|
460 | + $child->_prev_sibling = null; |
|
462 | 461 | |
463 | 462 | } else { |
464 | 463 | |
465 | - $this->_last_child->_next_sibling = $child; |
|
466 | - $child->_prev_sibling = $this->_last_child; |
|
467 | - $this->_last_child = $child; |
|
464 | + $this->_last_child->_next_sibling = $child; |
|
465 | + $child->_prev_sibling = $this->_last_child; |
|
466 | + $this->_last_child = $child; |
|
468 | 467 | |
469 | 468 | } |
470 | - } |
|
469 | + } |
|
471 | 470 | |
472 | - // Inserts a new child immediately before the specified frame |
|
473 | - function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
471 | + // Inserts a new child immediately before the specified frame |
|
472 | + function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
474 | 473 | |
475 | 474 | if ( $ref === $this->_first_child ) { |
476 | - $this->prepend_child($new_child, $update_node); |
|
477 | - return; |
|
475 | + $this->prepend_child($new_child, $update_node); |
|
476 | + return; |
|
478 | 477 | } |
479 | 478 | |
480 | 479 | if ( is_null($ref) ) { |
481 | - $this->append_child($new_child, $update_node); |
|
482 | - return; |
|
480 | + $this->append_child($new_child, $update_node); |
|
481 | + return; |
|
483 | 482 | } |
484 | 483 | |
485 | 484 | if ( $ref->_parent !== $this ) |
486 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
485 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
487 | 486 | |
488 | 487 | // Update the node |
489 | 488 | if ( $update_node ) |
490 | - $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
489 | + $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
491 | 490 | |
492 | 491 | // Remove the child from its parent |
493 | 492 | if ( $new_child->_parent ) |
494 | - $new_child->_parent->remove_child($new_child, false); |
|
493 | + $new_child->_parent->remove_child($new_child, false); |
|
495 | 494 | |
496 | 495 | $new_child->_parent = $this; |
497 | 496 | $new_child->_next_sibling = $ref; |
498 | 497 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 498 | |
500 | 499 | if ( $ref->_prev_sibling ) |
501 | - $ref->_prev_sibling->_next_sibling = $new_child; |
|
500 | + $ref->_prev_sibling->_next_sibling = $new_child; |
|
502 | 501 | |
503 | 502 | $ref->_prev_sibling = $new_child; |
504 | - } |
|
503 | + } |
|
505 | 504 | |
506 | - // Inserts a new child immediately after the specified frame |
|
507 | - function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
505 | + // Inserts a new child immediately after the specified frame |
|
506 | + function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
508 | 507 | |
509 | 508 | if ( $ref === $this->_last_child ) { |
510 | - $this->append_child($new_child, $update_node); |
|
511 | - return; |
|
509 | + $this->append_child($new_child, $update_node); |
|
510 | + return; |
|
512 | 511 | } |
513 | 512 | |
514 | 513 | if ( is_null($ref) ) { |
515 | - $this->prepend_child($new_child, $update_node); |
|
516 | - return; |
|
514 | + $this->prepend_child($new_child, $update_node); |
|
515 | + return; |
|
517 | 516 | } |
518 | 517 | |
519 | 518 | if ( $ref->_parent !== $this ) |
520 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
519 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
521 | 520 | |
522 | 521 | // Update the node |
523 | 522 | if ( $update_node ) { |
524 | - if ( $ref->_next_sibling ) { |
|
523 | + if ( $ref->_next_sibling ) { |
|
525 | 524 | $next_node = $ref->_next_sibling->_node; |
526 | 525 | $this->_node->insertBefore($new_child->_node, $next_node); |
527 | - } else { |
|
526 | + } else { |
|
528 | 527 | $new_child->_node = $this->_node->appendChild($new_child); |
529 | - } |
|
528 | + } |
|
530 | 529 | } |
531 | 530 | |
532 | 531 | // Remove the child from its parent |
533 | 532 | if ( $new_child->_parent) |
534 | - $new_child->_parent->remove_child($new_child, false); |
|
533 | + $new_child->_parent->remove_child($new_child, false); |
|
535 | 534 | |
536 | 535 | $new_child->_parent = $this; |
537 | 536 | $new_child->_prev_sibling = $ref; |
538 | 537 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 538 | |
540 | 539 | if ( $ref->_next_sibling ) |
541 | - $ref->_next_sibling->_prev_sibling = $new_child; |
|
540 | + $ref->_next_sibling->_prev_sibling = $new_child; |
|
542 | 541 | |
543 | 542 | $ref->_next_sibling = $new_child; |
544 | - } |
|
543 | + } |
|
545 | 544 | |
546 | 545 | |
547 | - function remove_child(Frame $child, $update_node = true) { |
|
546 | + function remove_child(Frame $child, $update_node = true) { |
|
548 | 547 | |
549 | 548 | if ( $child->_parent !== $this ) |
550 | - throw new DOMPDF_Exception("Child not found in this frame"); |
|
549 | + throw new DOMPDF_Exception("Child not found in this frame"); |
|
551 | 550 | |
552 | 551 | if ( $update_node ) |
553 | - $this->_node->removeChild($child->_node); |
|
552 | + $this->_node->removeChild($child->_node); |
|
554 | 553 | |
555 | 554 | if ( $child === $this->_first_child ) |
556 | - $this->_first_child = $child->_next_sibling; |
|
555 | + $this->_first_child = $child->_next_sibling; |
|
557 | 556 | |
558 | 557 | if ( $child === $this->_last_child ) |
559 | - $this->_last_child = $child->_prev_sibling; |
|
558 | + $this->_last_child = $child->_prev_sibling; |
|
560 | 559 | |
561 | 560 | if ( $child->_prev_sibling ) |
562 | - $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
561 | + $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
563 | 562 | |
564 | 563 | if ( $child->_next_sibling ) |
565 | - $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
564 | + $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
566 | 565 | |
567 | 566 | $child->_next_sibling = null; |
568 | 567 | $child->_prev_sibling = null; |
569 | 568 | $child->_parent = null; |
570 | 569 | return $child; |
571 | 570 | |
572 | - } |
|
571 | + } |
|
573 | 572 | |
574 | - //........................................................................ |
|
573 | + //........................................................................ |
|
575 | 574 | |
576 | - // Debugging function: |
|
577 | - function __toString() { |
|
575 | + // Debugging function: |
|
576 | + function __toString() { |
|
578 | 577 | |
579 | 578 | // Skip empty text frames |
580 | 579 | // if ( $this->_node->nodeName === "#text" && |
@@ -588,29 +587,29 @@ discard block |
||
588 | 587 | $str .= "Class: " .get_class($this) . "<br/>"; |
589 | 588 | |
590 | 589 | if ( $this->_node->nodeName === "#text" ) { |
591 | - $tmp = htmlspecialchars($this->_node->nodeValue); |
|
592 | - $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
590 | + $tmp = htmlspecialchars($this->_node->nodeValue); |
|
591 | + $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
593 | 592 | (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
594 | 593 | } |
595 | 594 | if ( $this->_parent ) |
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
595 | + $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | 596 | " (" . spl_object_hash($this->_parent->_node) . ") " . |
598 | 597 | "<br/>"; |
599 | 598 | |
600 | 599 | if ( $this->_prev_sibling ) |
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
600 | + $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | 601 | " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
603 | 602 | "<br/>"; |
604 | 603 | |
605 | 604 | if ( $this->_next_sibling ) |
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
605 | + $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | 606 | " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
608 | 607 | "<br/>"; |
609 | 608 | |
610 | 609 | $d = $this->get_decorator(); |
611 | 610 | while ($d && $d != $d->get_decorator()) { |
612 | - $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
613 | - $d = $d->get_decorator(); |
|
611 | + $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
612 | + $d = $d->get_decorator(); |
|
614 | 613 | } |
615 | 614 | |
616 | 615 | $str .= "Position: " . pre_r($this->_position, true); |
@@ -621,33 +620,33 @@ discard block |
||
621 | 620 | $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>"; |
622 | 621 | |
623 | 622 | if ( $this->_decorator instanceof Block_Frame_Decorator ) { |
624 | - $str .= "Lines:<pre>"; |
|
625 | - foreach ($this->_decorator->get_lines() as $line) { |
|
623 | + $str .= "Lines:<pre>"; |
|
624 | + foreach ($this->_decorator->get_lines() as $line) { |
|
626 | 625 | foreach ($line["frames"] as $frame) { |
627 | - if ($frame instanceof Text_Frame_Decorator) { |
|
626 | + if ($frame instanceof Text_Frame_Decorator) { |
|
628 | 627 | $str .= "\ntext: "; |
629 | 628 | $str .= "'". htmlspecialchars($frame->get_text()) ."'"; |
630 | - } else { |
|
629 | + } else { |
|
631 | 630 | $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; |
632 | - } |
|
631 | + } |
|
633 | 632 | } |
634 | 633 | |
635 | 634 | $str .= |
636 | - //"\ncount => " . $line["count"] . "\n". |
|
637 | - "\ny => " . $line["y"] . "\n" . |
|
638 | - "w => " . $line["w"] . "\n" . |
|
639 | - "h => " . $line["h"] . "\n"; |
|
640 | - } |
|
641 | - $str .= "</pre>"; |
|
635 | + //"\ncount => " . $line["count"] . "\n". |
|
636 | + "\ny => " . $line["y"] . "\n" . |
|
637 | + "w => " . $line["w"] . "\n" . |
|
638 | + "h => " . $line["h"] . "\n"; |
|
639 | + } |
|
640 | + $str .= "</pre>"; |
|
642 | 641 | } |
643 | 642 | $str .= "\n"; |
644 | 643 | if ( php_sapi_name() === "cli" ) |
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
644 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | 645 | array("\n","",""), |
647 | 646 | $str)); |
648 | 647 | |
649 | 648 | return $str; |
650 | - } |
|
649 | + } |
|
651 | 650 | |
652 | 651 | } |
653 | 652 | |
@@ -660,10 +659,10 @@ discard block |
||
660 | 659 | * @package dompdf |
661 | 660 | */ |
662 | 661 | class FrameList implements IteratorAggregate { |
663 | - protected $_frame; |
|
662 | + protected $_frame; |
|
664 | 663 | |
665 | - function __construct($frame) { $this->_frame = $frame; } |
|
666 | - function getIterator() { return new FrameListIterator($this->_frame); } |
|
664 | + function __construct($frame) { $this->_frame = $frame; } |
|
665 | + function getIterator() { return new FrameListIterator($this->_frame); } |
|
667 | 666 | } |
668 | 667 | |
669 | 668 | /** |
@@ -677,37 +676,37 @@ discard block |
||
677 | 676 | */ |
678 | 677 | class FrameListIterator implements Iterator { |
679 | 678 | |
680 | - protected $_parent; |
|
681 | - protected $_cur; |
|
682 | - protected $_num; |
|
679 | + protected $_parent; |
|
680 | + protected $_cur; |
|
681 | + protected $_num; |
|
683 | 682 | |
684 | - function __construct(Frame $frame) { |
|
683 | + function __construct(Frame $frame) { |
|
685 | 684 | $this->_parent = $frame; |
686 | 685 | $this->_cur = $frame->get_first_child(); |
687 | 686 | $this->_num = 0; |
688 | - } |
|
687 | + } |
|
689 | 688 | |
690 | - function rewind() { |
|
689 | + function rewind() { |
|
691 | 690 | $this->_cur = $this->_parent->get_first_child(); |
692 | 691 | $this->_num = 0; |
693 | - } |
|
692 | + } |
|
694 | 693 | |
695 | - function valid() { |
|
694 | + function valid() { |
|
696 | 695 | return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev); |
697 | - } |
|
698 | - function key() { return $this->_num; } |
|
699 | - function current() { return $this->_cur; } |
|
696 | + } |
|
697 | + function key() { return $this->_num; } |
|
698 | + function current() { return $this->_cur; } |
|
700 | 699 | |
701 | - function next() { |
|
700 | + function next() { |
|
702 | 701 | |
703 | 702 | $ret = $this->_cur; |
704 | 703 | if ( !$ret ) |
705 | - return null; |
|
704 | + return null; |
|
706 | 705 | |
707 | 706 | $this->_cur = $this->_cur->get_next_sibling(); |
708 | 707 | $this->_num++; |
709 | 708 | return $ret; |
710 | - } |
|
709 | + } |
|
711 | 710 | } |
712 | 711 | |
713 | 712 | //------------------------------------------------------------------------ |
@@ -720,9 +719,9 @@ discard block |
||
720 | 719 | */ |
721 | 720 | class FrameTreeList implements IteratorAggregate { |
722 | 721 | |
723 | - protected $_root; |
|
724 | - function __construct(Frame $root) { $this->_root = $root; } |
|
725 | - function getIterator() { return new FrameTreeIterator($this->_root); } |
|
722 | + protected $_root; |
|
723 | + function __construct(Frame $root) { $this->_root = $root; } |
|
724 | + function getIterator() { return new FrameTreeIterator($this->_root); } |
|
726 | 725 | |
727 | 726 | } |
728 | 727 | |
@@ -736,25 +735,25 @@ discard block |
||
736 | 735 | */ |
737 | 736 | class FrameTreeIterator implements Iterator { |
738 | 737 | |
739 | - protected $_root; |
|
740 | - protected $_stack = array(); |
|
741 | - protected $_num; |
|
738 | + protected $_root; |
|
739 | + protected $_stack = array(); |
|
740 | + protected $_num; |
|
742 | 741 | |
743 | - function __construct(Frame $root) { |
|
742 | + function __construct(Frame $root) { |
|
744 | 743 | $this->_stack[] = $this->_root = $root; |
745 | 744 | $this->_num = 0; |
746 | - } |
|
745 | + } |
|
747 | 746 | |
748 | - function rewind() { |
|
747 | + function rewind() { |
|
749 | 748 | $this->_stack = array($this->_root); |
750 | 749 | $this->_num = 0; |
751 | - } |
|
750 | + } |
|
752 | 751 | |
753 | - function valid() { return count($this->_stack) > 0; } |
|
754 | - function key() { return $this->_num; } |
|
755 | - function current() { return end($this->_stack); } |
|
752 | + function valid() { return count($this->_stack) > 0; } |
|
753 | + function key() { return $this->_num; } |
|
754 | + function current() { return end($this->_stack); } |
|
756 | 755 | |
757 | - function next() { |
|
756 | + function next() { |
|
758 | 757 | $b = end($this->_stack); |
759 | 758 | |
760 | 759 | // Pop last element |
@@ -763,10 +762,10 @@ discard block |
||
763 | 762 | |
764 | 763 | // Push all children onto the stack in reverse order |
765 | 764 | if ( $c = $b->get_last_child() ) { |
766 | - $this->_stack[] = $c; |
|
767 | - while ( $c = $c->get_prev_sibling() ) |
|
765 | + $this->_stack[] = $c; |
|
766 | + while ( $c = $c->get_prev_sibling() ) |
|
768 | 767 | $this->_stack[] = $c; |
769 | 768 | } |
770 | 769 | return $b; |
771 | - } |
|
770 | + } |
|
772 | 771 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $this->_decorator = null; |
173 | 173 | |
174 | - $this->set_id( self::$ID_COUNTER++ ); |
|
174 | + $this->set_id(self::$ID_COUNTER++); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -181,29 +181,29 @@ discard block |
||
181 | 181 | */ |
182 | 182 | function dispose($recursive = false) { |
183 | 183 | |
184 | - if ( $recursive ) { |
|
185 | - while ( $child = $this->_first_child ) |
|
184 | + if ($recursive) { |
|
185 | + while ($child = $this->_first_child) |
|
186 | 186 | $child->dispose(true); |
187 | 187 | } |
188 | 188 | |
189 | 189 | // Remove this frame from the tree |
190 | - if ( $this->_prev_sibling ) { |
|
190 | + if ($this->_prev_sibling) { |
|
191 | 191 | $this->_prev_sibling->_next_sibling = $this->_next_sibling; |
192 | 192 | } |
193 | 193 | |
194 | - if ( $this->_next_sibling ) { |
|
194 | + if ($this->_next_sibling) { |
|
195 | 195 | $this->_next_sibling->_prev_sibling = $this->_prev_sibling; |
196 | 196 | } |
197 | 197 | |
198 | - if ( $this->_parent && $this->_parent->_first_child === $this ) { |
|
198 | + if ($this->_parent && $this->_parent->_first_child === $this) { |
|
199 | 199 | $this->_parent->_first_child = $this->_next_sibling; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $this->_parent && $this->_parent->_last_child === $this ) { |
|
202 | + if ($this->_parent && $this->_parent->_last_child === $this) { |
|
203 | 203 | $this->_parent->_last_child = $this->_prev_sibling; |
204 | 204 | } |
205 | 205 | |
206 | - if ( $this->_parent ) { |
|
206 | + if ($this->_parent) { |
|
207 | 207 | $this->_parent->get_node()->removeChild($this->_node); |
208 | 208 | } |
209 | 209 | |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | // Layout property accessors |
248 | 248 | function get_containing_block($i = null) { |
249 | - if ( isset($i) ) |
|
249 | + if (isset($i)) |
|
250 | 250 | return $this->_containing_block[$i]; |
251 | 251 | return $this->_containing_block; |
252 | 252 | } |
253 | 253 | |
254 | 254 | function get_position($i = null) { |
255 | - if ( isset($i) ) |
|
255 | + if (isset($i)) |
|
256 | 256 | return $this->_position[$i]; |
257 | 257 | return array($this->_position["x"], |
258 | 258 | $this->_position["y"], |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 355 | // Since these are the only objects that we can assign CSS rules to, |
356 | 356 | // this shortcoming is okay. |
357 | - if ( $this->_node->nodeType == 1) |
|
357 | + if ($this->_node->nodeType == 1) |
|
358 | 358 | $this->_node->setAttribute("frame_id", $id); |
359 | 359 | } |
360 | 360 | |
361 | 361 | function set_style(Style $style) { |
362 | - if ( is_null($this->_style) ) |
|
362 | + if (is_null($this->_style)) |
|
363 | 363 | $this->_original_style = clone $style; |
364 | 364 | |
365 | 365 | $this->_style = $style; |
@@ -370,8 +370,8 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
373 | - if ( is_array($x) ){ |
|
374 | - foreach($x AS $key => $val){ |
|
373 | + if (is_array($x)) { |
|
374 | + foreach ($x AS $key => $val) { |
|
375 | 375 | $$key = $val; |
376 | 376 | } |
377 | 377 | } |
@@ -399,15 +399,15 @@ discard block |
||
399 | 399 | } |
400 | 400 | |
401 | 401 | function set_position($x = null, $y = null) { |
402 | - if ( is_array($x) ) |
|
402 | + if (is_array($x)) |
|
403 | 403 | extract($x); |
404 | 404 | |
405 | - if ( is_numeric($x) ) { |
|
405 | + if (is_numeric($x)) { |
|
406 | 406 | $this->_position[0] = $x; |
407 | 407 | $this->_position["x"] = $x; |
408 | 408 | } |
409 | 409 | |
410 | - if ( is_numeric($y) ) { |
|
410 | + if (is_numeric($y)) { |
|
411 | 411 | $this->_position[1] = $y; |
412 | 412 | $this->_position["y"] = $y; |
413 | 413 | } |
@@ -417,18 +417,18 @@ discard block |
||
417 | 417 | |
418 | 418 | function prepend_child(Frame $child, $update_node = true) { |
419 | 419 | |
420 | - if ( $update_node ) |
|
420 | + if ($update_node) |
|
421 | 421 | $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
422 | 422 | |
423 | 423 | // Remove the child from its parent |
424 | - if ( $child->_parent ) |
|
424 | + if ($child->_parent) |
|
425 | 425 | $child->_parent->remove_child($child, false); |
426 | 426 | |
427 | 427 | $child->_parent = $this; |
428 | 428 | $child->_prev_sibling = null; |
429 | 429 | |
430 | 430 | // Handle the first child |
431 | - if ( !$this->_first_child ) { |
|
431 | + if (!$this->_first_child) { |
|
432 | 432 | $this->_first_child = $child; |
433 | 433 | $this->_last_child = $child; |
434 | 434 | $child->_next_sibling = null; |
@@ -444,18 +444,18 @@ discard block |
||
444 | 444 | |
445 | 445 | function append_child(Frame $child, $update_node = true) { |
446 | 446 | |
447 | - if ( $update_node ) |
|
447 | + if ($update_node) |
|
448 | 448 | $this->_node->appendChild($child->_node); |
449 | 449 | |
450 | 450 | // Remove the child from its parent |
451 | - if ( $child->_parent ) |
|
451 | + if ($child->_parent) |
|
452 | 452 | $child->_parent->remove_child($child, false); |
453 | 453 | |
454 | 454 | $child->_parent = $this; |
455 | 455 | $child->_next_sibling = null; |
456 | 456 | |
457 | 457 | // Handle the first child |
458 | - if ( !$this->_last_child ) { |
|
458 | + if (!$this->_last_child) { |
|
459 | 459 | $this->_first_child = $child; |
460 | 460 | $this->_last_child = $child; |
461 | 461 | $child->_prev_sibling = null; |
@@ -472,32 +472,32 @@ discard block |
||
472 | 472 | // Inserts a new child immediately before the specified frame |
473 | 473 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
474 | 474 | |
475 | - if ( $ref === $this->_first_child ) { |
|
475 | + if ($ref === $this->_first_child) { |
|
476 | 476 | $this->prepend_child($new_child, $update_node); |
477 | 477 | return; |
478 | 478 | } |
479 | 479 | |
480 | - if ( is_null($ref) ) { |
|
480 | + if (is_null($ref)) { |
|
481 | 481 | $this->append_child($new_child, $update_node); |
482 | 482 | return; |
483 | 483 | } |
484 | 484 | |
485 | - if ( $ref->_parent !== $this ) |
|
485 | + if ($ref->_parent !== $this) |
|
486 | 486 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
487 | 487 | |
488 | 488 | // Update the node |
489 | - if ( $update_node ) |
|
489 | + if ($update_node) |
|
490 | 490 | $this->_node->insertBefore($new_child->_node, $ref->_node); |
491 | 491 | |
492 | 492 | // Remove the child from its parent |
493 | - if ( $new_child->_parent ) |
|
493 | + if ($new_child->_parent) |
|
494 | 494 | $new_child->_parent->remove_child($new_child, false); |
495 | 495 | |
496 | 496 | $new_child->_parent = $this; |
497 | 497 | $new_child->_next_sibling = $ref; |
498 | 498 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 499 | |
500 | - if ( $ref->_prev_sibling ) |
|
500 | + if ($ref->_prev_sibling) |
|
501 | 501 | $ref->_prev_sibling->_next_sibling = $new_child; |
502 | 502 | |
503 | 503 | $ref->_prev_sibling = $new_child; |
@@ -506,22 +506,22 @@ discard block |
||
506 | 506 | // Inserts a new child immediately after the specified frame |
507 | 507 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
508 | 508 | |
509 | - if ( $ref === $this->_last_child ) { |
|
509 | + if ($ref === $this->_last_child) { |
|
510 | 510 | $this->append_child($new_child, $update_node); |
511 | 511 | return; |
512 | 512 | } |
513 | 513 | |
514 | - if ( is_null($ref) ) { |
|
514 | + if (is_null($ref)) { |
|
515 | 515 | $this->prepend_child($new_child, $update_node); |
516 | 516 | return; |
517 | 517 | } |
518 | 518 | |
519 | - if ( $ref->_parent !== $this ) |
|
519 | + if ($ref->_parent !== $this) |
|
520 | 520 | throw new DOMPDF_Exception("Reference child is not a child of this node."); |
521 | 521 | |
522 | 522 | // Update the node |
523 | - if ( $update_node ) { |
|
524 | - if ( $ref->_next_sibling ) { |
|
523 | + if ($update_node) { |
|
524 | + if ($ref->_next_sibling) { |
|
525 | 525 | $next_node = $ref->_next_sibling->_node; |
526 | 526 | $this->_node->insertBefore($new_child->_node, $next_node); |
527 | 527 | } else { |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | } |
531 | 531 | |
532 | 532 | // Remove the child from its parent |
533 | - if ( $new_child->_parent) |
|
533 | + if ($new_child->_parent) |
|
534 | 534 | $new_child->_parent->remove_child($new_child, false); |
535 | 535 | |
536 | 536 | $new_child->_parent = $this; |
537 | 537 | $new_child->_prev_sibling = $ref; |
538 | 538 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 539 | |
540 | - if ( $ref->_next_sibling ) |
|
540 | + if ($ref->_next_sibling) |
|
541 | 541 | $ref->_next_sibling->_prev_sibling = $new_child; |
542 | 542 | |
543 | 543 | $ref->_next_sibling = $new_child; |
@@ -546,22 +546,22 @@ discard block |
||
546 | 546 | |
547 | 547 | function remove_child(Frame $child, $update_node = true) { |
548 | 548 | |
549 | - if ( $child->_parent !== $this ) |
|
549 | + if ($child->_parent !== $this) |
|
550 | 550 | throw new DOMPDF_Exception("Child not found in this frame"); |
551 | 551 | |
552 | - if ( $update_node ) |
|
552 | + if ($update_node) |
|
553 | 553 | $this->_node->removeChild($child->_node); |
554 | 554 | |
555 | - if ( $child === $this->_first_child ) |
|
555 | + if ($child === $this->_first_child) |
|
556 | 556 | $this->_first_child = $child->_next_sibling; |
557 | 557 | |
558 | - if ( $child === $this->_last_child ) |
|
558 | + if ($child === $this->_last_child) |
|
559 | 559 | $this->_last_child = $child->_prev_sibling; |
560 | 560 | |
561 | - if ( $child->_prev_sibling ) |
|
561 | + if ($child->_prev_sibling) |
|
562 | 562 | $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
563 | 563 | |
564 | - if ( $child->_next_sibling ) |
|
564 | + if ($child->_next_sibling) |
|
565 | 565 | $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
566 | 566 | |
567 | 567 | $child->_next_sibling = null; |
@@ -582,68 +582,68 @@ discard block |
||
582 | 582 | // return ""; |
583 | 583 | |
584 | 584 | |
585 | - $str = "<b>" . $this->_node->nodeName . ":</b><br/>"; |
|
585 | + $str = "<b>".$this->_node->nodeName.":</b><br/>"; |
|
586 | 586 | //$str .= spl_object_hash($this->_node) . "<br/>"; |
587 | - $str .= "Id: " .$this->get_id() . "<br/>"; |
|
588 | - $str .= "Class: " .get_class($this) . "<br/>"; |
|
587 | + $str .= "Id: ".$this->get_id()."<br/>"; |
|
588 | + $str .= "Class: ".get_class($this)."<br/>"; |
|
589 | 589 | |
590 | - if ( $this->_node->nodeName === "#text" ) { |
|
590 | + if ($this->_node->nodeName === "#text") { |
|
591 | 591 | $tmp = htmlspecialchars($this->_node->nodeValue); |
592 | - $str .= "<pre>'" . mb_substr($tmp,0,70) . |
|
593 | - (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
|
592 | + $str .= "<pre>'".mb_substr($tmp, 0, 70). |
|
593 | + (mb_strlen($tmp) > 70 ? "..." : "")."'</pre>"; |
|
594 | 594 | } |
595 | - if ( $this->_parent ) |
|
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | - " (" . spl_object_hash($this->_parent->_node) . ") " . |
|
595 | + if ($this->_parent) |
|
596 | + $str .= "\nParent:".$this->_parent->_node->nodeName. |
|
597 | + " (".spl_object_hash($this->_parent->_node).") ". |
|
598 | 598 | "<br/>"; |
599 | 599 | |
600 | - if ( $this->_prev_sibling ) |
|
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | - " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
|
600 | + if ($this->_prev_sibling) |
|
601 | + $str .= "Prev: ".$this->_prev_sibling->_node->nodeName. |
|
602 | + " (".spl_object_hash($this->_prev_sibling->_node).") ". |
|
603 | 603 | "<br/>"; |
604 | 604 | |
605 | - if ( $this->_next_sibling ) |
|
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | - " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
|
605 | + if ($this->_next_sibling) |
|
606 | + $str .= "Next: ".$this->_next_sibling->_node->nodeName. |
|
607 | + " (".spl_object_hash($this->_next_sibling->_node).") ". |
|
608 | 608 | "<br/>"; |
609 | 609 | |
610 | 610 | $d = $this->get_decorator(); |
611 | 611 | while ($d && $d != $d->get_decorator()) { |
612 | - $str .= "Decorator: " . get_class($d) . "<br/>"; |
|
612 | + $str .= "Decorator: ".get_class($d)."<br/>"; |
|
613 | 613 | $d = $d->get_decorator(); |
614 | 614 | } |
615 | 615 | |
616 | - $str .= "Position: " . pre_r($this->_position, true); |
|
617 | - $str .= "\nContaining block: " . pre_r($this->_containing_block, true); |
|
618 | - $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true); |
|
619 | - $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true); |
|
616 | + $str .= "Position: ".pre_r($this->_position, true); |
|
617 | + $str .= "\nContaining block: ".pre_r($this->_containing_block, true); |
|
618 | + $str .= "\nMargin width: ".pre_r($this->get_margin_width(), true); |
|
619 | + $str .= "\nMargin height: ".pre_r($this->get_margin_height(), true); |
|
620 | 620 | |
621 | - $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>"; |
|
621 | + $str .= "\nStyle: <pre>".$this->_style->__toString()."</pre>"; |
|
622 | 622 | |
623 | - if ( $this->_decorator instanceof Block_Frame_Decorator ) { |
|
623 | + if ($this->_decorator instanceof Block_Frame_Decorator) { |
|
624 | 624 | $str .= "Lines:<pre>"; |
625 | 625 | foreach ($this->_decorator->get_lines() as $line) { |
626 | 626 | foreach ($line["frames"] as $frame) { |
627 | 627 | if ($frame instanceof Text_Frame_Decorator) { |
628 | 628 | $str .= "\ntext: "; |
629 | - $str .= "'". htmlspecialchars($frame->get_text()) ."'"; |
|
629 | + $str .= "'".htmlspecialchars($frame->get_text())."'"; |
|
630 | 630 | } else { |
631 | - $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")"; |
|
631 | + $str .= "\nBlock: ".$frame->get_node()->nodeName." (".spl_object_hash($frame->get_node()).")"; |
|
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | 635 | $str .= |
636 | 636 | //"\ncount => " . $line["count"] . "\n". |
637 | - "\ny => " . $line["y"] . "\n" . |
|
638 | - "w => " . $line["w"] . "\n" . |
|
639 | - "h => " . $line["h"] . "\n"; |
|
637 | + "\ny => ".$line["y"]."\n". |
|
638 | + "w => ".$line["w"]."\n". |
|
639 | + "h => ".$line["h"]."\n"; |
|
640 | 640 | } |
641 | 641 | $str .= "</pre>"; |
642 | 642 | } |
643 | 643 | $str .= "\n"; |
644 | - if ( php_sapi_name() === "cli" ) |
|
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | - array("\n","",""), |
|
644 | + if (php_sapi_name() === "cli") |
|
645 | + $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"), |
|
646 | + array("\n", "", ""), |
|
647 | 647 | $str)); |
648 | 648 | |
649 | 649 | return $str; |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | } |
694 | 694 | |
695 | 695 | function valid() { |
696 | - return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
696 | + return isset($this->_cur); // && ($this->_cur->get_prev_sibling() === $this->_prev); |
|
697 | 697 | } |
698 | 698 | function key() { return $this->_num; } |
699 | 699 | function current() { return $this->_cur; } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | function next() { |
702 | 702 | |
703 | 703 | $ret = $this->_cur; |
704 | - if ( !$ret ) |
|
704 | + if (!$ret) |
|
705 | 705 | return null; |
706 | 706 | |
707 | 707 | $this->_cur = $this->_cur->get_next_sibling(); |
@@ -758,13 +758,13 @@ discard block |
||
758 | 758 | $b = end($this->_stack); |
759 | 759 | |
760 | 760 | // Pop last element |
761 | - unset($this->_stack[ key($this->_stack) ]); |
|
761 | + unset($this->_stack[key($this->_stack)]); |
|
762 | 762 | $this->_num++; |
763 | 763 | |
764 | 764 | // Push all children onto the stack in reverse order |
765 | - if ( $c = $b->get_last_child() ) { |
|
765 | + if ($c = $b->get_last_child()) { |
|
766 | 766 | $this->_stack[] = $c; |
767 | - while ( $c = $c->get_prev_sibling() ) |
|
767 | + while ($c = $c->get_prev_sibling()) |
|
768 | 768 | $this->_stack[] = $c; |
769 | 769 | } |
770 | 770 | return $b; |
@@ -182,8 +182,9 @@ discard block |
||
182 | 182 | function dispose($recursive = false) { |
183 | 183 | |
184 | 184 | if ( $recursive ) { |
185 | - while ( $child = $this->_first_child ) |
|
186 | - $child->dispose(true); |
|
185 | + while ( $child = $this->_first_child ) { |
|
186 | + $child->dispose(true); |
|
187 | + } |
|
187 | 188 | } |
188 | 189 | |
189 | 190 | // Remove this frame from the tree |
@@ -246,14 +247,16 @@ discard block |
||
246 | 247 | |
247 | 248 | // Layout property accessors |
248 | 249 | function get_containing_block($i = null) { |
249 | - if ( isset($i) ) |
|
250 | - return $this->_containing_block[$i]; |
|
250 | + if ( isset($i) ) { |
|
251 | + return $this->_containing_block[$i]; |
|
252 | + } |
|
251 | 253 | return $this->_containing_block; |
252 | 254 | } |
253 | 255 | |
254 | 256 | function get_position($i = null) { |
255 | - if ( isset($i) ) |
|
256 | - return $this->_position[$i]; |
|
257 | + if ( isset($i) ) { |
|
258 | + return $this->_position[$i]; |
|
259 | + } |
|
257 | 260 | return array($this->_position["x"], |
258 | 261 | $this->_position["y"], |
259 | 262 | "x"=>$this->_position["x"], |
@@ -354,13 +357,15 @@ discard block |
||
354 | 357 | // We can only set attributes of DOMElement objects (nodeType == 1). |
355 | 358 | // Since these are the only objects that we can assign CSS rules to, |
356 | 359 | // this shortcoming is okay. |
357 | - if ( $this->_node->nodeType == 1) |
|
358 | - $this->_node->setAttribute("frame_id", $id); |
|
360 | + if ( $this->_node->nodeType == 1) { |
|
361 | + $this->_node->setAttribute("frame_id", $id); |
|
362 | + } |
|
359 | 363 | } |
360 | 364 | |
361 | 365 | function set_style(Style $style) { |
362 | - if ( is_null($this->_style) ) |
|
363 | - $this->_original_style = clone $style; |
|
366 | + if ( is_null($this->_style) ) { |
|
367 | + $this->_original_style = clone $style; |
|
368 | + } |
|
364 | 369 | |
365 | 370 | $this->_style = $style; |
366 | 371 | } |
@@ -399,8 +404,9 @@ discard block |
||
399 | 404 | } |
400 | 405 | |
401 | 406 | function set_position($x = null, $y = null) { |
402 | - if ( is_array($x) ) |
|
403 | - extract($x); |
|
407 | + if ( is_array($x) ) { |
|
408 | + extract($x); |
|
409 | + } |
|
404 | 410 | |
405 | 411 | if ( is_numeric($x) ) { |
406 | 412 | $this->_position[0] = $x; |
@@ -417,12 +423,14 @@ discard block |
||
417 | 423 | |
418 | 424 | function prepend_child(Frame $child, $update_node = true) { |
419 | 425 | |
420 | - if ( $update_node ) |
|
421 | - $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
426 | + if ( $update_node ) { |
|
427 | + $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null); |
|
428 | + } |
|
422 | 429 | |
423 | 430 | // Remove the child from its parent |
424 | - if ( $child->_parent ) |
|
425 | - $child->_parent->remove_child($child, false); |
|
431 | + if ( $child->_parent ) { |
|
432 | + $child->_parent->remove_child($child, false); |
|
433 | + } |
|
426 | 434 | |
427 | 435 | $child->_parent = $this; |
428 | 436 | $child->_prev_sibling = null; |
@@ -444,12 +452,14 @@ discard block |
||
444 | 452 | |
445 | 453 | function append_child(Frame $child, $update_node = true) { |
446 | 454 | |
447 | - if ( $update_node ) |
|
448 | - $this->_node->appendChild($child->_node); |
|
455 | + if ( $update_node ) { |
|
456 | + $this->_node->appendChild($child->_node); |
|
457 | + } |
|
449 | 458 | |
450 | 459 | // Remove the child from its parent |
451 | - if ( $child->_parent ) |
|
452 | - $child->_parent->remove_child($child, false); |
|
460 | + if ( $child->_parent ) { |
|
461 | + $child->_parent->remove_child($child, false); |
|
462 | + } |
|
453 | 463 | |
454 | 464 | $child->_parent = $this; |
455 | 465 | $child->_next_sibling = null; |
@@ -482,23 +492,27 @@ discard block |
||
482 | 492 | return; |
483 | 493 | } |
484 | 494 | |
485 | - if ( $ref->_parent !== $this ) |
|
486 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
495 | + if ( $ref->_parent !== $this ) { |
|
496 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
497 | + } |
|
487 | 498 | |
488 | 499 | // Update the node |
489 | - if ( $update_node ) |
|
490 | - $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
500 | + if ( $update_node ) { |
|
501 | + $this->_node->insertBefore($new_child->_node, $ref->_node); |
|
502 | + } |
|
491 | 503 | |
492 | 504 | // Remove the child from its parent |
493 | - if ( $new_child->_parent ) |
|
494 | - $new_child->_parent->remove_child($new_child, false); |
|
505 | + if ( $new_child->_parent ) { |
|
506 | + $new_child->_parent->remove_child($new_child, false); |
|
507 | + } |
|
495 | 508 | |
496 | 509 | $new_child->_parent = $this; |
497 | 510 | $new_child->_next_sibling = $ref; |
498 | 511 | $new_child->_prev_sibling = $ref->_prev_sibling; |
499 | 512 | |
500 | - if ( $ref->_prev_sibling ) |
|
501 | - $ref->_prev_sibling->_next_sibling = $new_child; |
|
513 | + if ( $ref->_prev_sibling ) { |
|
514 | + $ref->_prev_sibling->_next_sibling = $new_child; |
|
515 | + } |
|
502 | 516 | |
503 | 517 | $ref->_prev_sibling = $new_child; |
504 | 518 | } |
@@ -516,8 +530,9 @@ discard block |
||
516 | 530 | return; |
517 | 531 | } |
518 | 532 | |
519 | - if ( $ref->_parent !== $this ) |
|
520 | - throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
533 | + if ( $ref->_parent !== $this ) { |
|
534 | + throw new DOMPDF_Exception("Reference child is not a child of this node."); |
|
535 | + } |
|
521 | 536 | |
522 | 537 | // Update the node |
523 | 538 | if ( $update_node ) { |
@@ -530,15 +545,17 @@ discard block |
||
530 | 545 | } |
531 | 546 | |
532 | 547 | // Remove the child from its parent |
533 | - if ( $new_child->_parent) |
|
534 | - $new_child->_parent->remove_child($new_child, false); |
|
548 | + if ( $new_child->_parent) { |
|
549 | + $new_child->_parent->remove_child($new_child, false); |
|
550 | + } |
|
535 | 551 | |
536 | 552 | $new_child->_parent = $this; |
537 | 553 | $new_child->_prev_sibling = $ref; |
538 | 554 | $new_child->_next_sibling = $ref->_next_sibling; |
539 | 555 | |
540 | - if ( $ref->_next_sibling ) |
|
541 | - $ref->_next_sibling->_prev_sibling = $new_child; |
|
556 | + if ( $ref->_next_sibling ) { |
|
557 | + $ref->_next_sibling->_prev_sibling = $new_child; |
|
558 | + } |
|
542 | 559 | |
543 | 560 | $ref->_next_sibling = $new_child; |
544 | 561 | } |
@@ -546,23 +563,29 @@ discard block |
||
546 | 563 | |
547 | 564 | function remove_child(Frame $child, $update_node = true) { |
548 | 565 | |
549 | - if ( $child->_parent !== $this ) |
|
550 | - throw new DOMPDF_Exception("Child not found in this frame"); |
|
566 | + if ( $child->_parent !== $this ) { |
|
567 | + throw new DOMPDF_Exception("Child not found in this frame"); |
|
568 | + } |
|
551 | 569 | |
552 | - if ( $update_node ) |
|
553 | - $this->_node->removeChild($child->_node); |
|
570 | + if ( $update_node ) { |
|
571 | + $this->_node->removeChild($child->_node); |
|
572 | + } |
|
554 | 573 | |
555 | - if ( $child === $this->_first_child ) |
|
556 | - $this->_first_child = $child->_next_sibling; |
|
574 | + if ( $child === $this->_first_child ) { |
|
575 | + $this->_first_child = $child->_next_sibling; |
|
576 | + } |
|
557 | 577 | |
558 | - if ( $child === $this->_last_child ) |
|
559 | - $this->_last_child = $child->_prev_sibling; |
|
578 | + if ( $child === $this->_last_child ) { |
|
579 | + $this->_last_child = $child->_prev_sibling; |
|
580 | + } |
|
560 | 581 | |
561 | - if ( $child->_prev_sibling ) |
|
562 | - $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
582 | + if ( $child->_prev_sibling ) { |
|
583 | + $child->_prev_sibling->_next_sibling = $child->_next_sibling; |
|
584 | + } |
|
563 | 585 | |
564 | - if ( $child->_next_sibling ) |
|
565 | - $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
586 | + if ( $child->_next_sibling ) { |
|
587 | + $child->_next_sibling->_prev_sibling = $child->_prev_sibling; |
|
588 | + } |
|
566 | 589 | |
567 | 590 | $child->_next_sibling = null; |
568 | 591 | $child->_prev_sibling = null; |
@@ -592,20 +615,23 @@ discard block |
||
592 | 615 | $str .= "<pre>'" . mb_substr($tmp,0,70) . |
593 | 616 | (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>"; |
594 | 617 | } |
595 | - if ( $this->_parent ) |
|
596 | - $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
618 | + if ( $this->_parent ) { |
|
619 | + $str .= "\nParent:" . $this->_parent->_node->nodeName . |
|
597 | 620 | " (" . spl_object_hash($this->_parent->_node) . ") " . |
598 | 621 | "<br/>"; |
622 | + } |
|
599 | 623 | |
600 | - if ( $this->_prev_sibling ) |
|
601 | - $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
624 | + if ( $this->_prev_sibling ) { |
|
625 | + $str .= "Prev: " . $this->_prev_sibling->_node->nodeName . |
|
602 | 626 | " (" . spl_object_hash($this->_prev_sibling->_node) . ") " . |
603 | 627 | "<br/>"; |
628 | + } |
|
604 | 629 | |
605 | - if ( $this->_next_sibling ) |
|
606 | - $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
630 | + if ( $this->_next_sibling ) { |
|
631 | + $str .= "Next: " . $this->_next_sibling->_node->nodeName . |
|
607 | 632 | " (" . spl_object_hash($this->_next_sibling->_node) . ") " . |
608 | 633 | "<br/>"; |
634 | + } |
|
609 | 635 | |
610 | 636 | $d = $this->get_decorator(); |
611 | 637 | while ($d && $d != $d->get_decorator()) { |
@@ -641,10 +667,11 @@ discard block |
||
641 | 667 | $str .= "</pre>"; |
642 | 668 | } |
643 | 669 | $str .= "\n"; |
644 | - if ( php_sapi_name() === "cli" ) |
|
645 | - $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
670 | + if ( php_sapi_name() === "cli" ) { |
|
671 | + $str = strip_tags(str_replace(array("<br/>","<b>","</b>"), |
|
646 | 672 | array("\n","",""), |
647 | 673 | $str)); |
674 | + } |
|
648 | 675 | |
649 | 676 | return $str; |
650 | 677 | } |
@@ -701,8 +728,9 @@ discard block |
||
701 | 728 | function next() { |
702 | 729 | |
703 | 730 | $ret = $this->_cur; |
704 | - if ( !$ret ) |
|
705 | - return null; |
|
731 | + if ( !$ret ) { |
|
732 | + return null; |
|
733 | + } |
|
706 | 734 | |
707 | 735 | $this->_cur = $this->_cur->get_next_sibling(); |
708 | 736 | $this->_num++; |
@@ -764,8 +792,9 @@ discard block |
||
764 | 792 | // Push all children onto the stack in reverse order |
765 | 793 | if ( $c = $b->get_last_child() ) { |
766 | 794 | $this->_stack[] = $c; |
767 | - while ( $c = $c->get_prev_sibling() ) |
|
768 | - $this->_stack[] = $c; |
|
795 | + while ( $c = $c->get_prev_sibling() ) { |
|
796 | + $this->_stack[] = $c; |
|
797 | + } |
|
769 | 798 | } |
770 | 799 | return $b; |
771 | 800 | } |
@@ -155,7 +155,15 @@ discard block |
||
155 | 155 | function get_id() { return $this->_frame->get_id(); } |
156 | 156 | function get_style() { return $this->_frame->get_style(); } |
157 | 157 | function get_original_style() { return $this->_frame->get_original_style(); } |
158 | + |
|
159 | + /** |
|
160 | + * @param string $i |
|
161 | + */ |
|
158 | 162 | function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
163 | + |
|
164 | + /** |
|
165 | + * @param string $i |
|
166 | + */ |
|
159 | 167 | function get_position($i = null) { return $this->_frame->get_position($i); } |
160 | 168 | function get_dompdf() { return $this->_dompdf; } |
161 | 169 | // function get_decorator() { |
@@ -173,6 +181,12 @@ discard block |
||
173 | 181 | function set_id($id) { $this->_frame->set_id($id); } |
174 | 182 | function set_style(Style $style) { $this->_frame->set_style($style); } |
175 | 183 | |
184 | + /** |
|
185 | + * @param double $x |
|
186 | + * @param double $y |
|
187 | + * @param double $w |
|
188 | + * @param double $h |
|
189 | + */ |
|
176 | 190 | function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
177 | 191 | $this->_frame->set_containing_block($x, $y, $w, $h); |
178 | 192 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,62 +46,62 @@ discard block |
||
47 | 46 | */ |
48 | 47 | abstract class Frame_Decorator extends Frame { |
49 | 48 | |
50 | - /** |
|
51 | - * The root node of the DOM tree |
|
52 | - * |
|
53 | - * @var Frame |
|
54 | - */ |
|
55 | - protected $_root; |
|
56 | - |
|
57 | - /** |
|
58 | - * The decorated frame |
|
59 | - * |
|
60 | - * @var Frame |
|
61 | - */ |
|
62 | - protected $_frame; |
|
63 | - |
|
64 | - /** |
|
65 | - * Positioner object used to position this frame (Strategy pattern) |
|
66 | - * |
|
67 | - * @var Positioner |
|
68 | - */ |
|
69 | - protected $_positioner; |
|
70 | - |
|
71 | - /** |
|
72 | - * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
73 | - * |
|
74 | - * @var Frame_Reflower |
|
75 | - */ |
|
76 | - protected $_reflower; |
|
49 | + /** |
|
50 | + * The root node of the DOM tree |
|
51 | + * |
|
52 | + * @var Frame |
|
53 | + */ |
|
54 | + protected $_root; |
|
55 | + |
|
56 | + /** |
|
57 | + * The decorated frame |
|
58 | + * |
|
59 | + * @var Frame |
|
60 | + */ |
|
61 | + protected $_frame; |
|
62 | + |
|
63 | + /** |
|
64 | + * Positioner object used to position this frame (Strategy pattern) |
|
65 | + * |
|
66 | + * @var Positioner |
|
67 | + */ |
|
68 | + protected $_positioner; |
|
69 | + |
|
70 | + /** |
|
71 | + * Reflower object used to calculate frame dimensions (Strategy pattern) |
|
72 | + * |
|
73 | + * @var Frame_Reflower |
|
74 | + */ |
|
75 | + protected $_reflower; |
|
77 | 76 | |
78 | - /** |
|
79 | - * Reference to the current dompdf instance |
|
80 | - * |
|
81 | - * @var DOMPDF |
|
82 | - */ |
|
83 | - protected $_dompdf; |
|
84 | - |
|
85 | - /** |
|
86 | - * Class constructor |
|
87 | - * |
|
88 | - * @param Frame $frame the decoration target |
|
89 | - */ |
|
90 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
77 | + /** |
|
78 | + * Reference to the current dompdf instance |
|
79 | + * |
|
80 | + * @var DOMPDF |
|
81 | + */ |
|
82 | + protected $_dompdf; |
|
83 | + |
|
84 | + /** |
|
85 | + * Class constructor |
|
86 | + * |
|
87 | + * @param Frame $frame the decoration target |
|
88 | + */ |
|
89 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
91 | 90 | $this->_frame = $frame; |
92 | 91 | $this->_root = null; |
93 | 92 | $this->_dompdf = $dompdf; |
94 | 93 | $frame->set_decorator($this); |
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * "Destructor": foribly free all references held by this object |
|
99 | - * |
|
100 | - * @param bool $recursive if true, call dispose on all children |
|
101 | - */ |
|
102 | - function dispose($recursive = false) { |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * "Destructor": foribly free all references held by this object |
|
98 | + * |
|
99 | + * @param bool $recursive if true, call dispose on all children |
|
100 | + */ |
|
101 | + function dispose($recursive = false) { |
|
103 | 102 | |
104 | 103 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + while ( $child = $this->get_first_child() ) |
|
106 | 105 | $child->dispose(true); |
107 | 106 | } |
108 | 107 | |
@@ -112,52 +111,52 @@ discard block |
||
112 | 111 | unset($this->_positioner); |
113 | 112 | unset($this->_reflower); |
114 | 113 | |
115 | - } |
|
114 | + } |
|
116 | 115 | |
117 | - // Return a copy of this frame with $node as its node |
|
118 | - function copy(DomNode $node) { |
|
116 | + // Return a copy of this frame with $node as its node |
|
117 | + function copy(DomNode $node) { |
|
119 | 118 | $frame = new Frame($node); |
120 | 119 | $frame->set_style(clone $this->_frame->get_original_style()); |
121 | 120 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
122 | 121 | $deco->set_root($this->_root); |
123 | 122 | return $deco; |
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Create a deep copy: copy this node and all children |
|
128 | - * |
|
129 | - * @return Frame |
|
130 | - */ |
|
131 | - function deep_copy() { |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Create a deep copy: copy this node and all children |
|
127 | + * |
|
128 | + * @return Frame |
|
129 | + */ |
|
130 | + function deep_copy() { |
|
132 | 131 | $frame = new Frame($this->get_node()->cloneNode()); |
133 | 132 | $frame->set_style(clone $this->_frame->get_original_style()); |
134 | 133 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 134 | $deco->set_root($this->_root); |
136 | 135 | |
137 | 136 | foreach ($this->get_children() as $child) |
138 | - $deco->append_child($child->deep_copy()); |
|
137 | + $deco->append_child($child->deep_copy()); |
|
139 | 138 | |
140 | 139 | return $deco; |
141 | - } |
|
142 | - //........................................................................ |
|
140 | + } |
|
141 | + //........................................................................ |
|
143 | 142 | |
144 | - // Delegate calls to decorated frame object |
|
145 | - function reset() { |
|
143 | + // Delegate calls to decorated frame object |
|
144 | + function reset() { |
|
146 | 145 | $this->_frame->reset(); |
147 | 146 | |
148 | 147 | // Reset all children |
149 | 148 | foreach ($this->get_children() as $child) |
150 | - $child->reset(); |
|
149 | + $child->reset(); |
|
151 | 150 | |
152 | - } |
|
151 | + } |
|
153 | 152 | |
154 | - function get_node() { return $this->_frame->get_node(); } |
|
155 | - function get_id() { return $this->_frame->get_id(); } |
|
156 | - function get_style() { return $this->_frame->get_style(); } |
|
157 | - function get_original_style() { return $this->_frame->get_original_style(); } |
|
158 | - function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
159 | - function get_position($i = null) { return $this->_frame->get_position($i); } |
|
160 | - function get_dompdf() { return $this->_dompdf; } |
|
153 | + function get_node() { return $this->_frame->get_node(); } |
|
154 | + function get_id() { return $this->_frame->get_id(); } |
|
155 | + function get_style() { return $this->_frame->get_style(); } |
|
156 | + function get_original_style() { return $this->_frame->get_original_style(); } |
|
157 | + function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); } |
|
158 | + function get_position($i = null) { return $this->_frame->get_position($i); } |
|
159 | + function get_dompdf() { return $this->_dompdf; } |
|
161 | 160 | // function get_decorator() { |
162 | 161 | // if ( isset($this->_decorator) ) |
163 | 162 | // return $this->_decorator; |
@@ -165,201 +164,201 @@ discard block |
||
165 | 164 | // return $this; |
166 | 165 | // } |
167 | 166 | |
168 | - function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
169 | - function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
170 | - function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
171 | - function get_border_box() { return $this->_frame->get_border_box(); } |
|
167 | + function get_margin_height() { return $this->_frame->get_margin_height(); } |
|
168 | + function get_margin_width() { return $this->_frame->get_margin_width(); } |
|
169 | + function get_padding_box() { return $this->_frame->get_padding_box(); } |
|
170 | + function get_border_box() { return $this->_frame->get_border_box(); } |
|
172 | 171 | |
173 | - function set_id($id) { $this->_frame->set_id($id); } |
|
174 | - function set_style(Style $style) { $this->_frame->set_style($style); } |
|
172 | + function set_id($id) { $this->_frame->set_id($id); } |
|
173 | + function set_style(Style $style) { $this->_frame->set_style($style); } |
|
175 | 174 | |
176 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
175 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
177 | 176 | $this->_frame->set_containing_block($x, $y, $w, $h); |
178 | - } |
|
177 | + } |
|
179 | 178 | |
180 | - function set_position($x = null, $y = null) { |
|
179 | + function set_position($x = null, $y = null) { |
|
181 | 180 | $this->_frame->set_position($x, $y); |
182 | - } |
|
183 | - function __toString() { return $this->_frame->__toString(); } |
|
181 | + } |
|
182 | + function __toString() { return $this->_frame->__toString(); } |
|
184 | 183 | |
185 | - function prepend_child(Frame $child, $update_node = true) { |
|
184 | + function prepend_child(Frame $child, $update_node = true) { |
|
186 | 185 | while ( $child instanceof Frame_Decorator ) |
187 | - $child = $child->_frame; |
|
186 | + $child = $child->_frame; |
|
188 | 187 | |
189 | 188 | $this->_frame->prepend_child($child, $update_node); |
190 | - } |
|
189 | + } |
|
191 | 190 | |
192 | - function append_child(Frame $child, $update_node = true) { |
|
191 | + function append_child(Frame $child, $update_node = true) { |
|
193 | 192 | while ( $child instanceof Frame_Decorator ) |
194 | - $child = $child->_frame; |
|
193 | + $child = $child->_frame; |
|
195 | 194 | |
196 | 195 | $this->_frame->append_child($child, $update_node); |
197 | - } |
|
196 | + } |
|
198 | 197 | |
199 | - function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
198 | + function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
|
200 | 199 | while ( $new_child instanceof Frame_Decorator ) |
201 | - $new_child = $new_child->_frame; |
|
200 | + $new_child = $new_child->_frame; |
|
202 | 201 | |
203 | 202 | if ( $ref instanceof Frame_Decorator ) |
204 | - $ref = $ref->_frame; |
|
203 | + $ref = $ref->_frame; |
|
205 | 204 | |
206 | 205 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | - function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
208 | + function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
|
210 | 209 | while ( $new_child instanceof Frame_Decorator ) |
211 | - $new_child = $new_child->_frame; |
|
210 | + $new_child = $new_child->_frame; |
|
212 | 211 | |
213 | 212 | while ( $ref instanceof Frame_Decorator ) |
214 | - $ref = $ref->_frame; |
|
213 | + $ref = $ref->_frame; |
|
215 | 214 | |
216 | 215 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | - } |
|
216 | + } |
|
218 | 217 | |
219 | - function remove_child(Frame $child, $update_node = true) { |
|
218 | + function remove_child(Frame $child, $update_node = true) { |
|
220 | 219 | while ( $child instanceof Frame_Decorator ) |
221 | - $child = $new_child->_frame; |
|
220 | + $child = $new_child->_frame; |
|
222 | 221 | |
223 | 222 | $this->_frame->remove_child($child, $update_node); |
224 | - } |
|
223 | + } |
|
225 | 224 | |
226 | - //........................................................................ |
|
225 | + //........................................................................ |
|
227 | 226 | |
228 | - function get_parent() { |
|
227 | + function get_parent() { |
|
229 | 228 | |
230 | 229 | $p = $this->_frame->get_parent(); |
231 | 230 | |
232 | 231 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + while ( $tmp = $deco->get_decorator() ) |
|
234 | 233 | $deco = $tmp; |
235 | - return $deco; |
|
234 | + return $deco; |
|
236 | 235 | } else if ( $p ) |
237 | - return $p; |
|
236 | + return $p; |
|
238 | 237 | else |
239 | - return null; |
|
240 | - } |
|
238 | + return null; |
|
239 | + } |
|
241 | 240 | |
242 | - function get_first_child() { |
|
241 | + function get_first_child() { |
|
243 | 242 | $c = $this->_frame->get_first_child(); |
244 | 243 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + while ( $tmp = $deco->get_decorator() ) |
|
246 | 245 | $deco = $tmp; |
247 | - return $deco; |
|
246 | + return $deco; |
|
248 | 247 | } else if ( $c ) |
249 | - return $c; |
|
248 | + return $c; |
|
250 | 249 | else |
251 | - return null; |
|
252 | - } |
|
250 | + return null; |
|
251 | + } |
|
253 | 252 | |
254 | - function get_last_child() { |
|
253 | + function get_last_child() { |
|
255 | 254 | $c = $this->_frame->get_last_child(); |
256 | 255 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + while ( $tmp = $deco->get_decorator() ) |
|
258 | 257 | $deco = $tmp; |
259 | - return $deco; |
|
258 | + return $deco; |
|
260 | 259 | } else if ( $c ) |
261 | - return $c; |
|
260 | + return $c; |
|
262 | 261 | else |
263 | - return null; |
|
264 | - } |
|
262 | + return null; |
|
263 | + } |
|
265 | 264 | |
266 | - function get_prev_sibling() { |
|
265 | + function get_prev_sibling() { |
|
267 | 266 | $s = $this->_frame->get_prev_sibling(); |
268 | 267 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + while ( $tmp = $deco->get_decorator() ) |
|
270 | 269 | $deco = $tmp; |
271 | - return $deco; |
|
270 | + return $deco; |
|
272 | 271 | } else if ( $s ) |
273 | - return $s; |
|
272 | + return $s; |
|
274 | 273 | else |
275 | - return null; |
|
276 | - } |
|
274 | + return null; |
|
275 | + } |
|
277 | 276 | |
278 | - function get_next_sibling() { |
|
277 | + function get_next_sibling() { |
|
279 | 278 | $s = $this->_frame->get_next_sibling(); |
280 | 279 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + while ( $tmp = $deco->get_decorator() ) |
|
282 | 281 | $deco = $tmp; |
283 | - return $deco; |
|
282 | + return $deco; |
|
284 | 283 | } else if ( $s ) |
285 | - return $s; |
|
284 | + return $s; |
|
286 | 285 | else |
287 | - return null; |
|
288 | - } |
|
286 | + return null; |
|
287 | + } |
|
289 | 288 | |
290 | - function get_children() { |
|
289 | + function get_children() { |
|
291 | 290 | return new FrameList($this); |
292 | - } |
|
291 | + } |
|
293 | 292 | |
294 | - function get_subtree() { |
|
293 | + function get_subtree() { |
|
295 | 294 | return new FrameTreeList($this); |
296 | - } |
|
295 | + } |
|
297 | 296 | |
298 | - //........................................................................ |
|
297 | + //........................................................................ |
|
299 | 298 | |
300 | - function set_positioner(Positioner $posn) { |
|
299 | + function set_positioner(Positioner $posn) { |
|
301 | 300 | $this->_positioner = $posn; |
302 | 301 | if ( $this->_frame instanceof Frame_Decorator ) |
303 | - $this->_frame->set_positioner($posn); |
|
304 | - } |
|
302 | + $this->_frame->set_positioner($posn); |
|
303 | + } |
|
305 | 304 | |
306 | - //........................................................................ |
|
305 | + //........................................................................ |
|
307 | 306 | |
308 | - function set_reflower(Frame_Reflower $reflower) { |
|
307 | + function set_reflower(Frame_Reflower $reflower) { |
|
309 | 308 | $this->_reflower = $reflower; |
310 | 309 | if ( $this->_frame instanceof Frame_Decorator ) |
311 | - $this->_frame->set_reflower( $reflower ); |
|
312 | - } |
|
310 | + $this->_frame->set_reflower( $reflower ); |
|
311 | + } |
|
313 | 312 | |
314 | - function get_reflower() { return $this->_reflower; } |
|
313 | + function get_reflower() { return $this->_reflower; } |
|
315 | 314 | |
316 | - //........................................................................ |
|
315 | + //........................................................................ |
|
317 | 316 | |
318 | - function set_root(Frame $root) { |
|
317 | + function set_root(Frame $root) { |
|
319 | 318 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
319 | + if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | 320 | $this->_frame->set_root($root); |
322 | - } |
|
321 | + } |
|
323 | 322 | |
324 | - function get_root() { return $this->_root; } |
|
323 | + function get_root() { return $this->_root; } |
|
325 | 324 | |
326 | - //........................................................................ |
|
325 | + //........................................................................ |
|
327 | 326 | |
328 | - function find_block_parent() { |
|
327 | + function find_block_parent() { |
|
329 | 328 | |
330 | 329 | // Find our nearest block level parent |
331 | 330 | $p = $this->get_parent(); |
332 | 331 | |
333 | 332 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | 334 | break; |
336 | 335 | |
337 | - $p = $p->get_parent(); |
|
336 | + $p = $p->get_parent(); |
|
338 | 337 | } |
339 | 338 | |
340 | 339 | return $p; |
341 | - } |
|
340 | + } |
|
342 | 341 | |
343 | - //........................................................................ |
|
342 | + //........................................................................ |
|
344 | 343 | |
345 | - /** |
|
346 | - * split this frame at $child. |
|
347 | - * |
|
348 | - * The current frame is cloned and $child and all children following |
|
349 | - * $child are added to the clone. The clone is then passed to the |
|
350 | - * current frame's parent->split() method. |
|
351 | - * |
|
352 | - * @param Frame $child |
|
353 | - */ |
|
354 | - function split($child = null) { |
|
344 | + /** |
|
345 | + * split this frame at $child. |
|
346 | + * |
|
347 | + * The current frame is cloned and $child and all children following |
|
348 | + * $child are added to the clone. The clone is then passed to the |
|
349 | + * current frame's parent->split() method. |
|
350 | + * |
|
351 | + * @param Frame $child |
|
352 | + */ |
|
353 | + function split($child = null) { |
|
355 | 354 | |
356 | 355 | if ( is_null( $child ) ) { |
357 | - $this->get_parent()->split($this); |
|
358 | - return; |
|
356 | + $this->get_parent()->split($this); |
|
357 | + return; |
|
359 | 358 | } |
360 | 359 | |
361 | 360 | if ( $child->get_parent() !== $this ) |
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
361 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
363 | 362 | |
364 | 363 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 364 | $split->reset(); |
@@ -368,29 +367,29 @@ discard block |
||
368 | 367 | // Add $frame and all following siblings to the new split node |
369 | 368 | $iter = $child; |
370 | 369 | while ($iter) { |
371 | - $frame = $iter; |
|
372 | - $iter = $iter->get_next_sibling(); |
|
373 | - $frame->reset(); |
|
374 | - $split->append_child($frame); |
|
370 | + $frame = $iter; |
|
371 | + $iter = $iter->get_next_sibling(); |
|
372 | + $frame->reset(); |
|
373 | + $split->append_child($frame); |
|
375 | 374 | } |
376 | 375 | |
377 | 376 | $this->get_parent()->split($split); |
378 | - } |
|
377 | + } |
|
379 | 378 | |
380 | - //........................................................................ |
|
379 | + //........................................................................ |
|
381 | 380 | |
382 | - final function position() { $this->_positioner->position(); } |
|
381 | + final function position() { $this->_positioner->position(); } |
|
383 | 382 | |
384 | - final function reflow() { |
|
383 | + final function reflow() { |
|
385 | 384 | // Uncomment this to see the frames before they're laid out, instead of |
386 | 385 | // during rendering. |
387 | 386 | //echo $this->_frame; flush(); |
388 | 387 | $this->_reflower->reflow(); |
389 | - } |
|
388 | + } |
|
390 | 389 | |
391 | - final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
390 | + final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); } |
|
392 | 391 | |
393 | - //........................................................................ |
|
392 | + //........................................................................ |
|
394 | 393 | |
395 | 394 | |
396 | 395 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | - if ( $recursive ) { |
|
105 | - while ( $child = $this->get_first_child() ) |
|
104 | + if ($recursive) { |
|
105 | + while ($child = $this->get_first_child()) |
|
106 | 106 | $child->dispose(true); |
107 | 107 | } |
108 | 108 | |
@@ -183,41 +183,41 @@ discard block |
||
183 | 183 | function __toString() { return $this->_frame->__toString(); } |
184 | 184 | |
185 | 185 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
186 | + while ($child instanceof Frame_Decorator) |
|
187 | 187 | $child = $child->_frame; |
188 | 188 | |
189 | 189 | $this->_frame->prepend_child($child, $update_node); |
190 | 190 | } |
191 | 191 | |
192 | 192 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
193 | + while ($child instanceof Frame_Decorator) |
|
194 | 194 | $child = $child->_frame; |
195 | 195 | |
196 | 196 | $this->_frame->append_child($child, $update_node); |
197 | 197 | } |
198 | 198 | |
199 | 199 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
200 | + while ($new_child instanceof Frame_Decorator) |
|
201 | 201 | $new_child = $new_child->_frame; |
202 | 202 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
203 | + if ($ref instanceof Frame_Decorator) |
|
204 | 204 | $ref = $ref->_frame; |
205 | 205 | |
206 | 206 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 207 | } |
208 | 208 | |
209 | 209 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
210 | + while ($new_child instanceof Frame_Decorator) |
|
211 | 211 | $new_child = $new_child->_frame; |
212 | 212 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
213 | + while ($ref instanceof Frame_Decorator) |
|
214 | 214 | $ref = $ref->_frame; |
215 | 215 | |
216 | 216 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 217 | } |
218 | 218 | |
219 | 219 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
220 | + while ($child instanceof Frame_Decorator) |
|
221 | 221 | $child = $new_child->_frame; |
222 | 222 | |
223 | 223 | $this->_frame->remove_child($child, $update_node); |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | |
230 | 230 | $p = $this->_frame->get_parent(); |
231 | 231 | |
232 | - if ( $p && $deco = $p->get_decorator() ) { |
|
233 | - while ( $tmp = $deco->get_decorator() ) |
|
232 | + if ($p && $deco = $p->get_decorator()) { |
|
233 | + while ($tmp = $deco->get_decorator()) |
|
234 | 234 | $deco = $tmp; |
235 | 235 | return $deco; |
236 | - } else if ( $p ) |
|
236 | + } else if ($p) |
|
237 | 237 | return $p; |
238 | 238 | else |
239 | 239 | return null; |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | |
242 | 242 | function get_first_child() { |
243 | 243 | $c = $this->_frame->get_first_child(); |
244 | - if ( $c && $deco = $c->get_decorator() ) { |
|
245 | - while ( $tmp = $deco->get_decorator() ) |
|
244 | + if ($c && $deco = $c->get_decorator()) { |
|
245 | + while ($tmp = $deco->get_decorator()) |
|
246 | 246 | $deco = $tmp; |
247 | 247 | return $deco; |
248 | - } else if ( $c ) |
|
248 | + } else if ($c) |
|
249 | 249 | return $c; |
250 | 250 | else |
251 | 251 | return null; |
@@ -253,11 +253,11 @@ discard block |
||
253 | 253 | |
254 | 254 | function get_last_child() { |
255 | 255 | $c = $this->_frame->get_last_child(); |
256 | - if ( $c && $deco = $c->get_decorator() ) { |
|
257 | - while ( $tmp = $deco->get_decorator() ) |
|
256 | + if ($c && $deco = $c->get_decorator()) { |
|
257 | + while ($tmp = $deco->get_decorator()) |
|
258 | 258 | $deco = $tmp; |
259 | 259 | return $deco; |
260 | - } else if ( $c ) |
|
260 | + } else if ($c) |
|
261 | 261 | return $c; |
262 | 262 | else |
263 | 263 | return null; |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | |
266 | 266 | function get_prev_sibling() { |
267 | 267 | $s = $this->_frame->get_prev_sibling(); |
268 | - if ( $s && $deco = $s->get_decorator() ) { |
|
269 | - while ( $tmp = $deco->get_decorator() ) |
|
268 | + if ($s && $deco = $s->get_decorator()) { |
|
269 | + while ($tmp = $deco->get_decorator()) |
|
270 | 270 | $deco = $tmp; |
271 | 271 | return $deco; |
272 | - } else if ( $s ) |
|
272 | + } else if ($s) |
|
273 | 273 | return $s; |
274 | 274 | else |
275 | 275 | return null; |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | |
278 | 278 | function get_next_sibling() { |
279 | 279 | $s = $this->_frame->get_next_sibling(); |
280 | - if ( $s && $deco = $s->get_decorator() ) { |
|
281 | - while ( $tmp = $deco->get_decorator() ) |
|
280 | + if ($s && $deco = $s->get_decorator()) { |
|
281 | + while ($tmp = $deco->get_decorator()) |
|
282 | 282 | $deco = $tmp; |
283 | 283 | return $deco; |
284 | - } else if ( $s ) |
|
284 | + } else if ($s) |
|
285 | 285 | return $s; |
286 | 286 | else |
287 | 287 | return null; |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | |
300 | 300 | function set_positioner(Positioner $posn) { |
301 | 301 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
302 | + if ($this->_frame instanceof Frame_Decorator) |
|
303 | 303 | $this->_frame->set_positioner($posn); |
304 | 304 | } |
305 | 305 | |
@@ -307,8 +307,8 @@ discard block |
||
307 | 307 | |
308 | 308 | function set_reflower(Frame_Reflower $reflower) { |
309 | 309 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
310 | + if ($this->_frame instanceof Frame_Decorator) |
|
311 | + $this->_frame->set_reflower($reflower); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | function get_reflower() { return $this->_reflower; } |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | |
318 | 318 | function set_root(Frame $root) { |
319 | 319 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
320 | + if ($this->_frame instanceof Frame_Decorator) |
|
321 | 321 | $this->_frame->set_root($root); |
322 | 322 | } |
323 | 323 | |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | // Find our nearest block level parent |
331 | 331 | $p = $this->get_parent(); |
332 | 332 | |
333 | - while ( $p ) { |
|
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
333 | + while ($p) { |
|
334 | + if (in_array($p->get_style()->display, Style::$BLOCK_TYPES)) |
|
335 | 335 | break; |
336 | 336 | |
337 | 337 | $p = $p->get_parent(); |
@@ -353,15 +353,15 @@ discard block |
||
353 | 353 | */ |
354 | 354 | function split($child = null) { |
355 | 355 | |
356 | - if ( is_null( $child ) ) { |
|
356 | + if (is_null($child)) { |
|
357 | 357 | $this->get_parent()->split($this); |
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | - if ( $child->get_parent() !== $this ) |
|
361 | + if ($child->get_parent() !== $this) |
|
362 | 362 | throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
363 | 363 | |
364 | - $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
|
364 | + $split = $this->copy($this->_frame->get_node()->cloneNode()); |
|
365 | 365 | $split->reset(); |
366 | 366 | $this->get_parent()->insert_child_after($split, $this); |
367 | 367 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | |
380 | 380 | //........................................................................ |
381 | 381 | |
382 | - final function position() { $this->_positioner->position(); } |
|
382 | + final function position() { $this->_positioner->position(); } |
|
383 | 383 | |
384 | 384 | final function reflow() { |
385 | 385 | // Uncomment this to see the frames before they're laid out, instead of |
@@ -102,8 +102,9 @@ discard block |
||
102 | 102 | function dispose($recursive = false) { |
103 | 103 | |
104 | 104 | if ( $recursive ) { |
105 | - while ( $child = $this->get_first_child() ) |
|
106 | - $child->dispose(true); |
|
105 | + while ( $child = $this->get_first_child() ) { |
|
106 | + $child->dispose(true); |
|
107 | + } |
|
107 | 108 | } |
108 | 109 | |
109 | 110 | unset($this->_root); |
@@ -134,8 +135,9 @@ discard block |
||
134 | 135 | $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf); |
135 | 136 | $deco->set_root($this->_root); |
136 | 137 | |
137 | - foreach ($this->get_children() as $child) |
|
138 | - $deco->append_child($child->deep_copy()); |
|
138 | + foreach ($this->get_children() as $child) { |
|
139 | + $deco->append_child($child->deep_copy()); |
|
140 | + } |
|
139 | 141 | |
140 | 142 | return $deco; |
141 | 143 | } |
@@ -146,8 +148,9 @@ discard block |
||
146 | 148 | $this->_frame->reset(); |
147 | 149 | |
148 | 150 | // Reset all children |
149 | - foreach ($this->get_children() as $child) |
|
150 | - $child->reset(); |
|
151 | + foreach ($this->get_children() as $child) { |
|
152 | + $child->reset(); |
|
153 | + } |
|
151 | 154 | |
152 | 155 | } |
153 | 156 | |
@@ -183,42 +186,49 @@ discard block |
||
183 | 186 | function __toString() { return $this->_frame->__toString(); } |
184 | 187 | |
185 | 188 | function prepend_child(Frame $child, $update_node = true) { |
186 | - while ( $child instanceof Frame_Decorator ) |
|
187 | - $child = $child->_frame; |
|
189 | + while ( $child instanceof Frame_Decorator ) { |
|
190 | + $child = $child->_frame; |
|
191 | + } |
|
188 | 192 | |
189 | 193 | $this->_frame->prepend_child($child, $update_node); |
190 | 194 | } |
191 | 195 | |
192 | 196 | function append_child(Frame $child, $update_node = true) { |
193 | - while ( $child instanceof Frame_Decorator ) |
|
194 | - $child = $child->_frame; |
|
197 | + while ( $child instanceof Frame_Decorator ) { |
|
198 | + $child = $child->_frame; |
|
199 | + } |
|
195 | 200 | |
196 | 201 | $this->_frame->append_child($child, $update_node); |
197 | 202 | } |
198 | 203 | |
199 | 204 | function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) { |
200 | - while ( $new_child instanceof Frame_Decorator ) |
|
201 | - $new_child = $new_child->_frame; |
|
205 | + while ( $new_child instanceof Frame_Decorator ) { |
|
206 | + $new_child = $new_child->_frame; |
|
207 | + } |
|
202 | 208 | |
203 | - if ( $ref instanceof Frame_Decorator ) |
|
204 | - $ref = $ref->_frame; |
|
209 | + if ( $ref instanceof Frame_Decorator ) { |
|
210 | + $ref = $ref->_frame; |
|
211 | + } |
|
205 | 212 | |
206 | 213 | $this->_frame->insert_child_before($new_child, $ref, $update_node); |
207 | 214 | } |
208 | 215 | |
209 | 216 | function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) { |
210 | - while ( $new_child instanceof Frame_Decorator ) |
|
211 | - $new_child = $new_child->_frame; |
|
217 | + while ( $new_child instanceof Frame_Decorator ) { |
|
218 | + $new_child = $new_child->_frame; |
|
219 | + } |
|
212 | 220 | |
213 | - while ( $ref instanceof Frame_Decorator ) |
|
214 | - $ref = $ref->_frame; |
|
221 | + while ( $ref instanceof Frame_Decorator ) { |
|
222 | + $ref = $ref->_frame; |
|
223 | + } |
|
215 | 224 | |
216 | 225 | $this->_frame->insert_child_after($new_child, $ref, $update_node); |
217 | 226 | } |
218 | 227 | |
219 | 228 | function remove_child(Frame $child, $update_node = true) { |
220 | - while ( $child instanceof Frame_Decorator ) |
|
221 | - $child = $new_child->_frame; |
|
229 | + while ( $child instanceof Frame_Decorator ) { |
|
230 | + $child = $new_child->_frame; |
|
231 | + } |
|
222 | 232 | |
223 | 233 | $this->_frame->remove_child($child, $update_node); |
224 | 234 | } |
@@ -230,61 +240,71 @@ discard block |
||
230 | 240 | $p = $this->_frame->get_parent(); |
231 | 241 | |
232 | 242 | if ( $p && $deco = $p->get_decorator() ) { |
233 | - while ( $tmp = $deco->get_decorator() ) |
|
234 | - $deco = $tmp; |
|
243 | + while ( $tmp = $deco->get_decorator() ) { |
|
244 | + $deco = $tmp; |
|
245 | + } |
|
235 | 246 | return $deco; |
236 | - } else if ( $p ) |
|
237 | - return $p; |
|
238 | - else |
|
239 | - return null; |
|
247 | + } else if ( $p ) { |
|
248 | + return $p; |
|
249 | + } else { |
|
250 | + return null; |
|
251 | + } |
|
240 | 252 | } |
241 | 253 | |
242 | 254 | function get_first_child() { |
243 | 255 | $c = $this->_frame->get_first_child(); |
244 | 256 | if ( $c && $deco = $c->get_decorator() ) { |
245 | - while ( $tmp = $deco->get_decorator() ) |
|
246 | - $deco = $tmp; |
|
257 | + while ( $tmp = $deco->get_decorator() ) { |
|
258 | + $deco = $tmp; |
|
259 | + } |
|
247 | 260 | return $deco; |
248 | - } else if ( $c ) |
|
249 | - return $c; |
|
250 | - else |
|
251 | - return null; |
|
261 | + } else if ( $c ) { |
|
262 | + return $c; |
|
263 | + } else { |
|
264 | + return null; |
|
265 | + } |
|
252 | 266 | } |
253 | 267 | |
254 | 268 | function get_last_child() { |
255 | 269 | $c = $this->_frame->get_last_child(); |
256 | 270 | if ( $c && $deco = $c->get_decorator() ) { |
257 | - while ( $tmp = $deco->get_decorator() ) |
|
258 | - $deco = $tmp; |
|
271 | + while ( $tmp = $deco->get_decorator() ) { |
|
272 | + $deco = $tmp; |
|
273 | + } |
|
259 | 274 | return $deco; |
260 | - } else if ( $c ) |
|
261 | - return $c; |
|
262 | - else |
|
263 | - return null; |
|
275 | + } else if ( $c ) { |
|
276 | + return $c; |
|
277 | + } else { |
|
278 | + return null; |
|
279 | + } |
|
264 | 280 | } |
265 | 281 | |
266 | 282 | function get_prev_sibling() { |
267 | 283 | $s = $this->_frame->get_prev_sibling(); |
268 | 284 | if ( $s && $deco = $s->get_decorator() ) { |
269 | - while ( $tmp = $deco->get_decorator() ) |
|
270 | - $deco = $tmp; |
|
285 | + while ( $tmp = $deco->get_decorator() ) { |
|
286 | + $deco = $tmp; |
|
287 | + } |
|
271 | 288 | return $deco; |
272 | - } else if ( $s ) |
|
273 | - return $s; |
|
274 | - else |
|
275 | - return null; |
|
289 | + } else if ( $s ) { |
|
290 | + return $s; |
|
291 | + } else { |
|
292 | + return null; |
|
293 | + } |
|
276 | 294 | } |
277 | 295 | |
278 | 296 | function get_next_sibling() { |
279 | 297 | $s = $this->_frame->get_next_sibling(); |
280 | 298 | if ( $s && $deco = $s->get_decorator() ) { |
281 | - while ( $tmp = $deco->get_decorator() ) |
|
282 | - $deco = $tmp; |
|
299 | + while ( $tmp = $deco->get_decorator() ) { |
|
300 | + $deco = $tmp; |
|
301 | + } |
|
283 | 302 | return $deco; |
284 | - } else if ( $s ) |
|
285 | - return $s; |
|
286 | - else |
|
287 | - return null; |
|
303 | + } else if ( $s ) { |
|
304 | + return $s; |
|
305 | + } else { |
|
306 | + return null; |
|
307 | + } |
|
288 | 308 | } |
289 | 309 | |
290 | 310 | function get_children() { |
@@ -299,16 +319,18 @@ discard block |
||
299 | 319 | |
300 | 320 | function set_positioner(Positioner $posn) { |
301 | 321 | $this->_positioner = $posn; |
302 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
303 | - $this->_frame->set_positioner($posn); |
|
322 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
323 | + $this->_frame->set_positioner($posn); |
|
324 | + } |
|
304 | 325 | } |
305 | 326 | |
306 | 327 | //........................................................................ |
307 | 328 | |
308 | 329 | function set_reflower(Frame_Reflower $reflower) { |
309 | 330 | $this->_reflower = $reflower; |
310 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
311 | - $this->_frame->set_reflower( $reflower ); |
|
331 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
332 | + $this->_frame->set_reflower( $reflower ); |
|
333 | + } |
|
312 | 334 | } |
313 | 335 | |
314 | 336 | function get_reflower() { return $this->_reflower; } |
@@ -317,8 +339,9 @@ discard block |
||
317 | 339 | |
318 | 340 | function set_root(Frame $root) { |
319 | 341 | $this->_root = $root; |
320 | - if ( $this->_frame instanceof Frame_Decorator ) |
|
321 | - $this->_frame->set_root($root); |
|
342 | + if ( $this->_frame instanceof Frame_Decorator ) { |
|
343 | + $this->_frame->set_root($root); |
|
344 | + } |
|
322 | 345 | } |
323 | 346 | |
324 | 347 | function get_root() { return $this->_root; } |
@@ -331,8 +354,9 @@ discard block |
||
331 | 354 | $p = $this->get_parent(); |
332 | 355 | |
333 | 356 | while ( $p ) { |
334 | - if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) |
|
335 | - break; |
|
357 | + if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) { |
|
358 | + break; |
|
359 | + } |
|
336 | 360 | |
337 | 361 | $p = $p->get_parent(); |
338 | 362 | } |
@@ -358,8 +382,9 @@ discard block |
||
358 | 382 | return; |
359 | 383 | } |
360 | 384 | |
361 | - if ( $child->get_parent() !== $this ) |
|
362 | - throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
385 | + if ( $child->get_parent() !== $this ) { |
|
386 | + throw new DOMPDF_Exception("Unable to split: frame is not a child of this one."); |
|
387 | + } |
|
363 | 388 | |
364 | 389 | $split = $this->copy( $this->_frame->get_node()->cloneNode() ); |
365 | 390 | $split->reset(); |
@@ -60,6 +60,10 @@ |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | + |
|
64 | + /** |
|
65 | + * @param DOMPDF $dompdf |
|
66 | + */ |
|
63 | 67 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | 68 | if ( is_null($dompdf) ) |
65 | 69 | throw new Exception("foo"); |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -52,119 +51,119 @@ discard block |
||
52 | 51 | */ |
53 | 52 | class Frame_Factory { |
54 | 53 | |
55 | - static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
54 | + static function decorate_root(Frame $root, DOMPDF $dompdf) { |
|
56 | 55 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | 56 | $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
58 | 57 | $root->set_decorator($frame); |
59 | 58 | return $frame; |
60 | - } |
|
59 | + } |
|
61 | 60 | |
62 | - // FIXME: this is admittedly a little smelly... |
|
63 | - static function decorate_frame(Frame $frame, $dompdf) { |
|
61 | + // FIXME: this is admittedly a little smelly... |
|
62 | + static function decorate_frame(Frame $frame, $dompdf) { |
|
64 | 63 | if ( is_null($dompdf) ) |
65 | - throw new Exception("foo"); |
|
64 | + throw new Exception("foo"); |
|
66 | 65 | switch ($frame->get_style()->display) { |
67 | 66 | |
68 | 67 | case "block": |
69 | 68 | $positioner = "Block"; |
70 | - $decorator = "Block"; |
|
71 | - $reflower = "Block"; |
|
72 | - break; |
|
69 | + $decorator = "Block"; |
|
70 | + $reflower = "Block"; |
|
71 | + break; |
|
73 | 72 | |
74 | 73 | case "inline-block": |
75 | 74 | $positioner = "Inline"; |
76 | - $decorator = "Block"; |
|
77 | - $reflower = "Block"; |
|
78 | - break; |
|
75 | + $decorator = "Block"; |
|
76 | + $reflower = "Block"; |
|
77 | + break; |
|
79 | 78 | |
80 | 79 | case "inline": |
81 | 80 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
81 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | 82 | $decorator = "Text"; |
84 | 83 | $reflower = "Text"; |
85 | - } else { |
|
84 | + } else { |
|
86 | 85 | $decorator = "Inline"; |
87 | 86 | $reflower = "Inline"; |
88 | - } |
|
89 | - break; |
|
87 | + } |
|
88 | + break; |
|
90 | 89 | |
91 | 90 | case "table": |
92 | 91 | $positioner = "Block"; |
93 | - $decorator = "Table"; |
|
94 | - $reflower = "Table"; |
|
95 | - break; |
|
92 | + $decorator = "Table"; |
|
93 | + $reflower = "Table"; |
|
94 | + break; |
|
96 | 95 | |
97 | 96 | case "inline-table": |
98 | 97 | $positioner = "Inline"; |
99 | - $decorator = "Table"; |
|
100 | - $reflower = "Table"; |
|
101 | - break; |
|
98 | + $decorator = "Table"; |
|
99 | + $reflower = "Table"; |
|
100 | + break; |
|
102 | 101 | |
103 | 102 | case "table-row-group": |
104 | 103 | case "table-header-group": |
105 | 104 | case "table-footer-group": |
106 | 105 | $positioner = "Null"; |
107 | - $decorator = "Table_Row_Group"; |
|
108 | - $reflower = "Table_Row_Group"; |
|
109 | - break; |
|
106 | + $decorator = "Table_Row_Group"; |
|
107 | + $reflower = "Table_Row_Group"; |
|
108 | + break; |
|
110 | 109 | |
111 | 110 | case "table-row": |
112 | 111 | $positioner = "Null"; |
113 | - $decorator = "Table_Row"; |
|
114 | - $reflower = "Table_Row"; |
|
115 | - break; |
|
112 | + $decorator = "Table_Row"; |
|
113 | + $reflower = "Table_Row"; |
|
114 | + break; |
|
116 | 115 | |
117 | 116 | case "table-cell": |
118 | 117 | $positioner = "Table_Cell"; |
119 | - $decorator = "Table_Cell"; |
|
120 | - $reflower = "Table_Cell"; |
|
121 | - break; |
|
118 | + $decorator = "Table_Cell"; |
|
119 | + $reflower = "Table_Cell"; |
|
120 | + break; |
|
122 | 121 | |
123 | 122 | case "list-item": |
124 | 123 | $positioner = "Block"; |
125 | - $decorator = "Block"; |
|
126 | - $reflower = "Block"; |
|
127 | - break; |
|
124 | + $decorator = "Block"; |
|
125 | + $reflower = "Block"; |
|
126 | + break; |
|
128 | 127 | |
129 | 128 | case "-dompdf-list-bullet": |
130 | 129 | if ( $frame->get_style()->list_style_position === "inside" ) |
131 | 130 | $positioner = "Inline"; |
132 | - else |
|
131 | + else |
|
133 | 132 | $positioner = "List_Bullet"; |
134 | 133 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
134 | + if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | 135 | $decorator = "List_Bullet_Image"; |
137 | - else |
|
136 | + else |
|
138 | 137 | $decorator = "List_Bullet"; |
139 | 138 | |
140 | - $reflower = "List_Bullet"; |
|
141 | - break; |
|
139 | + $reflower = "List_Bullet"; |
|
140 | + break; |
|
142 | 141 | |
143 | 142 | case "-dompdf-image": |
144 | 143 | $positioner = "Inline"; |
145 | - $decorator = "Image"; |
|
146 | - $reflower = "Image"; |
|
147 | - break; |
|
144 | + $decorator = "Image"; |
|
145 | + $reflower = "Image"; |
|
146 | + break; |
|
148 | 147 | |
149 | 148 | case "-dompdf-br": |
150 | 149 | $positioner = "Inline"; |
151 | - $decorator = "Inline"; |
|
152 | - $reflower = "Inline"; |
|
153 | - break; |
|
150 | + $decorator = "Inline"; |
|
151 | + $reflower = "Inline"; |
|
152 | + break; |
|
154 | 153 | |
155 | 154 | default: |
156 | 155 | // FIXME: should throw some sort of warning or something? |
157 | 156 | case "none": |
158 | 157 | $positioner = "Null"; |
159 | - $decorator = "Null"; |
|
160 | - $reflower = "Null"; |
|
161 | - break; |
|
158 | + $decorator = "Null"; |
|
159 | + $reflower = "Null"; |
|
160 | + break; |
|
162 | 161 | |
163 | 162 | } |
164 | 163 | |
165 | 164 | if ( $frame->get_style()->position === "absolute" || |
166 | 165 | $frame->get_style()->position === "fixed" ) |
167 | - $positioner = "Absolute"; |
|
166 | + $positioner = "Absolute"; |
|
168 | 167 | |
169 | 168 | $positioner .= "_Positioner"; |
170 | 169 | $decorator .= "_Frame_Decorator"; |
@@ -176,10 +175,10 @@ discard block |
||
176 | 175 | |
177 | 176 | // Generated content is a special case |
178 | 177 | if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
179 | - // Decorate the reflower |
|
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
182 | - $reflow = $gen; |
|
178 | + // Decorate the reflower |
|
179 | + $gen = new Generated_Frame_Reflower( $deco ); |
|
180 | + $gen->set_reflower( $reflow ); |
|
181 | + $reflow = $gen; |
|
183 | 182 | } |
184 | 183 | |
185 | 184 | $deco->set_reflower( $reflow ); |
@@ -204,6 +203,6 @@ discard block |
||
204 | 203 | // } |
205 | 204 | |
206 | 205 | return $deco; |
207 | - } |
|
206 | + } |
|
208 | 207 | |
209 | 208 | } |
@@ -65,100 +65,100 @@ |
||
65 | 65 | throw new Exception("foo"); |
66 | 66 | switch ($frame->get_style()->display) { |
67 | 67 | |
68 | - case "block": |
|
69 | - $positioner = "Block"; |
|
70 | - $decorator = "Block"; |
|
71 | - $reflower = "Block"; |
|
72 | - break; |
|
68 | + case "block": |
|
69 | + $positioner = "Block"; |
|
70 | + $decorator = "Block"; |
|
71 | + $reflower = "Block"; |
|
72 | + break; |
|
73 | 73 | |
74 | - case "inline-block": |
|
75 | - $positioner = "Inline"; |
|
76 | - $decorator = "Block"; |
|
77 | - $reflower = "Block"; |
|
78 | - break; |
|
79 | - |
|
80 | - case "inline": |
|
81 | - $positioner = "Inline"; |
|
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | - $decorator = "Text"; |
|
84 | - $reflower = "Text"; |
|
85 | - } else { |
|
86 | - $decorator = "Inline"; |
|
87 | - $reflower = "Inline"; |
|
88 | - } |
|
89 | - break; |
|
90 | - |
|
91 | - case "table": |
|
92 | - $positioner = "Block"; |
|
93 | - $decorator = "Table"; |
|
94 | - $reflower = "Table"; |
|
95 | - break; |
|
74 | + case "inline-block": |
|
75 | + $positioner = "Inline"; |
|
76 | + $decorator = "Block"; |
|
77 | + $reflower = "Block"; |
|
78 | + break; |
|
79 | + |
|
80 | + case "inline": |
|
81 | + $positioner = "Inline"; |
|
82 | + if ( $frame->get_node()->nodeName === "#text" ) { |
|
83 | + $decorator = "Text"; |
|
84 | + $reflower = "Text"; |
|
85 | + } else { |
|
86 | + $decorator = "Inline"; |
|
87 | + $reflower = "Inline"; |
|
88 | + } |
|
89 | + break; |
|
90 | + |
|
91 | + case "table": |
|
92 | + $positioner = "Block"; |
|
93 | + $decorator = "Table"; |
|
94 | + $reflower = "Table"; |
|
95 | + break; |
|
96 | 96 | |
97 | - case "inline-table": |
|
98 | - $positioner = "Inline"; |
|
99 | - $decorator = "Table"; |
|
100 | - $reflower = "Table"; |
|
101 | - break; |
|
102 | - |
|
103 | - case "table-row-group": |
|
104 | - case "table-header-group": |
|
105 | - case "table-footer-group": |
|
106 | - $positioner = "Null"; |
|
107 | - $decorator = "Table_Row_Group"; |
|
108 | - $reflower = "Table_Row_Group"; |
|
109 | - break; |
|
97 | + case "inline-table": |
|
98 | + $positioner = "Inline"; |
|
99 | + $decorator = "Table"; |
|
100 | + $reflower = "Table"; |
|
101 | + break; |
|
102 | + |
|
103 | + case "table-row-group": |
|
104 | + case "table-header-group": |
|
105 | + case "table-footer-group": |
|
106 | + $positioner = "Null"; |
|
107 | + $decorator = "Table_Row_Group"; |
|
108 | + $reflower = "Table_Row_Group"; |
|
109 | + break; |
|
110 | 110 | |
111 | - case "table-row": |
|
112 | - $positioner = "Null"; |
|
113 | - $decorator = "Table_Row"; |
|
114 | - $reflower = "Table_Row"; |
|
115 | - break; |
|
116 | - |
|
117 | - case "table-cell": |
|
118 | - $positioner = "Table_Cell"; |
|
119 | - $decorator = "Table_Cell"; |
|
120 | - $reflower = "Table_Cell"; |
|
121 | - break; |
|
111 | + case "table-row": |
|
112 | + $positioner = "Null"; |
|
113 | + $decorator = "Table_Row"; |
|
114 | + $reflower = "Table_Row"; |
|
115 | + break; |
|
116 | + |
|
117 | + case "table-cell": |
|
118 | + $positioner = "Table_Cell"; |
|
119 | + $decorator = "Table_Cell"; |
|
120 | + $reflower = "Table_Cell"; |
|
121 | + break; |
|
122 | 122 | |
123 | - case "list-item": |
|
124 | - $positioner = "Block"; |
|
125 | - $decorator = "Block"; |
|
126 | - $reflower = "Block"; |
|
127 | - break; |
|
128 | - |
|
129 | - case "-dompdf-list-bullet": |
|
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
131 | - $positioner = "Inline"; |
|
132 | - else |
|
133 | - $positioner = "List_Bullet"; |
|
134 | - |
|
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | - $decorator = "List_Bullet_Image"; |
|
137 | - else |
|
138 | - $decorator = "List_Bullet"; |
|
123 | + case "list-item": |
|
124 | + $positioner = "Block"; |
|
125 | + $decorator = "Block"; |
|
126 | + $reflower = "Block"; |
|
127 | + break; |
|
128 | + |
|
129 | + case "-dompdf-list-bullet": |
|
130 | + if ( $frame->get_style()->list_style_position === "inside" ) |
|
131 | + $positioner = "Inline"; |
|
132 | + else |
|
133 | + $positioner = "List_Bullet"; |
|
134 | + |
|
135 | + if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | + $decorator = "List_Bullet_Image"; |
|
137 | + else |
|
138 | + $decorator = "List_Bullet"; |
|
139 | 139 | |
140 | - $reflower = "List_Bullet"; |
|
141 | - break; |
|
142 | - |
|
143 | - case "-dompdf-image": |
|
144 | - $positioner = "Inline"; |
|
145 | - $decorator = "Image"; |
|
146 | - $reflower = "Image"; |
|
147 | - break; |
|
140 | + $reflower = "List_Bullet"; |
|
141 | + break; |
|
142 | + |
|
143 | + case "-dompdf-image": |
|
144 | + $positioner = "Inline"; |
|
145 | + $decorator = "Image"; |
|
146 | + $reflower = "Image"; |
|
147 | + break; |
|
148 | 148 | |
149 | - case "-dompdf-br": |
|
150 | - $positioner = "Inline"; |
|
151 | - $decorator = "Inline"; |
|
152 | - $reflower = "Inline"; |
|
153 | - break; |
|
154 | - |
|
155 | - default: |
|
156 | - // FIXME: should throw some sort of warning or something? |
|
157 | - case "none": |
|
158 | - $positioner = "Null"; |
|
159 | - $decorator = "Null"; |
|
160 | - $reflower = "Null"; |
|
161 | - break; |
|
149 | + case "-dompdf-br": |
|
150 | + $positioner = "Inline"; |
|
151 | + $decorator = "Inline"; |
|
152 | + $reflower = "Inline"; |
|
153 | + break; |
|
154 | + |
|
155 | + default: |
|
156 | + // FIXME: should throw some sort of warning or something? |
|
157 | + case "none": |
|
158 | + $positioner = "Null"; |
|
159 | + $decorator = "Null"; |
|
160 | + $reflower = "Null"; |
|
161 | + break; |
|
162 | 162 | |
163 | 163 | } |
164 | 164 |
@@ -54,14 +54,14 @@ discard block |
||
54 | 54 | |
55 | 55 | static function decorate_root(Frame $root, DOMPDF $dompdf) { |
56 | 56 | $frame = new Page_Frame_Decorator($root, $dompdf); |
57 | - $frame->set_reflower( new Page_Frame_Reflower($frame) ); |
|
57 | + $frame->set_reflower(new Page_Frame_Reflower($frame)); |
|
58 | 58 | $root->set_decorator($frame); |
59 | 59 | return $frame; |
60 | 60 | } |
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | 63 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | - if ( is_null($dompdf) ) |
|
64 | + if (is_null($dompdf)) |
|
65 | 65 | throw new Exception("foo"); |
66 | 66 | switch ($frame->get_style()->display) { |
67 | 67 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | case "inline": |
81 | 81 | $positioner = "Inline"; |
82 | - if ( $frame->get_node()->nodeName === "#text" ) { |
|
82 | + if ($frame->get_node()->nodeName === "#text") { |
|
83 | 83 | $decorator = "Text"; |
84 | 84 | $reflower = "Text"; |
85 | 85 | } else { |
@@ -127,12 +127,12 @@ discard block |
||
127 | 127 | break; |
128 | 128 | |
129 | 129 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
130 | + if ($frame->get_style()->list_style_position === "inside") |
|
131 | 131 | $positioner = "Inline"; |
132 | 132 | else |
133 | 133 | $positioner = "List_Bullet"; |
134 | 134 | |
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
135 | + if ($frame->get_style()->list_style_image !== "none") |
|
136 | 136 | $decorator = "List_Bullet_Image"; |
137 | 137 | else |
138 | 138 | $decorator = "List_Bullet"; |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | - if ( $frame->get_style()->position === "absolute" || |
|
166 | - $frame->get_style()->position === "fixed" ) |
|
165 | + if ($frame->get_style()->position === "absolute" || |
|
166 | + $frame->get_style()->position === "fixed") |
|
167 | 167 | $positioner = "Absolute"; |
168 | 168 | |
169 | 169 | $positioner .= "_Positioner"; |
@@ -171,18 +171,18 @@ discard block |
||
171 | 171 | $reflower .= "_Frame_Reflower"; |
172 | 172 | |
173 | 173 | $deco = new $decorator($frame, $dompdf); |
174 | - $deco->set_positioner( new $positioner($deco) ); |
|
174 | + $deco->set_positioner(new $positioner($deco)); |
|
175 | 175 | $reflow = new $reflower($deco); |
176 | 176 | |
177 | 177 | // Generated content is a special case |
178 | - if ( $frame->get_node()->nodeName === "_dompdf_generated" ) { |
|
178 | + if ($frame->get_node()->nodeName === "_dompdf_generated") { |
|
179 | 179 | // Decorate the reflower |
180 | - $gen = new Generated_Frame_Reflower( $deco ); |
|
181 | - $gen->set_reflower( $reflow ); |
|
180 | + $gen = new Generated_Frame_Reflower($deco); |
|
181 | + $gen->set_reflower($reflow); |
|
182 | 182 | $reflow = $gen; |
183 | 183 | } |
184 | 184 | |
185 | - $deco->set_reflower( $reflow ); |
|
185 | + $deco->set_reflower($reflow); |
|
186 | 186 | |
187 | 187 | // Images are a special case |
188 | 188 | // if ( $frame->get_node()->nodeName === "img" ) { |
@@ -61,8 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | // FIXME: this is admittedly a little smelly... |
63 | 63 | static function decorate_frame(Frame $frame, $dompdf) { |
64 | - if ( is_null($dompdf) ) |
|
65 | - throw new Exception("foo"); |
|
64 | + if ( is_null($dompdf) ) { |
|
65 | + throw new Exception("foo"); |
|
66 | + } |
|
66 | 67 | switch ($frame->get_style()->display) { |
67 | 68 | |
68 | 69 | case "block": |
@@ -127,15 +128,17 @@ discard block |
||
127 | 128 | break; |
128 | 129 | |
129 | 130 | case "-dompdf-list-bullet": |
130 | - if ( $frame->get_style()->list_style_position === "inside" ) |
|
131 | - $positioner = "Inline"; |
|
132 | - else |
|
133 | - $positioner = "List_Bullet"; |
|
134 | - |
|
135 | - if ( $frame->get_style()->list_style_image !== "none" ) |
|
136 | - $decorator = "List_Bullet_Image"; |
|
137 | - else |
|
138 | - $decorator = "List_Bullet"; |
|
131 | + if ( $frame->get_style()->list_style_position === "inside" ) { |
|
132 | + $positioner = "Inline"; |
|
133 | + } else { |
|
134 | + $positioner = "List_Bullet"; |
|
135 | + } |
|
136 | + |
|
137 | + if ( $frame->get_style()->list_style_image !== "none" ) { |
|
138 | + $decorator = "List_Bullet_Image"; |
|
139 | + } else { |
|
140 | + $decorator = "List_Bullet"; |
|
141 | + } |
|
139 | 142 | |
140 | 143 | $reflower = "List_Bullet"; |
141 | 144 | break; |
@@ -163,8 +166,9 @@ discard block |
||
163 | 166 | } |
164 | 167 | |
165 | 168 | if ( $frame->get_style()->position === "absolute" || |
166 | - $frame->get_style()->position === "fixed" ) |
|
167 | - $positioner = "Absolute"; |
|
169 | + $frame->get_style()->position === "fixed" ) { |
|
170 | + $positioner = "Absolute"; |
|
171 | + } |
|
168 | 172 | |
169 | 173 | $positioner .= "_Positioner"; |
170 | 174 | $decorator .= "_Frame_Decorator"; |
@@ -305,6 +305,10 @@ discard block |
||
305 | 305 | */ |
306 | 306 | |
307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
308 | + |
|
309 | + /** |
|
310 | + * @param string|null $to_encoding |
|
311 | + */ |
|
308 | 312 | function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
309 | 313 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | 314 | return utf8_encode($data); |
@@ -327,6 +331,10 @@ discard block |
||
327 | 331 | } |
328 | 332 | |
329 | 333 | if ( !function_exists("mb_internal_encoding") ) { |
334 | + |
|
335 | + /** |
|
336 | + * @param string $encoding |
|
337 | + */ |
|
330 | 338 | function mb_internal_encoding($encoding=NULL) { |
331 | 339 | if (isset($encoding)) { |
332 | 340 | return true; |
@@ -365,6 +373,10 @@ discard block |
||
365 | 373 | } |
366 | 374 | |
367 | 375 | if ( !function_exists("mb_strtoupper") ) { |
376 | + |
|
377 | + /** |
|
378 | + * @param string $str |
|
379 | + */ |
|
368 | 380 | function mb_strtoupper($str) { |
369 | 381 | return strtoupper($str); |
370 | 382 | } |
@@ -380,6 +392,10 @@ discard block |
||
380 | 392 | } |
381 | 393 | |
382 | 394 | if ( !function_exists("mb_substr_count") ) { |
395 | + |
|
396 | + /** |
|
397 | + * @param string $needle |
|
398 | + */ |
|
383 | 399 | function mb_substr_count($haystack, $needle) { |
384 | 400 | return substr_count($haystack, $needle); |
385 | 401 | } |
@@ -442,6 +458,7 @@ discard block |
||
442 | 458 | * Print debug messages |
443 | 459 | * |
444 | 460 | * @param string $type The type of debug messages to print |
461 | + * @param string $msg |
|
445 | 462 | */ |
446 | 463 | function dompdf_debug($type, $msg) { |
447 | 464 | global $_DOMPDF_DEBUG_TYPES; |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | */ |
64 | 64 | if ( !function_exists("pre_r") ) { |
65 | 65 | function pre_r($mixed, $return = false) { |
66 | - if ($return) |
|
66 | + if ($return) |
|
67 | 67 | return "<pre>" . print_r($mixed, true) . "</pre>"; |
68 | 68 | |
69 | - if ( php_sapi_name() !== "cli") |
|
69 | + if ( php_sapi_name() !== "cli") |
|
70 | 70 | echo ("<pre>"); |
71 | - print_r($mixed); |
|
71 | + print_r($mixed); |
|
72 | 72 | |
73 | - if ( php_sapi_name() !== "cli") |
|
73 | + if ( php_sapi_name() !== "cli") |
|
74 | 74 | echo("</pre>"); |
75 | - else |
|
75 | + else |
|
76 | 76 | echo ("\n"); |
77 | - flush(); |
|
77 | + flush(); |
|
78 | 78 | |
79 | 79 | } |
80 | 80 | } |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | */ |
90 | 90 | if ( !function_exists("pre_var_dump") ) { |
91 | 91 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
92 | + if ( php_sapi_name() !== "cli") |
|
93 | 93 | echo("<pre>"); |
94 | - var_dump($mixed); |
|
95 | - if ( php_sapi_name() !== "cli") |
|
94 | + var_dump($mixed); |
|
95 | + if ( php_sapi_name() !== "cli") |
|
96 | 96 | echo("</pre>"); |
97 | 97 | } |
98 | 98 | } |
@@ -115,41 +115,41 @@ discard block |
||
115 | 115 | * is appended (o.k. also for Windows) |
116 | 116 | */ |
117 | 117 | function build_url($protocol, $host, $base_path, $url) { |
118 | - if ( mb_strlen($url) == 0 ) { |
|
118 | + if ( mb_strlen($url) == 0 ) { |
|
119 | 119 | //return $protocol . $host . rtrim($base_path, "/\\") . "/"; |
120 | 120 | return $protocol . $host . $base_path; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - // Is the url already fully qualified? |
|
124 | - if ( mb_strpos($url, "://") !== false ) |
|
123 | + // Is the url already fully qualified? |
|
124 | + if ( mb_strpos($url, "://") !== false ) |
|
125 | 125 | return $url; |
126 | 126 | |
127 | - $ret = $protocol; |
|
127 | + $ret = $protocol; |
|
128 | 128 | |
129 | - if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
129 | + if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) { |
|
130 | 130 | //On Windows local file, an abs path can begin also with a '\' or a drive letter and colon |
131 | 131 | //drive: followed by a relative path would be a drive specific default folder. |
132 | 132 | //not known in php app code, treat as abs path |
133 | 133 | //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/')) |
134 | 134 | if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':'))) { |
135 | - // For rel path and local acess we ignore the host, and run the path through realpath() |
|
136 | - $ret .= realpath($base_path).'/'; |
|
135 | + // For rel path and local acess we ignore the host, and run the path through realpath() |
|
136 | + $ret .= realpath($base_path).'/'; |
|
137 | 137 | } |
138 | 138 | $ret .= $url; |
139 | 139 | return $ret; |
140 | - } |
|
140 | + } |
|
141 | 141 | |
142 | - //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
142 | + //remote urls with backslash in html/css are not really correct, but lets be genereous |
|
143 | + if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
144 | 144 | // Absolute path |
145 | 145 | $ret .= $host . $url; |
146 | - } else { |
|
146 | + } else { |
|
147 | 147 | // Relative path |
148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
149 | 149 | $ret .= $host . $base_path . $url; |
150 | - } |
|
150 | + } |
|
151 | 151 | |
152 | - return $ret; |
|
152 | + return $ret; |
|
153 | 153 | |
154 | 154 | } |
155 | 155 | |
@@ -161,56 +161,56 @@ discard block |
||
161 | 161 | * @return array |
162 | 162 | */ |
163 | 163 | function explode_url($url) { |
164 | - $protocol = ""; |
|
165 | - $host = ""; |
|
166 | - $path = ""; |
|
167 | - $file = ""; |
|
164 | + $protocol = ""; |
|
165 | + $host = ""; |
|
166 | + $path = ""; |
|
167 | + $file = ""; |
|
168 | 168 | |
169 | - $arr = parse_url($url); |
|
169 | + $arr = parse_url($url); |
|
170 | 170 | |
171 | - if ( isset($arr["scheme"]) && |
|
171 | + if ( isset($arr["scheme"]) && |
|
172 | 172 | $arr["scheme"] !== "file" && |
173 | 173 | mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
174 | 174 | { |
175 | 175 | $protocol = $arr["scheme"] . "://"; |
176 | 176 | |
177 | 177 | if ( isset($arr["user"]) ) { |
178 | - $host .= $arr["user"]; |
|
178 | + $host .= $arr["user"]; |
|
179 | 179 | |
180 | - if ( isset($arr["pass"]) ) |
|
180 | + if ( isset($arr["pass"]) ) |
|
181 | 181 | $host .= "@" . $arr["pass"]; |
182 | 182 | |
183 | - $host .= ":"; |
|
183 | + $host .= ":"; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | if ( isset($arr["host"]) ) |
187 | - $host .= $arr["host"]; |
|
187 | + $host .= $arr["host"]; |
|
188 | 188 | |
189 | 189 | if ( isset($arr["port"]) ) |
190 | - $host .= ":" . $arr["port"]; |
|
190 | + $host .= ":" . $arr["port"]; |
|
191 | 191 | |
192 | 192 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
193 | - // Do we have a trailing slash? |
|
194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
193 | + // Do we have a trailing slash? |
|
194 | + if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
195 | 195 | $path = $arr["path"]; |
196 | 196 | $file = ""; |
197 | - } else { |
|
197 | + } else { |
|
198 | 198 | $path = dirname($arr["path"]) . "/"; |
199 | 199 | $file = basename($arr["path"]); |
200 | - } |
|
200 | + } |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | if ( isset($arr["query"]) ) |
204 | - $file .= "?" . $arr["query"]; |
|
204 | + $file .= "?" . $arr["query"]; |
|
205 | 205 | |
206 | 206 | if ( isset($arr["fragment"]) ) |
207 | - $file .= "#" . $arr["fragment"]; |
|
207 | + $file .= "#" . $arr["fragment"]; |
|
208 | 208 | |
209 | - } else { |
|
209 | + } else { |
|
210 | 210 | |
211 | 211 | $i = mb_strpos($url, "file://"); |
212 | 212 | if ( $i !== false) |
213 | - $url = mb_substr($url, $i + 7); |
|
213 | + $url = mb_substr($url, $i + 7); |
|
214 | 214 | |
215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
216 | 216 | // network filenames like //COMPU/SHARENAME |
@@ -222,28 +222,28 @@ discard block |
||
222 | 222 | |
223 | 223 | // Check that the path exists |
224 | 224 | if ( $path !== false ) { |
225 | - $path .= '/'; |
|
225 | + $path .= '/'; |
|
226 | 226 | |
227 | 227 | } else { |
228 | - // generate a url to access the file if no real path found. |
|
229 | - $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
228 | + // generate a url to access the file if no real path found. |
|
229 | + $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://'; |
|
230 | 230 | |
231 | - $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
|
231 | + $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
|
232 | 232 | |
233 | - if ( substr($arr["path"], 0, 1) === '/' ) { |
|
233 | + if ( substr($arr["path"], 0, 1) === '/' ) { |
|
234 | 234 | $path = dirname($arr["path"]); |
235 | - } else { |
|
235 | + } else { |
|
236 | 236 | $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
237 | - } |
|
237 | + } |
|
238 | + } |
|
238 | 239 | } |
239 | - } |
|
240 | - |
|
241 | - $ret = array($protocol, $host, $path, $file, |
|
242 | - "protocol" => $protocol, |
|
243 | - "host" => $host, |
|
244 | - "path" => $path, |
|
245 | - "file" => $file); |
|
246 | - return $ret; |
|
240 | + |
|
241 | + $ret = array($protocol, $host, $path, $file, |
|
242 | + "protocol" => $protocol, |
|
243 | + "host" => $host, |
|
244 | + "path" => $path, |
|
245 | + "file" => $file); |
|
246 | + return $ret; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -254,41 +254,41 @@ discard block |
||
254 | 254 | */ |
255 | 255 | function dec2roman($num) { |
256 | 256 | |
257 | - static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
258 | - "vi", "vii", "viii", "ix"); |
|
259 | - static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
260 | - "lx", "lxx", "lxxx", "xc"); |
|
261 | - static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
262 | - "dc", "dcc", "dccc", "cm"); |
|
263 | - static $thou = array("", "m", "mm", "mmm"); |
|
257 | + static $ones = array("", "i", "ii", "iii", "iv", "v", |
|
258 | + "vi", "vii", "viii", "ix"); |
|
259 | + static $tens = array("", "x", "xx", "xxx", "xl", "l", |
|
260 | + "lx", "lxx", "lxxx", "xc"); |
|
261 | + static $hund = array("", "c", "cc", "ccc", "cd", "d", |
|
262 | + "dc", "dcc", "dccc", "cm"); |
|
263 | + static $thou = array("", "m", "mm", "mmm"); |
|
264 | 264 | |
265 | - if ( !is_numeric($num) ) |
|
265 | + if ( !is_numeric($num) ) |
|
266 | 266 | throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
267 | 267 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
268 | + if ( $num > 4000 || $num < 0 ) |
|
269 | 269 | return "(out of range)"; |
270 | 270 | |
271 | - $num = strrev((string)$num); |
|
271 | + $num = strrev((string)$num); |
|
272 | 272 | |
273 | - $ret = ""; |
|
274 | - switch (mb_strlen($num)) { |
|
273 | + $ret = ""; |
|
274 | + switch (mb_strlen($num)) { |
|
275 | 275 | |
276 | - case 4: |
|
276 | + case 4: |
|
277 | 277 | $ret .= $thou[$num[3]]; |
278 | 278 | |
279 | - case 3: |
|
279 | + case 3: |
|
280 | 280 | $ret .= $hund[$num[2]]; |
281 | 281 | |
282 | - case 2: |
|
282 | + case 2: |
|
283 | 283 | $ret .= $tens[$num[1]]; |
284 | 284 | |
285 | - case 1: |
|
285 | + case 1: |
|
286 | 286 | $ret .= $ones[$num[0]]; |
287 | 287 | |
288 | - default: |
|
288 | + default: |
|
289 | 289 | break; |
290 | - } |
|
291 | - return $ret; |
|
290 | + } |
|
291 | + return $ret; |
|
292 | 292 | |
293 | 293 | } |
294 | 294 | |
@@ -305,84 +305,84 @@ discard block |
||
305 | 305 | */ |
306 | 306 | |
307 | 307 | if ( !function_exists("mb_convert_encoding") ) { |
308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | - return utf8_encode($data); |
|
310 | + return utf8_encode($data); |
|
311 | 311 | } else { |
312 | - return utf8_decode($data); |
|
312 | + return utf8_decode($data); |
|
313 | + } |
|
313 | 314 | } |
314 | - } |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | if ( !function_exists("mb_detect_encoding") ) { |
318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
318 | + function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
319 | 319 | return 'iso-8859-1'; |
320 | - } |
|
320 | + } |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | if ( !function_exists("mb_detect_order") ) { |
324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
324 | + function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
325 | 325 | return 'iso-8859-1'; |
326 | - } |
|
326 | + } |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | if ( !function_exists("mb_internal_encoding") ) { |
330 | - function mb_internal_encoding($encoding=NULL) { |
|
330 | + function mb_internal_encoding($encoding=NULL) { |
|
331 | 331 | if (isset($encoding)) { |
332 | - return true; |
|
332 | + return true; |
|
333 | 333 | } else { |
334 | - return 'iso-8859-1'; |
|
334 | + return 'iso-8859-1'; |
|
335 | + } |
|
335 | 336 | } |
336 | - } |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | if ( !function_exists("mb_strlen") ) { |
340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
340 | + function mb_strlen($str, $encoding='iso-8859-1') { |
|
341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
342 | - return strlen(utf8_encode($data)); |
|
342 | + return strlen(utf8_encode($data)); |
|
343 | 343 | } else { |
344 | - return strlen(utf8_decode($data)); |
|
344 | + return strlen(utf8_decode($data)); |
|
345 | + } |
|
345 | 346 | } |
346 | - } |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | if ( !function_exists("mb_strpos") ) { |
350 | - function mb_strpos($haystack, $needle, $offset = 0) { |
|
350 | + function mb_strpos($haystack, $needle, $offset = 0) { |
|
351 | 351 | return strpos($haystack, $needle, $offset); |
352 | - } |
|
352 | + } |
|
353 | 353 | } |
354 | 354 | |
355 | 355 | if ( !function_exists("mb_strrpos") ) { |
356 | - function mb_strrpos($haystack, $needle, $offset = 0) { |
|
356 | + function mb_strrpos($haystack, $needle, $offset = 0) { |
|
357 | 357 | return strrpos($haystack, $needle, $offset); |
358 | - } |
|
358 | + } |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | if ( !function_exists("mb_strtolower") ) { |
362 | - function mb_strtolower($str) { |
|
362 | + function mb_strtolower($str) { |
|
363 | 363 | return strtolower($str); |
364 | - } |
|
364 | + } |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | if ( !function_exists("mb_strtoupper") ) { |
368 | - function mb_strtoupper($str) { |
|
368 | + function mb_strtoupper($str) { |
|
369 | 369 | return strtoupper($str); |
370 | - } |
|
370 | + } |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | if ( !function_exists("mb_substr") ) { |
374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
374 | + function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
375 | 375 | if ( is_null($length) ) |
376 | - return substr($str, $start); |
|
376 | + return substr($str, $start); |
|
377 | 377 | else |
378 | - return substr($str, $start, $length); |
|
379 | - } |
|
378 | + return substr($str, $start, $length); |
|
379 | + } |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | if ( !function_exists("mb_substr_count") ) { |
383 | - function mb_substr_count($haystack, $needle) { |
|
383 | + function mb_substr_count($haystack, $needle) { |
|
384 | 384 | return substr_count($haystack, $needle); |
385 | - } |
|
385 | + } |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -402,40 +402,40 @@ discard block |
||
402 | 402 | */ |
403 | 403 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 404 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
405 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
406 | 406 | throw new DOMPDF_Exception($errstr . " $errno"); |
407 | 407 | |
408 | - global $_dompdf_warnings; |
|
409 | - global $_dompdf_show_warnings; |
|
408 | + global $_dompdf_warnings; |
|
409 | + global $_dompdf_show_warnings; |
|
410 | 410 | |
411 | - if ( $_dompdf_show_warnings ) |
|
411 | + if ( $_dompdf_show_warnings ) |
|
412 | 412 | echo $errstr . "\n"; |
413 | 413 | |
414 | - $_dompdf_warnings[] = $errstr; |
|
414 | + $_dompdf_warnings[] = $errstr; |
|
415 | 415 | } |
416 | 416 | |
417 | 417 | /** |
418 | 418 | * Print a useful backtrace |
419 | 419 | */ |
420 | 420 | function bt() { |
421 | - $bt = debug_backtrace(); |
|
421 | + $bt = debug_backtrace(); |
|
422 | 422 | |
423 | - array_shift($bt); // remove actual bt() call |
|
424 | - echo "\n"; |
|
423 | + array_shift($bt); // remove actual bt() call |
|
424 | + echo "\n"; |
|
425 | 425 | |
426 | - $i = 0; |
|
427 | - foreach ($bt as $call) { |
|
426 | + $i = 0; |
|
427 | + foreach ($bt as $call) { |
|
428 | 428 | $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
429 | 429 | if ( isset($call["class"]) ) { |
430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
430 | + $func = $call["class"] . "->" . $call["function"] . "()"; |
|
431 | 431 | } else { |
432 | - $func = $call["function"] . "()"; |
|
432 | + $func = $call["function"] . "()"; |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
436 | 436 | $i++; |
437 | - } |
|
438 | - echo "\n"; |
|
437 | + } |
|
438 | + echo "\n"; |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /** |
@@ -444,15 +444,15 @@ discard block |
||
444 | 444 | * @param string $type The type of debug messages to print |
445 | 445 | */ |
446 | 446 | function dompdf_debug($type, $msg) { |
447 | - global $_DOMPDF_DEBUG_TYPES; |
|
448 | - global $_dompdf_show_warnings; |
|
449 | - global $_dompdf_debug; |
|
450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
447 | + global $_DOMPDF_DEBUG_TYPES; |
|
448 | + global $_dompdf_show_warnings; |
|
449 | + global $_dompdf_debug; |
|
450 | + if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
451 | 451 | $arr = debug_backtrace(); |
452 | 452 | |
453 | 453 | echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
454 | 454 | pre_r($msg); |
455 | - } |
|
455 | + } |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -460,20 +460,20 @@ discard block |
||
460 | 460 | */ |
461 | 461 | if ( !function_exists("print_memusage") ) { |
462 | 462 | function print_memusage() { |
463 | - global $memusage; |
|
464 | - echo ("Memory Usage\n"); |
|
465 | - $prev = 0; |
|
466 | - $initial = reset($memusage); |
|
467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
463 | + global $memusage; |
|
464 | + echo ("Memory Usage\n"); |
|
465 | + $prev = 0; |
|
466 | + $initial = reset($memusage); |
|
467 | + echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
468 | 468 | |
469 | - foreach ($memusage as $key=>$mem) { |
|
469 | + foreach ($memusage as $key=>$mem) { |
|
470 | 470 | $mem -= $initial; |
471 | 471 | echo (str_pad("$key:" , 40)); |
472 | 472 | echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n"); |
473 | 473 | $prev = $mem; |
474 | - } |
|
474 | + } |
|
475 | 475 | |
476 | - echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
476 | + echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
@@ -495,8 +495,8 @@ discard block |
||
495 | 495 | */ |
496 | 496 | if ( !function_exists("mark_memusage") ) { |
497 | 497 | function mark_memusage($location) { |
498 | - global $memusage; |
|
499 | - if ( isset($memusage) ) |
|
498 | + global $memusage; |
|
499 | + if ( isset($memusage) ) |
|
500 | 500 | $memusage[$location] = memory_get_usage(); |
501 | 501 | } |
502 | 502 | } |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
508 | 508 | */ |
509 | 509 | if ( !function_exists('sys_get_temp_dir')) { |
510 | - function sys_get_temp_dir() { |
|
510 | + function sys_get_temp_dir() { |
|
511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
512 | 512 | if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
513 | 513 | if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
@@ -516,5 +516,5 @@ discard block |
||
516 | 516 | unlink($tempfile); |
517 | 517 | return realpath(dirname($tempfile)); |
518 | 518 | } |
519 | - } |
|
519 | + } |
|
520 | 520 | } |
@@ -273,20 +273,20 @@ |
||
273 | 273 | $ret = ""; |
274 | 274 | switch (mb_strlen($num)) { |
275 | 275 | |
276 | - case 4: |
|
277 | - $ret .= $thou[$num[3]]; |
|
276 | + case 4: |
|
277 | + $ret .= $thou[$num[3]]; |
|
278 | 278 | |
279 | - case 3: |
|
280 | - $ret .= $hund[$num[2]]; |
|
279 | + case 3: |
|
280 | + $ret .= $hund[$num[2]]; |
|
281 | 281 | |
282 | - case 2: |
|
283 | - $ret .= $tens[$num[1]]; |
|
282 | + case 2: |
|
283 | + $ret .= $tens[$num[1]]; |
|
284 | 284 | |
285 | - case 1: |
|
286 | - $ret .= $ones[$num[0]]; |
|
285 | + case 1: |
|
286 | + $ret .= $ones[$num[0]]; |
|
287 | 287 | |
288 | - default: |
|
289 | - break; |
|
288 | + default: |
|
289 | + break; |
|
290 | 290 | } |
291 | 291 | return $ret; |
292 | 292 |
@@ -61,16 +61,16 @@ discard block |
||
61 | 61 | * @param bool $return |
62 | 62 | * |
63 | 63 | */ |
64 | -if ( !function_exists("pre_r") ) { |
|
64 | +if (!function_exists("pre_r")) { |
|
65 | 65 | function pre_r($mixed, $return = false) { |
66 | 66 | if ($return) |
67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
67 | + return "<pre>".print_r($mixed, true)."</pre>"; |
|
68 | 68 | |
69 | - if ( php_sapi_name() !== "cli") |
|
69 | + if (php_sapi_name() !== "cli") |
|
70 | 70 | echo ("<pre>"); |
71 | 71 | print_r($mixed); |
72 | 72 | |
73 | - if ( php_sapi_name() !== "cli") |
|
73 | + if (php_sapi_name() !== "cli") |
|
74 | 74 | echo("</pre>"); |
75 | 75 | else |
76 | 76 | echo ("\n"); |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @param mixed $mixed variable or expression to display. |
89 | 89 | */ |
90 | -if ( !function_exists("pre_var_dump") ) { |
|
90 | +if (!function_exists("pre_var_dump")) { |
|
91 | 91 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
92 | + if (php_sapi_name() !== "cli") |
|
93 | 93 | echo("<pre>"); |
94 | 94 | var_dump($mixed); |
95 | - if ( php_sapi_name() !== "cli") |
|
95 | + if (php_sapi_name() !== "cli") |
|
96 | 96 | echo("</pre>"); |
97 | 97 | } |
98 | 98 | } |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | * is appended (o.k. also for Windows) |
116 | 116 | */ |
117 | 117 | function build_url($protocol, $host, $base_path, $url) { |
118 | - if ( mb_strlen($url) == 0 ) { |
|
118 | + if (mb_strlen($url) == 0) { |
|
119 | 119 | //return $protocol . $host . rtrim($base_path, "/\\") . "/"; |
120 | - return $protocol . $host . $base_path; |
|
120 | + return $protocol.$host.$base_path; |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | // Is the url already fully qualified? |
124 | - if ( mb_strpos($url, "://") !== false ) |
|
124 | + if (mb_strpos($url, "://") !== false) |
|
125 | 125 | return $url; |
126 | 126 | |
127 | 127 | $ret = $protocol; |
@@ -140,13 +140,13 @@ discard block |
||
140 | 140 | } |
141 | 141 | |
142 | 142 | //remote urls with backslash in html/css are not really correct, but lets be genereous |
143 | - if ( $url[0] === '/' || $url[0] === '\\' ) { |
|
143 | + if ($url[0] === '/' || $url[0] === '\\') { |
|
144 | 144 | // Absolute path |
145 | - $ret .= $host . $url; |
|
145 | + $ret .= $host.$url; |
|
146 | 146 | } else { |
147 | 147 | // Relative path |
148 | 148 | //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : ""; |
149 | - $ret .= $host . $base_path . $url; |
|
149 | + $ret .= $host.$base_path.$url; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | return $ret; |
@@ -168,48 +168,48 @@ discard block |
||
168 | 168 | |
169 | 169 | $arr = parse_url($url); |
170 | 170 | |
171 | - if ( isset($arr["scheme"]) && |
|
171 | + if (isset($arr["scheme"]) && |
|
172 | 172 | $arr["scheme"] !== "file" && |
173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
173 | + mb_strlen($arr["scheme"]) > 1) // Exclude windows drive letters... |
|
174 | 174 | { |
175 | - $protocol = $arr["scheme"] . "://"; |
|
175 | + $protocol = $arr["scheme"]."://"; |
|
176 | 176 | |
177 | - if ( isset($arr["user"]) ) { |
|
177 | + if (isset($arr["user"])) { |
|
178 | 178 | $host .= $arr["user"]; |
179 | 179 | |
180 | - if ( isset($arr["pass"]) ) |
|
181 | - $host .= "@" . $arr["pass"]; |
|
180 | + if (isset($arr["pass"])) |
|
181 | + $host .= "@".$arr["pass"]; |
|
182 | 182 | |
183 | 183 | $host .= ":"; |
184 | 184 | } |
185 | 185 | |
186 | - if ( isset($arr["host"]) ) |
|
186 | + if (isset($arr["host"])) |
|
187 | 187 | $host .= $arr["host"]; |
188 | 188 | |
189 | - if ( isset($arr["port"]) ) |
|
190 | - $host .= ":" . $arr["port"]; |
|
189 | + if (isset($arr["port"])) |
|
190 | + $host .= ":".$arr["port"]; |
|
191 | 191 | |
192 | - if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
|
192 | + if (isset($arr["path"]) && $arr["path"] !== "") { |
|
193 | 193 | // Do we have a trailing slash? |
194 | - if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) { |
|
194 | + if ($arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/") { |
|
195 | 195 | $path = $arr["path"]; |
196 | 196 | $file = ""; |
197 | 197 | } else { |
198 | - $path = dirname($arr["path"]) . "/"; |
|
198 | + $path = dirname($arr["path"])."/"; |
|
199 | 199 | $file = basename($arr["path"]); |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - if ( isset($arr["query"]) ) |
|
204 | - $file .= "?" . $arr["query"]; |
|
203 | + if (isset($arr["query"])) |
|
204 | + $file .= "?".$arr["query"]; |
|
205 | 205 | |
206 | - if ( isset($arr["fragment"]) ) |
|
207 | - $file .= "#" . $arr["fragment"]; |
|
206 | + if (isset($arr["fragment"])) |
|
207 | + $file .= "#".$arr["fragment"]; |
|
208 | 208 | |
209 | 209 | } else { |
210 | 210 | |
211 | 211 | $i = mb_strpos($url, "file://"); |
212 | - if ( $i !== false) |
|
212 | + if ($i !== false) |
|
213 | 213 | $url = mb_substr($url, $i + 7); |
214 | 214 | |
215 | 215 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | $path = dirname($url); |
222 | 222 | |
223 | 223 | // Check that the path exists |
224 | - if ( $path !== false ) { |
|
224 | + if ($path !== false) { |
|
225 | 225 | $path .= '/'; |
226 | 226 | |
227 | 227 | } else { |
@@ -230,10 +230,10 @@ discard block |
||
230 | 230 | |
231 | 231 | $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n"); |
232 | 232 | |
233 | - if ( substr($arr["path"], 0, 1) === '/' ) { |
|
233 | + if (substr($arr["path"], 0, 1) === '/') { |
|
234 | 234 | $path = dirname($arr["path"]); |
235 | 235 | } else { |
236 | - $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"]; |
|
236 | + $path = '/'.rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/').'/'.$arr["path"]; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | "dc", "dcc", "dccc", "cm"); |
263 | 263 | static $thou = array("", "m", "mm", "mmm"); |
264 | 264 | |
265 | - if ( !is_numeric($num) ) |
|
265 | + if (!is_numeric($num)) |
|
266 | 266 | throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
267 | 267 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
268 | + if ($num > 4000 || $num < 0) |
|
269 | 269 | return "(out of range)"; |
270 | 270 | |
271 | - $num = strrev((string)$num); |
|
271 | + $num = strrev((string) $num); |
|
272 | 272 | |
273 | 273 | $ret = ""; |
274 | 274 | switch (mb_strlen($num)) { |
@@ -304,8 +304,8 @@ discard block |
||
304 | 304 | * mb_string compatibility |
305 | 305 | */ |
306 | 306 | |
307 | -if ( !function_exists("mb_convert_encoding") ) { |
|
308 | - function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') { |
|
307 | +if (!function_exists("mb_convert_encoding")) { |
|
308 | + function mb_convert_encoding($data, $to_encoding, $from_encoding = 'UTF-8') { |
|
309 | 309 | if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') { |
310 | 310 | return utf8_encode($data); |
311 | 311 | } else { |
@@ -314,20 +314,20 @@ discard block |
||
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | -if ( !function_exists("mb_detect_encoding") ) { |
|
318 | - function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) { |
|
317 | +if (!function_exists("mb_detect_encoding")) { |
|
318 | + function mb_detect_encoding($data, $encoding_list = array('iso-8859-1'), $strict = false) { |
|
319 | 319 | return 'iso-8859-1'; |
320 | 320 | } |
321 | 321 | } |
322 | 322 | |
323 | -if ( !function_exists("mb_detect_order") ) { |
|
324 | - function mb_detect_order($encoding_list=array('iso-8859-1')) { |
|
323 | +if (!function_exists("mb_detect_order")) { |
|
324 | + function mb_detect_order($encoding_list = array('iso-8859-1')) { |
|
325 | 325 | return 'iso-8859-1'; |
326 | 326 | } |
327 | 327 | } |
328 | 328 | |
329 | -if ( !function_exists("mb_internal_encoding") ) { |
|
330 | - function mb_internal_encoding($encoding=NULL) { |
|
329 | +if (!function_exists("mb_internal_encoding")) { |
|
330 | + function mb_internal_encoding($encoding = NULL) { |
|
331 | 331 | if (isset($encoding)) { |
332 | 332 | return true; |
333 | 333 | } else { |
@@ -336,8 +336,8 @@ discard block |
||
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
339 | -if ( !function_exists("mb_strlen") ) { |
|
340 | - function mb_strlen($str, $encoding='iso-8859-1') { |
|
339 | +if (!function_exists("mb_strlen")) { |
|
340 | + function mb_strlen($str, $encoding = 'iso-8859-1') { |
|
341 | 341 | if (str_replace('-', '', strtolower($encoding)) == 'utf8') { |
342 | 342 | return strlen(utf8_encode($data)); |
343 | 343 | } else { |
@@ -346,40 +346,40 @@ discard block |
||
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | -if ( !function_exists("mb_strpos") ) { |
|
349 | +if (!function_exists("mb_strpos")) { |
|
350 | 350 | function mb_strpos($haystack, $needle, $offset = 0) { |
351 | 351 | return strpos($haystack, $needle, $offset); |
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | -if ( !function_exists("mb_strrpos") ) { |
|
355 | +if (!function_exists("mb_strrpos")) { |
|
356 | 356 | function mb_strrpos($haystack, $needle, $offset = 0) { |
357 | 357 | return strrpos($haystack, $needle, $offset); |
358 | 358 | } |
359 | 359 | } |
360 | 360 | |
361 | -if ( !function_exists("mb_strtolower") ) { |
|
361 | +if (!function_exists("mb_strtolower")) { |
|
362 | 362 | function mb_strtolower($str) { |
363 | 363 | return strtolower($str); |
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | -if ( !function_exists("mb_strtoupper") ) { |
|
367 | +if (!function_exists("mb_strtoupper")) { |
|
368 | 368 | function mb_strtoupper($str) { |
369 | 369 | return strtoupper($str); |
370 | 370 | } |
371 | 371 | } |
372 | 372 | |
373 | -if ( !function_exists("mb_substr") ) { |
|
374 | - function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
|
375 | - if ( is_null($length) ) |
|
373 | +if (!function_exists("mb_substr")) { |
|
374 | + function mb_substr($str, $start, $length = null, $encoding = 'iso-8859-1') { |
|
375 | + if (is_null($length)) |
|
376 | 376 | return substr($str, $start); |
377 | 377 | else |
378 | 378 | return substr($str, $start, $length); |
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
382 | -if ( !function_exists("mb_substr_count") ) { |
|
382 | +if (!function_exists("mb_substr_count")) { |
|
383 | 383 | function mb_substr_count($haystack, $needle) { |
384 | 384 | return substr_count($haystack, $needle); |
385 | 385 | } |
@@ -402,14 +402,14 @@ discard block |
||
402 | 402 | */ |
403 | 403 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 404 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
406 | - throw new DOMPDF_Exception($errstr . " $errno"); |
|
405 | + if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) // Not a warning or notice |
|
406 | + throw new DOMPDF_Exception($errstr." $errno"); |
|
407 | 407 | |
408 | 408 | global $_dompdf_warnings; |
409 | 409 | global $_dompdf_show_warnings; |
410 | 410 | |
411 | - if ( $_dompdf_show_warnings ) |
|
412 | - echo $errstr . "\n"; |
|
411 | + if ($_dompdf_show_warnings) |
|
412 | + echo $errstr."\n"; |
|
413 | 413 | |
414 | 414 | $_dompdf_warnings[] = $errstr; |
415 | 415 | } |
@@ -425,14 +425,14 @@ discard block |
||
425 | 425 | |
426 | 426 | $i = 0; |
427 | 427 | foreach ($bt as $call) { |
428 | - $file = basename($call["file"]) . " (" . $call["line"] . ")"; |
|
429 | - if ( isset($call["class"]) ) { |
|
430 | - $func = $call["class"] . "->" . $call["function"] . "()"; |
|
428 | + $file = basename($call["file"])." (".$call["line"].")"; |
|
429 | + if (isset($call["class"])) { |
|
430 | + $func = $call["class"]."->".$call["function"]."()"; |
|
431 | 431 | } else { |
432 | - $func = $call["function"] . "()"; |
|
432 | + $func = $call["function"]."()"; |
|
433 | 433 | } |
434 | 434 | |
435 | - echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n"; |
|
435 | + echo "#".str_pad($i, 2, " ", STR_PAD_RIGHT).": ".str_pad($file.":", 42)." $func\n"; |
|
436 | 436 | $i++; |
437 | 437 | } |
438 | 438 | echo "\n"; |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | global $_DOMPDF_DEBUG_TYPES; |
448 | 448 | global $_dompdf_show_warnings; |
449 | 449 | global $_dompdf_debug; |
450 | - if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) { |
|
450 | + if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) { |
|
451 | 451 | $arr = debug_backtrace(); |
452 | 452 | |
453 | - echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": "; |
|
453 | + echo basename($arr[0]["file"])." (".$arr[0]["line"]."): ".$arr[1]["function"].": "; |
|
454 | 454 | pre_r($msg); |
455 | 455 | } |
456 | 456 | } |
@@ -458,29 +458,29 @@ discard block |
||
458 | 458 | /** |
459 | 459 | * Dump memory usage |
460 | 460 | */ |
461 | -if ( !function_exists("print_memusage") ) { |
|
461 | +if (!function_exists("print_memusage")) { |
|
462 | 462 | function print_memusage() { |
463 | 463 | global $memusage; |
464 | 464 | echo ("Memory Usage\n"); |
465 | 465 | $prev = 0; |
466 | 466 | $initial = reset($memusage); |
467 | - echo (str_pad("Initial:", 40) . $initial . "\n\n"); |
|
467 | + echo (str_pad("Initial:", 40).$initial."\n\n"); |
|
468 | 468 | |
469 | 469 | foreach ($memusage as $key=>$mem) { |
470 | 470 | $mem -= $initial; |
471 | - echo (str_pad("$key:" , 40)); |
|
472 | - echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n"); |
|
471 | + echo (str_pad("$key:", 40)); |
|
472 | + echo (str_pad("$mem", 12)."(diff: ".($mem - $prev).")\n"); |
|
473 | 473 | $prev = $mem; |
474 | 474 | } |
475 | 475 | |
476 | - echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n"; |
|
476 | + echo ("\n".str_pad("Total:", 40).memory_get_usage())."\n"; |
|
477 | 477 | } |
478 | 478 | } |
479 | 479 | |
480 | 480 | /** |
481 | 481 | * Initialize memory profiling code |
482 | 482 | */ |
483 | -if ( !function_exists("enable_mem_profile") ) { |
|
483 | +if (!function_exists("enable_mem_profile")) { |
|
484 | 484 | function enable_mem_profile() { |
485 | 485 | global $memusage; |
486 | 486 | $memusage = array("Startup" => memory_get_usage()); |
@@ -493,10 +493,10 @@ discard block |
||
493 | 493 | * |
494 | 494 | * @param string $location a meaningful location |
495 | 495 | */ |
496 | -if ( !function_exists("mark_memusage") ) { |
|
496 | +if (!function_exists("mark_memusage")) { |
|
497 | 497 | function mark_memusage($location) { |
498 | 498 | global $memusage; |
499 | - if ( isset($memusage) ) |
|
499 | + if (isset($memusage)) |
|
500 | 500 | $memusage[$location] = memory_get_usage(); |
501 | 501 | } |
502 | 502 | } |
@@ -506,12 +506,12 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261 |
508 | 508 | */ |
509 | -if ( !function_exists('sys_get_temp_dir')) { |
|
509 | +if (!function_exists('sys_get_temp_dir')) { |
|
510 | 510 | function sys_get_temp_dir() { |
511 | 511 | if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); } |
512 | - if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); } |
|
513 | - if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); } |
|
514 | - $tempfile=tempnam(uniqid(rand(),TRUE),''); |
|
512 | + if (!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); } |
|
513 | + if (!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); } |
|
514 | + $tempfile = tempnam(uniqid(rand(), TRUE), ''); |
|
515 | 515 | if (file_exists($tempfile)) { |
516 | 516 | unlink($tempfile); |
517 | 517 | return realpath(dirname($tempfile)); |
@@ -63,17 +63,20 @@ discard block |
||
63 | 63 | */ |
64 | 64 | if ( !function_exists("pre_r") ) { |
65 | 65 | function pre_r($mixed, $return = false) { |
66 | - if ($return) |
|
67 | - return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
66 | + if ($return) { |
|
67 | + return "<pre>" . print_r($mixed, true) . "</pre>"; |
|
68 | + } |
|
68 | 69 | |
69 | - if ( php_sapi_name() !== "cli") |
|
70 | - echo ("<pre>"); |
|
70 | + if ( php_sapi_name() !== "cli") { |
|
71 | + echo ("<pre>"); |
|
72 | + } |
|
71 | 73 | print_r($mixed); |
72 | 74 | |
73 | - if ( php_sapi_name() !== "cli") |
|
74 | - echo("</pre>"); |
|
75 | - else |
|
76 | - echo ("\n"); |
|
75 | + if ( php_sapi_name() !== "cli") { |
|
76 | + echo("</pre>"); |
|
77 | + } else { |
|
78 | + echo ("\n"); |
|
79 | + } |
|
77 | 80 | flush(); |
78 | 81 | |
79 | 82 | } |
@@ -89,12 +92,14 @@ discard block |
||
89 | 92 | */ |
90 | 93 | if ( !function_exists("pre_var_dump") ) { |
91 | 94 | function pre_var_dump($mixed) { |
92 | - if ( php_sapi_name() !== "cli") |
|
93 | - echo("<pre>"); |
|
95 | + if ( php_sapi_name() !== "cli") { |
|
96 | + echo("<pre>"); |
|
97 | + } |
|
94 | 98 | var_dump($mixed); |
95 | - if ( php_sapi_name() !== "cli") |
|
96 | - echo("</pre>"); |
|
97 | -} |
|
99 | + if ( php_sapi_name() !== "cli") { |
|
100 | + echo("</pre>"); |
|
101 | + } |
|
102 | + } |
|
98 | 103 | } |
99 | 104 | |
100 | 105 | /** |
@@ -121,8 +126,9 @@ discard block |
||
121 | 126 | } |
122 | 127 | |
123 | 128 | // Is the url already fully qualified? |
124 | - if ( mb_strpos($url, "://") !== false ) |
|
125 | - return $url; |
|
129 | + if ( mb_strpos($url, "://") !== false ) { |
|
130 | + return $url; |
|
131 | + } |
|
126 | 132 | |
127 | 133 | $ret = $protocol; |
128 | 134 | |
@@ -170,24 +176,29 @@ discard block |
||
170 | 176 | |
171 | 177 | if ( isset($arr["scheme"]) && |
172 | 178 | $arr["scheme"] !== "file" && |
173 | - mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters... |
|
179 | + mb_strlen($arr["scheme"]) > 1 ) { |
|
180 | + // Exclude windows drive letters... |
|
174 | 181 | { |
175 | 182 | $protocol = $arr["scheme"] . "://"; |
183 | + } |
|
176 | 184 | |
177 | 185 | if ( isset($arr["user"]) ) { |
178 | 186 | $host .= $arr["user"]; |
179 | 187 | |
180 | - if ( isset($arr["pass"]) ) |
|
181 | - $host .= "@" . $arr["pass"]; |
|
188 | + if ( isset($arr["pass"]) ) { |
|
189 | + $host .= "@" . $arr["pass"]; |
|
190 | + } |
|
182 | 191 | |
183 | 192 | $host .= ":"; |
184 | 193 | } |
185 | 194 | |
186 | - if ( isset($arr["host"]) ) |
|
187 | - $host .= $arr["host"]; |
|
195 | + if ( isset($arr["host"]) ) { |
|
196 | + $host .= $arr["host"]; |
|
197 | + } |
|
188 | 198 | |
189 | - if ( isset($arr["port"]) ) |
|
190 | - $host .= ":" . $arr["port"]; |
|
199 | + if ( isset($arr["port"]) ) { |
|
200 | + $host .= ":" . $arr["port"]; |
|
201 | + } |
|
191 | 202 | |
192 | 203 | if ( isset($arr["path"]) && $arr["path"] !== "" ) { |
193 | 204 | // Do we have a trailing slash? |
@@ -200,17 +211,20 @@ discard block |
||
200 | 211 | } |
201 | 212 | } |
202 | 213 | |
203 | - if ( isset($arr["query"]) ) |
|
204 | - $file .= "?" . $arr["query"]; |
|
214 | + if ( isset($arr["query"]) ) { |
|
215 | + $file .= "?" . $arr["query"]; |
|
216 | + } |
|
205 | 217 | |
206 | - if ( isset($arr["fragment"]) ) |
|
207 | - $file .= "#" . $arr["fragment"]; |
|
218 | + if ( isset($arr["fragment"]) ) { |
|
219 | + $file .= "#" . $arr["fragment"]; |
|
220 | + } |
|
208 | 221 | |
209 | 222 | } else { |
210 | 223 | |
211 | 224 | $i = mb_strpos($url, "file://"); |
212 | - if ( $i !== false) |
|
213 | - $url = mb_substr($url, $i + 7); |
|
225 | + if ( $i !== false) { |
|
226 | + $url = mb_substr($url, $i + 7); |
|
227 | + } |
|
214 | 228 | |
215 | 229 | $protocol = ""; // "file://"; ? why doesn't this work... It's because of |
216 | 230 | // network filenames like //COMPU/SHARENAME |
@@ -262,11 +276,13 @@ discard block |
||
262 | 276 | "dc", "dcc", "dccc", "cm"); |
263 | 277 | static $thou = array("", "m", "mm", "mmm"); |
264 | 278 | |
265 | - if ( !is_numeric($num) ) |
|
266 | - throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
279 | + if ( !is_numeric($num) ) { |
|
280 | + throw new DOMPDF_Exception("dec2roman() requires a numeric argument."); |
|
281 | + } |
|
267 | 282 | |
268 | - if ( $num > 4000 || $num < 0 ) |
|
269 | - return "(out of range)"; |
|
283 | + if ( $num > 4000 || $num < 0 ) { |
|
284 | + return "(out of range)"; |
|
285 | + } |
|
270 | 286 | |
271 | 287 | $num = strrev((string)$num); |
272 | 288 | |
@@ -372,10 +388,11 @@ discard block |
||
372 | 388 | |
373 | 389 | if ( !function_exists("mb_substr") ) { |
374 | 390 | function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') { |
375 | - if ( is_null($length) ) |
|
376 | - return substr($str, $start); |
|
377 | - else |
|
378 | - return substr($str, $start, $length); |
|
391 | + if ( is_null($length) ) { |
|
392 | + return substr($str, $start); |
|
393 | + } else { |
|
394 | + return substr($str, $start, $length); |
|
395 | + } |
|
379 | 396 | } |
380 | 397 | } |
381 | 398 | |
@@ -402,14 +419,17 @@ discard block |
||
402 | 419 | */ |
403 | 420 | function record_warnings($errno, $errstr, $errfile, $errline) { |
404 | 421 | |
405 | - if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice |
|
422 | + if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) { |
|
423 | + // Not a warning or notice |
|
406 | 424 | throw new DOMPDF_Exception($errstr . " $errno"); |
425 | + } |
|
407 | 426 | |
408 | 427 | global $_dompdf_warnings; |
409 | 428 | global $_dompdf_show_warnings; |
410 | 429 | |
411 | - if ( $_dompdf_show_warnings ) |
|
412 | - echo $errstr . "\n"; |
|
430 | + if ( $_dompdf_show_warnings ) { |
|
431 | + echo $errstr . "\n"; |
|
432 | + } |
|
413 | 433 | |
414 | 434 | $_dompdf_warnings[] = $errstr; |
415 | 435 | } |
@@ -496,9 +516,10 @@ discard block |
||
496 | 516 | if ( !function_exists("mark_memusage") ) { |
497 | 517 | function mark_memusage($location) { |
498 | 518 | global $memusage; |
499 | - if ( isset($memusage) ) |
|
500 | - $memusage[$location] = memory_get_usage(); |
|
501 | -} |
|
519 | + if ( isset($memusage) ) { |
|
520 | + $memusage[$location] = memory_get_usage(); |
|
521 | + } |
|
522 | + } |
|
502 | 523 | } |
503 | 524 | |
504 | 525 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
98 | 98 | * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
99 | + * @param integer $aa_factor Anti-aliasing factor, 1 for no AA |
|
100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
101 | 101 | */ |
102 | 102 | function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
@@ -536,8 +536,8 @@ discard block |
||
536 | 536 | * @param string $font the font file to use |
537 | 537 | * @param float $size the font size, in points |
538 | 538 | * @param array $color |
539 | - * @param float $adjust word spacing adjustment |
|
540 | - * @param float $angle Text angle |
|
539 | + * @param integer $adjust word spacing adjustment |
|
540 | + * @param integer $angle Text angle |
|
541 | 541 | */ |
542 | 542 | function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
543 | 543 | |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @param string $text the text to be sized |
591 | 591 | * @param string $font the desired font |
592 | 592 | * @param float $size the desired font size |
593 | - * @param float $spacing word spacing, if any |
|
593 | + * @param integer $spacing word spacing, if any |
|
594 | 594 | * @return float |
595 | 595 | */ |
596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */ |
@@ -49,73 +48,73 @@ discard block |
||
49 | 48 | */ |
50 | 49 | class GD_Adapter implements Canvas { |
51 | 50 | |
52 | - /** |
|
53 | - * Resoure handle for the image |
|
54 | - * |
|
55 | - * @var resource |
|
56 | - */ |
|
57 | - private $_img; |
|
58 | - |
|
59 | - /** |
|
60 | - * Image width in pixels |
|
61 | - * |
|
62 | - * @var int |
|
63 | - */ |
|
64 | - private $_width; |
|
65 | - |
|
66 | - /** |
|
67 | - * Image height in pixels |
|
68 | - * |
|
69 | - * @var int |
|
70 | - */ |
|
71 | - private $_height; |
|
72 | - |
|
73 | - /** |
|
74 | - * Image antialias factor |
|
75 | - * |
|
76 | - * @var float |
|
77 | - */ |
|
78 | - private $_aa_factor; |
|
79 | - |
|
80 | - /** |
|
81 | - * Allocated colors |
|
82 | - * |
|
83 | - * @var array |
|
84 | - */ |
|
85 | - private $_colors; |
|
86 | - |
|
87 | - /** |
|
88 | - * Background color |
|
89 | - * |
|
90 | - * @var int |
|
91 | - */ |
|
92 | - private $_bg_color; |
|
51 | + /** |
|
52 | + * Resoure handle for the image |
|
53 | + * |
|
54 | + * @var resource |
|
55 | + */ |
|
56 | + private $_img; |
|
57 | + |
|
58 | + /** |
|
59 | + * Image width in pixels |
|
60 | + * |
|
61 | + * @var int |
|
62 | + */ |
|
63 | + private $_width; |
|
64 | + |
|
65 | + /** |
|
66 | + * Image height in pixels |
|
67 | + * |
|
68 | + * @var int |
|
69 | + */ |
|
70 | + private $_height; |
|
71 | + |
|
72 | + /** |
|
73 | + * Image antialias factor |
|
74 | + * |
|
75 | + * @var float |
|
76 | + */ |
|
77 | + private $_aa_factor; |
|
78 | + |
|
79 | + /** |
|
80 | + * Allocated colors |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + private $_colors; |
|
85 | + |
|
86 | + /** |
|
87 | + * Background color |
|
88 | + * |
|
89 | + * @var int |
|
90 | + */ |
|
91 | + private $_bg_color; |
|
93 | 92 | |
94 | - /** |
|
95 | - * Class constructor |
|
96 | - * |
|
97 | - * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
98 | - * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
99 | - * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
100 | - * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
101 | - */ |
|
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
93 | + /** |
|
94 | + * Class constructor |
|
95 | + * |
|
96 | + * @param mixed $size The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc. |
|
97 | + * @param string $orientation The orientation of the document (either 'landscape' or 'portrait') |
|
98 | + * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
|
99 | + * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
|
100 | + */ |
|
101 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
103 | 102 | |
104 | 103 | if ( !is_array($size) ) { |
105 | 104 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
105 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | 106 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | - else |
|
107 | + else |
|
109 | 108 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 109 | |
111 | 110 | } |
112 | 111 | |
113 | 112 | if ( strtolower($orientation) === "landscape" ) { |
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + list($size[2],$size[3]) = array($size[3],$size[2]); |
|
115 | 114 | } |
116 | 115 | |
117 | 116 | if ( $aa_factor < 1 ) |
118 | - $aa_factor = 1; |
|
117 | + $aa_factor = 1; |
|
119 | 118 | |
120 | 119 | $this->_aa_factor = $aa_factor; |
121 | 120 | |
@@ -128,8 +127,8 @@ discard block |
||
128 | 127 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 128 | |
130 | 129 | if ( is_null($bg_color) || !is_array($bg_color) ) { |
131 | - // Pure white bg |
|
132 | - $bg_color = array(1,1,1,0); |
|
130 | + // Pure white bg |
|
131 | + $bg_color = array(1,1,1,0); |
|
133 | 132 | } |
134 | 133 | |
135 | 134 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -137,68 +136,68 @@ discard block |
||
137 | 136 | imagesavealpha($this->_img, true); |
138 | 137 | imagefill($this->_img, 0, 0, $this->_bg_color); |
139 | 138 | |
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Return the GF image resource |
|
144 | - * |
|
145 | - * @return resource |
|
146 | - */ |
|
147 | - function get_image() { return $this->_img; } |
|
148 | - |
|
149 | - /** |
|
150 | - * Return the image's width in pixels |
|
151 | - * |
|
152 | - * @return float |
|
153 | - */ |
|
154 | - function get_width() { return $this->_width / $this->_aa_factor; } |
|
155 | - |
|
156 | - /** |
|
157 | - * Return the image's height in pixels |
|
158 | - * |
|
159 | - * @return float |
|
160 | - */ |
|
161 | - function get_height() { return $this->_height / $this->_aa_factor; } |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Return the GF image resource |
|
143 | + * |
|
144 | + * @return resource |
|
145 | + */ |
|
146 | + function get_image() { return $this->_img; } |
|
147 | + |
|
148 | + /** |
|
149 | + * Return the image's width in pixels |
|
150 | + * |
|
151 | + * @return float |
|
152 | + */ |
|
153 | + function get_width() { return $this->_width / $this->_aa_factor; } |
|
154 | + |
|
155 | + /** |
|
156 | + * Return the image's height in pixels |
|
157 | + * |
|
158 | + * @return float |
|
159 | + */ |
|
160 | + function get_height() { return $this->_height / $this->_aa_factor; } |
|
162 | 161 | |
163 | - /** |
|
164 | - * Returns the current page number |
|
165 | - * |
|
166 | - * @return int |
|
167 | - */ |
|
168 | - function get_page_number() { |
|
162 | + /** |
|
163 | + * Returns the current page number |
|
164 | + * |
|
165 | + * @return int |
|
166 | + */ |
|
167 | + function get_page_number() { |
|
169 | 168 | // FIXME |
170 | - } |
|
169 | + } |
|
171 | 170 | |
172 | - /** |
|
173 | - * Returns the total number of pages |
|
174 | - * |
|
175 | - * @return int |
|
176 | - */ |
|
177 | - function get_page_count() { |
|
171 | + /** |
|
172 | + * Returns the total number of pages |
|
173 | + * |
|
174 | + * @return int |
|
175 | + */ |
|
176 | + function get_page_count() { |
|
178 | 177 | // FIXME |
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Sets the total number of pages |
|
183 | - * |
|
184 | - * @param int $count |
|
185 | - */ |
|
186 | - function set_page_count($count) { |
|
178 | + } |
|
179 | + |
|
180 | + /** |
|
181 | + * Sets the total number of pages |
|
182 | + * |
|
183 | + * @param int $count |
|
184 | + */ |
|
185 | + function set_page_count($count) { |
|
187 | 186 | // FIXME |
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Allocate a new color. Allocate with GD as needed and store |
|
192 | - * previously allocated colors in $this->_colors. |
|
193 | - * |
|
194 | - * @param array $color The new current color |
|
195 | - * @return int The allocated color |
|
196 | - */ |
|
197 | - private function _allocate_color($color) { |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Allocate a new color. Allocate with GD as needed and store |
|
191 | + * previously allocated colors in $this->_colors. |
|
192 | + * |
|
193 | + * @param array $color The new current color |
|
194 | + * @return int The allocated color |
|
195 | + */ |
|
196 | + private function _allocate_color($color) { |
|
198 | 197 | |
199 | 198 | // Full opacity if no alpha set |
200 | 199 | if ( !isset($color[3]) ) |
201 | - $color[3] = 0; |
|
200 | + $color[3] = 0; |
|
202 | 201 | |
203 | 202 | list($r,$g,$b,$a) = $color; |
204 | 203 | |
@@ -221,33 +220,33 @@ discard block |
||
221 | 220 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 221 | |
223 | 222 | if ( isset($this->_colors[$key]) ) |
224 | - return $this->_colors[$key]; |
|
223 | + return $this->_colors[$key]; |
|
225 | 224 | |
226 | 225 | if ( $a != 0 ) |
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
226 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | 227 | else |
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
228 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | 229 | |
231 | 230 | return $this->_colors[$key]; |
232 | 231 | |
233 | - } |
|
232 | + } |
|
234 | 233 | |
235 | - /** |
|
236 | - * Draws a line from x1,y1 to x2,y2 |
|
237 | - * |
|
238 | - * See {@link Style::munge_color()} for the format of the color array. |
|
239 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
240 | - * $style parameter (aka dash). |
|
241 | - * |
|
242 | - * @param float $x1 |
|
243 | - * @param float $y1 |
|
244 | - * @param float $x2 |
|
245 | - * @param float $y2 |
|
246 | - * @param array $color |
|
247 | - * @param float $width |
|
248 | - * @param array $style |
|
249 | - */ |
|
250 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
234 | + /** |
|
235 | + * Draws a line from x1,y1 to x2,y2 |
|
236 | + * |
|
237 | + * See {@link Style::munge_color()} for the format of the color array. |
|
238 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
239 | + * $style parameter (aka dash). |
|
240 | + * |
|
241 | + * @param float $x1 |
|
242 | + * @param float $y1 |
|
243 | + * @param float $x2 |
|
244 | + * @param float $y2 |
|
245 | + * @param array $color |
|
246 | + * @param float $width |
|
247 | + * @param array $style |
|
248 | + */ |
|
249 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null) { |
|
251 | 250 | |
252 | 251 | // Scale by the AA factor |
253 | 252 | $x1 *= $this->_aa_factor; |
@@ -260,63 +259,63 @@ discard block |
||
260 | 259 | |
261 | 260 | // Convert the style array if required |
262 | 261 | if ( !is_null($style) ) { |
263 | - $gd_style = array(); |
|
262 | + $gd_style = array(); |
|
264 | 263 | |
265 | - if ( count($style) == 1 ) { |
|
264 | + if ( count($style) == 1 ) { |
|
266 | 265 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | - $gd_style[] = $c; |
|
266 | + $gd_style[] = $c; |
|
268 | 267 | } |
269 | 268 | |
270 | 269 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
271 | - $gd_style[] = $this->_bg_color; |
|
270 | + $gd_style[] = $this->_bg_color; |
|
272 | 271 | } |
273 | 272 | |
274 | - } else { |
|
273 | + } else { |
|
275 | 274 | |
276 | 275 | $i = 0; |
277 | 276 | foreach ($style as $length) { |
278 | 277 | |
279 | - if ( $i % 2 == 0 ) { |
|
278 | + if ( $i % 2 == 0 ) { |
|
280 | 279 | // 'On' pattern |
281 | 280 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | - $gd_style[] = $c; |
|
281 | + $gd_style[] = $c; |
|
283 | 282 | |
284 | - } else { |
|
283 | + } else { |
|
285 | 284 | // Off pattern |
286 | 285 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
287 | - $gd_style[] = $this->_bg_color; |
|
286 | + $gd_style[] = $this->_bg_color; |
|
288 | 287 | |
289 | - } |
|
290 | - $i++; |
|
288 | + } |
|
289 | + $i++; |
|
290 | + } |
|
291 | 291 | } |
292 | - } |
|
293 | 292 | |
294 | - imagesetstyle($this->_img, $gd_style); |
|
295 | - $c = IMG_COLOR_STYLED; |
|
293 | + imagesetstyle($this->_img, $gd_style); |
|
294 | + $c = IMG_COLOR_STYLED; |
|
296 | 295 | } |
297 | 296 | |
298 | 297 | imagesetthickness($this->_img, $width); |
299 | 298 | |
300 | 299 | imageline($this->_img, $x1, $y1, $x2, $y2, $c); |
301 | 300 | |
302 | - } |
|
303 | - |
|
304 | - /** |
|
305 | - * Draws a rectangle at x1,y1 with width w and height h |
|
306 | - * |
|
307 | - * See {@link Style::munge_color()} for the format of the color array. |
|
308 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
309 | - * parameter (aka dash) |
|
310 | - * |
|
311 | - * @param float $x1 |
|
312 | - * @param float $y1 |
|
313 | - * @param float $w |
|
314 | - * @param float $h |
|
315 | - * @param array $color |
|
316 | - * @param float $width |
|
317 | - * @param array $style |
|
318 | - */ |
|
319 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
301 | + } |
|
302 | + |
|
303 | + /** |
|
304 | + * Draws a rectangle at x1,y1 with width w and height h |
|
305 | + * |
|
306 | + * See {@link Style::munge_color()} for the format of the color array. |
|
307 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
308 | + * parameter (aka dash) |
|
309 | + * |
|
310 | + * @param float $x1 |
|
311 | + * @param float $y1 |
|
312 | + * @param float $w |
|
313 | + * @param float $h |
|
314 | + * @param array $color |
|
315 | + * @param float $width |
|
316 | + * @param array $style |
|
317 | + */ |
|
318 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) { |
|
320 | 319 | |
321 | 320 | // Scale by the AA factor |
322 | 321 | $x1 *= $this->_aa_factor; |
@@ -328,36 +327,36 @@ discard block |
||
328 | 327 | |
329 | 328 | // Convert the style array if required |
330 | 329 | if ( !is_null($style) ) { |
331 | - $gd_style = array(); |
|
330 | + $gd_style = array(); |
|
332 | 331 | |
333 | - foreach ($style as $length) { |
|
332 | + foreach ($style as $length) { |
|
334 | 333 | for ($i = 0; $i < $length; $i++) { |
335 | - $gd_style[] = $c; |
|
334 | + $gd_style[] = $c; |
|
335 | + } |
|
336 | 336 | } |
337 | - } |
|
338 | 337 | |
339 | - imagesetstyle($this->_img, $gd_style); |
|
340 | - $c = IMG_COLOR_STYLED; |
|
338 | + imagesetstyle($this->_img, $gd_style); |
|
339 | + $c = IMG_COLOR_STYLED; |
|
341 | 340 | } |
342 | 341 | |
343 | 342 | imagesetthickness($this->_img, $width); |
344 | 343 | |
345 | 344 | imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
346 | 345 | |
347 | - } |
|
348 | - |
|
349 | - /** |
|
350 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
351 | - * |
|
352 | - * See {@link Style::munge_color()} for the format of the color array. |
|
353 | - * |
|
354 | - * @param float $x1 |
|
355 | - * @param float $y1 |
|
356 | - * @param float $w |
|
357 | - * @param float $h |
|
358 | - * @param array $color |
|
359 | - */ |
|
360 | - function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
346 | + } |
|
347 | + |
|
348 | + /** |
|
349 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
350 | + * |
|
351 | + * See {@link Style::munge_color()} for the format of the color array. |
|
352 | + * |
|
353 | + * @param float $x1 |
|
354 | + * @param float $y1 |
|
355 | + * @param float $w |
|
356 | + * @param float $h |
|
357 | + * @param array $color |
|
358 | + */ |
|
359 | + function filled_rectangle($x1, $y1, $w, $h, $color) { |
|
361 | 360 | |
362 | 361 | // Scale by the AA factor |
363 | 362 | $x1 *= $this->_aa_factor; |
@@ -369,79 +368,79 @@ discard block |
||
369 | 368 | |
370 | 369 | imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c); |
371 | 370 | |
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Draws a polygon |
|
376 | - * |
|
377 | - * The polygon is formed by joining all the points stored in the $points |
|
378 | - * array. $points has the following structure: |
|
379 | - * <code> |
|
380 | - * array(0 => x1, |
|
381 | - * 1 => y1, |
|
382 | - * 2 => x2, |
|
383 | - * 3 => y2, |
|
384 | - * ... |
|
385 | - * ); |
|
386 | - * </code> |
|
387 | - * |
|
388 | - * See {@link Style::munge_color()} for the format of the color array. |
|
389 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
390 | - * parameter (aka dash) |
|
391 | - * |
|
392 | - * @param array $points |
|
393 | - * @param array $color |
|
394 | - * @param float $width |
|
395 | - * @param array $style |
|
396 | - * @param bool $fill Fills the polygon if true |
|
397 | - */ |
|
398 | - function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Draws a polygon |
|
375 | + * |
|
376 | + * The polygon is formed by joining all the points stored in the $points |
|
377 | + * array. $points has the following structure: |
|
378 | + * <code> |
|
379 | + * array(0 => x1, |
|
380 | + * 1 => y1, |
|
381 | + * 2 => x2, |
|
382 | + * 3 => y2, |
|
383 | + * ... |
|
384 | + * ); |
|
385 | + * </code> |
|
386 | + * |
|
387 | + * See {@link Style::munge_color()} for the format of the color array. |
|
388 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
389 | + * parameter (aka dash) |
|
390 | + * |
|
391 | + * @param array $points |
|
392 | + * @param array $color |
|
393 | + * @param float $width |
|
394 | + * @param array $style |
|
395 | + * @param bool $fill Fills the polygon if true |
|
396 | + */ |
|
397 | + function polygon($points, $color, $width = null, $style = null, $fill = false) { |
|
399 | 398 | |
400 | 399 | // Scale each point by the AA factor |
401 | 400 | foreach (array_keys($points) as $i) |
402 | - $points[$i] *= $this->_aa_factor; |
|
401 | + $points[$i] *= $this->_aa_factor; |
|
403 | 402 | |
404 | 403 | $c = $this->_allocate_color($color); |
405 | 404 | |
406 | 405 | // Convert the style array if required |
407 | 406 | if ( !is_null($style) && !$fill ) { |
408 | - $gd_style = array(); |
|
407 | + $gd_style = array(); |
|
409 | 408 | |
410 | - foreach ($style as $length) { |
|
409 | + foreach ($style as $length) { |
|
411 | 410 | for ($i = 0; $i < $length; $i++) { |
412 | - $gd_style[] = $c; |
|
411 | + $gd_style[] = $c; |
|
412 | + } |
|
413 | 413 | } |
414 | - } |
|
415 | 414 | |
416 | - imagesetstyle($this->_img, $gd_style); |
|
417 | - $c = IMG_COLOR_STYLED; |
|
415 | + imagesetstyle($this->_img, $gd_style); |
|
416 | + $c = IMG_COLOR_STYLED; |
|
418 | 417 | } |
419 | 418 | |
420 | 419 | imagesetthickness($this->_img, $width); |
421 | 420 | |
422 | 421 | if ( $fill ) |
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
422 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | 423 | else |
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
426 | 425 | |
427 | - } |
|
428 | - |
|
429 | - /** |
|
430 | - * Draws a circle at $x,$y with radius $r |
|
431 | - * |
|
432 | - * See {@link Style::munge_color()} for the format of the color array. |
|
433 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
434 | - * parameter (aka dash) |
|
435 | - * |
|
436 | - * @param float $x |
|
437 | - * @param float $y |
|
438 | - * @param float $r |
|
439 | - * @param array $color |
|
440 | - * @param float $width |
|
441 | - * @param array $style |
|
442 | - * @param bool $fill Fills the circle if true |
|
443 | - */ |
|
444 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
426 | + } |
|
427 | + |
|
428 | + /** |
|
429 | + * Draws a circle at $x,$y with radius $r |
|
430 | + * |
|
431 | + * See {@link Style::munge_color()} for the format of the color array. |
|
432 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
433 | + * parameter (aka dash) |
|
434 | + * |
|
435 | + * @param float $x |
|
436 | + * @param float $y |
|
437 | + * @param float $r |
|
438 | + * @param array $color |
|
439 | + * @param float $width |
|
440 | + * @param array $style |
|
441 | + * @param bool $fill Fills the circle if true |
|
442 | + */ |
|
443 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) { |
|
445 | 444 | |
446 | 445 | // Scale by the AA factor |
447 | 446 | $x *= $this->_aa_factor; |
@@ -452,55 +451,55 @@ discard block |
||
452 | 451 | |
453 | 452 | // Convert the style array if required |
454 | 453 | if ( !is_null($style) && !$fill ) { |
455 | - $gd_style = array(); |
|
454 | + $gd_style = array(); |
|
456 | 455 | |
457 | - foreach ($style as $length) { |
|
456 | + foreach ($style as $length) { |
|
458 | 457 | for ($i = 0; $i < $length; $i++) { |
459 | - $gd_style[] = $c; |
|
458 | + $gd_style[] = $c; |
|
459 | + } |
|
460 | 460 | } |
461 | - } |
|
462 | 461 | |
463 | - imagesetstyle($this->_img, $gd_style); |
|
464 | - $c = IMG_COLOR_STYLED; |
|
462 | + imagesetstyle($this->_img, $gd_style); |
|
463 | + $c = IMG_COLOR_STYLED; |
|
465 | 464 | } |
466 | 465 | |
467 | 466 | imagesetthickness($this->_img, $width); |
468 | 467 | |
469 | 468 | if ( $fill ) |
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
469 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | 470 | else |
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
473 | 472 | |
474 | - } |
|
475 | - |
|
476 | - /** |
|
477 | - * Add an image to the pdf. |
|
478 | - * |
|
479 | - * The image is placed at the specified x and y coordinates with the |
|
480 | - * given width and height. |
|
481 | - * |
|
482 | - * @param string $img_url the path to the image |
|
483 | - * @param string $img_type the type (e.g. extension) of the image |
|
484 | - * @param float $x x position |
|
485 | - * @param float $y y position |
|
486 | - * @param int $w width (in pixels) |
|
487 | - * @param int $h height (in pixels) |
|
488 | - */ |
|
489 | - function image($img_url, $img_type, $x, $y, $w, $h) { |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * Add an image to the pdf. |
|
477 | + * |
|
478 | + * The image is placed at the specified x and y coordinates with the |
|
479 | + * given width and height. |
|
480 | + * |
|
481 | + * @param string $img_url the path to the image |
|
482 | + * @param string $img_type the type (e.g. extension) of the image |
|
483 | + * @param float $x x position |
|
484 | + * @param float $y y position |
|
485 | + * @param int $w width (in pixels) |
|
486 | + * @param int $h height (in pixels) |
|
487 | + */ |
|
488 | + function image($img_url, $img_type, $x, $y, $w, $h) { |
|
490 | 489 | |
491 | 490 | switch ($img_type) { |
492 | 491 | case "png": |
493 | 492 | $src = @imagecreatefrompng($img_url); |
494 | - break; |
|
493 | + break; |
|
495 | 494 | |
496 | 495 | case "gif": |
497 | 496 | $src = @imagecreatefromgif($img_url); |
498 | - break; |
|
497 | + break; |
|
499 | 498 | |
500 | 499 | case "jpg": |
501 | 500 | case "jpeg": |
502 | 501 | $src = @imagecreatefromjpeg($img_url); |
503 | - break; |
|
502 | + break; |
|
504 | 503 | |
505 | 504 | default: |
506 | 505 | break; |
@@ -508,7 +507,7 @@ discard block |
||
508 | 507 | } |
509 | 508 | |
510 | 509 | if ( !$src ) |
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
510 | + return; // Probably should add to $_dompdf_errors or whatever here |
|
512 | 511 | |
513 | 512 | // Scale by the AA factor |
514 | 513 | $x *= $this->_aa_factor; |
@@ -523,23 +522,23 @@ discard block |
||
523 | 522 | |
524 | 523 | imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h); |
525 | 524 | |
526 | - } |
|
527 | - |
|
528 | - /** |
|
529 | - * Writes text at the specified x and y coordinates |
|
530 | - * |
|
531 | - * See {@link Style::munge_color()} for the format of the color array. |
|
532 | - * |
|
533 | - * @param float $x |
|
534 | - * @param float $y |
|
535 | - * @param string $text the text to write |
|
536 | - * @param string $font the font file to use |
|
537 | - * @param float $size the font size, in points |
|
538 | - * @param array $color |
|
539 | - * @param float $adjust word spacing adjustment |
|
540 | - * @param float $angle Text angle |
|
541 | - */ |
|
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
525 | + } |
|
526 | + |
|
527 | + /** |
|
528 | + * Writes text at the specified x and y coordinates |
|
529 | + * |
|
530 | + * See {@link Style::munge_color()} for the format of the color array. |
|
531 | + * |
|
532 | + * @param float $x |
|
533 | + * @param float $y |
|
534 | + * @param string $text the text to write |
|
535 | + * @param string $font the font file to use |
|
536 | + * @param float $size the font size, in points |
|
537 | + * @param array $color |
|
538 | + * @param float $adjust word spacing adjustment |
|
539 | + * @param float $angle Text angle |
|
540 | + */ |
|
541 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
543 | 542 | |
544 | 543 | // Scale by the AA factor |
545 | 544 | $x *= $this->_aa_factor; |
@@ -551,106 +550,106 @@ discard block |
||
551 | 550 | $c = $this->_allocate_color($color); |
552 | 551 | |
553 | 552 | if ( strpos($font, '.ttf') === false ) |
554 | - $font .= ".ttf"; |
|
553 | + $font .= ".ttf"; |
|
555 | 554 | |
556 | 555 | // FIXME: word spacing |
557 | 556 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
558 | 557 | |
559 | - } |
|
558 | + } |
|
560 | 559 | |
561 | - function javascript($code) { |
|
560 | + function javascript($code) { |
|
562 | 561 | // Not implemented |
563 | - } |
|
564 | - |
|
565 | - /** |
|
566 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
567 | - * |
|
568 | - * @param string $anchorname The name of the named destination |
|
569 | - */ |
|
570 | - function add_named_dest($anchorname) { |
|
562 | + } |
|
563 | + |
|
564 | + /** |
|
565 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
566 | + * |
|
567 | + * @param string $anchorname The name of the named destination |
|
568 | + */ |
|
569 | + function add_named_dest($anchorname) { |
|
571 | 570 | // Not implemented |
572 | - } |
|
573 | - |
|
574 | - /** |
|
575 | - * Add a link to the pdf |
|
576 | - * |
|
577 | - * @param string $url The url to link to |
|
578 | - * @param float $x The x position of the link |
|
579 | - * @param float $y The y position of the link |
|
580 | - * @param float $width The width of the link |
|
581 | - * @param float $height The height of the link |
|
582 | - */ |
|
583 | - function add_link($url, $x, $y, $width, $height) { |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * Add a link to the pdf |
|
575 | + * |
|
576 | + * @param string $url The url to link to |
|
577 | + * @param float $x The x position of the link |
|
578 | + * @param float $y The y position of the link |
|
579 | + * @param float $width The width of the link |
|
580 | + * @param float $height The height of the link |
|
581 | + */ |
|
582 | + function add_link($url, $x, $y, $width, $height) { |
|
584 | 583 | // Not implemented |
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Calculates text size, in points |
|
589 | - * |
|
590 | - * @param string $text the text to be sized |
|
591 | - * @param string $font the desired font |
|
592 | - * @param float $size the desired font size |
|
593 | - * @param float $spacing word spacing, if any |
|
594 | - * @return float |
|
595 | - */ |
|
596 | - function get_text_width($text, $font, $size, $spacing = 0) { |
|
584 | + } |
|
585 | + |
|
586 | + /** |
|
587 | + * Calculates text size, in points |
|
588 | + * |
|
589 | + * @param string $text the text to be sized |
|
590 | + * @param string $font the desired font |
|
591 | + * @param float $size the desired font size |
|
592 | + * @param float $spacing word spacing, if any |
|
593 | + * @return float |
|
594 | + */ |
|
595 | + function get_text_width($text, $font, $size, $spacing = 0) { |
|
597 | 596 | |
598 | 597 | if ( strpos($font, '.ttf') === false ) |
599 | - $font .= ".ttf"; |
|
598 | + $font .= ".ttf"; |
|
600 | 599 | |
601 | 600 | // FIXME: word spacing |
602 | 601 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
603 | 602 | return $x2 - $x1; |
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Calculates font height, in points |
|
608 | - * |
|
609 | - * @param string $font |
|
610 | - * @param float $size |
|
611 | - * @return float |
|
612 | - */ |
|
613 | - function get_font_height($font, $size) { |
|
603 | + } |
|
604 | + |
|
605 | + /** |
|
606 | + * Calculates font height, in points |
|
607 | + * |
|
608 | + * @param string $font |
|
609 | + * @param float $size |
|
610 | + * @return float |
|
611 | + */ |
|
612 | + function get_font_height($font, $size) { |
|
614 | 613 | if ( strpos($font, '.ttf') === false ) |
615 | - $font .= ".ttf"; |
|
614 | + $font .= ".ttf"; |
|
616 | 615 | |
617 | 616 | // FIXME: word spacing |
618 | 617 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
619 | 618 | return $y2 - $y1; |
620 | - } |
|
619 | + } |
|
621 | 620 | |
622 | 621 | |
623 | - /** |
|
624 | - * Starts a new page |
|
625 | - * |
|
626 | - * Subsequent drawing operations will appear on the new page. |
|
627 | - */ |
|
628 | - function new_page() { |
|
622 | + /** |
|
623 | + * Starts a new page |
|
624 | + * |
|
625 | + * Subsequent drawing operations will appear on the new page. |
|
626 | + */ |
|
627 | + function new_page() { |
|
629 | 628 | // FIXME |
630 | - } |
|
629 | + } |
|
631 | 630 | |
632 | - /** |
|
633 | - * Streams the image directly to the browser |
|
634 | - * |
|
635 | - * @param string $filename the name of the image file (ignored) |
|
636 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
637 | - */ |
|
638 | - function stream($filename, $options = null) { |
|
631 | + /** |
|
632 | + * Streams the image directly to the browser |
|
633 | + * |
|
634 | + * @param string $filename the name of the image file (ignored) |
|
635 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
636 | + */ |
|
637 | + function stream($filename, $options = null) { |
|
639 | 638 | |
640 | 639 | // Perform any antialiasing |
641 | 640 | if ( $this->_aa_factor != 1 ) { |
642 | - $dst_w = $this->_width / $this->_aa_factor; |
|
643 | - $dst_h = $this->_height / $this->_aa_factor; |
|
644 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
645 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
646 | - $dst_w, $dst_h, |
|
647 | - $this->_width, $this->_height); |
|
641 | + $dst_w = $this->_width / $this->_aa_factor; |
|
642 | + $dst_h = $this->_height / $this->_aa_factor; |
|
643 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
644 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
645 | + $dst_w, $dst_h, |
|
646 | + $this->_width, $this->_height); |
|
648 | 647 | } else { |
649 | - $dst = $this->_img; |
|
648 | + $dst = $this->_img; |
|
650 | 649 | } |
651 | 650 | |
652 | 651 | if ( !isset($options["type"]) ) |
653 | - $options["type"] = "png"; |
|
652 | + $options["type"] = "png"; |
|
654 | 653 | |
655 | 654 | $type = strtolower($options["type"]); |
656 | 655 | |
@@ -663,42 +662,42 @@ discard block |
||
663 | 662 | if ( !isset($options["quality"]) ) |
664 | 663 | $options["quality"] = 75; |
665 | 664 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
665 | + header("Content-type: image/jpeg"); |
|
666 | + imagejpeg($dst, '', $options["quality"]); |
|
667 | + break; |
|
669 | 668 | |
670 | 669 | case "png": |
671 | 670 | default: |
672 | 671 | header("Content-type: image/png"); |
673 | - imagepng($dst); |
|
674 | - break; |
|
672 | + imagepng($dst); |
|
673 | + break; |
|
675 | 674 | } |
676 | 675 | |
677 | 676 | if ( $this->_aa_factor != 1 ) |
678 | - imagedestroy($dst); |
|
679 | - } |
|
677 | + imagedestroy($dst); |
|
678 | + } |
|
680 | 679 | |
681 | - /** |
|
682 | - * Returns the PNG as a string |
|
683 | - * |
|
684 | - * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
685 | - * @return string |
|
686 | - */ |
|
687 | - function output($options = null) { |
|
680 | + /** |
|
681 | + * Returns the PNG as a string |
|
682 | + * |
|
683 | + * @param array $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only) |
|
684 | + * @return string |
|
685 | + */ |
|
686 | + function output($options = null) { |
|
688 | 687 | |
689 | 688 | if ( $this->_aa_factor != 1 ) { |
690 | - $dst_w = $this->_width / $this->_aa_factor; |
|
691 | - $dst_h = $this->_height / $this->_aa_factor; |
|
692 | - $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
693 | - imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
694 | - $dst_w, $dst_h, |
|
695 | - $this->_width, $this->_height); |
|
689 | + $dst_w = $this->_width / $this->_aa_factor; |
|
690 | + $dst_h = $this->_height / $this->_aa_factor; |
|
691 | + $dst = imagecreatetruecolor($dst_w, $dst_h); |
|
692 | + imagecopyresampled($dst, $this->_img, 0, 0, 0, 0, |
|
693 | + $dst_w, $dst_h, |
|
694 | + $this->_width, $this->_height); |
|
696 | 695 | } else { |
697 | - $dst = $this->_img; |
|
696 | + $dst = $this->_img; |
|
698 | 697 | } |
699 | 698 | |
700 | 699 | if ( !isset($options["type"]) ) |
701 | - $options["type"] = "png"; |
|
700 | + $options["type"] = "png"; |
|
702 | 701 | |
703 | 702 | $type = $options["type"]; |
704 | 703 | |
@@ -711,23 +710,23 @@ discard block |
||
711 | 710 | if ( !isset($options["quality"]) ) |
712 | 711 | $options["quality"] = 75; |
713 | 712 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
713 | + imagejpeg($dst, '', $options["quality"]); |
|
714 | + break; |
|
716 | 715 | |
717 | 716 | case "png": |
718 | 717 | default: |
719 | 718 | imagepng($dst); |
720 | - break; |
|
719 | + break; |
|
721 | 720 | } |
722 | 721 | |
723 | 722 | $image = ob_get_contents(); |
724 | 723 | ob_end_clean(); |
725 | 724 | |
726 | 725 | if ( $this->_aa_factor != 1 ) |
727 | - imagedestroy($dst); |
|
726 | + imagedestroy($dst); |
|
728 | 727 | |
729 | 728 | return $image; |
730 | - } |
|
729 | + } |
|
731 | 730 | |
732 | 731 | |
733 | 732 | } |
@@ -489,21 +489,21 @@ discard block |
||
489 | 489 | function image($img_url, $img_type, $x, $y, $w, $h) { |
490 | 490 | |
491 | 491 | switch ($img_type) { |
492 | - case "png": |
|
493 | - $src = @imagecreatefrompng($img_url); |
|
494 | - break; |
|
492 | + case "png": |
|
493 | + $src = @imagecreatefrompng($img_url); |
|
494 | + break; |
|
495 | 495 | |
496 | - case "gif": |
|
497 | - $src = @imagecreatefromgif($img_url); |
|
498 | - break; |
|
496 | + case "gif": |
|
497 | + $src = @imagecreatefromgif($img_url); |
|
498 | + break; |
|
499 | 499 | |
500 | - case "jpg": |
|
501 | - case "jpeg": |
|
502 | - $src = @imagecreatefromjpeg($img_url); |
|
503 | - break; |
|
500 | + case "jpg": |
|
501 | + case "jpeg": |
|
502 | + $src = @imagecreatefromjpeg($img_url); |
|
503 | + break; |
|
504 | 504 | |
505 | - default: |
|
506 | - break; |
|
505 | + default: |
|
506 | + break; |
|
507 | 507 | |
508 | 508 | } |
509 | 509 | |
@@ -658,20 +658,20 @@ discard block |
||
658 | 658 | |
659 | 659 | switch ($type) { |
660 | 660 | |
661 | - case "jpg": |
|
662 | - case "jpeg": |
|
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
661 | + case "jpg": |
|
662 | + case "jpeg": |
|
663 | + if ( !isset($options["quality"]) ) |
|
664 | + $options["quality"] = 75; |
|
665 | 665 | |
666 | - header("Content-type: image/jpeg"); |
|
667 | - imagejpeg($dst, '', $options["quality"]); |
|
668 | - break; |
|
669 | - |
|
670 | - case "png": |
|
671 | - default: |
|
672 | - header("Content-type: image/png"); |
|
673 | - imagepng($dst); |
|
674 | - break; |
|
666 | + header("Content-type: image/jpeg"); |
|
667 | + imagejpeg($dst, '', $options["quality"]); |
|
668 | + break; |
|
669 | + |
|
670 | + case "png": |
|
671 | + default: |
|
672 | + header("Content-type: image/png"); |
|
673 | + imagepng($dst); |
|
674 | + break; |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | if ( $this->_aa_factor != 1 ) |
@@ -706,18 +706,18 @@ discard block |
||
706 | 706 | |
707 | 707 | switch ($type) { |
708 | 708 | |
709 | - case "jpg": |
|
710 | - case "jpeg": |
|
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
709 | + case "jpg": |
|
710 | + case "jpeg": |
|
711 | + if ( !isset($options["quality"]) ) |
|
712 | + $options["quality"] = 75; |
|
713 | 713 | |
714 | - imagejpeg($dst, '', $options["quality"]); |
|
715 | - break; |
|
714 | + imagejpeg($dst, '', $options["quality"]); |
|
715 | + break; |
|
716 | 716 | |
717 | - case "png": |
|
718 | - default: |
|
719 | - imagepng($dst); |
|
720 | - break; |
|
717 | + case "png": |
|
718 | + default: |
|
719 | + imagepng($dst); |
|
720 | + break; |
|
721 | 721 | } |
722 | 722 | |
723 | 723 | $image = ob_get_contents(); |
@@ -99,22 +99,22 @@ discard block |
||
99 | 99 | * @param float $aa_factor Anti-aliasing factor, 1 for no AA |
100 | 100 | * @param array $bg_color Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1 |
101 | 101 | */ |
102 | - function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) { |
|
102 | + function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1, 1, 1, 0)) { |
|
103 | 103 | |
104 | - if ( !is_array($size) ) { |
|
104 | + if (!is_array($size)) { |
|
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
106 | + if (isset(CPDF_Adapter::$PAPER_SIZES[strtolower($size)])) |
|
107 | 107 | $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
108 | 108 | else |
109 | 109 | $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
110 | 110 | |
111 | 111 | } |
112 | 112 | |
113 | - if ( strtolower($orientation) === "landscape" ) { |
|
114 | - list($size[2],$size[3]) = array($size[3],$size[2]); |
|
113 | + if (strtolower($orientation) === "landscape") { |
|
114 | + list($size[2], $size[3]) = array($size[3], $size[2]); |
|
115 | 115 | } |
116 | 116 | |
117 | - if ( $aa_factor < 1 ) |
|
117 | + if ($aa_factor < 1) |
|
118 | 118 | $aa_factor = 1; |
119 | 119 | |
120 | 120 | $this->_aa_factor = $aa_factor; |
@@ -127,9 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | $this->_img = imagecreatetruecolor($this->_width, $this->_height); |
129 | 129 | |
130 | - if ( is_null($bg_color) || !is_array($bg_color) ) { |
|
130 | + if (is_null($bg_color) || !is_array($bg_color)) { |
|
131 | 131 | // Pure white bg |
132 | - $bg_color = array(1,1,1,0); |
|
132 | + $bg_color = array(1, 1, 1, 0); |
|
133 | 133 | } |
134 | 134 | |
135 | 135 | $this->_bg_color = $this->_allocate_color($bg_color); |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | private function _allocate_color($color) { |
198 | 198 | |
199 | 199 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
200 | + if (!isset($color[3])) |
|
201 | 201 | $color[3] = 0; |
202 | 202 | |
203 | - list($r,$g,$b,$a) = $color; |
|
203 | + list($r, $g, $b, $a) = $color; |
|
204 | 204 | |
205 | 205 | $r *= 255; |
206 | 206 | $g *= 255; |
@@ -220,10 +220,10 @@ discard block |
||
220 | 220 | |
221 | 221 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 222 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
223 | + if (isset($this->_colors[$key])) |
|
224 | 224 | return $this->_colors[$key]; |
225 | 225 | |
226 | - if ( $a != 0 ) |
|
226 | + if ($a != 0) |
|
227 | 227 | $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
228 | 228 | else |
229 | 229 | $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | $c = $this->_allocate_color($color); |
260 | 260 | |
261 | 261 | // Convert the style array if required |
262 | - if ( !is_null($style) ) { |
|
262 | + if (!is_null($style)) { |
|
263 | 263 | $gd_style = array(); |
264 | 264 | |
265 | - if ( count($style) == 1 ) { |
|
265 | + if (count($style) == 1) { |
|
266 | 266 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
267 | 267 | $gd_style[] = $c; |
268 | 268 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $i = 0; |
277 | 277 | foreach ($style as $length) { |
278 | 278 | |
279 | - if ( $i % 2 == 0 ) { |
|
279 | + if ($i % 2 == 0) { |
|
280 | 280 | // 'On' pattern |
281 | 281 | for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
282 | 282 | $gd_style[] = $c; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | $c = $this->_allocate_color($color); |
328 | 328 | |
329 | 329 | // Convert the style array if required |
330 | - if ( !is_null($style) ) { |
|
330 | + if (!is_null($style)) { |
|
331 | 331 | $gd_style = array(); |
332 | 332 | |
333 | 333 | foreach ($style as $length) { |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | $c = $this->_allocate_color($color); |
405 | 405 | |
406 | 406 | // Convert the style array if required |
407 | - if ( !is_null($style) && !$fill ) { |
|
407 | + if (!is_null($style) && !$fill) { |
|
408 | 408 | $gd_style = array(); |
409 | 409 | |
410 | 410 | foreach ($style as $length) { |
@@ -419,7 +419,7 @@ discard block |
||
419 | 419 | |
420 | 420 | imagesetthickness($this->_img, $width); |
421 | 421 | |
422 | - if ( $fill ) |
|
422 | + if ($fill) |
|
423 | 423 | imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
424 | 424 | else |
425 | 425 | imagepolygon($this->_img, $points, count($points) / 2, $c); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | $c = $this->_allocate_color($color); |
452 | 452 | |
453 | 453 | // Convert the style array if required |
454 | - if ( !is_null($style) && !$fill ) { |
|
454 | + if (!is_null($style) && !$fill) { |
|
455 | 455 | $gd_style = array(); |
456 | 456 | |
457 | 457 | foreach ($style as $length) { |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | |
467 | 467 | imagesetthickness($this->_img, $width); |
468 | 468 | |
469 | - if ( $fill ) |
|
469 | + if ($fill) |
|
470 | 470 | imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
471 | 471 | else |
472 | 472 | imageellipse($this->_img, $x, $y, $r, $r, $c); |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | |
508 | 508 | } |
509 | 509 | |
510 | - if ( !$src ) |
|
510 | + if (!$src) |
|
511 | 511 | return; // Probably should add to $_dompdf_errors or whatever here |
512 | 512 | |
513 | 513 | // Scale by the AA factor |
@@ -539,7 +539,7 @@ discard block |
||
539 | 539 | * @param float $adjust word spacing adjustment |
540 | 540 | * @param float $angle Text angle |
541 | 541 | */ |
542 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) { |
|
542 | + function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) { |
|
543 | 543 | |
544 | 544 | // Scale by the AA factor |
545 | 545 | $x *= $this->_aa_factor; |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | |
551 | 551 | $c = $this->_allocate_color($color); |
552 | 552 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
553 | + if (strpos($font, '.ttf') === false) |
|
554 | 554 | $font .= ".ttf"; |
555 | 555 | |
556 | 556 | // FIXME: word spacing |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | */ |
596 | 596 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 597 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
598 | + if (strpos($font, '.ttf') === false) |
|
599 | 599 | $font .= ".ttf"; |
600 | 600 | |
601 | 601 | // FIXME: word spacing |
@@ -611,11 +611,11 @@ discard block |
||
611 | 611 | * @return float |
612 | 612 | */ |
613 | 613 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
614 | + if (strpos($font, '.ttf') === false) |
|
615 | 615 | $font .= ".ttf"; |
616 | 616 | |
617 | 617 | // FIXME: word spacing |
618 | - list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
618 | + list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
|
619 | 619 | return $y2 - $y1; |
620 | 620 | } |
621 | 621 | |
@@ -638,7 +638,7 @@ discard block |
||
638 | 638 | function stream($filename, $options = null) { |
639 | 639 | |
640 | 640 | // Perform any antialiasing |
641 | - if ( $this->_aa_factor != 1 ) { |
|
641 | + if ($this->_aa_factor != 1) { |
|
642 | 642 | $dst_w = $this->_width / $this->_aa_factor; |
643 | 643 | $dst_h = $this->_height / $this->_aa_factor; |
644 | 644 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | $dst = $this->_img; |
650 | 650 | } |
651 | 651 | |
652 | - if ( !isset($options["type"]) ) |
|
652 | + if (!isset($options["type"])) |
|
653 | 653 | $options["type"] = "png"; |
654 | 654 | |
655 | 655 | $type = strtolower($options["type"]); |
@@ -660,7 +660,7 @@ discard block |
||
660 | 660 | |
661 | 661 | case "jpg": |
662 | 662 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
663 | + if (!isset($options["quality"])) |
|
664 | 664 | $options["quality"] = 75; |
665 | 665 | |
666 | 666 | header("Content-type: image/jpeg"); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | break; |
675 | 675 | } |
676 | 676 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
677 | + if ($this->_aa_factor != 1) |
|
678 | 678 | imagedestroy($dst); |
679 | 679 | } |
680 | 680 | |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | */ |
687 | 687 | function output($options = null) { |
688 | 688 | |
689 | - if ( $this->_aa_factor != 1 ) { |
|
689 | + if ($this->_aa_factor != 1) { |
|
690 | 690 | $dst_w = $this->_width / $this->_aa_factor; |
691 | 691 | $dst_h = $this->_height / $this->_aa_factor; |
692 | 692 | $dst = imagecreatetruecolor($dst_w, $dst_h); |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | $dst = $this->_img; |
698 | 698 | } |
699 | 699 | |
700 | - if ( !isset($options["type"]) ) |
|
700 | + if (!isset($options["type"])) |
|
701 | 701 | $options["type"] = "png"; |
702 | 702 | |
703 | 703 | $type = $options["type"]; |
@@ -708,7 +708,7 @@ discard block |
||
708 | 708 | |
709 | 709 | case "jpg": |
710 | 710 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
711 | + if (!isset($options["quality"])) |
|
712 | 712 | $options["quality"] = 75; |
713 | 713 | |
714 | 714 | imagejpeg($dst, '', $options["quality"]); |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | $image = ob_get_contents(); |
724 | 724 | ob_end_clean(); |
725 | 725 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
726 | + if ($this->_aa_factor != 1) |
|
727 | 727 | imagedestroy($dst); |
728 | 728 | |
729 | 729 | return $image; |
@@ -103,10 +103,11 @@ discard block |
||
103 | 103 | |
104 | 104 | if ( !is_array($size) ) { |
105 | 105 | |
106 | - if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) |
|
107 | - $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | - else |
|
109 | - $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
106 | + if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) { |
|
107 | + $size = CPDF_Adapter::$PAPER_SIZES[$size]; |
|
108 | + } else { |
|
109 | + $size = CPDF_Adapter::$PAPER_SIZES["letter"]; |
|
110 | + } |
|
110 | 111 | |
111 | 112 | } |
112 | 113 | |
@@ -114,8 +115,9 @@ discard block |
||
114 | 115 | list($size[2],$size[3]) = array($size[3],$size[2]); |
115 | 116 | } |
116 | 117 | |
117 | - if ( $aa_factor < 1 ) |
|
118 | - $aa_factor = 1; |
|
118 | + if ( $aa_factor < 1 ) { |
|
119 | + $aa_factor = 1; |
|
120 | + } |
|
119 | 121 | |
120 | 122 | $this->_aa_factor = $aa_factor; |
121 | 123 | |
@@ -197,8 +199,9 @@ discard block |
||
197 | 199 | private function _allocate_color($color) { |
198 | 200 | |
199 | 201 | // Full opacity if no alpha set |
200 | - if ( !isset($color[3]) ) |
|
201 | - $color[3] = 0; |
|
202 | + if ( !isset($color[3]) ) { |
|
203 | + $color[3] = 0; |
|
204 | + } |
|
202 | 205 | |
203 | 206 | list($r,$g,$b,$a) = $color; |
204 | 207 | |
@@ -220,13 +223,15 @@ discard block |
||
220 | 223 | |
221 | 224 | $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a); |
222 | 225 | |
223 | - if ( isset($this->_colors[$key]) ) |
|
224 | - return $this->_colors[$key]; |
|
226 | + if ( isset($this->_colors[$key]) ) { |
|
227 | + return $this->_colors[$key]; |
|
228 | + } |
|
225 | 229 | |
226 | - if ( $a != 0 ) |
|
227 | - $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
228 | - else |
|
229 | - $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
230 | + if ( $a != 0 ) { |
|
231 | + $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a); |
|
232 | + } else { |
|
233 | + $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b); |
|
234 | + } |
|
230 | 235 | |
231 | 236 | return $this->_colors[$key]; |
232 | 237 | |
@@ -278,13 +283,15 @@ discard block |
||
278 | 283 | |
279 | 284 | if ( $i % 2 == 0 ) { |
280 | 285 | // 'On' pattern |
281 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
282 | - $gd_style[] = $c; |
|
286 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
287 | + $gd_style[] = $c; |
|
288 | + } |
|
283 | 289 | |
284 | 290 | } else { |
285 | 291 | // Off pattern |
286 | - for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) |
|
287 | - $gd_style[] = $this->_bg_color; |
|
292 | + for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) { |
|
293 | + $gd_style[] = $this->_bg_color; |
|
294 | + } |
|
288 | 295 | |
289 | 296 | } |
290 | 297 | $i++; |
@@ -398,8 +405,9 @@ discard block |
||
398 | 405 | function polygon($points, $color, $width = null, $style = null, $fill = false) { |
399 | 406 | |
400 | 407 | // Scale each point by the AA factor |
401 | - foreach (array_keys($points) as $i) |
|
402 | - $points[$i] *= $this->_aa_factor; |
|
408 | + foreach (array_keys($points) as $i) { |
|
409 | + $points[$i] *= $this->_aa_factor; |
|
410 | + } |
|
403 | 411 | |
404 | 412 | $c = $this->_allocate_color($color); |
405 | 413 | |
@@ -419,10 +427,11 @@ discard block |
||
419 | 427 | |
420 | 428 | imagesetthickness($this->_img, $width); |
421 | 429 | |
422 | - if ( $fill ) |
|
423 | - imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
424 | - else |
|
425 | - imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
430 | + if ( $fill ) { |
|
431 | + imagefilledpolygon($this->_img, $points, count($points) / 2, $c); |
|
432 | + } else { |
|
433 | + imagepolygon($this->_img, $points, count($points) / 2, $c); |
|
434 | + } |
|
426 | 435 | |
427 | 436 | } |
428 | 437 | |
@@ -466,10 +475,11 @@ discard block |
||
466 | 475 | |
467 | 476 | imagesetthickness($this->_img, $width); |
468 | 477 | |
469 | - if ( $fill ) |
|
470 | - imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
471 | - else |
|
472 | - imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
478 | + if ( $fill ) { |
|
479 | + imagefilledellipse($this->_img, $x, $y, $r, $r, $c); |
|
480 | + } else { |
|
481 | + imageellipse($this->_img, $x, $y, $r, $r, $c); |
|
482 | + } |
|
473 | 483 | |
474 | 484 | } |
475 | 485 | |
@@ -507,8 +517,10 @@ discard block |
||
507 | 517 | |
508 | 518 | } |
509 | 519 | |
510 | - if ( !$src ) |
|
511 | - return; // Probably should add to $_dompdf_errors or whatever here |
|
520 | + if ( !$src ) { |
|
521 | + return; |
|
522 | + } |
|
523 | + // Probably should add to $_dompdf_errors or whatever here |
|
512 | 524 | |
513 | 525 | // Scale by the AA factor |
514 | 526 | $x *= $this->_aa_factor; |
@@ -550,8 +562,9 @@ discard block |
||
550 | 562 | |
551 | 563 | $c = $this->_allocate_color($color); |
552 | 564 | |
553 | - if ( strpos($font, '.ttf') === false ) |
|
554 | - $font .= ".ttf"; |
|
565 | + if ( strpos($font, '.ttf') === false ) { |
|
566 | + $font .= ".ttf"; |
|
567 | + } |
|
555 | 568 | |
556 | 569 | // FIXME: word spacing |
557 | 570 | imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text); |
@@ -595,8 +608,9 @@ discard block |
||
595 | 608 | */ |
596 | 609 | function get_text_width($text, $font, $size, $spacing = 0) { |
597 | 610 | |
598 | - if ( strpos($font, '.ttf') === false ) |
|
599 | - $font .= ".ttf"; |
|
611 | + if ( strpos($font, '.ttf') === false ) { |
|
612 | + $font .= ".ttf"; |
|
613 | + } |
|
600 | 614 | |
601 | 615 | // FIXME: word spacing |
602 | 616 | list($x1,,$x2) = imagettfbbox($size, 0, $font, $text); |
@@ -611,8 +625,9 @@ discard block |
||
611 | 625 | * @return float |
612 | 626 | */ |
613 | 627 | function get_font_height($font, $size) { |
614 | - if ( strpos($font, '.ttf') === false ) |
|
615 | - $font .= ".ttf"; |
|
628 | + if ( strpos($font, '.ttf') === false ) { |
|
629 | + $font .= ".ttf"; |
|
630 | + } |
|
616 | 631 | |
617 | 632 | // FIXME: word spacing |
618 | 633 | list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps |
@@ -649,8 +664,9 @@ discard block |
||
649 | 664 | $dst = $this->_img; |
650 | 665 | } |
651 | 666 | |
652 | - if ( !isset($options["type"]) ) |
|
653 | - $options["type"] = "png"; |
|
667 | + if ( !isset($options["type"]) ) { |
|
668 | + $options["type"] = "png"; |
|
669 | + } |
|
654 | 670 | |
655 | 671 | $type = strtolower($options["type"]); |
656 | 672 | |
@@ -660,8 +676,9 @@ discard block |
||
660 | 676 | |
661 | 677 | case "jpg": |
662 | 678 | case "jpeg": |
663 | - if ( !isset($options["quality"]) ) |
|
664 | - $options["quality"] = 75; |
|
679 | + if ( !isset($options["quality"]) ) { |
|
680 | + $options["quality"] = 75; |
|
681 | + } |
|
665 | 682 | |
666 | 683 | header("Content-type: image/jpeg"); |
667 | 684 | imagejpeg($dst, '', $options["quality"]); |
@@ -674,8 +691,9 @@ discard block |
||
674 | 691 | break; |
675 | 692 | } |
676 | 693 | |
677 | - if ( $this->_aa_factor != 1 ) |
|
678 | - imagedestroy($dst); |
|
694 | + if ( $this->_aa_factor != 1 ) { |
|
695 | + imagedestroy($dst); |
|
696 | + } |
|
679 | 697 | } |
680 | 698 | |
681 | 699 | /** |
@@ -697,8 +715,9 @@ discard block |
||
697 | 715 | $dst = $this->_img; |
698 | 716 | } |
699 | 717 | |
700 | - if ( !isset($options["type"]) ) |
|
701 | - $options["type"] = "png"; |
|
718 | + if ( !isset($options["type"]) ) { |
|
719 | + $options["type"] = "png"; |
|
720 | + } |
|
702 | 721 | |
703 | 722 | $type = $options["type"]; |
704 | 723 | |
@@ -708,8 +727,9 @@ discard block |
||
708 | 727 | |
709 | 728 | case "jpg": |
710 | 729 | case "jpeg": |
711 | - if ( !isset($options["quality"]) ) |
|
712 | - $options["quality"] = 75; |
|
730 | + if ( !isset($options["quality"]) ) { |
|
731 | + $options["quality"] = 75; |
|
732 | + } |
|
713 | 733 | |
714 | 734 | imagejpeg($dst, '', $options["quality"]); |
715 | 735 | break; |
@@ -723,8 +743,9 @@ discard block |
||
723 | 743 | $image = ob_get_contents(); |
724 | 744 | ob_end_clean(); |
725 | 745 | |
726 | - if ( $this->_aa_factor != 1 ) |
|
727 | - imagedestroy($dst); |
|
746 | + if ( $this->_aa_factor != 1 ) { |
|
747 | + imagedestroy($dst); |
|
748 | + } |
|
728 | 749 | |
729 | 750 | return $image; |
730 | 751 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | /** |
110 | 110 | * Return the bullet's width |
111 | 111 | * |
112 | - * @return int |
|
112 | + * @return double |
|
113 | 113 | */ |
114 | 114 | function get_width() { |
115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | /** |
160 | 160 | * Override get_margin_height() |
161 | 161 | * |
162 | - * @return int |
|
162 | + * @return double |
|
163 | 163 | */ |
164 | 164 | function get_margin_height() { |
165 | 165 | //Hits only on "inset" lists items, to increase height of box |
@@ -52,34 +52,34 @@ discard block |
||
52 | 52 | */ |
53 | 53 | class List_Bullet_Image_Frame_Decorator extends Frame_Decorator { |
54 | 54 | |
55 | - /** |
|
56 | - * The underlying image frame |
|
57 | - * |
|
58 | - * @var Image_Frame_Decorator |
|
59 | - */ |
|
60 | - protected $_img; |
|
55 | + /** |
|
56 | + * The underlying image frame |
|
57 | + * |
|
58 | + * @var Image_Frame_Decorator |
|
59 | + */ |
|
60 | + protected $_img; |
|
61 | 61 | |
62 | - /** |
|
63 | - * The image's width in pixels |
|
64 | - * |
|
65 | - * @var int |
|
66 | - */ |
|
67 | - protected $_width; |
|
62 | + /** |
|
63 | + * The image's width in pixels |
|
64 | + * |
|
65 | + * @var int |
|
66 | + */ |
|
67 | + protected $_width; |
|
68 | 68 | |
69 | - /** |
|
70 | - * The image's height in pixels |
|
71 | - * |
|
72 | - * @var int |
|
73 | - */ |
|
74 | - protected $_height; |
|
69 | + /** |
|
70 | + * The image's height in pixels |
|
71 | + * |
|
72 | + * @var int |
|
73 | + */ |
|
74 | + protected $_height; |
|
75 | 75 | |
76 | - /** |
|
77 | - * Class constructor |
|
78 | - * |
|
79 | - * @param Frame $frame the bullet frame to decorate |
|
80 | - * @param DOMPDF $dompdf the document's dompdf object |
|
81 | - */ |
|
82 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
76 | + /** |
|
77 | + * Class constructor |
|
78 | + * |
|
79 | + * @param Frame $frame the bullet frame to decorate |
|
80 | + * @param DOMPDF $dompdf the document's dompdf object |
|
81 | + */ |
|
82 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
83 | 83 | $style = $frame->get_style(); |
84 | 84 | $url = $style->list_style_image; |
85 | 85 | $frame->get_node()->setAttribute("src", $url); |
@@ -104,38 +104,38 @@ discard block |
||
104 | 104 | // $style->min_height = $this->_height; |
105 | 105 | //} |
106 | 106 | //$style->height = "auto"; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Return the bullet's width |
|
111 | - * |
|
112 | - * @return int |
|
113 | - */ |
|
114 | - function get_width() { |
|
109 | + /** |
|
110 | + * Return the bullet's width |
|
111 | + * |
|
112 | + * @return int |
|
113 | + */ |
|
114 | + function get_width() { |
|
115 | 115 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
117 | 117 | //This controls the distance between bullet image and text |
118 | 118 | //return $this->_width; |
119 | 119 | return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
121 | - } |
|
121 | + } |
|
122 | 122 | |
123 | - /** |
|
124 | - * Return the bullet's height |
|
125 | - * |
|
126 | - * @return int |
|
127 | - */ |
|
128 | - function get_height() { |
|
123 | + /** |
|
124 | + * Return the bullet's height |
|
125 | + * |
|
126 | + * @return int |
|
127 | + */ |
|
128 | + function get_height() { |
|
129 | 129 | //based on image height |
130 | 130 | return $this->_height; |
131 | - } |
|
131 | + } |
|
132 | 132 | |
133 | - /** |
|
134 | - * Override get_margin_width |
|
135 | - * |
|
136 | - * @return int |
|
137 | - */ |
|
138 | - function get_margin_width() { |
|
133 | + /** |
|
134 | + * Override get_margin_width |
|
135 | + * |
|
136 | + * @return int |
|
137 | + */ |
|
138 | + function get_margin_width() { |
|
139 | 139 | //ignore image width, use same width as on predefined bullet List_Bullet_Frame_Decorator |
140 | 140 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
141 | 141 | //This controls the extra indentation of text to make room for the bullet image. |
@@ -147,42 +147,42 @@ discard block |
||
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
149 | 149 | $this->_width == 0) |
150 | - return 0; |
|
150 | + return 0; |
|
151 | 151 | //This aligns the "inside" image position with the text. |
152 | 152 | //The text starts to the right of the image. |
153 | 153 | //Between the image and the text there is an added margin of image width. |
154 | 154 | //Where this comes from is unknown. |
155 | 155 | //The corresponding List_Bullet_Frame_Decorator sets a smaller margin. bullet size? |
156 | 156 | return $this->_width + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
157 | - } |
|
157 | + } |
|
158 | 158 | |
159 | - /** |
|
160 | - * Override get_margin_height() |
|
161 | - * |
|
162 | - * @return int |
|
163 | - */ |
|
164 | - function get_margin_height() { |
|
159 | + /** |
|
160 | + * Override get_margin_height() |
|
161 | + * |
|
162 | + * @return int |
|
163 | + */ |
|
164 | + function get_margin_height() { |
|
165 | 165 | //Hits only on "inset" lists items, to increase height of box |
166 | 166 | //based on image height |
167 | 167 | return $this->_height + 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
168 | - } |
|
168 | + } |
|
169 | 169 | |
170 | - /** |
|
171 | - * Return image url |
|
172 | - * |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - function get_image_url() { |
|
170 | + /** |
|
171 | + * Return image url |
|
172 | + * |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + function get_image_url() { |
|
176 | 176 | return $this->_img->get_image_url(); |
177 | - } |
|
177 | + } |
|
178 | 178 | |
179 | - /** |
|
180 | - * Return the image extension |
|
181 | - * |
|
182 | - * @return string |
|
183 | - */ |
|
184 | - function get_image_ext() { |
|
179 | + /** |
|
180 | + * Return the image extension |
|
181 | + * |
|
182 | + * @return string |
|
183 | + */ |
|
184 | + function get_image_ext() { |
|
185 | 185 | return $this->_img->get_image_ext(); |
186 | - } |
|
186 | + } |
|
187 | 187 | |
188 | 188 | } |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | // Resample the bullet image to be consistent with 'auto' sized images |
91 | 91 | // See also Image_Frame_Reflower::get_min_max_width |
92 | 92 | // Tested php ver: value measured in px, suffix "px" not in value: rtrim unnecessary. |
93 | - $this->_width = (((float)rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | - $this->_height = (((float)rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
93 | + $this->_width = (((float) rtrim($width, "px")) * 72) / DOMPDF_DPI; |
|
94 | + $this->_height = (((float) rtrim($height, "px")) * 72) / DOMPDF_DPI; |
|
95 | 95 | |
96 | 96 | //If an image is taller as the containing block/box, the box should be extended. |
97 | 97 | //Neighbour elements are overwriting the overlapping image areas. |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | //for proper alignment of bullet image and text. Allow image to not fitting on left border. |
117 | 117 | //This controls the distance between bullet image and text |
118 | 118 | //return $this->_width; |
119 | - return $this->_frame->get_style()->get_font_size()*List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
119 | + return $this->_frame->get_style()->get_font_size() * List_Bullet_Frame_Decorator::BULLET_SIZE + |
|
120 | 120 | 2 * List_Bullet_Frame_Decorator::BULLET_PADDING; |
121 | 121 | } |
122 | 122 | |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | |
146 | 146 | // Small hack to prevent indenting of list text |
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | - if ( $this->_frame->get_style()->list_style_position === "outside" || |
|
148 | + if ($this->_frame->get_style()->list_style_position === "outside" || |
|
149 | 149 | $this->_width == 0) |
150 | 150 | return 0; |
151 | 151 | //This aligns the "inside" image position with the text. |
@@ -146,8 +146,9 @@ |
||
146 | 146 | // Small hack to prevent indenting of list text |
147 | 147 | // Image Might not exist, then position like on list_bullet_frame_decorator fallback to none. |
148 | 148 | if ( $this->_frame->get_style()->list_style_position === "outside" || |
149 | - $this->_width == 0) |
|
150 | - return 0; |
|
149 | + $this->_width == 0) { |
|
150 | + return 0; |
|
151 | + } |
|
151 | 152 | //This aligns the "inside" image position with the text. |
152 | 153 | //The text starts to the right of the image. |
153 | 154 | //Between the image and the text there is an added margin of image width. |
@@ -70,12 +70,19 @@ |
||
70 | 70 | |
71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 72 | |
73 | + /** |
|
74 | + * @param string $sql |
|
75 | + */ |
|
73 | 76 | private static function __query($sql) { |
74 | 77 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
75 | 78 | throw new Exception(pg_last_error(self::$__connection)); |
76 | 79 | return $res; |
77 | 80 | } |
78 | 81 | |
82 | + /** |
|
83 | + * @param integer $page_num |
|
84 | + * @param string|null $data |
|
85 | + */ |
|
79 | 86 | static function store_page($id, $page_num, $data) { |
80 | 87 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
81 | 88 | "page_num=". pg_escape_string($page_num); |
@@ -57,13 +57,13 @@ discard block |
||
57 | 57 | static private $__connection = null; |
58 | 58 | |
59 | 59 | function init() { |
60 | - if ( is_null(self::$__connection) ) { |
|
61 | - $con_str = "host=" . DB_HOST . |
|
62 | - " dbname=" . self::DB_NAME . |
|
63 | - " user=" . self::DB_USER . |
|
64 | - " password=" . self::DB_PASS; |
|
60 | + if (is_null(self::$__connection)) { |
|
61 | + $con_str = "host=".DB_HOST. |
|
62 | + " dbname=".self::DB_NAME. |
|
63 | + " user=".self::DB_USER. |
|
64 | + " password=".self::DB_PASS; |
|
65 | 65 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
66 | + if (!self::$__connection = pg_connect($con_str)) |
|
67 | 67 | throw new Exception("Database connection failed."); |
68 | 68 | } |
69 | 69 | } |
@@ -71,36 +71,36 @@ discard block |
||
71 | 71 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 72 | |
73 | 73 | private static function __query($sql) { |
74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
74 | + if (!($res = pg_query(self::$__connection, $sql))) |
|
75 | 75 | throw new Exception(pg_last_error(self::$__connection)); |
76 | 76 | return $res; |
77 | 77 | } |
78 | 78 | |
79 | 79 | static function store_page($id, $page_num, $data) { |
80 | - $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
|
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + $where = "WHERE id='".pg_escape_string($id)."' AND ". |
|
81 | + "page_num=".pg_escape_string($page_num); |
|
82 | 82 | |
83 | - $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
|
83 | + $res = self::__query("SELECT timestamp FROM page_cache ".$where); |
|
84 | 84 | |
85 | 85 | $row = pg_fetch_assoc($res); |
86 | 86 | |
87 | - if ( $row ) |
|
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + if ($row) |
|
88 | + self::__query("UPDATE page_cache SET data='".pg_escape_string($data)."' ".$where); |
|
89 | 89 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
90 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('".pg_escape_string($id)."', ". |
|
91 | + pg_escape_string($page_num).", ". |
|
92 | + "'".pg_escape_string($data)."')"); |
|
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | 96 | static function store_fonts($id, $fonts) { |
97 | 97 | self::__query("BEGIN"); |
98 | 98 | // Update the font information |
99 | - self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
99 | + self::__query("DELETE FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
100 | 100 | |
101 | 101 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | - pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
|
102 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('". |
|
103 | + pg_escape_string($id)."', '".pg_escape_string($font)."')"); |
|
104 | 104 | self::__query("COMMIT"); |
105 | 105 | } |
106 | 106 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | // } |
117 | 117 | |
118 | 118 | static function get_page_timestamp($id, $page_num) { |
119 | - $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
|
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + $res = self::__query("SELECT timestamp FROM page_cache WHERE id='".pg_escape_string($id)."' AND ". |
|
120 | + "page_num=".pg_escape_string($page_num)); |
|
121 | 121 | |
122 | 122 | $row = pg_fetch_assoc($res); |
123 | 123 | |
@@ -127,22 +127,22 @@ discard block |
||
127 | 127 | |
128 | 128 | // Adds the cached document referenced by $id to the provided pdf |
129 | 129 | static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
130 | - $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
|
130 | + $res = self::__query("SELECT font_name FROM page_fonts WHERE id='".pg_escape_string($id)."'"); |
|
131 | 131 | |
132 | 132 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 133 | // the pdf |
134 | 134 | while ($row = pg_fetch_assoc($res)) |
135 | 135 | $pdf->get_cpdf()->selectFont($row["font_name"]); |
136 | 136 | |
137 | - $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
|
137 | + $res = self::__query("SELECT data FROM page_cache WHERE id='".pg_escape_string($id)."'"); |
|
138 | 138 | |
139 | - if ( $new_page ) |
|
139 | + if ($new_page) |
|
140 | 140 | $pdf->new_page(); |
141 | 141 | |
142 | 142 | $first = true; |
143 | 143 | while ($row = pg_fetch_assoc($res)) { |
144 | 144 | |
145 | - if ( !$first ) |
|
145 | + if (!$first) |
|
146 | 146 | $pdf->new_page(); |
147 | 147 | else |
148 | 148 | $first = false; |
@@ -63,16 +63,18 @@ discard block |
||
63 | 63 | " user=" . self::DB_USER . |
64 | 64 | " password=" . self::DB_PASS; |
65 | 65 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
67 | - throw new Exception("Database connection failed."); |
|
66 | + if ( !self::$__connection = pg_connect($con_str) ) { |
|
67 | + throw new Exception("Database connection failed."); |
|
68 | + } |
|
68 | 69 | } |
69 | 70 | } |
70 | 71 | |
71 | 72 | function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
72 | 73 | |
73 | 74 | private static function __query($sql) { |
74 | - if ( !($res = pg_query(self::$__connection, $sql)) ) |
|
75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
75 | + if ( !($res = pg_query(self::$__connection, $sql)) ) { |
|
76 | + throw new Exception(pg_last_error(self::$__connection)); |
|
77 | + } |
|
76 | 78 | return $res; |
77 | 79 | } |
78 | 80 | |
@@ -84,12 +86,13 @@ discard block |
||
84 | 86 | |
85 | 87 | $row = pg_fetch_assoc($res); |
86 | 88 | |
87 | - if ( $row ) |
|
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
89 | - else |
|
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
89 | + if ( $row ) { |
|
90 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
91 | + } else { |
|
92 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | 93 | pg_escape_string($page_num) . ", ". |
92 | 94 | "'". pg_escape_string($data) . "')"); |
95 | + } |
|
93 | 96 | |
94 | 97 | } |
95 | 98 | |
@@ -98,9 +101,10 @@ discard block |
||
98 | 101 | // Update the font information |
99 | 102 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
100 | 103 | |
101 | - foreach (array_keys($fonts) as $font) |
|
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
104 | + foreach (array_keys($fonts) as $font) { |
|
105 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | 106 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
107 | + } |
|
104 | 108 | self::__query("COMMIT"); |
105 | 109 | } |
106 | 110 | |
@@ -131,21 +135,24 @@ discard block |
||
131 | 135 | |
132 | 136 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 137 | // the pdf |
134 | - while ($row = pg_fetch_assoc($res)) |
|
135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
138 | + while ($row = pg_fetch_assoc($res)) { |
|
139 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
140 | + } |
|
136 | 141 | |
137 | 142 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
138 | 143 | |
139 | - if ( $new_page ) |
|
140 | - $pdf->new_page(); |
|
144 | + if ( $new_page ) { |
|
145 | + $pdf->new_page(); |
|
146 | + } |
|
141 | 147 | |
142 | 148 | $first = true; |
143 | 149 | while ($row = pg_fetch_assoc($res)) { |
144 | 150 | |
145 | - if ( !$first ) |
|
146 | - $pdf->new_page(); |
|
147 | - else |
|
148 | - $first = false; |
|
151 | + if ( !$first ) { |
|
152 | + $pdf->new_page(); |
|
153 | + } else { |
|
154 | + $first = false; |
|
155 | + } |
|
149 | 156 | |
150 | 157 | $page = $pdf->reopen_serialized_object($row["data"]); |
151 | 158 | //$pdf->close_object(); |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: page_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -50,59 +49,59 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Page_Cache { |
52 | 51 | |
53 | - const DB_USER = "dompdf_page_cache"; |
|
54 | - const DB_PASS = "some meaningful password"; |
|
55 | - const DB_NAME = "dompdf_page_cache"; |
|
52 | + const DB_USER = "dompdf_page_cache"; |
|
53 | + const DB_PASS = "some meaningful password"; |
|
54 | + const DB_NAME = "dompdf_page_cache"; |
|
56 | 55 | |
57 | - static private $__connection = null; |
|
56 | + static private $__connection = null; |
|
58 | 57 | |
59 | - function init() { |
|
58 | + function init() { |
|
60 | 59 | if ( is_null(self::$__connection) ) { |
61 | - $con_str = "host=" . DB_HOST . |
|
60 | + $con_str = "host=" . DB_HOST . |
|
62 | 61 | " dbname=" . self::DB_NAME . |
63 | 62 | " user=" . self::DB_USER . |
64 | 63 | " password=" . self::DB_PASS; |
65 | 64 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
65 | + if ( !self::$__connection = pg_connect($con_str) ) |
|
67 | 66 | throw new Exception("Database connection failed."); |
68 | 67 | } |
69 | - } |
|
68 | + } |
|
70 | 69 | |
71 | - function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
70 | + function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
72 | 71 | |
73 | - private static function __query($sql) { |
|
72 | + private static function __query($sql) { |
|
74 | 73 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
74 | + throw new Exception(pg_last_error(self::$__connection)); |
|
76 | 75 | return $res; |
77 | - } |
|
76 | + } |
|
78 | 77 | |
79 | - static function store_page($id, $page_num, $data) { |
|
78 | + static function store_page($id, $page_num, $data) { |
|
80 | 79 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + "page_num=". pg_escape_string($page_num); |
|
82 | 81 | |
83 | 82 | $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
84 | 83 | |
85 | 84 | $row = pg_fetch_assoc($res); |
86 | 85 | |
87 | 86 | if ( $row ) |
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
89 | 88 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
89 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
90 | + pg_escape_string($page_num) . ", ". |
|
91 | + "'". pg_escape_string($data) . "')"); |
|
93 | 92 | |
94 | - } |
|
93 | + } |
|
95 | 94 | |
96 | - static function store_fonts($id, $fonts) { |
|
95 | + static function store_fonts($id, $fonts) { |
|
97 | 96 | self::__query("BEGIN"); |
98 | 97 | // Update the font information |
99 | 98 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
100 | 99 | |
101 | 100 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
101 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | 102 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
104 | 103 | self::__query("COMMIT"); |
105 | - } |
|
104 | + } |
|
106 | 105 | |
107 | 106 | // static function retrieve_page($id, $page_num) { |
108 | 107 | |
@@ -115,45 +114,45 @@ discard block |
||
115 | 114 | |
116 | 115 | // } |
117 | 116 | |
118 | - static function get_page_timestamp($id, $page_num) { |
|
117 | + static function get_page_timestamp($id, $page_num) { |
|
119 | 118 | $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + "page_num=". pg_escape_string($page_num)); |
|
121 | 120 | |
122 | 121 | $row = pg_fetch_assoc($res); |
123 | 122 | |
124 | 123 | return $row["timestamp"]; |
125 | 124 | |
126 | - } |
|
125 | + } |
|
127 | 126 | |
128 | - // Adds the cached document referenced by $id to the provided pdf |
|
129 | - static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
127 | + // Adds the cached document referenced by $id to the provided pdf |
|
128 | + static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
130 | 129 | $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
131 | 130 | |
132 | 131 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 132 | // the pdf |
134 | 133 | while ($row = pg_fetch_assoc($res)) |
135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
134 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
136 | 135 | |
137 | 136 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
138 | 137 | |
139 | 138 | if ( $new_page ) |
140 | - $pdf->new_page(); |
|
139 | + $pdf->new_page(); |
|
141 | 140 | |
142 | 141 | $first = true; |
143 | 142 | while ($row = pg_fetch_assoc($res)) { |
144 | 143 | |
145 | - if ( !$first ) |
|
144 | + if ( !$first ) |
|
146 | 145 | $pdf->new_page(); |
147 | - else |
|
146 | + else |
|
148 | 147 | $first = false; |
149 | 148 | |
150 | - $page = $pdf->reopen_serialized_object($row["data"]); |
|
151 | - //$pdf->close_object(); |
|
152 | - $pdf->add_object($page, "add"); |
|
149 | + $page = $pdf->reopen_serialized_object($row["data"]); |
|
150 | + //$pdf->close_object(); |
|
151 | + $pdf->add_object($page, "add"); |
|
153 | 152 | |
154 | 153 | } |
155 | 154 | |
156 | - } |
|
155 | + } |
|
157 | 156 | } |
158 | 157 | |
159 | 158 | Page_Cache::init(); |