Completed
Push — 1.10.x ( ba0bf0...97c0d2 )
by Angel Fernando Quiroz
44:06
created
main/inc/lib/phpdocx/lib/log4php/appenders/LoggerAppenderDailyFile.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -46,47 +46,47 @@
 block discarded – undo
46 46
  */
47 47
 class LoggerAppenderDailyFile extends LoggerAppenderFile {
48 48
 
49
-	/**
50
-	 * Format date. 
51
-	 * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>.
52
-	 * @var string
53
-	 */
54
-	public $datePattern = "Ymd";
49
+    /**
50
+     * Format date. 
51
+     * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>.
52
+     * @var string
53
+     */
54
+    public $datePattern = "Ymd";
55 55
 	
56
-	public function __destruct() {
57
-       parent::__destruct();
58
-   	}
56
+    public function __destruct() {
57
+        parent::__destruct();
58
+        }
59 59
    	
60
-	/**
61
-	* Sets date format for the file name.
62
-	* @param string $format a regular date() string format
63
-	*/
64
-	public function setDatePattern($format) {
65
-		$this->datePattern = $format;
66
-	}
60
+    /**
61
+     * Sets date format for the file name.
62
+     * @param string $format a regular date() string format
63
+     */
64
+    public function setDatePattern($format) {
65
+        $this->datePattern = $format;
66
+    }
67 67
 	
68
-	/**
69
-	* @return string returns date format for the filename
70
-	*/
71
-	public function getDatePattern() {
72
-		return $this->datePattern;
73
-	}
68
+    /**
69
+     * @return string returns date format for the filename
70
+     */
71
+    public function getDatePattern() {
72
+        return $this->datePattern;
73
+    }
74 74
 	
75
-	/**
76
-	* The File property takes a string value which should be the name of the file to append to.
77
-	* Sets and opens the file where the log output will go.
78
-	*
79
-	* @see LoggerAppenderFile::setFile()
80
-	*/
81
-	public function setFile() {
82
-		$numargs = func_num_args();
83
-		$args = func_get_args();
75
+    /**
76
+     * The File property takes a string value which should be the name of the file to append to.
77
+     * Sets and opens the file where the log output will go.
78
+     *
79
+     * @see LoggerAppenderFile::setFile()
80
+     */
81
+    public function setFile() {
82
+        $numargs = func_num_args();
83
+        $args = func_get_args();
84 84
 		
85
-		if($numargs == 1 and is_string($args[0])) {
86
-			parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) );
87
-		} else if ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) {
88
-			parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] );
89
-		}
90
-	} 
85
+        if($numargs == 1 and is_string($args[0])) {
86
+            parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) );
87
+        } else if ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) {
88
+            parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] );
89
+        }
90
+    } 
91 91
 
92 92
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/appenders/LoggerAppenderFile.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -42,129 +42,129 @@
 block discarded – undo
42 42
  */
43 43
 class LoggerAppenderFile extends LoggerAppender {
44 44
 
45
-	/**
46
-	 * @var boolean if {@link $file} exists, appends events.
47
-	 */
48
-	private $append = true;
49
-	/**
50
-	 * @var string the file name used to append events
51
-	 */
52
-	protected $fileName;
53
-	/**
54
-	 * @var mixed file resource
55
-	 */
56
-	protected $fp = false;
45
+    /**
46
+     * @var boolean if {@link $file} exists, appends events.
47
+     */
48
+    private $append = true;
49
+    /**
50
+     * @var string the file name used to append events
51
+     */
52
+    protected $fileName;
53
+    /**
54
+     * @var mixed file resource
55
+     */
56
+    protected $fp = false;
57 57
 	
58
-	public function __construct($name = '') {
59
-		parent::__construct($name);
60
-		$this->requiresLayout = true;
61
-	}
58
+    public function __construct($name = '') {
59
+        parent::__construct($name);
60
+        $this->requiresLayout = true;
61
+    }
62 62
 
63
-	public function __destruct() {
64
-       $this->close();
65
-   	}
63
+    public function __destruct() {
64
+        $this->close();
65
+        }
66 66
    	
67
-	public function activateOptions() {
68
-		$fileName = $this->getFile();
67
+    public function activateOptions() {
68
+        $fileName = $this->getFile();
69 69
 
70
-		if(!is_file($fileName)) {
71
-			$dir = dirname($fileName);
72
-			if(!is_dir($dir)) {
73
-				mkdir($dir, 0777, true);
74
-			}
75
-		}
70
+        if(!is_file($fileName)) {
71
+            $dir = dirname($fileName);
72
+            if(!is_dir($dir)) {
73
+                mkdir($dir, 0777, true);
74
+            }
75
+        }
76 76
 
77
-		$this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
78
-		if($this->fp) {
79
-			if(flock($this->fp, LOCK_EX)) {
80
-				if($this->getAppend()) {
81
-					fseek($this->fp, 0, SEEK_END);
82
-				}
83
-				fwrite($this->fp, $this->layout->getHeader());
84
-				flock($this->fp, LOCK_UN);
85
-				$this->closed = false;
86
-			} else {
87
-				// TODO: should we take some action in this case?
88
-				$this->closed = true;
89
-			}		 
90
-		} else {
91
-			$this->closed = true;
92
-		}
93
-	}
77
+        $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w'));
78
+        if($this->fp) {
79
+            if(flock($this->fp, LOCK_EX)) {
80
+                if($this->getAppend()) {
81
+                    fseek($this->fp, 0, SEEK_END);
82
+                }
83
+                fwrite($this->fp, $this->layout->getHeader());
84
+                flock($this->fp, LOCK_UN);
85
+                $this->closed = false;
86
+            } else {
87
+                // TODO: should we take some action in this case?
88
+                $this->closed = true;
89
+            }		 
90
+        } else {
91
+            $this->closed = true;
92
+        }
93
+    }
94 94
 	
95
-	public function close() {
96
-		if($this->closed != true) {
97
-			if($this->fp and $this->layout !== null) {
98
-				if(flock($this->fp, LOCK_EX)) {
99
-					fwrite($this->fp, $this->layout->getFooter());
100
-					flock($this->fp, LOCK_UN);
101
-				}
102
-				fclose($this->fp);
103
-			}
104
-			$this->closed = true;
105
-		}
106
-	}
95
+    public function close() {
96
+        if($this->closed != true) {
97
+            if($this->fp and $this->layout !== null) {
98
+                if(flock($this->fp, LOCK_EX)) {
99
+                    fwrite($this->fp, $this->layout->getFooter());
100
+                    flock($this->fp, LOCK_UN);
101
+                }
102
+                fclose($this->fp);
103
+            }
104
+            $this->closed = true;
105
+        }
106
+    }
107 107
 
108
-	public function append(LoggerLoggingEvent $event) {
109
-		if($this->fp and $this->layout !== null) {
110
-			if(flock($this->fp, LOCK_EX)) {
111
-				fwrite($this->fp, $this->layout->format($event));
112
-				flock($this->fp, LOCK_UN);
113
-			} else {
114
-				$this->closed = true;
115
-			}
116
-		} 
117
-	}
108
+    public function append(LoggerLoggingEvent $event) {
109
+        if($this->fp and $this->layout !== null) {
110
+            if(flock($this->fp, LOCK_EX)) {
111
+                fwrite($this->fp, $this->layout->format($event));
112
+                flock($this->fp, LOCK_UN);
113
+            } else {
114
+                $this->closed = true;
115
+            }
116
+        } 
117
+    }
118 118
 	
119
-	/**
120
-	 * Sets and opens the file where the log output will go.
121
-	 *
122
-	 * This is an overloaded method. It can be called with:
123
-	 * - setFile(string $fileName) to set filename.
124
-	 * - setFile(string $fileName, boolean $append) to set filename and append.
125
-	 * 
126
-	 * TODO: remove overloading. Use only file as alias to filename
127
-	 */
128
-	public function setFile() {
129
-		$numargs = func_num_args();
130
-		$args	 = func_get_args();
119
+    /**
120
+     * Sets and opens the file where the log output will go.
121
+     *
122
+     * This is an overloaded method. It can be called with:
123
+     * - setFile(string $fileName) to set filename.
124
+     * - setFile(string $fileName, boolean $append) to set filename and append.
125
+     * 
126
+     * TODO: remove overloading. Use only file as alias to filename
127
+     */
128
+    public function setFile() {
129
+        $numargs = func_num_args();
130
+        $args	 = func_get_args();
131 131
 
132
-		if($numargs == 1 and is_string($args[0])) {
133
-			$this->setFileName($args[0]);
134
-		} else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) {
135
-			$this->setFile($args[0]);
136
-			$this->setAppend($args[1]);
137
-		}
138
-	}
132
+        if($numargs == 1 and is_string($args[0])) {
133
+            $this->setFileName($args[0]);
134
+        } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) {
135
+            $this->setFile($args[0]);
136
+            $this->setAppend($args[1]);
137
+        }
138
+    }
139 139
 	
140
-	/**
141
-	 * @return string
142
-	 */
143
-	public function getFile() {
144
-		return $this->getFileName();
145
-	}
140
+    /**
141
+     * @return string
142
+     */
143
+    public function getFile() {
144
+        return $this->getFileName();
145
+    }
146 146
 	
147
-	/**
148
-	 * @return boolean
149
-	 */
150
-	public function getAppend() {
151
-		return $this->append;
152
-	}
147
+    /**
148
+     * @return boolean
149
+     */
150
+    public function getAppend() {
151
+        return $this->append;
152
+    }
153 153
 
154
-	public function setAppend($flag) {
155
-		$this->append = LoggerOptionConverter::toBoolean($flag, true);		  
156
-	}
154
+    public function setAppend($flag) {
155
+        $this->append = LoggerOptionConverter::toBoolean($flag, true);		  
156
+    }
157 157
 
158
-	public function setFileName($fileName) {
159
-		$this->fileName = $fileName;
160
-	}
158
+    public function setFileName($fileName) {
159
+        $this->fileName = $fileName;
160
+    }
161 161
 	
162
-	/**
163
-	 * @return string
164
-	 */
165
-	public function getFileName() {
166
-		return $this->fileName;
167
-	}
162
+    /**
163
+     * @return string
164
+     */
165
+    public function getFileName() {
166
+        return $this->fileName;
167
+    }
168 168
 	
169 169
 	 
170 170
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/image_renderer.cls.php 1 patch
Indentation   +2 added lines, -3 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: image_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,7 +46,7 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Image_Renderer extends Abstract_Renderer {
49 48
 
50
-  function render(Frame $frame) {
49
+    function render(Frame $frame) {
51 50
 
52 51
     // Render background & borders
53 52
     //parent::render($frame);
@@ -65,5 +64,5 @@  discard block
 block discarded – undo
65 64
 
66 65
     $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h);
67 66
 
68
-  }
67
+    }
69 68
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_decorator.cls.php 1 patch
Indentation   +71 added lines, -72 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: block_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -47,16 +46,16 @@  discard block
 block discarded – undo
47 46
  */
48 47
 class Block_Frame_Decorator extends Frame_Decorator {
49 48
 
50
-  const DEFAULT_COUNTER = "-dompdf-default-counter";
49
+    const DEFAULT_COUNTER = "-dompdf-default-counter";
51 50
 
52
-  protected $_lines; // array( [num] => array([frames] => array(<frame list>),
53
-                     //                 y, w, h) )
54
-  protected $_counters; // array([id] => counter_value) (for generated content)
55
-  protected $_cl;    // current line index
51
+    protected $_lines; // array( [num] => array([frames] => array(<frame list>),
52
+                        //                 y, w, h) )
53
+    protected $_counters; // array([id] => counter_value) (for generated content)
54
+    protected $_cl;    // current line index
56 55
 
57
-  //........................................................................
56
+    //........................................................................
58 57
 
59
-  function __construct(Frame $frame, DOMPDF $dompdf) {
58
+    function __construct(Frame $frame, DOMPDF $dompdf) {
60 59
     parent::__construct($frame, $dompdf);
61 60
     $this->_lines = array(array("frames" => array(),
62 61
                                 "wc" => 0,
@@ -66,11 +65,11 @@  discard block
 block discarded – undo
66 65
     $this->_counters = array(self::DEFAULT_COUNTER => 0);
67 66
     $this->_cl = 0;
68 67
 
69
-  }
68
+    }
70 69
 
71
-  //........................................................................
70
+    //........................................................................
72 71
 
73
-  function reset() {
72
+    function reset() {
74 73
     parent::reset();
75 74
     $this->_lines = array(array("frames" => array(),
76 75
                                 "wc" => 0,
@@ -79,67 +78,67 @@  discard block
 block discarded – undo
79 78
                                 "h" => 0));
80 79
     $this->_counters = array(self::DEFAULT_COUNTER => 0);
81 80
     $this->_cl = 0;
82
-  }
81
+    }
83 82
 
84
-  //........................................................................
83
+    //........................................................................
85 84
 
86
-  // Accessor methods
85
+    // Accessor methods
87 86
 
88
-  function get_current_line($i = null) {
87
+    function get_current_line($i = null) {
89 88
     $cl = $this->_lines[$this->_cl];
90 89
     if ( isset($i) )
91
-      return $cl[$i];
90
+        return $cl[$i];
92 91
     return $cl;
93
-  }
92
+    }
94 93
 
95
-  function get_lines() { return $this->_lines; }
94
+    function get_lines() { return $this->_lines; }
96 95
 
97
-  //........................................................................
96
+    //........................................................................
98 97
 
99
-  // Set methods
100
-  function set_current_line($y = null, $w = null, $h = null) {
98
+    // Set methods
99
+    function set_current_line($y = null, $w = null, $h = null) {
101 100
     $this->set_line($this->_cl, $y, $w, $h);
102
-  }
101
+    }
103 102
 
104
-  function clear_line($i) {
103
+    function clear_line($i) {
105 104
     if ( isset($this->_lines[$i]) )
106
-      unset($this->_lines[$i]);
107
-  }
105
+        unset($this->_lines[$i]);
106
+    }
108 107
 
109
-  function set_line($lineno, $y = null, $w = null, $h = null) {
108
+    function set_line($lineno, $y = null, $w = null, $h = null) {
110 109
 
111 110
     if ( is_array($y) )
112
-      extract($y);
111
+        extract($y);
113 112
 
114 113
     if (is_numeric($y))
115
-      $this->_lines[$lineno]["y"] = $y;
114
+        $this->_lines[$lineno]["y"] = $y;
116 115
 
117 116
     if (is_numeric($w))
118
-      $this->_lines[$lineno]["w"] = $w;
117
+        $this->_lines[$lineno]["w"] = $w;
119 118
 
120 119
     if (is_numeric($h))
121
-      $this->_lines[$lineno]["h"] = $h;
120
+        $this->_lines[$lineno]["h"] = $h;
122 121
 
123
-  }
122
+    }
124 123
 
125 124
 
126
-  function add_frame_to_line(Frame $frame) {
125
+    function add_frame_to_line(Frame $frame) {
127 126
 
128 127
     // Handle inline frames (which are effectively wrappers)
129 128
     if ( $frame instanceof Inline_Frame_Decorator ) {
130 129
 
131
-      // Handle line breaks
132
-      if ( $frame->get_node()->nodeName === "br" ) {
130
+        // Handle line breaks
131
+        if ( $frame->get_node()->nodeName === "br" ) {
133 132
         $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) );
134 133
         $this->add_line();
135 134
         return;
136
-      }
135
+        }
137 136
 
138
-      // Add each child of the inline frame to the line individually
139
-      foreach ($frame->get_children() as $child)
137
+        // Add each child of the inline frame to the line individually
138
+        foreach ($frame->get_children() as $child)
140 139
         $this->add_frame_to_line( $child );
141 140
 
142
-      return;
141
+        return;
143 142
     }
144 143
 
145 144
     // Trim leading text if this is an empty line.  Kinda a hack to put it here,
@@ -149,15 +148,15 @@  discard block
 block discarded – undo
149 148
          ($frame->get_style()->white_space !== "pre" ||
150 149
           $frame->get_style()->white_space !== "pre-wrap") ) {
151 150
 
152
-      $frame->set_text( ltrim($frame->get_text()) );
153
-      $frame->recalculate_width();
151
+        $frame->set_text( ltrim($frame->get_text()) );
152
+        $frame->recalculate_width();
154 153
 
155 154
     }
156 155
 
157 156
     $w = $frame->get_margin_width();
158 157
 
159 158
     if ( $w == 0 )
160
-      return;
159
+        return;
161 160
 
162 161
     // Debugging code:
163 162
     /*
@@ -177,7 +176,7 @@  discard block
 block discarded – undo
177 176
     // End debugging
178 177
 
179 178
     if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w"))
180
-      $this->add_line();
179
+        $this->add_line();
181 180
 
182 181
     $frame->position();
183 182
 
@@ -185,55 +184,55 @@  discard block
 block discarded – undo
185 184
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 185
 
187 186
     if ( $frame->get_node()->nodeName === "#text")
188
-      $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
187
+        $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
189 188
 
190 189
     $this->_lines[$this->_cl]["w"] += $w;
191 190
     $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height());
192 191
 
193
-  }
192
+    }
194 193
 
195
-  function remove_frames_from_line(Frame $frame) {
194
+    function remove_frames_from_line(Frame $frame) {
196 195
     // Search backwards through the lines for $frame
197 196
     $i = $this->_cl;
198 197
 
199 198
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
199
+        if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
201 200
         break;
202
-      $i--;
201
+        $i--;
203 202
     }
204 203
 
205 204
     if ( $j === false )
206
-      return;
205
+        return;
207 206
 
208 207
     // Remove $frame and all frames that follow
209 208
     while ($j < count($this->_lines[$i]["frames"])) {
210
-      $f = $this->_lines[$i]["frames"][$j];
211
-      unset($this->_lines[$i]["frames"][$j++]);
212
-      $this->_lines[$i]["w"] -= $f->get_margin_width();
209
+        $f = $this->_lines[$i]["frames"][$j];
210
+        unset($this->_lines[$i]["frames"][$j++]);
211
+        $this->_lines[$i]["w"] -= $f->get_margin_width();
213 212
     }
214 213
 
215 214
     // Recalculate the height of the line
216 215
     $h = 0;
217 216
     foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
217
+        $h = max( $h, $f->get_margin_height() );
219 218
 
220 219
     $this->_lines[$i]["h"] = $h;
221 220
 
222 221
     // Remove all lines that follow
223 222
     while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
223
+        unset($this->_lines[ $this->_cl-- ]);
225 224
 
226
-  }
225
+    }
227 226
 
228
-  function increase_line_width($w) {
227
+    function increase_line_width($w) {
229 228
     $this->_lines[ $this->_cl ]["w"] += $w;
230
-  }
229
+    }
231 230
 
232
-  function maximize_line_height($val) {
231
+    function maximize_line_height($val) {
233 232
     $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val);
234
-  }
233
+    }
235 234
 
236
-  function add_line() {
235
+    function add_line() {
237 236
 
238 237
 //     if ( $this->_lines[$this->_cl]["h"] == 0 ) //count($this->_lines[$i]["frames"]) == 0 ||
239 238
 //       return;
@@ -241,28 +240,28 @@  discard block
 block discarded – undo
241 240
     $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"];
242 241
 
243 242
     $this->_lines[ ++$this->_cl ] = array("frames" => array(),
244
-                                          "wc" => 0,
245
-                                          "y" => $y, "w" => 0, "h" => 0);
246
-  }
243
+                                            "wc" => 0,
244
+                                            "y" => $y, "w" => 0, "h" => 0);
245
+    }
247 246
 
248
-  //........................................................................
247
+    //........................................................................
249 248
 
250
-  function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) {
249
+    function reset_counter($id = self::DEFAULT_COUNTER, $value = 0) {
251 250
     $this->_counters[$id] = $value;
252
-  }
251
+    }
253 252
 
254
-  function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
253
+    function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255 254
     if ( !isset($this->_counters[$id]) )
256
-      $this->_counters[$id] = $increment;
255
+        $this->_counters[$id] = $increment;
257 256
     else
258
-      $this->_counters[$id] += $increment;
257
+        $this->_counters[$id] += $increment;
259 258
 
260
-  }
259
+    }
261 260
 
262
-  function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
261
+    function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 262
     $type = mb_strtolower($type);
264 263
     if ( !isset($this->_counters[$id]) )
265
-      $this->_counters[$id] = 0;
264
+        $this->_counters[$id] = 0;
266 265
 
267 266
     switch ($type) {
268 267
 
@@ -293,5 +292,5 @@  discard block
 block discarded – undo
293 292
     case "upper-greek":
294 293
       return chr($this->_counters[$id] + 912);
295 294
     }
296
-  }
295
+    }
297 296
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/frame_tree.cls.php 1 patch
Indentation   +114 added lines, -115 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_tree.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -52,118 +51,118 @@  discard block
 block discarded – undo
52 51
  */
53 52
 class Frame_Tree {
54 53
     
55
-  /**
56
-   * Tags to ignore while parsing the tree
57
-   *
58
-   * @var array
59
-   */
60
-  static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style",
61
-                                         "meta", "title", "colgroup",
62
-                                         "noembed", "noscript", "param", "#comment");  
63
-  /**
64
-   * The main DomDocument
65
-   *
66
-   * @see http://ca2.php.net/manual/en/ref.dom.php
67
-   * @var DomDocument
68
-   */
69
-  protected $_dom;
70
-
71
-  /**
72
-   * The root node of the FrameTree.
73
-   *
74
-   * @var Frame
75
-   */
76
-  protected $_root;
77
-
78
-  /**
79
-   * Subtrees of absolutely positioned elements
80
-   *
81
-   * @var array of Frames
82
-   */
83
-  protected $_absolute_frames;
84
-
85
-  /**
86
-   * A mapping of {@link Frame} objects to DomNode objects
87
-   *
88
-   * @var array
89
-   */
90
-  protected $_registry;
54
+    /**
55
+     * Tags to ignore while parsing the tree
56
+     *
57
+     * @var array
58
+     */
59
+    static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style",
60
+                                            "meta", "title", "colgroup",
61
+                                            "noembed", "noscript", "param", "#comment");  
62
+    /**
63
+     * The main DomDocument
64
+     *
65
+     * @see http://ca2.php.net/manual/en/ref.dom.php
66
+     * @var DomDocument
67
+     */
68
+    protected $_dom;
69
+
70
+    /**
71
+     * The root node of the FrameTree.
72
+     *
73
+     * @var Frame
74
+     */
75
+    protected $_root;
76
+
77
+    /**
78
+     * Subtrees of absolutely positioned elements
79
+     *
80
+     * @var array of Frames
81
+     */
82
+    protected $_absolute_frames;
83
+
84
+    /**
85
+     * A mapping of {@link Frame} objects to DomNode objects
86
+     *
87
+     * @var array
88
+     */
89
+    protected $_registry;
91 90
   
92 91
 
93
-  /**
94
-   * Class constructor
95
-   *
96
-   * @param DomDocument $dom the main DomDocument object representing the current html document
97
-   */
98
-  function __construct(DomDocument $dom) {
92
+    /**
93
+     * Class constructor
94
+     *
95
+     * @param DomDocument $dom the main DomDocument object representing the current html document
96
+     */
97
+    function __construct(DomDocument $dom) {
99 98
     $this->_dom = $dom;
100 99
     $this->_root = null;
101 100
     $this->_registry = array();
102
-  }
103
-
104
-  /**
105
-   * Returns the DomDocument object representing the curent html document
106
-   *
107
-   * @return DomDocument
108
-   */
109
-  function get_dom() { return $this->_dom; }
110
-
111
-  /**
112
-   * Returns the root frame of the tree
113
-   *
114
-   * @return Frame
115
-   */
116
-  function get_root() { return $this->_root; }
117
-
118
-  /**
119
-   * Returns a specific frame given its id
120
-   *
121
-   * @param string $id
122
-   * @return Frame
123
-   */
124
-  function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; }
125
-
126
-  /**
127
-   * Returns a post-order iterator for all frames in the tree
128
-   *
129
-   * @return FrameTreeList
130
-   */
131
-  function get_frames() { return new FrameTreeList($this->_root); }
101
+    }
102
+
103
+    /**
104
+     * Returns the DomDocument object representing the curent html document
105
+     *
106
+     * @return DomDocument
107
+     */
108
+    function get_dom() { return $this->_dom; }
109
+
110
+    /**
111
+     * Returns the root frame of the tree
112
+     *
113
+     * @return Frame
114
+     */
115
+    function get_root() { return $this->_root; }
116
+
117
+    /**
118
+     * Returns a specific frame given its id
119
+     *
120
+     * @param string $id
121
+     * @return Frame
122
+     */
123
+    function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; }
124
+
125
+    /**
126
+     * Returns a post-order iterator for all frames in the tree
127
+     *
128
+     * @return FrameTreeList
129
+     */
130
+    function get_frames() { return new FrameTreeList($this->_root); }
132 131
       
133
-  /**
134
-   * Builds the tree
135
-   */
136
-  function build_tree() {
132
+    /**
133
+     * Builds the tree
134
+     */
135
+    function build_tree() {
137 136
     $html = $this->_dom->getElementsByTagName("html")->item(0);
138 137
     if ( is_null($html) )
139
-      $html = $this->_dom->firstChild;
138
+        $html = $this->_dom->firstChild;
140 139
 
141 140
     if ( is_null($html) )
142
-      throw new DOMPDF_Exception("Requested HTML document contains no data.");
141
+        throw new DOMPDF_Exception("Requested HTML document contains no data.");
143 142
 
144 143
     $this->_root = $this->_build_tree_r($html);
145 144
 
146
-  }
147
-
148
-  /**
149
-   * Recursively adds {@link Frame} objects to the tree
150
-   *
151
-   * Recursively build a tree of Frame objects based on a dom tree.
152
-   * No layout information is calculated at this time, although the
153
-   * tree may be adjusted (i.e. nodes and frames for generated content
154
-   * and images may be created).
155
-   *
156
-   * @param DomNode $node the current DomNode being considered
157
-   * @return Frame
158
-   */
159
-  protected function _build_tree_r(DomNode $node) {
145
+    }
146
+
147
+    /**
148
+     * Recursively adds {@link Frame} objects to the tree
149
+     *
150
+     * Recursively build a tree of Frame objects based on a dom tree.
151
+     * No layout information is calculated at this time, although the
152
+     * tree may be adjusted (i.e. nodes and frames for generated content
153
+     * and images may be created).
154
+     *
155
+     * @param DomNode $node the current DomNode being considered
156
+     * @return Frame
157
+     */
158
+    protected function _build_tree_r(DomNode $node) {
160 159
     
161 160
     $frame = new Frame($node);
162 161
     $id = $frame->get_id();
163 162
     $this->_registry[ $id ] = $frame;
164 163
     
165 164
     if ( !$node->hasChildNodes() )
166
-      return $frame;
165
+        return $frame;
167 166
 
168 167
     // Fixes 'cannot access undefined property for object with
169 168
     // overloaded access', fix by Stefan radulian
@@ -173,55 +172,55 @@  discard block
 block discarded – undo
173 172
     // Store the children in an array so that the tree can be modified
174 173
     $children = array();
175 174
     for ($i = 0; $i < $node->childNodes->length; $i++)
176
-      $children[] = $node->childNodes->item($i);
175
+        $children[] = $node->childNodes->item($i);
177 176
 
178 177
     foreach ($children as $child) {
179
-      // Skip non-displaying nodes
180
-      if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) )  {
178
+        // Skip non-displaying nodes
179
+        if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) )  {
181 180
         if ( mb_strtolower($child->nodeName) !== "head" &&
182 181
              mb_strtolower($child->nodeName) !== "style" ) 
183
-          $child->parentNode->removeChild($child);
182
+            $child->parentNode->removeChild($child);
184 183
         continue;
185
-      }
184
+        }
186 185
 
187
-      // Skip empty text nodes
188
-      if ( $child->nodeName === "#text" && $child->nodeValue == "" ) {
186
+        // Skip empty text nodes
187
+        if ( $child->nodeName === "#text" && $child->nodeValue == "" ) {
189 188
         $child->parentNode->removeChild($child);
190 189
         continue;
191
-      }
190
+        }
192 191
 
193
-      // Skip empty image nodes
194
-      if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) {
192
+        // Skip empty image nodes
193
+        if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) {
195 194
         $child->parentNode->removeChild($child);
196 195
         continue;
197
-      }
196
+        }
198 197
 
199
-      // Add a container frame for images
200
-      if ( $child->nodeName === "img" ) {
198
+        // Add a container frame for images
199
+        if ( $child->nodeName === "img" ) {
201 200
         $img_node = $child->ownerDocument->createElement("img_inner");
202 201
      
203 202
         // Move attributes to inner node        
204 203
         foreach ( $child->attributes as $attr => $attr_node ) {
205
-          // Skip style, but move all other attributes
206
-          if ( $attr === "style" )
204
+            // Skip style, but move all other attributes
205
+            if ( $attr === "style" )
207 206
             continue;
208 207
        
209
-          $img_node->setAttribute($attr, $attr_node->value);
208
+            $img_node->setAttribute($attr, $attr_node->value);
210 209
         }
211 210
 
212 211
         foreach ( $child->attributes as $attr => $node ) {
213
-          if ( $attr === "style" )
212
+            if ( $attr === "style" )
214 213
             continue;
215
-          $child->removeAttribute($attr);
214
+            $child->removeAttribute($attr);
216 215
         }
217 216
 
218 217
         $child->appendChild($img_node);
219
-      }
218
+        }
220 219
       
221
-      $frame->append_child($this->_build_tree_r($child), false);
220
+        $frame->append_child($this->_build_tree_r($child), false);
222 221
 
223 222
     }
224 223
     
225 224
     return $frame;
226
-  }
225
+    }
227 226
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/canvas.cls.php 1 patch
Indentation   +185 added lines, -186 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: canvas.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -54,207 +53,207 @@  discard block
 block discarded – undo
54 53
  */
55 54
 interface Canvas {
56 55
 
57
-  /**
58
-   * Returns the current page number
59
-   *
60
-   * @return int
61
-   */
62
-  function get_page_number();
56
+    /**
57
+     * Returns the current page number
58
+     *
59
+     * @return int
60
+     */
61
+    function get_page_number();
63 62
 
64
-  /**
65
-   * Returns the total number of pages
66
-   *
67
-   * @return int
68
-   */
69
-  function get_page_count();
63
+    /**
64
+     * Returns the total number of pages
65
+     *
66
+     * @return int
67
+     */
68
+    function get_page_count();
70 69
 
71
-  /**
72
-   * Sets the total number of pages
73
-   *
74
-   * @param int $count
75
-   */
76
-  function set_page_count($count);
70
+    /**
71
+     * Sets the total number of pages
72
+     *
73
+     * @param int $count
74
+     */
75
+    function set_page_count($count);
77 76
 
78
-  /**
79
-   * Draws a line from x1,y1 to x2,y2
80
-   *
81
-   * See {@link Style::munge_colour()} for the format of the colour array.
82
-   * See {@link Cpdf::setLineStyle()} for a description of the format of the
83
-   * $style parameter (aka dash).
84
-   *
85
-   * @param float $x1
86
-   * @param float $y1
87
-   * @param float $x2
88
-   * @param float $y2
89
-   * @param array $color
90
-   * @param float $width
91
-   * @param array $style
92
-   */
93
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null);
77
+    /**
78
+     * Draws a line from x1,y1 to x2,y2
79
+     *
80
+     * See {@link Style::munge_colour()} for the format of the colour array.
81
+     * See {@link Cpdf::setLineStyle()} for a description of the format of the
82
+     * $style parameter (aka dash).
83
+     *
84
+     * @param float $x1
85
+     * @param float $y1
86
+     * @param float $x2
87
+     * @param float $y2
88
+     * @param array $color
89
+     * @param float $width
90
+     * @param array $style
91
+     */
92
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null);
94 93
 
95
-  /**
96
-   * Draws a rectangle at x1,y1 with width w and height h
97
-   *
98
-   * See {@link Style::munge_colour()} for the format of the colour array.
99
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
100
-   * parameter (aka dash)
101
-   *
102
-   * @param float $x1
103
-   * @param float $y1
104
-   * @param float $w
105
-   * @param float $h
106
-   * @param array $color
107
-   * @param float $width
108
-   * @param array $style
109
-   */   
110
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null);
94
+    /**
95
+     * Draws a rectangle at x1,y1 with width w and height h
96
+     *
97
+     * See {@link Style::munge_colour()} for the format of the colour array.
98
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
99
+     * parameter (aka dash)
100
+     *
101
+     * @param float $x1
102
+     * @param float $y1
103
+     * @param float $w
104
+     * @param float $h
105
+     * @param array $color
106
+     * @param float $width
107
+     * @param array $style
108
+     */   
109
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null);
111 110
 
112
-  /**
113
-   * Draws a filled rectangle at x1,y1 with width w and height h
114
-   *
115
-   * See {@link Style::munge_colour()} for the format of the colour array.
116
-   *
117
-   * @param float $x1
118
-   * @param float $y1
119
-   * @param float $w
120
-   * @param float $h
121
-   * @param array $color
122
-   */   
123
-  function filled_rectangle($x1, $y1, $w, $h, $color);
111
+    /**
112
+     * Draws a filled rectangle at x1,y1 with width w and height h
113
+     *
114
+     * See {@link Style::munge_colour()} for the format of the colour array.
115
+     *
116
+     * @param float $x1
117
+     * @param float $y1
118
+     * @param float $w
119
+     * @param float $h
120
+     * @param array $color
121
+     */   
122
+    function filled_rectangle($x1, $y1, $w, $h, $color);
124 123
 
125
-  /**
126
-   * Draws a polygon
127
-   *
128
-   * The polygon is formed by joining all the points stored in the $points
129
-   * array.  $points has the following structure:
130
-   * <code>
131
-   * array(0 => x1,
132
-   *       1 => y1,
133
-   *       2 => x2,
134
-   *       3 => y2,
135
-   *       ...
136
-   *       );
137
-   * </code>
138
-   *
139
-   * See {@link Style::munge_colour()} for the format of the colour array.
140
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
141
-   * parameter (aka dash)   
142
-   *
143
-   * @param array $points
144
-   * @param array $color
145
-   * @param float $width
146
-   * @param array $style
147
-   * @param bool  $fill  Fills the polygon if true
148
-   */
149
-  function polygon($points, $color, $width = null, $style = null, $fill = false);
124
+    /**
125
+     * Draws a polygon
126
+     *
127
+     * The polygon is formed by joining all the points stored in the $points
128
+     * array.  $points has the following structure:
129
+     * <code>
130
+     * array(0 => x1,
131
+     *       1 => y1,
132
+     *       2 => x2,
133
+     *       3 => y2,
134
+     *       ...
135
+     *       );
136
+     * </code>
137
+     *
138
+     * See {@link Style::munge_colour()} for the format of the colour array.
139
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
140
+     * parameter (aka dash)   
141
+     *
142
+     * @param array $points
143
+     * @param array $color
144
+     * @param float $width
145
+     * @param array $style
146
+     * @param bool  $fill  Fills the polygon if true
147
+     */
148
+    function polygon($points, $color, $width = null, $style = null, $fill = false);
150 149
 
151
-  /**
152
-   * Draws a circle at $x,$y with radius $r
153
-   *
154
-   * See {@link Style::munge_colour()} for the format of the colour array.
155
-   * See {@link Cpdf::setLineStyle()} for a description of the $style
156
-   * parameter (aka dash)
157
-   *
158
-   * @param float $x
159
-   * @param float $y
160
-   * @param float $r
161
-   * @param array $color
162
-   * @param float $width
163
-   * @param array $style
164
-   * @param bool $fill Fills the circle if true   
165
-   */   
166
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false);
150
+    /**
151
+     * Draws a circle at $x,$y with radius $r
152
+     *
153
+     * See {@link Style::munge_colour()} for the format of the colour array.
154
+     * See {@link Cpdf::setLineStyle()} for a description of the $style
155
+     * parameter (aka dash)
156
+     *
157
+     * @param float $x
158
+     * @param float $y
159
+     * @param float $r
160
+     * @param array $color
161
+     * @param float $width
162
+     * @param array $style
163
+     * @param bool $fill Fills the circle if true   
164
+     */   
165
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false);
167 166
 
168
-  /**
169
-   * Add an image to the pdf.
170
-   *
171
-   * The image is placed at the specified x and y coordinates with the
172
-   * given width and height.
173
-   *
174
-   * @param string $img_url the path to the image
175
-   * @param string $img_type the type (e.g. extension) of the image
176
-   * @param float $x x position
177
-   * @param float $y y position
178
-   * @param int $w width (in pixels)
179
-   * @param int $h height (in pixels)
180
-   */
181
-  function image($img_url, $img_type, $x, $y, $w, $h);
167
+    /**
168
+     * Add an image to the pdf.
169
+     *
170
+     * The image is placed at the specified x and y coordinates with the
171
+     * given width and height.
172
+     *
173
+     * @param string $img_url the path to the image
174
+     * @param string $img_type the type (e.g. extension) of the image
175
+     * @param float $x x position
176
+     * @param float $y y position
177
+     * @param int $w width (in pixels)
178
+     * @param int $h height (in pixels)
179
+     */
180
+    function image($img_url, $img_type, $x, $y, $w, $h);
182 181
 
183
-  /**
184
-   * Writes text at the specified x and y coordinates
185
-   *
186
-   * See {@link Style::munge_colour()} for the format of the colour array.
187
-   *
188
-   * @param float $x
189
-   * @param float $y
190
-   * @param string $text the text to write
191
-   * @param string $font the font file to use
192
-   * @param float $size the font size, in points
193
-   * @param array $color
194
-   * @param float $adjust word spacing adjustment
195
-   */
196
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0);
182
+    /**
183
+     * Writes text at the specified x and y coordinates
184
+     *
185
+     * See {@link Style::munge_colour()} for the format of the colour array.
186
+     *
187
+     * @param float $x
188
+     * @param float $y
189
+     * @param string $text the text to write
190
+     * @param string $font the font file to use
191
+     * @param float $size the font size, in points
192
+     * @param array $color
193
+     * @param float $adjust word spacing adjustment
194
+     */
195
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0);
197 196
 
198
-  /**
199
-   * Add a named destination (similar to <a name="foo">...</a> in html)
200
-   *
201
-   * @param string $anchorname The name of the named destination
202
-   */
203
-  function add_named_dest($anchorname);
197
+    /**
198
+     * Add a named destination (similar to <a name="foo">...</a> in html)
199
+     *
200
+     * @param string $anchorname The name of the named destination
201
+     */
202
+    function add_named_dest($anchorname);
204 203
 
205
-  /**
206
-   * Add a link to the pdf
207
-   *
208
-   * @param string $url The url to link to
209
-   * @param float  $x   The x position of the link
210
-   * @param float  $y   The y position of the link
211
-   * @param float  $width   The width of the link
212
-   * @param float  $height   The height of the link
213
-   */
214
-  function add_link($url, $x, $y, $width, $height);
204
+    /**
205
+     * Add a link to the pdf
206
+     *
207
+     * @param string $url The url to link to
208
+     * @param float  $x   The x position of the link
209
+     * @param float  $y   The y position of the link
210
+     * @param float  $width   The width of the link
211
+     * @param float  $height   The height of the link
212
+     */
213
+    function add_link($url, $x, $y, $width, $height);
215 214
   
216
-  /**
217
-   * Calculates text size, in points
218
-   *
219
-   * @param string $text the text to be sized
220
-   * @param string $font the desired font
221
-   * @param float  $size the desired font size
222
-   * @param float  $spacing word spacing, if any
223
-   * @return float
224
-   */
225
-  function get_text_width($text, $font, $size, $spacing = 0);
215
+    /**
216
+     * Calculates text size, in points
217
+     *
218
+     * @param string $text the text to be sized
219
+     * @param string $font the desired font
220
+     * @param float  $size the desired font size
221
+     * @param float  $spacing word spacing, if any
222
+     * @return float
223
+     */
224
+    function get_text_width($text, $font, $size, $spacing = 0);
226 225
 
227
-  /**
228
-   * Calculates font height, in points
229
-   *
230
-   * @param string $font
231
-   * @param float $size
232
-   * @return float
233
-   */
234
-  function get_font_height($font, $size);
226
+    /**
227
+     * Calculates font height, in points
228
+     *
229
+     * @param string $font
230
+     * @param float $size
231
+     * @return float
232
+     */
233
+    function get_font_height($font, $size);
235 234
 
236 235
   
237
-  /**
238
-   * Starts a new page
239
-   *
240
-   * Subsequent drawing operations will appear on the new page.
241
-   */
242
-  function new_page();
236
+    /**
237
+     * Starts a new page
238
+     *
239
+     * Subsequent drawing operations will appear on the new page.
240
+     */
241
+    function new_page();
243 242
 
244
-  /**
245
-   * Streams the PDF directly to the browser
246
-   *
247
-   * @param string $filename the name of the PDF file
248
-   * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
249
-   */
250
-  function stream($filename, $options = null);
243
+    /**
244
+     * Streams the PDF directly to the browser
245
+     *
246
+     * @param string $filename the name of the PDF file
247
+     * @param array  $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0
248
+     */
249
+    function stream($filename, $options = null);
251 250
 
252
-  /**
253
-   * Returns the PDF as a string
254
-   *
255
-   * @param array  $options associative array: 'compress' => 1 or 0
256
-   * @return string
257
-   */
258
-  function output($options = null);
251
+    /**
252
+     * Returns the PDF as a string
253
+     *
254
+     * @param array  $options associative array: 'compress' => 1 or 0
255
+     * @return string
256
+     */
257
+    function output($options = null);
259 258
   
260 259
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/page_cache.cls.php 1 patch
Indentation   +35 added lines, -36 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: page_cache.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -50,59 +49,59 @@  discard block
 block discarded – undo
50 49
  */
51 50
 class Page_Cache {
52 51
 
53
-  const DB_USER = "dompdf_page_cache";
54
-  const DB_PASS = "some meaningful password";
55
-  const DB_NAME = "dompdf_page_cache";
52
+    const DB_USER = "dompdf_page_cache";
53
+    const DB_PASS = "some meaningful password";
54
+    const DB_NAME = "dompdf_page_cache";
56 55
   
57
-  static private $__connection = null;
56
+    static private $__connection = null;
58 57
   
59
-  function init() {
58
+    function init() {
60 59
     if ( is_null(self::$__connection) ) {
61
-      $con_str = "host=" . DB_HOST .
60
+        $con_str = "host=" . DB_HOST .
62 61
         " dbname=" . self::DB_NAME .
63 62
         " user=" . self::DB_USER .
64 63
         " password=" . self::DB_PASS;
65 64
       
66
-      if ( !self::$__connection = pg_connect($con_str) )
65
+        if ( !self::$__connection = pg_connect($con_str) )
67 66
         throw new Exception("Database connection failed.");
68 67
     }
69
-  }
68
+    }
70 69
   
71
-  function __construct() { throw new Exception("Can not create instance of Page_Class.  Class is static."); }
70
+    function __construct() { throw new Exception("Can not create instance of Page_Class.  Class is static."); }
72 71
 
73
-  private static function __query($sql) {
72
+    private static function __query($sql) {
74 73
     if ( !($res = pg_query(self::$__connection, $sql)) )
75
-      throw new Exception(pg_last_error(self::$__connection));
74
+        throw new Exception(pg_last_error(self::$__connection));
76 75
     return $res;
77
-  }
76
+    }
78 77
   
79
-  static function store_page($id, $page_num, $data) {
78
+    static function store_page($id, $page_num, $data) {
80 79
     $where = "WHERE id='" . pg_escape_string($id) . "' AND ".
81
-      "page_num=". pg_escape_string($page_num);
80
+        "page_num=". pg_escape_string($page_num);
82 81
 
83 82
     $res = self::__query("SELECT timestamp FROM page_cache ". $where);
84 83
 
85 84
     $row = pg_fetch_assoc($res);
86 85
     
87 86
     if ( $row ) 
88
-      self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where);
87
+        self::__query("UPDATE page_cache SET data='" . pg_escape_string($data) . "' " . $where);
89 88
     else 
90
-      self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ".
91
-                     pg_escape_string($page_num) . ", ".
92
-                     "'". pg_escape_string($data) . "')");
89
+        self::__query("INSERT INTO page_cache (id, page_num, data) VALUES ('" . pg_escape_string($id) . "', ".
90
+                        pg_escape_string($page_num) . ", ".
91
+                        "'". pg_escape_string($data) . "')");
93 92
 
94
-  }
93
+    }
95 94
 
96
-  static function store_fonts($id, $fonts) {
95
+    static function store_fonts($id, $fonts) {
97 96
     self::__query("BEGIN");
98 97
     // Update the font information
99 98
     self::__query("DELETE FROM page_fonts WHERE id='" . pg_escape_string($id) . "'");
100 99
 
101 100
     foreach (array_keys($fonts) as $font)
102
-      self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" .
101
+        self::__query("INSERT INTO page_fonts (id, font_name) VALUES ('" .
103 102
                     pg_escape_string($id) . "', '" . pg_escape_string($font) . "')");
104 103
     self::__query("COMMIT");
105
-  }
104
+    }
106 105
   
107 106
 //   static function retrieve_page($id, $page_num) {
108 107
 
@@ -115,45 +114,45 @@  discard block
 block discarded – undo
115 114
     
116 115
 //   }
117 116
 
118
-  static function get_page_timestamp($id, $page_num) {
117
+    static function get_page_timestamp($id, $page_num) {
119 118
     $res = self::__query("SELECT timestamp FROM page_cache WHERE id='" . pg_escape_string($id) . "' AND ".
120
-                          "page_num=". pg_escape_string($page_num));
119
+                            "page_num=". pg_escape_string($page_num));
121 120
 
122 121
     $row = pg_fetch_assoc($res);
123 122
 
124 123
     return $row["timestamp"];
125 124
     
126
-  }
125
+    }
127 126
 
128
-  // Adds the cached document referenced by $id to the provided pdf
129
-  static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) {
127
+    // Adds the cached document referenced by $id to the provided pdf
128
+    static function insert_cached_document(CPDF_Adapter $pdf, $id, $new_page = true) {
130 129
     $res = self::__query("SELECT font_name FROM page_fonts WHERE id='" . pg_escape_string($id) . "'");
131 130
 
132 131
     // Ensure that the fonts needed by the cached document are loaded into
133 132
     // the pdf
134 133
     while ($row = pg_fetch_assoc($res)) 
135
-      $pdf->get_cpdf()->selectFont($row["font_name"]);
134
+        $pdf->get_cpdf()->selectFont($row["font_name"]);
136 135
     
137 136
     $res = self::__query("SELECT data FROM page_cache WHERE id='" . pg_escape_string($id) . "'");
138 137
 
139 138
     if ( $new_page )
140
-      $pdf->new_page();
139
+        $pdf->new_page();
141 140
 
142 141
     $first = true;
143 142
     while ($row = pg_fetch_assoc($res)) {
144 143
 
145
-      if ( !$first ) 
144
+        if ( !$first ) 
146 145
         $pdf->new_page();
147
-      else 
146
+        else 
148 147
         $first = false;        
149 148
       
150
-      $page = $pdf->reopen_serialized_object($row["data"]);
151
-      //$pdf->close_object();
152
-      $pdf->add_object($page, "add");
149
+        $page = $pdf->reopen_serialized_object($row["data"]);
150
+        //$pdf->close_object();
151
+        $pdf->add_object($page, "add");
153 152
 
154 153
     }
155 154
       
156
-  }
155
+    }
157 156
 }
158 157
 
159 158
 Page_Cache::init();
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/pdflib_adapter.cls.php 1 patch
Indentation   +486 added lines, -486 removed lines patch added patch discarded remove patch
@@ -61,170 +61,170 @@  discard block
 block discarded – undo
61 61
  */
62 62
 class PDFLib_Adapter implements Canvas {
63 63
 
64
-  /**
65
-   * Dimensions of paper sizes in points
66
-   *
67
-   * @var array;
68
-   */
69
-  static public $PAPER_SIZES = array(); // Set to
64
+    /**
65
+     * Dimensions of paper sizes in points
66
+     *
67
+     * @var array;
68
+     */
69
+    static public $PAPER_SIZES = array(); // Set to
70 70
                                         // CPDF_Adapter::$PAPER_SIZES below.
71 71
 
72
-  /**
73
-   * Fudge factor to adjust reported font heights
74
-   *
75
-   * CPDF reports larger font heights than PDFLib.  This factor
76
-   * adjusts the height reported by get_font_height().
77
-   *
78
-   * @var float
79
-   */
80
-  const FONT_HEIGHT_SCALE = 1.2;
81
-
82
-  /**
83
-   * Whether to create PDFs in memory or on disk
84
-   *
85
-   * @var bool
86
-   */
87
-  static $IN_MEMORY = true;
88
-
89
-  /**
90
-   * Instance of PDFLib class
91
-   *
92
-   * @var PDFlib
93
-   */
94
-  private $_pdf;
95
-
96
-  /**
97
-   * Name of temporary file used for PDFs created on disk
98
-   *
99
-   * @var string
100
-   */
101
-  private $_file;
102
-
103
-  /**
104
-   * PDF width, in points
105
-   *
106
-   * @var float
107
-   */
108
-  private $_width;
109
-
110
-  /**
111
-   * PDF height, in points
112
-   *
113
-   * @var height
114
-   */
115
-  private $_height;
116
-
117
-  /**
118
-   * Last fill colour used
119
-   *
120
-   * @var array
121
-   */
122
-  private $_last_fill_color;
123
-
124
-  /**
125
-   * Last stroke colour used
126
-   *
127
-   * @var array
128
-   */
129
-  private $_last_stroke_color;
130
-
131
-  /**
132
-   * Cache of image handles
133
-   *
134
-   * @var array
135
-   */
136
-  private $_imgs;
137
-
138
-  /**
139
-   * Cache of font handles
140
-   *
141
-   * @var array
142
-   */
143
-  private $_fonts;
144
-
145
-  /**
146
-   * List of objects (templates) to add to multiple pages
147
-   *
148
-   * @var array
149
-   */
150
-  private $_objs;
151
-
152
-  /**
153
-   * Current page number
154
-   *
155
-   * @var int
156
-   */
157
-  private $_page_number;
158
-
159
-  /**
160
-   * Total number of pages
161
-   *
162
-   * @var int
163
-   */
164
-  private $_page_count;
165
-
166
-  /**
167
-   * Text to display on every page
168
-   *
169
-   * @var array
170
-   */
171
-  private $_page_text;
172
-
173
-  /**
174
-   * Array of pages for accesing after rendering is initially complete
175
-   *
176
-   * @var array
177
-   */
178
-  private $_pages;
179
-
180
-  /**
181
-   * Class constructor
182
-   *
183
-   * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
-   *                     an array(xmin,ymin,xmax,ymax)
185
-   * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
-   */
187
-  function __construct($paper = "letter", $orientation = "portrait") {
72
+    /**
73
+     * Fudge factor to adjust reported font heights
74
+     *
75
+     * CPDF reports larger font heights than PDFLib.  This factor
76
+     * adjusts the height reported by get_font_height().
77
+     *
78
+     * @var float
79
+     */
80
+    const FONT_HEIGHT_SCALE = 1.2;
81
+
82
+    /**
83
+     * Whether to create PDFs in memory or on disk
84
+     *
85
+     * @var bool
86
+     */
87
+    static $IN_MEMORY = true;
88
+
89
+    /**
90
+     * Instance of PDFLib class
91
+     *
92
+     * @var PDFlib
93
+     */
94
+    private $_pdf;
95
+
96
+    /**
97
+     * Name of temporary file used for PDFs created on disk
98
+     *
99
+     * @var string
100
+     */
101
+    private $_file;
102
+
103
+    /**
104
+     * PDF width, in points
105
+     *
106
+     * @var float
107
+     */
108
+    private $_width;
109
+
110
+    /**
111
+     * PDF height, in points
112
+     *
113
+     * @var height
114
+     */
115
+    private $_height;
116
+
117
+    /**
118
+     * Last fill colour used
119
+     *
120
+     * @var array
121
+     */
122
+    private $_last_fill_color;
123
+
124
+    /**
125
+     * Last stroke colour used
126
+     *
127
+     * @var array
128
+     */
129
+    private $_last_stroke_color;
130
+
131
+    /**
132
+     * Cache of image handles
133
+     *
134
+     * @var array
135
+     */
136
+    private $_imgs;
137
+
138
+    /**
139
+     * Cache of font handles
140
+     *
141
+     * @var array
142
+     */
143
+    private $_fonts;
144
+
145
+    /**
146
+     * List of objects (templates) to add to multiple pages
147
+     *
148
+     * @var array
149
+     */
150
+    private $_objs;
151
+
152
+    /**
153
+     * Current page number
154
+     *
155
+     * @var int
156
+     */
157
+    private $_page_number;
158
+
159
+    /**
160
+     * Total number of pages
161
+     *
162
+     * @var int
163
+     */
164
+    private $_page_count;
165
+
166
+    /**
167
+     * Text to display on every page
168
+     *
169
+     * @var array
170
+     */
171
+    private $_page_text;
172
+
173
+    /**
174
+     * Array of pages for accesing after rendering is initially complete
175
+     *
176
+     * @var array
177
+     */
178
+    private $_pages;
179
+
180
+    /**
181
+     * Class constructor
182
+     *
183
+     * @param mixed $paper The size of paper to use either a string (see {@link CPDF_Adapter::$PAPER_SIZES}) or
184
+     *                     an array(xmin,ymin,xmax,ymax)
185
+     * @param string $orientation The orientation of the document (either 'landscape' or 'portrait')
186
+     */
187
+    function __construct($paper = "letter", $orientation = "portrait") {
188 188
     if ( is_array($paper) )
189
-      $size = $paper;
189
+        $size = $paper;
190 190
     else if ( isset(self::$PAPER_SIZES[mb_strtolower($paper)]) )
191
-      $size = self::$PAPER_SIZES[mb_strtolower($paper)];
191
+        $size = self::$PAPER_SIZES[mb_strtolower($paper)];
192 192
     else
193
-      $size = self::$PAPER_SIZES["letter"];
193
+        $size = self::$PAPER_SIZES["letter"];
194 194
 
195 195
     if ( mb_strtolower($orientation) === "landscape" ) {
196
-      $a = $size[3];
197
-      $size[3] = $size[2];
198
-      $size[2] = $a;
196
+        $a = $size[3];
197
+        $size[3] = $size[2];
198
+        $size[2] = $a;
199 199
     }
200 200
     $this->_width = $size[2] - $size[0];
201 201
     $this->_height= $size[3] - $size[1];
202 202
 
203 203
     $this->_pdf = new PDFLib();
204 204
 
205
-	if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
-      $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
205
+    if ( defined("DOMPDF_PDFLIB_LICENSE") )
206
+        $this->_pdf->set_parameter( "license", DOMPDF_PDFLIB_LICENSE);
207 207
 
208
-	$this->_pdf->set_parameter("textformat", "utf8");
208
+    $this->_pdf->set_parameter("textformat", "utf8");
209 209
     $this->_pdf->set_parameter("fontwarning", "false");
210 210
 
211 211
     $this->_pdf->set_info("Creator", "DOMPDF Converter");
212 212
 
213 213
     // Silence pedantic warnings about missing TZ settings
214 214
     if ( function_exists("date_default_timezone_get") ) {
215
-      $tz = @date_default_timezone_get();
216
-      date_default_timezone_set("UTC");
217
-      $this->_pdf->set_info("Date", date("Y-m-d"));
218
-      date_default_timezone_set($tz);
215
+        $tz = @date_default_timezone_get();
216
+        date_default_timezone_set("UTC");
217
+        $this->_pdf->set_info("Date", date("Y-m-d"));
218
+        date_default_timezone_set($tz);
219 219
     } else {
220
-      $this->_pdf->set_info("Date", date("Y-m-d"));
220
+        $this->_pdf->set_info("Date", date("Y-m-d"));
221 221
     }
222 222
 
223 223
     if ( self::$IN_MEMORY )
224
-      $this->_pdf->begin_document("","");
224
+        $this->_pdf->begin_document("","");
225 225
     else {
226
-      $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
-      $this->_pdf->begin_document($this->_file,"");
226
+        $this->_file = tempnam(DOMPDF_TEMP_DIR, "libdompdf_pdf_").'.pdf';
227
+        $this->_pdf->begin_document($this->_file,"");
228 228
     }
229 229
 
230 230
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
@@ -239,155 +239,155 @@  discard block
 block discarded – undo
239 239
     // Set up font paths
240 240
     $families = Font_Metrics::get_font_families();
241 241
     foreach ($families as $family => $files) {
242
-      foreach ($files as $style => $file) {
242
+        foreach ($files as $style => $file) {
243 243
         $face = basename($file);
244 244
 
245 245
         // Prefer ttfs to afms
246 246
         if ( file_exists($file.".ttf") ) {
247
-          $outline = "$file.ttf";
248
-          $afm = null;
247
+            $outline = "$file.ttf";
248
+            $afm = null;
249 249
 
250 250
         } else if ( file_exists($file .".TTF") ) {
251
-          $outline = "$file.TTF";
252
-          $afm = null;
251
+            $outline = "$file.TTF";
252
+            $afm = null;
253 253
 
254 254
         } else if ( file_exists($file . ".pfb") ) {
255
-          $outline = "$file.pfb";
255
+            $outline = "$file.pfb";
256 256
 
257
-          if ( file_exists($file . ".afm") )
257
+            if ( file_exists($file . ".afm") )
258 258
             $afm = "$file.afm";
259 259
 
260 260
         } else if ( file_exists($file . ".PFB") ) {
261
-          $outline = "$file.PFB";
262
-          if ( file_exists($file . ".AFM") )
261
+            $outline = "$file.PFB";
262
+            if ( file_exists($file . ".AFM") )
263 263
             $afm = "$file.AFM";
264 264
         } else
265
-          continue;
265
+            continue;
266 266
 
267 267
         $this->_pdf->set_parameter("FontOutline", "\{$face\}=\{$outline\}");
268 268
         if ( !is_null($afm) )
269
-          $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
-      }
269
+            $this->_pdf->set_parameter("FontAFM", "\{$face\}=\{$afm\}");
270
+        }
271
+    }
271 272
     }
272
-  }
273 273
 
274
-  /**
275
-   * Close the pdf
276
-   */
277
-  protected function _close() {
274
+    /**
275
+     * Close the pdf
276
+     */
277
+    protected function _close() {
278 278
     $this->_place_objects();
279 279
 
280 280
     // Close all pages
281 281
     $this->_pdf->suspend_page("");
282 282
     for ($p = 1; $p <= $this->_page_count; $p++) {
283
-      $this->_pdf->resume_page("pagenumber=$p");
284
-      $this->_pdf->end_page_ext("");
283
+        $this->_pdf->resume_page("pagenumber=$p");
284
+        $this->_pdf->end_page_ext("");
285 285
     }
286 286
 
287 287
     $this->_pdf->end_document("");
288
-  }
289
-
290
-
291
-  /**
292
-   * Returns the PDFLib instance
293
-   *
294
-   * @return PDFLib
295
-   */
296
-  function get_pdflib() { return $this->_pdf; }
297
-
298
-  /**
299
-   * Add meta information to the PDF
300
-   *
301
-   * @param string $label  label of the value (Creator, Producter, etc.)
302
-   * @param string $value  the text to set
303
-   */
304
-  function add_info($label, $value) {
288
+    }
289
+
290
+
291
+    /**
292
+     * Returns the PDFLib instance
293
+     *
294
+     * @return PDFLib
295
+     */
296
+    function get_pdflib() { return $this->_pdf; }
297
+
298
+    /**
299
+     * Add meta information to the PDF
300
+     *
301
+     * @param string $label  label of the value (Creator, Producter, etc.)
302
+     * @param string $value  the text to set
303
+     */
304
+    function add_info($label, $value) {
305 305
     $this->_pdf->set_info($label, $value);
306
-  }
306
+    }
307 307
   
308
-  /**
309
-   * Opens a new 'object' (template in PDFLib-speak)
310
-   *
311
-   * While an object is open, all drawing actions are recorded to the
312
-   * object instead of being drawn on the current page.  Objects can
313
-   * be added later to a specific page or to several pages.
314
-   *
315
-   * The return value is an integer ID for the new object.
316
-   *
317
-   * @see PDFLib_Adapter::close_object()
318
-   * @see PDFLib_Adapter::add_object()
319
-   *
320
-   * @return int
321
-   */
322
-  function open_object() {
308
+    /**
309
+     * Opens a new 'object' (template in PDFLib-speak)
310
+     *
311
+     * While an object is open, all drawing actions are recorded to the
312
+     * object instead of being drawn on the current page.  Objects can
313
+     * be added later to a specific page or to several pages.
314
+     *
315
+     * The return value is an integer ID for the new object.
316
+     *
317
+     * @see PDFLib_Adapter::close_object()
318
+     * @see PDFLib_Adapter::add_object()
319
+     *
320
+     * @return int
321
+     */
322
+    function open_object() {
323 323
     $this->_pdf->suspend_page("");
324 324
     $ret = $this->_pdf->begin_template($this->_width, $this->_height);
325 325
     $this->_pdf->save();
326 326
     $this->_objs[$ret] = array("start_page" => $this->_page_number);
327 327
     return $ret;
328
-  }
329
-
330
-  /**
331
-   * Reopen an existing object (NOT IMPLEMENTED)
332
-   *
333
-   * PDFLib does not seem to support reopening templates.
334
-   *
335
-   * @param int $object the ID of a previously opened object
336
-   */
337
-  function reopen_object($object) {
328
+    }
329
+
330
+    /**
331
+     * Reopen an existing object (NOT IMPLEMENTED)
332
+     *
333
+     * PDFLib does not seem to support reopening templates.
334
+     *
335
+     * @param int $object the ID of a previously opened object
336
+     */
337
+    function reopen_object($object) {
338 338
     throw new DOMPDF_Exception("PDFLib does not support reopening objects.");
339
-  }
340
-
341
-  /**
342
-   * Close the current template
343
-   *
344
-   * @see PDFLib_Adapter::open_object()
345
-   */
346
-  function close_object() {
339
+    }
340
+
341
+    /**
342
+     * Close the current template
343
+     *
344
+     * @see PDFLib_Adapter::open_object()
345
+     */
346
+    function close_object() {
347 347
     $this->_pdf->restore();
348 348
     $this->_pdf->end_template();
349 349
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
350
-  }
351
-
352
-  /**
353
-   * Adds the specified object to the document
354
-   *
355
-   * $where can be one of:
356
-   * - 'add' add to current page only
357
-   * - 'all' add to every page from the current one onwards
358
-   * - 'odd' add to all odd numbered pages from now on
359
-   * - 'even' add to all even numbered pages from now on
360
-   * - 'next' add the object to the next page only
361
-   * - 'nextodd' add to all odd numbered pages from the next one
362
-   * - 'nexteven' add to all even numbered pages from the next one
363
-   *
364
-   * @param int $object the object handle returned by open_object()
365
-   * @param string $where
366
-   */
367
-  function add_object($object, $where = 'all') {
350
+    }
351
+
352
+    /**
353
+     * Adds the specified object to the document
354
+     *
355
+     * $where can be one of:
356
+     * - 'add' add to current page only
357
+     * - 'all' add to every page from the current one onwards
358
+     * - 'odd' add to all odd numbered pages from now on
359
+     * - 'even' add to all even numbered pages from now on
360
+     * - 'next' add the object to the next page only
361
+     * - 'nextodd' add to all odd numbered pages from the next one
362
+     * - 'nexteven' add to all even numbered pages from the next one
363
+     *
364
+     * @param int $object the object handle returned by open_object()
365
+     * @param string $where
366
+     */
367
+    function add_object($object, $where = 'all') {
368 368
 
369 369
     if ( mb_strpos($where, "next") !== false ) {
370
-      $this->_objs[$object]["start_page"]++;
371
-      $where = str_replace("next", "", $where);
372
-      if ( $where == "" )
370
+        $this->_objs[$object]["start_page"]++;
371
+        $where = str_replace("next", "", $where);
372
+        if ( $where == "" )
373 373
         $where = "add";
374 374
     }
375 375
 
376 376
     $this->_objs[$object]["where"] = $where;
377
-  }
378
-
379
-  /**
380
-   * Stops the specified template from appearing in the document.
381
-   *
382
-   * The object will stop being displayed on the page following the
383
-   * current one.
384
-   *
385
-   * @param int $object
386
-   */
387
-  function stop_object($object) {
377
+    }
378
+
379
+    /**
380
+     * Stops the specified template from appearing in the document.
381
+     *
382
+     * The object will stop being displayed on the page following the
383
+     * current one.
384
+     *
385
+     * @param int $object
386
+     */
387
+    function stop_object($object) {
388 388
 
389 389
     if ( !isset($this->_objs[$object]) )
390
-      return;
390
+        return;
391 391
 
392 392
     $start = $this->_objs[$object]["start_page"];
393 393
     $where = $this->_objs[$object]["where"];
@@ -397,74 +397,74 @@  discard block
 block discarded – undo
397 397
          (($this->_page_number % 2 == 0 && $where === "even") ||
398 398
           ($this->_page_number % 2 == 1 && $where === "odd") ||
399 399
           ($where === "all")) )
400
-      $this->_pdf->fit_image($object,0,0,"");
400
+        $this->_pdf->fit_image($object,0,0,"");
401 401
 
402 402
     unset($this->_objs[$object]);
403
-  }
403
+    }
404 404
 
405
-  /**
406
-   * Add all active objects to the current page
407
-   */
408
-  protected function _place_objects() {
405
+    /**
406
+     * Add all active objects to the current page
407
+     */
408
+    protected function _place_objects() {
409 409
 
410 410
     foreach ( $this->_objs as $obj => $props ) {
411
-      $start = $props["start_page"];
412
-      $where = $props["where"];
411
+        $start = $props["start_page"];
412
+        $where = $props["where"];
413 413
 
414
-      // Place the object on this page if required
415
-      if ( $this->_page_number >= $start &&
414
+        // Place the object on this page if required
415
+        if ( $this->_page_number >= $start &&
416 416
            (($this->_page_number % 2 == 0 && $where === "even") ||
417 417
             ($this->_page_number % 2 == 1 && $where === "odd") ||
418 418
             ($where === "all")) ) {
419 419
         $this->_pdf->fit_image($obj,0,0,"");
420
-      }
420
+        }
421 421
     }
422 422
 
423
-  }
423
+    }
424 424
 
425
-  function get_width() { return $this->_width; }
425
+    function get_width() { return $this->_width; }
426 426
 
427
-  function get_height() { return $this->_height; }
427
+    function get_height() { return $this->_height; }
428 428
 
429
-  function get_page_number() { return $this->_page_number; }
429
+    function get_page_number() { return $this->_page_number; }
430 430
 
431
-  function get_page_count() { return $this->_page_count; }
431
+    function get_page_count() { return $this->_page_count; }
432 432
 
433
-  function set_page_number($num) { $this->_page_number = (int)$num; }
433
+    function set_page_number($num) { $this->_page_number = (int)$num; }
434 434
 
435
-  function set_page_count($count) { $this->_page_count = (int)$count; }
435
+    function set_page_count($count) { $this->_page_count = (int)$count; }
436 436
 
437 437
 
438
-  /**
439
-   * Sets the line style
440
-   *
441
-   * @param float width
442
-   * @param string corner
443
-   * @param string join
444
-   * @param array dash
445
-   */
446
-  protected function _set_line_style($width, $cap, $join, $dash) {
438
+    /**
439
+     * Sets the line style
440
+     *
441
+     * @param float width
442
+     * @param string corner
443
+     * @param string join
444
+     * @param array dash
445
+     */
446
+    protected function _set_line_style($width, $cap, $join, $dash) {
447 447
 
448 448
     if ( count($dash) == 1 )
449
-      $dash[] = $dash[0];
449
+        $dash[] = $dash[0];
450 450
 
451 451
     if ( count($dash) > 1 )
452
-      $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
452
+        $this->_pdf->setdashpattern("dasharray={" . join(" ", $dash) . "}");
453 453
     else
454
-      $this->_pdf->setdash(0,0);
454
+        $this->_pdf->setdash(0,0);
455 455
 
456 456
     switch ( $join ) {
457 457
     case "miter":
458 458
       $this->_pdf->setlinejoin(0);
459
-      break;
459
+        break;
460 460
 
461 461
     case "round":
462 462
       $this->_pdf->setlinejoin(1);
463
-      break;
463
+        break;
464 464
 
465 465
     case "bevel":
466 466
       $this->_pdf->setlinejoin(2);
467
-      break;
467
+        break;
468 468
 
469 469
     default:
470 470
       break;
@@ -473,15 +473,15 @@  discard block
 block discarded – undo
473 473
     switch ( $cap ) {
474 474
     case "butt":
475 475
       $this->_pdf->setlinecap(0);
476
-      break;
476
+        break;
477 477
 
478 478
     case "round":
479 479
       $this->_pdf->setlinecap(1);
480
-      break;
480
+        break;
481 481
 
482 482
     case "square":
483 483
       $this->_pdf->setlinecap(2);
484
-      break;
484
+        break;
485 485
 
486 486
     default:
487 487
       break;
@@ -489,69 +489,69 @@  discard block
 block discarded – undo
489 489
 
490 490
     $this->_pdf->setlinewidth($width);
491 491
 
492
-  }
492
+    }
493 493
 
494
-  /**
495
-   * Sets the line color
496
-   *
497
-   * @param array $color array(r,g,b)
498
-   */
499
-  protected function _set_stroke_color($color) {
494
+    /**
495
+     * Sets the line color
496
+     *
497
+     * @param array $color array(r,g,b)
498
+     */
499
+    protected function _set_stroke_color($color) {
500 500
     if($this->_last_stroke_color == $color)
501
-    	return;
501
+        return;
502 502
 
503 503
     $this->_last_stroke_color = $color;
504 504
 
505 505
     list($r,$g,$b) = $color;
506 506
     $this->_pdf->setcolor("stroke", "rgb", $r, $g, $b, 0);
507
-  }
508
-
509
-  /**
510
-   * Sets the fill color
511
-   *
512
-   * @param array $color array(r,g,b)
513
-   */
514
-  protected function _set_fill_color($color) {
507
+    }
508
+
509
+    /**
510
+     * Sets the fill color
511
+     *
512
+     * @param array $color array(r,g,b)
513
+     */
514
+    protected function _set_fill_color($color) {
515 515
     if($this->_last_fill_color == $color)
516
-    	return;
516
+        return;
517 517
 
518 518
     $this->_last_fill_color = $color;
519 519
 
520 520
     list($r,$g,$b) = $color;
521 521
     $this->_pdf->setcolor("fill", "rgb", $r, $g, $b, 0);
522
-  }
522
+    }
523 523
 
524
-  /**
525
-   * Loads a specific font and stores the corresponding descriptor.
526
-   *
527
-   * @param string $font
528
-   * @return int the font descriptor for the font
529
-   */
530
-  protected function _load_font($font, $encoding = null, $options = "") {
524
+    /**
525
+     * Loads a specific font and stores the corresponding descriptor.
526
+     *
527
+     * @param string $font
528
+     * @return int the font descriptor for the font
529
+     */
530
+    protected function _load_font($font, $encoding = null, $options = "") {
531 531
 
532 532
     // Check if the font is a native PDF font
533 533
     // Embed non-native fonts
534 534
     $native_fonts = array("courier", "courier-bold", "courier-oblique", "courier-boldoblique",
535
-                          "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
-                          "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
-                          "symbol", "zapfdinbats");
535
+                            "helvetica", "helvetica-bold", "helvetica-oblique", "helvetica-boldoblique",
536
+                            "times-roman", "times-bold", "times-italic", "times-bolditalic",
537
+                            "symbol", "zapfdinbats");
538 538
 
539 539
     $test = strtolower(basename($font));
540 540
     if ( in_array($test, $native_fonts) ) {
541
-      $font = basename($font);
541
+        $font = basename($font);
542 542
 
543 543
     } else {
544
-      // Embed non-native fonts
545
-      $options .= " embedding=true";
544
+        // Embed non-native fonts
545
+        $options .= " embedding=true";
546 546
     }
547 547
 
548 548
     if ( is_null($encoding) ) {
549 549
 
550
-      // Unicode encoding is only available for the commerical
551
-      // version of PDFlib and not PDFlib-Lite
552
-      if ( defined("DOMPDF_PDFLIB_LICENSE") )
550
+        // Unicode encoding is only available for the commerical
551
+        // version of PDFlib and not PDFlib-Lite
552
+        if ( defined("DOMPDF_PDFLIB_LICENSE") )
553 553
         $encoding = "unicode";
554
-      else
554
+        else
555 555
         $encoding = "auto";
556 556
 
557 557
     }
@@ -559,28 +559,28 @@  discard block
 block discarded – undo
559 559
     $key = $font .":". $encoding .":". $options;
560 560
 
561 561
     if ( isset($this->_fonts[$key]) )
562
-      return $this->_fonts[$key];
562
+        return $this->_fonts[$key];
563 563
 
564 564
     else {
565 565
 
566
-      $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
-      return $this->_fonts[$key];
566
+        $this->_fonts[$key] = $this->_pdf->load_font($font, $encoding, $options);
567
+        return $this->_fonts[$key];
568 568
 
569 569
     }
570 570
 
571
-  }
571
+    }
572 572
 
573
-  /**
574
-   * Remaps y coords from 4th to 1st quadrant
575
-   *
576
-   * @param float $y
577
-   * @return float
578
-   */
579
-  protected function y($y) { return $this->_height - $y; }
573
+    /**
574
+     * Remaps y coords from 4th to 1st quadrant
575
+     *
576
+     * @param float $y
577
+     * @return float
578
+     */
579
+    protected function y($y) { return $this->_height - $y; }
580 580
 
581
-  //........................................................................
581
+    //........................................................................
582 582
 
583
-  function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
583
+    function line($x1, $y1, $x2, $y2, $color, $width, $style = null) {
584 584
     $this->_set_line_style($width, "butt", "", $style);
585 585
     $this->_set_stroke_color($color);
586 586
 
@@ -590,11 +590,11 @@  discard block
 block discarded – undo
590 590
     $this->_pdf->moveto($x1,$y1);
591 591
     $this->_pdf->lineto($x2, $y2);
592 592
     $this->_pdf->stroke();
593
-  }
593
+    }
594 594
 
595
-  //........................................................................
595
+    //........................................................................
596 596
 
597
-  function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
597
+    function rectangle($x1, $y1, $w, $h, $color, $width, $style = null) {
598 598
     $this->_set_stroke_color($color);
599 599
     $this->_set_line_style($width, "square", "miter", $style);
600 600
 
@@ -602,93 +602,93 @@  discard block
 block discarded – undo
602 602
 
603 603
     $this->_pdf->rect($x1, $y1, $w, $h);
604 604
     $this->_pdf->stroke();
605
-  }
605
+    }
606 606
 
607
-  //........................................................................
607
+    //........................................................................
608 608
 
609
-  function filled_rectangle($x1, $y1, $w, $h, $color) {
609
+    function filled_rectangle($x1, $y1, $w, $h, $color) {
610 610
     $this->_set_fill_color($color);
611 611
 
612 612
     $y1 = $this->y($y1) - $h;
613 613
 
614 614
     $this->_pdf->rect($x1, $y1, $w, $h);
615 615
     $this->_pdf->fill();
616
-  }
616
+    }
617 617
 
618
-  //........................................................................
618
+    //........................................................................
619 619
 
620
-  function polygon($points, $color, $width = null, $style = null, $fill = false) {
620
+    function polygon($points, $color, $width = null, $style = null, $fill = false) {
621 621
 
622 622
     $this->_set_fill_color($color);
623 623
     $this->_set_stroke_color($color);
624 624
 
625 625
     if ( !$fill && isset($width) )
626
-      $this->_set_line_style($width, "square", "miter", $style);
626
+        $this->_set_line_style($width, "square", "miter", $style);
627 627
 
628 628
     $y = $this->y(array_pop($points));
629 629
     $x = array_pop($points);
630 630
     $this->_pdf->moveto($x,$y);
631 631
 
632 632
     while (count($points) > 1) {
633
-      $y = $this->y(array_pop($points));
634
-      $x = array_pop($points);
635
-      $this->_pdf->lineto($x,$y);
633
+        $y = $this->y(array_pop($points));
634
+        $x = array_pop($points);
635
+        $this->_pdf->lineto($x,$y);
636 636
     }
637 637
 
638 638
     if ( $fill )
639
-      $this->_pdf->fill();
639
+        $this->_pdf->fill();
640 640
     else
641
-      $this->_pdf->closepath_stroke();
642
-  }
641
+        $this->_pdf->closepath_stroke();
642
+    }
643 643
 
644
-  //........................................................................
644
+    //........................................................................
645 645
 
646
-  function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
646
+    function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false) {
647 647
 
648 648
     $this->_set_fill_color($color);
649 649
     $this->_set_stroke_color($color);
650 650
 
651 651
     if ( !$fill && isset($width) )
652
-      $this->_set_line_style($width, "round", "round", $style);
652
+        $this->_set_line_style($width, "round", "round", $style);
653 653
 
654 654
     $y = $this->y($y);
655 655
 
656 656
     $this->_pdf->circle($x, $y, $r);
657 657
 
658 658
     if ( $fill )
659
-      $this->_pdf->fill();
659
+        $this->_pdf->fill();
660 660
     else
661
-      $this->_pdf->stroke();
661
+        $this->_pdf->stroke();
662 662
 
663
-  }
663
+    }
664 664
 
665
-  //........................................................................
665
+    //........................................................................
666 666
 
667
-  function image($img_url, $img_type, $x, $y, $w, $h) {
667
+    function image($img_url, $img_type, $x, $y, $w, $h) {
668 668
     $w = (int)$w;
669 669
     $h = (int)$h;
670 670
 
671 671
     $img_type = strtolower($img_type);
672 672
 
673 673
     if ( $img_type === "jpg" )
674
-      $img_type = "jpeg";
674
+        $img_type = "jpeg";
675 675
 
676 676
     if ( isset($this->_imgs[$img_url]) )
677
-      $img = $this->_imgs[$img_url];
677
+        $img = $this->_imgs[$img_url];
678 678
 
679 679
     else {
680 680
 
681
-      $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
681
+        $img = $this->_imgs[$img_url] = $this->_pdf->load_image($img_type, $img_url, "");
682 682
     }
683 683
 
684 684
     $y = $this->y($y) - $h;
685 685
     $this->_pdf->fit_image($img, $x, $y, 'boxsize={'. "$w $h" .'} fitmethod=entire');
686 686
 
687
-  }
687
+    }
688 688
 
689
-  //........................................................................
689
+    //........................................................................
690 690
 
691
-  function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
691
+    function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0, $angle = 0) {
692 692
     $fh = $this->_load_font($font);
693 693
 
694 694
     $this->_pdf->setfont($fh, $size);
@@ -701,72 +701,72 @@  discard block
 block discarded – undo
701 701
 
702 702
     $this->_pdf->fit_textline($text, $x, $y, "rotate=$angle wordspacing=$adjust");
703 703
 
704
-  }
704
+    }
705 705
 
706
-  //........................................................................
706
+    //........................................................................
707 707
   
708
-  function javascript($code) {
708
+    function javascript($code) {
709 709
     // Not implemented
710
-  }
710
+    }
711 711
 
712
-  //........................................................................
712
+    //........................................................................
713 713
 
714
-  /**
715
-   * Add a named destination (similar to <a name="foo">...</a> in html)
716
-   *
717
-   * @param string $anchorname The name of the named destination
718
-   */
719
-  function add_named_dest($anchorname) {
714
+    /**
715
+     * Add a named destination (similar to <a name="foo">...</a> in html)
716
+     *
717
+     * @param string $anchorname The name of the named destination
718
+     */
719
+    function add_named_dest($anchorname) {
720 720
     $this->_pdf->add_nameddest($anchorname,"");
721
-  }
721
+    }
722 722
 
723
-  //........................................................................
723
+    //........................................................................
724 724
 
725
-  /**
726
-   * Add a link to the pdf
727
-   *
728
-   * @param string $url The url to link to
729
-   * @param float  $x   The x position of the link
730
-   * @param float  $y   The y position of the link
731
-   * @param float  $width   The width of the link
732
-   * @param float  $height   The height of the link
733
-   */
734
-  function add_link($url, $x, $y, $width, $height) {
725
+    /**
726
+     * Add a link to the pdf
727
+     *
728
+     * @param string $url The url to link to
729
+     * @param float  $x   The x position of the link
730
+     * @param float  $y   The y position of the link
731
+     * @param float  $width   The width of the link
732
+     * @param float  $height   The height of the link
733
+     */
734
+    function add_link($url, $x, $y, $width, $height) {
735 735
 
736 736
     $y = $this->y($y) - $height;
737 737
     if ( strpos($url, '#') === 0 ) {
738
-      // Local link
739
-      $name = substr($url,1);
740
-      if ( $name )
738
+        // Local link
739
+        $name = substr($url,1);
740
+        if ( $name )
741 741
         $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} destname=". substr($url,1) . " linewidth=0");
742 742
     } else {
743 743
 
744
-      list($proto, $host, $path, $file) = explode_url($url);
744
+        list($proto, $host, $path, $file) = explode_url($url);
745 745
 
746
-      if ( $proto == "" || $proto === "file://" )
746
+        if ( $proto == "" || $proto === "file://" )
747 747
         return; // Local links are not allowed
748
-      $url = build_url($proto, $host, $path, $file);
749
-      $url = '{' . rawurldecode($url) . '}';
748
+        $url = build_url($proto, $host, $path, $file);
749
+        $url = '{' . rawurldecode($url) . '}';
750 750
       
751
-      $action = $this->_pdf->create_action("URI", "url=" . $url);
752
-      $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
751
+        $action = $this->_pdf->create_action("URI", "url=" . $url);
752
+        $this->_pdf->create_annotation($x, $y, $x + $width, $y + $height, 'Link', "contents={$url} action={activate=$action} linewidth=0");
753
+    }
753 754
     }
754
-  }
755 755
 
756
-  //........................................................................
756
+    //........................................................................
757 757
 
758
-  function get_text_width($text, $font, $size, $spacing = 0) {
758
+    function get_text_width($text, $font, $size, $spacing = 0) {
759 759
     $fh = $this->_load_font($font);
760 760
 
761 761
     // Determine the additional width due to extra spacing
762 762
     $num_spaces = mb_substr_count($text," ");
763 763
     $delta = $spacing * $num_spaces;
764 764
     return $this->_pdf->stringwidth($text, $fh, $size) + $delta;
765
-  }
765
+    }
766 766
 
767
-  //........................................................................
767
+    //........................................................................
768 768
 
769
-  function get_font_height($font, $size) {
769
+    function get_font_height($font, $size) {
770 770
 
771 771
     $fh = $this->_load_font($font);
772 772
 
@@ -777,54 +777,54 @@  discard block
 block discarded – undo
777 777
 
778 778
     // $desc is usually < 0,
779 779
     return self::FONT_HEIGHT_SCALE * $size * ($asc - $desc);
780
-  }
781
-
782
-  //........................................................................
783
-
784
-  /**
785
-   * Writes text at the specified x and y coordinates on every page
786
-   *
787
-   * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
-   * with their current values.
789
-   *
790
-   * See {@link Style::munge_colour()} for the format of the colour array.
791
-   *
792
-   * @param float $x
793
-   * @param float $y
794
-   * @param string $text the text to write
795
-   * @param string $font the font file to use
796
-   * @param float $size the font size, in points
797
-   * @param array $color
798
-   * @param float $adjust word spacing adjustment
799
-   * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
-   */
801
-  function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
-                     $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
780
+    }
781
+
782
+    //........................................................................
783
+
784
+    /**
785
+     * Writes text at the specified x and y coordinates on every page
786
+     *
787
+     * The strings '{PAGE_NUM}' and '{PAGE_COUNT}' are automatically replaced
788
+     * with their current values.
789
+     *
790
+     * See {@link Style::munge_colour()} for the format of the colour array.
791
+     *
792
+     * @param float $x
793
+     * @param float $y
794
+     * @param string $text the text to write
795
+     * @param string $font the font file to use
796
+     * @param float $size the font size, in points
797
+     * @param array $color
798
+     * @param float $adjust word spacing adjustment
799
+     * @param float $angle angle to write the text at, measured CW starting from the x-axis
800
+     */
801
+    function page_text($x, $y, $text, $font, $size, $color = array(0,0,0),
802
+                        $adjust = 0, $angle = 0,  $blend = "Normal", $opacity = 1.0) {
803 803
     $_t = "text";
804 804
     $this->_page_text[] = compact("_t", "x", "y", "text", "font", "size", "color", "adjust", "angle");
805
-  }
806
-
807
-  //........................................................................
808
-
809
-  /**
810
-   * Processes a script on every page
811
-   *
812
-   * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
-   *
814
-   * This function can be used to add page numbers to all pages
815
-   * after the first one, for example.
816
-   *
817
-   * @param string $code the script code
818
-   * @param string $type the language type for script
819
-   */
820
-  function page_script($code, $type = "text/php") {
805
+    }
806
+
807
+    //........................................................................
808
+
809
+    /**
810
+     * Processes a script on every page
811
+     *
812
+     * The variables $pdf, $PAGE_NUM, and $PAGE_COUNT are available.
813
+     *
814
+     * This function can be used to add page numbers to all pages
815
+     * after the first one, for example.
816
+     *
817
+     * @param string $code the script code
818
+     * @param string $type the language type for script
819
+     */
820
+    function page_script($code, $type = "text/php") {
821 821
     $_t = "script";
822 822
     $this->_page_text[] = compact("_t", "code", "type");
823
-  }
823
+    }
824 824
 
825
-  //........................................................................
825
+    //........................................................................
826 826
 
827
-  function new_page() {
827
+    function new_page() {
828 828
 
829 829
     // Add objects to the current page
830 830
     $this->_place_objects();
@@ -833,69 +833,69 @@  discard block
 block discarded – undo
833 833
     $this->_pdf->begin_page_ext($this->_width, $this->_height, "");
834 834
     $this->_page_number = ++$this->_page_count;
835 835
 
836
-  }
836
+    }
837 837
 
838
-  //........................................................................
838
+    //........................................................................
839 839
 
840
-  /**
841
-   * Add text to each page after rendering is complete
842
-   */
843
-  protected function _add_page_text() {
840
+    /**
841
+     * Add text to each page after rendering is complete
842
+     */
843
+    protected function _add_page_text() {
844 844
 
845 845
     if ( !count($this->_page_text) )
846
-      return;
846
+        return;
847 847
 
848 848
     $this->_pdf->suspend_page("");
849 849
 
850 850
     for ($p = 1; $p <= $this->_page_count; $p++) {
851
-      $this->_pdf->resume_page("pagenumber=$p");
851
+        $this->_pdf->resume_page("pagenumber=$p");
852 852
 
853
-      foreach ($this->_page_text as $pt) {
853
+        foreach ($this->_page_text as $pt) {
854 854
         extract($pt);
855 855
 
856 856
         switch ($_t) {
857 857
 
858 858
         case "text":
859 859
           $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"),
860
-                              array($p, $this->_page_count), $text);
861
-          $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
-          break;
860
+                                array($p, $this->_page_count), $text);
861
+            $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle);
862
+            break;
863 863
 
864 864
         case "script":
865 865
           if (!$eval) {
866 866
             $eval = new PHP_Evaluator($this);
867
-          }
868
-          $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
-          break;
867
+            }
868
+            $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count));
869
+            break;
870
+        }
870 871
         }
871
-      }
872 872
 
873
-      $this->_pdf->suspend_page("");
873
+        $this->_pdf->suspend_page("");
874 874
     }
875 875
 
876 876
     $this->_pdf->resume_page("pagenumber=".$this->_page_number);
877
-  }
877
+    }
878 878
 
879
-  //........................................................................
879
+    //........................................................................
880 880
 
881
-  function stream($filename, $options = null) {
881
+    function stream($filename, $options = null) {
882 882
 
883 883
     // Add page text
884 884
     $this->_add_page_text();
885 885
 
886 886
     if ( isset($options["compress"]) && $options["compress"] != 1 )
887
-      $this->_pdf->set_value("compress", 0);
887
+        $this->_pdf->set_value("compress", 0);
888 888
     else
889
-      $this->_pdf->set_value("compress", 6);
889
+        $this->_pdf->set_value("compress", 6);
890 890
 
891 891
     $this->_close();
892 892
 
893 893
     if ( self::$IN_MEMORY ) {
894
-      $data = $this->_pdf->get_buffer();
895
-      $size = strlen($data);
894
+        $data = $this->_pdf->get_buffer();
895
+        $size = strlen($data);
896 896
 
897 897
     } else
898
-      $size = filesize($this->_file);
898
+        $size = filesize($this->_file);
899 899
 
900 900
 
901 901
     $filename = str_replace(array("\n","'"),"", $filename);
@@ -908,63 +908,63 @@  discard block
 block discarded – undo
908 908
     //header("Content-length: " . $size);
909 909
 
910 910
     if ( self::$IN_MEMORY )
911
-      echo $data;
911
+        echo $data;
912 912
 
913 913
     else {
914 914
 
915
-      // Chunked readfile()
916
-      $chunk = (1 << 21); // 2 MB
917
-      $fh = fopen($this->_file, "rb");
918
-      if ( !$fh )
915
+        // Chunked readfile()
916
+        $chunk = (1 << 21); // 2 MB
917
+        $fh = fopen($this->_file, "rb");
918
+        if ( !$fh )
919 919
         throw new DOMPDF_Exception("Unable to load temporary PDF file: " . $this->_file);
920 920
 
921
-      while ( !feof($fh) )
921
+        while ( !feof($fh) )
922 922
         echo fread($fh,$chunk);
923
-      fclose($fh);
923
+        fclose($fh);
924 924
 
925
-      //debugpng
926
-      if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
-      if (!DEBUGKEEPTEMP)
925
+        //debugpng
926
+        if (DEBUGPNG) print '[pdflib stream unlink '.$this->_file.']';
927
+        if (!DEBUGKEEPTEMP)
928 928
 
929
-      unlink($this->_file);
930
-      $this->_file = null;
929
+        unlink($this->_file);
930
+        $this->_file = null;
931 931
     }
932 932
 
933 933
     flush();
934 934
 
935 935
 
936
-  }
936
+    }
937 937
 
938
-  //........................................................................
938
+    //........................................................................
939 939
 
940
-  function output($options = null) {
940
+    function output($options = null) {
941 941
 
942 942
     // Add page text
943 943
     $this->_add_page_text();
944 944
 
945 945
     if ( isset($options["compress"]) && $options["compress"] != 1 )
946
-      $this->_pdf->set_value("compress", 0);
946
+        $this->_pdf->set_value("compress", 0);
947 947
     else
948
-      $this->_pdf->set_value("compress", 6);
948
+        $this->_pdf->set_value("compress", 6);
949 949
 
950 950
     $this->_close();
951 951
 
952 952
     if ( self::$IN_MEMORY )
953
-      $data = $this->_pdf->get_buffer();
953
+        $data = $this->_pdf->get_buffer();
954 954
 
955 955
     else {
956
-      $data = file_get_contents($this->_file);
956
+        $data = file_get_contents($this->_file);
957 957
 
958
-      //debugpng
959
-      if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
-      if (!DEBUGKEEPTEMP)
958
+        //debugpng
959
+        if (DEBUGPNG) print '[pdflib output unlink '.$this->_file.']';
960
+        if (!DEBUGKEEPTEMP)
961 961
 
962
-      unlink($this->_file);
963
-      $this->_file = null;
962
+        unlink($this->_file);
963
+        $this->_file = null;
964 964
     }
965 965
 
966 966
     return $data;
967
-  }
967
+    }
968 968
 }
969 969
 
970 970
 // Workaround for idiotic limitation on statics...
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/cellmap.cls.php 1 patch
Indentation   +288 added lines, -289 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: cellmap.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -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.