@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | require_once("../dompdf_config.inc.php"); |
4 | 4 | if ( isset( $_POST["html"] ) ) { |
5 | 5 | |
6 | - if ( get_magic_quotes_gpc() ) |
|
6 | + if ( get_magic_quotes_gpc() ) |
|
7 | 7 | $_POST["html"] = stripslashes($_POST["html"]); |
8 | 8 | |
9 | - $dompdf = new DOMPDF(); |
|
10 | - $dompdf->load_html($_POST["html"]); |
|
11 | - $dompdf->set_paper($_POST["paper"], $_POST["orientation"]); |
|
12 | - $dompdf->render(); |
|
9 | + $dompdf = new DOMPDF(); |
|
10 | + $dompdf->load_html($_POST["html"]); |
|
11 | + $dompdf->set_paper($_POST["paper"], $_POST["orientation"]); |
|
12 | + $dompdf->render(); |
|
13 | 13 | |
14 | - $dompdf->stream("dompdf_out.pdf"); |
|
14 | + $dompdf->stream("dompdf_out.pdf"); |
|
15 | 15 | |
16 | - exit(0); |
|
16 | + exit(0); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | ?> |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | $dompdf = dirname(dirname($_SERVER["PHP_SELF"])); |
43 | 43 | //echo '<li>['.$dompdf.']</li>'; |
44 | 44 | if ( $dompdf == '/' || $dompdf == '\\') { |
45 | - $dompdf = ''; |
|
45 | + $dompdf = ''; |
|
46 | 46 | } |
47 | 47 | //echo '<li>['.$dompdf.']</li>'; |
48 | 48 | $dompdf .= "/dompdf.php?base_path=" . rawurlencode("www/test/"); |
49 | 49 | //echo '<li>['.$dompdf.']</li>'; |
50 | 50 | foreach ( $test_files as $file ) { |
51 | - $file = basename($file); |
|
52 | - $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; |
|
53 | - echo "<li style=\"list-style-image: url('$arrow');\">\n"; |
|
54 | - echo $file; |
|
55 | - echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("$file") . "\">PDF</a>]\n"; |
|
56 | - echo "</li>\n"; |
|
51 | + $file = basename($file); |
|
52 | + $arrow = "images/arrow_0" . rand(1, 6) . ".gif"; |
|
53 | + echo "<li style=\"list-style-image: url('$arrow');\">\n"; |
|
54 | + echo $file; |
|
55 | + echo " [<a class=\"button\" target=\"blank\" href=\"test/$file\">HTML</a>] [<a class=\"button\" href=\"$dompdf&input_file=" . rawurlencode("$file") . "\">PDF</a>]\n"; |
|
56 | + echo "</li>\n"; |
|
57 | 57 | } |
58 | 58 | ?> |
59 | 59 | </ul> |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | <select name="paper"> |
70 | 70 | <?php |
71 | 71 | foreach ( array_keys(CPDF_Adapter::$PAPER_SIZES) as $size ) |
72 | - echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n"; |
|
72 | + echo "<option ". ($size == "letter" ? "selected " : "" ) . "value=\"$size\">$size</option>\n"; |
|
73 | 73 | ?> |
74 | 74 | </select> |
75 | 75 | <select name="orientation"> |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | function li_arrow() { |
3 | - return '<li style="list-style-image: url(\'images/arrow_0' . rand(1,6) . '.gif\');">'; |
|
3 | + return '<li style="list-style-image: url(\'images/arrow_0' . rand(1,6) . '.gif\');">'; |
|
4 | 4 | } |
5 | 5 | function li_star() { |
6 | - return '<li style="list-style-image: url(\'images/star_0' . rand(1,5) . '.gif\');">'; |
|
6 | + return '<li style="list-style-image: url(\'images/star_0' . rand(1,5) . '.gif\');">'; |
|
7 | 7 | } |
8 | 8 | ?> |
9 | 9 | <?php echo '<?' . 'xml version="1.0" encoding="iso-8859-1"?' . '>'; ?> |
@@ -52,28 +52,28 @@ discard block |
||
52 | 52 | */ |
53 | 53 | class Image_Frame_Decorator extends Frame_Decorator { |
54 | 54 | |
55 | - /** |
|
56 | - * The path to the image file (note that remote images are |
|
57 | - * downloaded locally to DOMPDF_TEMP_DIR). |
|
58 | - * |
|
59 | - * @var string |
|
60 | - */ |
|
61 | - protected $_image_url; |
|
55 | + /** |
|
56 | + * The path to the image file (note that remote images are |
|
57 | + * downloaded locally to DOMPDF_TEMP_DIR). |
|
58 | + * |
|
59 | + * @var string |
|
60 | + */ |
|
61 | + protected $_image_url; |
|
62 | 62 | |
63 | - /** |
|
64 | - * The image's file extension (i.e. png, jpeg, gif) |
|
65 | - * |
|
66 | - * @var string |
|
67 | - */ |
|
68 | - protected $_image_ext; |
|
63 | + /** |
|
64 | + * The image's file extension (i.e. png, jpeg, gif) |
|
65 | + * |
|
66 | + * @var string |
|
67 | + */ |
|
68 | + protected $_image_ext; |
|
69 | 69 | |
70 | - /** |
|
71 | - * Class constructor |
|
72 | - * |
|
73 | - * @param Frame $frame the frame to decorate |
|
74 | - * @param DOMPDF $dompdf the document's dompdf object (required to resolve relative & remote urls) |
|
75 | - */ |
|
76 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
70 | + /** |
|
71 | + * Class constructor |
|
72 | + * |
|
73 | + * @param Frame $frame the frame to decorate |
|
74 | + * @param DOMPDF $dompdf the document's dompdf object (required to resolve relative & remote urls) |
|
75 | + */ |
|
76 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
77 | 77 | global $_dompdf_warnings; |
78 | 78 | |
79 | 79 | parent::__construct($frame, $dompdf); |
@@ -83,28 +83,28 @@ discard block |
||
83 | 83 | if (DEBUGPNG) print '[__construct '.$url.']'; |
84 | 84 | |
85 | 85 | list($this->_image_url, $this->_image_ext) = Image_Cache::resolve_url($url, |
86 | - $dompdf->get_protocol(), |
|
87 | - $dompdf->get_host(), |
|
88 | - $dompdf->get_base_path()); |
|
86 | + $dompdf->get_protocol(), |
|
87 | + $dompdf->get_host(), |
|
88 | + $dompdf->get_base_path()); |
|
89 | 89 | |
90 | - } |
|
90 | + } |
|
91 | 91 | |
92 | - /** |
|
93 | - * Return the image's url |
|
94 | - * |
|
95 | - * @return string The url of this image |
|
96 | - */ |
|
97 | - function get_image_url() { |
|
92 | + /** |
|
93 | + * Return the image's url |
|
94 | + * |
|
95 | + * @return string The url of this image |
|
96 | + */ |
|
97 | + function get_image_url() { |
|
98 | 98 | return $this->_image_url; |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | - /** |
|
102 | - * Return the image's file extension |
|
103 | - * |
|
104 | - * @return string The image's file extension |
|
105 | - */ |
|
106 | - function get_image_ext() { |
|
101 | + /** |
|
102 | + * Return the image's file extension |
|
103 | + * |
|
104 | + * @return string The image's file extension |
|
105 | + */ |
|
106 | + function get_image_ext() { |
|
107 | 107 | return $this->_image_ext; |
108 | - } |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
@@ -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 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: page_cache.cls.php,v $ |
|
6 | - * Created on: 2004-07-23 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: page_cache.cls.php,v $ |
|
6 | + * Created on: 2004-07-23 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: page_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -50,59 +49,59 @@ discard block |
||
50 | 49 | */ |
51 | 50 | class Page_Cache { |
52 | 51 | |
53 | - const DB_USER = "dompdf_page_cache"; |
|
54 | - const DB_PASS = "some meaningful password"; |
|
55 | - const DB_NAME = "dompdf_page_cache"; |
|
52 | + const DB_USER = "dompdf_page_cache"; |
|
53 | + const DB_PASS = "some meaningful password"; |
|
54 | + const DB_NAME = "dompdf_page_cache"; |
|
56 | 55 | |
57 | - static private $__connection = null; |
|
56 | + static private $__connection = null; |
|
58 | 57 | |
59 | - function init() { |
|
58 | + function init() { |
|
60 | 59 | if ( is_null(self::$__connection) ) { |
61 | - $con_str = "host=" . DB_HOST . |
|
60 | + $con_str = "host=" . DB_HOST . |
|
62 | 61 | " dbname=" . self::DB_NAME . |
63 | 62 | " user=" . self::DB_USER . |
64 | 63 | " password=" . self::DB_PASS; |
65 | 64 | |
66 | - if ( !self::$__connection = pg_connect($con_str) ) |
|
65 | + if ( !self::$__connection = pg_connect($con_str) ) |
|
67 | 66 | throw new Exception("Database connection failed."); |
68 | 67 | } |
69 | - } |
|
68 | + } |
|
70 | 69 | |
71 | - function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
70 | + function __construct() { throw new Exception("Can not create instance of Page_Class. Class is static."); } |
|
72 | 71 | |
73 | - private static function __query($sql) { |
|
72 | + private static function __query($sql) { |
|
74 | 73 | if ( !($res = pg_query(self::$__connection, $sql)) ) |
75 | - throw new Exception(pg_last_error(self::$__connection)); |
|
74 | + throw new Exception(pg_last_error(self::$__connection)); |
|
76 | 75 | return $res; |
77 | - } |
|
76 | + } |
|
78 | 77 | |
79 | - static function store_page($id, $page_num, $data) { |
|
78 | + static function store_page($id, $page_num, $data) { |
|
80 | 79 | $where = "WHERE id='" . pg_escape_string($id) . "' AND ". |
81 | - "page_num=". pg_escape_string($page_num); |
|
80 | + "page_num=". pg_escape_string($page_num); |
|
82 | 81 | |
83 | 82 | $res = self::__query("SELECT timestamp FROM page_cache ". $where); |
84 | 83 | |
85 | 84 | $row = pg_fetch_assoc($res); |
86 | 85 | |
87 | 86 | if ( $row ) |
88 | - self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
87 | + self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where); |
|
89 | 88 | else |
90 | - self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
91 | - pg_escape_string($page_num) . ", ". |
|
92 | - "'". pg_escape_string($data) . "')"); |
|
89 | + self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ". |
|
90 | + pg_escape_string($page_num) . ", ". |
|
91 | + "'". pg_escape_string($data) . "')"); |
|
93 | 92 | |
94 | - } |
|
93 | + } |
|
95 | 94 | |
96 | - static function store_fonts($id, $fonts) { |
|
95 | + static function store_fonts($id, $fonts) { |
|
97 | 96 | self::__query("BEGIN"); |
98 | 97 | // Update the font information |
99 | 98 | self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
100 | 99 | |
101 | 100 | foreach (array_keys($fonts) as $font) |
102 | - self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
101 | + self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" . |
|
103 | 102 | pg_escape_string($id) . "', '" . pg_escape_string($font) . "')"); |
104 | 103 | self::__query("COMMIT"); |
105 | - } |
|
104 | + } |
|
106 | 105 | |
107 | 106 | // static function retrieve_page($id, $page_num) { |
108 | 107 | |
@@ -115,45 +114,45 @@ discard block |
||
115 | 114 | |
116 | 115 | // } |
117 | 116 | |
118 | - static function get_page_timestamp($id, $page_num) { |
|
117 | + static function get_page_timestamp($id, $page_num) { |
|
119 | 118 | $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ". |
120 | - "page_num=". pg_escape_string($page_num)); |
|
119 | + "page_num=". pg_escape_string($page_num)); |
|
121 | 120 | |
122 | 121 | $row = pg_fetch_assoc($res); |
123 | 122 | |
124 | 123 | return $row["timestamp"]; |
125 | 124 | |
126 | - } |
|
125 | + } |
|
127 | 126 | |
128 | - // Adds the cached document referenced by $id to the provided pdf |
|
129 | - static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
127 | + // Adds the cached document referenced by $id to the provided pdf |
|
128 | + static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) { |
|
130 | 129 | $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'"); |
131 | 130 | |
132 | 131 | // Ensure that the fonts needed by the cached document are loaded into |
133 | 132 | // the pdf |
134 | 133 | while ($row = pg_fetch_assoc($res)) |
135 | - $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
134 | + $pdf->get_cpdf()->selectFont($row["font_name"]); |
|
136 | 135 | |
137 | 136 | $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'"); |
138 | 137 | |
139 | 138 | if ( $new_page ) |
140 | - $pdf->new_page(); |
|
139 | + $pdf->new_page(); |
|
141 | 140 | |
142 | 141 | $first = true; |
143 | 142 | while ($row = pg_fetch_assoc($res)) { |
144 | 143 | |
145 | - if ( !$first ) |
|
144 | + if ( !$first ) |
|
146 | 145 | $pdf->new_page(); |
147 | - else |
|
146 | + else |
|
148 | 147 | $first = false; |
149 | 148 | |
150 | - $page = $pdf->reopen_serialized_object($row["data"]); |
|
151 | - //$pdf->close_object(); |
|
152 | - $pdf->add_object($page, "add"); |
|
149 | + $page = $pdf->reopen_serialized_object($row["data"]); |
|
150 | + //$pdf->close_object(); |
|
151 | + $pdf->add_object($page, "add"); |
|
153 | 152 | |
154 | 153 | } |
155 | 154 | |
156 | - } |
|
155 | + } |
|
157 | 156 | } |
158 | 157 | |
159 | 158 | Page_Cache::init(); |
@@ -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_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -50,30 +49,30 @@ discard block |
||
50 | 49 | */ |
51 | 50 | abstract class Frame_Reflower { |
52 | 51 | |
53 | - /** |
|
54 | - * Frame for this reflower |
|
55 | - * |
|
56 | - * @var Frame |
|
57 | - */ |
|
58 | - protected $_frame; |
|
59 | - |
|
60 | - /** |
|
61 | - * Cached min/max size |
|
62 | - * |
|
63 | - * @var array |
|
64 | - */ |
|
65 | - protected $_min_max_cache; |
|
52 | + /** |
|
53 | + * Frame for this reflower |
|
54 | + * |
|
55 | + * @var Frame |
|
56 | + */ |
|
57 | + protected $_frame; |
|
58 | + |
|
59 | + /** |
|
60 | + * Cached min/max size |
|
61 | + * |
|
62 | + * @var array |
|
63 | + */ |
|
64 | + protected $_min_max_cache; |
|
66 | 65 | |
67 | - function __construct(Frame $frame) { |
|
66 | + function __construct(Frame $frame) { |
|
68 | 67 | $this->_frame = $frame; |
69 | 68 | $this->_min_max_cache = null; |
70 | - } |
|
69 | + } |
|
71 | 70 | |
72 | - function dispose() { |
|
71 | + function dispose() { |
|
73 | 72 | unset($this->_frame); |
74 | - } |
|
73 | + } |
|
75 | 74 | |
76 | - protected function _collapse_margins() { |
|
75 | + protected function _collapse_margins() { |
|
77 | 76 | $cb = $this->_frame->get_containing_block(); |
78 | 77 | $style = $this->_frame->get_style(); |
79 | 78 | |
@@ -82,121 +81,121 @@ discard block |
||
82 | 81 | |
83 | 82 | // Handle 'auto' values |
84 | 83 | if ( $t === "auto" ) { |
85 | - $style->margin_top = "0pt"; |
|
86 | - $t = 0; |
|
84 | + $style->margin_top = "0pt"; |
|
85 | + $t = 0; |
|
87 | 86 | } |
88 | 87 | |
89 | 88 | if ( $b === "auto" ) { |
90 | - $style->margin_bottom = "0pt"; |
|
91 | - $b = 0; |
|
89 | + $style->margin_bottom = "0pt"; |
|
90 | + $b = 0; |
|
92 | 91 | } |
93 | 92 | |
94 | 93 | // Collapse vertical margins: |
95 | 94 | $n = $this->_frame->get_next_sibling(); |
96 | 95 | while ( $n && !in_array($n->get_style()->display, Style::$BLOCK_TYPES) ) |
97 | - $n = $n->get_next_sibling(); |
|
96 | + $n = $n->get_next_sibling(); |
|
98 | 97 | |
99 | 98 | if ( $n ) { // && !$n instanceof Page_Frame_Decorator ) { |
100 | 99 | |
101 | - $b = max($b, $style->length_in_pt($n->get_style()->margin_top, $cb["w"])); |
|
100 | + $b = max($b, $style->length_in_pt($n->get_style()->margin_top, $cb["w"])); |
|
102 | 101 | |
103 | - $n->get_style()->margin_top = "$b pt"; |
|
104 | - $style->margin_bottom = "0 pt"; |
|
102 | + $n->get_style()->margin_top = "$b pt"; |
|
103 | + $style->margin_bottom = "0 pt"; |
|
105 | 104 | |
106 | 105 | } |
107 | 106 | |
108 | 107 | // Collapse our first child's margin |
109 | 108 | $f = $this->_frame->get_first_child(); |
110 | 109 | while ( $f && !in_array($f->get_style()->display, Style::$BLOCK_TYPES) ) |
111 | - $f = $f->get_next_sibling(); |
|
110 | + $f = $f->get_next_sibling(); |
|
112 | 111 | |
113 | 112 | if ( $f ) { |
114 | - $t = max( $t, $style->length_in_pt($f->get_style()->margin_top, $cb["w"])); |
|
115 | - $style->margin_top = "$t pt"; |
|
116 | - $f->get_style()->margin_top = "0 pt"; |
|
113 | + $t = max( $t, $style->length_in_pt($f->get_style()->margin_top, $cb["w"])); |
|
114 | + $style->margin_top = "$t pt"; |
|
115 | + $f->get_style()->margin_top = "0 pt"; |
|
117 | 116 | } |
118 | 117 | |
119 | - } |
|
118 | + } |
|
120 | 119 | |
121 | - // Returns true if a new page is required |
|
122 | - protected function _check_new_page() { |
|
120 | + // Returns true if a new page is required |
|
121 | + protected function _check_new_page() { |
|
123 | 122 | $y = $this->_frame->get_position("y"); |
124 | 123 | $h = $style->length_in_pt($style->height); |
125 | 124 | // Check if we need to move to a new page |
126 | 125 | if ( $y + $h >= $this->_frame->get_root()->get_page_height() ) |
127 | - return true; |
|
126 | + return true; |
|
128 | 127 | |
129 | - } |
|
128 | + } |
|
130 | 129 | |
131 | - //........................................................................ |
|
130 | + //........................................................................ |
|
132 | 131 | |
133 | - abstract function reflow(); |
|
132 | + abstract function reflow(); |
|
134 | 133 | |
135 | - //........................................................................ |
|
134 | + //........................................................................ |
|
136 | 135 | |
137 | - // Required for table layout: Returns an array(0 => min, 1 => max, "min" |
|
138 | - // => min, "max" => max) of the minimum and maximum widths of this frame. |
|
139 | - // This provides a basic implementation. Child classes should override |
|
140 | - // this if necessary. |
|
141 | - function get_min_max_width() { |
|
136 | + // Required for table layout: Returns an array(0 => min, 1 => max, "min" |
|
137 | + // => min, "max" => max) of the minimum and maximum widths of this frame. |
|
138 | + // This provides a basic implementation. Child classes should override |
|
139 | + // this if necessary. |
|
140 | + function get_min_max_width() { |
|
142 | 141 | if ( !is_null($this->_min_max_cache) ) { |
143 | - return $this->_min_max_cache; |
|
142 | + return $this->_min_max_cache; |
|
144 | 143 | } |
145 | 144 | |
146 | 145 | $style = $this->_frame->get_style(); |
147 | 146 | |
148 | 147 | // Account for margins & padding |
149 | 148 | $dims = array($style->padding_left, |
150 | - $style->padding_right, |
|
151 | - $style->border_left_width, |
|
152 | - $style->border_right_width, |
|
153 | - $style->margin_left, |
|
154 | - $style->margin_right); |
|
149 | + $style->padding_right, |
|
150 | + $style->border_left_width, |
|
151 | + $style->border_right_width, |
|
152 | + $style->margin_left, |
|
153 | + $style->margin_right); |
|
155 | 154 | |
156 | 155 | $cb_w = $this->_frame->get_containing_block("w"); |
157 | 156 | $delta = $style->length_in_pt($dims, $cb_w); |
158 | 157 | |
159 | 158 | // Handle degenerate case |
160 | 159 | if ( !$this->_frame->get_first_child() ) |
161 | - return $this->_min_max_cache = array($delta, $delta,"min" => $delta, "max" => $delta); |
|
160 | + return $this->_min_max_cache = array($delta, $delta,"min" => $delta, "max" => $delta); |
|
162 | 161 | |
163 | 162 | $low = array(); |
164 | 163 | $high = array(); |
165 | 164 | |
166 | 165 | for ( $iter = $this->_frame->get_children()->getIterator(); |
167 | - $iter->valid(); |
|
168 | - $iter->next() ) { |
|
166 | + $iter->valid(); |
|
167 | + $iter->next() ) { |
|
169 | 168 | |
170 | - $inline_min = 0; |
|
171 | - $inline_max = 0; |
|
169 | + $inline_min = 0; |
|
170 | + $inline_max = 0; |
|
172 | 171 | |
173 | - // Add all adjacent inline widths together to calculate max width |
|
174 | - while ( $iter->valid() && in_array( $iter->current()->get_style()->display, Style::$INLINE_TYPES ) ) { |
|
172 | + // Add all adjacent inline widths together to calculate max width |
|
173 | + while ( $iter->valid() && in_array( $iter->current()->get_style()->display, Style::$INLINE_TYPES ) ) { |
|
175 | 174 | |
176 | 175 | $child = $iter->current(); |
177 | 176 | |
178 | 177 | $minmax = $child->get_min_max_width(); |
179 | 178 | |
180 | 179 | if ( in_array( $iter->current()->get_style()->white_space, array("pre", "nowrap") ) ) |
181 | - $inline_min += $minmax["min"]; |
|
180 | + $inline_min += $minmax["min"]; |
|
182 | 181 | else |
183 | - $low[] = $minmax["min"]; |
|
182 | + $low[] = $minmax["min"]; |
|
184 | 183 | |
185 | 184 | $inline_max += $minmax["max"]; |
186 | 185 | $iter->next(); |
187 | 186 | |
188 | - } |
|
187 | + } |
|
189 | 188 | |
190 | - if ( $inline_max > 0 ) |
|
189 | + if ( $inline_max > 0 ) |
|
191 | 190 | $high[] = $inline_max; |
192 | 191 | |
193 | - if ( $inline_min > 0 ) |
|
192 | + if ( $inline_min > 0 ) |
|
194 | 193 | $low[] = $inline_min; |
195 | 194 | |
196 | - if ( $iter->valid() ) { |
|
195 | + if ( $iter->valid() ) { |
|
197 | 196 | list($low[], $high[]) = $iter->current()->get_min_max_width(); |
198 | 197 | continue; |
199 | - } |
|
198 | + } |
|
200 | 199 | |
201 | 200 | } |
202 | 201 | $min = count($low) ? max($low) : 0; |
@@ -206,16 +205,16 @@ discard block |
||
206 | 205 | // content. If the width is a percentage ignore it for now. |
207 | 206 | $width = $style->width; |
208 | 207 | if ( $width !== "auto" && !is_percent($width) ) { |
209 | - $width = $style->length_in_pt($width, $cb_w); |
|
210 | - if ( $min < $width ) |
|
208 | + $width = $style->length_in_pt($width, $cb_w); |
|
209 | + if ( $min < $width ) |
|
211 | 210 | $min = $width; |
212 | - if ( $max < $width ) |
|
211 | + if ( $max < $width ) |
|
213 | 212 | $max = $width; |
214 | 213 | } |
215 | 214 | |
216 | 215 | $min += $delta; |
217 | 216 | $max += $delta; |
218 | 217 | return $this->_min_max_cache = array($min, $max, "min"=>$min, "max"=>$max); |
219 | - } |
|
218 | + } |
|
220 | 219 | |
221 | 220 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_row_positioner.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,22 +46,22 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Table_Row_Positioner extends Positioner { |
49 | 48 | |
50 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
49 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
51 | 50 | |
52 | - //........................................................................ |
|
51 | + //........................................................................ |
|
53 | 52 | |
54 | - function position() { |
|
53 | + function position() { |
|
55 | 54 | |
56 | 55 | $cb = $this->_frame->get_containing_block(); |
57 | 56 | $p = $this->_frame->get_prev_sibling(); |
58 | 57 | |
59 | 58 | if ( $p ) |
60 | - $y = $p->get_position("y") + $p->get_margin_height(); |
|
59 | + $y = $p->get_position("y") + $p->get_margin_height(); |
|
61 | 60 | |
62 | 61 | else |
63 | - $y = $cb["y"]; |
|
62 | + $y = $cb["y"]; |
|
64 | 63 | |
65 | 64 | $this->_frame->set_position($cb["x"], $y); |
66 | 65 | |
67 | - } |
|
66 | + } |
|
68 | 67 | } |
@@ -1,41 +1,40 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | - * |
|
5 | - * File: $RCSfile: page_frame_decorator.cls.php,v $ |
|
6 | - * Created on: 2004-06-15 |
|
7 | - * |
|
8 | - * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | - * |
|
10 | - * This library is free software; you can redistribute it and/or |
|
11 | - * modify it under the terms of the GNU Lesser General Public |
|
12 | - * License as published by the Free Software Foundation; either |
|
13 | - * version 2.1 of the License, or (at your option) any later version. |
|
14 | - * |
|
15 | - * This library is distributed in the hope that it will be useful, |
|
16 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | - * Lesser General Public License for more details. |
|
19 | - * |
|
20 | - * You should have received a copy of the GNU Lesser General Public License |
|
21 | - * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | - * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | - * 02111-1307 USA |
|
24 | - * |
|
25 | - * Alternatively, you may distribute this software under the terms of the |
|
26 | - * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | - * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | - * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | - * |
|
30 | - * The latest version of DOMPDF might be available at: |
|
31 | - * http://www.dompdf.com/ |
|
32 | - * |
|
33 | - * @link http://www.dompdf.com/ |
|
34 | - * @copyright 2004 Benj Carson |
|
35 | - * @author Benj Carson <[email protected]> |
|
36 | - * @package dompdf |
|
37 | - |
|
38 | - */ |
|
3 | + * DOMPDF - PHP5 HTML to PDF renderer |
|
4 | + * |
|
5 | + * File: $RCSfile: page_frame_decorator.cls.php,v $ |
|
6 | + * Created on: 2004-06-15 |
|
7 | + * |
|
8 | + * Copyright (c) 2004 - Benj Carson <[email protected]> |
|
9 | + * |
|
10 | + * This library is free software; you can redistribute it and/or |
|
11 | + * modify it under the terms of the GNU Lesser General Public |
|
12 | + * License as published by the Free Software Foundation; either |
|
13 | + * version 2.1 of the License, or (at your option) any later version. |
|
14 | + * |
|
15 | + * This library is distributed in the hope that it will be useful, |
|
16 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
18 | + * Lesser General Public License for more details. |
|
19 | + * |
|
20 | + * You should have received a copy of the GNU Lesser General Public License |
|
21 | + * along with this library in the file LICENSE.LGPL; if not, write to the |
|
22 | + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
23 | + * 02111-1307 USA |
|
24 | + * |
|
25 | + * Alternatively, you may distribute this software under the terms of the |
|
26 | + * PHP License, version 3.0 or later. A copy of this license should have |
|
27 | + * been distributed with this file in the file LICENSE.PHP . If this is not |
|
28 | + * the case, you can obtain a copy at http://www.php.net/license/3_0.txt. |
|
29 | + * |
|
30 | + * The latest version of DOMPDF might be available at: |
|
31 | + * http://www.dompdf.com/ |
|
32 | + * |
|
33 | + * @link http://www.dompdf.com/ |
|
34 | + * @copyright 2004 Benj Carson |
|
35 | + * @author Benj Carson <[email protected]> |
|
36 | + * @package dompdf |
|
37 | + */ |
|
39 | 38 | |
40 | 39 | /* $Id: page_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
41 | 40 | |
@@ -47,137 +46,137 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Page_Frame_Decorator extends Frame_Decorator { |
49 | 48 | |
50 | - /** |
|
51 | - * y value of bottom page margin |
|
52 | - * |
|
53 | - * @var float |
|
54 | - */ |
|
55 | - protected $_bottom_page_margin; |
|
56 | - |
|
57 | - /** |
|
58 | - * Flag indicating page is full. |
|
59 | - * |
|
60 | - * @var bool |
|
61 | - */ |
|
62 | - protected $_page_full; |
|
63 | - |
|
64 | - /** |
|
65 | - * Number of tables currently being reflowed |
|
66 | - * |
|
67 | - * @var int |
|
68 | - */ |
|
69 | - protected $_in_table; |
|
70 | - |
|
71 | - /** |
|
72 | - * The pdf renderer |
|
73 | - * |
|
74 | - * @var Renderer |
|
75 | - */ |
|
76 | - protected $_renderer; |
|
77 | - |
|
78 | - //........................................................................ |
|
79 | - |
|
80 | - /** |
|
81 | - * Class constructor |
|
82 | - * |
|
83 | - * @param Frame $frame the frame to decorate |
|
84 | - */ |
|
85 | - function __construct(Frame $frame, DOMPDF $dompdf) { |
|
49 | + /** |
|
50 | + * y value of bottom page margin |
|
51 | + * |
|
52 | + * @var float |
|
53 | + */ |
|
54 | + protected $_bottom_page_margin; |
|
55 | + |
|
56 | + /** |
|
57 | + * Flag indicating page is full. |
|
58 | + * |
|
59 | + * @var bool |
|
60 | + */ |
|
61 | + protected $_page_full; |
|
62 | + |
|
63 | + /** |
|
64 | + * Number of tables currently being reflowed |
|
65 | + * |
|
66 | + * @var int |
|
67 | + */ |
|
68 | + protected $_in_table; |
|
69 | + |
|
70 | + /** |
|
71 | + * The pdf renderer |
|
72 | + * |
|
73 | + * @var Renderer |
|
74 | + */ |
|
75 | + protected $_renderer; |
|
76 | + |
|
77 | + //........................................................................ |
|
78 | + |
|
79 | + /** |
|
80 | + * Class constructor |
|
81 | + * |
|
82 | + * @param Frame $frame the frame to decorate |
|
83 | + */ |
|
84 | + function __construct(Frame $frame, DOMPDF $dompdf) { |
|
86 | 85 | parent::__construct($frame, $dompdf); |
87 | 86 | $this->_page_full = false; |
88 | 87 | $this->_in_table = 0; |
89 | 88 | $this->_bottom_page_margin = null; |
90 | - } |
|
89 | + } |
|
91 | 90 | |
92 | 91 | |
93 | - /** |
|
94 | - * Set the renderer used for this pdf |
|
95 | - * |
|
96 | - * @param Renderer $renderer the renderer to use |
|
97 | - */ |
|
98 | - function set_renderer($renderer) { |
|
92 | + /** |
|
93 | + * Set the renderer used for this pdf |
|
94 | + * |
|
95 | + * @param Renderer $renderer the renderer to use |
|
96 | + */ |
|
97 | + function set_renderer($renderer) { |
|
99 | 98 | $this->_renderer = $renderer; |
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Return the renderer used for this pdf |
|
104 | - * |
|
105 | - * @return Renderer |
|
106 | - */ |
|
107 | - function get_renderer() { |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Return the renderer used for this pdf |
|
103 | + * |
|
104 | + * @return Renderer |
|
105 | + */ |
|
106 | + function get_renderer() { |
|
108 | 107 | return $this->_renderer; |
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
113 | - * |
|
114 | - * @param float $x |
|
115 | - * @param float $y |
|
116 | - * @param float $w |
|
117 | - * @param float $h |
|
118 | - */ |
|
119 | - function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Set the frame's containing block. Overridden to set $this->_bottom_page_margin. |
|
112 | + * |
|
113 | + * @param float $x |
|
114 | + * @param float $y |
|
115 | + * @param float $w |
|
116 | + * @param float $h |
|
117 | + */ |
|
118 | + function set_containing_block($x = null, $y = null, $w = null, $h = null) { |
|
120 | 119 | parent::set_containing_block($x,$y,$w,$h); |
121 | 120 | $w = $this->get_containing_block("w"); |
122 | 121 | if ( isset($h) ) |
123 | - $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns true if the page is full and is no longer accepting frames. |
|
128 | - * |
|
129 | - * @return bool |
|
130 | - */ |
|
131 | - function is_full() { |
|
122 | + $this->_bottom_page_margin = $h; // - $this->_frame->get_style()->length_in_pt($this->_frame->get_style()->margin_bottom, $w); |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns true if the page is full and is no longer accepting frames. |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + function is_full() { |
|
132 | 131 | return $this->_page_full; |
133 | - } |
|
132 | + } |
|
134 | 133 | |
135 | - /** |
|
136 | - * Start a new page by resetting the full flag. |
|
137 | - */ |
|
138 | - function next_page() { |
|
134 | + /** |
|
135 | + * Start a new page by resetting the full flag. |
|
136 | + */ |
|
137 | + function next_page() { |
|
139 | 138 | $this->_renderer->new_page(); |
140 | 139 | $this->_page_full = false; |
141 | - } |
|
140 | + } |
|
142 | 141 | |
143 | - /** |
|
144 | - * Indicate to the page that a table is currently being reflowed. |
|
145 | - */ |
|
146 | - function table_reflow_start() { |
|
142 | + /** |
|
143 | + * Indicate to the page that a table is currently being reflowed. |
|
144 | + */ |
|
145 | + function table_reflow_start() { |
|
147 | 146 | $this->_in_table++; |
148 | - } |
|
147 | + } |
|
149 | 148 | |
150 | - /** |
|
151 | - * Indicate to the page that table reflow is finished. |
|
152 | - */ |
|
153 | - function table_reflow_end() { |
|
149 | + /** |
|
150 | + * Indicate to the page that table reflow is finished. |
|
151 | + */ |
|
152 | + function table_reflow_end() { |
|
154 | 153 | $this->_in_table--; |
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Return whether we are currently in a nested table or not |
|
159 | - * |
|
160 | - * @return bool |
|
161 | - */ |
|
162 | - function in_nested_table() { |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Return whether we are currently in a nested table or not |
|
158 | + * |
|
159 | + * @return bool |
|
160 | + */ |
|
161 | + function in_nested_table() { |
|
163 | 162 | return $this->_in_table > 1; |
164 | - } |
|
163 | + } |
|
165 | 164 | |
166 | - /** |
|
167 | - * Check if a forced page break is required before $frame. This uses the |
|
168 | - * frame's page_break_before property as well as the preceeding frame's |
|
169 | - * page_break_after property. |
|
170 | - * |
|
171 | - * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
172 | - * |
|
173 | - * @param Frame $frame the frame to check |
|
174 | - * @return bool true if a page break occured |
|
175 | - */ |
|
176 | - function check_forced_page_break(Frame $frame) { |
|
165 | + /** |
|
166 | + * Check if a forced page break is required before $frame. This uses the |
|
167 | + * frame's page_break_before property as well as the preceeding frame's |
|
168 | + * page_break_after property. |
|
169 | + * |
|
170 | + * @link http://www.w3.org/TR/CSS21/page.html#forced |
|
171 | + * |
|
172 | + * @param Frame $frame the frame to check |
|
173 | + * @return bool true if a page break occured |
|
174 | + */ |
|
175 | + function check_forced_page_break(Frame $frame) { |
|
177 | 176 | |
178 | 177 | // Skip check if page is already split |
179 | 178 | if ( $this->_page_full ) |
180 | - return; |
|
179 | + return; |
|
181 | 180 | |
182 | 181 | $block_types = array("block", "list-item", "table"); |
183 | 182 | $page_breaks = array("always", "left", "right"); |
@@ -185,42 +184,42 @@ discard block |
||
185 | 184 | $style = $frame->get_style(); |
186 | 185 | |
187 | 186 | if ( !in_array($style->display, $block_types) ) |
188 | - return false; |
|
187 | + return false; |
|
189 | 188 | |
190 | 189 | // Find the previous block-level sibling |
191 | 190 | $prev = $frame->get_prev_sibling(); |
192 | 191 | while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
193 | - $prev = $prev->get_prev_sibling(); |
|
192 | + $prev = $prev->get_prev_sibling(); |
|
194 | 193 | |
195 | 194 | if ( in_array($style->page_break_before, $page_breaks) ) { |
196 | 195 | |
197 | - // Prevent cascading splits |
|
198 | - $frame->split(); |
|
199 | - // We have to grab the style again here because split() resets |
|
200 | - // $frame->style to the frame's orignal style. |
|
201 | - $frame->get_style()->page_break_before = "auto"; |
|
202 | - $this->_page_full = true; |
|
203 | - return true; |
|
196 | + // Prevent cascading splits |
|
197 | + $frame->split(); |
|
198 | + // We have to grab the style again here because split() resets |
|
199 | + // $frame->style to the frame's orignal style. |
|
200 | + $frame->get_style()->page_break_before = "auto"; |
|
201 | + $this->_page_full = true; |
|
202 | + return true; |
|
204 | 203 | } |
205 | 204 | |
206 | 205 | if ( ($prev && in_array($prev->get_style()->page_break_after, $page_breaks)) ) { |
207 | - // Prevent cascading splits |
|
208 | - $frame->split(); |
|
209 | - $prev->get_style()->page_break_after = "auto"; |
|
210 | - $this->_page_full = true; |
|
211 | - return true; |
|
206 | + // Prevent cascading splits |
|
207 | + $frame->split(); |
|
208 | + $prev->get_style()->page_break_after = "auto"; |
|
209 | + $this->_page_full = true; |
|
210 | + return true; |
|
212 | 211 | } |
213 | 212 | |
214 | 213 | return false; |
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Determine if a page break is allowed before $frame |
|
219 | - * |
|
220 | - * @param Frame $frame the frame to check |
|
221 | - * @return bool true if a break is allowed, false otherwise |
|
222 | - */ |
|
223 | - protected function _page_break_allowed(Frame $frame) { |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Determine if a page break is allowed before $frame |
|
218 | + * |
|
219 | + * @param Frame $frame the frame to check |
|
220 | + * @return bool true if a break is allowed, false otherwise |
|
221 | + */ |
|
222 | + protected function _page_break_allowed(Frame $frame) { |
|
224 | 223 | /** |
225 | 224 | * |
226 | 225 | * http://www.w3.org/TR/CSS21/page.html#allowed-page-breaks |
@@ -276,162 +275,162 @@ discard block |
||
276 | 275 | // Block Frames (1): |
277 | 276 | if ( in_array($display, $block_types) ) { |
278 | 277 | |
279 | - // Avoid breaks within table-cells |
|
280 | - if ( $this->_in_table ) { |
|
278 | + // Avoid breaks within table-cells |
|
279 | + if ( $this->_in_table ) { |
|
281 | 280 | dompdf_debug("page-break", "In table: " . $this->_in_table); |
282 | 281 | return false; |
283 | - } |
|
282 | + } |
|
284 | 283 | |
285 | - // Rules A & B |
|
284 | + // Rules A & B |
|
286 | 285 | |
287 | - if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
286 | + if ( $frame->get_style()->page_break_before === "avoid" ) { |
|
288 | 287 | dompdf_debug("page-break", "before: avoid"); |
289 | 288 | return false; |
290 | - } |
|
289 | + } |
|
291 | 290 | |
292 | - // Find the preceeding block-level sibling |
|
293 | - $prev = $frame->get_prev_sibling(); |
|
294 | - while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
291 | + // Find the preceeding block-level sibling |
|
292 | + $prev = $frame->get_prev_sibling(); |
|
293 | + while ( $prev && !in_array($prev->get_style()->display, $block_types) ) |
|
295 | 294 | $prev = $prev->get_prev_sibling(); |
296 | 295 | |
297 | - // Does the previous element allow a page break after? |
|
298 | - if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
296 | + // Does the previous element allow a page break after? |
|
297 | + if ( $prev && $prev->get_style()->page_break_after === "avoid" ) { |
|
299 | 298 | dompdf_debug("page-break", "after: avoid"); |
300 | 299 | return false; |
301 | - } |
|
300 | + } |
|
302 | 301 | |
303 | - // If both $prev & $frame have the same parent, check the parent's |
|
304 | - // page_break_inside property. |
|
305 | - $parent = $frame->get_parent(); |
|
306 | - if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
307 | - dompdf_debug("page-break", "parent inside: avoid"); |
|
302 | + // If both $prev & $frame have the same parent, check the parent's |
|
303 | + // page_break_inside property. |
|
304 | + $parent = $frame->get_parent(); |
|
305 | + if ( $prev && $parent && $parent->get_style()->page_break_inside === "avoid" ) { |
|
306 | + dompdf_debug("page-break", "parent inside: avoid"); |
|
308 | 307 | return false; |
309 | - } |
|
308 | + } |
|
310 | 309 | |
311 | - // To prevent cascading page breaks when a top-level element has |
|
312 | - // page-break-inside: avoid, ensure that at least one frame is |
|
313 | - // on the page before splitting. |
|
314 | - if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
310 | + // To prevent cascading page breaks when a top-level element has |
|
311 | + // page-break-inside: avoid, ensure that at least one frame is |
|
312 | + // on the page before splitting. |
|
313 | + if ( $parent->get_node()->nodeName === "body" && !$prev ) { |
|
315 | 314 | // We are the body's first child |
316 | - dompdf_debug("page-break", "Body's first child."); |
|
315 | + dompdf_debug("page-break", "Body's first child."); |
|
317 | 316 | return false; |
318 | - } |
|
317 | + } |
|
319 | 318 | |
320 | - // If the frame is the first block-level frame, use the value from |
|
321 | - // $frame's parent instead. |
|
322 | - if ( !$prev && $parent ) |
|
319 | + // If the frame is the first block-level frame, use the value from |
|
320 | + // $frame's parent instead. |
|
321 | + if ( !$prev && $parent ) |
|
323 | 322 | return $this->_page_break_allowed( $parent ); |
324 | 323 | |
325 | - dompdf_debug("page-break", "block: break allowed"); |
|
326 | - return true; |
|
324 | + dompdf_debug("page-break", "block: break allowed"); |
|
325 | + return true; |
|
327 | 326 | |
328 | 327 | } |
329 | 328 | |
330 | 329 | // Inline frames (2): |
331 | 330 | else if ( in_array($display, Style::$INLINE_TYPES) ) { |
332 | 331 | |
333 | - // Avoid breaks within table-cells |
|
334 | - if ( $this->_in_table ) { |
|
335 | - dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
332 | + // Avoid breaks within table-cells |
|
333 | + if ( $this->_in_table ) { |
|
334 | + dompdf_debug("page-break", "In table: " . $this->_in_table); |
|
336 | 335 | return false; |
337 | - } |
|
336 | + } |
|
338 | 337 | |
339 | - // Rule C |
|
340 | - $block_parent = $frame->find_block_parent(); |
|
341 | - if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
342 | - dompdf_debug("page-break", "orphans"); |
|
338 | + // Rule C |
|
339 | + $block_parent = $frame->find_block_parent(); |
|
340 | + if ( count($block_parent->get_lines() ) < $frame->get_style()->orphans ) { |
|
341 | + dompdf_debug("page-break", "orphans"); |
|
343 | 342 | return false; |
344 | - } |
|
343 | + } |
|
345 | 344 | |
346 | - // FIXME: Checking widows is tricky without having laid out the |
|
347 | - // remaining line boxes. Just ignore it for now... |
|
345 | + // FIXME: Checking widows is tricky without having laid out the |
|
346 | + // remaining line boxes. Just ignore it for now... |
|
348 | 347 | |
349 | - // Rule D |
|
350 | - $p = $block_parent; |
|
351 | - while ($p) { |
|
348 | + // Rule D |
|
349 | + $p = $block_parent; |
|
350 | + while ($p) { |
|
352 | 351 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
353 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
354 | - return false; |
|
352 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
353 | + return false; |
|
355 | 354 | } |
356 | 355 | $p = $p->find_block_parent(); |
357 | - } |
|
356 | + } |
|
358 | 357 | |
359 | - // To prevent cascading page breaks when a top-level element has |
|
360 | - // page-break-inside: avoid, ensure that at least one frame with |
|
361 | - // some content is on the page before splitting. |
|
362 | - $prev = $frame->get_prev_sibling(); |
|
363 | - while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
358 | + // To prevent cascading page breaks when a top-level element has |
|
359 | + // page-break-inside: avoid, ensure that at least one frame with |
|
360 | + // some content is on the page before splitting. |
|
361 | + $prev = $frame->get_prev_sibling(); |
|
362 | + while ( $prev && ($prev->get_node()->nodeName === "#text" && trim($prev->get_node()->nodeValue) == "") ) |
|
364 | 363 | $prev = $prev->get_prev_sibling(); |
365 | 364 | |
366 | - if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
365 | + if ( $block_parent->get_node()->nodeName === "body" && !$prev ) { |
|
367 | 366 | // We are the body's first child |
368 | - dompdf_debug("page-break", "Body's first child."); |
|
367 | + dompdf_debug("page-break", "Body's first child."); |
|
369 | 368 | return false; |
370 | - } |
|
369 | + } |
|
371 | 370 | |
372 | - // Skip breaks on empty text nodes |
|
373 | - if ( $frame->get_node()->nodeName === "#text" && |
|
371 | + // Skip breaks on empty text nodes |
|
372 | + if ( $frame->get_node()->nodeName === "#text" && |
|
374 | 373 | $frame->get_node()->nodeValue == "" ) |
375 | 374 | return false; |
376 | 375 | |
377 | - dompdf_debug("page-break", "inline: break allowed"); |
|
378 | - return true; |
|
376 | + dompdf_debug("page-break", "inline: break allowed"); |
|
377 | + return true; |
|
379 | 378 | |
380 | 379 | // Table-rows |
381 | 380 | } else if ( $display === "table-row" ) { |
382 | 381 | |
383 | - // Simply check if the parent table's page_break_inside property is |
|
384 | - // not 'avoid' |
|
385 | - $p = Table_Frame_Decorator::find_parent_table($frame); |
|
382 | + // Simply check if the parent table's page_break_inside property is |
|
383 | + // not 'avoid' |
|
384 | + $p = Table_Frame_Decorator::find_parent_table($frame); |
|
386 | 385 | |
387 | - while ($p) { |
|
386 | + while ($p) { |
|
388 | 387 | if ( $p->get_style()->page_break_inside === "avoid" ) { |
389 | - dompdf_debug("page-break", "parent->inside: avoid"); |
|
390 | - return false; |
|
388 | + dompdf_debug("page-break", "parent->inside: avoid"); |
|
389 | + return false; |
|
391 | 390 | } |
392 | 391 | $p = $p->find_block_parent(); |
393 | - } |
|
392 | + } |
|
394 | 393 | |
395 | - // Avoid breaking after the first row of a table |
|
396 | - if ( $p && $p->get_first_child() === $frame) { |
|
397 | - dompdf_debug("page-break", "table: first-row"); |
|
394 | + // Avoid breaking after the first row of a table |
|
395 | + if ( $p && $p->get_first_child() === $frame) { |
|
396 | + dompdf_debug("page-break", "table: first-row"); |
|
398 | 397 | return false; |
399 | - } |
|
398 | + } |
|
400 | 399 | |
401 | - // If this is a nested table, prevent the page from breaking |
|
402 | - if ( $this->_in_table > 1 ) { |
|
400 | + // If this is a nested table, prevent the page from breaking |
|
401 | + if ( $this->_in_table > 1 ) { |
|
403 | 402 | dompdf_debug("page-break", "table: nested table"); |
404 | 403 | return false; |
405 | - } |
|
404 | + } |
|
406 | 405 | |
407 | - dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
408 | - return true; |
|
406 | + dompdf_debug("page-break","table-row/row-groups: break allowed"); |
|
407 | + return true; |
|
409 | 408 | |
410 | 409 | } else if ( in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) { |
411 | 410 | |
412 | - // Disallow breaks at row-groups: only split at row boundaries |
|
413 | - return false; |
|
411 | + // Disallow breaks at row-groups: only split at row boundaries |
|
412 | + return false; |
|
414 | 413 | |
415 | 414 | } else { |
416 | 415 | |
417 | - dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
418 | - return false; |
|
416 | + dompdf_debug("page-break", "? " . $frame->get_style()->display . ""); |
|
417 | + return false; |
|
418 | + } |
|
419 | + |
|
419 | 420 | } |
420 | 421 | |
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Check if $frame will fit on the page. If the frame does not fit, |
|
425 | - * the frame tree is modified so that a page break occurs in the |
|
426 | - * correct location. |
|
427 | - * |
|
428 | - * @param Frame $frame the frame to check |
|
429 | - * @return Frame the frame following the page break |
|
430 | - */ |
|
431 | - function check_page_break(Frame $frame) { |
|
422 | + /** |
|
423 | + * Check if $frame will fit on the page. If the frame does not fit, |
|
424 | + * the frame tree is modified so that a page break occurs in the |
|
425 | + * correct location. |
|
426 | + * |
|
427 | + * @param Frame $frame the frame to check |
|
428 | + * @return Frame the frame following the page break |
|
429 | + */ |
|
430 | + function check_page_break(Frame $frame) { |
|
432 | 431 | // Do not split if we have already |
433 | 432 | if ( $this->_page_full ) |
434 | - return false; |
|
433 | + return false; |
|
435 | 434 | |
436 | 435 | // Determine the frame's maximum y value |
437 | 436 | $max_y = $frame->get_position("y") + $frame->get_margin_height(); |
@@ -440,18 +439,18 @@ discard block |
||
440 | 439 | // parents of $frame must fit on the page as well: |
441 | 440 | $p = $frame->get_parent(); |
442 | 441 | while ( $p ) { |
443 | - $style = $p->get_style(); |
|
444 | - $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
445 | - $style->padding_bottom, |
|
446 | - $style->border_bottom_width)); |
|
447 | - $p = $p->get_parent(); |
|
442 | + $style = $p->get_style(); |
|
443 | + $max_y += $style->length_in_pt(array($style->margin_bottom, |
|
444 | + $style->padding_bottom, |
|
445 | + $style->border_bottom_width)); |
|
446 | + $p = $p->get_parent(); |
|
448 | 447 | } |
449 | 448 | |
450 | 449 | |
451 | 450 | // Check if $frame flows off the page |
452 | 451 | if ( $max_y <= $this->_bottom_page_margin ) |
453 | - // no: do nothing |
|
454 | - return false; |
|
452 | + // no: do nothing |
|
453 | + return false; |
|
455 | 454 | |
456 | 455 | dompdf_debug("page-break", "check_page_break"); |
457 | 456 | dompdf_debug("page-break", "in_table: " . $this->_in_table); |
@@ -466,58 +465,58 @@ discard block |
||
466 | 465 | dompdf_debug("page-break","Starting search"); |
467 | 466 | while ( $iter ) { |
468 | 467 | // echo "\nbacktrack: " .$iter->get_node()->nodeName ." ".spl_object_hash($iter->get_node()). ""; |
469 | - if ( $iter === $this ) { |
|
470 | - dompdf_debug("page-break", "reached root."); |
|
468 | + if ( $iter === $this ) { |
|
469 | + dompdf_debug("page-break", "reached root."); |
|
471 | 470 | // We've reached the root in our search. Just split at $frame. |
472 | 471 | break; |
473 | - } |
|
472 | + } |
|
474 | 473 | |
475 | - if ( $this->_page_break_allowed($iter) ) { |
|
474 | + if ( $this->_page_break_allowed($iter) ) { |
|
476 | 475 | dompdf_debug("page-break","break allowed, splitting."); |
477 | 476 | $iter->split(); |
478 | 477 | $this->_page_full = true; |
479 | 478 | $this->_in_table = $in_table; |
480 | 479 | return true; |
481 | - } |
|
480 | + } |
|
482 | 481 | |
483 | - if ( !$flg && $next = $iter->get_last_child() ) { |
|
484 | - dompdf_debug("page-break", "following last child."); |
|
482 | + if ( !$flg && $next = $iter->get_last_child() ) { |
|
483 | + dompdf_debug("page-break", "following last child."); |
|
485 | 484 | |
486 | 485 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) ) |
487 | - $this->_in_table++; |
|
486 | + $this->_in_table++; |
|
488 | 487 | |
489 | 488 | $iter = $next; |
490 | 489 | continue; |
491 | - } |
|
490 | + } |
|
492 | 491 | |
493 | - if ( $next = $iter->get_prev_sibling() ) { |
|
494 | - dompdf_debug("page-break", "following prev sibling."); |
|
492 | + if ( $next = $iter->get_prev_sibling() ) { |
|
493 | + dompdf_debug("page-break", "following prev sibling."); |
|
495 | 494 | |
496 | 495 | if ( in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
497 | 496 | !in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
498 | - $this->_in_table++; |
|
497 | + $this->_in_table++; |
|
499 | 498 | |
500 | 499 | else if ( !in_array($next->get_style()->display, Style::$TABLE_TYPES) && |
501 | 500 | in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
502 | - $this->_in_table--; |
|
501 | + $this->_in_table--; |
|
503 | 502 | |
504 | 503 | $iter = $next; |
505 | 504 | $flg = false; |
506 | 505 | continue; |
507 | - } |
|
506 | + } |
|
508 | 507 | |
509 | - if ( $next = $iter->get_parent() ) { |
|
510 | - dompdf_debug("page-break", "following parent."); |
|
508 | + if ( $next = $iter->get_parent() ) { |
|
509 | + dompdf_debug("page-break", "following parent."); |
|
511 | 510 | |
512 | 511 | if ( in_array($iter->get_style()->display, Style::$TABLE_TYPES) ) |
513 | - $this->_in_table--; |
|
512 | + $this->_in_table--; |
|
514 | 513 | |
515 | 514 | $iter = $next; |
516 | 515 | $flg = true; |
517 | 516 | continue; |
518 | - } |
|
517 | + } |
|
519 | 518 | |
520 | - break; |
|
519 | + break; |
|
521 | 520 | |
522 | 521 | } |
523 | 522 | |
@@ -528,33 +527,33 @@ discard block |
||
528 | 527 | |
529 | 528 | // If we are in a table, backtrack to the nearest top-level table row |
530 | 529 | if ( $this->_in_table ) { |
531 | - $num_tables = $this->_in_table - 1; |
|
530 | + $num_tables = $this->_in_table - 1; |
|
532 | 531 | |
533 | - $iter = $frame; |
|
534 | - while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
532 | + $iter = $frame; |
|
533 | + while ( $iter && $num_tables && $iter->get_style->display !== "table" ) { |
|
535 | 534 | $iter = $iter->get_parent(); |
536 | 535 | $num_tables--; |
537 | - } |
|
536 | + } |
|
538 | 537 | |
539 | - $iter = $frame; |
|
540 | - while ($iter && $iter->get_style()->display !== "table-row" ) |
|
538 | + $iter = $frame; |
|
539 | + while ($iter && $iter->get_style()->display !== "table-row" ) |
|
541 | 540 | $iter = $iter->get_parent(); |
542 | 541 | |
543 | - $iter->split(); |
|
544 | - $this->_page_full = true; |
|
545 | - return true; |
|
542 | + $iter->split(); |
|
543 | + $this->_page_full = true; |
|
544 | + return true; |
|
546 | 545 | } |
547 | 546 | |
548 | 547 | $frame->split(); |
549 | 548 | $this->_page_full = true; |
550 | 549 | return true; |
551 | 550 | |
552 | - } |
|
551 | + } |
|
553 | 552 | |
554 | - //........................................................................ |
|
553 | + //........................................................................ |
|
555 | 554 | |
556 | - function split($frame = null) { |
|
555 | + function split($frame = null) { |
|
557 | 556 | // Do nothing |
558 | - } |
|
557 | + } |
|
559 | 558 | |
560 | 559 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id */ |
@@ -44,9 +43,9 @@ discard block |
||
44 | 43 | */ |
45 | 44 | class Absolute_Positioner extends Positioner { |
46 | 45 | |
47 | - function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
46 | + function __construct(Frame_Decorator $frame) { parent::__construct($frame); } |
|
48 | 47 | |
49 | - function position() { |
|
48 | + function position() { |
|
50 | 49 | |
51 | 50 | $cb = $this->_frame->get_containing_block(); |
52 | 51 | |
@@ -61,27 +60,27 @@ discard block |
||
61 | 60 | |
62 | 61 | if ( $p ) { |
63 | 62 | |
64 | - // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
63 | + // Get the parent's padding box (see http://www.w3.org/TR/CSS21/visuren.html#propdef-top) |
|
65 | 64 | |
66 | - list($x, $y, $w, $h) = $p->get_padding_box(); |
|
65 | + list($x, $y, $w, $h) = $p->get_padding_box(); |
|
67 | 66 | |
68 | 67 | } else { |
69 | 68 | |
70 | - $x = $cb["x"]; |
|
71 | - $y = $cb["y"]; |
|
69 | + $x = $cb["x"]; |
|
70 | + $y = $cb["y"]; |
|
72 | 71 | |
73 | 72 | } |
74 | 73 | |
75 | 74 | if ( isset($top) ) { |
76 | - $y += $top; |
|
75 | + $y += $top; |
|
77 | 76 | } else if ( isset($bottom) ) { |
78 | - // FIXME: need to know this frame's height before we can do this correctly |
|
77 | + // FIXME: need to know this frame's height before we can do this correctly |
|
79 | 78 | } |
80 | 79 | |
81 | 80 | $x += $left; |
82 | 81 | |
83 | 82 | $this->_frame->set_position($x, $y); |
84 | 83 | |
85 | - } |
|
84 | + } |
|
86 | 85 | |
87 | 86 | } |
88 | 87 | \ No newline at end of file |