Passed
Push — 1.10.x ( 918f1f...c8b126 )
by Yannick
419:13 queued 372:02
created
main/inc/lib/phpdocx/pdf/include/cellmap.cls.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -194,6 +194,9 @@  discard block
 block discarded – undo
194 194
     return $this->_rows[$j];
195 195
   }
196 196
 
197
+  /**
198
+   * @param string $h_v
199
+   */
197 200
   function get_border($i, $j, $h_v, $prop = null) {
198 201
     if ( !isset($this->_borders[$i][$j][$h_v]) )
199 202
       $this->_borders[$i][$j][$h_v] = array("width" => 0,
@@ -318,6 +321,11 @@  discard block
 block discarded – undo
318 321
   //........................................................................
319 322
 
320 323
 
324
+  /**
325
+   * @param integer $i
326
+   * @param integer $j
327
+   * @param string $h_v
328
+   */
321 329
   protected function _resolve_border($i, $j, $h_v, $border_spec) {
322 330
     $n_width = $border_spec["width"];
323 331
     $n_style = $border_spec["style"];
Please login to merge, or discard this patch.
Indentation   +323 added lines, -324 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: cellmap.cls.php,v $
6
- * Created on: 2004-07-28
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: cellmap.cls.php,v $
6
+     * Created on: 2004-07-28
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: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -50,12 +49,12 @@  discard block
 block discarded – undo
50 49
  */
51 50
 class Cellmap {
52 51
 
53
-  /**
54
-   * Border style weight lookup for collapsed border resolution.
55
-   *
56
-   * @var array
57
-   */
58
-  static protected $_BORDER_STYLE_SCORE = array("inset"  => 1,
52
+    /**
53
+     * Border style weight lookup for collapsed border resolution.
54
+     *
55
+     * @var array
56
+     */
57
+    static protected $_BORDER_STYLE_SCORE = array("inset"  => 1,
59 58
                                                 "groove" => 2,
60 59
                                                 "outset" => 3,
61 60
                                                 "ridge"  => 4,
@@ -65,87 +64,87 @@  discard block
 block discarded – undo
65 64
                                                 "double" => 8,
66 65
                                                 "none"   => 0);
67 66
 
68
-  /**
69
-   * The table object this cellmap is attached to.
70
-   *
71
-   * @var Table_Frame_Decorator
72
-   */
73
-  protected $_table;
74
-
75
-  /**
76
-   * The total number of rows in the table
77
-   *
78
-   * @var int
79
-   */
80
-  protected $_num_rows;
81
-
82
-  /**
83
-   * The total number of columns in the table
84
-   *
85
-   * @var int
86
-   */
87
-  protected $_num_cols;
88
-
89
-  /**
90
-   * 2D array mapping <row,column> to frames
91
-   *
92
-   * @var array
93
-   */
94
-  protected $_cells;
95
-
96
-  /**
97
-   * 1D array of column dimensions
98
-   *
99
-   * @var array
100
-   */
101
-  protected $_columns;
102
-
103
-  /**
104
-   * 1D array of row dimensions
105
-   *
106
-   * @var array
107
-   */
108
-  protected $_rows;
109
-
110
-  /**
111
-   * 2D array of border specs
112
-   *
113
-   * @var array
114
-   */
115
-  protected $_borders;
116
-
117
-  /**
118
-   * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on
119
-   * frame_id.
120
-   *
121
-   * @var array
122
-   */
123
-  protected $_frames;
124
-
125
-  /**
126
-   * Current column when adding cells, 0-based
127
-   *
128
-   * @var int
129
-   */
130
-  private $__col;
131
-
132
-  /**
133
-   * Current row when adding cells, 0-based
134
-   *
135
-   * @var int
136
-   */
137
-  private $__row;
138
-
139
-  //........................................................................
140
-
141
-  function __construct(Table_Frame_Decorator $table) {
67
+    /**
68
+     * The table object this cellmap is attached to.
69
+     *
70
+     * @var Table_Frame_Decorator
71
+     */
72
+    protected $_table;
73
+
74
+    /**
75
+     * The total number of rows in the table
76
+     *
77
+     * @var int
78
+     */
79
+    protected $_num_rows;
80
+
81
+    /**
82
+     * The total number of columns in the table
83
+     *
84
+     * @var int
85
+     */
86
+    protected $_num_cols;
87
+
88
+    /**
89
+     * 2D array mapping <row,column> to frames
90
+     *
91
+     * @var array
92
+     */
93
+    protected $_cells;
94
+
95
+    /**
96
+     * 1D array of column dimensions
97
+     *
98
+     * @var array
99
+     */
100
+    protected $_columns;
101
+
102
+    /**
103
+     * 1D array of row dimensions
104
+     *
105
+     * @var array
106
+     */
107
+    protected $_rows;
108
+
109
+    /**
110
+     * 2D array of border specs
111
+     *
112
+     * @var array
113
+     */
114
+    protected $_borders;
115
+
116
+    /**
117
+     * 1D Array mapping frames to (multiple) <row, col> pairs, keyed on
118
+     * frame_id.
119
+     *
120
+     * @var array
121
+     */
122
+    protected $_frames;
123
+
124
+    /**
125
+     * Current column when adding cells, 0-based
126
+     *
127
+     * @var int
128
+     */
129
+    private $__col;
130
+
131
+    /**
132
+     * Current row when adding cells, 0-based
133
+     *
134
+     * @var int
135
+     */
136
+    private $__row;
137
+
138
+    //........................................................................
139
+
140
+    function __construct(Table_Frame_Decorator $table) {
142 141
     $this->_table = $table;
143 142
     $this->reset();
144
-  }
143
+    }
145 144
 
146
-  //........................................................................
145
+    //........................................................................
147 146
 
148
-  function reset() {
147
+    function reset() {
149 148
     $this->_num_rows = 0;
150 149
     $this->_num_cols = 0;
151 150
 
@@ -158,54 +157,54 @@  discard block
 block discarded – undo
158 157
     $this->_borders = array();
159 158
 
160 159
     $this->__col = $this->__row = 0;
161
-  }
160
+    }
162 161
 
163
-  //........................................................................
162
+    //........................................................................
164 163
 
165
-  function get_num_rows() { return $this->_num_rows; }
166
-  function get_num_cols() { return $this->_num_cols; }
164
+    function get_num_rows() { return $this->_num_rows; }
165
+    function get_num_cols() { return $this->_num_cols; }
167 166
 
168
-  function &get_columns() {
167
+    function &get_columns() {
169 168
     return $this->_columns;
170
-  }
169
+    }
171 170
 
172
-  function &get_column($i) {
171
+    function &get_column($i) {
173 172
     if ( !isset($this->_columns[$i]) )
174
-      $this->_columns[$i] = array("x" => 0,
175
-                                  "min-width" => 0,
176
-                                  "max-width" => 0,
177
-                                  "used-width" => null,
178
-                                  "absolute" => 0,
179
-                                  "percent" => 0,
180
-                                  "auto" => true);
173
+        $this->_columns[$i] = array("x" => 0,
174
+                                    "min-width" => 0,
175
+                                    "max-width" => 0,
176
+                                    "used-width" => null,
177
+                                    "absolute" => 0,
178
+                                    "percent" => 0,
179
+                                    "auto" => true);
181 180
 
182 181
     return $this->_columns[$i];
183
-  }
182
+    }
184 183
 
185
-  function &get_rows() {
184
+    function &get_rows() {
186 185
     return $this->_rows;
187
-  }
186
+    }
188 187
 
189
-  function &get_row($j) {
188
+    function &get_row($j) {
190 189
     if ( !isset($this->_rows[$j]) )
191
-      $this->_rows[$j] = array("y" => 0,
192
-                               "first-column" => 0,
193
-                               "height" => null);
190
+        $this->_rows[$j] = array("y" => 0,
191
+                                "first-column" => 0,
192
+                                "height" => null);
194 193
     return $this->_rows[$j];
195
-  }
194
+    }
196 195
 
197
-  function get_border($i, $j, $h_v, $prop = null) {
196
+    function get_border($i, $j, $h_v, $prop = null) {
198 197
     if ( !isset($this->_borders[$i][$j][$h_v]) )
199
-      $this->_borders[$i][$j][$h_v] = array("width" => 0,
200
-                                           "style" => "solid",
201
-                                           "color" => "black");
198
+        $this->_borders[$i][$j][$h_v] = array("width" => 0,
199
+                                            "style" => "solid",
200
+                                            "color" => "black");
202 201
     if ( isset($prop) )
203
-      return $this->_borders[$i][$j][$h_v][$prop];
202
+        return $this->_borders[$i][$j][$h_v][$prop];
204 203
 
205 204
     return $this->_borders[$i][$j][$h_v];
206
-  }
205
+    }
207 206
 
208
-  function get_border_properties($i, $j) {
207
+    function get_border_properties($i, $j) {
209 208
 
210 209
     $left = $this->get_border($i, $j, "vertical");
211 210
     $right = $this->get_border($i, $j+1, "vertical");
@@ -213,119 +212,119 @@  discard block
 block discarded – undo
213 212
     $bottom = $this->get_border($i+1, $j, "horizontal");
214 213
 
215 214
     return compact("top", "bottom", "left", "right");
216
-  }
215
+    }
217 216
 
218
-  //........................................................................
217
+    //........................................................................
219 218
 
220
-  function get_spanned_cells($frame) {
219
+    function get_spanned_cells($frame) {
221 220
     $key = $frame->get_id();
222 221
 
223 222
     if ( !isset($this->_frames[$key]) ) {
224
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
223
+        throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
225 224
     }
226 225
 
227 226
     return $this->_frames[$key];
228 227
 
229
-  }
228
+    }
230 229
 
231
-  function frame_exists_in_cellmap($frame) {
230
+    function frame_exists_in_cellmap($frame) {
232 231
     $key = $frame->get_id();
233 232
     return isset($this->_frames[$key]);
234
-  }
233
+    }
235 234
   
236
-  function get_frame_position($frame) {
235
+    function get_frame_position($frame) {
237 236
     global $_dompdf_warnings;
238 237
 
239 238
     $key = $frame->get_id();
240 239
 
241 240
     if ( !isset($this->_frames[$key]) ) {
242
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
241
+        throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
243 242
     }
244 243
 
245 244
     $col = $this->_frames[$key]["columns"][0];
246 245
     $row = $this->_frames[$key]["rows"][0];
247 246
 
248 247
     if ( !isset($this->_columns[$col])) {
249
-      $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
250
-      $x = 0;
248
+        $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
249
+        $x = 0;
251 250
     } else
252
-      $x = $this->_columns[$col]["x"];
251
+        $x = $this->_columns[$col]["x"];
253 252
 
254 253
     if ( !isset($this->_rows[$row])) {
255
-      $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
256
-      $y = 0;
254
+        $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
255
+        $y = 0;
257 256
     } else
258
-      $y = $this->_rows[$row]["y"];
257
+        $y = $this->_rows[$row]["y"];
259 258
 
260 259
     return array($x, $y, "x" => $x, "y" => $y);
261
-  }
260
+    }
262 261
 
263
-  function get_frame_width($frame) {
262
+    function get_frame_width($frame) {
264 263
     $key = $frame->get_id();
265 264
 
266 265
     if ( !isset($this->_frames[$key]) ) {
267
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
266
+        throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
268 267
     }
269 268
 
270 269
     $cols = $this->_frames[$key]["columns"];
271 270
     $w = 0;
272 271
     foreach ($cols as $i)
273
-      $w += $this->_columns[$i]["used-width"];
272
+        $w += $this->_columns[$i]["used-width"];
274 273
 
275 274
     return $w;
276 275
 
277
-  }
276
+    }
278 277
 
279
-  function get_frame_height($frame) {
278
+    function get_frame_height($frame) {
280 279
     $key = $frame->get_id();
281 280
 
282 281
     if ( !isset($this->_frames[$key]) )
283
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
282
+        throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
284 283
 
285 284
     $rows = $this->_frames[$key]["rows"];
286 285
     $h = 0;
287 286
     foreach ($rows as $i) {
288
-      if ( !isset($this->_rows[$i]) )  {
287
+        if ( !isset($this->_rows[$i]) )  {
289 288
         throw new Exception("foo");
290
-      }
291
-      $h += $this->_rows[$i]["height"];
289
+        }
290
+        $h += $this->_rows[$i]["height"];
292 291
     }
293 292
     return $h;
294 293
 
295
-  }
294
+    }
296 295
 
297 296
 
298
-  //........................................................................
297
+    //........................................................................
299 298
 
300
-  function set_column_width($j, $width) {
299
+    function set_column_width($j, $width) {
301 300
     $col =& $this->get_column($j);
302 301
     $col["used-width"] = $width;
303 302
     $next_col =& $this->get_column($j+1);
304 303
     $next_col["x"] = $next_col["x"] + $width;
305
-  }
304
+    }
306 305
 
307
-  function set_row_height($i, $height) {
306
+    function set_row_height($i, $height) {
308 307
     $row =& $this->get_row($i);
309 308
     if ( $height <= $row["height"] )
310
-      return;
309
+        return;
311 310
 
312 311
     $row["height"] = $height;
313 312
     $next_row =& $this->get_row($i+1);
314 313
     $next_row["y"] = $row["y"] + $height;
315 314
 
316
-  }
315
+    }
317 316
 
318
-  //........................................................................
317
+    //........................................................................
319 318
 
320 319
 
321
-  protected function _resolve_border($i, $j, $h_v, $border_spec) {
320
+    protected function _resolve_border($i, $j, $h_v, $border_spec) {
322 321
     $n_width = $border_spec["width"];
323 322
     $n_style = $border_spec["style"];
324 323
     $n_color = $border_spec["color"];
325 324
 
326 325
     if ( !isset($this->_borders[$i][$j][$h_v]) ) {
327
-      $this->_borders[$i][$j][$h_v] = $border_spec;
328
-      return $this->_borders[$i][$j][$h_v]["width"];
326
+        $this->_borders[$i][$j][$h_v] = $border_spec;
327
+        return $this->_borders[$i][$j][$h_v]["width"];
329 328
     }
330 329
 
331 330
     $o_width = $this->_borders[$i][$j][$h_v]["width"];
@@ -341,14 +340,14 @@  discard block
 block discarded – undo
341 340
          ($o_width == $n_width &&
342 341
           in_array($n_style, self::$_BORDER_STYLE_SCORE) &&
343 342
           self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) )
344
-      $this->_borders[$i][$j][$h_v] = $border_spec;
343
+        $this->_borders[$i][$j][$h_v] = $border_spec;
345 344
 
346 345
     return $this->_borders[$i][$j][$h_v]["width"];
347
-  }
346
+    }
348 347
 
349
-  //........................................................................
348
+    //........................................................................
350 349
 
351
-  function add_frame(Frame $frame) {
350
+    function add_frame(Frame $frame) {
352 351
     
353 352
     $style = $frame->get_style();
354 353
     $display = $style->display;
@@ -361,39 +360,39 @@  discard block
 block discarded – undo
361 360
          $display == "inline-table" ||
362 361
          in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
363 362
 
364
-      $start_row = $this->__row;
365
-      foreach ( $frame->get_children() as $child )
363
+        $start_row = $this->__row;
364
+        foreach ( $frame->get_children() as $child )
366 365
         $this->add_frame( $child );
367 366
 
368
-      if ( $display == "table-row" )
367
+        if ( $display == "table-row" )
369 368
         $this->add_row();
370 369
 
371
-      $num_rows = $this->__row - $start_row - 1;
372
-      $key = $frame->get_id();
370
+        $num_rows = $this->__row - $start_row - 1;
371
+        $key = $frame->get_id();
373 372
 
374
-      // Row groups always span across the entire table
375
-      $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1));
376
-      $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1));
377
-      $this->_frames[ $key ]["frame"] = $frame;
373
+        // Row groups always span across the entire table
374
+        $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1));
375
+        $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1));
376
+        $this->_frames[ $key ]["frame"] = $frame;
378 377
 
379
-      if ( $display != "table-row" && $collapse ) {
378
+        if ( $display != "table-row" && $collapse ) {
380 379
 
381 380
         $bp = $style->get_border_properties();
382 381
 
383 382
         // Resolve the borders
384 383
         for ( $i = 0; $i < $num_rows+1; $i++) {
385
-          $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]);
386
-          $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]);
384
+            $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]);
385
+            $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]);
387 386
         }
388 387
 
389 388
         for ( $j = 0; $j < $this->_num_cols; $j++) {
390
-          $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]);
391
-          $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]);
389
+            $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]);
390
+            $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]);
391
+        }
392 392
         }
393
-      }
394 393
 
395 394
 
396
-      return;
395
+        return;
397 396
     }
398 397
 
399 398
     // Determine where this cell is going
@@ -401,13 +400,13 @@  discard block
 block discarded – undo
401 400
     $rowspan = $frame->get_node()->getAttribute("rowspan");
402 401
 
403 402
     if ( !$colspan ) {
404
-      $colspan = 1;
405
-      $frame->get_node()->setAttribute("colspan",1);
403
+        $colspan = 1;
404
+        $frame->get_node()->setAttribute("colspan",1);
406 405
     }
407 406
 
408 407
     if ( !$rowspan ) {
409
-      $rowspan = 1;
410
-      $frame->get_node()->setAttribute("rowspan",1);
408
+        $rowspan = 1;
409
+        $frame->get_node()->setAttribute("rowspan",1);
411 410
     }
412 411
     $key = $frame->get_id();
413 412
 
@@ -420,60 +419,60 @@  discard block
 block discarded – undo
420 419
     // Find the next available column (fix by Ciro Mondueri)
421 420
     $ac = $this->__col;
422 421
     while ( isset($this->_cells[$this->__row][$ac]) )
423
-       $ac++;
422
+        $ac++;
424 423
     $this->__col = $ac;
425 424
 
426 425
     // Rows:
427 426
     for ( $i = 0; $i < $rowspan; $i++ ) {
428
-      $row = $this->__row + $i;
427
+        $row = $this->__row + $i;
429 428
 
430
-      $this->_frames[ $key ]["rows"][] = $row;
429
+        $this->_frames[ $key ]["rows"][] = $row;
431 430
 
432
-      for ( $j = 0; $j < $colspan; $j++)
431
+        for ( $j = 0; $j < $colspan; $j++)
433 432
         $this->_cells[$row][$this->__col + $j] = $frame;
434 433
 
435
-      if ( $collapse ) {
434
+        if ( $collapse ) {
436 435
         // Resolve vertical borders
437 436
         $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"]));
438 437
         $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"]));
439
-      }
438
+        }
440 439
     }
441 440
 
442 441
     $max_top = $max_bottom = 0;
443 442
 
444 443
     // Columns:
445 444
     for ( $j = 0; $j < $colspan; $j++ ) {
446
-      $col = $this->__col + $j;
447
-      $this->_frames[ $key ]["columns"][] = $col;
445
+        $col = $this->__col + $j;
446
+        $this->_frames[ $key ]["columns"][] = $col;
448 447
 
449
-      if ( $collapse ) {
448
+        if ( $collapse ) {
450 449
         // Resolve horizontal borders
451 450
         $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"]));
452 451
         $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"]));
453
-      }
452
+        }
454 453
     }
455 454
 
456 455
     $this->_frames[ $key ]["frame"] = $frame;
457 456
 
458 457
     // Handle seperated border model
459 458
     if ( !$collapse ) {
460
-      list($h, $v) = $this->_table->get_style()->border_spacing;
459
+        list($h, $v) = $this->_table->get_style()->border_spacing;
461 460
 
462
-      // Border spacing is effectively a margin between cells
463
-      $v = $style->length_in_pt($v) / 2;
464
-      $h = $style->length_in_pt($h) / 2;
465
-      $style->margin = "$v $h";
461
+        // Border spacing is effectively a margin between cells
462
+        $v = $style->length_in_pt($v) / 2;
463
+        $h = $style->length_in_pt($h) / 2;
464
+        $style->margin = "$v $h";
466 465
 
467
-      // The additional 1/2 width gets added to the table proper
466
+        // The additional 1/2 width gets added to the table proper
468 467
 
469 468
     } else {
470 469
 
471
-      // Drop the frame's actual border
472
-      $style->border_left_width = $max_left / 2;
473
-      $style->border_right_width = $max_right / 2;
474
-      $style->border_top_width = $max_top / 2;
475
-      $style->border_bottom_width = $max_bottom / 2;
476
-      $style->margin = "none";
470
+        // Drop the frame's actual border
471
+        $style->border_left_width = $max_left / 2;
472
+        $style->border_right_width = $max_right / 2;
473
+        $style->border_top_width = $max_top / 2;
474
+        $style->border_bottom_width = $max_bottom / 2;
475
+        $style->margin = "none";
477 476
     }
478 477
 
479 478
     // Resolve the frame's width
@@ -482,60 +481,60 @@  discard block
 block discarded – undo
482 481
     $width = $style->width;
483 482
 
484 483
     if ( is_percent($width) ) {
485
-      $var = "percent";
486
-      $val = (float)rtrim($width, "% ") / $colspan;
484
+        $var = "percent";
485
+        $val = (float)rtrim($width, "% ") / $colspan;
487 486
 
488 487
     } else if ( $width !== "auto" ) {
489
-      $var = "absolute";
490
-      $val = $style->length_in_pt($frame_min) / $colspan;
488
+        $var = "absolute";
489
+        $val = $style->length_in_pt($frame_min) / $colspan;
491 490
     }
492 491
 
493 492
     $min = 0;
494 493
     $max = 0;
495 494
     for ( $cs = 0; $cs < $colspan; $cs++ ) {
496 495
 
497
-      // Resolve the frame's width(s) with other cells
498
-      $col =& $this->get_column( $this->__col + $cs );
496
+        // Resolve the frame's width(s) with other cells
497
+        $col =& $this->get_column( $this->__col + $cs );
499 498
 
500
-      // Note: $var is either 'percent' or 'absolute'.  We compare the
501
-      // requested percentage or absolute values with the existing widths
502
-      // and adjust accordingly.
503
-      if ( isset($var) && $val > $col[$var] ) {
499
+        // Note: $var is either 'percent' or 'absolute'.  We compare the
500
+        // requested percentage or absolute values with the existing widths
501
+        // and adjust accordingly.
502
+        if ( isset($var) && $val > $col[$var] ) {
504 503
         $col[$var] = $val;
505 504
         $col["auto"] = false;
506
-      }
505
+        }
507 506
 
508
-      $min += $col["min-width"];
509
-      $max += $col["max-width"];
507
+        $min += $col["min-width"];
508
+        $max += $col["max-width"];
510 509
     }
511 510
 
512 511
 
513 512
     if ( $frame_min > $min ) {
514
-      // The frame needs more space.  Expand each sub-column
515
-      $inc = ($frame_min - $min) / $colspan;
516
-      for ($c = 0; $c < $colspan; $c++) {
513
+        // The frame needs more space.  Expand each sub-column
514
+        $inc = ($frame_min - $min) / $colspan;
515
+        for ($c = 0; $c < $colspan; $c++) {
517 516
         $col =& $this->get_column($this->__col + $c);
518 517
         $col["min-width"] += $inc;
519
-      }
518
+        }
520 519
     }
521 520
 
522 521
     if ( $frame_max > $max ) {
523
-      $inc = ($frame_max - $max) / $colspan;
524
-      for ($c = 0; $c < $colspan; $c++) {
522
+        $inc = ($frame_max - $max) / $colspan;
523
+        for ($c = 0; $c < $colspan; $c++) {
525 524
         $col =& $this->get_column($this->__col + $c);
526 525
         $col["max-width"] += $inc;
527
-      }
526
+        }
528 527
     }
529 528
 
530 529
     $this->__col += $colspan;
531 530
     if ( $this->__col > $this->_num_cols )
532
-      $this->_num_cols = $this->__col;
531
+        $this->_num_cols = $this->__col;
533 532
 
534
-  }
533
+    }
535 534
 
536
-  //........................................................................
535
+    //........................................................................
537 536
 
538
-  function add_row() {
537
+    function add_row() {
539 538
 
540 539
     $this->__row++;
541 540
     $this->_num_rows++;
@@ -543,24 +542,24 @@  discard block
 block discarded – undo
543 542
     // Find the next available column
544 543
     $i = 0;
545 544
     while ( isset($this->_cells[$this->__row][$i]) )
546
-      $i++;
545
+        $i++;
547 546
 
548 547
     $this->__col = $i;
549 548
 
550
-  }
549
+    }
551 550
 
552
-  //........................................................................
551
+    //........................................................................
553 552
 
554
-  /**
555
-   * Remove a row from the cellmap.
556
-   *
557
-   * @param Frame
558
-   */
559
-  function remove_row(Frame $row) {
553
+    /**
554
+     * Remove a row from the cellmap.
555
+     *
556
+     * @param Frame
557
+     */
558
+    function remove_row(Frame $row) {
560 559
 
561 560
     $key = $row->get_id();
562 561
     if ( !isset($this->_frames[$key]) )
563
-      return;  // Presumably this row has alredy been removed
562
+        return;  // Presumably this row has alredy been removed
564 563
 
565 564
     $this->_row = $this->_num_rows--;
566 565
 
@@ -569,47 +568,47 @@  discard block
 block discarded – undo
569 568
 
570 569
     // Remove all frames from this row
571 570
     foreach ( $rows as $r ) {
572
-      foreach ( $columns as $c ) {
571
+        foreach ( $columns as $c ) {
573 572
         if ( isset($this->_cells[$r][$c]) ) {
574
-          $frame = $this->_cells[$r][$c];
575
-          unset($this->_frames[ $frame->get_id() ]);
576
-          unset($this->_cells[$r][$c]);
573
+            $frame = $this->_cells[$r][$c];
574
+            unset($this->_frames[ $frame->get_id() ]);
575
+            unset($this->_cells[$r][$c]);
576
+        }
577 577
         }
578
-      }
579
-      unset($this->_rows[$r]);
578
+        unset($this->_rows[$r]);
580 579
     }
581 580
 
582 581
     unset($this->_frames[$key]);
583 582
 
584
-  }
583
+    }
585 584
 
586
-  /**
587
-   * Remove a row group from the cellmap.
588
-   *
589
-   * @param Frame $group  The group to remove
590
-   */
591
-  function remove_row_group(Frame $group) {
585
+    /**
586
+     * Remove a row group from the cellmap.
587
+     *
588
+     * @param Frame $group  The group to remove
589
+     */
590
+    function remove_row_group(Frame $group) {
592 591
 
593 592
     $key = $group->get_id();
594 593
     if ( !isset($this->_frames[$key]) )
595
-      return;  // Presumably this row has alredy been removed
594
+        return;  // Presumably this row has alredy been removed
596 595
 
597 596
     $iter = $group->get_first_child();
598 597
     while ($iter) {
599
-      $this->remove_row($iter);
600
-      $iter = $iter->get_next_sibling();
598
+        $this->remove_row($iter);
599
+        $iter = $iter->get_next_sibling();
601 600
     }
602 601
 
603 602
     unset($this->_frames[$key]);
604
-  }
603
+    }
605 604
 
606
-  /**
607
-   * Update a row group after rows have been removed
608
-   *
609
-   * @param Frame $group    The group to update
610
-   * @param Frame $last_row The last row in the row group
611
-   */
612
-  function update_row_group(Frame $group, Frame $last_row) {
605
+    /**
606
+     * Update a row group after rows have been removed
607
+     *
608
+     * @param Frame $group    The group to update
609
+     * @param Frame $last_row The last row in the row group
610
+     */
611
+    function update_row_group(Frame $group, Frame $last_row) {
613 612
 
614 613
     $g_key = $group->get_id();
615 614
     $r_key = $last_row->get_id();
@@ -617,80 +616,80 @@  discard block
 block discarded – undo
617 616
     $r_rows = $this->_frames[$r_key]["rows"];
618 617
     $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) );
619 618
 
620
-  }
619
+    }
621 620
 
622
-  //........................................................................
621
+    //........................................................................
623 622
 
624
-  function assign_x_positions() {
623
+    function assign_x_positions() {
625 624
     // Pre-condition: widths must be resolved and assigned to columns and
626 625
     // column[0]["x"] must be set.
627 626
 
628 627
     $x = $this->_columns[0]["x"];
629 628
     foreach ( array_keys($this->_columns) as $j ) {
630
-      $this->_columns[$j]["x"] = $x;
631
-      $x += $this->_columns[$j]["used-width"];
629
+        $this->_columns[$j]["x"] = $x;
630
+        $x += $this->_columns[$j]["used-width"];
632 631
 
633 632
     }
634 633
 
635
-  }
634
+    }
636 635
 
637
-  function assign_frame_heights() {
636
+    function assign_frame_heights() {
638 637
     // Pre-condition: widths and heights of each column & row must be
639 638
     // calcluated
640 639
 
641 640
     foreach ( $this->_frames as $arr ) {
642
-      $frame = $arr["frame"];
641
+        $frame = $arr["frame"];
643 642
 
644
-      $h = 0;
645
-      foreach( $arr["rows"] as $row ) {
643
+        $h = 0;
644
+        foreach( $arr["rows"] as $row ) {
646 645
         if ( !isset($this->_rows[$row]) )
647
-          // The row has been removed because of a page split, so skip it.
648
-          continue;
646
+            // The row has been removed because of a page split, so skip it.
647
+            continue;
649 648
         $h += $this->_rows[$row]["height"];
650
-      }
649
+        }
651 650
 
652
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
651
+        if ( $frame instanceof Table_Cell_Frame_Decorator )
653 652
         $frame->set_cell_height($h);
654
-      else
653
+        else
655 654
         $frame->get_style()->height = $h;
656 655
     }
657 656
 
658
-  }
657
+    }
659 658
 
660
-  //........................................................................
659
+    //........................................................................
661 660
 
662
-  /**
663
-   * Re-adjust frame height if the table height is larger than its content
664
-   */
665
-  function set_frame_heights($table_height, $content_height) {
661
+    /**
662
+     * Re-adjust frame height if the table height is larger than its content
663
+     */
664
+    function set_frame_heights($table_height, $content_height) {
666 665
 
667 666
 
668 667
     // Distribute the increased height proportionally amongst each row
669 668
     foreach ( $this->_frames as $arr ) {
670
-      $frame = $arr["frame"];
669
+        $frame = $arr["frame"];
671 670
 
672
-      $h = 0;
673
-      foreach ($arr["rows"] as $row ) {
671
+        $h = 0;
672
+        foreach ($arr["rows"] as $row ) {
674 673
         if ( !isset($this->_rows[$row]) )
675
-          continue;
674
+            continue;
676 675
 
677 676
         $h += $this->_rows[$row]["height"];
678
-      }
677
+        }
679 678
 
680
-      $new_height = ($h / $content_height) * $table_height;
679
+        $new_height = ($h / $content_height) * $table_height;
681 680
 
682
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
681
+        if ( $frame instanceof Table_Cell_Frame_Decorator )
683 682
         $frame->set_cell_height($new_height);
684
-      else
683
+        else
685 684
         $frame->get_style()->height = $new_height;
686 685
     }
687 686
 
688
-  }
687
+    }
689 688
 
690
-  //........................................................................
689
+    //........................................................................
691 690
 
692
-  // Used for debugging:
693
-  function __toString() {
691
+    // Used for debugging:
692
+    function __toString() {
694 693
     $str = "";
695 694
     $str .= "Columns:<br/>";
696 695
     $str .= pre_r($this->_columns, true);
@@ -700,14 +699,14 @@  discard block
 block discarded – undo
700 699
     $str .=  "Frames:<br/>";
701 700
     $arr = array();
702 701
     foreach ( $this->_frames as $key => $val )
703
-      $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
702
+        $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
704 703
 
705 704
     $str .= pre_r($arr, true);
706 705
 
707 706
     if ( php_sapi_name() == "cli" )
708
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
707
+        $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
709 708
                                     array("\n",chr(27)."[01;33m", chr(27)."[0m"),
710 709
                                     $str));
711 710
     return $str;
712
-  }
711
+    }
713 712
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
   }
171 171
 
172 172
   function &get_column($i) {
173
-    if ( !isset($this->_columns[$i]) )
173
+    if (!isset($this->_columns[$i]))
174 174
       $this->_columns[$i] = array("x" => 0,
175 175
                                   "min-width" => 0,
176 176
                                   "max-width" => 0,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
   }
188 188
 
189 189
   function &get_row($j) {
190
-    if ( !isset($this->_rows[$j]) )
190
+    if (!isset($this->_rows[$j]))
191 191
       $this->_rows[$j] = array("y" => 0,
192 192
                                "first-column" => 0,
193 193
                                "height" => null);
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
   }
196 196
 
197 197
   function get_border($i, $j, $h_v, $prop = null) {
198
-    if ( !isset($this->_borders[$i][$j][$h_v]) )
198
+    if (!isset($this->_borders[$i][$j][$h_v]))
199 199
       $this->_borders[$i][$j][$h_v] = array("width" => 0,
200 200
                                            "style" => "solid",
201 201
                                            "color" => "black");
202
-    if ( isset($prop) )
202
+    if (isset($prop))
203 203
       return $this->_borders[$i][$j][$h_v][$prop];
204 204
 
205 205
     return $this->_borders[$i][$j][$h_v];
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
   function get_border_properties($i, $j) {
209 209
 
210 210
     $left = $this->get_border($i, $j, "vertical");
211
-    $right = $this->get_border($i, $j+1, "vertical");
211
+    $right = $this->get_border($i, $j + 1, "vertical");
212 212
     $top = $this->get_border($i, $j, "horizontal");
213
-    $bottom = $this->get_border($i+1, $j, "horizontal");
213
+    $bottom = $this->get_border($i + 1, $j, "horizontal");
214 214
 
215 215
     return compact("top", "bottom", "left", "right");
216 216
   }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
   function get_spanned_cells($frame) {
221 221
     $key = $frame->get_id();
222 222
 
223
-    if ( !isset($this->_frames[$key]) ) {
223
+    if (!isset($this->_frames[$key])) {
224 224
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
225 225
     }
226 226
 
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 
239 239
     $key = $frame->get_id();
240 240
 
241
-    if ( !isset($this->_frames[$key]) ) {
241
+    if (!isset($this->_frames[$key])) {
242 242
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
243 243
     }
244 244
 
245 245
     $col = $this->_frames[$key]["columns"][0];
246 246
     $row = $this->_frames[$key]["rows"][0];
247 247
 
248
-    if ( !isset($this->_columns[$col])) {
248
+    if (!isset($this->_columns[$col])) {
249 249
       $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
250 250
       $x = 0;
251 251
     } else
252 252
       $x = $this->_columns[$col]["x"];
253 253
 
254
-    if ( !isset($this->_rows[$row])) {
254
+    if (!isset($this->_rows[$row])) {
255 255
       $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
256 256
       $y = 0;
257 257
     } else
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
   function get_frame_width($frame) {
264 264
     $key = $frame->get_id();
265 265
 
266
-    if ( !isset($this->_frames[$key]) ) {
266
+    if (!isset($this->_frames[$key])) {
267 267
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
268 268
     }
269 269
 
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
   function get_frame_height($frame) {
280 280
     $key = $frame->get_id();
281 281
 
282
-    if ( !isset($this->_frames[$key]) )
282
+    if (!isset($this->_frames[$key]))
283 283
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
284 284
 
285 285
     $rows = $this->_frames[$key]["rows"];
286 286
     $h = 0;
287 287
     foreach ($rows as $i) {
288
-      if ( !isset($this->_rows[$i]) )  {
288
+      if (!isset($this->_rows[$i])) {
289 289
         throw new Exception("foo");
290 290
       }
291 291
       $h += $this->_rows[$i]["height"];
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
   //........................................................................
299 299
 
300 300
   function set_column_width($j, $width) {
301
-    $col =& $this->get_column($j);
301
+    $col = & $this->get_column($j);
302 302
     $col["used-width"] = $width;
303
-    $next_col =& $this->get_column($j+1);
303
+    $next_col = & $this->get_column($j + 1);
304 304
     $next_col["x"] = $next_col["x"] + $width;
305 305
   }
306 306
 
307 307
   function set_row_height($i, $height) {
308
-    $row =& $this->get_row($i);
309
-    if ( $height <= $row["height"] )
308
+    $row = & $this->get_row($i);
309
+    if ($height <= $row["height"])
310 310
       return;
311 311
 
312 312
     $row["height"] = $height;
313
-    $next_row =& $this->get_row($i+1);
313
+    $next_row = & $this->get_row($i + 1);
314 314
     $next_row["y"] = $row["y"] + $height;
315 315
 
316 316
   }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     $n_style = $border_spec["style"];
324 324
     $n_color = $border_spec["color"];
325 325
 
326
-    if ( !isset($this->_borders[$i][$j][$h_v]) ) {
326
+    if (!isset($this->_borders[$i][$j][$h_v])) {
327 327
       $this->_borders[$i][$j][$h_v] = $border_spec;
328 328
       return $this->_borders[$i][$j][$h_v]["width"];
329 329
     }
@@ -332,15 +332,15 @@  discard block
 block discarded – undo
332 332
     $o_style = $this->_borders[$i][$j][$h_v]["style"];
333 333
     $o_color = $this->_borders[$i][$j][$h_v]["color"];
334 334
 
335
-    if ( ($n_style === "hidden" ||
336
-          $n_width  >  $o_width ||
335
+    if (($n_style === "hidden" ||
336
+          $n_width > $o_width ||
337 337
           $o_style === "none")
338 338
 
339 339
          or
340 340
 
341 341
          ($o_width == $n_width &&
342 342
           in_array($n_style, self::$_BORDER_STYLE_SCORE) &&
343
-          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) )
343
+          self::$_BORDER_STYLE_SCORE[$n_style] > self::$_BORDER_STYLE_SCORE[$o_style]))
344 344
       $this->_borders[$i][$j][$h_v] = $border_spec;
345 345
 
346 346
     return $this->_borders[$i][$j][$h_v]["width"];
@@ -356,37 +356,37 @@  discard block
 block discarded – undo
356 356
     $collapse = $this->_table->get_style()->border_collapse == "collapse";
357 357
 
358 358
     // Recursively add the frames within tables, table-row-groups and table-rows
359
-    if ( $display == "table-row" ||
359
+    if ($display == "table-row" ||
360 360
          $display == "table" ||
361 361
          $display == "inline-table" ||
362
-         in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
362
+         in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) {
363 363
 
364 364
       $start_row = $this->__row;
365
-      foreach ( $frame->get_children() as $child )
366
-        $this->add_frame( $child );
365
+      foreach ($frame->get_children() as $child)
366
+        $this->add_frame($child);
367 367
 
368
-      if ( $display == "table-row" )
368
+      if ($display == "table-row")
369 369
         $this->add_row();
370 370
 
371 371
       $num_rows = $this->__row - $start_row - 1;
372 372
       $key = $frame->get_id();
373 373
 
374 374
       // Row groups always span across the entire table
375
-      $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1));
376
-      $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1));
377
-      $this->_frames[ $key ]["frame"] = $frame;
375
+      $this->_frames[$key]["columns"] = range(0, max(0, $this->_num_cols - 1));
376
+      $this->_frames[$key]["rows"] = range($start_row, max(0, $this->__row - 1));
377
+      $this->_frames[$key]["frame"] = $frame;
378 378
 
379
-      if ( $display != "table-row" && $collapse ) {
379
+      if ($display != "table-row" && $collapse) {
380 380
 
381 381
         $bp = $style->get_border_properties();
382 382
 
383 383
         // Resolve the borders
384
-        for ( $i = 0; $i < $num_rows+1; $i++) {
384
+        for ($i = 0; $i < $num_rows + 1; $i++) {
385 385
           $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]);
386 386
           $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]);
387 387
         }
388 388
 
389
-        for ( $j = 0; $j < $this->_num_cols; $j++) {
389
+        for ($j = 0; $j < $this->_num_cols; $j++) {
390 390
           $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]);
391 391
           $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]);
392 392
         }
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
     $colspan = $frame->get_node()->getAttribute("colspan");
401 401
     $rowspan = $frame->get_node()->getAttribute("rowspan");
402 402
 
403
-    if ( !$colspan ) {
403
+    if (!$colspan) {
404 404
       $colspan = 1;
405
-      $frame->get_node()->setAttribute("colspan",1);
405
+      $frame->get_node()->setAttribute("colspan", 1);
406 406
     }
407 407
 
408
-    if ( !$rowspan ) {
408
+    if (!$rowspan) {
409 409
       $rowspan = 1;
410
-      $frame->get_node()->setAttribute("rowspan",1);
410
+      $frame->get_node()->setAttribute("rowspan", 1);
411 411
     }
412 412
     $key = $frame->get_id();
413 413
 
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 
420 420
     // Find the next available column (fix by Ciro Mondueri)
421 421
     $ac = $this->__col;
422
-    while ( isset($this->_cells[$this->__row][$ac]) )
422
+    while (isset($this->_cells[$this->__row][$ac]))
423 423
        $ac++;
424 424
     $this->__col = $ac;
425 425
 
426 426
     // Rows:
427
-    for ( $i = 0; $i < $rowspan; $i++ ) {
427
+    for ($i = 0; $i < $rowspan; $i++) {
428 428
       $row = $this->__row + $i;
429 429
 
430
-      $this->_frames[ $key ]["rows"][] = $row;
430
+      $this->_frames[$key]["rows"][] = $row;
431 431
 
432
-      for ( $j = 0; $j < $colspan; $j++)
432
+      for ($j = 0; $j < $colspan; $j++)
433 433
         $this->_cells[$row][$this->__col + $j] = $frame;
434 434
 
435
-      if ( $collapse ) {
435
+      if ($collapse) {
436 436
         // Resolve vertical borders
437 437
         $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"]));
438 438
         $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"]));
@@ -442,21 +442,21 @@  discard block
 block discarded – undo
442 442
     $max_top = $max_bottom = 0;
443 443
 
444 444
     // Columns:
445
-    for ( $j = 0; $j < $colspan; $j++ ) {
445
+    for ($j = 0; $j < $colspan; $j++) {
446 446
       $col = $this->__col + $j;
447
-      $this->_frames[ $key ]["columns"][] = $col;
447
+      $this->_frames[$key]["columns"][] = $col;
448 448
 
449
-      if ( $collapse ) {
449
+      if ($collapse) {
450 450
         // Resolve horizontal borders
451 451
         $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"]));
452 452
         $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"]));
453 453
       }
454 454
     }
455 455
 
456
-    $this->_frames[ $key ]["frame"] = $frame;
456
+    $this->_frames[$key]["frame"] = $frame;
457 457
 
458 458
     // Handle seperated border model
459
-    if ( !$collapse ) {
459
+    if (!$collapse) {
460 460
       list($h, $v) = $this->_table->get_style()->border_spacing;
461 461
 
462 462
       // Border spacing is effectively a margin between cells
@@ -481,26 +481,26 @@  discard block
 block discarded – undo
481 481
 
482 482
     $width = $style->width;
483 483
 
484
-    if ( is_percent($width) ) {
484
+    if (is_percent($width)) {
485 485
       $var = "percent";
486
-      $val = (float)rtrim($width, "% ") / $colspan;
486
+      $val = (float) rtrim($width, "% ") / $colspan;
487 487
 
488
-    } else if ( $width !== "auto" ) {
488
+    } else if ($width !== "auto") {
489 489
       $var = "absolute";
490 490
       $val = $style->length_in_pt($frame_min) / $colspan;
491 491
     }
492 492
 
493 493
     $min = 0;
494 494
     $max = 0;
495
-    for ( $cs = 0; $cs < $colspan; $cs++ ) {
495
+    for ($cs = 0; $cs < $colspan; $cs++) {
496 496
 
497 497
       // Resolve the frame's width(s) with other cells
498
-      $col =& $this->get_column( $this->__col + $cs );
498
+      $col = & $this->get_column($this->__col + $cs);
499 499
 
500 500
       // Note: $var is either 'percent' or 'absolute'.  We compare the
501 501
       // requested percentage or absolute values with the existing widths
502 502
       // and adjust accordingly.
503
-      if ( isset($var) && $val > $col[$var] ) {
503
+      if (isset($var) && $val > $col[$var]) {
504 504
         $col[$var] = $val;
505 505
         $col["auto"] = false;
506 506
       }
@@ -510,25 +510,25 @@  discard block
 block discarded – undo
510 510
     }
511 511
 
512 512
 
513
-    if ( $frame_min > $min ) {
513
+    if ($frame_min > $min) {
514 514
       // The frame needs more space.  Expand each sub-column
515 515
       $inc = ($frame_min - $min) / $colspan;
516 516
       for ($c = 0; $c < $colspan; $c++) {
517
-        $col =& $this->get_column($this->__col + $c);
517
+        $col = & $this->get_column($this->__col + $c);
518 518
         $col["min-width"] += $inc;
519 519
       }
520 520
     }
521 521
 
522
-    if ( $frame_max > $max ) {
522
+    if ($frame_max > $max) {
523 523
       $inc = ($frame_max - $max) / $colspan;
524 524
       for ($c = 0; $c < $colspan; $c++) {
525
-        $col =& $this->get_column($this->__col + $c);
525
+        $col = & $this->get_column($this->__col + $c);
526 526
         $col["max-width"] += $inc;
527 527
       }
528 528
     }
529 529
 
530 530
     $this->__col += $colspan;
531
-    if ( $this->__col > $this->_num_cols )
531
+    if ($this->__col > $this->_num_cols)
532 532
       $this->_num_cols = $this->__col;
533 533
 
534 534
   }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 
543 543
     // Find the next available column
544 544
     $i = 0;
545
-    while ( isset($this->_cells[$this->__row][$i]) )
545
+    while (isset($this->_cells[$this->__row][$i]))
546 546
       $i++;
547 547
 
548 548
     $this->__col = $i;
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
   function remove_row(Frame $row) {
560 560
 
561 561
     $key = $row->get_id();
562
-    if ( !isset($this->_frames[$key]) )
563
-      return;  // Presumably this row has alredy been removed
562
+    if (!isset($this->_frames[$key]))
563
+      return; // Presumably this row has alredy been removed
564 564
 
565 565
     $this->_row = $this->_num_rows--;
566 566
 
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
     $columns = $this->_frames[$key]["columns"];
569 569
 
570 570
     // Remove all frames from this row
571
-    foreach ( $rows as $r ) {
572
-      foreach ( $columns as $c ) {
573
-        if ( isset($this->_cells[$r][$c]) ) {
571
+    foreach ($rows as $r) {
572
+      foreach ($columns as $c) {
573
+        if (isset($this->_cells[$r][$c])) {
574 574
           $frame = $this->_cells[$r][$c];
575
-          unset($this->_frames[ $frame->get_id() ]);
575
+          unset($this->_frames[$frame->get_id()]);
576 576
           unset($this->_cells[$r][$c]);
577 577
         }
578 578
       }
@@ -591,8 +591,8 @@  discard block
 block discarded – undo
591 591
   function remove_row_group(Frame $group) {
592 592
 
593 593
     $key = $group->get_id();
594
-    if ( !isset($this->_frames[$key]) )
595
-      return;  // Presumably this row has alredy been removed
594
+    if (!isset($this->_frames[$key]))
595
+      return; // Presumably this row has alredy been removed
596 596
 
597 597
     $iter = $group->get_first_child();
598 598
     while ($iter) {
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
     $r_key = $last_row->get_id();
616 616
 
617 617
     $r_rows = $this->_frames[$r_key]["rows"];
618
-    $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) );
618
+    $this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows));
619 619
 
620 620
   }
621 621
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     // column[0]["x"] must be set.
627 627
 
628 628
     $x = $this->_columns[0]["x"];
629
-    foreach ( array_keys($this->_columns) as $j ) {
629
+    foreach (array_keys($this->_columns) as $j) {
630 630
       $this->_columns[$j]["x"] = $x;
631 631
       $x += $this->_columns[$j]["used-width"];
632 632
 
@@ -638,18 +638,18 @@  discard block
 block discarded – undo
638 638
     // Pre-condition: widths and heights of each column & row must be
639 639
     // calcluated
640 640
 
641
-    foreach ( $this->_frames as $arr ) {
641
+    foreach ($this->_frames as $arr) {
642 642
       $frame = $arr["frame"];
643 643
 
644 644
       $h = 0;
645
-      foreach( $arr["rows"] as $row ) {
646
-        if ( !isset($this->_rows[$row]) )
645
+      foreach ($arr["rows"] as $row) {
646
+        if (!isset($this->_rows[$row]))
647 647
           // The row has been removed because of a page split, so skip it.
648 648
           continue;
649 649
         $h += $this->_rows[$row]["height"];
650 650
       }
651 651
 
652
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
652
+      if ($frame instanceof Table_Cell_Frame_Decorator)
653 653
         $frame->set_cell_height($h);
654 654
       else
655 655
         $frame->get_style()->height = $h;
@@ -666,12 +666,12 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
     // Distribute the increased height proportionally amongst each row
669
-    foreach ( $this->_frames as $arr ) {
669
+    foreach ($this->_frames as $arr) {
670 670
       $frame = $arr["frame"];
671 671
 
672 672
       $h = 0;
673
-      foreach ($arr["rows"] as $row ) {
674
-        if ( !isset($this->_rows[$row]) )
673
+      foreach ($arr["rows"] as $row) {
674
+        if (!isset($this->_rows[$row]))
675 675
           continue;
676 676
 
677 677
         $h += $this->_rows[$row]["height"];
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
       $new_height = ($h / $content_height) * $table_height;
681 681
 
682
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
682
+      if ($frame instanceof Table_Cell_Frame_Decorator)
683 683
         $frame->set_cell_height($new_height);
684 684
       else
685 685
         $frame->get_style()->height = $new_height;
@@ -694,19 +694,19 @@  discard block
 block discarded – undo
694 694
     $str = "";
695 695
     $str .= "Columns:<br/>";
696 696
     $str .= pre_r($this->_columns, true);
697
-    $str .=  "Rows:<br/>";
697
+    $str .= "Rows:<br/>";
698 698
     $str .= pre_r($this->_rows, true);
699 699
 
700
-    $str .=  "Frames:<br/>";
700
+    $str .= "Frames:<br/>";
701 701
     $arr = array();
702
-    foreach ( $this->_frames as $key => $val )
702
+    foreach ($this->_frames as $key => $val)
703 703
       $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
704 704
 
705 705
     $str .= pre_r($arr, true);
706 706
 
707
-    if ( php_sapi_name() == "cli" )
708
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
709
-                                    array("\n",chr(27)."[01;33m", chr(27)."[0m"),
707
+    if (php_sapi_name() == "cli")
708
+      $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"),
709
+                                    array("\n", chr(27)."[01;33m", chr(27)."[0m"),
710 710
                                     $str));
711 711
     return $str;
712 712
   }
Please login to merge, or discard this patch.
Braces   +78 added lines, -52 removed lines patch added patch discarded remove patch
@@ -170,14 +170,15 @@  discard block
 block discarded – undo
170 170
   }
171 171
 
172 172
   function &get_column($i) {
173
-    if ( !isset($this->_columns[$i]) )
174
-      $this->_columns[$i] = array("x" => 0,
173
+    if ( !isset($this->_columns[$i]) ) {
174
+          $this->_columns[$i] = array("x" => 0,
175 175
                                   "min-width" => 0,
176 176
                                   "max-width" => 0,
177 177
                                   "used-width" => null,
178 178
                                   "absolute" => 0,
179 179
                                   "percent" => 0,
180 180
                                   "auto" => true);
181
+    }
181 182
 
182 183
     return $this->_columns[$i];
183 184
   }
@@ -187,20 +188,23 @@  discard block
 block discarded – undo
187 188
   }
188 189
 
189 190
   function &get_row($j) {
190
-    if ( !isset($this->_rows[$j]) )
191
-      $this->_rows[$j] = array("y" => 0,
191
+    if ( !isset($this->_rows[$j]) ) {
192
+          $this->_rows[$j] = array("y" => 0,
192 193
                                "first-column" => 0,
193 194
                                "height" => null);
195
+    }
194 196
     return $this->_rows[$j];
195 197
   }
196 198
 
197 199
   function get_border($i, $j, $h_v, $prop = null) {
198
-    if ( !isset($this->_borders[$i][$j][$h_v]) )
199
-      $this->_borders[$i][$j][$h_v] = array("width" => 0,
200
+    if ( !isset($this->_borders[$i][$j][$h_v]) ) {
201
+          $this->_borders[$i][$j][$h_v] = array("width" => 0,
200 202
                                            "style" => "solid",
201 203
                                            "color" => "black");
202
-    if ( isset($prop) )
203
-      return $this->_borders[$i][$j][$h_v][$prop];
204
+    }
205
+    if ( isset($prop) ) {
206
+          return $this->_borders[$i][$j][$h_v][$prop];
207
+    }
204 208
 
205 209
     return $this->_borders[$i][$j][$h_v];
206 210
   }
@@ -248,14 +252,16 @@  discard block
 block discarded – undo
248 252
     if ( !isset($this->_columns[$col])) {
249 253
       $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
250 254
       $x = 0;
251
-    } else
252
-      $x = $this->_columns[$col]["x"];
255
+    } else {
256
+          $x = $this->_columns[$col]["x"];
257
+    }
253 258
 
254 259
     if ( !isset($this->_rows[$row])) {
255 260
       $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
256 261
       $y = 0;
257
-    } else
258
-      $y = $this->_rows[$row]["y"];
262
+    } else {
263
+          $y = $this->_rows[$row]["y"];
264
+    }
259 265
 
260 266
     return array($x, $y, "x" => $x, "y" => $y);
261 267
   }
@@ -269,8 +275,9 @@  discard block
 block discarded – undo
269 275
 
270 276
     $cols = $this->_frames[$key]["columns"];
271 277
     $w = 0;
272
-    foreach ($cols as $i)
273
-      $w += $this->_columns[$i]["used-width"];
278
+    foreach ($cols as $i) {
279
+          $w += $this->_columns[$i]["used-width"];
280
+    }
274 281
 
275 282
     return $w;
276 283
 
@@ -279,8 +286,9 @@  discard block
 block discarded – undo
279 286
   function get_frame_height($frame) {
280 287
     $key = $frame->get_id();
281 288
 
282
-    if ( !isset($this->_frames[$key]) )
283
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
289
+    if ( !isset($this->_frames[$key]) ) {
290
+          throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
291
+    }
284 292
 
285 293
     $rows = $this->_frames[$key]["rows"];
286 294
     $h = 0;
@@ -306,8 +314,9 @@  discard block
 block discarded – undo
306 314
 
307 315
   function set_row_height($i, $height) {
308 316
     $row =& $this->get_row($i);
309
-    if ( $height <= $row["height"] )
310
-      return;
317
+    if ( $height <= $row["height"] ) {
318
+          return;
319
+    }
311 320
 
312 321
     $row["height"] = $height;
313 322
     $next_row =& $this->get_row($i+1);
@@ -340,8 +349,9 @@  discard block
 block discarded – undo
340 349
 
341 350
          ($o_width == $n_width &&
342 351
           in_array($n_style, self::$_BORDER_STYLE_SCORE) &&
343
-          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) )
344
-      $this->_borders[$i][$j][$h_v] = $border_spec;
352
+          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) {
353
+          $this->_borders[$i][$j][$h_v] = $border_spec;
354
+    }
345 355
 
346 356
     return $this->_borders[$i][$j][$h_v]["width"];
347 357
   }
@@ -362,11 +372,13 @@  discard block
 block discarded – undo
362 372
          in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
363 373
 
364 374
       $start_row = $this->__row;
365
-      foreach ( $frame->get_children() as $child )
366
-        $this->add_frame( $child );
375
+      foreach ( $frame->get_children() as $child ) {
376
+              $this->add_frame( $child );
377
+      }
367 378
 
368
-      if ( $display == "table-row" )
369
-        $this->add_row();
379
+      if ( $display == "table-row" ) {
380
+              $this->add_row();
381
+      }
370 382
 
371 383
       $num_rows = $this->__row - $start_row - 1;
372 384
       $key = $frame->get_id();
@@ -419,8 +431,9 @@  discard block
 block discarded – undo
419 431
 
420 432
     // Find the next available column (fix by Ciro Mondueri)
421 433
     $ac = $this->__col;
422
-    while ( isset($this->_cells[$this->__row][$ac]) )
423
-       $ac++;
434
+    while ( isset($this->_cells[$this->__row][$ac]) ) {
435
+           $ac++;
436
+    }
424 437
     $this->__col = $ac;
425 438
 
426 439
     // Rows:
@@ -429,8 +442,9 @@  discard block
 block discarded – undo
429 442
 
430 443
       $this->_frames[ $key ]["rows"][] = $row;
431 444
 
432
-      for ( $j = 0; $j < $colspan; $j++)
433
-        $this->_cells[$row][$this->__col + $j] = $frame;
445
+      for ( $j = 0; $j < $colspan; $j++) {
446
+              $this->_cells[$row][$this->__col + $j] = $frame;
447
+      }
434 448
 
435 449
       if ( $collapse ) {
436 450
         // Resolve vertical borders
@@ -528,8 +542,9 @@  discard block
 block discarded – undo
528 542
     }
529 543
 
530 544
     $this->__col += $colspan;
531
-    if ( $this->__col > $this->_num_cols )
532
-      $this->_num_cols = $this->__col;
545
+    if ( $this->__col > $this->_num_cols ) {
546
+          $this->_num_cols = $this->__col;
547
+    }
533 548
 
534 549
   }
535 550
 
@@ -542,8 +557,9 @@  discard block
 block discarded – undo
542 557
 
543 558
     // Find the next available column
544 559
     $i = 0;
545
-    while ( isset($this->_cells[$this->__row][$i]) )
546
-      $i++;
560
+    while ( isset($this->_cells[$this->__row][$i]) ) {
561
+          $i++;
562
+    }
547 563
 
548 564
     $this->__col = $i;
549 565
 
@@ -559,8 +575,10 @@  discard block
 block discarded – undo
559 575
   function remove_row(Frame $row) {
560 576
 
561 577
     $key = $row->get_id();
562
-    if ( !isset($this->_frames[$key]) )
563
-      return;  // Presumably this row has alredy been removed
578
+    if ( !isset($this->_frames[$key]) ) {
579
+          return;
580
+    }
581
+    // Presumably this row has alredy been removed
564 582
 
565 583
     $this->_row = $this->_num_rows--;
566 584
 
@@ -591,8 +609,10 @@  discard block
 block discarded – undo
591 609
   function remove_row_group(Frame $group) {
592 610
 
593 611
     $key = $group->get_id();
594
-    if ( !isset($this->_frames[$key]) )
595
-      return;  // Presumably this row has alredy been removed
612
+    if ( !isset($this->_frames[$key]) ) {
613
+          return;
614
+    }
615
+    // Presumably this row has alredy been removed
596 616
 
597 617
     $iter = $group->get_first_child();
598 618
     while ($iter) {
@@ -643,16 +663,18 @@  discard block
 block discarded – undo
643 663
 
644 664
       $h = 0;
645 665
       foreach( $arr["rows"] as $row ) {
646
-        if ( !isset($this->_rows[$row]) )
647
-          // The row has been removed because of a page split, so skip it.
666
+        if ( !isset($this->_rows[$row]) ) {
667
+                  // The row has been removed because of a page split, so skip it.
648 668
           continue;
669
+        }
649 670
         $h += $this->_rows[$row]["height"];
650 671
       }
651 672
 
652
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
653
-        $frame->set_cell_height($h);
654
-      else
655
-        $frame->get_style()->height = $h;
673
+      if ( $frame instanceof Table_Cell_Frame_Decorator ) {
674
+              $frame->set_cell_height($h);
675
+      } else {
676
+              $frame->get_style()->height = $h;
677
+      }
656 678
     }
657 679
 
658 680
   }
@@ -671,18 +693,20 @@  discard block
 block discarded – undo
671 693
 
672 694
       $h = 0;
673 695
       foreach ($arr["rows"] as $row ) {
674
-        if ( !isset($this->_rows[$row]) )
675
-          continue;
696
+        if ( !isset($this->_rows[$row]) ) {
697
+                  continue;
698
+        }
676 699
 
677 700
         $h += $this->_rows[$row]["height"];
678 701
       }
679 702
 
680 703
       $new_height = ($h / $content_height) * $table_height;
681 704
 
682
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
683
-        $frame->set_cell_height($new_height);
684
-      else
685
-        $frame->get_style()->height = $new_height;
705
+      if ( $frame instanceof Table_Cell_Frame_Decorator ) {
706
+              $frame->set_cell_height($new_height);
707
+      } else {
708
+              $frame->get_style()->height = $new_height;
709
+      }
686 710
     }
687 711
 
688 712
   }
@@ -699,15 +723,17 @@  discard block
 block discarded – undo
699 723
 
700 724
     $str .=  "Frames:<br/>";
701 725
     $arr = array();
702
-    foreach ( $this->_frames as $key => $val )
703
-      $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
726
+    foreach ( $this->_frames as $key => $val ) {
727
+          $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
728
+    }
704 729
 
705 730
     $str .= pre_r($arr, true);
706 731
 
707
-    if ( php_sapi_name() == "cli" )
708
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
732
+    if ( php_sapi_name() == "cli" ) {
733
+          $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
709 734
                                     array("\n",chr(27)."[01;33m", chr(27)."[0m"),
710 735
                                     $str));
736
+    }
711 737
     return $str;
712 738
   }
713 739
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/cpdf_adapter.cls.php 5 patches
Doc Comments   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -461,6 +461,8 @@  discard block
 block discarded – undo
461 461
    * @param string cap
462 462
    * @param string join
463 463
    * @param array dash
464
+   * @param string $cap
465
+   * @param string $join
464 466
    */
465 467
   protected function _set_line_style($width, $cap, $join, $dash) {
466 468
     $this->_pdf->setLineStyle($width, $cap, $join, $dash);
@@ -496,6 +498,7 @@  discard block
 block discarded – undo
496 498
   /**
497 499
    * Convert a GIF image to a PNG image
498 500
    *
501
+   * @param string $image_url
499 502
    * @return string The url of the newly converted image
500 503
    */
501 504
   protected function _convert_gif_to_png($image_url) {
@@ -775,8 +778,8 @@  discard block
 block discarded – undo
775 778
    * @param string $font the font file to use
776 779
    * @param float $size the font size, in points
777 780
    * @param array $color
778
-   * @param float $adjust word spacing adjustment
779
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
781
+   * @param integer $adjust word spacing adjustment
782
+   * @param integer $angle angle to write the text at, measured CW starting from the x-axis
780 783
    */
781 784
   function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
782 785
                      $adjust = 0, $angle = 0) {
Please login to merge, or discard this patch.
Switch Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -595,56 +595,56 @@  discard block
 block discarded – undo
595 595
     $img_type = mb_strtolower($img_type);
596 596
 
597 597
     switch ($img_type) {
598
-    case "jpeg":
599
-    case "jpg":
600
-      //debugpng
601
-      if (DEBUGPNG)  print '!!!jpg!!!';
598
+        case "jpeg":
599
+        case "jpg":
600
+          //debugpng
601
+          if (DEBUGPNG)  print '!!!jpg!!!';
602 602
 
603
-      $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
-      break;
603
+          $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
+          break;
605 605
 
606
-    case "png":
607
-      //debugpng
608
-      if (DEBUGPNG)  print '!!!png!!!';
609
-
610
-      $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
-      break;
612
-
613
-    case "gif":
614
-      // Convert gifs to pngs
615
-      //DEBUG_IMG_TEMP
616
-      //if (0) {
617
-      if ( method_exists( $this->_pdf, "addImagePng" ) ) {
618
-        //debugpng
619
-        if (DEBUGPNG)  print '!!!gif addImagePng!!!';
620
-
621
-      	//If optimization to direct png creation from gd object is available,
622
-        //don't create temp file, but place gd object directly into the pdf
623
-	    if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
-	         $this->_pdf->image_iscached($img_url) ) {
625
-	      //If same image has occured already before, no need to load because
626
-	      //duplicate will anyway be eliminated.
627
-	      $img = null;
628
-	    } else {
629
-    	  $img = @imagecreatefromgif($img_url);
630
-    	  if (!$img) {
631
-      	    return;
632
-    	  }
633
-    	  imageinterlace($img, 0);
634
-    	}
635
-    	$this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
-      } else {
637
-        //debugpng
638
-        if (DEBUGPNG)  print '!!!gif addPngFromFile!!!';
639
-        $img_url = $this->_convert_gif_to_png($img_url);
640
-        $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
641
-      }
642
-      break;
606
+        case "png":
607
+          //debugpng
608
+          if (DEBUGPNG)  print '!!!png!!!';
643 609
 
644
-    default:
645
-      //debugpng
646
-      if (DEBUGPNG) print '!!!unknown!!!';
647
-      break;
610
+          $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
+          break;
612
+
613
+        case "gif":
614
+          // Convert gifs to pngs
615
+          //DEBUG_IMG_TEMP
616
+          //if (0) {
617
+          if ( method_exists( $this->_pdf, "addImagePng" ) ) {
618
+            //debugpng
619
+            if (DEBUGPNG)  print '!!!gif addImagePng!!!';
620
+
621
+      	    //If optimization to direct png creation from gd object is available,
622
+            //don't create temp file, but place gd object directly into the pdf
623
+	        if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
+	             $this->_pdf->image_iscached($img_url) ) {
625
+	          //If same image has occured already before, no need to load because
626
+	          //duplicate will anyway be eliminated.
627
+	          $img = null;
628
+	        } else {
629
+    	      $img = @imagecreatefromgif($img_url);
630
+    	      if (!$img) {
631
+      	        return;
632
+    	      }
633
+    	      imageinterlace($img, 0);
634
+    	    }
635
+    	    $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
+          } else {
637
+            //debugpng
638
+            if (DEBUGPNG)  print '!!!gif addPngFromFile!!!';
639
+            $img_url = $this->_convert_gif_to_png($img_url);
640
+            $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
641
+          }
642
+          break;
643
+
644
+        default:
645
+          //debugpng
646
+          if (DEBUGPNG) print '!!!unknown!!!';
647
+          break;
648 648
     }
649 649
     
650 650
     return;
@@ -833,18 +833,18 @@  discard block
 block discarded – undo
833 833
 
834 834
         switch ($_t) {
835 835
             
836
-        case "text":
837
-        $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
838
-                            array($page_number, $this->_page_count), $text);
839
-        $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
840
-          break;
836
+            case "text":
837
+            $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
838
+                                array($page_number, $this->_page_count), $text);
839
+            $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
840
+              break;
841 841
           
842
-        case "script":
843
-          if (!$eval) {
844
-            $eval = new PHP_Evaluator($this);
845
-          }
846
-          $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
-          break;
842
+            case "script":
843
+              if (!$eval) {
844
+                $eval = new PHP_Evaluator($this);
845
+              }
846
+              $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
+              break;
848 848
         }
849 849
       }
850 850
 
Please login to merge, or discard this patch.
Spacing   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
 /* $Id: cpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
56 56
 
57 57
 // FIXME: Need to sanity check inputs to this class
58
-require_once(DOMPDF_LIB_DIR . "/class.pdf.php");
58
+require_once(DOMPDF_LIB_DIR."/class.pdf.php");
59 59
 
60 60
 /**
61 61
  * PDF rendering interface
@@ -79,62 +79,62 @@  discard block
 block discarded – undo
79 79
    *
80 80
    * @var array;
81 81
    */
82
-  static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79),
83
-                              "2a0" => array(0,0,3370.39,4767.87),
84
-                              "a0" => array(0,0,2383.94,3370.39),
85
-                              "a1" => array(0,0,1683.78,2383.94),
86
-                              "a2" => array(0,0,1190.55,1683.78),
87
-                              "a3" => array(0,0,841.89,1190.55),
88
-                              "a4" => array(0,0,595.28,841.89),
89
-                              "a5" => array(0,0,419.53,595.28),
90
-                              "a6" => array(0,0,297.64,419.53),
91
-                              "a7" => array(0,0,209.76,297.64),
92
-                              "a8" => array(0,0,147.40,209.76),
93
-                              "a9" => array(0,0,104.88,147.40),
94
-                              "a10" => array(0,0,73.70,104.88),
95
-                              "b0" => array(0,0,2834.65,4008.19),
96
-                              "b1" => array(0,0,2004.09,2834.65),
97
-                              "b2" => array(0,0,1417.32,2004.09),
98
-                              "b3" => array(0,0,1000.63,1417.32),
99
-                              "b4" => array(0,0,708.66,1000.63),
100
-                              "b5" => array(0,0,498.90,708.66),
101
-                              "b6" => array(0,0,354.33,498.90),
102
-                              "b7" => array(0,0,249.45,354.33),
103
-                              "b8" => array(0,0,175.75,249.45),
104
-                              "b9" => array(0,0,124.72,175.75),
105
-                              "b10" => array(0,0,87.87,124.72),
106
-                              "c0" => array(0,0,2599.37,3676.54),
107
-                              "c1" => array(0,0,1836.85,2599.37),
108
-                              "c2" => array(0,0,1298.27,1836.85),
109
-                              "c3" => array(0,0,918.43,1298.27),
110
-                              "c4" => array(0,0,649.13,918.43),
111
-                              "c5" => array(0,0,459.21,649.13),
112
-                              "c6" => array(0,0,323.15,459.21),
113
-                              "c7" => array(0,0,229.61,323.15),
114
-                              "c8" => array(0,0,161.57,229.61),
115
-                              "c9" => array(0,0,113.39,161.57),
116
-                              "c10" => array(0,0,79.37,113.39),
117
-                              "ra0" => array(0,0,2437.80,3458.27),
118
-                              "ra1" => array(0,0,1729.13,2437.80),
119
-                              "ra2" => array(0,0,1218.90,1729.13),
120
-                              "ra3" => array(0,0,864.57,1218.90),
121
-                              "ra4" => array(0,0,609.45,864.57),
122
-                              "sra0" => array(0,0,2551.18,3628.35),
123
-                              "sra1" => array(0,0,1814.17,2551.18),
124
-                              "sra2" => array(0,0,1275.59,1814.17),
125
-                              "sra3" => array(0,0,907.09,1275.59),
126
-                              "sra4" => array(0,0,637.80,907.09),
127
-                              "letter" => array(0,0,612.00,792.00),
128
-                              "legal" => array(0,0,612.00,1008.00),
129
-                              "ledger" => array(0,0,1224.00, 792.00),
130
-                              "tabloid" => array(0,0,792.00, 1224.00),
131
-                              "executive" => array(0,0,521.86,756.00),
132
-                              "folio" => array(0,0,612.00,936.00),
133
-                              "commerical #10 envelope" => array(0,0,684,297),
134
-                              "catalog #10 1/2 envelope" => array(0,0,648,864),
135
-                              "8.5x11" => array(0,0,612.00,792.00),
136
-                              "8.5x14" => array(0,0,612.00,1008.0),
137
-                              "11x17"  => array(0,0,792.00, 1224.00));
82
+  static $PAPER_SIZES = array("4a0" => array(0, 0, 4767.87, 6740.79),
83
+                              "2a0" => array(0, 0, 3370.39, 4767.87),
84
+                              "a0" => array(0, 0, 2383.94, 3370.39),
85
+                              "a1" => array(0, 0, 1683.78, 2383.94),
86
+                              "a2" => array(0, 0, 1190.55, 1683.78),
87
+                              "a3" => array(0, 0, 841.89, 1190.55),
88
+                              "a4" => array(0, 0, 595.28, 841.89),
89
+                              "a5" => array(0, 0, 419.53, 595.28),
90
+                              "a6" => array(0, 0, 297.64, 419.53),
91
+                              "a7" => array(0, 0, 209.76, 297.64),
92
+                              "a8" => array(0, 0, 147.40, 209.76),
93
+                              "a9" => array(0, 0, 104.88, 147.40),
94
+                              "a10" => array(0, 0, 73.70, 104.88),
95
+                              "b0" => array(0, 0, 2834.65, 4008.19),
96
+                              "b1" => array(0, 0, 2004.09, 2834.65),
97
+                              "b2" => array(0, 0, 1417.32, 2004.09),
98
+                              "b3" => array(0, 0, 1000.63, 1417.32),
99
+                              "b4" => array(0, 0, 708.66, 1000.63),
100
+                              "b5" => array(0, 0, 498.90, 708.66),
101
+                              "b6" => array(0, 0, 354.33, 498.90),
102
+                              "b7" => array(0, 0, 249.45, 354.33),
103
+                              "b8" => array(0, 0, 175.75, 249.45),
104
+                              "b9" => array(0, 0, 124.72, 175.75),
105
+                              "b10" => array(0, 0, 87.87, 124.72),
106
+                              "c0" => array(0, 0, 2599.37, 3676.54),
107
+                              "c1" => array(0, 0, 1836.85, 2599.37),
108
+                              "c2" => array(0, 0, 1298.27, 1836.85),
109
+                              "c3" => array(0, 0, 918.43, 1298.27),
110
+                              "c4" => array(0, 0, 649.13, 918.43),
111
+                              "c5" => array(0, 0, 459.21, 649.13),
112
+                              "c6" => array(0, 0, 323.15, 459.21),
113
+                              "c7" => array(0, 0, 229.61, 323.15),
114
+                              "c8" => array(0, 0, 161.57, 229.61),
115
+                              "c9" => array(0, 0, 113.39, 161.57),
116
+                              "c10" => array(0, 0, 79.37, 113.39),
117
+                              "ra0" => array(0, 0, 2437.80, 3458.27),
118
+                              "ra1" => array(0, 0, 1729.13, 2437.80),
119
+                              "ra2" => array(0, 0, 1218.90, 1729.13),
120
+                              "ra3" => array(0, 0, 864.57, 1218.90),
121
+                              "ra4" => array(0, 0, 609.45, 864.57),
122
+                              "sra0" => array(0, 0, 2551.18, 3628.35),
123
+                              "sra1" => array(0, 0, 1814.17, 2551.18),
124
+                              "sra2" => array(0, 0, 1275.59, 1814.17),
125
+                              "sra3" => array(0, 0, 907.09, 1275.59),
126
+                              "sra4" => array(0, 0, 637.80, 907.09),
127
+                              "letter" => array(0, 0, 612.00, 792.00),
128
+                              "legal" => array(0, 0, 612.00, 1008.00),
129
+                              "ledger" => array(0, 0, 1224.00, 792.00),
130
+                              "tabloid" => array(0, 0, 792.00, 1224.00),
131
+                              "executive" => array(0, 0, 521.86, 756.00),
132
+                              "folio" => array(0, 0, 612.00, 936.00),
133
+                              "commerical #10 envelope" => array(0, 0, 684, 297),
134
+                              "catalog #10 1/2 envelope" => array(0, 0, 648, 864),
135
+                              "8.5x11" => array(0, 0, 612.00, 792.00),
136
+                              "8.5x14" => array(0, 0, 612.00, 1008.0),
137
+                              "11x17"  => array(0, 0, 792.00, 1224.00));
138 138
 
139 139
 
140 140
   /**
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
    */
202 202
   function __construct($paper = "letter", $orientation = "portrait") {
203 203
 
204
-    if ( is_array($paper) )
204
+    if (is_array($paper))
205 205
       $size = $paper;
206
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
206
+    else if (isset(self::$PAPER_SIZES[mb_strtolower($paper)]))
207 207
       $size = self::$PAPER_SIZES[mb_strtolower($paper)];
208 208
     else
209 209
       $size = self::$PAPER_SIZES["letter"];
210 210
 
211
-    if ( mb_strtolower($orientation) === "landscape" ) {
211
+    if (mb_strtolower($orientation) === "landscape") {
212 212
       $a = $size[3];
213 213
       $size[3] = $size[2];
214 214
       $size[2] = $a;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     
225 225
 
226 226
     $this->_width = $size[2] - $size[0];
227
-    $this->_height= $size[3] - $size[1];
227
+    $this->_height = $size[3] - $size[1];
228 228
     $this->_pdf->openHere('Fit');
229 229
     
230 230
     $this->_page_number = $this->_page_count = 1;
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
    */
501 501
   protected function _convert_gif_to_png($image_url) {
502 502
     
503
-    if ( !function_exists("imagecreatefromgif") ) {
503
+    if (!function_exists("imagecreatefromgif")) {
504 504
       throw new DOMPDF_Exception("Function imagecreatefromgif() not found.  Cannot convert gif image: $image_url.  Please install the image PHP extension.");
505 505
     }
506 506
 
507 507
     $old_err = set_error_handler("record_warnings");
508 508
     $im = imagecreatefromgif($image_url);
509 509
 
510
-    if ( $im ) {
510
+    if ($im) {
511 511
       imageinterlace($im, 0);
512 512
 
513 513
       $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png';
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
       imagepng($im, $filename);
517 517
 
518 518
     } else {
519
-      $filename = DOMPDF_LIB_DIR . "/res/broken_image.png";
519
+      $filename = DOMPDF_LIB_DIR."/res/broken_image.png";
520 520
 
521 521
     }
522 522
 
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
     $this->_set_line_transparency($blend, $opacity);
560 560
     $this->_set_fill_transparency($blend, $opacity);
561 561
     
562
-    if ( !$fill && isset($width) )
562
+    if (!$fill && isset($width))
563 563
       $this->_set_line_style($width, "square", "miter", $style);
564 564
     
565 565
     // Adjust y values
566
-    for ( $i = 1; $i < count($points); $i += 2)
566
+    for ($i = 1; $i < count($points); $i += 2)
567 567
       $points[$i] = $this->y($points[$i]);
568 568
     
569 569
     $this->_pdf->polygon($points, count($points) / 2, $fill);
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     $this->_set_line_transparency($blend, $opacity);
581 581
     $this->_set_fill_transparency($blend, $opacity);
582 582
 
583
-    if ( !$fill && isset($width) )
583
+    if (!$fill && isset($width))
584 584
       $this->_set_line_style($width, "round", "round", $style);
585 585
 
586 586
     $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill);
@@ -614,14 +614,14 @@  discard block
 block discarded – undo
614 614
       // Convert gifs to pngs
615 615
       //DEBUG_IMG_TEMP
616 616
       //if (0) {
617
-      if ( method_exists( $this->_pdf, "addImagePng" ) ) {
617
+      if (method_exists($this->_pdf, "addImagePng")) {
618 618
         //debugpng
619 619
         if (DEBUGPNG)  print '!!!gif addImagePng!!!';
620 620
 
621 621
       	//If optimization to direct png creation from gd object is available,
622 622
         //don't create temp file, but place gd object directly into the pdf
623
-	    if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
-	         $this->_pdf->image_iscached($img_url) ) {
623
+	    if (method_exists($this->_pdf, "image_iscached") &&
624
+	         $this->_pdf->image_iscached($img_url)) {
625 625
 	      //If same image has occured already before, no need to load because
626 626
 	      //duplicate will anyway be eliminated.
627 627
 	      $img = null;
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 
653 653
   //........................................................................
654 654
 
655
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0),
655
+  function text($x, $y, $text, $font, $size, $color = array(0, 0, 0),
656 656
                 $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) {
657 657
 
658 658
     list($r, $g, $b) = $color;
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
     //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust);
696 696
 	//$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
697 697
 	//$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
698
-	$this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust);
698
+	$this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3] * $size) / 1000, $size, $text, $angle, $adjust);
699 699
   }
700 700
 
701 701
   //........................................................................
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
    * @param string $anchorname The name of the named destination
713 713
    */
714 714
   function add_named_dest($anchorname) {
715
-    $this->_pdf->addDestination($anchorname,"Fit");
715
+    $this->_pdf->addDestination($anchorname, "Fit");
716 716
   }
717 717
 
718 718
   //........................................................................
@@ -730,10 +730,10 @@  discard block
 block discarded – undo
730 730
 
731 731
     $y = $this->y($y) - $height;
732 732
 
733
-    if ( strpos($url, '#') === 0 ) {
733
+    if (strpos($url, '#') === 0) {
734 734
       // Local link
735
-      $name = substr($url,1);
736
-      if ( $name )
735
+      $name = substr($url, 1);
736
+      if ($name)
737 737
         $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
738 738
 
739 739
     } else {
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
    * @param float $adjust word spacing adjustment
779 779
    * @param float $angle angle to write the text at, measured CW starting from the x-axis
780 780
    */
781
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
781
+  function page_text($x, $y, $text, $font, $size, $color = array(0, 0, 0),
782 782
                      $adjust = 0, $angle = 0) {
783 783
     $_t = "text";
784 784
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
    */
820 820
   protected function _add_page_text() {
821 821
     
822
-    if ( !count($this->_page_text) )
822
+    if (!count($this->_page_text))
823 823
       return;
824 824
 
825 825
     $page_number = 1;
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
         switch ($_t) {
835 835
             
836 836
         case "text":
837
-        $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
837
+        $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"),
838 838
                             array($page_number, $this->_page_count), $text);
839 839
         $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
840 840
           break;
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
     // Add page text
879 879
     $this->_add_page_text();
880 880
 
881
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
881
+    if (isset($options["compress"]) && $options["compress"] != 1)
882 882
       $debug = 1;
883 883
     else
884 884
       $debug = 0;
Please login to merge, or discard this patch.
Braces   +51 added lines, -29 removed lines patch added patch discarded remove patch
@@ -201,12 +201,13 @@  discard block
 block discarded – undo
201 201
    */
202 202
   function __construct($paper = "letter", $orientation = "portrait") {
203 203
 
204
-    if ( is_array($paper) )
205
-      $size = $paper;
206
-    else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
207
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
208
-    else
209
-      $size = self::$PAPER_SIZES["letter"];
204
+    if ( is_array($paper) ) {
205
+          $size = $paper;
206
+    } else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) ) {
207
+          $size = self::$PAPER_SIZES[mb_strtolower($paper)];
208
+    } else {
209
+          $size = self::$PAPER_SIZES["letter"];
210
+    }
210 211
 
211 212
     if ( mb_strtolower($orientation) === "landscape" ) {
212 213
       $a = $size[3];
@@ -243,9 +244,12 @@  discard block
 block discarded – undo
243 244
   function __destruct() {
244 245
     foreach ($this->_image_cache as $img) {
245 246
       //debugpng
246
-      if (DEBUGPNG) print '[__destruct unlink '.$img.']';
247
-      if (!DEBUGKEEPTEMP)
248
-        unlink($img);
247
+      if (DEBUGPNG) {
248
+          print '[__destruct unlink '.$img.']';
249
+      }
250
+      if (!DEBUGKEEPTEMP) {
251
+              unlink($img);
252
+      }
249 253
     }
250 254
   }
251 255
   
@@ -559,12 +563,14 @@  discard block
 block discarded – undo
559 563
     $this->_set_line_transparency($blend, $opacity);
560 564
     $this->_set_fill_transparency($blend, $opacity);
561 565
     
562
-    if ( !$fill && isset($width) )
563
-      $this->_set_line_style($width, "square", "miter", $style);
566
+    if ( !$fill && isset($width) ) {
567
+          $this->_set_line_style($width, "square", "miter", $style);
568
+    }
564 569
     
565 570
     // Adjust y values
566
-    for ( $i = 1; $i < count($points); $i += 2)
567
-      $points[$i] = $this->y($points[$i]);
571
+    for ( $i = 1; $i < count($points); $i += 2) {
572
+          $points[$i] = $this->y($points[$i]);
573
+    }
568 574
     
569 575
     $this->_pdf->polygon($points, count($points) / 2, $fill);
570 576
   }
@@ -580,8 +586,9 @@  discard block
 block discarded – undo
580 586
     $this->_set_line_transparency($blend, $opacity);
581 587
     $this->_set_fill_transparency($blend, $opacity);
582 588
 
583
-    if ( !$fill && isset($width) )
584
-      $this->_set_line_style($width, "round", "round", $style);
589
+    if ( !$fill && isset($width) ) {
590
+          $this->_set_line_style($width, "round", "round", $style);
591
+    }
585 592
 
586 593
     $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill);
587 594
   }
@@ -590,7 +597,9 @@  discard block
 block discarded – undo
590 597
 
591 598
   function image($img_url, $img_type, $x, $y, $w, $h) {
592 599
     //debugpng
593
-    if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']';
600
+    if (DEBUGPNG) {
601
+        print '[image:'.$img_url.'|'.$img_type.']';
602
+    }
594 603
 
595 604
     $img_type = mb_strtolower($img_type);
596 605
 
@@ -598,14 +607,18 @@  discard block
 block discarded – undo
598 607
     case "jpeg":
599 608
     case "jpg":
600 609
       //debugpng
601
-      if (DEBUGPNG)  print '!!!jpg!!!';
610
+      if (DEBUGPNG) {
611
+          print '!!!jpg!!!';
612
+      }
602 613
 
603 614
       $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604 615
       break;
605 616
 
606 617
     case "png":
607 618
       //debugpng
608
-      if (DEBUGPNG)  print '!!!png!!!';
619
+      if (DEBUGPNG) {
620
+          print '!!!png!!!';
621
+      }
609 622
 
610 623
       $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611 624
       break;
@@ -616,7 +629,9 @@  discard block
 block discarded – undo
616 629
       //if (0) {
617 630
       if ( method_exists( $this->_pdf, "addImagePng" ) ) {
618 631
         //debugpng
619
-        if (DEBUGPNG)  print '!!!gif addImagePng!!!';
632
+        if (DEBUGPNG) {
633
+            print '!!!gif addImagePng!!!';
634
+        }
620 635
 
621 636
       	//If optimization to direct png creation from gd object is available,
622 637
         //don't create temp file, but place gd object directly into the pdf
@@ -635,7 +650,9 @@  discard block
 block discarded – undo
635 650
     	$this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636 651
       } else {
637 652
         //debugpng
638
-        if (DEBUGPNG)  print '!!!gif addPngFromFile!!!';
653
+        if (DEBUGPNG) {
654
+            print '!!!gif addPngFromFile!!!';
655
+        }
639 656
         $img_url = $this->_convert_gif_to_png($img_url);
640 657
         $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
641 658
       }
@@ -643,7 +660,9 @@  discard block
 block discarded – undo
643 660
 
644 661
     default:
645 662
       //debugpng
646
-      if (DEBUGPNG) print '!!!unknown!!!';
663
+      if (DEBUGPNG) {
664
+          print '!!!unknown!!!';
665
+      }
647 666
       break;
648 667
     }
649 668
     
@@ -733,8 +752,9 @@  discard block
 block discarded – undo
733 752
     if ( strpos($url, '#') === 0 ) {
734 753
       // Local link
735 754
       $name = substr($url,1);
736
-      if ( $name )
737
-        $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
755
+      if ( $name ) {
756
+              $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
757
+      }
738 758
 
739 759
     } else {
740 760
       $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
@@ -819,8 +839,9 @@  discard block
 block discarded – undo
819 839
    */
820 840
   protected function _add_page_text() {
821 841
     
822
-    if ( !count($this->_page_text) )
823
-      return;
842
+    if ( !count($this->_page_text) ) {
843
+          return;
844
+    }
824 845
 
825 846
     $page_number = 1;
826 847
     $eval = null;
@@ -878,10 +899,11 @@  discard block
 block discarded – undo
878 899
     // Add page text
879 900
     $this->_add_page_text();
880 901
 
881
-    if ( isset($options["compress"]) && $options["compress"] != 1 )
882
-      $debug = 1;
883
-    else
884
-      $debug = 0;
902
+    if ( isset($options["compress"]) && $options["compress"] != 1 ) {
903
+          $debug = 1;
904
+    } else {
905
+          $debug = 0;
906
+    }
885 907
     
886 908
     return $this->_pdf->output($debug);
887 909
     
Please login to merge, or discard this patch.
Indentation   +575 added lines, -575 removed lines patch added patch discarded remove patch
@@ -1,56 +1,56 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: cpdf_adapter.cls.php,v $
6
- * Created on: 2004-08-04
7
- * Modified on: 2008-01-05
8
- *
9
- * Copyright (c) 2004 - Benj Carson <[email protected]>
10
- * Portions copyright (c) 2008 - Orion Richardson <[email protected]>
11
- *
12
- * This library is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU Lesser General Public
14
- * License as published by the Free Software Foundation; either
15
- * version 2.1 of the License, or (at your option) any later version.
16
- *
17
- * This library is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
- * Lesser General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU Lesser General Public License
23
- * along with this library in the file LICENSE.LGPL; if not, write to the
24
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25
- * 02111-1307 USA
26
- *
27
- * Alternatively, you may distribute this software under the terms of the
28
- * PHP License, version 3.0 or later.  A copy of this license should have
29
- * been distributed with this file in the file LICENSE.PHP .  If this is not
30
- * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
31
- *
32
- * The latest version of DOMPDF might be available at:
33
- * http://www.dompdf.com/
34
- *
35
- * @link http://www.dompdf.com/
36
- * @copyright 2004 Benj Carson
37
- * @author Benj Carson <[email protected]>
38
- * @contributor Orion Richardson <[email protected]>
39
- * @contributor Helmut Tischer <[email protected]>
40
- * @package dompdf
41
- *
42
- * Changes
43
- * @contributor Helmut Tischer <[email protected]>
44
- * @version 0.5.1.htischer.20090507
45
- * - On gif to png conversion tmp file creation, clarify tmp name and add to tmp deletion list only on success
46
- * - On gif to png conversion, when available add direct from gd without tmp file, skip image load if already cached.
47
- *   to safe CPU time and memory
48
- * @contributor Helmut Tischer <[email protected]>
49
- * @version dompdf_trunk_with_helmut_mods.20090524
50
- * - Pass temp and fontcache folders to Cpdf, to making Cpdf independent from dompdf
51
- * @version dompdf_trunk_with_helmut_mods.20090528
52
- * - fix text position according to glyph baseline to match background rectangle
53
- */
3
+     * DOMPDF - PHP5 HTML to PDF renderer
4
+     *
5
+     * File: $RCSfile: cpdf_adapter.cls.php,v $
6
+     * Created on: 2004-08-04
7
+     * Modified on: 2008-01-05
8
+     *
9
+     * Copyright (c) 2004 - Benj Carson <[email protected]>
10
+     * Portions copyright (c) 2008 - Orion Richardson <[email protected]>
11
+     *
12
+     * This library is free software; you can redistribute it and/or
13
+     * modify it under the terms of the GNU Lesser General Public
14
+     * License as published by the Free Software Foundation; either
15
+     * version 2.1 of the License, or (at your option) any later version.
16
+     *
17
+     * This library is distributed in the hope that it will be useful,
18
+     * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
+     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20
+     * Lesser General Public License for more details.
21
+     *
22
+     * You should have received a copy of the GNU Lesser General Public License
23
+     * along with this library in the file LICENSE.LGPL; if not, write to the
24
+     * Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
25
+     * 02111-1307 USA
26
+     *
27
+     * Alternatively, you may distribute this software under the terms of the
28
+     * PHP License, version 3.0 or later.  A copy of this license should have
29
+     * been distributed with this file in the file LICENSE.PHP .  If this is not
30
+     * the case, you can obtain a copy at http://www.php.net/license/3_0.txt.
31
+     *
32
+     * The latest version of DOMPDF might be available at:
33
+     * http://www.dompdf.com/
34
+     *
35
+     * @link http://www.dompdf.com/
36
+     * @copyright 2004 Benj Carson
37
+     * @author Benj Carson <[email protected]>
38
+     * @contributor Orion Richardson <[email protected]>
39
+     * @contributor Helmut Tischer <[email protected]>
40
+     * @package dompdf
41
+     *
42
+     * Changes
43
+     * @contributor Helmut Tischer <[email protected]>
44
+     * @version 0.5.1.htischer.20090507
45
+     * - On gif to png conversion tmp file creation, clarify tmp name and add to tmp deletion list only on success
46
+     * - On gif to png conversion, when available add direct from gd without tmp file, skip image load if already cached.
47
+     *   to safe CPU time and memory
48
+     * @contributor Helmut Tischer <[email protected]>
49
+     * @version dompdf_trunk_with_helmut_mods.20090524
50
+     * - Pass temp and fontcache folders to Cpdf, to making Cpdf independent from dompdf
51
+     * @version dompdf_trunk_with_helmut_mods.20090528
52
+     * - fix text position according to glyph baseline to match background rectangle
53
+     */
54 54
 
55 55
 /* $Id: cpdf_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
56 56
 
@@ -74,144 +74,144 @@  discard block
 block discarded – undo
74 74
  */
75 75
 class CPDF_Adapter implements Canvas {
76 76
 
77
-  /**
78
-   * Dimensions of paper sizes in points
79
-   *
80
-   * @var array;
81
-   */
82
-  static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79),
83
-                              "2a0" => array(0,0,3370.39,4767.87),
84
-                              "a0" => array(0,0,2383.94,3370.39),
85
-                              "a1" => array(0,0,1683.78,2383.94),
86
-                              "a2" => array(0,0,1190.55,1683.78),
87
-                              "a3" => array(0,0,841.89,1190.55),
88
-                              "a4" => array(0,0,595.28,841.89),
89
-                              "a5" => array(0,0,419.53,595.28),
90
-                              "a6" => array(0,0,297.64,419.53),
91
-                              "a7" => array(0,0,209.76,297.64),
92
-                              "a8" => array(0,0,147.40,209.76),
93
-                              "a9" => array(0,0,104.88,147.40),
94
-                              "a10" => array(0,0,73.70,104.88),
95
-                              "b0" => array(0,0,2834.65,4008.19),
96
-                              "b1" => array(0,0,2004.09,2834.65),
97
-                              "b2" => array(0,0,1417.32,2004.09),
98
-                              "b3" => array(0,0,1000.63,1417.32),
99
-                              "b4" => array(0,0,708.66,1000.63),
100
-                              "b5" => array(0,0,498.90,708.66),
101
-                              "b6" => array(0,0,354.33,498.90),
102
-                              "b7" => array(0,0,249.45,354.33),
103
-                              "b8" => array(0,0,175.75,249.45),
104
-                              "b9" => array(0,0,124.72,175.75),
105
-                              "b10" => array(0,0,87.87,124.72),
106
-                              "c0" => array(0,0,2599.37,3676.54),
107
-                              "c1" => array(0,0,1836.85,2599.37),
108
-                              "c2" => array(0,0,1298.27,1836.85),
109
-                              "c3" => array(0,0,918.43,1298.27),
110
-                              "c4" => array(0,0,649.13,918.43),
111
-                              "c5" => array(0,0,459.21,649.13),
112
-                              "c6" => array(0,0,323.15,459.21),
113
-                              "c7" => array(0,0,229.61,323.15),
114
-                              "c8" => array(0,0,161.57,229.61),
115
-                              "c9" => array(0,0,113.39,161.57),
116
-                              "c10" => array(0,0,79.37,113.39),
117
-                              "ra0" => array(0,0,2437.80,3458.27),
118
-                              "ra1" => array(0,0,1729.13,2437.80),
119
-                              "ra2" => array(0,0,1218.90,1729.13),
120
-                              "ra3" => array(0,0,864.57,1218.90),
121
-                              "ra4" => array(0,0,609.45,864.57),
122
-                              "sra0" => array(0,0,2551.18,3628.35),
123
-                              "sra1" => array(0,0,1814.17,2551.18),
124
-                              "sra2" => array(0,0,1275.59,1814.17),
125
-                              "sra3" => array(0,0,907.09,1275.59),
126
-                              "sra4" => array(0,0,637.80,907.09),
127
-                              "letter" => array(0,0,612.00,792.00),
128
-                              "legal" => array(0,0,612.00,1008.00),
129
-                              "ledger" => array(0,0,1224.00, 792.00),
130
-                              "tabloid" => array(0,0,792.00, 1224.00),
131
-                              "executive" => array(0,0,521.86,756.00),
132
-                              "folio" => array(0,0,612.00,936.00),
133
-                              "commerical #10 envelope" => array(0,0,684,297),
134
-                              "catalog #10 1/2 envelope" => array(0,0,648,864),
135
-                              "8.5x11" => array(0,0,612.00,792.00),
136
-                              "8.5x14" => array(0,0,612.00,1008.0),
137
-                              "11x17"  => array(0,0,792.00, 1224.00));
138
-
139
-
140
-  /**
141
-   * Instance of Cpdf class
142
-   *
143
-   * @var Cpdf
144
-   */
145
-  private $_pdf;
146
-
147
-  /**
148
-   * PDF width, in points
149
-   *
150
-   * @var float
151
-   */
152
-  private $_width;
153
-
154
-  /**
155
-   * PDF height, in points
156
-   *
157
-   * @var float;
158
-   */
159
-  private $_height;
160
-
161
-  /**
162
-   * Current page number
163
-   *
164
-   * @var int
165
-   */
166
-  private $_page_number;
167
-
168
-  /**
169
-   * Total number of pages
170
-   *
171
-   * @var int
172
-   */
173
-  private $_page_count;
174
-
175
-  /**
176
-   * Text to display on every page
177
-   *
178
-   * @var array
179
-   */
180
-  private $_page_text;
181
-
182
-  /**
183
-   * Array of pages for accesing after rendering is initially complete
184
-   *
185
-   * @var array
186
-   */
187
-  private $_pages;
188
-
189
-  /**
190
-   * Array of temporary cached images to be deleted when processing is complete
191
-   *
192
-   * @var array
193
-   */
194
-  private $_image_cache;
77
+    /**
78
+     * Dimensions of paper sizes in points
79
+     *
80
+     * @var array;
81
+     */
82
+    static $PAPER_SIZES = array("4a0" => array(0,0,4767.87,6740.79),
83
+                                "2a0" => array(0,0,3370.39,4767.87),
84
+                                "a0" => array(0,0,2383.94,3370.39),
85
+                                "a1" => array(0,0,1683.78,2383.94),
86
+                                "a2" => array(0,0,1190.55,1683.78),
87
+                                "a3" => array(0,0,841.89,1190.55),
88
+                                "a4" => array(0,0,595.28,841.89),
89
+                                "a5" => array(0,0,419.53,595.28),
90
+                                "a6" => array(0,0,297.64,419.53),
91
+                                "a7" => array(0,0,209.76,297.64),
92
+                                "a8" => array(0,0,147.40,209.76),
93
+                                "a9" => array(0,0,104.88,147.40),
94
+                                "a10" => array(0,0,73.70,104.88),
95
+                                "b0" => array(0,0,2834.65,4008.19),
96
+                                "b1" => array(0,0,2004.09,2834.65),
97
+                                "b2" => array(0,0,1417.32,2004.09),
98
+                                "b3" => array(0,0,1000.63,1417.32),
99
+                                "b4" => array(0,0,708.66,1000.63),
100
+                                "b5" => array(0,0,498.90,708.66),
101
+                                "b6" => array(0,0,354.33,498.90),
102
+                                "b7" => array(0,0,249.45,354.33),
103
+                                "b8" => array(0,0,175.75,249.45),
104
+                                "b9" => array(0,0,124.72,175.75),
105
+                                "b10" => array(0,0,87.87,124.72),
106
+                                "c0" => array(0,0,2599.37,3676.54),
107
+                                "c1" => array(0,0,1836.85,2599.37),
108
+                                "c2" => array(0,0,1298.27,1836.85),
109
+                                "c3" => array(0,0,918.43,1298.27),
110
+                                "c4" => array(0,0,649.13,918.43),
111
+                                "c5" => array(0,0,459.21,649.13),
112
+                                "c6" => array(0,0,323.15,459.21),
113
+                                "c7" => array(0,0,229.61,323.15),
114
+                                "c8" => array(0,0,161.57,229.61),
115
+                                "c9" => array(0,0,113.39,161.57),
116
+                                "c10" => array(0,0,79.37,113.39),
117
+                                "ra0" => array(0,0,2437.80,3458.27),
118
+                                "ra1" => array(0,0,1729.13,2437.80),
119
+                                "ra2" => array(0,0,1218.90,1729.13),
120
+                                "ra3" => array(0,0,864.57,1218.90),
121
+                                "ra4" => array(0,0,609.45,864.57),
122
+                                "sra0" => array(0,0,2551.18,3628.35),
123
+                                "sra1" => array(0,0,1814.17,2551.18),
124
+                                "sra2" => array(0,0,1275.59,1814.17),
125
+                                "sra3" => array(0,0,907.09,1275.59),
126
+                                "sra4" => array(0,0,637.80,907.09),
127
+                                "letter" => array(0,0,612.00,792.00),
128
+                                "legal" => array(0,0,612.00,1008.00),
129
+                                "ledger" => array(0,0,1224.00, 792.00),
130
+                                "tabloid" => array(0,0,792.00, 1224.00),
131
+                                "executive" => array(0,0,521.86,756.00),
132
+                                "folio" => array(0,0,612.00,936.00),
133
+                                "commerical #10 envelope" => array(0,0,684,297),
134
+                                "catalog #10 1/2 envelope" => array(0,0,648,864),
135
+                                "8.5x11" => array(0,0,612.00,792.00),
136
+                                "8.5x14" => array(0,0,612.00,1008.0),
137
+                                "11x17"  => array(0,0,792.00, 1224.00));
138
+
139
+
140
+    /**
141
+     * Instance of Cpdf class
142
+     *
143
+     * @var Cpdf
144
+     */
145
+    private $_pdf;
146
+
147
+    /**
148
+     * PDF width, in points
149
+     *
150
+     * @var float
151
+     */
152
+    private $_width;
153
+
154
+    /**
155
+     * PDF height, in points
156
+     *
157
+     * @var float;
158
+     */
159
+    private $_height;
160
+
161
+    /**
162
+     * Current page number
163
+     *
164
+     * @var int
165
+     */
166
+    private $_page_number;
167
+
168
+    /**
169
+     * Total number of pages
170
+     *
171
+     * @var int
172
+     */
173
+    private $_page_count;
174
+
175
+    /**
176
+     * Text to display on every page
177
+     *
178
+     * @var array
179
+     */
180
+    private $_page_text;
181
+
182
+    /**
183
+     * Array of pages for accesing after rendering is initially complete
184
+     *
185
+     * @var array
186
+     */
187
+    private $_pages;
188
+
189
+    /**
190
+     * Array of temporary cached images to be deleted when processing is complete
191
+     *
192
+     * @var array
193
+     */
194
+    private $_image_cache;
195 195
   
196
-  /**
197
-   * Class constructor
198
-   *
199
-   * @param mixed  $paper  The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES})
200
-   * @param string $orientation The orienation of the document (either 'landscape' or 'portrait')
201
-   */
202
-  function __construct($paper = "letter", $orientation = "portrait") {
196
+    /**
197
+     * Class constructor
198
+     *
199
+     * @param mixed  $paper  The size of paper to use in this PDF ({@link CPDF_Adapter::$PAPER_SIZES})
200
+     * @param string $orientation The orienation of the document (either 'landscape' or 'portrait')
201
+     */
202
+    function __construct($paper = "letter", $orientation = "portrait") {
203 203
 
204 204
     if ( is_array($paper) )
205
-      $size = $paper;
205
+        $size = $paper;
206 206
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
207
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
207
+        $size = self::$PAPER_SIZES[mb_strtolower($paper)];
208 208
     else
209
-      $size = self::$PAPER_SIZES["letter"];
209
+        $size = self::$PAPER_SIZES["letter"];
210 210
 
211 211
     if ( mb_strtolower($orientation) === "landscape" ) {
212
-      $a = $size[3];
213
-      $size[3] = $size[2];
214
-      $size[2] = $a;
212
+        $a = $size[3];
213
+        $size[3] = $size[2];
214
+        $size[2] = $a;
215 215
     }
216 216
     
217 217
     $this->_pdf = new Cpdf($size, DOMPDF_UNICODE_ENABLED, DOMPDF_FONT_CACHE, DOMPDF_TEMP_DIR);
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 
220 220
     // Silence pedantic warnings about missing TZ settings
221 221
     $time = substr_replace(date('YmdHisO'), '\'', (0 - 2), 0).'\'';
222
-	$this->_pdf->addInfo("CreationDate", "D:".$time);
223
-	$this->_pdf->addInfo("ModDate", "D:".$time);
222
+    $this->_pdf->addInfo("CreationDate", "D:".$time);
223
+    $this->_pdf->addInfo("ModDate", "D:".$time);
224 224
     
225 225
 
226 226
     $this->_width = $size[2] - $size[0];
@@ -233,253 +233,253 @@  discard block
 block discarded – undo
233 233
     $this->_pages = array($this->_pdf->getFirstPageId());
234 234
 
235 235
     $this->_image_cache = array();
236
-  }
237
-
238
-  /**
239
-   * Class destructor
240
-   *
241
-   * Deletes all temporary image files
242
-   */
243
-  function __destruct() {
236
+    }
237
+
238
+    /**
239
+     * Class destructor
240
+     *
241
+     * Deletes all temporary image files
242
+     */
243
+    function __destruct() {
244 244
     foreach ($this->_image_cache as $img) {
245
-      //debugpng
246
-      if (DEBUGPNG) print '[__destruct unlink '.$img.']';
247
-      if (!DEBUGKEEPTEMP)
245
+        //debugpng
246
+        if (DEBUGPNG) print '[__destruct unlink '.$img.']';
247
+        if (!DEBUGKEEPTEMP)
248 248
         unlink($img);
249 249
     }
250
-  }
250
+    }
251 251
   
252
-  /**
253
-   * Returns the Cpdf instance
254
-   *
255
-   * @return Cpdf
256
-   */
257
-  function get_cpdf() { return $this->_pdf; }
258
-
259
-  /**
260
-   * Add meta information to the PDF
261
-   *
262
-   * @param string $label  label of the value (Creator, Producter, etc.)
263
-   * @param string $value  the text to set
264
-   */
265
-  function add_info($label, $value) {
252
+    /**
253
+     * Returns the Cpdf instance
254
+     *
255
+     * @return Cpdf
256
+     */
257
+    function get_cpdf() { return $this->_pdf; }
258
+
259
+    /**
260
+     * Add meta information to the PDF
261
+     *
262
+     * @param string $label  label of the value (Creator, Producter, etc.)
263
+     * @param string $value  the text to set
264
+     */
265
+    function add_info($label, $value) {
266 266
     $this->_pdf->addInfo($label, $value);
267
-  }
268
-
269
-  /**
270
-   * Opens a new 'object'
271
-   *
272
-   * While an object is open, all drawing actions are recored in the object,
273
-   * as opposed to being drawn on the current page.  Objects can be added
274
-   * later to a specific page or to several pages.
275
-   *
276
-   * The return value is an integer ID for the new object.
277
-   *
278
-   * @see CPDF_Adapter::close_object()
279
-   * @see CPDF_Adapter::add_object()
280
-   *
281
-   * @return int
282
-   */
283
-  function open_object() {
267
+    }
268
+
269
+    /**
270
+     * Opens a new 'object'
271
+     *
272
+     * While an object is open, all drawing actions are recored in the object,
273
+     * as opposed to being drawn on the current page.  Objects can be added
274
+     * later to a specific page or to several pages.
275
+     *
276
+     * The return value is an integer ID for the new object.
277
+     *
278
+     * @see CPDF_Adapter::close_object()
279
+     * @see CPDF_Adapter::add_object()
280
+     *
281
+     * @return int
282
+     */
283
+    function open_object() {
284 284
     $ret = $this->_pdf->openObject();
285 285
     $this->_pdf->saveState();
286 286
     return $ret;
287
-  }
288
-
289
-  /**
290
-   * Reopens an existing 'object'
291
-   *
292
-   * @see CPDF_Adapter::open_object()
293
-   * @param int $object  the ID of a previously opened object
294
-   */
295
-  function reopen_object($object) {
287
+    }
288
+
289
+    /**
290
+     * Reopens an existing 'object'
291
+     *
292
+     * @see CPDF_Adapter::open_object()
293
+     * @param int $object  the ID of a previously opened object
294
+     */
295
+    function reopen_object($object) {
296 296
     $this->_pdf->reopenObject($object);
297 297
     $this->_pdf->saveState();
298
-  }
299
-
300
-  /**
301
-   * Closes the current 'object'
302
-   *
303
-   * @see CPDF_Adapter::open_object()
304
-   */
305
-  function close_object() {
298
+    }
299
+
300
+    /**
301
+     * Closes the current 'object'
302
+     *
303
+     * @see CPDF_Adapter::open_object()
304
+     */
305
+    function close_object() {
306 306
     $this->_pdf->restoreState();
307 307
     $this->_pdf->closeObject();
308
-  }
309
-
310
-  /**
311
-   * Adds a specified 'object' to the document
312
-   *
313
-   * $object int specifying an object created with {@link
314
-   * CPDF_Adapter::open_object()}.  $where can be one of:
315
-   * - 'add' add to current page only
316
-   * - 'all' add to every page from the current one onwards
317
-   * - 'odd' add to all odd numbered pages from now on
318
-   * - 'even' add to all even numbered pages from now on
319
-   * - 'next' add the object to the next page only
320
-   * - 'nextodd' add to all odd numbered pages from the next one
321
-   * - 'nexteven' add to all even numbered pages from the next one
322
-   *
323
-   * @see Cpdf::addObject()
324
-   *
325
-   * @param int $object
326
-   * @param string $where
327
-   */
328
-  function add_object($object, $where = 'all') {
308
+    }
309
+
310
+    /**
311
+     * Adds a specified 'object' to the document
312
+     *
313
+     * $object int specifying an object created with {@link
314
+     * CPDF_Adapter::open_object()}.  $where can be one of:
315
+     * - 'add' add to current page only
316
+     * - 'all' add to every page from the current one onwards
317
+     * - 'odd' add to all odd numbered pages from now on
318
+     * - 'even' add to all even numbered pages from now on
319
+     * - 'next' add the object to the next page only
320
+     * - 'nextodd' add to all odd numbered pages from the next one
321
+     * - 'nexteven' add to all even numbered pages from the next one
322
+     *
323
+     * @see Cpdf::addObject()
324
+     *
325
+     * @param int $object
326
+     * @param string $where
327
+     */
328
+    function add_object($object, $where = 'all') {
329 329
     $this->_pdf->addObject($object, $where);
330
-  }
331
-
332
-  /**
333
-   * Stops the specified 'object' from appearing in the document.
334
-   *
335
-   * The object will stop being displayed on the page following the current
336
-   * one.
337
-   *
338
-   * @param int $object
339
-   */
340
-  function stop_object($object) {
330
+    }
331
+
332
+    /**
333
+     * Stops the specified 'object' from appearing in the document.
334
+     *
335
+     * The object will stop being displayed on the page following the current
336
+     * one.
337
+     *
338
+     * @param int $object
339
+     */
340
+    function stop_object($object) {
341 341
     $this->_pdf->stopObject($object);
342
-  }
342
+    }
343 343
 
344
-  /**
345
-   * @access private
346
-   */
347
-  function serialize_object($id) {
344
+    /**
345
+     * @access private
346
+     */
347
+    function serialize_object($id) {
348 348
     // Serialize the pdf object's current state for retrieval later
349 349
     return $this->_pdf->serializeObject($id);
350
-  }
350
+    }
351 351
 
352
-  /**
353
-   * @access private
354
-   */
355
-  function reopen_serialized_object($obj) {
352
+    /**
353
+     * @access private
354
+     */
355
+    function reopen_serialized_object($obj) {
356 356
     return $this->_pdf->restoreSerializedObject($obj);
357
-  }
357
+    }
358 358
     
359
-  //........................................................................
360
-
361
-  /**
362
-   * Returns the PDF's width in points
363
-   * @return float
364
-   */
365
-  function get_width() { return $this->_width; }
366
-
367
-  /**
368
-   * Returns the PDF's height in points
369
-   * @return float
370
-   */
371
-  function get_height() { return $this->_height; }
372
-
373
-  /**
374
-   * Returns the current page number
375
-   * @return int
376
-   */
377
-  function get_page_number() { return $this->_page_number; }
378
-
379
-  /**
380
-   * Returns the total number of pages in the document
381
-   * @return int
382
-   */
383
-  function get_page_count() { return $this->_page_count; }
384
-
385
-  /**
386
-   * Sets the current page number
387
-   *
388
-   * @param int $num
389
-   */
390
-  function set_page_number($num) { $this->_page_number = $num; }
391
-
392
-  /**
393
-   * Sets the page count
394
-   *
395
-   * @param int $count
396
-   */
397
-  function set_page_count($count) {  $this->_page_count = $count; }
359
+    //........................................................................
360
+
361
+    /**
362
+     * Returns the PDF's width in points
363
+     * @return float
364
+     */
365
+    function get_width() { return $this->_width; }
366
+
367
+    /**
368
+     * Returns the PDF's height in points
369
+     * @return float
370
+     */
371
+    function get_height() { return $this->_height; }
372
+
373
+    /**
374
+     * Returns the current page number
375
+     * @return int
376
+     */
377
+    function get_page_number() { return $this->_page_number; }
378
+
379
+    /**
380
+     * Returns the total number of pages in the document
381
+     * @return int
382
+     */
383
+    function get_page_count() { return $this->_page_count; }
384
+
385
+    /**
386
+     * Sets the current page number
387
+     *
388
+     * @param int $num
389
+     */
390
+    function set_page_number($num) { $this->_page_number = $num; }
391
+
392
+    /**
393
+     * Sets the page count
394
+     *
395
+     * @param int $count
396
+     */
397
+    function set_page_count($count) {  $this->_page_count = $count; }
398 398
     
399
-  /**
400
-   * Sets the stroke colour
401
-   *
402
-   * See {@link Style::set_colour()} for the format of the color array.
403
-   * @param array $color
404
-   */
405
-  protected function _set_stroke_color($color) {
399
+    /**
400
+     * Sets the stroke colour
401
+     *
402
+     * See {@link Style::set_colour()} for the format of the color array.
403
+     * @param array $color
404
+     */
405
+    protected function _set_stroke_color($color) {
406 406
     list($r, $g, $b) = $color;
407 407
     $this->_pdf->setStrokeColor($r, $g, $b);
408
-  }
408
+    }
409 409
   
410
-  /**
411
-   * Sets the fill colour
412
-   *
413
-   * See {@link Style::set_colour()} for the format of the colour array.
414
-   * @param array $color
415
-   */
416
-  protected function _set_fill_color($color) {
410
+    /**
411
+     * Sets the fill colour
412
+     *
413
+     * See {@link Style::set_colour()} for the format of the colour array.
414
+     * @param array $color
415
+     */
416
+    protected function _set_fill_color($color) {
417 417
     list($r, $g, $b) = $color;
418 418
     $this->_pdf->setColor($r, $g, $b);
419
-  }
420
-
421
-  /**
422
-   * Sets line transparency
423
-   * @see Cpdf::setLineTransparency()
424
-   *
425
-   * Valid blend modes are (case-sensitive):
426
-   *
427
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
428
-   * ColorDodge, ColorBurn, HardLight, SoftLight, Difference,
429
-   * Exclusion
430
-   *
431
-   * @param string $mode the blending mode to use
432
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
433
-   */
434
-  protected function _set_line_transparency($mode, $opacity) {
419
+    }
420
+
421
+    /**
422
+     * Sets line transparency
423
+     * @see Cpdf::setLineTransparency()
424
+     *
425
+     * Valid blend modes are (case-sensitive):
426
+     *
427
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
428
+     * ColorDodge, ColorBurn, HardLight, SoftLight, Difference,
429
+     * Exclusion
430
+     *
431
+     * @param string $mode the blending mode to use
432
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
433
+     */
434
+    protected function _set_line_transparency($mode, $opacity) {
435 435
     $this->_pdf->setLineTransparency($mode, $opacity);
436
-  }
436
+    }
437 437
   
438
-  /**
439
-   * Sets fill transparency
440
-   * @see Cpdf::setFillTransparency()
441
-   *
442
-   * Valid blend modes are (case-sensitive):
443
-   *
444
-   * Normal, Multiply, Screen, Overlay, Darken, Lighten,
445
-   * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
446
-   * Exclusion
447
-   *
448
-   * @param string $mode the blending mode to use
449
-   * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
450
-   */
451
-  protected function _set_fill_transparency($mode, $opacity) {
438
+    /**
439
+     * Sets fill transparency
440
+     * @see Cpdf::setFillTransparency()
441
+     *
442
+     * Valid blend modes are (case-sensitive):
443
+     *
444
+     * Normal, Multiply, Screen, Overlay, Darken, Lighten,
445
+     * ColorDogde, ColorBurn, HardLight, SoftLight, Difference,
446
+     * Exclusion
447
+     *
448
+     * @param string $mode the blending mode to use
449
+     * @param float $opacity 0.0 fully transparent, 1.0 fully opaque
450
+     */
451
+    protected function _set_fill_transparency($mode, $opacity) {
452 452
     $this->_pdf->setFillTransparency($mode, $opacity);
453
-  }
454
-
455
-  /**
456
-   * Sets the line style
457
-   *
458
-   * @see Cpdf::setLineStyle()
459
-   *
460
-   * @param float width
461
-   * @param string cap
462
-   * @param string join
463
-   * @param array dash
464
-   */
465
-  protected function _set_line_style($width, $cap, $join, $dash) {
453
+    }
454
+
455
+    /**
456
+     * Sets the line style
457
+     *
458
+     * @see Cpdf::setLineStyle()
459
+     *
460
+     * @param float width
461
+     * @param string cap
462
+     * @param string join
463
+     * @param array dash
464
+     */
465
+    protected function _set_line_style($width, $cap, $join, $dash) {
466 466
     $this->_pdf->setLineStyle($width, $cap, $join, $dash);
467
-  }
467
+    }
468 468
   
469
-  //........................................................................
469
+    //........................................................................
470 470
 
471 471
   
472
-  /**
473
-   * Remaps y coords from 4th to 1st quadrant
474
-   *
475
-   * @param float $y
476
-   * @return float
477
-   */
478
-  protected function y($y) { return $this->_height - $y; }
472
+    /**
473
+     * Remaps y coords from 4th to 1st quadrant
474
+     *
475
+     * @param float $y
476
+     * @return float
477
+     */
478
+    protected function y($y) { return $this->_height - $y; }
479 479
 
480
-  // Canvas implementation
480
+    // Canvas implementation
481 481
 
482
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = array(),
482
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = array(),
483 483
                 $blend = "Normal", $opacity = 1.0) {
484 484
     //pre_r(compact("x1", "y1", "x2", "y2", "color", "width", "style"));
485 485
 
@@ -488,35 +488,35 @@  discard block
 block discarded – undo
488 488
     $this->_set_line_transparency($blend, $opacity);
489 489
     
490 490
     $this->_pdf->line($x1, $this->y($y1),
491
-                      $x2, $this->y($y2));
492
-  }
491
+                        $x2, $this->y($y2));
492
+    }
493 493
                               
494
-  //........................................................................
495
-
496
-  /**
497
-   * Convert a GIF image to a PNG image
498
-   *
499
-   * @return string The url of the newly converted image
500
-   */
501
-  protected function _convert_gif_to_png($image_url) {
494
+    //........................................................................
495
+
496
+    /**
497
+     * Convert a GIF image to a PNG image
498
+     *
499
+     * @return string The url of the newly converted image
500
+     */
501
+    protected function _convert_gif_to_png($image_url) {
502 502
     
503 503
     if ( !function_exists("imagecreatefromgif") ) {
504
-      throw new DOMPDF_Exception("Function imagecreatefromgif() not found.  Cannot convert gif image: $image_url.  Please install the image PHP extension.");
504
+        throw new DOMPDF_Exception("Function imagecreatefromgif() not found.  Cannot convert gif image: $image_url.  Please install the image PHP extension.");
505 505
     }
506 506
 
507 507
     $old_err = set_error_handler("record_warnings");
508 508
     $im = imagecreatefromgif($image_url);
509 509
 
510 510
     if ( $im ) {
511
-      imageinterlace($im, 0);
511
+        imageinterlace($im, 0);
512 512
 
513
-      $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png';
514
-      $this->_image_cache[] = $filename;
513
+        $filename = tempnam(DOMPDF_TEMP_DIR, "gifdompdf_img_").'.png';
514
+        $this->_image_cache[] = $filename;
515 515
 
516
-      imagepng($im, $filename);
516
+        imagepng($im, $filename);
517 517
 
518 518
     } else {
519
-      $filename = DOMPDF_LIB_DIR . "/res/broken_image.png";
519
+        $filename = DOMPDF_LIB_DIR . "/res/broken_image.png";
520 520
 
521 521
     }
522 522
 
@@ -524,21 +524,21 @@  discard block
 block discarded – undo
524 524
 
525 525
     return $filename;
526 526
     
527
-  }
527
+    }
528 528
 
529
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(),
530
-                     $blend = "Normal", $opacity = 1.0) {
529
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = array(),
530
+                        $blend = "Normal", $opacity = 1.0) {
531 531
 
532 532
     $this->_set_stroke_color($color);
533 533
     $this->_set_line_style($width, "square", "miter", $style);
534 534
     $this->_set_line_transparency($blend, $opacity);
535 535
     
536 536
     $this->_pdf->rectangle($x1, $this->y($y1) - $h, $w, $h);
537
-  }
537
+    }
538 538
 
539
-  //........................................................................
539
+    //........................................................................
540 540
   
541
-  function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) {
541
+    function filled_rectangle($x1, $y1, $w, $h, $color, $blend = "Normal", $opacity = 1.0) {
542 542
 
543 543
     $this->_set_fill_color($color);
544 544
     $this->_set_line_style(1, "square", "miter", array());
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
     $this->_set_fill_transparency($blend, $opacity);
547 547
     
548 548
     $this->_pdf->filledRectangle($x1, $this->y($y1) - $h, $w, $h);
549
-  }
549
+    }
550 550
 
551
-  //........................................................................
551
+    //........................................................................
552 552
 
553
-  function polygon($points, $color, $width = null, $style = array(),
554
-                   $fill = false, $blend = "Normal", $opacity = 1.0) {
553
+    function polygon($points, $color, $width = null, $style = array(),
554
+                    $fill = false, $blend = "Normal", $opacity = 1.0) {
555 555
 
556 556
     $this->_set_fill_color($color);
557 557
     $this->_set_stroke_color($color);
@@ -560,19 +560,19 @@  discard block
 block discarded – undo
560 560
     $this->_set_fill_transparency($blend, $opacity);
561 561
     
562 562
     if ( !$fill && isset($width) )
563
-      $this->_set_line_style($width, "square", "miter", $style);
563
+        $this->_set_line_style($width, "square", "miter", $style);
564 564
     
565 565
     // Adjust y values
566 566
     for ( $i = 1; $i < count($points); $i += 2)
567
-      $points[$i] = $this->y($points[$i]);
567
+        $points[$i] = $this->y($points[$i]);
568 568
     
569 569
     $this->_pdf->polygon($points, count($points) / 2, $fill);
570
-  }
570
+    }
571 571
 
572
-  //........................................................................
572
+    //........................................................................
573 573
 
574
-  function circle($x, $y, $r1, $color, $width = null, $style = null,
575
-                  $fill = false, $blend = "Normal", $opacity = 1.0) {
574
+    function circle($x, $y, $r1, $color, $width = null, $style = null,
575
+                    $fill = false, $blend = "Normal", $opacity = 1.0) {
576 576
 
577 577
     $this->_set_fill_color($color);
578 578
     $this->_set_stroke_color($color);
@@ -581,14 +581,14 @@  discard block
 block discarded – undo
581 581
     $this->_set_fill_transparency($blend, $opacity);
582 582
 
583 583
     if ( !$fill && isset($width) )
584
-      $this->_set_line_style($width, "round", "round", $style);
584
+        $this->_set_line_style($width, "round", "round", $style);
585 585
 
586 586
     $this->_pdf->ellipse($x, $this->y($y), $r1, 0, 0, 8, 0, 360, 1, $fill);
587
-  }
587
+    }
588 588
   
589
-  //........................................................................
589
+    //........................................................................
590 590
 
591
-  function image($img_url, $img_type, $x, $y, $w, $h) {
591
+    function image($img_url, $img_type, $x, $y, $w, $h) {
592 592
     //debugpng
593 593
     if (DEBUGPNG) print '[image:'.$img_url.'|'.$img_type.']';
594 594
 
@@ -600,15 +600,15 @@  discard block
 block discarded – undo
600 600
       //debugpng
601 601
       if (DEBUGPNG)  print '!!!jpg!!!';
602 602
 
603
-      $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
-      break;
603
+        $this->_pdf->addJpegFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
604
+        break;
605 605
 
606 606
     case "png":
607 607
       //debugpng
608 608
       if (DEBUGPNG)  print '!!!png!!!';
609 609
 
610
-      $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
-      break;
610
+        $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
611
+        break;
612 612
 
613 613
     case "gif":
614 614
       // Convert gifs to pngs
@@ -618,41 +618,41 @@  discard block
 block discarded – undo
618 618
         //debugpng
619 619
         if (DEBUGPNG)  print '!!!gif addImagePng!!!';
620 620
 
621
-      	//If optimization to direct png creation from gd object is available,
621
+            //If optimization to direct png creation from gd object is available,
622 622
         //don't create temp file, but place gd object directly into the pdf
623
-	    if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
-	         $this->_pdf->image_iscached($img_url) ) {
625
-	      //If same image has occured already before, no need to load because
626
-	      //duplicate will anyway be eliminated.
627
-	      $img = null;
628
-	    } else {
629
-    	  $img = @imagecreatefromgif($img_url);
630
-    	  if (!$img) {
631
-      	    return;
632
-    	  }
633
-    	  imageinterlace($img, 0);
634
-    	}
635
-    	$this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
-      } else {
623
+        if ( method_exists( $this->_pdf, "image_iscached" ) &&
624
+             $this->_pdf->image_iscached($img_url) ) {
625
+            //If same image has occured already before, no need to load because
626
+            //duplicate will anyway be eliminated.
627
+            $img = null;
628
+        } else {
629
+            $img = @imagecreatefromgif($img_url);
630
+            if (!$img) {
631
+                return;
632
+            }
633
+            imageinterlace($img, 0);
634
+        }
635
+        $this->_pdf->addImagePng($img_url, $x, $this->y($y) - $h, $w, $h, $img);
636
+        } else {
637 637
         //debugpng
638 638
         if (DEBUGPNG)  print '!!!gif addPngFromFile!!!';
639 639
         $img_url = $this->_convert_gif_to_png($img_url);
640 640
         $this->_pdf->addPngFromFile($img_url, $x, $this->y($y) - $h, $w, $h);
641
-      }
642
-      break;
641
+        }
642
+        break;
643 643
 
644 644
     default:
645 645
       //debugpng
646 646
       if (DEBUGPNG) print '!!!unknown!!!';
647
-      break;
647
+        break;
648 648
     }
649 649
     
650 650
     return;
651
-  }
651
+    }
652 652
 
653
-  //........................................................................
653
+    //........................................................................
654 654
 
655
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0),
655
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0),
656 656
                 $adjust = 0, $angle = 0, $blend = "Normal", $opacity = 1.0) {
657 657
 
658 658
     list($r, $g, $b) = $color;
@@ -693,142 +693,142 @@  discard block
 block discarded – undo
693 693
     //print '<pre>['.$font.','.$size.','.$this->_pdf->getFontHeight($size).','.$this->_pdf->getFontDescender($size).','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][1].','.$this->_pdf->fonts[$this->_pdf->currentFont]['FontHeightOffset'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Ascender'].','.$this->_pdf->fonts[$this->_pdf->currentFont]['Descender'].']</pre>';
694 694
     //
695 695
     //$this->_pdf->addText($x, $this->y($y) - Font_Metrics::get_font_height($font, $size), $size, $text, $angle, $adjust);
696
-	//$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
697
-	//$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
698
-	$this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust);
699
-  }
696
+    //$this->_pdf->addText($x, $this->y($y) - $size, $size, $text, $angle, $adjust);
697
+    //$this->_pdf->addText($x, $this->y($y) - $this->_pdf->getFontHeight($size)-$this->_pdf->getFontDescender($size), $size, $text, $angle, $adjust);
698
+    $this->_pdf->addText($x, $this->y($y) - ($this->_pdf->fonts[$this->_pdf->currentFont]['FontBBox'][3]*$size)/1000, $size, $text, $angle, $adjust);
699
+    }
700 700
 
701
-  //........................................................................
701
+    //........................................................................
702 702
 
703
-  function javascript($code) {
703
+    function javascript($code) {
704 704
     $this->_pdf->addJavascript($code);
705
-  }
705
+    }
706 706
 
707
-  //........................................................................
707
+    //........................................................................
708 708
 
709
-  /**
710
-   * Add a named destination (similar to <a name="foo">...</a> in html)
711
-   *
712
-   * @param string $anchorname The name of the named destination
713
-   */
714
-  function add_named_dest($anchorname) {
709
+    /**
710
+     * Add a named destination (similar to <a name="foo">...</a> in html)
711
+     *
712
+     * @param string $anchorname The name of the named destination
713
+     */
714
+    function add_named_dest($anchorname) {
715 715
     $this->_pdf->addDestination($anchorname,"Fit");
716
-  }
716
+    }
717 717
 
718
-  //........................................................................
718
+    //........................................................................
719 719
 
720
-  /**
721
-   * Add a link to the pdf
722
-   *
723
-   * @param string $url The url to link to
724
-   * @param float  $x   The x position of the link
725
-   * @param float  $y   The y position of the link
726
-   * @param float  $width   The width of the link
727
-   * @param float  $height   The height of the link
728
-   */
729
-  function add_link($url, $x, $y, $width, $height) {
720
+    /**
721
+     * Add a link to the pdf
722
+     *
723
+     * @param string $url The url to link to
724
+     * @param float  $x   The x position of the link
725
+     * @param float  $y   The y position of the link
726
+     * @param float  $width   The width of the link
727
+     * @param float  $height   The height of the link
728
+     */
729
+    function add_link($url, $x, $y, $width, $height) {
730 730
 
731 731
     $y = $this->y($y) - $height;
732 732
 
733 733
     if ( strpos($url, '#') === 0 ) {
734
-      // Local link
735
-      $name = substr($url,1);
736
-      if ( $name )
734
+        // Local link
735
+        $name = substr($url,1);
736
+        if ( $name )
737 737
         $this->_pdf->addInternalLink($name, $x, $y, $x + $width, $y + $height);
738 738
 
739 739
     } else {
740
-      $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
740
+        $this->_pdf->addLink(rawurldecode($url), $x, $y, $x + $width, $y + $height);
741 741
     }
742 742
     
743
-  }
743
+    }
744 744
 
745
-  //........................................................................
745
+    //........................................................................
746 746
 
747
-  function get_text_width($text, $font, $size, $spacing = 0) {
747
+    function get_text_width($text, $font, $size, $spacing = 0) {
748 748
     $this->_pdf->selectFont($font);
749 749
     if (!DOMPDF_UNICODE_ENABLED) {
750
-    	$text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
750
+        $text = mb_convert_encoding($text, 'Windows-1252', 'UTF-8');
751 751
     }
752 752
     return $this->_pdf->getTextWidth($size, $text, $spacing);
753
-  }
753
+    }
754 754
 
755
-  //........................................................................
755
+    //........................................................................
756 756
 
757
-  function get_font_height($font, $size) {
757
+    function get_font_height($font, $size) {
758 758
     $this->_pdf->selectFont($font);
759 759
     return $this->_pdf->getFontHeight($size);
760
-  }
760
+    }
761 761
 
762
-  //........................................................................
762
+    //........................................................................
763 763
   
764
-  /**
765
-   * Writes text at the specified x and y coordinates on every page
766
-   *
767
-   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
768
-   * with their current values.
769
-   *
770
-   * See {@link Style::munge_colour()} for the format of the colour array.
771
-   *
772
-   * @param float $x
773
-   * @param float $y
774
-   * @param string $text the text to write
775
-   * @param string $font the font file to use
776
-   * @param float $size the font size, in points
777
-   * @param array $color
778
-   * @param float $adjust word spacing adjustment
779
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
780
-   */
781
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
782
-                     $adjust = 0, $angle = 0) {
764
+    /**
765
+     * Writes text at the specified x and y coordinates on every page
766
+     *
767
+     * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
768
+     * with their current values.
769
+     *
770
+     * See {@link Style::munge_colour()} for the format of the colour array.
771
+     *
772
+     * @param float $x
773
+     * @param float $y
774
+     * @param string $text the text to write
775
+     * @param string $font the font file to use
776
+     * @param float $size the font size, in points
777
+     * @param array $color
778
+     * @param float $adjust word spacing adjustment
779
+     * @param float $angle angle to write the text at, measured CW starting from the x-axis
780
+     */
781
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
782
+                        $adjust = 0, $angle = 0) {
783 783
     $_t = "text";
784 784
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
785
-  }
785
+    }
786 786
 
787
-  //........................................................................
787
+    //........................................................................
788 788
     
789
-  /**
790
-   * Processes a script on every page
791
-   *
792
-   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
793
-   *
794
-   * This function can be used to add page numbers to all pages
795
-   * after the first one, for example.
796
-   *
797
-   * @param string $code the script code
798
-   * @param string $type the language type for script
799
-   */
800
-  function page_script($code, $type = "text/php") {
789
+    /**
790
+     * Processes a script on every page
791
+     *
792
+     * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
793
+     *
794
+     * This function can be used to add page numbers to all pages
795
+     * after the first one, for example.
796
+     *
797
+     * @param string $code the script code
798
+     * @param string $type the language type for script
799
+     */
800
+    function page_script($code, $type = "text/php") {
801 801
     $_t = "script";
802 802
     $this->_page_text[] = compact("_t", "code", "type");
803
-  }
803
+    }
804 804
   
805
-  //........................................................................
805
+    //........................................................................
806 806
 
807
-  function new_page() {
807
+    function new_page() {
808 808
     $this->_page_count++;
809 809
 
810 810
     $ret = $this->_pdf->newPage();
811 811
     $this->_pages[] = $ret;
812 812
     return $ret;
813
-  }
813
+    }
814 814
   
815
-  //........................................................................
815
+    //........................................................................
816 816
 
817
-  /**
818
-   * Add text to each page after rendering is complete
819
-   */
820
-  protected function _add_page_text() {
817
+    /**
818
+     * Add text to each page after rendering is complete
819
+     */
820
+    protected function _add_page_text() {
821 821
     
822 822
     if ( !count($this->_page_text) )
823
-      return;
823
+        return;
824 824
 
825 825
     $page_number = 1;
826 826
     $eval = null;
827 827
 
828 828
     foreach ($this->_pages as $pid) {
829
-      $this->reopen_object($pid);
829
+        $this->reopen_object($pid);
830 830
 
831
-      foreach ($this->_page_text as $pt) {
831
+        foreach ($this->_page_text as $pt) {
832 832
         extract($pt);
833 833
 
834 834
         switch ($_t) {
@@ -837,63 +837,63 @@  discard block
 block discarded – undo
837 837
         $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
838 838
                             array($page_number, $this->_page_count), $text);
839 839
         $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
840
-          break;
840
+            break;
841 841
           
842 842
         case "script":
843 843
           if (!$eval) {
844 844
             $eval = new PHP_Evaluator($this);
845
-          }
846
-          $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
-          break;
845
+            }
846
+            $eval->evaluate($code, array('PAGE_NUM' => $page_number, 'PAGE_COUNT' => $this->_page_count));
847
+            break;
848
+        }
848 849
         }
849
-      }
850 850
 
851
-      $this->close_object();
852
-      $page_number++;
851
+        $this->close_object();
852
+        $page_number++;
853
+    }
853 854
     }
854
-  }
855 855
   
856
-  /**
857
-   * Streams the PDF directly to the browser
858
-   *
859
-   * @param string $filename the name of the PDF file
860
-   * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
861
-   */
862
-  function stream($filename, $options = null) {
856
+    /**
857
+     * Streams the PDF directly to the browser
858
+     *
859
+     * @param string $filename the name of the PDF file
860
+     * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
861
+     */
862
+    function stream($filename, $options = null) {
863 863
     // Add page text
864 864
     $this->_add_page_text();
865 865
     
866 866
     $options["Content-Disposition"] = $filename;
867 867
     $this->_pdf->stream($options);
868
-  }
868
+    }
869 869
 
870
-  //........................................................................
870
+    //........................................................................
871 871
 
872
-  /**
873
-   * Returns the PDF as a string
874
-   *
875
-   * @return string
876
-   */
877
-  function output($options = null) {
872
+    /**
873
+     * Returns the PDF as a string
874
+     *
875
+     * @return string
876
+     */
877
+    function output($options = null) {
878 878
     // Add page text
879 879
     $this->_add_page_text();
880 880
 
881 881
     if ( isset($options["compress"]) && $options["compress"] != 1 )
882
-      $debug = 1;
882
+        $debug = 1;
883 883
     else
884
-      $debug = 0;
884
+        $debug = 0;
885 885
     
886 886
     return $this->_pdf->output($debug);
887 887
     
888
-  }
888
+    }
889 889
   
890
-  //........................................................................
891
-
892
-  /**
893
-   * Returns logging messages generated by the Cpdf class
894
-   *
895
-   * @return string
896
-   */
897
-  function get_messages() { return $this->_pdf->messages; }
890
+    //........................................................................
891
+
892
+    /**
893
+     * Returns logging messages generated by the Cpdf class
894
+     *
895
+     * @return string
896
+     */
897
+    function get_messages() { return $this->_pdf->messages; }
898 898
   
899 899
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/css_color.cls.php 1 patch
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -190,6 +190,9 @@
 block discarded – undo
190 190
     "yellowgreen" => "9ACD32",
191 191
   );
192 192
 
193
+  /**
194
+   * @param string $colour
195
+   */
193 196
   static function parse($colour) {
194 197
     if ( is_array($colour) )
195 198
       // Assume the array has the right format...
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/font_metrics.cls.php 4 patches
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
    * @param string $text the text to be sized
118 118
    * @param string $font the desired font
119 119
    * @param float  $size the desired font size
120
-   * @param float  $spacing word spacing, if any
120
+   * @param integer  $spacing word spacing, if any
121 121
    * @return float
122 122
    */
123 123
   static function get_text_width($text, $font, $size, $spacing = 0) {
@@ -234,6 +234,9 @@  discard block
 block discarded – undo
234 234
     return self::$_font_lookup;
235 235
   }
236 236
 
237
+  /**
238
+   * @param string $fontname
239
+   */
237 240
   static function set_font_family($fontname, $entry) {
238 241
     self::$_font_lookup[mb_strtolower($fontname)] = $entry;
239 242
   }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 /* $Id: font_metrics.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
48 48
 
49
-require_once(DOMPDF_LIB_DIR . "/class.pdf.php");
49
+require_once(DOMPDF_LIB_DIR."/class.pdf.php");
50 50
 
51 51
 /**
52 52
  * Name of the font cache file
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  *
60 60
  * Declared here because PHP5 prevents constants from being declared with expressions
61 61
  */
62
-if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) {
63
-	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache");
62
+if (file_exists(DOMPDF_FONT_DIR."dompdf_font_family_cache")) {
63
+	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache");
64 64
 } else {
65
-	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist");
65
+	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR."dompdf_font_family_cache.dist");
66 66
 }
67 67
 
68 68
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
      * Only on checking the fallback font, check various subtypes on same font.
158 158
      */
159 159
 
160
-    if ( $family ) {
161
-      $family = str_replace( array("'", '"'), "", mb_strtolower($family));
160
+    if ($family) {
161
+      $family = str_replace(array("'", '"'), "", mb_strtolower($family));
162 162
       $subtype = mb_strtolower($subtype);
163 163
 
164
-      if ( isset(self::$_font_lookup[$family][$subtype]) ) {
164
+      if (isset(self::$_font_lookup[$family][$subtype])) {
165 165
         return self::$_font_lookup[$family][$subtype];
166 166
       }
167 167
       return null;
@@ -169,18 +169,18 @@  discard block
 block discarded – undo
169 169
 
170 170
     $family = DOMPDF_DEFAULT_FONT;
171 171
 
172
-    if ( isset(self::$_font_lookup[$family][$subtype]) ) {
172
+    if (isset(self::$_font_lookup[$family][$subtype])) {
173 173
       return self::$_font_lookup[$family][$subtype];
174 174
     }
175 175
 
176
-    foreach ( self::$_font_lookup[$family] as $sub => $font ) {
176
+    foreach (self::$_font_lookup[$family] as $sub => $font) {
177 177
       if (strpos($subtype, $sub) !== false) {
178 178
         return $font;
179 179
       }
180 180
     }
181 181
 
182 182
     if ($subtype !== "normal") {
183
-      foreach ( self::$_font_lookup[$family] as $sub => $font ) {
183
+      foreach (self::$_font_lookup[$family] as $sub => $font) {
184 184
         if ($sub !== "normal") {
185 185
           return $font;
186 186
         }
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 
190 190
     $subtype = "normal";
191 191
 
192
-    if ( isset(self::$_font_lookup[$family][$subtype]) ) {
192
+    if (isset(self::$_font_lookup[$family][$subtype])) {
193 193
       return self::$_font_lookup[$family][$subtype];
194 194
     }
195 195
     return null;
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
    * @see save_font_families()
217 217
    */
218 218
   static function load_font_families() {
219
-    if ( !is_readable(self::CACHE_FILE) )
219
+    if (!is_readable(self::CACHE_FILE))
220 220
       return;
221 221
 
222 222
     $data = file_get_contents(self::CACHE_FILE);
223 223
 
224
-    if ( $data != "" )
225
-      eval ('self::$_font_lookup = ' . $data . ";");
224
+    if ($data != "")
225
+      eval ('self::$_font_lookup = '.$data.";");
226 226
   }
227 227
 
228 228
   /**
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -216,13 +216,15 @@
 block discarded – undo
216 216
    * @see save_font_families()
217 217
    */
218 218
   static function load_font_families() {
219
-    if ( !is_readable(self::CACHE_FILE) )
220
-      return;
219
+    if ( !is_readable(self::CACHE_FILE) ) {
220
+          return;
221
+    }
221 222
 
222 223
     $data = file_get_contents(self::CACHE_FILE);
223 224
 
224
-    if ( $data != "" )
225
-      eval ('self::$_font_lookup = ' . $data . ";");
225
+    if ( $data != "" ) {
226
+          eval ('self::$_font_lookup = ' . $data . ";");
227
+    }
226 228
   }
227 229
 
228 230
   /**
Please login to merge, or discard this patch.
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
  * Declared here because PHP5 prevents constants from being declared with expressions
61 61
  */
62 62
 if (file_exists(DOMPDF_FONT_DIR . "dompdf_font_family_cache")) {
63
-	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache");
63
+    define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache");
64 64
 } else {
65
-	define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist");
65
+    define('__DOMPDF_FONT_CACHE_FILE', DOMPDF_FONT_DIR . "dompdf_font_family_cache.dist");
66 66
 }
67 67
 
68 68
 
@@ -78,76 +78,76 @@  discard block
 block discarded – undo
78 78
  */
79 79
 class Font_Metrics {
80 80
 
81
-  /**
82
-   * @see __DOMPDF_FONT_CACHE_FILE
83
-   */
84
-  const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE;
81
+    /**
82
+     * @see __DOMPDF_FONT_CACHE_FILE
83
+     */
84
+    const CACHE_FILE = __DOMPDF_FONT_CACHE_FILE;
85 85
   
86
-  /**
87
-   * Underlying {@link Cpdf} object to perform text size calculations
88
-   *
89
-   * @var Cpdf
90
-   */
91
-  static protected $_pdf = null;
92
-
93
-  /**
94
-   * Array of font family names to font files
95
-   *
96
-   * Usually cached by the {@link load_font.php} script
97
-   *
98
-   * @var array
99
-   */
100
-  static protected $_font_lookup = array();
86
+    /**
87
+     * Underlying {@link Cpdf} object to perform text size calculations
88
+     *
89
+     * @var Cpdf
90
+     */
91
+    static protected $_pdf = null;
92
+
93
+    /**
94
+     * Array of font family names to font files
95
+     *
96
+     * Usually cached by the {@link load_font.php} script
97
+     *
98
+     * @var array
99
+     */
100
+    static protected $_font_lookup = array();
101 101
   
102 102
   
103
-  /**
104
-   * Class initialization
105
-   *
106
-   */
107
-  static function init() {
103
+    /**
104
+     * Class initialization
105
+     *
106
+     */
107
+    static function init() {
108 108
     if (!self::$_pdf) {
109
-      self::load_font_families();
110
-      self::$_pdf = Canvas_Factory::get_instance();
109
+        self::load_font_families();
110
+        self::$_pdf = Canvas_Factory::get_instance();
111 111
     }
112
-  }
113
-
114
-  /**
115
-   * Calculates text size, in points
116
-   *
117
-   * @param string $text the text to be sized
118
-   * @param string $font the desired font
119
-   * @param float  $size the desired font size
120
-   * @param float  $spacing word spacing, if any
121
-   * @return float
122
-   */
123
-  static function get_text_width($text, $font, $size, $spacing = 0) {
112
+    }
113
+
114
+    /**
115
+     * Calculates text size, in points
116
+     *
117
+     * @param string $text the text to be sized
118
+     * @param string $font the desired font
119
+     * @param float  $size the desired font size
120
+     * @param float  $spacing word spacing, if any
121
+     * @return float
122
+     */
123
+    static function get_text_width($text, $font, $size, $spacing = 0) {
124 124
     return self::$_pdf->get_text_width($text, $font, $size, $spacing);
125
-  }
126
-
127
-  /**
128
-   * Calculates font height
129
-   *
130
-   * @param string $font
131
-   * @param float $size
132
-   * @return float
133
-   */
134
-  static function get_font_height($font, $size) {
125
+    }
126
+
127
+    /**
128
+     * Calculates font height
129
+     *
130
+     * @param string $font
131
+     * @param float $size
132
+     * @return float
133
+     */
134
+    static function get_font_height($font, $size) {
135 135
     return self::$_pdf->get_font_height($font, $size);
136
-  }
137
-
138
-  /**
139
-   * Resolves a font family & subtype into an actual font file
140
-   *
141
-   * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'.  If
142
-   * the particular font family has no suitable font file, the default font
143
-   * ({@link DOMPDF_DEFAULT_FONT}) is used.  The font file returned
144
-   * is the absolute pathname to the font file on the system.
145
-   *
146
-   * @param string $family
147
-   * @param string $subtype
148
-   * @return string
149
-   */
150
-  static function get_font($family, $subtype = "normal") {
136
+    }
137
+
138
+    /**
139
+     * Resolves a font family & subtype into an actual font file
140
+     *
141
+     * Subtype can be one of 'normal', 'bold', 'italic' or 'bold_italic'.  If
142
+     * the particular font family has no suitable font file, the default font
143
+     * ({@link DOMPDF_DEFAULT_FONT}) is used.  The font file returned
144
+     * is the absolute pathname to the font file on the system.
145
+     *
146
+     * @param string $family
147
+     * @param string $subtype
148
+     * @return string
149
+     */
150
+    static function get_font($family, $subtype = "normal") {
151 151
 
152 152
     /* Allow calling for various fonts in search path. Therefore not immediately
153 153
      * return replacement on non match.
@@ -158,85 +158,85 @@  discard block
 block discarded – undo
158 158
      */
159 159
 
160 160
     if ( $family ) {
161
-      $family = str_replace( array("'", '"'), "", mb_strtolower($family));
162
-      $subtype = mb_strtolower($subtype);
161
+        $family = str_replace( array("'", '"'), "", mb_strtolower($family));
162
+        $subtype = mb_strtolower($subtype);
163 163
 
164
-      if ( isset(self::$_font_lookup[$family][$subtype]) ) {
164
+        if ( isset(self::$_font_lookup[$family][$subtype]) ) {
165 165
         return self::$_font_lookup[$family][$subtype];
166
-      }
167
-      return null;
166
+        }
167
+        return null;
168 168
     }
169 169
 
170 170
     $family = DOMPDF_DEFAULT_FONT;
171 171
 
172 172
     if ( isset(self::$_font_lookup[$family][$subtype]) ) {
173
-      return self::$_font_lookup[$family][$subtype];
173
+        return self::$_font_lookup[$family][$subtype];
174 174
     }
175 175
 
176 176
     foreach ( self::$_font_lookup[$family] as $sub => $font ) {
177
-      if (strpos($subtype, $sub) !== false) {
177
+        if (strpos($subtype, $sub) !== false) {
178 178
         return $font;
179
-      }
179
+        }
180 180
     }
181 181
 
182 182
     if ($subtype !== "normal") {
183
-      foreach ( self::$_font_lookup[$family] as $sub => $font ) {
183
+        foreach ( self::$_font_lookup[$family] as $sub => $font ) {
184 184
         if ($sub !== "normal") {
185
-          return $font;
185
+            return $font;
186
+        }
186 187
         }
187
-      }
188 188
     }
189 189
 
190 190
     $subtype = "normal";
191 191
 
192 192
     if ( isset(self::$_font_lookup[$family][$subtype]) ) {
193
-      return self::$_font_lookup[$family][$subtype];
193
+        return self::$_font_lookup[$family][$subtype];
194 194
     }
195 195
     return null;
196
-  }
197
-
198
-  /**
199
-   * Saves the stored font family cache
200
-   *
201
-   * The name and location of the cache file are determined by {@link
202
-   * Font_Metrics::CACHE_FILE}.  This file should be writable by the
203
-   * webserver process.
204
-   *
205
-   * @see Font_Metrics::load_font_families()
206
-   */
207
-  static function save_font_families() {
196
+    }
197
+
198
+    /**
199
+     * Saves the stored font family cache
200
+     *
201
+     * The name and location of the cache file are determined by {@link
202
+     * Font_Metrics::CACHE_FILE}.  This file should be writable by the
203
+     * webserver process.
204
+     *
205
+     * @see Font_Metrics::load_font_families()
206
+     */
207
+    static function save_font_families() {
208 208
 
209 209
     file_put_contents(self::CACHE_FILE, var_export(self::$_font_lookup, true));
210 210
     
211
-  }
212
-
213
-  /**
214
-   * Loads the stored font family cache
215
-   *
216
-   * @see save_font_families()
217
-   */
218
-  static function load_font_families() {
211
+    }
212
+
213
+    /**
214
+     * Loads the stored font family cache
215
+     *
216
+     * @see save_font_families()
217
+     */
218
+    static function load_font_families() {
219 219
     if ( !is_readable(self::CACHE_FILE) )
220
-      return;
220
+        return;
221 221
 
222 222
     $data = file_get_contents(self::CACHE_FILE);
223 223
 
224 224
     if ( $data != "" )
225
-      eval ('self::$_font_lookup = ' . $data . ";");
226
-  }
227
-
228
-  /**
229
-   * Returns the current font lookup table
230
-   *
231
-   * @return array
232
-   */
233
-  static function get_font_families() {
225
+        eval ('self::$_font_lookup = ' . $data . ";");
226
+    }
227
+
228
+    /**
229
+     * Returns the current font lookup table
230
+     *
231
+     * @return array
232
+     */
233
+    static function get_font_families() {
234 234
     return self::$_font_lookup;
235
-  }
235
+    }
236 236
 
237
-  static function set_font_family($fontname, $entry) {
237
+    static function set_font_family($fontname, $entry) {
238 238
     self::$_font_lookup[mb_strtolower($fontname)] = $entry;
239
-  }
239
+    }
240 240
 }
241 241
 
242 242
 Font_Metrics::init();
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/frame.cls.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -662,6 +662,9 @@
 block discarded – undo
662 662
 class FrameList implements IteratorAggregate {
663 663
   protected $_frame;
664 664
 
665
+  /**
666
+   * @param Frame $frame
667
+   */
665 668
   function __construct($frame) { $this->_frame = $frame; }
666 669
   function getIterator() { return new FrameListIterator($this->_frame); }
667 670
 }
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
     $this->_decorator = null;
173 173
 
174
-    $this->set_id( self::$ID_COUNTER++ );
174
+    $this->set_id(self::$ID_COUNTER++);
175 175
   }
176 176
 
177 177
   /**
@@ -181,29 +181,29 @@  discard block
 block discarded – undo
181 181
    */
182 182
   function dispose($recursive = false) {
183 183
 
184
-    if ( $recursive ) {
185
-      while ( $child = $this->_first_child )
184
+    if ($recursive) {
185
+      while ($child = $this->_first_child)
186 186
         $child->dispose(true);
187 187
     }
188 188
 
189 189
     // Remove this frame from the tree
190
-    if ( $this->_prev_sibling ) {
190
+    if ($this->_prev_sibling) {
191 191
       $this->_prev_sibling->_next_sibling = $this->_next_sibling;      
192 192
     }
193 193
 
194
-    if ( $this->_next_sibling ) {
194
+    if ($this->_next_sibling) {
195 195
       $this->_next_sibling->_prev_sibling = $this->_prev_sibling;
196 196
     }
197 197
 
198
-    if ( $this->_parent && $this->_parent->_first_child === $this ) {
198
+    if ($this->_parent && $this->_parent->_first_child === $this) {
199 199
       $this->_parent->_first_child = $this->_next_sibling;
200 200
     }
201 201
 
202
-    if ( $this->_parent && $this->_parent->_last_child === $this ) {
202
+    if ($this->_parent && $this->_parent->_last_child === $this) {
203 203
       $this->_parent->_last_child = $this->_prev_sibling;
204 204
     }
205 205
 
206
-    if ( $this->_parent ) {
206
+    if ($this->_parent) {
207 207
       $this->_parent->get_node()->removeChild($this->_node);
208 208
     }
209 209
 
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
   
247 247
   // Layout property accessors
248 248
   function get_containing_block($i = null) {
249
-    if ( isset($i) )
249
+    if (isset($i))
250 250
       return $this->_containing_block[$i];    
251 251
     return $this->_containing_block;
252 252
   }
253 253
   
254 254
   function get_position($i = null) {
255
-    if ( isset($i) )
255
+    if (isset($i))
256 256
       return $this->_position[$i];
257 257
     return array($this->_position["x"],
258 258
                  $this->_position["y"],
@@ -354,12 +354,12 @@  discard block
 block discarded – undo
354 354
     // We can only set attributes of DOMElement objects (nodeType == 1).
355 355
     // Since these are the only objects that we can assign CSS rules to,
356 356
     // this shortcoming is okay.
357
-    if ( $this->_node->nodeType == 1)
357
+    if ($this->_node->nodeType == 1)
358 358
       $this->_node->setAttribute("frame_id", $id);
359 359
   }
360 360
 
361 361
   function set_style(Style $style) {
362
-    if ( is_null($this->_style) )
362
+    if (is_null($this->_style))
363 363
       $this->_original_style = clone $style;
364 364
     
365 365
     $this->_style = $style;
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
   }
371 371
   
372 372
   function set_containing_block($x = null, $y = null, $w = null, $h = null) {
373
-    if ( is_array($x) ){
374
-  		foreach($x AS $key => $val){
373
+    if (is_array($x)) {
374
+  		foreach ($x AS $key => $val) {
375 375
 			$$key = $val;
376 376
 		}
377 377
     }
@@ -399,15 +399,15 @@  discard block
 block discarded – undo
399 399
   }
400 400
 
401 401
   function set_position($x = null, $y = null) {
402
-    if ( is_array($x) )
402
+    if (is_array($x))
403 403
       extract($x);
404 404
     
405
-    if ( is_numeric($x) ) {
405
+    if (is_numeric($x)) {
406 406
       $this->_position[0] = $x;
407 407
       $this->_position["x"] = $x;
408 408
     }
409 409
 
410
-    if ( is_numeric($y) ) {
410
+    if (is_numeric($y)) {
411 411
       $this->_position[1] = $y;
412 412
       $this->_position["y"] = $y;
413 413
     }
@@ -417,18 +417,18 @@  discard block
 block discarded – undo
417 417
 
418 418
   function prepend_child(Frame $child, $update_node = true) {
419 419
 
420
-    if ( $update_node ) 
420
+    if ($update_node) 
421 421
       $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
422 422
 
423 423
     // Remove the child from its parent
424
-    if ( $child->_parent )
424
+    if ($child->_parent)
425 425
       $child->_parent->remove_child($child, false);
426 426
     
427 427
     $child->_parent = $this;
428 428
     $child->_prev_sibling = null;
429 429
     
430 430
     // Handle the first child
431
-    if ( !$this->_first_child ) {
431
+    if (!$this->_first_child) {
432 432
       $this->_first_child = $child;
433 433
       $this->_last_child = $child;
434 434
       $child->_next_sibling = null;
@@ -444,18 +444,18 @@  discard block
 block discarded – undo
444 444
   
445 445
   function append_child(Frame $child, $update_node = true) {
446 446
 
447
-    if ( $update_node ) 
447
+    if ($update_node) 
448 448
       $this->_node->appendChild($child->_node);
449 449
 
450 450
     // Remove the child from its parent
451
-    if ( $child->_parent )
451
+    if ($child->_parent)
452 452
       $child->_parent->remove_child($child, false);
453 453
 
454 454
     $child->_parent = $this;
455 455
     $child->_next_sibling = null;
456 456
     
457 457
     // Handle the first child
458
-    if ( !$this->_last_child ) {
458
+    if (!$this->_last_child) {
459 459
       $this->_first_child = $child;
460 460
       $this->_last_child = $child;
461 461
       $child->_prev_sibling = null;
@@ -472,32 +472,32 @@  discard block
 block discarded – undo
472 472
   // Inserts a new child immediately before the specified frame
473 473
   function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) {
474 474
 
475
-    if ( $ref === $this->_first_child ) {
475
+    if ($ref === $this->_first_child) {
476 476
       $this->prepend_child($new_child, $update_node);
477 477
       return;
478 478
     }
479 479
 
480
-    if ( is_null($ref) ) {
480
+    if (is_null($ref)) {
481 481
       $this->append_child($new_child, $update_node);
482 482
       return;
483 483
     }
484 484
     
485
-    if ( $ref->_parent !== $this )
485
+    if ($ref->_parent !== $this)
486 486
       throw new DOMPDF_Exception("Reference child is not a child of this node.");
487 487
 
488 488
     // Update the node    
489
-    if ( $update_node )
489
+    if ($update_node)
490 490
       $this->_node->insertBefore($new_child->_node, $ref->_node);
491 491
 
492 492
     // Remove the child from its parent
493
-    if ( $new_child->_parent )
493
+    if ($new_child->_parent)
494 494
       $new_child->_parent->remove_child($new_child, false);
495 495
     
496 496
     $new_child->_parent = $this;
497 497
     $new_child->_next_sibling = $ref;
498 498
     $new_child->_prev_sibling = $ref->_prev_sibling;
499 499
 
500
-    if ( $ref->_prev_sibling )
500
+    if ($ref->_prev_sibling)
501 501
       $ref->_prev_sibling->_next_sibling = $new_child;
502 502
     
503 503
     $ref->_prev_sibling = $new_child;
@@ -506,22 +506,22 @@  discard block
 block discarded – undo
506 506
   // Inserts a new child immediately after the specified frame
507 507
   function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) {    
508 508
 
509
-    if ( $ref === $this->_last_child ) {
509
+    if ($ref === $this->_last_child) {
510 510
       $this->append_child($new_child, $update_node);
511 511
       return;
512 512
     }
513 513
 
514
-    if ( is_null($ref) ) {
514
+    if (is_null($ref)) {
515 515
       $this->prepend_child($new_child, $update_node);
516 516
       return;
517 517
     }
518 518
     
519
-    if ( $ref->_parent !== $this )
519
+    if ($ref->_parent !== $this)
520 520
       throw new DOMPDF_Exception("Reference child is not a child of this node.");
521 521
 
522 522
     // Update the node
523
-    if ( $update_node ) {
524
-      if ( $ref->_next_sibling ) {
523
+    if ($update_node) {
524
+      if ($ref->_next_sibling) {
525 525
         $next_node = $ref->_next_sibling->_node;
526 526
         $this->_node->insertBefore($new_child->_node, $next_node);
527 527
       } else {
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
     }
531 531
     
532 532
     // Remove the child from its parent
533
-    if ( $new_child->_parent)
533
+    if ($new_child->_parent)
534 534
       $new_child->_parent->remove_child($new_child, false);
535 535
     
536 536
     $new_child->_parent = $this;
537 537
     $new_child->_prev_sibling = $ref;
538 538
     $new_child->_next_sibling = $ref->_next_sibling;
539 539
 
540
-    if ( $ref->_next_sibling ) 
540
+    if ($ref->_next_sibling) 
541 541
       $ref->_next_sibling->_prev_sibling = $new_child;
542 542
 
543 543
     $ref->_next_sibling = $new_child;
@@ -546,22 +546,22 @@  discard block
 block discarded – undo
546 546
 
547 547
   function remove_child(Frame $child, $update_node = true) {
548 548
 
549
-    if ( $child->_parent !== $this )
549
+    if ($child->_parent !== $this)
550 550
       throw new DOMPDF_Exception("Child not found in this frame");
551 551
 
552
-    if ( $update_node )
552
+    if ($update_node)
553 553
       $this->_node->removeChild($child->_node);
554 554
     
555
-    if ( $child === $this->_first_child )
555
+    if ($child === $this->_first_child)
556 556
       $this->_first_child = $child->_next_sibling;
557 557
 
558
-    if ( $child === $this->_last_child )
558
+    if ($child === $this->_last_child)
559 559
       $this->_last_child = $child->_prev_sibling;
560 560
 
561
-    if ( $child->_prev_sibling )
561
+    if ($child->_prev_sibling)
562 562
       $child->_prev_sibling->_next_sibling = $child->_next_sibling;
563 563
 
564
-    if ( $child->_next_sibling )
564
+    if ($child->_next_sibling)
565 565
       $child->_next_sibling->_prev_sibling = $child->_prev_sibling;    
566 566
 
567 567
     $child->_next_sibling = null;
@@ -582,68 +582,68 @@  discard block
 block discarded – undo
582 582
 //       return "";
583 583
     
584 584
     
585
-    $str = "<b>" . $this->_node->nodeName . ":</b><br/>";
585
+    $str = "<b>".$this->_node->nodeName.":</b><br/>";
586 586
     //$str .= spl_object_hash($this->_node) . "<br/>";
587
-    $str .= "Id: " .$this->get_id() . "<br/>";
588
-    $str .= "Class: " .get_class($this) . "<br/>";
587
+    $str .= "Id: ".$this->get_id()."<br/>";
588
+    $str .= "Class: ".get_class($this)."<br/>";
589 589
     
590
-    if ( $this->_node->nodeName === "#text" ) {
590
+    if ($this->_node->nodeName === "#text") {
591 591
       $tmp = htmlspecialchars($this->_node->nodeValue);
592
-      $str .= "<pre>'" .  mb_substr($tmp,0,70) .
593
-        (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>";
592
+      $str .= "<pre>'".mb_substr($tmp, 0, 70).
593
+        (mb_strlen($tmp) > 70 ? "..." : "")."'</pre>";
594 594
     }
595
-    if ( $this->_parent )
596
-      $str .= "\nParent:" . $this->_parent->_node->nodeName .
597
-        " (" . spl_object_hash($this->_parent->_node) . ") " .
595
+    if ($this->_parent)
596
+      $str .= "\nParent:".$this->_parent->_node->nodeName.
597
+        " (".spl_object_hash($this->_parent->_node).") ".
598 598
         "<br/>";
599 599
 
600
-    if ( $this->_prev_sibling )
601
-      $str .= "Prev: " . $this->_prev_sibling->_node->nodeName .
602
-        " (" . spl_object_hash($this->_prev_sibling->_node) . ") " .
600
+    if ($this->_prev_sibling)
601
+      $str .= "Prev: ".$this->_prev_sibling->_node->nodeName.
602
+        " (".spl_object_hash($this->_prev_sibling->_node).") ".
603 603
         "<br/>";
604 604
 
605
-    if ( $this->_next_sibling )
606
-      $str .= "Next: " . $this->_next_sibling->_node->nodeName .
607
-        " (" . spl_object_hash($this->_next_sibling->_node) . ") " .
605
+    if ($this->_next_sibling)
606
+      $str .= "Next: ".$this->_next_sibling->_node->nodeName.
607
+        " (".spl_object_hash($this->_next_sibling->_node).") ".
608 608
         "<br/>";
609 609
 
610 610
     $d = $this->get_decorator();
611 611
     while ($d && $d != $d->get_decorator()) {
612
-      $str .= "Decorator: " . get_class($d) . "<br/>";
612
+      $str .= "Decorator: ".get_class($d)."<br/>";
613 613
       $d = $d->get_decorator();
614 614
     }
615 615
 
616
-    $str .= "Position: " . pre_r($this->_position, true);
617
-    $str .= "\nContaining block: " . pre_r($this->_containing_block, true);
618
-    $str .= "\nMargin width: " . pre_r($this->get_margin_width(), true);
619
-    $str .= "\nMargin height: " . pre_r($this->get_margin_height(), true);
616
+    $str .= "Position: ".pre_r($this->_position, true);
617
+    $str .= "\nContaining block: ".pre_r($this->_containing_block, true);
618
+    $str .= "\nMargin width: ".pre_r($this->get_margin_width(), true);
619
+    $str .= "\nMargin height: ".pre_r($this->get_margin_height(), true);
620 620
     
621
-    $str .= "\nStyle: <pre>". $this->_style->__toString() . "</pre>";
621
+    $str .= "\nStyle: <pre>".$this->_style->__toString()."</pre>";
622 622
 
623
-    if ( $this->_decorator instanceof Block_Frame_Decorator ) {
623
+    if ($this->_decorator instanceof Block_Frame_Decorator) {
624 624
       $str .= "Lines:<pre>";
625 625
       foreach ($this->_decorator->get_lines() as $line) {
626 626
         foreach ($line["frames"] as $frame) {
627 627
           if ($frame instanceof Text_Frame_Decorator) {
628 628
             $str .= "\ntext: ";          
629
-            $str .= "'". htmlspecialchars($frame->get_text()) ."'";
629
+            $str .= "'".htmlspecialchars($frame->get_text())."'";
630 630
           } else {
631
-            $str .= "\nBlock: " . $frame->get_node()->nodeName . " (" . spl_object_hash($frame->get_node()) . ")";
631
+            $str .= "\nBlock: ".$frame->get_node()->nodeName." (".spl_object_hash($frame->get_node()).")";
632 632
           }
633 633
         }
634 634
         
635 635
         $str .=
636 636
           //"\ncount => " . $line["count"] . "\n".
637
-          "\ny => " . $line["y"] . "\n" .
638
-          "w => " . $line["w"] . "\n" .
639
-          "h => " . $line["h"] . "\n";
637
+          "\ny => ".$line["y"]."\n".
638
+          "w => ".$line["w"]."\n".
639
+          "h => ".$line["h"]."\n";
640 640
       }
641 641
       $str .= "</pre>";
642 642
     }
643 643
     $str .= "\n";
644
-    if ( php_sapi_name() === "cli" )
645
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
646
-                                    array("\n","",""),
644
+    if (php_sapi_name() === "cli")
645
+      $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"),
646
+                                    array("\n", "", ""),
647 647
                                     $str));
648 648
     
649 649
     return $str;
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
   }
694 694
 
695 695
   function valid() {
696
-    return isset($this->_cur);// && ($this->_cur->get_prev_sibling() === $this->_prev);
696
+    return isset($this->_cur); // && ($this->_cur->get_prev_sibling() === $this->_prev);
697 697
   }
698 698
   function key() { return $this->_num; }
699 699
   function current() { return $this->_cur; }
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
   function next() {
702 702
 
703 703
     $ret = $this->_cur;
704
-    if ( !$ret )
704
+    if (!$ret)
705 705
       return null;
706 706
     
707 707
     $this->_cur = $this->_cur->get_next_sibling();
@@ -758,13 +758,13 @@  discard block
 block discarded – undo
758 758
     $b = end($this->_stack);
759 759
     
760 760
     // Pop last element
761
-    unset($this->_stack[ key($this->_stack) ]);
761
+    unset($this->_stack[key($this->_stack)]);
762 762
     $this->_num++;
763 763
     
764 764
     // Push all children onto the stack in reverse order
765
-    if ( $c = $b->get_last_child() ) {
765
+    if ($c = $b->get_last_child()) {
766 766
       $this->_stack[] = $c;
767
-      while ( $c = $c->get_prev_sibling() )
767
+      while ($c = $c->get_prev_sibling())
768 768
         $this->_stack[] = $c;
769 769
     }
770 770
     return $b;
Please login to merge, or discard this patch.
Braces   +87 added lines, -58 removed lines patch added patch discarded remove patch
@@ -182,8 +182,9 @@  discard block
 block discarded – undo
182 182
   function dispose($recursive = false) {
183 183
 
184 184
     if ( $recursive ) {
185
-      while ( $child = $this->_first_child )
186
-        $child->dispose(true);
185
+      while ( $child = $this->_first_child ) {
186
+              $child->dispose(true);
187
+      }
187 188
     }
188 189
 
189 190
     // Remove this frame from the tree
@@ -246,14 +247,16 @@  discard block
 block discarded – undo
246 247
   
247 248
   // Layout property accessors
248 249
   function get_containing_block($i = null) {
249
-    if ( isset($i) )
250
-      return $this->_containing_block[$i];    
250
+    if ( isset($i) ) {
251
+          return $this->_containing_block[$i];
252
+    }
251 253
     return $this->_containing_block;
252 254
   }
253 255
   
254 256
   function get_position($i = null) {
255
-    if ( isset($i) )
256
-      return $this->_position[$i];
257
+    if ( isset($i) ) {
258
+          return $this->_position[$i];
259
+    }
257 260
     return array($this->_position["x"],
258 261
                  $this->_position["y"],
259 262
                  "x"=>$this->_position["x"],
@@ -354,13 +357,15 @@  discard block
 block discarded – undo
354 357
     // We can only set attributes of DOMElement objects (nodeType == 1).
355 358
     // Since these are the only objects that we can assign CSS rules to,
356 359
     // this shortcoming is okay.
357
-    if ( $this->_node->nodeType == 1)
358
-      $this->_node->setAttribute("frame_id", $id);
360
+    if ( $this->_node->nodeType == 1) {
361
+          $this->_node->setAttribute("frame_id", $id);
362
+    }
359 363
   }
360 364
 
361 365
   function set_style(Style $style) {
362
-    if ( is_null($this->_style) )
363
-      $this->_original_style = clone $style;
366
+    if ( is_null($this->_style) ) {
367
+          $this->_original_style = clone $style;
368
+    }
364 369
     
365 370
     $this->_style = $style;
366 371
   }
@@ -399,8 +404,9 @@  discard block
 block discarded – undo
399 404
   }
400 405
 
401 406
   function set_position($x = null, $y = null) {
402
-    if ( is_array($x) )
403
-      extract($x);
407
+    if ( is_array($x) ) {
408
+          extract($x);
409
+    }
404 410
     
405 411
     if ( is_numeric($x) ) {
406 412
       $this->_position[0] = $x;
@@ -417,12 +423,14 @@  discard block
 block discarded – undo
417 423
 
418 424
   function prepend_child(Frame $child, $update_node = true) {
419 425
 
420
-    if ( $update_node ) 
421
-      $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
426
+    if ( $update_node ) {
427
+          $this->_node->insertBefore($child->_node, $this->_first_child ? $this->_first_child->_node : null);
428
+    }
422 429
 
423 430
     // Remove the child from its parent
424
-    if ( $child->_parent )
425
-      $child->_parent->remove_child($child, false);
431
+    if ( $child->_parent ) {
432
+          $child->_parent->remove_child($child, false);
433
+    }
426 434
     
427 435
     $child->_parent = $this;
428 436
     $child->_prev_sibling = null;
@@ -444,12 +452,14 @@  discard block
 block discarded – undo
444 452
   
445 453
   function append_child(Frame $child, $update_node = true) {
446 454
 
447
-    if ( $update_node ) 
448
-      $this->_node->appendChild($child->_node);
455
+    if ( $update_node ) {
456
+          $this->_node->appendChild($child->_node);
457
+    }
449 458
 
450 459
     // Remove the child from its parent
451
-    if ( $child->_parent )
452
-      $child->_parent->remove_child($child, false);
460
+    if ( $child->_parent ) {
461
+          $child->_parent->remove_child($child, false);
462
+    }
453 463
 
454 464
     $child->_parent = $this;
455 465
     $child->_next_sibling = null;
@@ -482,23 +492,27 @@  discard block
 block discarded – undo
482 492
       return;
483 493
     }
484 494
     
485
-    if ( $ref->_parent !== $this )
486
-      throw new DOMPDF_Exception("Reference child is not a child of this node.");
495
+    if ( $ref->_parent !== $this ) {
496
+          throw new DOMPDF_Exception("Reference child is not a child of this node.");
497
+    }
487 498
 
488 499
     // Update the node    
489
-    if ( $update_node )
490
-      $this->_node->insertBefore($new_child->_node, $ref->_node);
500
+    if ( $update_node ) {
501
+          $this->_node->insertBefore($new_child->_node, $ref->_node);
502
+    }
491 503
 
492 504
     // Remove the child from its parent
493
-    if ( $new_child->_parent )
494
-      $new_child->_parent->remove_child($new_child, false);
505
+    if ( $new_child->_parent ) {
506
+          $new_child->_parent->remove_child($new_child, false);
507
+    }
495 508
     
496 509
     $new_child->_parent = $this;
497 510
     $new_child->_next_sibling = $ref;
498 511
     $new_child->_prev_sibling = $ref->_prev_sibling;
499 512
 
500
-    if ( $ref->_prev_sibling )
501
-      $ref->_prev_sibling->_next_sibling = $new_child;
513
+    if ( $ref->_prev_sibling ) {
514
+          $ref->_prev_sibling->_next_sibling = $new_child;
515
+    }
502 516
     
503 517
     $ref->_prev_sibling = $new_child;
504 518
   }
@@ -516,8 +530,9 @@  discard block
 block discarded – undo
516 530
       return;
517 531
     }
518 532
     
519
-    if ( $ref->_parent !== $this )
520
-      throw new DOMPDF_Exception("Reference child is not a child of this node.");
533
+    if ( $ref->_parent !== $this ) {
534
+          throw new DOMPDF_Exception("Reference child is not a child of this node.");
535
+    }
521 536
 
522 537
     // Update the node
523 538
     if ( $update_node ) {
@@ -530,15 +545,17 @@  discard block
 block discarded – undo
530 545
     }
531 546
     
532 547
     // Remove the child from its parent
533
-    if ( $new_child->_parent)
534
-      $new_child->_parent->remove_child($new_child, false);
548
+    if ( $new_child->_parent) {
549
+          $new_child->_parent->remove_child($new_child, false);
550
+    }
535 551
     
536 552
     $new_child->_parent = $this;
537 553
     $new_child->_prev_sibling = $ref;
538 554
     $new_child->_next_sibling = $ref->_next_sibling;
539 555
 
540
-    if ( $ref->_next_sibling ) 
541
-      $ref->_next_sibling->_prev_sibling = $new_child;
556
+    if ( $ref->_next_sibling ) {
557
+          $ref->_next_sibling->_prev_sibling = $new_child;
558
+    }
542 559
 
543 560
     $ref->_next_sibling = $new_child;
544 561
   }
@@ -546,23 +563,29 @@  discard block
 block discarded – undo
546 563
 
547 564
   function remove_child(Frame $child, $update_node = true) {
548 565
 
549
-    if ( $child->_parent !== $this )
550
-      throw new DOMPDF_Exception("Child not found in this frame");
566
+    if ( $child->_parent !== $this ) {
567
+          throw new DOMPDF_Exception("Child not found in this frame");
568
+    }
551 569
 
552
-    if ( $update_node )
553
-      $this->_node->removeChild($child->_node);
570
+    if ( $update_node ) {
571
+          $this->_node->removeChild($child->_node);
572
+    }
554 573
     
555
-    if ( $child === $this->_first_child )
556
-      $this->_first_child = $child->_next_sibling;
574
+    if ( $child === $this->_first_child ) {
575
+          $this->_first_child = $child->_next_sibling;
576
+    }
557 577
 
558
-    if ( $child === $this->_last_child )
559
-      $this->_last_child = $child->_prev_sibling;
578
+    if ( $child === $this->_last_child ) {
579
+          $this->_last_child = $child->_prev_sibling;
580
+    }
560 581
 
561
-    if ( $child->_prev_sibling )
562
-      $child->_prev_sibling->_next_sibling = $child->_next_sibling;
582
+    if ( $child->_prev_sibling ) {
583
+          $child->_prev_sibling->_next_sibling = $child->_next_sibling;
584
+    }
563 585
 
564
-    if ( $child->_next_sibling )
565
-      $child->_next_sibling->_prev_sibling = $child->_prev_sibling;    
586
+    if ( $child->_next_sibling ) {
587
+          $child->_next_sibling->_prev_sibling = $child->_prev_sibling;
588
+    }
566 589
 
567 590
     $child->_next_sibling = null;
568 591
     $child->_prev_sibling = null;
@@ -592,20 +615,23 @@  discard block
 block discarded – undo
592 615
       $str .= "<pre>'" .  mb_substr($tmp,0,70) .
593 616
         (mb_strlen($tmp) > 70 ? "..." : "") . "'</pre>";
594 617
     }
595
-    if ( $this->_parent )
596
-      $str .= "\nParent:" . $this->_parent->_node->nodeName .
618
+    if ( $this->_parent ) {
619
+          $str .= "\nParent:" . $this->_parent->_node->nodeName .
597 620
         " (" . spl_object_hash($this->_parent->_node) . ") " .
598 621
         "<br/>";
622
+    }
599 623
 
600
-    if ( $this->_prev_sibling )
601
-      $str .= "Prev: " . $this->_prev_sibling->_node->nodeName .
624
+    if ( $this->_prev_sibling ) {
625
+          $str .= "Prev: " . $this->_prev_sibling->_node->nodeName .
602 626
         " (" . spl_object_hash($this->_prev_sibling->_node) . ") " .
603 627
         "<br/>";
628
+    }
604 629
 
605
-    if ( $this->_next_sibling )
606
-      $str .= "Next: " . $this->_next_sibling->_node->nodeName .
630
+    if ( $this->_next_sibling ) {
631
+          $str .= "Next: " . $this->_next_sibling->_node->nodeName .
607 632
         " (" . spl_object_hash($this->_next_sibling->_node) . ") " .
608 633
         "<br/>";
634
+    }
609 635
 
610 636
     $d = $this->get_decorator();
611 637
     while ($d && $d != $d->get_decorator()) {
@@ -641,10 +667,11 @@  discard block
 block discarded – undo
641 667
       $str .= "</pre>";
642 668
     }
643 669
     $str .= "\n";
644
-    if ( php_sapi_name() === "cli" )
645
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
670
+    if ( php_sapi_name() === "cli" ) {
671
+          $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
646 672
                                     array("\n","",""),
647 673
                                     $str));
674
+    }
648 675
     
649 676
     return $str;
650 677
   }
@@ -701,8 +728,9 @@  discard block
 block discarded – undo
701 728
   function next() {
702 729
 
703 730
     $ret = $this->_cur;
704
-    if ( !$ret )
705
-      return null;
731
+    if ( !$ret ) {
732
+          return null;
733
+    }
706 734
     
707 735
     $this->_cur = $this->_cur->get_next_sibling();
708 736
     $this->_num++;
@@ -764,8 +792,9 @@  discard block
 block discarded – undo
764 792
     // Push all children onto the stack in reverse order
765 793
     if ( $c = $b->get_last_child() ) {
766 794
       $this->_stack[] = $c;
767
-      while ( $c = $c->get_prev_sibling() )
768
-        $this->_stack[] = $c;
795
+      while ( $c = $c->get_prev_sibling() ) {
796
+              $this->_stack[] = $c;
797
+      }
769 798
     }
770 799
     return $b;
771 800
   }
Please login to merge, or discard this patch.
Indentation   +378 added lines, -379 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: frame.cls.php,v $
6
- * Created on: 2004-06-02
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: frame.cls.php,v $
6
+     * Created on: 2004-06-02
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: frame.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -53,105 +52,105 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/frame_decorator.cls.php 4 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -155,7 +155,15 @@  discard block
 block discarded – undo
155 155
   function get_id() { return $this->_frame->get_id(); }
156 156
   function get_style() { return $this->_frame->get_style(); }
157 157
   function get_original_style() { return $this->_frame->get_original_style(); }
158
+
159
+  /**
160
+   * @param string $i
161
+   */
158 162
   function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); }
163
+
164
+  /**
165
+   * @param string $i
166
+   */
159 167
   function get_position($i = null) { return $this->_frame->get_position($i); }
160 168
   function get_dompdf() { return $this->_dompdf; }
161 169
 //   function get_decorator() {
@@ -173,6 +181,12 @@  discard block
 block discarded – undo
173 181
   function set_id($id) { $this->_frame->set_id($id); }
174 182
   function set_style(Style $style) { $this->_frame->set_style($style); }
175 183
 
184
+  /**
185
+   * @param double $x
186
+   * @param double $y
187
+   * @param double $w
188
+   * @param double $h
189
+   */
176 190
   function set_containing_block($x = null, $y = null, $w = null, $h = null) {
177 191
     $this->_frame->set_containing_block($x, $y, $w, $h);
178 192
   }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
    */
102 102
   function dispose($recursive = false) {
103 103
     
104
-    if ( $recursive ) {
105
-      while ( $child = $this->get_first_child() )
104
+    if ($recursive) {
105
+      while ($child = $this->get_first_child())
106 106
         $child->dispose(true);
107 107
     }
108 108
     
@@ -183,41 +183,41 @@  discard block
 block discarded – undo
183 183
   function __toString() { return $this->_frame->__toString(); }
184 184
   
185 185
   function prepend_child(Frame $child, $update_node = true) {
186
-    while ( $child instanceof Frame_Decorator )
186
+    while ($child instanceof Frame_Decorator)
187 187
       $child = $child->_frame;
188 188
     
189 189
     $this->_frame->prepend_child($child, $update_node);
190 190
   }
191 191
 
192 192
   function append_child(Frame $child, $update_node = true) {
193
-    while ( $child instanceof Frame_Decorator )
193
+    while ($child instanceof Frame_Decorator)
194 194
       $child = $child->_frame;
195 195
 
196 196
     $this->_frame->append_child($child, $update_node);
197 197
   }
198 198
 
199 199
   function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) {
200
-    while ( $new_child instanceof Frame_Decorator )
200
+    while ($new_child instanceof Frame_Decorator)
201 201
       $new_child = $new_child->_frame;
202 202
 
203
-    if ( $ref instanceof Frame_Decorator )
203
+    if ($ref instanceof Frame_Decorator)
204 204
       $ref = $ref->_frame;
205 205
 
206 206
     $this->_frame->insert_child_before($new_child, $ref, $update_node);
207 207
   }
208 208
 
209 209
   function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) {
210
-    while ( $new_child instanceof Frame_Decorator )
210
+    while ($new_child instanceof Frame_Decorator)
211 211
       $new_child = $new_child->_frame;
212 212
 
213
-    while ( $ref instanceof Frame_Decorator )
213
+    while ($ref instanceof Frame_Decorator)
214 214
       $ref = $ref->_frame;
215 215
     
216 216
     $this->_frame->insert_child_after($new_child, $ref, $update_node);
217 217
   }
218 218
 
219 219
   function remove_child(Frame $child, $update_node = true) {
220
-    while  ( $child instanceof Frame_Decorator )
220
+    while ($child instanceof Frame_Decorator)
221 221
       $child = $new_child->_frame;
222 222
 
223 223
     $this->_frame->remove_child($child, $update_node);
@@ -229,11 +229,11 @@  discard block
 block discarded – undo
229 229
 
230 230
     $p = $this->_frame->get_parent();
231 231
     
232
-    if ( $p && $deco = $p->get_decorator() ) {
233
-      while ( $tmp = $deco->get_decorator() )
232
+    if ($p && $deco = $p->get_decorator()) {
233
+      while ($tmp = $deco->get_decorator())
234 234
         $deco = $tmp;      
235 235
       return $deco;
236
-    } else if ( $p )
236
+    } else if ($p)
237 237
       return $p;
238 238
     else
239 239
       return null;
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 
242 242
   function get_first_child() {
243 243
     $c = $this->_frame->get_first_child();
244
-    if ( $c && $deco = $c->get_decorator() ) {
245
-      while ( $tmp = $deco->get_decorator() )
244
+    if ($c && $deco = $c->get_decorator()) {
245
+      while ($tmp = $deco->get_decorator())
246 246
         $deco = $tmp;      
247 247
       return $deco;
248
-    } else if ( $c )
248
+    } else if ($c)
249 249
       return $c;
250 250
     else
251 251
       return null;
@@ -253,11 +253,11 @@  discard block
 block discarded – undo
253 253
 
254 254
   function get_last_child() {
255 255
     $c = $this->_frame->get_last_child();
256
-    if ( $c && $deco = $c->get_decorator() ) {
257
-      while ( $tmp = $deco->get_decorator() )
256
+    if ($c && $deco = $c->get_decorator()) {
257
+      while ($tmp = $deco->get_decorator())
258 258
         $deco = $tmp;      
259 259
       return $deco;
260
-    } else if ( $c )
260
+    } else if ($c)
261 261
       return $c;
262 262
     else
263 263
       return null;
@@ -265,11 +265,11 @@  discard block
 block discarded – undo
265 265
 
266 266
   function get_prev_sibling() {
267 267
     $s = $this->_frame->get_prev_sibling();
268
-    if ( $s && $deco = $s->get_decorator() ) {
269
-      while ( $tmp = $deco->get_decorator() )
268
+    if ($s && $deco = $s->get_decorator()) {
269
+      while ($tmp = $deco->get_decorator())
270 270
         $deco = $tmp;      
271 271
       return $deco;
272
-    } else if ( $s )
272
+    } else if ($s)
273 273
       return $s;
274 274
     else
275 275
       return null;
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
   
278 278
   function get_next_sibling() {
279 279
     $s = $this->_frame->get_next_sibling();
280
-    if ( $s && $deco = $s->get_decorator() ) {
281
-      while ( $tmp = $deco->get_decorator() )
280
+    if ($s && $deco = $s->get_decorator()) {
281
+      while ($tmp = $deco->get_decorator())
282 282
         $deco = $tmp;      
283 283
       return $deco;
284
-    } else if ( $s )
284
+    } else if ($s)
285 285
       return $s;
286 286
     else
287 287
       return null;
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 
300 300
   function set_positioner(Positioner $posn) {
301 301
     $this->_positioner = $posn;
302
-    if ( $this->_frame instanceof Frame_Decorator )
302
+    if ($this->_frame instanceof Frame_Decorator)
303 303
       $this->_frame->set_positioner($posn);
304 304
   }
305 305
   
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 
308 308
   function set_reflower(Frame_Reflower $reflower) {
309 309
     $this->_reflower = $reflower;
310
-    if ( $this->_frame instanceof Frame_Decorator )
311
-      $this->_frame->set_reflower( $reflower );
310
+    if ($this->_frame instanceof Frame_Decorator)
311
+      $this->_frame->set_reflower($reflower);
312 312
   }
313 313
   
314 314
   function get_reflower() { return $this->_reflower; }
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
   
318 318
   function set_root(Frame $root) {
319 319
     $this->_root = $root;
320
-      if ( $this->_frame instanceof Frame_Decorator )
320
+      if ($this->_frame instanceof Frame_Decorator)
321 321
         $this->_frame->set_root($root);
322 322
   }
323 323
   
@@ -330,8 +330,8 @@  discard block
 block discarded – undo
330 330
     // Find our nearest block level parent
331 331
     $p = $this->get_parent();
332 332
     
333
-    while ( $p ) {
334
-      if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) )
333
+    while ($p) {
334
+      if (in_array($p->get_style()->display, Style::$BLOCK_TYPES))
335 335
         break;
336 336
 
337 337
       $p = $p->get_parent();
@@ -353,15 +353,15 @@  discard block
 block discarded – undo
353 353
    */
354 354
   function split($child = null) {
355 355
 
356
-    if ( is_null( $child ) ) {
356
+    if (is_null($child)) {
357 357
       $this->get_parent()->split($this);
358 358
       return;
359 359
     }
360 360
     
361
-    if ( $child->get_parent() !== $this )
361
+    if ($child->get_parent() !== $this)
362 362
       throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
363 363
 
364
-    $split = $this->copy( $this->_frame->get_node()->cloneNode() );
364
+    $split = $this->copy($this->_frame->get_node()->cloneNode());
365 365
     $split->reset();
366 366
     $this->get_parent()->insert_child_after($split, $this);
367 367
 
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 
380 380
   //........................................................................
381 381
 
382
-  final function position() { $this->_positioner->position();  }
382
+  final function position() { $this->_positioner->position(); }
383 383
   
384 384
   final function reflow() {
385 385
     // Uncomment this to see the frames before they're laid out, instead of
Please login to merge, or discard this patch.
Braces   +85 added lines, -60 removed lines patch added patch discarded remove patch
@@ -102,8 +102,9 @@  discard block
 block discarded – undo
102 102
   function dispose($recursive = false) {
103 103
     
104 104
     if ( $recursive ) {
105
-      while ( $child = $this->get_first_child() )
106
-        $child->dispose(true);
105
+      while ( $child = $this->get_first_child() ) {
106
+              $child->dispose(true);
107
+      }
107 108
     }
108 109
     
109 110
     unset($this->_root);
@@ -134,8 +135,9 @@  discard block
 block discarded – undo
134 135
     $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf);
135 136
     $deco->set_root($this->_root);
136 137
 
137
-    foreach ($this->get_children() as $child)
138
-      $deco->append_child($child->deep_copy());
138
+    foreach ($this->get_children() as $child) {
139
+          $deco->append_child($child->deep_copy());
140
+    }
139 141
 
140 142
     return $deco;
141 143
   }
@@ -146,8 +148,9 @@  discard block
 block discarded – undo
146 148
     $this->_frame->reset();
147 149
 
148 150
     // Reset all children
149
-    foreach ($this->get_children() as $child)
150
-      $child->reset();
151
+    foreach ($this->get_children() as $child) {
152
+          $child->reset();
153
+    }
151 154
 
152 155
   }
153 156
   
@@ -183,42 +186,49 @@  discard block
 block discarded – undo
183 186
   function __toString() { return $this->_frame->__toString(); }
184 187
   
185 188
   function prepend_child(Frame $child, $update_node = true) {
186
-    while ( $child instanceof Frame_Decorator )
187
-      $child = $child->_frame;
189
+    while ( $child instanceof Frame_Decorator ) {
190
+          $child = $child->_frame;
191
+    }
188 192
     
189 193
     $this->_frame->prepend_child($child, $update_node);
190 194
   }
191 195
 
192 196
   function append_child(Frame $child, $update_node = true) {
193
-    while ( $child instanceof Frame_Decorator )
194
-      $child = $child->_frame;
197
+    while ( $child instanceof Frame_Decorator ) {
198
+          $child = $child->_frame;
199
+    }
195 200
 
196 201
     $this->_frame->append_child($child, $update_node);
197 202
   }
198 203
 
199 204
   function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) {
200
-    while ( $new_child instanceof Frame_Decorator )
201
-      $new_child = $new_child->_frame;
205
+    while ( $new_child instanceof Frame_Decorator ) {
206
+          $new_child = $new_child->_frame;
207
+    }
202 208
 
203
-    if ( $ref instanceof Frame_Decorator )
204
-      $ref = $ref->_frame;
209
+    if ( $ref instanceof Frame_Decorator ) {
210
+          $ref = $ref->_frame;
211
+    }
205 212
 
206 213
     $this->_frame->insert_child_before($new_child, $ref, $update_node);
207 214
   }
208 215
 
209 216
   function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) {
210
-    while ( $new_child instanceof Frame_Decorator )
211
-      $new_child = $new_child->_frame;
217
+    while ( $new_child instanceof Frame_Decorator ) {
218
+          $new_child = $new_child->_frame;
219
+    }
212 220
 
213
-    while ( $ref instanceof Frame_Decorator )
214
-      $ref = $ref->_frame;
221
+    while ( $ref instanceof Frame_Decorator ) {
222
+          $ref = $ref->_frame;
223
+    }
215 224
     
216 225
     $this->_frame->insert_child_after($new_child, $ref, $update_node);
217 226
   }
218 227
 
219 228
   function remove_child(Frame $child, $update_node = true) {
220
-    while  ( $child instanceof Frame_Decorator )
221
-      $child = $new_child->_frame;
229
+    while  ( $child instanceof Frame_Decorator ) {
230
+          $child = $new_child->_frame;
231
+    }
222 232
 
223 233
     $this->_frame->remove_child($child, $update_node);
224 234
   }
@@ -230,61 +240,71 @@  discard block
 block discarded – undo
230 240
     $p = $this->_frame->get_parent();
231 241
     
232 242
     if ( $p && $deco = $p->get_decorator() ) {
233
-      while ( $tmp = $deco->get_decorator() )
234
-        $deco = $tmp;      
243
+      while ( $tmp = $deco->get_decorator() ) {
244
+              $deco = $tmp;
245
+      }
235 246
       return $deco;
236
-    } else if ( $p )
237
-      return $p;
238
-    else
239
-      return null;
247
+    } else if ( $p ) {
248
+          return $p;
249
+    } else {
250
+          return null;
251
+    }
240 252
   }
241 253
 
242 254
   function get_first_child() {
243 255
     $c = $this->_frame->get_first_child();
244 256
     if ( $c && $deco = $c->get_decorator() ) {
245
-      while ( $tmp = $deco->get_decorator() )
246
-        $deco = $tmp;      
257
+      while ( $tmp = $deco->get_decorator() ) {
258
+              $deco = $tmp;
259
+      }
247 260
       return $deco;
248
-    } else if ( $c )
249
-      return $c;
250
-    else
251
-      return null;
261
+    } else if ( $c ) {
262
+          return $c;
263
+    } else {
264
+          return null;
265
+    }
252 266
   }
253 267
 
254 268
   function get_last_child() {
255 269
     $c = $this->_frame->get_last_child();
256 270
     if ( $c && $deco = $c->get_decorator() ) {
257
-      while ( $tmp = $deco->get_decorator() )
258
-        $deco = $tmp;      
271
+      while ( $tmp = $deco->get_decorator() ) {
272
+              $deco = $tmp;
273
+      }
259 274
       return $deco;
260
-    } else if ( $c )
261
-      return $c;
262
-    else
263
-      return null;
275
+    } else if ( $c ) {
276
+          return $c;
277
+    } else {
278
+          return null;
279
+    }
264 280
   }
265 281
 
266 282
   function get_prev_sibling() {
267 283
     $s = $this->_frame->get_prev_sibling();
268 284
     if ( $s && $deco = $s->get_decorator() ) {
269
-      while ( $tmp = $deco->get_decorator() )
270
-        $deco = $tmp;      
285
+      while ( $tmp = $deco->get_decorator() ) {
286
+              $deco = $tmp;
287
+      }
271 288
       return $deco;
272
-    } else if ( $s )
273
-      return $s;
274
-    else
275
-      return null;
289
+    } else if ( $s ) {
290
+          return $s;
291
+    } else {
292
+          return null;
293
+    }
276 294
   }
277 295
   
278 296
   function get_next_sibling() {
279 297
     $s = $this->_frame->get_next_sibling();
280 298
     if ( $s && $deco = $s->get_decorator() ) {
281
-      while ( $tmp = $deco->get_decorator() )
282
-        $deco = $tmp;      
299
+      while ( $tmp = $deco->get_decorator() ) {
300
+              $deco = $tmp;
301
+      }
283 302
       return $deco;
284
-    } else if ( $s )
285
-      return $s;
286
-    else
287
-      return null;
303
+    } else if ( $s ) {
304
+          return $s;
305
+    } else {
306
+          return null;
307
+    }
288 308
   }
289 309
 
290 310
   function get_children() {
@@ -299,16 +319,18 @@  discard block
 block discarded – undo
299 319
 
300 320
   function set_positioner(Positioner $posn) {
301 321
     $this->_positioner = $posn;
302
-    if ( $this->_frame instanceof Frame_Decorator )
303
-      $this->_frame->set_positioner($posn);
322
+    if ( $this->_frame instanceof Frame_Decorator ) {
323
+          $this->_frame->set_positioner($posn);
324
+    }
304 325
   }
305 326
   
306 327
   //........................................................................
307 328
 
308 329
   function set_reflower(Frame_Reflower $reflower) {
309 330
     $this->_reflower = $reflower;
310
-    if ( $this->_frame instanceof Frame_Decorator )
311
-      $this->_frame->set_reflower( $reflower );
331
+    if ( $this->_frame instanceof Frame_Decorator ) {
332
+          $this->_frame->set_reflower( $reflower );
333
+    }
312 334
   }
313 335
   
314 336
   function get_reflower() { return $this->_reflower; }
@@ -317,8 +339,9 @@  discard block
 block discarded – undo
317 339
   
318 340
   function set_root(Frame $root) {
319 341
     $this->_root = $root;
320
-      if ( $this->_frame instanceof Frame_Decorator )
321
-        $this->_frame->set_root($root);
342
+      if ( $this->_frame instanceof Frame_Decorator ) {
343
+              $this->_frame->set_root($root);
344
+      }
322 345
   }
323 346
   
324 347
   function get_root() { return $this->_root; }
@@ -331,8 +354,9 @@  discard block
 block discarded – undo
331 354
     $p = $this->get_parent();
332 355
     
333 356
     while ( $p ) {
334
-      if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) )
335
-        break;
357
+      if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) ) {
358
+              break;
359
+      }
336 360
 
337 361
       $p = $p->get_parent();
338 362
     }
@@ -358,8 +382,9 @@  discard block
 block discarded – undo
358 382
       return;
359 383
     }
360 384
     
361
-    if ( $child->get_parent() !== $this )
362
-      throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
385
+    if ( $child->get_parent() !== $this ) {
386
+          throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
387
+    }
363 388
 
364 389
     $split = $this->copy( $this->_frame->get_node()->cloneNode() );
365 390
     $split->reset();
Please login to merge, or discard this patch.
Indentation   +216 added lines, -217 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: frame_decorator.cls.php,v $
6
- * Created on: 2004-06-02
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: frame_decorator.cls.php,v $
6
+     * Created on: 2004-06-02
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: frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
41 40
 
@@ -47,62 +46,62 @@  discard block
 block discarded – undo
47 46
  */
48 47
 abstract class Frame_Decorator extends Frame {
49 48
   
50
-  /**
51
-   * The root node of the DOM tree
52
-   *
53
-   * @var Frame
54
-   */
55
-  protected $_root;
56
-
57
-  /**
58
-   * The decorated frame
59
-   *
60
-   * @var Frame
61
-   */
62
-  protected $_frame;
63
-
64
-  /**
65
-   * Positioner object used to position this frame (Strategy pattern)
66
-   *
67
-   * @var Positioner
68
-   */
69
-  protected $_positioner;
70
-
71
-  /**
72
-   * Reflower object used to calculate frame dimensions (Strategy pattern)
73
-   *
74
-   * @var Frame_Reflower
75
-   */
76
-  protected $_reflower;
49
+    /**
50
+     * The root node of the DOM tree
51
+     *
52
+     * @var Frame
53
+     */
54
+    protected $_root;
55
+
56
+    /**
57
+     * The decorated frame
58
+     *
59
+     * @var Frame
60
+     */
61
+    protected $_frame;
62
+
63
+    /**
64
+     * Positioner object used to position this frame (Strategy pattern)
65
+     *
66
+     * @var Positioner
67
+     */
68
+    protected $_positioner;
69
+
70
+    /**
71
+     * Reflower object used to calculate frame dimensions (Strategy pattern)
72
+     *
73
+     * @var Frame_Reflower
74
+     */
75
+    protected $_reflower;
77 76
   
78
-  /**
79
-   * Reference to the current dompdf instance
80
-   *
81
-   * @var DOMPDF
82
-   */
83
-  protected $_dompdf;
84
-
85
-  /**
86
-   * Class constructor
87
-   *
88
-   * @param Frame $frame the decoration target
89
-   */
90
-  function __construct(Frame $frame, DOMPDF $dompdf) {
77
+    /**
78
+     * Reference to the current dompdf instance
79
+     *
80
+     * @var DOMPDF
81
+     */
82
+    protected $_dompdf;
83
+
84
+    /**
85
+     * Class constructor
86
+     *
87
+     * @param Frame $frame the decoration target
88
+     */
89
+    function __construct(Frame $frame, DOMPDF $dompdf) {
91 90
     $this->_frame = $frame;
92 91
     $this->_root = null;
93 92
     $this->_dompdf = $dompdf;
94 93
     $frame->set_decorator($this);
95
-  }
96
-
97
-  /**
98
-   * "Destructor": foribly free all references held by this object
99
-   *
100
-   * @param bool $recursive if true, call dispose on all children
101
-   */
102
-  function dispose($recursive = false) {
94
+    }
95
+
96
+    /**
97
+     * "Destructor": foribly free all references held by this object
98
+     *
99
+     * @param bool $recursive if true, call dispose on all children
100
+     */
101
+    function dispose($recursive = false) {
103 102
     
104 103
     if ( $recursive ) {
105
-      while ( $child = $this->get_first_child() )
104
+        while ( $child = $this->get_first_child() )
106 105
         $child->dispose(true);
107 106
     }
108 107
     
@@ -112,52 +111,52 @@  discard block
 block discarded – undo
112 111
     unset($this->_positioner);
113 112
     unset($this->_reflower);
114 113
 
115
-  }
114
+    }
116 115
 
117
-  // Return a copy of this frame with $node as its node
118
-  function copy(DomNode $node) {
116
+    // Return a copy of this frame with $node as its node
117
+    function copy(DomNode $node) {
119 118
     $frame = new Frame($node);
120 119
     $frame->set_style(clone $this->_frame->get_original_style());
121 120
     $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf);
122 121
     $deco->set_root($this->_root);
123 122
     return $deco;
124
-  }
125
-
126
-  /**
127
-   * Create a deep copy: copy this node and all children
128
-   *
129
-   * @return Frame
130
-   */
131
-  function deep_copy() {
123
+    }
124
+
125
+    /**
126
+     * Create a deep copy: copy this node and all children
127
+     *
128
+     * @return Frame
129
+     */
130
+    function deep_copy() {
132 131
     $frame = new Frame($this->get_node()->cloneNode());
133 132
     $frame->set_style(clone $this->_frame->get_original_style());
134 133
     $deco = Frame_Factory::decorate_frame($frame, $this->_dompdf);
135 134
     $deco->set_root($this->_root);
136 135
 
137 136
     foreach ($this->get_children() as $child)
138
-      $deco->append_child($child->deep_copy());
137
+        $deco->append_child($child->deep_copy());
139 138
 
140 139
     return $deco;
141
-  }
142
-  //........................................................................
140
+    }
141
+    //........................................................................
143 142
   
144
-  // Delegate calls to decorated frame object
145
-  function reset() {
143
+    // Delegate calls to decorated frame object
144
+    function reset() {
146 145
     $this->_frame->reset();
147 146
 
148 147
     // Reset all children
149 148
     foreach ($this->get_children() as $child)
150
-      $child->reset();
149
+        $child->reset();
151 150
 
152
-  }
151
+    }
153 152
   
154
-  function get_node() { return $this->_frame->get_node(); }
155
-  function get_id() { return $this->_frame->get_id(); }
156
-  function get_style() { return $this->_frame->get_style(); }
157
-  function get_original_style() { return $this->_frame->get_original_style(); }
158
-  function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); }
159
-  function get_position($i = null) { return $this->_frame->get_position($i); }
160
-  function get_dompdf() { return $this->_dompdf; }
153
+    function get_node() { return $this->_frame->get_node(); }
154
+    function get_id() { return $this->_frame->get_id(); }
155
+    function get_style() { return $this->_frame->get_style(); }
156
+    function get_original_style() { return $this->_frame->get_original_style(); }
157
+    function get_containing_block($i = null) { return $this->_frame->get_containing_block($i); }
158
+    function get_position($i = null) { return $this->_frame->get_position($i); }
159
+    function get_dompdf() { return $this->_dompdf; }
161 160
 //   function get_decorator() {
162 161
 //     if ( isset($this->_decorator) )
163 162
 //       return $this->_decorator;
@@ -165,201 +164,201 @@  discard block
 block discarded – undo
165 164
 //       return $this;
166 165
 //   }
167 166
 
168
-  function get_margin_height() { return $this->_frame->get_margin_height(); }
169
-  function get_margin_width() { return $this->_frame->get_margin_width(); }
170
-  function get_padding_box() { return $this->_frame->get_padding_box(); }
171
-  function get_border_box() { return $this->_frame->get_border_box(); }
167
+    function get_margin_height() { return $this->_frame->get_margin_height(); }
168
+    function get_margin_width() { return $this->_frame->get_margin_width(); }
169
+    function get_padding_box() { return $this->_frame->get_padding_box(); }
170
+    function get_border_box() { return $this->_frame->get_border_box(); }
172 171
 
173
-  function set_id($id) { $this->_frame->set_id($id); }
174
-  function set_style(Style $style) { $this->_frame->set_style($style); }
172
+    function set_id($id) { $this->_frame->set_id($id); }
173
+    function set_style(Style $style) { $this->_frame->set_style($style); }
175 174
 
176
-  function set_containing_block($x = null, $y = null, $w = null, $h = null) {
175
+    function set_containing_block($x = null, $y = null, $w = null, $h = null) {
177 176
     $this->_frame->set_containing_block($x, $y, $w, $h);
178
-  }
177
+    }
179 178
 
180
-  function set_position($x = null, $y = null) {
179
+    function set_position($x = null, $y = null) {
181 180
     $this->_frame->set_position($x, $y);
182
-  }
183
-  function __toString() { return $this->_frame->__toString(); }
181
+    }
182
+    function __toString() { return $this->_frame->__toString(); }
184 183
   
185
-  function prepend_child(Frame $child, $update_node = true) {
184
+    function prepend_child(Frame $child, $update_node = true) {
186 185
     while ( $child instanceof Frame_Decorator )
187
-      $child = $child->_frame;
186
+        $child = $child->_frame;
188 187
     
189 188
     $this->_frame->prepend_child($child, $update_node);
190
-  }
189
+    }
191 190
 
192
-  function append_child(Frame $child, $update_node = true) {
191
+    function append_child(Frame $child, $update_node = true) {
193 192
     while ( $child instanceof Frame_Decorator )
194
-      $child = $child->_frame;
193
+        $child = $child->_frame;
195 194
 
196 195
     $this->_frame->append_child($child, $update_node);
197
-  }
196
+    }
198 197
 
199
-  function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) {
198
+    function insert_child_before(Frame $new_child, Frame $ref, $update_node = true) {
200 199
     while ( $new_child instanceof Frame_Decorator )
201
-      $new_child = $new_child->_frame;
200
+        $new_child = $new_child->_frame;
202 201
 
203 202
     if ( $ref instanceof Frame_Decorator )
204
-      $ref = $ref->_frame;
203
+        $ref = $ref->_frame;
205 204
 
206 205
     $this->_frame->insert_child_before($new_child, $ref, $update_node);
207
-  }
206
+    }
208 207
 
209
-  function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) {
208
+    function insert_child_after(Frame $new_child, Frame $ref, $update_node = true) {
210 209
     while ( $new_child instanceof Frame_Decorator )
211
-      $new_child = $new_child->_frame;
210
+        $new_child = $new_child->_frame;
212 211
 
213 212
     while ( $ref instanceof Frame_Decorator )
214
-      $ref = $ref->_frame;
213
+        $ref = $ref->_frame;
215 214
     
216 215
     $this->_frame->insert_child_after($new_child, $ref, $update_node);
217
-  }
216
+    }
218 217
 
219
-  function remove_child(Frame $child, $update_node = true) {
218
+    function remove_child(Frame $child, $update_node = true) {
220 219
     while  ( $child instanceof Frame_Decorator )
221
-      $child = $new_child->_frame;
220
+        $child = $new_child->_frame;
222 221
 
223 222
     $this->_frame->remove_child($child, $update_node);
224
-  }
223
+    }
225 224
   
226
-  //........................................................................
225
+    //........................................................................
227 226
 
228
-  function get_parent() {
227
+    function get_parent() {
229 228
 
230 229
     $p = $this->_frame->get_parent();
231 230
     
232 231
     if ( $p && $deco = $p->get_decorator() ) {
233
-      while ( $tmp = $deco->get_decorator() )
232
+        while ( $tmp = $deco->get_decorator() )
234 233
         $deco = $tmp;      
235
-      return $deco;
234
+        return $deco;
236 235
     } else if ( $p )
237
-      return $p;
236
+        return $p;
238 237
     else
239
-      return null;
240
-  }
238
+        return null;
239
+    }
241 240
 
242
-  function get_first_child() {
241
+    function get_first_child() {
243 242
     $c = $this->_frame->get_first_child();
244 243
     if ( $c && $deco = $c->get_decorator() ) {
245
-      while ( $tmp = $deco->get_decorator() )
244
+        while ( $tmp = $deco->get_decorator() )
246 245
         $deco = $tmp;      
247
-      return $deco;
246
+        return $deco;
248 247
     } else if ( $c )
249
-      return $c;
248
+        return $c;
250 249
     else
251
-      return null;
252
-  }
250
+        return null;
251
+    }
253 252
 
254
-  function get_last_child() {
253
+    function get_last_child() {
255 254
     $c = $this->_frame->get_last_child();
256 255
     if ( $c && $deco = $c->get_decorator() ) {
257
-      while ( $tmp = $deco->get_decorator() )
256
+        while ( $tmp = $deco->get_decorator() )
258 257
         $deco = $tmp;      
259
-      return $deco;
258
+        return $deco;
260 259
     } else if ( $c )
261
-      return $c;
260
+        return $c;
262 261
     else
263
-      return null;
264
-  }
262
+        return null;
263
+    }
265 264
 
266
-  function get_prev_sibling() {
265
+    function get_prev_sibling() {
267 266
     $s = $this->_frame->get_prev_sibling();
268 267
     if ( $s && $deco = $s->get_decorator() ) {
269
-      while ( $tmp = $deco->get_decorator() )
268
+        while ( $tmp = $deco->get_decorator() )
270 269
         $deco = $tmp;      
271
-      return $deco;
270
+        return $deco;
272 271
     } else if ( $s )
273
-      return $s;
272
+        return $s;
274 273
     else
275
-      return null;
276
-  }
274
+        return null;
275
+    }
277 276
   
278
-  function get_next_sibling() {
277
+    function get_next_sibling() {
279 278
     $s = $this->_frame->get_next_sibling();
280 279
     if ( $s && $deco = $s->get_decorator() ) {
281
-      while ( $tmp = $deco->get_decorator() )
280
+        while ( $tmp = $deco->get_decorator() )
282 281
         $deco = $tmp;      
283
-      return $deco;
282
+        return $deco;
284 283
     } else if ( $s )
285
-      return $s;
284
+        return $s;
286 285
     else
287
-      return null;
288
-  }
286
+        return null;
287
+    }
289 288
 
290
-  function get_children() {
289
+    function get_children() {
291 290
     return new FrameList($this);
292
-  }
291
+    }
293 292
 
294
-  function get_subtree() {
293
+    function get_subtree() {
295 294
     return new FrameTreeList($this);
296
-  }
295
+    }
297 296
   
298
-  //........................................................................
297
+    //........................................................................
299 298
 
300
-  function set_positioner(Positioner $posn) {
299
+    function set_positioner(Positioner $posn) {
301 300
     $this->_positioner = $posn;
302 301
     if ( $this->_frame instanceof Frame_Decorator )
303
-      $this->_frame->set_positioner($posn);
304
-  }
302
+        $this->_frame->set_positioner($posn);
303
+    }
305 304
   
306
-  //........................................................................
305
+    //........................................................................
307 306
 
308
-  function set_reflower(Frame_Reflower $reflower) {
307
+    function set_reflower(Frame_Reflower $reflower) {
309 308
     $this->_reflower = $reflower;
310 309
     if ( $this->_frame instanceof Frame_Decorator )
311
-      $this->_frame->set_reflower( $reflower );
312
-  }
310
+        $this->_frame->set_reflower( $reflower );
311
+    }
313 312
   
314
-  function get_reflower() { return $this->_reflower; }
313
+    function get_reflower() { return $this->_reflower; }
315 314
   
316
-  //........................................................................
315
+    //........................................................................
317 316
   
318
-  function set_root(Frame $root) {
317
+    function set_root(Frame $root) {
319 318
     $this->_root = $root;
320
-      if ( $this->_frame instanceof Frame_Decorator )
319
+        if ( $this->_frame instanceof Frame_Decorator )
321 320
         $this->_frame->set_root($root);
322
-  }
321
+    }
323 322
   
324
-  function get_root() { return $this->_root; }
323
+    function get_root() { return $this->_root; }
325 324
   
326
-  //........................................................................
325
+    //........................................................................
327 326
 
328
-  function find_block_parent() {
327
+    function find_block_parent() {
329 328
 
330 329
     // Find our nearest block level parent
331 330
     $p = $this->get_parent();
332 331
     
333 332
     while ( $p ) {
334
-      if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) )
333
+        if ( in_array($p->get_style()->display, Style::$BLOCK_TYPES) )
335 334
         break;
336 335
 
337
-      $p = $p->get_parent();
336
+        $p = $p->get_parent();
338 337
     }
339 338
 
340 339
     return $p;
341
-  }
340
+    }
342 341
 
343
-  //........................................................................
342
+    //........................................................................
344 343
 
345
-  /**
346
-   * split this frame at $child.
347
-   *
348
-   * The current frame is cloned and $child and all children following
349
-   * $child are added to the clone.  The clone is then passed to the
350
-   * current frame's parent->split() method.
351
-   *
352
-   * @param Frame $child
353
-   */
354
-  function split($child = null) {
344
+    /**
345
+     * split this frame at $child.
346
+     *
347
+     * The current frame is cloned and $child and all children following
348
+     * $child are added to the clone.  The clone is then passed to the
349
+     * current frame's parent->split() method.
350
+     *
351
+     * @param Frame $child
352
+     */
353
+    function split($child = null) {
355 354
 
356 355
     if ( is_null( $child ) ) {
357
-      $this->get_parent()->split($this);
358
-      return;
356
+        $this->get_parent()->split($this);
357
+        return;
359 358
     }
360 359
     
361 360
     if ( $child->get_parent() !== $this )
362
-      throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
361
+        throw new DOMPDF_Exception("Unable to split: frame is not a child of this one.");
363 362
 
364 363
     $split = $this->copy( $this->_frame->get_node()->cloneNode() );
365 364
     $split->reset();
@@ -368,29 +367,29 @@  discard block
 block discarded – undo
368 367
     // Add $frame and all following siblings to the new split node
369 368
     $iter = $child;
370 369
     while ($iter) {
371
-      $frame = $iter;      
372
-      $iter = $iter->get_next_sibling();
373
-      $frame->reset();
374
-      $split->append_child($frame);
370
+        $frame = $iter;      
371
+        $iter = $iter->get_next_sibling();
372
+        $frame->reset();
373
+        $split->append_child($frame);
375 374
     }
376 375
 
377 376
     $this->get_parent()->split($split);
378
-  }
377
+    }
379 378
 
380
-  //........................................................................
379
+    //........................................................................
381 380
 
382
-  final function position() { $this->_positioner->position();  }
381
+    final function position() { $this->_positioner->position();  }
383 382
   
384
-  final function reflow() {
383
+    final function reflow() {
385 384
     // Uncomment this to see the frames before they're laid out, instead of
386 385
     // during rendering.
387 386
     //echo $this->_frame; flush();
388 387
     $this->_reflower->reflow();
389
-  }
388
+    }
390 389
 
391
-  final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); }
390
+    final function get_min_max_width() { return $this->get_reflower()->get_min_max_width(); }
392 391
   
393
-  //........................................................................
392
+    //........................................................................
394 393
 
395 394
 
396 395
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/frame_factory.cls.php 5 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -60,6 +60,10 @@
 block discarded – undo
60 60
   }
61 61
 
62 62
   // FIXME: this is admittedly a little smelly...
63
+
64
+  /**
65
+   * @param DOMPDF $dompdf
66
+   */
63 67
   static function decorate_frame(Frame $frame, $dompdf) {
64 68
     if ( is_null($dompdf) )
65 69
       throw new Exception("foo");
Please login to merge, or discard this patch.
Indentation   +53 added lines, -54 removed lines patch added patch discarded remove patch
@@ -34,7 +34,6 @@  discard block
 block discarded – undo
34 34
  * @copyright 2004 Benj Carson
35 35
  * @author Benj Carson <[email protected]>
36 36
  * @package dompdf
37
-
38 37
  */
39 38
 
40 39
 /* $Id: frame_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -52,119 +51,119 @@  discard block
 block discarded – undo
52 51
  */
53 52
 class Frame_Factory {
54 53
 
55
-  static function decorate_root(Frame $root, DOMPDF $dompdf) {
54
+    static function decorate_root(Frame $root, DOMPDF $dompdf) {
56 55
     $frame = new Page_Frame_Decorator($root, $dompdf);
57 56
     $frame->set_reflower( new Page_Frame_Reflower($frame) );
58 57
     $root->set_decorator($frame);
59 58
     return $frame;
60
-  }
59
+    }
61 60
 
62
-  // FIXME: this is admittedly a little smelly...
63
-  static function decorate_frame(Frame $frame, $dompdf) {
61
+    // FIXME: this is admittedly a little smelly...
62
+    static function decorate_frame(Frame $frame, $dompdf) {
64 63
     if ( is_null($dompdf) )
65
-      throw new Exception("foo");
64
+        throw new Exception("foo");
66 65
     switch ($frame->get_style()->display) {
67 66
       
68 67
     case "block":
69 68
       $positioner = "Block";        
70
-      $decorator = "Block";
71
-      $reflower = "Block";
72
-      break;
69
+        $decorator = "Block";
70
+        $reflower = "Block";
71
+        break;
73 72
     
74 73
     case "inline-block":
75 74
       $positioner = "Inline";
76
-      $decorator = "Block";
77
-      $reflower = "Block";
78
-      break;
75
+        $decorator = "Block";
76
+        $reflower = "Block";
77
+        break;
79 78
 
80 79
     case "inline":
81 80
       $positioner = "Inline";
82
-      if ( $frame->get_node()->nodeName === "#text" ) {
81
+        if ( $frame->get_node()->nodeName === "#text" ) {
83 82
         $decorator = "Text";
84 83
         $reflower = "Text";
85
-      } else {
84
+        } else {
86 85
         $decorator = "Inline";
87 86
         $reflower = "Inline";
88
-      }
89
-      break;   
87
+        }
88
+        break;   
90 89
 
91 90
     case "table":
92 91
       $positioner = "Block";
93
-      $decorator = "Table";
94
-      $reflower = "Table";
95
-      break;
92
+        $decorator = "Table";
93
+        $reflower = "Table";
94
+        break;
96 95
       
97 96
     case "inline-table":
98 97
       $positioner = "Inline";
99
-      $decorator = "Table";
100
-      $reflower = "Table";
101
-      break;
98
+        $decorator = "Table";
99
+        $reflower = "Table";
100
+        break;
102 101
 
103 102
     case "table-row-group":
104 103
     case "table-header-group":
105 104
     case "table-footer-group":
106 105
       $positioner = "Null";
107
-      $decorator = "Table_Row_Group";
108
-      $reflower = "Table_Row_Group";
109
-      break;
106
+        $decorator = "Table_Row_Group";
107
+        $reflower = "Table_Row_Group";
108
+        break;
110 109
       
111 110
     case "table-row":
112 111
       $positioner = "Null";
113
-      $decorator = "Table_Row";
114
-      $reflower = "Table_Row";
115
-      break;
112
+        $decorator = "Table_Row";
113
+        $reflower = "Table_Row";
114
+        break;
116 115
 
117 116
     case "table-cell":
118 117
       $positioner = "Table_Cell";
119
-      $decorator = "Table_Cell";
120
-      $reflower = "Table_Cell";
121
-      break;
118
+        $decorator = "Table_Cell";
119
+        $reflower = "Table_Cell";
120
+        break;
122 121
         
123 122
     case "list-item":
124 123
       $positioner = "Block";
125
-      $decorator  = "Block";
126
-      $reflower   = "Block";
127
-      break;
124
+        $decorator  = "Block";
125
+        $reflower   = "Block";
126
+        break;
128 127
 
129 128
     case "-dompdf-list-bullet":
130 129
       if ( $frame->get_style()->list_style_position === "inside" )
131 130
         $positioner = "Inline";
132
-      else        
131
+        else        
133 132
         $positioner = "List_Bullet";
134 133
 
135
-      if ( $frame->get_style()->list_style_image !== "none" )
134
+        if ( $frame->get_style()->list_style_image !== "none" )
136 135
         $decorator = "List_Bullet_Image";
137
-      else
136
+        else
138 137
         $decorator = "List_Bullet";
139 138
       
140
-      $reflower = "List_Bullet";
141
-      break;
139
+        $reflower = "List_Bullet";
140
+        break;
142 141
 
143 142
     case "-dompdf-image":
144 143
       $positioner = "Inline";
145
-      $decorator = "Image";
146
-      $reflower = "Image";
147
-      break;
144
+        $decorator = "Image";
145
+        $reflower = "Image";
146
+        break;
148 147
       
149 148
     case "-dompdf-br":
150 149
       $positioner = "Inline";
151
-      $decorator = "Inline";
152
-      $reflower = "Inline";
153
-      break;
150
+        $decorator = "Inline";
151
+        $reflower = "Inline";
152
+        break;
154 153
 
155 154
     default:
156 155
       // FIXME: should throw some sort of warning or something?
157 156
     case "none":
158 157
       $positioner = "Null";
159
-      $decorator = "Null";
160
-      $reflower = "Null";
161
-      break;
158
+        $decorator = "Null";
159
+        $reflower = "Null";
160
+        break;
162 161
 
163 162
     }
164 163
 
165 164
     if ( $frame->get_style()->position === "absolute" ||
166 165
          $frame->get_style()->position === "fixed" )
167
-      $positioner = "Absolute";
166
+        $positioner = "Absolute";
168 167
     
169 168
     $positioner .= "_Positioner";
170 169
     $decorator .= "_Frame_Decorator";
@@ -176,10 +175,10 @@  discard block
 block discarded – undo
176 175
     
177 176
     // Generated content is a special case
178 177
     if ( $frame->get_node()->nodeName === "_dompdf_generated" ) {
179
-      // Decorate the reflower
180
-      $gen = new Generated_Frame_Reflower( $deco );
181
-      $gen->set_reflower( $reflow );
182
-      $reflow = $gen;
178
+        // Decorate the reflower
179
+        $gen = new Generated_Frame_Reflower( $deco );
180
+        $gen->set_reflower( $reflow );
181
+        $reflow = $gen;
183 182
     }
184 183
     
185 184
     $deco->set_reflower( $reflow );
@@ -204,6 +203,6 @@  discard block
 block discarded – undo
204 203
 //     }   
205 204
     
206 205
     return $deco;
207
-  }
206
+    }
208 207
   
209 208
 }
Please login to merge, or discard this patch.
Switch Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -65,100 +65,100 @@
 block discarded – undo
65 65
       throw new Exception("foo");
66 66
     switch ($frame->get_style()->display) {
67 67
       
68
-    case "block":
69
-      $positioner = "Block";        
70
-      $decorator = "Block";
71
-      $reflower = "Block";
72
-      break;
68
+        case "block":
69
+          $positioner = "Block";        
70
+          $decorator = "Block";
71
+          $reflower = "Block";
72
+          break;
73 73
     
74
-    case "inline-block":
75
-      $positioner = "Inline";
76
-      $decorator = "Block";
77
-      $reflower = "Block";
78
-      break;
79
-
80
-    case "inline":
81
-      $positioner = "Inline";
82
-      if ( $frame->get_node()->nodeName === "#text" ) {
83
-        $decorator = "Text";
84
-        $reflower = "Text";
85
-      } else {
86
-        $decorator = "Inline";
87
-        $reflower = "Inline";
88
-      }
89
-      break;   
90
-
91
-    case "table":
92
-      $positioner = "Block";
93
-      $decorator = "Table";
94
-      $reflower = "Table";
95
-      break;
74
+        case "inline-block":
75
+          $positioner = "Inline";
76
+          $decorator = "Block";
77
+          $reflower = "Block";
78
+          break;
79
+
80
+        case "inline":
81
+          $positioner = "Inline";
82
+          if ( $frame->get_node()->nodeName === "#text" ) {
83
+            $decorator = "Text";
84
+            $reflower = "Text";
85
+          } else {
86
+            $decorator = "Inline";
87
+            $reflower = "Inline";
88
+          }
89
+          break;   
90
+
91
+        case "table":
92
+          $positioner = "Block";
93
+          $decorator = "Table";
94
+          $reflower = "Table";
95
+          break;
96 96
       
97
-    case "inline-table":
98
-      $positioner = "Inline";
99
-      $decorator = "Table";
100
-      $reflower = "Table";
101
-      break;
102
-
103
-    case "table-row-group":
104
-    case "table-header-group":
105
-    case "table-footer-group":
106
-      $positioner = "Null";
107
-      $decorator = "Table_Row_Group";
108
-      $reflower = "Table_Row_Group";
109
-      break;
97
+        case "inline-table":
98
+          $positioner = "Inline";
99
+          $decorator = "Table";
100
+          $reflower = "Table";
101
+          break;
102
+
103
+        case "table-row-group":
104
+        case "table-header-group":
105
+        case "table-footer-group":
106
+          $positioner = "Null";
107
+          $decorator = "Table_Row_Group";
108
+          $reflower = "Table_Row_Group";
109
+          break;
110 110
       
111
-    case "table-row":
112
-      $positioner = "Null";
113
-      $decorator = "Table_Row";
114
-      $reflower = "Table_Row";
115
-      break;
116
-
117
-    case "table-cell":
118
-      $positioner = "Table_Cell";
119
-      $decorator = "Table_Cell";
120
-      $reflower = "Table_Cell";
121
-      break;
111
+        case "table-row":
112
+          $positioner = "Null";
113
+          $decorator = "Table_Row";
114
+          $reflower = "Table_Row";
115
+          break;
116
+
117
+        case "table-cell":
118
+          $positioner = "Table_Cell";
119
+          $decorator = "Table_Cell";
120
+          $reflower = "Table_Cell";
121
+          break;
122 122
         
123
-    case "list-item":
124
-      $positioner = "Block";
125
-      $decorator  = "Block";
126
-      $reflower   = "Block";
127
-      break;
128
-
129
-    case "-dompdf-list-bullet":
130
-      if ( $frame->get_style()->list_style_position === "inside" )
131
-        $positioner = "Inline";
132
-      else        
133
-        $positioner = "List_Bullet";
134
-
135
-      if ( $frame->get_style()->list_style_image !== "none" )
136
-        $decorator = "List_Bullet_Image";
137
-      else
138
-        $decorator = "List_Bullet";
123
+        case "list-item":
124
+          $positioner = "Block";
125
+          $decorator  = "Block";
126
+          $reflower   = "Block";
127
+          break;
128
+
129
+        case "-dompdf-list-bullet":
130
+          if ( $frame->get_style()->list_style_position === "inside" )
131
+            $positioner = "Inline";
132
+          else        
133
+            $positioner = "List_Bullet";
134
+
135
+          if ( $frame->get_style()->list_style_image !== "none" )
136
+            $decorator = "List_Bullet_Image";
137
+          else
138
+            $decorator = "List_Bullet";
139 139
       
140
-      $reflower = "List_Bullet";
141
-      break;
142
-
143
-    case "-dompdf-image":
144
-      $positioner = "Inline";
145
-      $decorator = "Image";
146
-      $reflower = "Image";
147
-      break;
140
+          $reflower = "List_Bullet";
141
+          break;
142
+
143
+        case "-dompdf-image":
144
+          $positioner = "Inline";
145
+          $decorator = "Image";
146
+          $reflower = "Image";
147
+          break;
148 148
       
149
-    case "-dompdf-br":
150
-      $positioner = "Inline";
151
-      $decorator = "Inline";
152
-      $reflower = "Inline";
153
-      break;
154
-
155
-    default:
156
-      // FIXME: should throw some sort of warning or something?
157
-    case "none":
158
-      $positioner = "Null";
159
-      $decorator = "Null";
160
-      $reflower = "Null";
161
-      break;
149
+        case "-dompdf-br":
150
+          $positioner = "Inline";
151
+          $decorator = "Inline";
152
+          $reflower = "Inline";
153
+          break;
154
+
155
+        default:
156
+          // FIXME: should throw some sort of warning or something?
157
+        case "none":
158
+          $positioner = "Null";
159
+          $decorator = "Null";
160
+          $reflower = "Null";
161
+          break;
162 162
 
163 163
     }
164 164
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -54,14 +54,14 @@  discard block
 block discarded – undo
54 54
 
55 55
   static function decorate_root(Frame $root, DOMPDF $dompdf) {
56 56
     $frame = new Page_Frame_Decorator($root, $dompdf);
57
-    $frame->set_reflower( new Page_Frame_Reflower($frame) );
57
+    $frame->set_reflower(new Page_Frame_Reflower($frame));
58 58
     $root->set_decorator($frame);
59 59
     return $frame;
60 60
   }
61 61
 
62 62
   // FIXME: this is admittedly a little smelly...
63 63
   static function decorate_frame(Frame $frame, $dompdf) {
64
-    if ( is_null($dompdf) )
64
+    if (is_null($dompdf))
65 65
       throw new Exception("foo");
66 66
     switch ($frame->get_style()->display) {
67 67
       
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 
80 80
     case "inline":
81 81
       $positioner = "Inline";
82
-      if ( $frame->get_node()->nodeName === "#text" ) {
82
+      if ($frame->get_node()->nodeName === "#text") {
83 83
         $decorator = "Text";
84 84
         $reflower = "Text";
85 85
       } else {
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
       break;
128 128
 
129 129
     case "-dompdf-list-bullet":
130
-      if ( $frame->get_style()->list_style_position === "inside" )
130
+      if ($frame->get_style()->list_style_position === "inside")
131 131
         $positioner = "Inline";
132 132
       else        
133 133
         $positioner = "List_Bullet";
134 134
 
135
-      if ( $frame->get_style()->list_style_image !== "none" )
135
+      if ($frame->get_style()->list_style_image !== "none")
136 136
         $decorator = "List_Bullet_Image";
137 137
       else
138 138
         $decorator = "List_Bullet";
@@ -162,8 +162,8 @@  discard block
 block discarded – undo
162 162
 
163 163
     }
164 164
 
165
-    if ( $frame->get_style()->position === "absolute" ||
166
-         $frame->get_style()->position === "fixed" )
165
+    if ($frame->get_style()->position === "absolute" ||
166
+         $frame->get_style()->position === "fixed")
167 167
       $positioner = "Absolute";
168 168
     
169 169
     $positioner .= "_Positioner";
@@ -171,18 +171,18 @@  discard block
 block discarded – undo
171 171
     $reflower .= "_Frame_Reflower";
172 172
 
173 173
     $deco = new $decorator($frame, $dompdf);
174
-    $deco->set_positioner( new $positioner($deco) );
174
+    $deco->set_positioner(new $positioner($deco));
175 175
     $reflow = new $reflower($deco);
176 176
     
177 177
     // Generated content is a special case
178
-    if ( $frame->get_node()->nodeName === "_dompdf_generated" ) {
178
+    if ($frame->get_node()->nodeName === "_dompdf_generated") {
179 179
       // Decorate the reflower
180
-      $gen = new Generated_Frame_Reflower( $deco );
181
-      $gen->set_reflower( $reflow );
180
+      $gen = new Generated_Frame_Reflower($deco);
181
+      $gen->set_reflower($reflow);
182 182
       $reflow = $gen;
183 183
     }
184 184
     
185
-    $deco->set_reflower( $reflow );
185
+    $deco->set_reflower($reflow);
186 186
 
187 187
     // Images are a special case
188 188
 //    if ( $frame->get_node()->nodeName === "img" ) {
Please login to merge, or discard this patch.
Braces   +17 added lines, -13 removed lines patch added patch discarded remove patch
@@ -61,8 +61,9 @@  discard block
 block discarded – undo
61 61
 
62 62
   // FIXME: this is admittedly a little smelly...
63 63
   static function decorate_frame(Frame $frame, $dompdf) {
64
-    if ( is_null($dompdf) )
65
-      throw new Exception("foo");
64
+    if ( is_null($dompdf) ) {
65
+          throw new Exception("foo");
66
+    }
66 67
     switch ($frame->get_style()->display) {
67 68
       
68 69
     case "block":
@@ -127,15 +128,17 @@  discard block
 block discarded – undo
127 128
       break;
128 129
 
129 130
     case "-dompdf-list-bullet":
130
-      if ( $frame->get_style()->list_style_position === "inside" )
131
-        $positioner = "Inline";
132
-      else        
133
-        $positioner = "List_Bullet";
134
-
135
-      if ( $frame->get_style()->list_style_image !== "none" )
136
-        $decorator = "List_Bullet_Image";
137
-      else
138
-        $decorator = "List_Bullet";
131
+      if ( $frame->get_style()->list_style_position === "inside" ) {
132
+              $positioner = "Inline";
133
+      } else {
134
+              $positioner = "List_Bullet";
135
+      }
136
+
137
+      if ( $frame->get_style()->list_style_image !== "none" ) {
138
+              $decorator = "List_Bullet_Image";
139
+      } else {
140
+              $decorator = "List_Bullet";
141
+      }
139 142
       
140 143
       $reflower = "List_Bullet";
141 144
       break;
@@ -163,8 +166,9 @@  discard block
 block discarded – undo
163 166
     }
164 167
 
165 168
     if ( $frame->get_style()->position === "absolute" ||
166
-         $frame->get_style()->position === "fixed" )
167
-      $positioner = "Absolute";
169
+         $frame->get_style()->position === "fixed" ) {
170
+          $positioner = "Absolute";
171
+    }
168 172
     
169 173
     $positioner .= "_Positioner";
170 174
     $decorator .= "_Frame_Decorator";
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/functions.inc.php 5 patches
Doc Comments   +17 added lines patch added patch discarded remove patch
@@ -305,6 +305,10 @@  discard block
 block discarded – undo
305 305
  */
306 306
 
307 307
 if ( !function_exists("mb_convert_encoding") ) {
308
+
309
+  /**
310
+   * @param string|null $to_encoding
311
+   */
308 312
   function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') {
309 313
     if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') {
310 314
       return utf8_encode($data);
@@ -327,6 +331,10 @@  discard block
 block discarded – undo
327 331
 }
328 332
 
329 333
 if ( !function_exists("mb_internal_encoding") ) {
334
+
335
+  /**
336
+   * @param string $encoding
337
+   */
330 338
   function mb_internal_encoding($encoding=NULL) {
331 339
     if (isset($encoding)) {
332 340
       return true;
@@ -365,6 +373,10 @@  discard block
 block discarded – undo
365 373
 }
366 374
 
367 375
 if ( !function_exists("mb_strtoupper") ) {
376
+
377
+  /**
378
+   * @param string $str
379
+   */
368 380
   function mb_strtoupper($str) {
369 381
     return strtoupper($str);
370 382
   }
@@ -380,6 +392,10 @@  discard block
 block discarded – undo
380 392
 }
381 393
 
382 394
 if ( !function_exists("mb_substr_count") ) {
395
+
396
+  /**
397
+   * @param string $needle
398
+   */
383 399
   function mb_substr_count($haystack, $needle) {
384 400
     return substr_count($haystack, $needle);
385 401
   }
@@ -442,6 +458,7 @@  discard block
 block discarded – undo
442 458
  * Print debug messages
443 459
  *
444 460
  * @param string $type  The type of debug messages to print
461
+ * @param string $msg
445 462
  */
446 463
 function dompdf_debug($type, $msg) {
447 464
   global $_DOMPDF_DEBUG_TYPES;
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -63,18 +63,18 @@  discard block
 block discarded – undo
63 63
  */
64 64
 if ( !function_exists("pre_r") ) {
65 65
 function pre_r($mixed, $return = false) {
66
-  if ($return)
66
+    if ($return)
67 67
     return "<pre>" . print_r($mixed, true) . "</pre>";
68 68
 
69
-  if ( php_sapi_name() !== "cli")
69
+    if ( php_sapi_name() !== "cli")
70 70
     echo ("<pre>");
71
-  print_r($mixed);
71
+    print_r($mixed);
72 72
 
73
-  if ( php_sapi_name() !== "cli")
73
+    if ( php_sapi_name() !== "cli")
74 74
     echo("</pre>");
75
-  else
75
+    else
76 76
     echo ("\n");
77
-  flush();
77
+    flush();
78 78
 
79 79
 }
80 80
 }
@@ -89,10 +89,10 @@  discard block
 block discarded – undo
89 89
  */
90 90
 if ( !function_exists("pre_var_dump") ) {
91 91
 function pre_var_dump($mixed) {
92
-  if ( php_sapi_name() !== "cli")
92
+    if ( php_sapi_name() !== "cli")
93 93
     echo("<pre>");
94
-  var_dump($mixed);
95
-  if ( php_sapi_name() !== "cli")
94
+    var_dump($mixed);
95
+    if ( php_sapi_name() !== "cli")
96 96
     echo("</pre>");
97 97
 }
98 98
 }
@@ -115,41 +115,41 @@  discard block
 block discarded – undo
115 115
  * is appended (o.k. also for Windows)
116 116
  */
117 117
 function build_url($protocol, $host, $base_path, $url) {
118
-  if ( mb_strlen($url) == 0 ) {
118
+    if ( mb_strlen($url) == 0 ) {
119 119
     //return $protocol . $host . rtrim($base_path, "/\\") . "/";
120 120
     return $protocol . $host . $base_path;
121
-  }
121
+    }
122 122
 
123
-  // Is the url already fully qualified?
124
-  if ( mb_strpos($url, "://") !== false )
123
+    // Is the url already fully qualified?
124
+    if ( mb_strpos($url, "://") !== false )
125 125
     return $url;
126 126
 
127
-  $ret = $protocol;
127
+    $ret = $protocol;
128 128
 
129
-  if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) {
129
+    if (!in_array(mb_strtolower($protocol), array("http://", "https://", "ftp://", "ftps://"))) {
130 130
     //On Windows local file, an abs path can begin also with a '\' or a drive letter and colon
131 131
     //drive: followed by a relative path would be a drive specific default folder.
132 132
     //not known in php app code, treat as abs path
133 133
     //($url[1] !== ':' || ($url[2]!=='\\' && $url[2]!=='/'))
134 134
     if ($url[0] !== '/' && (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN' || ($url[0] !== '\\' && $url[1] !== ':'))) {
135
-      // For rel path and local acess we ignore the host, and run the path through realpath()
136
-      $ret .= realpath($base_path).'/';
135
+        // For rel path and local acess we ignore the host, and run the path through realpath()
136
+        $ret .= realpath($base_path).'/';
137 137
     }
138 138
     $ret .= $url;
139 139
     return $ret;
140
-  }
140
+    }
141 141
 
142
-  //remote urls with backslash in html/css are not really correct, but lets be genereous
143
-  if ( $url[0] === '/' || $url[0] === '\\' ) {
142
+    //remote urls with backslash in html/css are not really correct, but lets be genereous
143
+    if ( $url[0] === '/' || $url[0] === '\\' ) {
144 144
     // Absolute path
145 145
     $ret .= $host . $url;
146
-  } else {
146
+    } else {
147 147
     // Relative path
148 148
     //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : "";
149 149
     $ret .= $host . $base_path . $url;
150
-  }
150
+    }
151 151
 
152
-  return $ret;
152
+    return $ret;
153 153
 
154 154
 }
155 155
 
@@ -161,56 +161,56 @@  discard block
 block discarded – undo
161 161
  * @return array
162 162
  */
163 163
 function explode_url($url) {
164
-  $protocol = "";
165
-  $host = "";
166
-  $path = "";
167
-  $file = "";
164
+    $protocol = "";
165
+    $host = "";
166
+    $path = "";
167
+    $file = "";
168 168
 
169
-  $arr = parse_url($url);
169
+    $arr = parse_url($url);
170 170
 
171
-  if ( isset($arr["scheme"]) &&
171
+    if ( isset($arr["scheme"]) &&
172 172
        $arr["scheme"] !== "file" &&
173 173
        mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters...
174 174
     {
175 175
     $protocol = $arr["scheme"] . "://";
176 176
 
177 177
     if ( isset($arr["user"]) ) {
178
-      $host .= $arr["user"];
178
+        $host .= $arr["user"];
179 179
 
180
-      if ( isset($arr["pass"]) )
180
+        if ( isset($arr["pass"]) )
181 181
         $host .= "@" . $arr["pass"];
182 182
 
183
-      $host .= ":";
183
+        $host .= ":";
184 184
     }
185 185
 
186 186
     if ( isset($arr["host"]) )
187
-      $host .= $arr["host"];
187
+        $host .= $arr["host"];
188 188
 
189 189
     if ( isset($arr["port"]) )
190
-      $host .= ":" . $arr["port"];
190
+        $host .= ":" . $arr["port"];
191 191
 
192 192
     if ( isset($arr["path"]) && $arr["path"] !== "" ) {
193
-      // Do we have a trailing slash?
194
-      if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) {
193
+        // Do we have a trailing slash?
194
+        if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) {
195 195
         $path = $arr["path"];
196 196
         $file = "";
197
-      } else {
197
+        } else {
198 198
         $path = dirname($arr["path"]) . "/";
199 199
         $file = basename($arr["path"]);
200
-      }
200
+        }
201 201
     }
202 202
 
203 203
     if ( isset($arr["query"]) )
204
-      $file .= "?" . $arr["query"];
204
+        $file .= "?" . $arr["query"];
205 205
 
206 206
     if ( isset($arr["fragment"]) )
207
-      $file .= "#" . $arr["fragment"];
207
+        $file .= "#" . $arr["fragment"];
208 208
 
209
-  } else {
209
+    } else {
210 210
 
211 211
     $i = mb_strpos($url, "file://");
212 212
     if ( $i !== false)
213
-      $url = mb_substr($url, $i + 7);
213
+        $url = mb_substr($url, $i + 7);
214 214
 
215 215
     $protocol = ""; // "file://"; ? why doesn't this work... It's because of
216 216
                     // network filenames like //COMPU/SHARENAME
@@ -222,28 +222,28 @@  discard block
 block discarded – undo
222 222
 
223 223
     // Check that the path exists
224 224
     if ( $path !== false ) {
225
-      $path .= '/';
225
+        $path .= '/';
226 226
 
227 227
     } else {
228
-      // generate a url to access the file if no real path found.
229
-      $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
228
+        // generate a url to access the file if no real path found.
229
+        $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https://' : 'http://';
230 230
 
231
-      $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
231
+        $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
232 232
 
233
-      if ( substr($arr["path"], 0, 1) === '/' ) {
233
+        if ( substr($arr["path"], 0, 1) === '/' ) {
234 234
         $path = dirname($arr["path"]);
235
-      } else {
235
+        } else {
236 236
         $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
237
-      }
237
+        }
238
+    }
238 239
     }
239
-  }
240
-
241
-  $ret = array($protocol, $host, $path, $file,
242
-               "protocol" => $protocol,
243
-               "host" => $host,
244
-               "path" => $path,
245
-               "file" => $file);
246
-  return $ret;
240
+
241
+    $ret = array($protocol, $host, $path, $file,
242
+                "protocol" => $protocol,
243
+                "host" => $host,
244
+                "path" => $path,
245
+                "file" => $file);
246
+    return $ret;
247 247
 }
248 248
 
249 249
 /**
@@ -254,41 +254,41 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function dec2roman($num) {
256 256
 
257
-  static $ones = array("", "i", "ii", "iii", "iv", "v",
258
-                       "vi", "vii", "viii", "ix");
259
-  static $tens = array("", "x", "xx", "xxx", "xl", "l",
260
-                       "lx", "lxx", "lxxx", "xc");
261
-  static $hund = array("", "c", "cc", "ccc", "cd", "d",
262
-                       "dc", "dcc", "dccc", "cm");
263
-  static $thou = array("", "m", "mm", "mmm");
257
+    static $ones = array("", "i", "ii", "iii", "iv", "v",
258
+                        "vi", "vii", "viii", "ix");
259
+    static $tens = array("", "x", "xx", "xxx", "xl", "l",
260
+                        "lx", "lxx", "lxxx", "xc");
261
+    static $hund = array("", "c", "cc", "ccc", "cd", "d",
262
+                        "dc", "dcc", "dccc", "cm");
263
+    static $thou = array("", "m", "mm", "mmm");
264 264
 
265
-  if ( !is_numeric($num) )
265
+    if ( !is_numeric($num) )
266 266
     throw new DOMPDF_Exception("dec2roman() requires a numeric argument.");
267 267
 
268
-  if ( $num > 4000 || $num < 0 )
268
+    if ( $num > 4000 || $num < 0 )
269 269
     return "(out of range)";
270 270
 
271
-  $num = strrev((string)$num);
271
+    $num = strrev((string)$num);
272 272
 
273
-  $ret = "";
274
-  switch (mb_strlen($num)) {
273
+    $ret = "";
274
+    switch (mb_strlen($num)) {
275 275
 
276
-  case 4:
276
+    case 4:
277 277
     $ret .= $thou[$num[3]];
278 278
 
279
-  case 3:
279
+    case 3:
280 280
     $ret .= $hund[$num[2]];
281 281
 
282
-  case 2:
282
+    case 2:
283 283
     $ret .= $tens[$num[1]];
284 284
 
285
-  case 1:
285
+    case 1:
286 286
     $ret .= $ones[$num[0]];
287 287
 
288
-  default:
288
+    default:
289 289
     break;
290
-  }
291
-  return $ret;
290
+    }
291
+    return $ret;
292 292
 
293 293
 }
294 294
 
@@ -305,84 +305,84 @@  discard block
 block discarded – undo
305 305
  */
306 306
 
307 307
 if ( !function_exists("mb_convert_encoding") ) {
308
-  function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') {
308
+    function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') {
309 309
     if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') {
310
-      return utf8_encode($data);
310
+        return utf8_encode($data);
311 311
     } else {
312
-      return utf8_decode($data);
312
+        return utf8_decode($data);
313
+    }
313 314
     }
314
-  }
315 315
 }
316 316
 
317 317
 if ( !function_exists("mb_detect_encoding") ) {
318
-  function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) {
318
+    function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) {
319 319
     return 'iso-8859-1';
320
-  }
320
+    }
321 321
 }
322 322
 
323 323
 if ( !function_exists("mb_detect_order") ) {
324
-  function mb_detect_order($encoding_list=array('iso-8859-1')) {
324
+    function mb_detect_order($encoding_list=array('iso-8859-1')) {
325 325
     return 'iso-8859-1';
326
-  }
326
+    }
327 327
 }
328 328
 
329 329
 if ( !function_exists("mb_internal_encoding") ) {
330
-  function mb_internal_encoding($encoding=NULL) {
330
+    function mb_internal_encoding($encoding=NULL) {
331 331
     if (isset($encoding)) {
332
-      return true;
332
+        return true;
333 333
     } else {
334
-      return 'iso-8859-1';
334
+        return 'iso-8859-1';
335
+    }
335 336
     }
336
-  }
337 337
 }
338 338
 
339 339
 if ( !function_exists("mb_strlen") ) {
340
-  function mb_strlen($str, $encoding='iso-8859-1') {
340
+    function mb_strlen($str, $encoding='iso-8859-1') {
341 341
     if (str_replace('-', '', strtolower($encoding)) == 'utf8') {
342
-      return strlen(utf8_encode($data));
342
+        return strlen(utf8_encode($data));
343 343
     } else {
344
-      return strlen(utf8_decode($data));
344
+        return strlen(utf8_decode($data));
345
+    }
345 346
     }
346
-  }
347 347
 }
348 348
 
349 349
 if ( !function_exists("mb_strpos") ) {
350
-  function mb_strpos($haystack, $needle, $offset = 0) {
350
+    function mb_strpos($haystack, $needle, $offset = 0) {
351 351
     return strpos($haystack, $needle, $offset);
352
-  }
352
+    }
353 353
 }
354 354
 
355 355
 if ( !function_exists("mb_strrpos") ) {
356
-  function mb_strrpos($haystack, $needle, $offset = 0) {
356
+    function mb_strrpos($haystack, $needle, $offset = 0) {
357 357
     return strrpos($haystack, $needle, $offset);
358
-  }
358
+    }
359 359
 }
360 360
 
361 361
 if ( !function_exists("mb_strtolower") ) {
362
-  function mb_strtolower($str) {
362
+    function mb_strtolower($str) {
363 363
     return strtolower($str);
364
-  }
364
+    }
365 365
 }
366 366
 
367 367
 if ( !function_exists("mb_strtoupper") ) {
368
-  function mb_strtoupper($str) {
368
+    function mb_strtoupper($str) {
369 369
     return strtoupper($str);
370
-  }
370
+    }
371 371
 }
372 372
 
373 373
 if ( !function_exists("mb_substr") ) {
374
-  function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') {
374
+    function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') {
375 375
     if ( is_null($length) )
376
-      return substr($str, $start);
376
+        return substr($str, $start);
377 377
     else
378
-      return substr($str, $start, $length);
379
-  }
378
+        return substr($str, $start, $length);
379
+    }
380 380
 }
381 381
 
382 382
 if ( !function_exists("mb_substr_count") ) {
383
-  function mb_substr_count($haystack, $needle) {
383
+    function mb_substr_count($haystack, $needle) {
384 384
     return substr_count($haystack, $needle);
385
-  }
385
+    }
386 386
 }
387 387
 
388 388
 /**
@@ -402,40 +402,40 @@  discard block
 block discarded – undo
402 402
  */
403 403
 function record_warnings($errno, $errstr, $errfile, $errline) {
404 404
 
405
-  if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice
405
+    if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice
406 406
     throw new DOMPDF_Exception($errstr . " $errno");
407 407
 
408
-  global $_dompdf_warnings;
409
-  global $_dompdf_show_warnings;
408
+    global $_dompdf_warnings;
409
+    global $_dompdf_show_warnings;
410 410
 
411
-  if ( $_dompdf_show_warnings )
411
+    if ( $_dompdf_show_warnings )
412 412
     echo $errstr . "\n";
413 413
 
414
-  $_dompdf_warnings[] = $errstr;
414
+    $_dompdf_warnings[] = $errstr;
415 415
 }
416 416
 
417 417
 /**
418 418
  * Print a useful backtrace
419 419
  */
420 420
 function bt() {
421
-  $bt = debug_backtrace();
421
+    $bt = debug_backtrace();
422 422
 
423
-  array_shift($bt); // remove actual bt() call
424
-  echo "\n";
423
+    array_shift($bt); // remove actual bt() call
424
+    echo "\n";
425 425
 
426
-  $i = 0;
427
-  foreach ($bt as $call) {
426
+    $i = 0;
427
+    foreach ($bt as $call) {
428 428
     $file = basename($call["file"]) . " (" . $call["line"] . ")";
429 429
     if ( isset($call["class"]) ) {
430
-      $func = $call["class"] . "->" . $call["function"] . "()";
430
+        $func = $call["class"] . "->" . $call["function"] . "()";
431 431
     } else {
432
-      $func = $call["function"] . "()";
432
+        $func = $call["function"] . "()";
433 433
     }
434 434
 
435 435
     echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n";
436 436
     $i++;
437
-  }
438
-  echo "\n";
437
+    }
438
+    echo "\n";
439 439
 }
440 440
 
441 441
 /**
@@ -444,15 +444,15 @@  discard block
 block discarded – undo
444 444
  * @param string $type  The type of debug messages to print
445 445
  */
446 446
 function dompdf_debug($type, $msg) {
447
-  global $_DOMPDF_DEBUG_TYPES;
448
-  global $_dompdf_show_warnings;
449
-  global $_dompdf_debug;
450
-  if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) {
447
+    global $_DOMPDF_DEBUG_TYPES;
448
+    global $_dompdf_show_warnings;
449
+    global $_dompdf_debug;
450
+    if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) {
451 451
     $arr = debug_backtrace();
452 452
 
453 453
     echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": ";
454 454
     pre_r($msg);
455
-  }
455
+    }
456 456
 }
457 457
 
458 458
 /**
@@ -460,20 +460,20 @@  discard block
 block discarded – undo
460 460
  */
461 461
 if ( !function_exists("print_memusage") ) {
462 462
 function print_memusage() {
463
-  global $memusage;
464
-  echo ("Memory Usage\n");
465
-  $prev = 0;
466
-  $initial = reset($memusage);
467
-  echo (str_pad("Initial:", 40) . $initial . "\n\n");
463
+    global $memusage;
464
+    echo ("Memory Usage\n");
465
+    $prev = 0;
466
+    $initial = reset($memusage);
467
+    echo (str_pad("Initial:", 40) . $initial . "\n\n");
468 468
 
469
-  foreach ($memusage as $key=>$mem) {
469
+    foreach ($memusage as $key=>$mem) {
470 470
     $mem -= $initial;
471 471
     echo (str_pad("$key:" , 40));
472 472
     echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n");
473 473
     $prev = $mem;
474
-  }
474
+    }
475 475
 
476
-  echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n";
476
+    echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n";
477 477
 }
478 478
 }
479 479
 
@@ -495,8 +495,8 @@  discard block
 block discarded – undo
495 495
  */
496 496
 if ( !function_exists("mark_memusage") ) {
497 497
 function mark_memusage($location) {
498
-  global $memusage;
499
-  if ( isset($memusage) )
498
+    global $memusage;
499
+    if ( isset($memusage) )
500 500
     $memusage[$location] = memory_get_usage();
501 501
 }
502 502
 }
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
  * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261
508 508
  */
509 509
 if ( !function_exists('sys_get_temp_dir')) {
510
-  function sys_get_temp_dir() {
510
+    function sys_get_temp_dir() {
511 511
     if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
512 512
     if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
513 513
     if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
@@ -516,5 +516,5 @@  discard block
 block discarded – undo
516 516
     unlink($tempfile);
517 517
     return realpath(dirname($tempfile));
518 518
     }
519
-  }
519
+    }
520 520
 }
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -273,20 +273,20 @@
 block discarded – undo
273 273
   $ret = "";
274 274
   switch (mb_strlen($num)) {
275 275
 
276
-  case 4:
277
-    $ret .= $thou[$num[3]];
276
+      case 4:
277
+        $ret .= $thou[$num[3]];
278 278
 
279
-  case 3:
280
-    $ret .= $hund[$num[2]];
279
+      case 3:
280
+        $ret .= $hund[$num[2]];
281 281
 
282
-  case 2:
283
-    $ret .= $tens[$num[1]];
282
+      case 2:
283
+        $ret .= $tens[$num[1]];
284 284
 
285
-  case 1:
286
-    $ret .= $ones[$num[0]];
285
+      case 1:
286
+        $ret .= $ones[$num[0]];
287 287
 
288
-  default:
289
-    break;
288
+      default:
289
+        break;
290 290
   }
291 291
   return $ret;
292 292
 
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -61,16 +61,16 @@  discard block
 block discarded – undo
61 61
  * @param bool $return
62 62
  *
63 63
  */
64
-if ( !function_exists("pre_r") ) {
64
+if (!function_exists("pre_r")) {
65 65
 function pre_r($mixed, $return = false) {
66 66
   if ($return)
67
-    return "<pre>" . print_r($mixed, true) . "</pre>";
67
+    return "<pre>".print_r($mixed, true)."</pre>";
68 68
 
69
-  if ( php_sapi_name() !== "cli")
69
+  if (php_sapi_name() !== "cli")
70 70
     echo ("<pre>");
71 71
   print_r($mixed);
72 72
 
73
-  if ( php_sapi_name() !== "cli")
73
+  if (php_sapi_name() !== "cli")
74 74
     echo("</pre>");
75 75
   else
76 76
     echo ("\n");
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
  *
88 88
  * @param mixed $mixed variable or expression to display.
89 89
  */
90
-if ( !function_exists("pre_var_dump") ) {
90
+if (!function_exists("pre_var_dump")) {
91 91
 function pre_var_dump($mixed) {
92
-  if ( php_sapi_name() !== "cli")
92
+  if (php_sapi_name() !== "cli")
93 93
     echo("<pre>");
94 94
   var_dump($mixed);
95
-  if ( php_sapi_name() !== "cli")
95
+  if (php_sapi_name() !== "cli")
96 96
     echo("</pre>");
97 97
 }
98 98
 }
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
  * is appended (o.k. also for Windows)
116 116
  */
117 117
 function build_url($protocol, $host, $base_path, $url) {
118
-  if ( mb_strlen($url) == 0 ) {
118
+  if (mb_strlen($url) == 0) {
119 119
     //return $protocol . $host . rtrim($base_path, "/\\") . "/";
120
-    return $protocol . $host . $base_path;
120
+    return $protocol.$host.$base_path;
121 121
   }
122 122
 
123 123
   // Is the url already fully qualified?
124
-  if ( mb_strpos($url, "://") !== false )
124
+  if (mb_strpos($url, "://") !== false)
125 125
     return $url;
126 126
 
127 127
   $ret = $protocol;
@@ -140,13 +140,13 @@  discard block
 block discarded – undo
140 140
   }
141 141
 
142 142
   //remote urls with backslash in html/css are not really correct, but lets be genereous
143
-  if ( $url[0] === '/' || $url[0] === '\\' ) {
143
+  if ($url[0] === '/' || $url[0] === '\\') {
144 144
     // Absolute path
145
-    $ret .= $host . $url;
145
+    $ret .= $host.$url;
146 146
   } else {
147 147
     // Relative path
148 148
     //$base_path = $base_path !== "" ? rtrim($base_path, "/\\") . "/" : "";
149
-    $ret .= $host . $base_path . $url;
149
+    $ret .= $host.$base_path.$url;
150 150
   }
151 151
 
152 152
   return $ret;
@@ -168,48 +168,48 @@  discard block
 block discarded – undo
168 168
 
169 169
   $arr = parse_url($url);
170 170
 
171
-  if ( isset($arr["scheme"]) &&
171
+  if (isset($arr["scheme"]) &&
172 172
        $arr["scheme"] !== "file" &&
173
-       mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters...
173
+       mb_strlen($arr["scheme"]) > 1) // Exclude windows drive letters...
174 174
     {
175
-    $protocol = $arr["scheme"] . "://";
175
+    $protocol = $arr["scheme"]."://";
176 176
 
177
-    if ( isset($arr["user"]) ) {
177
+    if (isset($arr["user"])) {
178 178
       $host .= $arr["user"];
179 179
 
180
-      if ( isset($arr["pass"]) )
181
-        $host .= "@" . $arr["pass"];
180
+      if (isset($arr["pass"]))
181
+        $host .= "@".$arr["pass"];
182 182
 
183 183
       $host .= ":";
184 184
     }
185 185
 
186
-    if ( isset($arr["host"]) )
186
+    if (isset($arr["host"]))
187 187
       $host .= $arr["host"];
188 188
 
189
-    if ( isset($arr["port"]) )
190
-      $host .= ":" . $arr["port"];
189
+    if (isset($arr["port"]))
190
+      $host .= ":".$arr["port"];
191 191
 
192
-    if ( isset($arr["path"]) && $arr["path"] !== "" ) {
192
+    if (isset($arr["path"]) && $arr["path"] !== "") {
193 193
       // Do we have a trailing slash?
194
-      if ( $arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/" ) {
194
+      if ($arr["path"]{ mb_strlen($arr["path"]) - 1 } === "/") {
195 195
         $path = $arr["path"];
196 196
         $file = "";
197 197
       } else {
198
-        $path = dirname($arr["path"]) . "/";
198
+        $path = dirname($arr["path"])."/";
199 199
         $file = basename($arr["path"]);
200 200
       }
201 201
     }
202 202
 
203
-    if ( isset($arr["query"]) )
204
-      $file .= "?" . $arr["query"];
203
+    if (isset($arr["query"]))
204
+      $file .= "?".$arr["query"];
205 205
 
206
-    if ( isset($arr["fragment"]) )
207
-      $file .= "#" . $arr["fragment"];
206
+    if (isset($arr["fragment"]))
207
+      $file .= "#".$arr["fragment"];
208 208
 
209 209
   } else {
210 210
 
211 211
     $i = mb_strpos($url, "file://");
212
-    if ( $i !== false)
212
+    if ($i !== false)
213 213
       $url = mb_substr($url, $i + 7);
214 214
 
215 215
     $protocol = ""; // "file://"; ? why doesn't this work... It's because of
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
     $path = dirname($url);
222 222
 
223 223
     // Check that the path exists
224
-    if ( $path !== false ) {
224
+    if ($path !== false) {
225 225
       $path .= '/';
226 226
 
227 227
     } else {
@@ -230,10 +230,10 @@  discard block
 block discarded – undo
230 230
 
231 231
       $host = isset($_SERVER["HTTP_HOST"]) ? $_SERVER["HTTP_HOST"] : php_uname("n");
232 232
 
233
-      if ( substr($arr["path"], 0, 1) === '/' ) {
233
+      if (substr($arr["path"], 0, 1) === '/') {
234 234
         $path = dirname($arr["path"]);
235 235
       } else {
236
-        $path = '/' . rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/') . '/' . $arr["path"];
236
+        $path = '/'.rtrim(dirname($_SERVER["SCRIPT_NAME"]), '/').'/'.$arr["path"];
237 237
       }
238 238
     }
239 239
   }
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
                        "dc", "dcc", "dccc", "cm");
263 263
   static $thou = array("", "m", "mm", "mmm");
264 264
 
265
-  if ( !is_numeric($num) )
265
+  if (!is_numeric($num))
266 266
     throw new DOMPDF_Exception("dec2roman() requires a numeric argument.");
267 267
 
268
-  if ( $num > 4000 || $num < 0 )
268
+  if ($num > 4000 || $num < 0)
269 269
     return "(out of range)";
270 270
 
271
-  $num = strrev((string)$num);
271
+  $num = strrev((string) $num);
272 272
 
273 273
   $ret = "";
274 274
   switch (mb_strlen($num)) {
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
  * mb_string compatibility
305 305
  */
306 306
 
307
-if ( !function_exists("mb_convert_encoding") ) {
308
-  function mb_convert_encoding($data, $to_encoding, $from_encoding='UTF-8') {
307
+if (!function_exists("mb_convert_encoding")) {
308
+  function mb_convert_encoding($data, $to_encoding, $from_encoding = 'UTF-8') {
309 309
     if (str_replace('-', '', strtolower($to_encoding)) == 'utf8') {
310 310
       return utf8_encode($data);
311 311
     } else {
@@ -314,20 +314,20 @@  discard block
 block discarded – undo
314 314
   }
315 315
 }
316 316
 
317
-if ( !function_exists("mb_detect_encoding") ) {
318
-  function mb_detect_encoding($data, $encoding_list=array('iso-8859-1'), $strict=false) {
317
+if (!function_exists("mb_detect_encoding")) {
318
+  function mb_detect_encoding($data, $encoding_list = array('iso-8859-1'), $strict = false) {
319 319
     return 'iso-8859-1';
320 320
   }
321 321
 }
322 322
 
323
-if ( !function_exists("mb_detect_order") ) {
324
-  function mb_detect_order($encoding_list=array('iso-8859-1')) {
323
+if (!function_exists("mb_detect_order")) {
324
+  function mb_detect_order($encoding_list = array('iso-8859-1')) {
325 325
     return 'iso-8859-1';
326 326
   }
327 327
 }
328 328
 
329
-if ( !function_exists("mb_internal_encoding") ) {
330
-  function mb_internal_encoding($encoding=NULL) {
329
+if (!function_exists("mb_internal_encoding")) {
330
+  function mb_internal_encoding($encoding = NULL) {
331 331
     if (isset($encoding)) {
332 332
       return true;
333 333
     } else {
@@ -336,8 +336,8 @@  discard block
 block discarded – undo
336 336
   }
337 337
 }
338 338
 
339
-if ( !function_exists("mb_strlen") ) {
340
-  function mb_strlen($str, $encoding='iso-8859-1') {
339
+if (!function_exists("mb_strlen")) {
340
+  function mb_strlen($str, $encoding = 'iso-8859-1') {
341 341
     if (str_replace('-', '', strtolower($encoding)) == 'utf8') {
342 342
       return strlen(utf8_encode($data));
343 343
     } else {
@@ -346,40 +346,40 @@  discard block
 block discarded – undo
346 346
   }
347 347
 }
348 348
 
349
-if ( !function_exists("mb_strpos") ) {
349
+if (!function_exists("mb_strpos")) {
350 350
   function mb_strpos($haystack, $needle, $offset = 0) {
351 351
     return strpos($haystack, $needle, $offset);
352 352
   }
353 353
 }
354 354
 
355
-if ( !function_exists("mb_strrpos") ) {
355
+if (!function_exists("mb_strrpos")) {
356 356
   function mb_strrpos($haystack, $needle, $offset = 0) {
357 357
     return strrpos($haystack, $needle, $offset);
358 358
   }
359 359
 }
360 360
 
361
-if ( !function_exists("mb_strtolower") ) {
361
+if (!function_exists("mb_strtolower")) {
362 362
   function mb_strtolower($str) {
363 363
     return strtolower($str);
364 364
   }
365 365
 }
366 366
 
367
-if ( !function_exists("mb_strtoupper") ) {
367
+if (!function_exists("mb_strtoupper")) {
368 368
   function mb_strtoupper($str) {
369 369
     return strtoupper($str);
370 370
   }
371 371
 }
372 372
 
373
-if ( !function_exists("mb_substr") ) {
374
-  function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') {
375
-    if ( is_null($length) )
373
+if (!function_exists("mb_substr")) {
374
+  function mb_substr($str, $start, $length = null, $encoding = 'iso-8859-1') {
375
+    if (is_null($length))
376 376
       return substr($str, $start);
377 377
     else
378 378
       return substr($str, $start, $length);
379 379
   }
380 380
 }
381 381
 
382
-if ( !function_exists("mb_substr_count") ) {
382
+if (!function_exists("mb_substr_count")) {
383 383
   function mb_substr_count($haystack, $needle) {
384 384
     return substr_count($haystack, $needle);
385 385
   }
@@ -402,14 +402,14 @@  discard block
 block discarded – undo
402 402
  */
403 403
 function record_warnings($errno, $errstr, $errfile, $errline) {
404 404
 
405
-  if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice
406
-    throw new DOMPDF_Exception($errstr . " $errno");
405
+  if (!($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING))) // Not a warning or notice
406
+    throw new DOMPDF_Exception($errstr." $errno");
407 407
 
408 408
   global $_dompdf_warnings;
409 409
   global $_dompdf_show_warnings;
410 410
 
411
-  if ( $_dompdf_show_warnings )
412
-    echo $errstr . "\n";
411
+  if ($_dompdf_show_warnings)
412
+    echo $errstr."\n";
413 413
 
414 414
   $_dompdf_warnings[] = $errstr;
415 415
 }
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
 
426 426
   $i = 0;
427 427
   foreach ($bt as $call) {
428
-    $file = basename($call["file"]) . " (" . $call["line"] . ")";
429
-    if ( isset($call["class"]) ) {
430
-      $func = $call["class"] . "->" . $call["function"] . "()";
428
+    $file = basename($call["file"])." (".$call["line"].")";
429
+    if (isset($call["class"])) {
430
+      $func = $call["class"]."->".$call["function"]."()";
431 431
     } else {
432
-      $func = $call["function"] . "()";
432
+      $func = $call["function"]."()";
433 433
     }
434 434
 
435
-    echo "#" . str_pad($i, 2, " ", STR_PAD_RIGHT) . ": " . str_pad($file.":", 42) . " $func\n";
435
+    echo "#".str_pad($i, 2, " ", STR_PAD_RIGHT).": ".str_pad($file.":", 42)." $func\n";
436 436
     $i++;
437 437
   }
438 438
   echo "\n";
@@ -447,10 +447,10 @@  discard block
 block discarded – undo
447 447
   global $_DOMPDF_DEBUG_TYPES;
448 448
   global $_dompdf_show_warnings;
449 449
   global $_dompdf_debug;
450
-  if ( isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug) ) {
450
+  if (isset($_DOMPDF_DEBUG_TYPES[$type]) && ($_dompdf_show_warnings || $_dompdf_debug)) {
451 451
     $arr = debug_backtrace();
452 452
 
453
-    echo basename($arr[0]["file"]) . " (" . $arr[0]["line"] ."): " . $arr[1]["function"] . ": ";
453
+    echo basename($arr[0]["file"])." (".$arr[0]["line"]."): ".$arr[1]["function"].": ";
454 454
     pre_r($msg);
455 455
   }
456 456
 }
@@ -458,29 +458,29 @@  discard block
 block discarded – undo
458 458
 /**
459 459
  * Dump memory usage
460 460
  */
461
-if ( !function_exists("print_memusage") ) {
461
+if (!function_exists("print_memusage")) {
462 462
 function print_memusage() {
463 463
   global $memusage;
464 464
   echo ("Memory Usage\n");
465 465
   $prev = 0;
466 466
   $initial = reset($memusage);
467
-  echo (str_pad("Initial:", 40) . $initial . "\n\n");
467
+  echo (str_pad("Initial:", 40).$initial."\n\n");
468 468
 
469 469
   foreach ($memusage as $key=>$mem) {
470 470
     $mem -= $initial;
471
-    echo (str_pad("$key:" , 40));
472
-    echo (str_pad("$mem", 12) . "(diff: " . ($mem - $prev) . ")\n");
471
+    echo (str_pad("$key:", 40));
472
+    echo (str_pad("$mem", 12)."(diff: ".($mem - $prev).")\n");
473 473
     $prev = $mem;
474 474
   }
475 475
 
476
-  echo ("\n" . str_pad("Total:", 40) . memory_get_usage()) . "\n";
476
+  echo ("\n".str_pad("Total:", 40).memory_get_usage())."\n";
477 477
 }
478 478
 }
479 479
 
480 480
 /**
481 481
  * Initialize memory profiling code
482 482
  */
483
-if ( !function_exists("enable_mem_profile") ) {
483
+if (!function_exists("enable_mem_profile")) {
484 484
 function enable_mem_profile() {
485 485
     global $memusage;
486 486
     $memusage = array("Startup" => memory_get_usage());
@@ -493,10 +493,10 @@  discard block
 block discarded – undo
493 493
  *
494 494
  * @param string $location a meaningful location
495 495
  */
496
-if ( !function_exists("mark_memusage") ) {
496
+if (!function_exists("mark_memusage")) {
497 497
 function mark_memusage($location) {
498 498
   global $memusage;
499
-  if ( isset($memusage) )
499
+  if (isset($memusage))
500 500
     $memusage[$location] = memory_get_usage();
501 501
 }
502 502
 }
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
  *
507 507
  * @link http://us.php.net/manual/en/function.sys-get-temp-dir.php#85261
508 508
  */
509
-if ( !function_exists('sys_get_temp_dir')) {
509
+if (!function_exists('sys_get_temp_dir')) {
510 510
   function sys_get_temp_dir() {
511 511
     if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
512
-    if (!empty($_ENV['TMPDIR'])) { return realpath( $_ENV['TMPDIR']); }
513
-    if (!empty($_ENV['TEMP'])) { return realpath( $_ENV['TEMP']); }
514
-    $tempfile=tempnam(uniqid(rand(),TRUE),'');
512
+    if (!empty($_ENV['TMPDIR'])) { return realpath($_ENV['TMPDIR']); }
513
+    if (!empty($_ENV['TEMP'])) { return realpath($_ENV['TEMP']); }
514
+    $tempfile = tempnam(uniqid(rand(), TRUE), '');
515 515
     if (file_exists($tempfile)) {
516 516
     unlink($tempfile);
517 517
     return realpath(dirname($tempfile));
Please login to merge, or discard this patch.
Braces   +63 added lines, -42 removed lines patch added patch discarded remove patch
@@ -63,17 +63,20 @@  discard block
 block discarded – undo
63 63
  */
64 64
 if ( !function_exists("pre_r") ) {
65 65
 function pre_r($mixed, $return = false) {
66
-  if ($return)
67
-    return "<pre>" . print_r($mixed, true) . "</pre>";
66
+  if ($return) {
67
+      return "<pre>" . print_r($mixed, true) . "</pre>";
68
+  }
68 69
 
69
-  if ( php_sapi_name() !== "cli")
70
-    echo ("<pre>");
70
+  if ( php_sapi_name() !== "cli") {
71
+      echo ("<pre>");
72
+  }
71 73
   print_r($mixed);
72 74
 
73
-  if ( php_sapi_name() !== "cli")
74
-    echo("</pre>");
75
-  else
76
-    echo ("\n");
75
+  if ( php_sapi_name() !== "cli") {
76
+      echo("</pre>");
77
+  } else {
78
+      echo ("\n");
79
+  }
77 80
   flush();
78 81
 
79 82
 }
@@ -89,12 +92,14 @@  discard block
 block discarded – undo
89 92
  */
90 93
 if ( !function_exists("pre_var_dump") ) {
91 94
 function pre_var_dump($mixed) {
92
-  if ( php_sapi_name() !== "cli")
93
-    echo("<pre>");
95
+  if ( php_sapi_name() !== "cli") {
96
+      echo("<pre>");
97
+  }
94 98
   var_dump($mixed);
95
-  if ( php_sapi_name() !== "cli")
96
-    echo("</pre>");
97
-}
99
+  if ( php_sapi_name() !== "cli") {
100
+      echo("</pre>");
101
+  }
102
+  }
98 103
 }
99 104
 
100 105
 /**
@@ -121,8 +126,9 @@  discard block
 block discarded – undo
121 126
   }
122 127
 
123 128
   // Is the url already fully qualified?
124
-  if ( mb_strpos($url, "://") !== false )
125
-    return $url;
129
+  if ( mb_strpos($url, "://") !== false ) {
130
+      return $url;
131
+  }
126 132
 
127 133
   $ret = $protocol;
128 134
 
@@ -170,24 +176,29 @@  discard block
 block discarded – undo
170 176
 
171 177
   if ( isset($arr["scheme"]) &&
172 178
        $arr["scheme"] !== "file" &&
173
-       mb_strlen($arr["scheme"]) > 1 ) // Exclude windows drive letters...
179
+       mb_strlen($arr["scheme"]) > 1 ) {
180
+      // Exclude windows drive letters...
174 181
     {
175 182
     $protocol = $arr["scheme"] . "://";
183
+  }
176 184
 
177 185
     if ( isset($arr["user"]) ) {
178 186
       $host .= $arr["user"];
179 187
 
180
-      if ( isset($arr["pass"]) )
181
-        $host .= "@" . $arr["pass"];
188
+      if ( isset($arr["pass"]) ) {
189
+              $host .= "@" . $arr["pass"];
190
+      }
182 191
 
183 192
       $host .= ":";
184 193
     }
185 194
 
186
-    if ( isset($arr["host"]) )
187
-      $host .= $arr["host"];
195
+    if ( isset($arr["host"]) ) {
196
+          $host .= $arr["host"];
197
+    }
188 198
 
189
-    if ( isset($arr["port"]) )
190
-      $host .= ":" . $arr["port"];
199
+    if ( isset($arr["port"]) ) {
200
+          $host .= ":" . $arr["port"];
201
+    }
191 202
 
192 203
     if ( isset($arr["path"]) && $arr["path"] !== "" ) {
193 204
       // Do we have a trailing slash?
@@ -200,17 +211,20 @@  discard block
 block discarded – undo
200 211
       }
201 212
     }
202 213
 
203
-    if ( isset($arr["query"]) )
204
-      $file .= "?" . $arr["query"];
214
+    if ( isset($arr["query"]) ) {
215
+          $file .= "?" . $arr["query"];
216
+    }
205 217
 
206
-    if ( isset($arr["fragment"]) )
207
-      $file .= "#" . $arr["fragment"];
218
+    if ( isset($arr["fragment"]) ) {
219
+          $file .= "#" . $arr["fragment"];
220
+    }
208 221
 
209 222
   } else {
210 223
 
211 224
     $i = mb_strpos($url, "file://");
212
-    if ( $i !== false)
213
-      $url = mb_substr($url, $i + 7);
225
+    if ( $i !== false) {
226
+          $url = mb_substr($url, $i + 7);
227
+    }
214 228
 
215 229
     $protocol = ""; // "file://"; ? why doesn't this work... It's because of
216 230
                     // network filenames like //COMPU/SHARENAME
@@ -262,11 +276,13 @@  discard block
 block discarded – undo
262 276
                        "dc", "dcc", "dccc", "cm");
263 277
   static $thou = array("", "m", "mm", "mmm");
264 278
 
265
-  if ( !is_numeric($num) )
266
-    throw new DOMPDF_Exception("dec2roman() requires a numeric argument.");
279
+  if ( !is_numeric($num) ) {
280
+      throw new DOMPDF_Exception("dec2roman() requires a numeric argument.");
281
+  }
267 282
 
268
-  if ( $num > 4000 || $num < 0 )
269
-    return "(out of range)";
283
+  if ( $num > 4000 || $num < 0 ) {
284
+      return "(out of range)";
285
+  }
270 286
 
271 287
   $num = strrev((string)$num);
272 288
 
@@ -372,10 +388,11 @@  discard block
 block discarded – undo
372 388
 
373 389
 if ( !function_exists("mb_substr") ) {
374 390
   function mb_substr($str, $start, $length=null, $encoding='iso-8859-1') {
375
-    if ( is_null($length) )
376
-      return substr($str, $start);
377
-    else
378
-      return substr($str, $start, $length);
391
+    if ( is_null($length) ) {
392
+          return substr($str, $start);
393
+    } else {
394
+          return substr($str, $start, $length);
395
+    }
379 396
   }
380 397
 }
381 398
 
@@ -402,14 +419,17 @@  discard block
 block discarded – undo
402 419
  */
403 420
 function record_warnings($errno, $errstr, $errfile, $errline) {
404 421
 
405
-  if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) // Not a warning or notice
422
+  if ( !($errno & (E_WARNING | E_NOTICE | E_USER_NOTICE | E_USER_WARNING )) ) {
423
+      // Not a warning or notice
406 424
     throw new DOMPDF_Exception($errstr . " $errno");
425
+  }
407 426
 
408 427
   global $_dompdf_warnings;
409 428
   global $_dompdf_show_warnings;
410 429
 
411
-  if ( $_dompdf_show_warnings )
412
-    echo $errstr . "\n";
430
+  if ( $_dompdf_show_warnings ) {
431
+      echo $errstr . "\n";
432
+  }
413 433
 
414 434
   $_dompdf_warnings[] = $errstr;
415 435
 }
@@ -496,9 +516,10 @@  discard block
 block discarded – undo
496 516
 if ( !function_exists("mark_memusage") ) {
497 517
 function mark_memusage($location) {
498 518
   global $memusage;
499
-  if ( isset($memusage) )
500
-    $memusage[$location] = memory_get_usage();
501
-}
519
+  if ( isset($memusage) ) {
520
+      $memusage[$location] = memory_get_usage();
521
+  }
522
+  }
502 523
 }
503 524
 
504 525
 /**
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/gd_adapter.cls.php 5 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    *
97 97
    * @param mixed  $size         The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc.
98 98
    * @param string $orientation  The orientation of the document (either 'landscape' or 'portrait')
99
-   * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
99
+   * @param integer  $aa_factor    Anti-aliasing factor, 1 for no AA
100 100
    * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
101 101
    */
102 102
   function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
@@ -536,8 +536,8 @@  discard block
 block discarded – undo
536 536
    * @param string $font the font file to use
537 537
    * @param float $size the font size, in points
538 538
    * @param array $color
539
-   * @param float $adjust word spacing adjustment
540
-   * @param float $angle Text angle
539
+   * @param integer $adjust word spacing adjustment
540
+   * @param integer $angle Text angle
541 541
    */
542 542
   function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
543 543
 
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
    * @param string $text the text to be sized
591 591
    * @param string $font the desired font
592 592
    * @param float  $size the desired font size
593
-   * @param float  $spacing word spacing, if any
593
+   * @param integer  $spacing word spacing, if any
594 594
    * @return float
595 595
    */
596 596
   function get_text_width($text, $font, $size, $spacing = 0) {    
Please login to merge, or discard this patch.
Switch Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -489,21 +489,21 @@  discard block
 block discarded – undo
489 489
   function image($img_url, $img_type, $x, $y, $w, $h) {
490 490
 
491 491
     switch ($img_type) {
492
-    case "png":
493
-      $src = @imagecreatefrompng($img_url);
494
-      break;
492
+        case "png":
493
+          $src = @imagecreatefrompng($img_url);
494
+          break;
495 495
       
496
-    case "gif":
497
-      $src = @imagecreatefromgif($img_url);
498
-      break;
496
+        case "gif":
497
+          $src = @imagecreatefromgif($img_url);
498
+          break;
499 499
       
500
-    case "jpg":
501
-    case "jpeg":
502
-      $src = @imagecreatefromjpeg($img_url);
503
-      break;
500
+        case "jpg":
501
+        case "jpeg":
502
+          $src = @imagecreatefromjpeg($img_url);
503
+          break;
504 504
 
505
-    default:
506
-      break;
505
+        default:
506
+          break;
507 507
       
508 508
     }
509 509
 
@@ -658,20 +658,20 @@  discard block
 block discarded – undo
658 658
     
659 659
     switch ($type) {
660 660
 
661
-    case "jpg":
662
-    case "jpeg":
663
-      if ( !isset($options["quality"]) )
664
-        $options["quality"] = 75;
661
+        case "jpg":
662
+        case "jpeg":
663
+          if ( !isset($options["quality"]) )
664
+            $options["quality"] = 75;
665 665
       
666
-      header("Content-type: image/jpeg");
667
-      imagejpeg($dst, '', $options["quality"]);
668
-      break;
669
-
670
-    case "png":
671
-    default:
672
-      header("Content-type: image/png");
673
-      imagepng($dst);
674
-      break;
666
+          header("Content-type: image/jpeg");
667
+          imagejpeg($dst, '', $options["quality"]);
668
+          break;
669
+
670
+        case "png":
671
+        default:
672
+          header("Content-type: image/png");
673
+          imagepng($dst);
674
+          break;
675 675
     }
676 676
 
677 677
     if ( $this->_aa_factor != 1 ) 
@@ -706,18 +706,18 @@  discard block
 block discarded – undo
706 706
 
707 707
     switch ($type) {
708 708
 
709
-    case "jpg":
710
-    case "jpeg":
711
-      if ( !isset($options["quality"]) )
712
-        $options["quality"] = 75;
709
+        case "jpg":
710
+        case "jpeg":
711
+          if ( !isset($options["quality"]) )
712
+            $options["quality"] = 75;
713 713
       
714
-      imagejpeg($dst, '', $options["quality"]);
715
-      break;
714
+          imagejpeg($dst, '', $options["quality"]);
715
+          break;
716 716
 
717
-    case "png":
718
-    default:
719
-      imagepng($dst);
720
-      break;
717
+        case "png":
718
+        default:
719
+          imagepng($dst);
720
+          break;
721 721
     }
722 722
 
723 723
     $image = ob_get_contents();
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -99,22 +99,22 @@  discard block
 block discarded – undo
99 99
    * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
100 100
    * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
101 101
    */
102
-  function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
102
+  function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1, 1, 1, 0)) {
103 103
 
104
-    if ( !is_array($size) ) {
104
+    if (!is_array($size)) {
105 105
 
106
-      if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
106
+      if (isset(CPDF_Adapter::$PAPER_SIZES[strtolower($size)])) 
107 107
         $size = CPDF_Adapter::$PAPER_SIZES[$size];
108 108
       else
109 109
         $size = CPDF_Adapter::$PAPER_SIZES["letter"];
110 110
     
111 111
     }
112 112
 
113
-    if ( strtolower($orientation) === "landscape" ) {
114
-      list($size[2],$size[3]) = array($size[3],$size[2]);
113
+    if (strtolower($orientation) === "landscape") {
114
+      list($size[2], $size[3]) = array($size[3], $size[2]);
115 115
     }
116 116
 
117
-    if ( $aa_factor < 1 )
117
+    if ($aa_factor < 1)
118 118
       $aa_factor = 1;
119 119
 
120 120
     $this->_aa_factor = $aa_factor;
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
 
128 128
     $this->_img = imagecreatetruecolor($this->_width, $this->_height);
129 129
 
130
-    if ( is_null($bg_color) || !is_array($bg_color) ) {
130
+    if (is_null($bg_color) || !is_array($bg_color)) {
131 131
       // Pure white bg
132
-      $bg_color = array(1,1,1,0);
132
+      $bg_color = array(1, 1, 1, 0);
133 133
     }
134 134
 
135 135
     $this->_bg_color = $this->_allocate_color($bg_color);
@@ -197,10 +197,10 @@  discard block
 block discarded – undo
197 197
   private function _allocate_color($color) {
198 198
     
199 199
     // Full opacity if no alpha set
200
-    if ( !isset($color[3]) ) 
200
+    if (!isset($color[3])) 
201 201
       $color[3] = 0;
202 202
     
203
-    list($r,$g,$b,$a) = $color;
203
+    list($r, $g, $b, $a) = $color;
204 204
     
205 205
     $r *= 255;
206 206
     $g *= 255;
@@ -220,10 +220,10 @@  discard block
 block discarded – undo
220 220
       
221 221
     $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
222 222
       
223
-    if ( isset($this->_colors[$key]) )
223
+    if (isset($this->_colors[$key]))
224 224
       return $this->_colors[$key];
225 225
 
226
-    if ( $a != 0 ) 
226
+    if ($a != 0) 
227 227
       $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
228 228
     else
229 229
       $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
@@ -259,10 +259,10 @@  discard block
 block discarded – undo
259 259
     $c = $this->_allocate_color($color);
260 260
 
261 261
     // Convert the style array if required
262
-    if ( !is_null($style) ) {
262
+    if (!is_null($style)) {
263 263
       $gd_style = array();
264 264
 
265
-      if ( count($style) == 1 ) {
265
+      if (count($style) == 1) {
266 266
         for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
267 267
           $gd_style[] = $c;
268 268
         }
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         $i = 0;
277 277
         foreach ($style as $length) {
278 278
 
279
-          if ( $i % 2 == 0 ) {
279
+          if ($i % 2 == 0) {
280 280
             // 'On' pattern
281 281
             for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
282 282
               $gd_style[] = $c;
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     $c = $this->_allocate_color($color);
328 328
 
329 329
     // Convert the style array if required
330
-    if ( !is_null($style) ) {
330
+    if (!is_null($style)) {
331 331
       $gd_style = array();
332 332
 
333 333
       foreach ($style as $length) {
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     $c = $this->_allocate_color($color);
405 405
 
406 406
     // Convert the style array if required
407
-    if ( !is_null($style) && !$fill ) {
407
+    if (!is_null($style) && !$fill) {
408 408
       $gd_style = array();
409 409
 
410 410
       foreach ($style as $length) {
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
 
420 420
     imagesetthickness($this->_img, $width);
421 421
 
422
-    if ( $fill ) 
422
+    if ($fill) 
423 423
       imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
424 424
     else
425 425
       imagepolygon($this->_img, $points, count($points) / 2, $c);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
     $c = $this->_allocate_color($color);
452 452
 
453 453
     // Convert the style array if required
454
-    if ( !is_null($style) && !$fill ) {
454
+    if (!is_null($style) && !$fill) {
455 455
       $gd_style = array();
456 456
 
457 457
       foreach ($style as $length) {
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 
467 467
     imagesetthickness($this->_img, $width);
468 468
 
469
-    if ( $fill )
469
+    if ($fill)
470 470
       imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
471 471
     else
472 472
       imageellipse($this->_img, $x, $y, $r, $r, $c);
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
       
508 508
     }
509 509
 
510
-    if ( !$src )
510
+    if (!$src)
511 511
       return; // Probably should add to $_dompdf_errors or whatever here
512 512
     
513 513
     // Scale by the AA factor
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
    * @param float $adjust word spacing adjustment
540 540
    * @param float $angle Text angle
541 541
    */
542
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
542
+  function text($x, $y, $text, $font, $size, $color = array(0, 0, 0), $adjust = 0, $angle = 0) {
543 543
 
544 544
     // Scale by the AA factor
545 545
     $x *= $this->_aa_factor;
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
     
551 551
     $c = $this->_allocate_color($color);
552 552
 
553
-    if ( strpos($font, '.ttf') === false )
553
+    if (strpos($font, '.ttf') === false)
554 554
       $font .= ".ttf";
555 555
 
556 556
     // FIXME: word spacing
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
    */
596 596
   function get_text_width($text, $font, $size, $spacing = 0) {    
597 597
 
598
-    if ( strpos($font, '.ttf') === false )
598
+    if (strpos($font, '.ttf') === false)
599 599
       $font .= ".ttf";
600 600
 
601 601
     // FIXME: word spacing
@@ -611,11 +611,11 @@  discard block
 block discarded – undo
611 611
    * @return float
612 612
    */
613 613
   function get_font_height($font, $size) {
614
-    if ( strpos($font, '.ttf') === false )
614
+    if (strpos($font, '.ttf') === false)
615 615
       $font .= ".ttf";
616 616
 
617 617
     // FIXME: word spacing
618
-    list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl");  // Test string with ascenders, descenders and caps
618
+    list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl"); // Test string with ascenders, descenders and caps
619 619
     return $y2 - $y1;
620 620
   }
621 621
 
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
   function stream($filename, $options = null) {
639 639
 
640 640
     // Perform any antialiasing
641
-    if ( $this->_aa_factor != 1 ) {
641
+    if ($this->_aa_factor != 1) {
642 642
       $dst_w = $this->_width / $this->_aa_factor;
643 643
       $dst_h = $this->_height / $this->_aa_factor;
644 644
       $dst = imagecreatetruecolor($dst_w, $dst_h);
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
       $dst = $this->_img;
650 650
     }
651 651
 
652
-    if ( !isset($options["type"]) )
652
+    if (!isset($options["type"]))
653 653
       $options["type"] = "png";
654 654
 
655 655
     $type = strtolower($options["type"]);
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
 
661 661
     case "jpg":
662 662
     case "jpeg":
663
-      if ( !isset($options["quality"]) )
663
+      if (!isset($options["quality"]))
664 664
         $options["quality"] = 75;
665 665
       
666 666
       header("Content-type: image/jpeg");
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
       break;
675 675
     }
676 676
 
677
-    if ( $this->_aa_factor != 1 ) 
677
+    if ($this->_aa_factor != 1) 
678 678
       imagedestroy($dst);
679 679
   }
680 680
 
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
    */
687 687
   function output($options = null) {
688 688
 
689
-    if ( $this->_aa_factor != 1 ) {
689
+    if ($this->_aa_factor != 1) {
690 690
       $dst_w = $this->_width / $this->_aa_factor;
691 691
       $dst_h = $this->_height / $this->_aa_factor;
692 692
       $dst = imagecreatetruecolor($dst_w, $dst_h);
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
       $dst = $this->_img;
698 698
     }
699 699
     
700
-    if ( !isset($options["type"]) )
700
+    if (!isset($options["type"]))
701 701
       $options["type"] = "png";
702 702
 
703 703
     $type = $options["type"];
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 
709 709
     case "jpg":
710 710
     case "jpeg":
711
-      if ( !isset($options["quality"]) )
711
+      if (!isset($options["quality"]))
712 712
         $options["quality"] = 75;
713 713
       
714 714
       imagejpeg($dst, '', $options["quality"]);
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     $image = ob_get_contents();
724 724
     ob_end_clean();
725 725
 
726
-    if ( $this->_aa_factor != 1 )
726
+    if ($this->_aa_factor != 1)
727 727
       imagedestroy($dst);
728 728
     
729 729
     return $image;
Please login to merge, or discard this patch.
Braces   +69 added lines, -48 removed lines patch added patch discarded remove patch
@@ -103,10 +103,11 @@  discard block
 block discarded – undo
103 103
 
104 104
     if ( !is_array($size) ) {
105 105
 
106
-      if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
107
-        $size = CPDF_Adapter::$PAPER_SIZES[$size];
108
-      else
109
-        $size = CPDF_Adapter::$PAPER_SIZES["letter"];
106
+      if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) {
107
+              $size = CPDF_Adapter::$PAPER_SIZES[$size];
108
+      } else {
109
+              $size = CPDF_Adapter::$PAPER_SIZES["letter"];
110
+      }
110 111
     
111 112
     }
112 113
 
@@ -114,8 +115,9 @@  discard block
 block discarded – undo
114 115
       list($size[2],$size[3]) = array($size[3],$size[2]);
115 116
     }
116 117
 
117
-    if ( $aa_factor < 1 )
118
-      $aa_factor = 1;
118
+    if ( $aa_factor < 1 ) {
119
+          $aa_factor = 1;
120
+    }
119 121
 
120 122
     $this->_aa_factor = $aa_factor;
121 123
     
@@ -197,8 +199,9 @@  discard block
 block discarded – undo
197 199
   private function _allocate_color($color) {
198 200
     
199 201
     // Full opacity if no alpha set
200
-    if ( !isset($color[3]) ) 
201
-      $color[3] = 0;
202
+    if ( !isset($color[3]) ) {
203
+          $color[3] = 0;
204
+    }
202 205
     
203 206
     list($r,$g,$b,$a) = $color;
204 207
     
@@ -220,13 +223,15 @@  discard block
 block discarded – undo
220 223
       
221 224
     $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
222 225
       
223
-    if ( isset($this->_colors[$key]) )
224
-      return $this->_colors[$key];
226
+    if ( isset($this->_colors[$key]) ) {
227
+          return $this->_colors[$key];
228
+    }
225 229
 
226
-    if ( $a != 0 ) 
227
-      $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
228
-    else
229
-      $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
230
+    if ( $a != 0 ) {
231
+          $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
232
+    } else {
233
+          $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
234
+    }
230 235
       
231 236
     return $this->_colors[$key];
232 237
     
@@ -278,13 +283,15 @@  discard block
 block discarded – undo
278 283
 
279 284
           if ( $i % 2 == 0 ) {
280 285
             // 'On' pattern
281
-            for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
282
-              $gd_style[] = $c;
286
+            for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
287
+                          $gd_style[] = $c;
288
+            }
283 289
             
284 290
           } else {
285 291
             // Off pattern
286
-            for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
287
-              $gd_style[] = $this->_bg_color;
292
+            for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
293
+                          $gd_style[] = $this->_bg_color;
294
+            }
288 295
             
289 296
           }
290 297
           $i++;
@@ -398,8 +405,9 @@  discard block
 block discarded – undo
398 405
   function polygon($points, $color, $width = null, $style = null, $fill = false) {
399 406
 
400 407
     // Scale each point by the AA factor
401
-    foreach (array_keys($points) as $i)
402
-      $points[$i] *= $this->_aa_factor;
408
+    foreach (array_keys($points) as $i) {
409
+          $points[$i] *= $this->_aa_factor;
410
+    }
403 411
 
404 412
     $c = $this->_allocate_color($color);
405 413
 
@@ -419,10 +427,11 @@  discard block
 block discarded – undo
419 427
 
420 428
     imagesetthickness($this->_img, $width);
421 429
 
422
-    if ( $fill ) 
423
-      imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
424
-    else
425
-      imagepolygon($this->_img, $points, count($points) / 2, $c);
430
+    if ( $fill ) {
431
+          imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
432
+    } else {
433
+          imagepolygon($this->_img, $points, count($points) / 2, $c);
434
+    }
426 435
         
427 436
   }
428 437
 
@@ -466,10 +475,11 @@  discard block
 block discarded – undo
466 475
 
467 476
     imagesetthickness($this->_img, $width);
468 477
 
469
-    if ( $fill )
470
-      imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
471
-    else
472
-      imageellipse($this->_img, $x, $y, $r, $r, $c);
478
+    if ( $fill ) {
479
+          imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
480
+    } else {
481
+          imageellipse($this->_img, $x, $y, $r, $r, $c);
482
+    }
473 483
         
474 484
   }
475 485
 
@@ -507,8 +517,10 @@  discard block
 block discarded – undo
507 517
       
508 518
     }
509 519
 
510
-    if ( !$src )
511
-      return; // Probably should add to $_dompdf_errors or whatever here
520
+    if ( !$src ) {
521
+          return;
522
+    }
523
+    // Probably should add to $_dompdf_errors or whatever here
512 524
     
513 525
     // Scale by the AA factor
514 526
     $x *= $this->_aa_factor;
@@ -550,8 +562,9 @@  discard block
 block discarded – undo
550 562
     
551 563
     $c = $this->_allocate_color($color);
552 564
 
553
-    if ( strpos($font, '.ttf') === false )
554
-      $font .= ".ttf";
565
+    if ( strpos($font, '.ttf') === false ) {
566
+          $font .= ".ttf";
567
+    }
555 568
 
556 569
     // FIXME: word spacing
557 570
     imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text);
@@ -595,8 +608,9 @@  discard block
 block discarded – undo
595 608
    */
596 609
   function get_text_width($text, $font, $size, $spacing = 0) {    
597 610
 
598
-    if ( strpos($font, '.ttf') === false )
599
-      $font .= ".ttf";
611
+    if ( strpos($font, '.ttf') === false ) {
612
+          $font .= ".ttf";
613
+    }
600 614
 
601 615
     // FIXME: word spacing
602 616
     list($x1,,$x2) = imagettfbbox($size, 0, $font, $text);
@@ -611,8 +625,9 @@  discard block
 block discarded – undo
611 625
    * @return float
612 626
    */
613 627
   function get_font_height($font, $size) {
614
-    if ( strpos($font, '.ttf') === false )
615
-      $font .= ".ttf";
628
+    if ( strpos($font, '.ttf') === false ) {
629
+          $font .= ".ttf";
630
+    }
616 631
 
617 632
     // FIXME: word spacing
618 633
     list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl");  // Test string with ascenders, descenders and caps
@@ -649,8 +664,9 @@  discard block
 block discarded – undo
649 664
       $dst = $this->_img;
650 665
     }
651 666
 
652
-    if ( !isset($options["type"]) )
653
-      $options["type"] = "png";
667
+    if ( !isset($options["type"]) ) {
668
+          $options["type"] = "png";
669
+    }
654 670
 
655 671
     $type = strtolower($options["type"]);
656 672
     
@@ -660,8 +676,9 @@  discard block
 block discarded – undo
660 676
 
661 677
     case "jpg":
662 678
     case "jpeg":
663
-      if ( !isset($options["quality"]) )
664
-        $options["quality"] = 75;
679
+      if ( !isset($options["quality"]) ) {
680
+              $options["quality"] = 75;
681
+      }
665 682
       
666 683
       header("Content-type: image/jpeg");
667 684
       imagejpeg($dst, '', $options["quality"]);
@@ -674,8 +691,9 @@  discard block
 block discarded – undo
674 691
       break;
675 692
     }
676 693
 
677
-    if ( $this->_aa_factor != 1 ) 
678
-      imagedestroy($dst);
694
+    if ( $this->_aa_factor != 1 ) {
695
+          imagedestroy($dst);
696
+    }
679 697
   }
680 698
 
681 699
   /**
@@ -697,8 +715,9 @@  discard block
 block discarded – undo
697 715
       $dst = $this->_img;
698 716
     }
699 717
     
700
-    if ( !isset($options["type"]) )
701
-      $options["type"] = "png";
718
+    if ( !isset($options["type"]) ) {
719
+          $options["type"] = "png";
720
+    }
702 721
 
703 722
     $type = $options["type"];
704 723
     
@@ -708,8 +727,9 @@  discard block
 block discarded – undo
708 727
 
709 728
     case "jpg":
710 729
     case "jpeg":
711
-      if ( !isset($options["quality"]) )
712
-        $options["quality"] = 75;
730
+      if ( !isset($options["quality"]) ) {
731
+              $options["quality"] = 75;
732
+      }
713 733
       
714 734
       imagejpeg($dst, '', $options["quality"]);
715 735
       break;
@@ -723,8 +743,9 @@  discard block
 block discarded – undo
723 743
     $image = ob_get_contents();
724 744
     ob_end_clean();
725 745
 
726
-    if ( $this->_aa_factor != 1 )
727
-      imagedestroy($dst);
746
+    if ( $this->_aa_factor != 1 ) {
747
+          imagedestroy($dst);
748
+    }
728 749
     
729 750
     return $image;
730 751
   }
Please login to merge, or discard this patch.
Indentation   +413 added lines, -414 removed lines patch added patch discarded remove patch
@@ -1,41 +1,40 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * DOMPDF - PHP5 HTML to PDF renderer
4
- *
5
- * File: $RCSfile: gd_adapter.cls.php,v $
6
- * Created on: 2004-06-06
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: gd_adapter.cls.php,v $
6
+     * Created on: 2004-06-06
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: gd_adapter.cls.php 217 2010-03-11 23:03:57Z ryan.masten $ */
41 40
 
@@ -49,73 +48,73 @@  discard block
 block discarded – undo
49 48
  */
50 49
 class GD_Adapter implements Canvas {
51 50
 
52
-  /**
53
-   * Resoure handle for the image
54
-   *
55
-   * @var resource
56
-   */
57
-  private $_img;
58
-
59
-  /**
60
-   * Image width in pixels
61
-   *
62
-   * @var int
63
-   */
64
-  private $_width;
65
-
66
-  /**
67
-   * Image height in pixels
68
-   *
69
-   * @var int
70
-   */
71
-  private $_height;
72
-
73
-  /**
74
-   * Image antialias factor
75
-   *
76
-   * @var float
77
-   */
78
-  private $_aa_factor;
79
-
80
-  /**
81
-   * Allocated colors
82
-   *
83
-   * @var array
84
-   */
85
-  private $_colors;
86
-
87
-  /**
88
-   * Background color
89
-   *
90
-   * @var int
91
-   */
92
-  private $_bg_color;
51
+    /**
52
+     * Resoure handle for the image
53
+     *
54
+     * @var resource
55
+     */
56
+    private $_img;
57
+
58
+    /**
59
+     * Image width in pixels
60
+     *
61
+     * @var int
62
+     */
63
+    private $_width;
64
+
65
+    /**
66
+     * Image height in pixels
67
+     *
68
+     * @var int
69
+     */
70
+    private $_height;
71
+
72
+    /**
73
+     * Image antialias factor
74
+     *
75
+     * @var float
76
+     */
77
+    private $_aa_factor;
78
+
79
+    /**
80
+     * Allocated colors
81
+     *
82
+     * @var array
83
+     */
84
+    private $_colors;
85
+
86
+    /**
87
+     * Background color
88
+     *
89
+     * @var int
90
+     */
91
+    private $_bg_color;
93 92
   
94
-  /**
95
-   * Class constructor
96
-   *
97
-   * @param mixed  $size         The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc.
98
-   * @param string $orientation  The orientation of the document (either 'landscape' or 'portrait')
99
-   * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
100
-   * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
101
-   */
102
-  function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
93
+    /**
94
+     * Class constructor
95
+     *
96
+     * @param mixed  $size         The size of image to create: array(x1,y1,x2,y2) or "letter", "legal", etc.
97
+     * @param string $orientation  The orientation of the document (either 'landscape' or 'portrait')
98
+     * @param float  $aa_factor    Anti-aliasing factor, 1 for no AA
99
+     * @param array  $bg_color     Image background color: array(r,g,b,a), 0 <= r,g,b,a <= 1
100
+     */
101
+    function __construct($size, $orientation = "portrait", $aa_factor = 1, $bg_color = array(1,1,1,0) ) {
103 102
 
104 103
     if ( !is_array($size) ) {
105 104
 
106
-      if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
105
+        if ( isset(CPDF_Adapter::$PAPER_SIZES[ strtolower($size)]) ) 
107 106
         $size = CPDF_Adapter::$PAPER_SIZES[$size];
108
-      else
107
+        else
109 108
         $size = CPDF_Adapter::$PAPER_SIZES["letter"];
110 109
     
111 110
     }
112 111
 
113 112
     if ( strtolower($orientation) === "landscape" ) {
114
-      list($size[2],$size[3]) = array($size[3],$size[2]);
113
+        list($size[2],$size[3]) = array($size[3],$size[2]);
115 114
     }
116 115
 
117 116
     if ( $aa_factor < 1 )
118
-      $aa_factor = 1;
117
+        $aa_factor = 1;
119 118
 
120 119
     $this->_aa_factor = $aa_factor;
121 120
     
@@ -128,8 +127,8 @@  discard block
 block discarded – undo
128 127
     $this->_img = imagecreatetruecolor($this->_width, $this->_height);
129 128
 
130 129
     if ( is_null($bg_color) || !is_array($bg_color) ) {
131
-      // Pure white bg
132
-      $bg_color = array(1,1,1,0);
130
+        // Pure white bg
131
+        $bg_color = array(1,1,1,0);
133 132
     }
134 133
 
135 134
     $this->_bg_color = $this->_allocate_color($bg_color);
@@ -137,68 +136,68 @@  discard block
 block discarded – undo
137 136
     imagesavealpha($this->_img, true);
138 137
     imagefill($this->_img, 0, 0, $this->_bg_color);
139 138
         
140
-  }
141
-
142
-  /**
143
-   * Return the GF image resource
144
-   *
145
-   * @return resource
146
-   */
147
-  function get_image() { return $this->_img; }
148
-
149
-  /**
150
-   * Return the image's width in pixels
151
-   *
152
-   * @return float
153
-   */
154
-  function get_width() { return $this->_width / $this->_aa_factor; }
155
-
156
-  /**
157
-   * Return the image's height in pixels
158
-   *
159
-   * @return float
160
-   */
161
-  function get_height() { return $this->_height / $this->_aa_factor; }
139
+    }
140
+
141
+    /**
142
+     * Return the GF image resource
143
+     *
144
+     * @return resource
145
+     */
146
+    function get_image() { return $this->_img; }
147
+
148
+    /**
149
+     * Return the image's width in pixels
150
+     *
151
+     * @return float
152
+     */
153
+    function get_width() { return $this->_width / $this->_aa_factor; }
154
+
155
+    /**
156
+     * Return the image's height in pixels
157
+     *
158
+     * @return float
159
+     */
160
+    function get_height() { return $this->_height / $this->_aa_factor; }
162 161
   
163
-  /**
164
-   * Returns the current page number
165
-   *
166
-   * @return int
167
-   */
168
-  function get_page_number() {
162
+    /**
163
+     * Returns the current page number
164
+     *
165
+     * @return int
166
+     */
167
+    function get_page_number() {
169 168
     // FIXME
170
-  }
169
+    }
171 170
    
172
-  /**
173
-   * Returns the total number of pages
174
-   *
175
-   * @return int
176
-   */
177
-  function get_page_count() {
171
+    /**
172
+     * Returns the total number of pages
173
+     *
174
+     * @return int
175
+     */
176
+    function get_page_count() {
178 177
     // FIXME
179
-  }    
180
-
181
-  /**
182
-   * Sets the total number of pages
183
-   *
184
-   * @param int $count
185
-   */
186
-  function set_page_count($count) {
178
+    }    
179
+
180
+    /**
181
+     * Sets the total number of pages
182
+     *
183
+     * @param int $count
184
+     */
185
+    function set_page_count($count) {
187 186
     // FIXME
188
-  }    
189
-
190
-  /**
191
-   * Allocate a new color.  Allocate with GD as needed and store
192
-   * previously allocated colors in $this->_colors.
193
-   *
194
-   * @param array $color  The new current color
195
-   * @return int           The allocated color
196
-   */
197
-  private function _allocate_color($color) {
187
+    }    
188
+
189
+    /**
190
+     * Allocate a new color.  Allocate with GD as needed and store
191
+     * previously allocated colors in $this->_colors.
192
+     *
193
+     * @param array $color  The new current color
194
+     * @return int           The allocated color
195
+     */
196
+    private function _allocate_color($color) {
198 197
     
199 198
     // Full opacity if no alpha set
200 199
     if ( !isset($color[3]) ) 
201
-      $color[3] = 0;
200
+        $color[3] = 0;
202 201
     
203 202
     list($r,$g,$b,$a) = $color;
204 203
     
@@ -221,33 +220,33 @@  discard block
 block discarded – undo
221 220
     $key = sprintf("#%02X%02X%02X%02X", $r, $g, $b, $a);
222 221
       
223 222
     if ( isset($this->_colors[$key]) )
224
-      return $this->_colors[$key];
223
+        return $this->_colors[$key];
225 224
 
226 225
     if ( $a != 0 ) 
227
-      $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
226
+        $this->_colors[$key] = imagecolorallocatealpha($this->_img, $r, $g, $b, $a);
228 227
     else
229
-      $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
228
+        $this->_colors[$key] = imagecolorallocate($this->_img, $r, $g, $b);
230 229
       
231 230
     return $this->_colors[$key];
232 231
     
233
-  }
232
+    }
234 233
   
235
-  /**
236
-   * Draws a line from x1,y1 to x2,y2
237
-   *
238
-   * See {@link Style::munge_color()} for the format of the color array.
239
-   * See {@link Cpdf::setLineStyle()} for a description of the format of the
240
-   * $style parameter (aka dash).
241
-   *
242
-   * @param float $x1
243
-   * @param float $y1
244
-   * @param float $x2
245
-   * @param float $y2
246
-   * @param array $color
247
-   * @param float $width
248
-   * @param array $style
249
-   */
250
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
234
+    /**
235
+     * Draws a line from x1,y1 to x2,y2
236
+     *
237
+     * See {@link Style::munge_color()} for the format of the color array.
238
+     * See {@link Cpdf::setLineStyle()} for a description of the format of the
239
+     * $style parameter (aka dash).
240
+     *
241
+     * @param float $x1
242
+     * @param float $y1
243
+     * @param float $x2
244
+     * @param float $y2
245
+     * @param array $color
246
+     * @param float $width
247
+     * @param array $style
248
+     */
249
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
251 250
 
252 251
     // Scale by the AA factor
253 252
     $x1 *= $this->_aa_factor;
@@ -260,63 +259,63 @@  discard block
 block discarded – undo
260 259
 
261 260
     // Convert the style array if required
262 261
     if ( !is_null($style) ) {
263
-      $gd_style = array();
262
+        $gd_style = array();
264 263
 
265
-      if ( count($style) == 1 ) {
264
+        if ( count($style) == 1 ) {
266 265
         for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
267
-          $gd_style[] = $c;
266
+            $gd_style[] = $c;
268 267
         }
269 268
 
270 269
         for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) {
271
-          $gd_style[] = $this->_bg_color;
270
+            $gd_style[] = $this->_bg_color;
272 271
         }
273 272
 
274
-      } else {
273
+        } else {
275 274
 
276 275
         $i = 0;
277 276
         foreach ($style as $length) {
278 277
 
279
-          if ( $i % 2 == 0 ) {
278
+            if ( $i % 2 == 0 ) {
280 279
             // 'On' pattern
281 280
             for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
282
-              $gd_style[] = $c;
281
+                $gd_style[] = $c;
283 282
             
284
-          } else {
283
+            } else {
285 284
             // Off pattern
286 285
             for ($i = 0; $i < $style[0] * $this->_aa_factor; $i++) 
287
-              $gd_style[] = $this->_bg_color;
286
+                $gd_style[] = $this->_bg_color;
288 287
             
289
-          }
290
-          $i++;
288
+            }
289
+            $i++;
290
+        }
291 291
         }
292
-      }
293 292
       
294
-      imagesetstyle($this->_img, $gd_style);
295
-      $c = IMG_COLOR_STYLED;
293
+        imagesetstyle($this->_img, $gd_style);
294
+        $c = IMG_COLOR_STYLED;
296 295
     }
297 296
     
298 297
     imagesetthickness($this->_img, $width);
299 298
 
300 299
     imageline($this->_img, $x1, $y1, $x2, $y2, $c);
301 300
     
302
-  }
303
-
304
-  /**
305
-   * Draws a rectangle at x1,y1 with width w and height h
306
-   *
307
-   * See {@link Style::munge_color()} for the format of the color array.
308
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
309
-   * parameter (aka dash)
310
-   *
311
-   * @param float $x1
312
-   * @param float $y1
313
-   * @param float $w
314
-   * @param float $h
315
-   * @param array $color
316
-   * @param float $width
317
-   * @param array $style
318
-   */   
319
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
301
+    }
302
+
303
+    /**
304
+     * Draws a rectangle at x1,y1 with width w and height h
305
+     *
306
+     * See {@link Style::munge_color()} for the format of the color array.
307
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
308
+     * parameter (aka dash)
309
+     *
310
+     * @param float $x1
311
+     * @param float $y1
312
+     * @param float $w
313
+     * @param float $h
314
+     * @param array $color
315
+     * @param float $width
316
+     * @param array $style
317
+     */   
318
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
320 319
 
321 320
     // Scale by the AA factor
322 321
     $x1 *= $this->_aa_factor;
@@ -328,36 +327,36 @@  discard block
 block discarded – undo
328 327
 
329 328
     // Convert the style array if required
330 329
     if ( !is_null($style) ) {
331
-      $gd_style = array();
330
+        $gd_style = array();
332 331
 
333
-      foreach ($style as $length) {
332
+        foreach ($style as $length) {
334 333
         for ($i = 0; $i < $length; $i++) {
335
-          $gd_style[] = $c;
334
+            $gd_style[] = $c;
335
+        }
336 336
         }
337
-      }
338 337
 
339
-      imagesetstyle($this->_img, $gd_style);
340
-      $c = IMG_COLOR_STYLED;
338
+        imagesetstyle($this->_img, $gd_style);
339
+        $c = IMG_COLOR_STYLED;
341 340
     }
342 341
 
343 342
     imagesetthickness($this->_img, $width);
344 343
 
345 344
     imagerectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c);
346 345
     
347
-  }
348
-
349
-  /**
350
-   * Draws a filled rectangle at x1,y1 with width w and height h
351
-   *
352
-   * See {@link Style::munge_color()} for the format of the color array.
353
-   *
354
-   * @param float $x1
355
-   * @param float $y1
356
-   * @param float $w
357
-   * @param float $h
358
-   * @param array $color
359
-   */   
360
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
346
+    }
347
+
348
+    /**
349
+     * Draws a filled rectangle at x1,y1 with width w and height h
350
+     *
351
+     * See {@link Style::munge_color()} for the format of the color array.
352
+     *
353
+     * @param float $x1
354
+     * @param float $y1
355
+     * @param float $w
356
+     * @param float $h
357
+     * @param array $color
358
+     */   
359
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
361 360
 
362 361
     // Scale by the AA factor
363 362
     $x1 *= $this->_aa_factor;
@@ -369,79 +368,79 @@  discard block
 block discarded – undo
369 368
 
370 369
     imagefilledrectangle($this->_img, $x1, $y1, $x1 + $w, $y1 + $h, $c);
371 370
 
372
-  }
373
-
374
-  /**
375
-   * Draws a polygon
376
-   *
377
-   * The polygon is formed by joining all the points stored in the $points
378
-   * array.  $points has the following structure:
379
-   * <code>
380
-   * array(0 => x1,
381
-   *       1 => y1,
382
-   *       2 => x2,
383
-   *       3 => y2,
384
-   *       ...
385
-   *       );
386
-   * </code>
387
-   *
388
-   * See {@link Style::munge_color()} for the format of the color array.
389
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
390
-   * parameter (aka dash)   
391
-   *
392
-   * @param array $points
393
-   * @param array $color
394
-   * @param float $width
395
-   * @param array $style
396
-   * @param bool  $fill  Fills the polygon if true
397
-   */
398
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
371
+    }
372
+
373
+    /**
374
+     * Draws a polygon
375
+     *
376
+     * The polygon is formed by joining all the points stored in the $points
377
+     * array.  $points has the following structure:
378
+     * <code>
379
+     * array(0 => x1,
380
+     *       1 => y1,
381
+     *       2 => x2,
382
+     *       3 => y2,
383
+     *       ...
384
+     *       );
385
+     * </code>
386
+     *
387
+     * See {@link Style::munge_color()} for the format of the color array.
388
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
389
+     * parameter (aka dash)   
390
+     *
391
+     * @param array $points
392
+     * @param array $color
393
+     * @param float $width
394
+     * @param array $style
395
+     * @param bool  $fill  Fills the polygon if true
396
+     */
397
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
399 398
 
400 399
     // Scale each point by the AA factor
401 400
     foreach (array_keys($points) as $i)
402
-      $points[$i] *= $this->_aa_factor;
401
+        $points[$i] *= $this->_aa_factor;
403 402
 
404 403
     $c = $this->_allocate_color($color);
405 404
 
406 405
     // Convert the style array if required
407 406
     if ( !is_null($style) && !$fill ) {
408
-      $gd_style = array();
407
+        $gd_style = array();
409 408
 
410
-      foreach ($style as $length) {
409
+        foreach ($style as $length) {
411 410
         for ($i = 0; $i < $length; $i++) {
412
-          $gd_style[] = $c;
411
+            $gd_style[] = $c;
412
+        }
413 413
         }
414
-      }
415 414
 
416
-      imagesetstyle($this->_img, $gd_style);
417
-      $c = IMG_COLOR_STYLED;
415
+        imagesetstyle($this->_img, $gd_style);
416
+        $c = IMG_COLOR_STYLED;
418 417
     }
419 418
 
420 419
     imagesetthickness($this->_img, $width);
421 420
 
422 421
     if ( $fill ) 
423
-      imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
422
+        imagefilledpolygon($this->_img, $points, count($points) / 2, $c);
424 423
     else
425
-      imagepolygon($this->_img, $points, count($points) / 2, $c);
424
+        imagepolygon($this->_img, $points, count($points) / 2, $c);
426 425
         
427
-  }
428
-
429
-  /**
430
-   * Draws a circle at $x,$y with radius $r
431
-   *
432
-   * See {@link Style::munge_color()} for the format of the color array.
433
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
434
-   * parameter (aka dash)
435
-   *
436
-   * @param float $x
437
-   * @param float $y
438
-   * @param float $r
439
-   * @param array $color
440
-   * @param float $width
441
-   * @param array $style
442
-   * @param bool $fill Fills the circle if true   
443
-   */   
444
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
426
+    }
427
+
428
+    /**
429
+     * Draws a circle at $x,$y with radius $r
430
+     *
431
+     * See {@link Style::munge_color()} for the format of the color array.
432
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
433
+     * parameter (aka dash)
434
+     *
435
+     * @param float $x
436
+     * @param float $y
437
+     * @param float $r
438
+     * @param array $color
439
+     * @param float $width
440
+     * @param array $style
441
+     * @param bool $fill Fills the circle if true   
442
+     */   
443
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
445 444
 
446 445
     // Scale by the AA factor
447 446
     $x *= $this->_aa_factor;
@@ -452,55 +451,55 @@  discard block
 block discarded – undo
452 451
 
453 452
     // Convert the style array if required
454 453
     if ( !is_null($style) && !$fill ) {
455
-      $gd_style = array();
454
+        $gd_style = array();
456 455
 
457
-      foreach ($style as $length) {
456
+        foreach ($style as $length) {
458 457
         for ($i = 0; $i < $length; $i++) {
459
-          $gd_style[] = $c;
458
+            $gd_style[] = $c;
459
+        }
460 460
         }
461
-      }
462 461
 
463
-      imagesetstyle($this->_img, $gd_style);
464
-      $c = IMG_COLOR_STYLED;
462
+        imagesetstyle($this->_img, $gd_style);
463
+        $c = IMG_COLOR_STYLED;
465 464
     }
466 465
 
467 466
     imagesetthickness($this->_img, $width);
468 467
 
469 468
     if ( $fill )
470
-      imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
469
+        imagefilledellipse($this->_img, $x, $y, $r, $r, $c);
471 470
     else
472
-      imageellipse($this->_img, $x, $y, $r, $r, $c);
471
+        imageellipse($this->_img, $x, $y, $r, $r, $c);
473 472
         
474
-  }
475
-
476
-  /**
477
-   * Add an image to the pdf.
478
-   *
479
-   * The image is placed at the specified x and y coordinates with the
480
-   * given width and height.
481
-   *
482
-   * @param string $img_url the path to the image
483
-   * @param string $img_type the type (e.g. extension) of the image
484
-   * @param float $x x position
485
-   * @param float $y y position
486
-   * @param int $w width (in pixels)
487
-   * @param int $h height (in pixels)
488
-   */
489
-  function image($img_url, $img_type, $x, $y, $w, $h) {
473
+    }
474
+
475
+    /**
476
+     * Add an image to the pdf.
477
+     *
478
+     * The image is placed at the specified x and y coordinates with the
479
+     * given width and height.
480
+     *
481
+     * @param string $img_url the path to the image
482
+     * @param string $img_type the type (e.g. extension) of the image
483
+     * @param float $x x position
484
+     * @param float $y y position
485
+     * @param int $w width (in pixels)
486
+     * @param int $h height (in pixels)
487
+     */
488
+    function image($img_url, $img_type, $x, $y, $w, $h) {
490 489
 
491 490
     switch ($img_type) {
492 491
     case "png":
493 492
       $src = @imagecreatefrompng($img_url);
494
-      break;
493
+        break;
495 494
       
496 495
     case "gif":
497 496
       $src = @imagecreatefromgif($img_url);
498
-      break;
497
+        break;
499 498
       
500 499
     case "jpg":
501 500
     case "jpeg":
502 501
       $src = @imagecreatefromjpeg($img_url);
503
-      break;
502
+        break;
504 503
 
505 504
     default:
506 505
       break;
@@ -508,7 +507,7 @@  discard block
 block discarded – undo
508 507
     }
509 508
 
510 509
     if ( !$src )
511
-      return; // Probably should add to $_dompdf_errors or whatever here
510
+        return; // Probably should add to $_dompdf_errors or whatever here
512 511
     
513 512
     // Scale by the AA factor
514 513
     $x *= $this->_aa_factor;
@@ -523,23 +522,23 @@  discard block
 block discarded – undo
523 522
     
524 523
     imagecopyresampled($this->_img, $src, $x, $y, 0, 0, $w, $h, $img_w, $img_h);
525 524
     
526
-  }
527
-
528
-  /**
529
-   * Writes text at the specified x and y coordinates
530
-   *
531
-   * See {@link Style::munge_color()} for the format of the color array.
532
-   *
533
-   * @param float $x
534
-   * @param float $y
535
-   * @param string $text the text to write
536
-   * @param string $font the font file to use
537
-   * @param float $size the font size, in points
538
-   * @param array $color
539
-   * @param float $adjust word spacing adjustment
540
-   * @param float $angle Text angle
541
-   */
542
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
525
+    }
526
+
527
+    /**
528
+     * Writes text at the specified x and y coordinates
529
+     *
530
+     * See {@link Style::munge_color()} for the format of the color array.
531
+     *
532
+     * @param float $x
533
+     * @param float $y
534
+     * @param string $text the text to write
535
+     * @param string $font the font file to use
536
+     * @param float $size the font size, in points
537
+     * @param array $color
538
+     * @param float $adjust word spacing adjustment
539
+     * @param float $angle Text angle
540
+     */
541
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
543 542
 
544 543
     // Scale by the AA factor
545 544
     $x *= $this->_aa_factor;
@@ -551,106 +550,106 @@  discard block
 block discarded – undo
551 550
     $c = $this->_allocate_color($color);
552 551
 
553 552
     if ( strpos($font, '.ttf') === false )
554
-      $font .= ".ttf";
553
+        $font .= ".ttf";
555 554
 
556 555
     // FIXME: word spacing
557 556
     imagettftext($this->_img, $size, $angle, $x, $y + $h, $c, $font, $text);
558 557
     
559
-  }
558
+    }
560 559
   
561
-  function javascript($code) {
560
+    function javascript($code) {
562 561
     // Not implemented
563
-  }
564
-
565
-  /**
566
-   * Add a named destination (similar to <a name="foo">...</a> in html)
567
-   *
568
-   * @param string $anchorname The name of the named destination
569
-   */
570
-  function add_named_dest($anchorname) {
562
+    }
563
+
564
+    /**
565
+     * Add a named destination (similar to <a name="foo">...</a> in html)
566
+     *
567
+     * @param string $anchorname The name of the named destination
568
+     */
569
+    function add_named_dest($anchorname) {
571 570
     // Not implemented
572
-  }
573
-
574
-  /**
575
-   * Add a link to the pdf
576
-   *
577
-   * @param string $url The url to link to
578
-   * @param float  $x   The x position of the link
579
-   * @param float  $y   The y position of the link
580
-   * @param float  $width   The width of the link
581
-   * @param float  $height   The height of the link
582
-   */
583
-  function add_link($url, $x, $y, $width, $height) {
571
+    }
572
+
573
+    /**
574
+     * Add a link to the pdf
575
+     *
576
+     * @param string $url The url to link to
577
+     * @param float  $x   The x position of the link
578
+     * @param float  $y   The y position of the link
579
+     * @param float  $width   The width of the link
580
+     * @param float  $height   The height of the link
581
+     */
582
+    function add_link($url, $x, $y, $width, $height) {
584 583
     // Not implemented
585
-  }
586
-
587
-  /**
588
-   * Calculates text size, in points
589
-   *
590
-   * @param string $text the text to be sized
591
-   * @param string $font the desired font
592
-   * @param float  $size the desired font size
593
-   * @param float  $spacing word spacing, if any
594
-   * @return float
595
-   */
596
-  function get_text_width($text, $font, $size, $spacing = 0) {    
584
+    }
585
+
586
+    /**
587
+     * Calculates text size, in points
588
+     *
589
+     * @param string $text the text to be sized
590
+     * @param string $font the desired font
591
+     * @param float  $size the desired font size
592
+     * @param float  $spacing word spacing, if any
593
+     * @return float
594
+     */
595
+    function get_text_width($text, $font, $size, $spacing = 0) {    
597 596
 
598 597
     if ( strpos($font, '.ttf') === false )
599
-      $font .= ".ttf";
598
+        $font .= ".ttf";
600 599
 
601 600
     // FIXME: word spacing
602 601
     list($x1,,$x2) = imagettfbbox($size, 0, $font, $text);
603 602
     return $x2 - $x1;
604
-  }
605
-
606
-  /**
607
-   * Calculates font height, in points
608
-   *
609
-   * @param string $font
610
-   * @param float $size
611
-   * @return float
612
-   */
613
-  function get_font_height($font, $size) {
603
+    }
604
+
605
+    /**
606
+     * Calculates font height, in points
607
+     *
608
+     * @param string $font
609
+     * @param float $size
610
+     * @return float
611
+     */
612
+    function get_font_height($font, $size) {
614 613
     if ( strpos($font, '.ttf') === false )
615
-      $font .= ".ttf";
614
+        $font .= ".ttf";
616 615
 
617 616
     // FIXME: word spacing
618 617
     list(,$y2,,,,$y1) = imagettfbbox($size, 0, $font, "MXjpqytfhl");  // Test string with ascenders, descenders and caps
619 618
     return $y2 - $y1;
620
-  }
619
+    }
621 620
 
622 621
   
623
-  /**
624
-   * Starts a new page
625
-   *
626
-   * Subsequent drawing operations will appear on the new page.
627
-   */
628
-  function new_page() {
622
+    /**
623
+     * Starts a new page
624
+     *
625
+     * Subsequent drawing operations will appear on the new page.
626
+     */
627
+    function new_page() {
629 628
     // FIXME
630
-  }    
629
+    }    
631 630
 
632
-  /**
633
-   * Streams the image directly to the browser
634
-   *
635
-   * @param string $filename the name of the image file (ignored)
636
-   * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
637
-   */
638
-  function stream($filename, $options = null) {
631
+    /**
632
+     * Streams the image directly to the browser
633
+     *
634
+     * @param string $filename the name of the image file (ignored)
635
+     * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
636
+     */
637
+    function stream($filename, $options = null) {
639 638
 
640 639
     // Perform any antialiasing
641 640
     if ( $this->_aa_factor != 1 ) {
642
-      $dst_w = $this->_width / $this->_aa_factor;
643
-      $dst_h = $this->_height / $this->_aa_factor;
644
-      $dst = imagecreatetruecolor($dst_w, $dst_h);
645
-      imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
646
-                         $dst_w, $dst_h,
647
-                         $this->_width, $this->_height);
641
+        $dst_w = $this->_width / $this->_aa_factor;
642
+        $dst_h = $this->_height / $this->_aa_factor;
643
+        $dst = imagecreatetruecolor($dst_w, $dst_h);
644
+        imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
645
+                            $dst_w, $dst_h,
646
+                            $this->_width, $this->_height);
648 647
     } else {
649
-      $dst = $this->_img;
648
+        $dst = $this->_img;
650 649
     }
651 650
 
652 651
     if ( !isset($options["type"]) )
653
-      $options["type"] = "png";
652
+        $options["type"] = "png";
654 653
 
655 654
     $type = strtolower($options["type"]);
656 655
     
@@ -663,42 +662,42 @@  discard block
 block discarded – undo
663 662
       if ( !isset($options["quality"]) )
664 663
         $options["quality"] = 75;
665 664
       
666
-      header("Content-type: image/jpeg");
667
-      imagejpeg($dst, '', $options["quality"]);
668
-      break;
665
+        header("Content-type: image/jpeg");
666
+        imagejpeg($dst, '', $options["quality"]);
667
+        break;
669 668
 
670 669
     case "png":
671 670
     default:
672 671
       header("Content-type: image/png");
673
-      imagepng($dst);
674
-      break;
672
+        imagepng($dst);
673
+        break;
675 674
     }
676 675
 
677 676
     if ( $this->_aa_factor != 1 ) 
678
-      imagedestroy($dst);
679
-  }
677
+        imagedestroy($dst);
678
+    }
680 679
 
681
-  /**
682
-   * Returns the PNG as a string
683
-   *
684
-   * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
685
-   * @return string
686
-   */
687
-  function output($options = null) {
680
+    /**
681
+     * Returns the PNG as a string
682
+     *
683
+     * @param array  $options associative array, 'type' => jpeg|jpg|png, 'quality' => 0 - 100 (jpeg only)
684
+     * @return string
685
+     */
686
+    function output($options = null) {
688 687
 
689 688
     if ( $this->_aa_factor != 1 ) {
690
-      $dst_w = $this->_width / $this->_aa_factor;
691
-      $dst_h = $this->_height / $this->_aa_factor;
692
-      $dst = imagecreatetruecolor($dst_w, $dst_h);
693
-      imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
694
-                         $dst_w, $dst_h,
695
-                         $this->_width, $this->_height);
689
+        $dst_w = $this->_width / $this->_aa_factor;
690
+        $dst_h = $this->_height / $this->_aa_factor;
691
+        $dst = imagecreatetruecolor($dst_w, $dst_h);
692
+        imagecopyresampled($dst, $this->_img, 0, 0, 0, 0,
693
+                            $dst_w, $dst_h,
694
+                            $this->_width, $this->_height);
696 695
     } else {
697
-      $dst = $this->_img;
696
+        $dst = $this->_img;
698 697
     }
699 698
     
700 699
     if ( !isset($options["type"]) )
701
-      $options["type"] = "png";
700
+        $options["type"] = "png";
702 701
 
703 702
     $type = $options["type"];
704 703
     
@@ -711,23 +710,23 @@  discard block
 block discarded – undo
711 710
       if ( !isset($options["quality"]) )
712 711
         $options["quality"] = 75;
713 712
       
714
-      imagejpeg($dst, '', $options["quality"]);
715
-      break;
713
+        imagejpeg($dst, '', $options["quality"]);
714
+        break;
716 715
 
717 716
     case "png":
718 717
     default:
719 718
       imagepng($dst);
720
-      break;
719
+        break;
721 720
     }
722 721
 
723 722
     $image = ob_get_contents();
724 723
     ob_end_clean();
725 724
 
726 725
     if ( $this->_aa_factor != 1 )
727
-      imagedestroy($dst);
726
+        imagedestroy($dst);
728 727
     
729 728
     return $image;
730
-  }
729
+    }
731 730
   
732 731
   
733 732
 }
Please login to merge, or discard this patch.