Completed
Push — 1.10.x ( 77bf11...88842f )
by Angel Fernando Quiroz
43:15
created
main/inc/lib/phpdocx/lib/log4php/LoggerLevel.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	/**
79 79
 	 * Two priorities are equal if their level fields are equal.
80 80
 	 *
81
-	 * @param object $o
82
-	 * @return boolean 
81
+	 * @param LoggerLevel $o
82
+	 * @return boolean|null 
83 83
 	 */
84 84
 	public function equals($o) {
85 85
 		if($o instanceof LoggerLevel) {
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * Convert the string passed as argument to a level. If the
221 221
 	 * conversion fails, then this method returns a DEBUG Level.
222 222
 	 *
223
-	 * @param mixed $arg
224
-	 * @param LoggerLevel $default
223
+	 * @param string $arg
224
+	 * @param LoggerLevel $defaultLevel
225 225
 	 * @static 
226 226
 	 */
227 227
 	public static function toLevel($arg, $defaultLevel = null) {
Please login to merge, or discard this patch.
Indentation   +202 added lines, -202 removed lines patch added patch discarded remove patch
@@ -33,224 +33,224 @@
 block discarded – undo
33 33
  */
34 34
 class LoggerLevel {
35 35
 	
36
-	const OFF = 2147483647;
37
-	const FATAL = 50000;
38
-	const ERROR = 40000;
39
-	const WARN = 30000;
40
-	const INFO = 20000;
41
-	const DEBUG = 10000;
42
-	const ALL = -2147483647;
36
+    const OFF = 2147483647;
37
+    const FATAL = 50000;
38
+    const ERROR = 40000;
39
+    const WARN = 30000;
40
+    const INFO = 20000;
41
+    const DEBUG = 10000;
42
+    const ALL = -2147483647;
43 43
 
44
-	/**
45
-	 * TODO: check if still necessary or to be refactored 
46
-	 * @var integer
47
-	 */
48
-	private $level;
44
+    /**
45
+     * TODO: check if still necessary or to be refactored 
46
+     * @var integer
47
+     */
48
+    private $level;
49 49
   
50
-  	/**
51
-   	 * Contains a list of instantiated levels 
52
-   	 */
53
-  	private static $levelMap;
50
+        /**
51
+         * Contains a list of instantiated levels 
52
+         */
53
+        private static $levelMap;
54 54
   	
55
-	/**
56
-	 * @var string
57
-	 */
58
-	private $levelStr;
55
+    /**
56
+     * @var string
57
+     */
58
+    private $levelStr;
59 59
   
60
-	/**
61
-	 * @var integer
62
-	 */
63
-	private $syslogEquivalent;
60
+    /**
61
+     * @var integer
62
+     */
63
+    private $syslogEquivalent;
64 64
 
65
-	/**
66
-	 * Constructor
67
-	 *
68
-	 * @param integer $level
69
-	 * @param string $levelStr
70
-	 * @param integer $syslogEquivalent
71
-	 */
72
-	private function __construct($level, $levelStr, $syslogEquivalent) {
73
-		$this->level = $level;
74
-		$this->levelStr = $levelStr;
75
-		$this->syslogEquivalent = $syslogEquivalent;
76
-	}
65
+    /**
66
+     * Constructor
67
+     *
68
+     * @param integer $level
69
+     * @param string $levelStr
70
+     * @param integer $syslogEquivalent
71
+     */
72
+    private function __construct($level, $levelStr, $syslogEquivalent) {
73
+        $this->level = $level;
74
+        $this->levelStr = $levelStr;
75
+        $this->syslogEquivalent = $syslogEquivalent;
76
+    }
77 77
 
78
-	/**
79
-	 * Two priorities are equal if their level fields are equal.
80
-	 *
81
-	 * @param object $o
82
-	 * @return boolean 
83
-	 */
84
-	public function equals($o) {
85
-		if($o instanceof LoggerLevel) {
86
-			if($this->level == $o->level) {
87
-			    return true;
88
-			}
89
-		} else {
90
-			return false;
91
-		}
92
-	}
78
+    /**
79
+     * Two priorities are equal if their level fields are equal.
80
+     *
81
+     * @param object $o
82
+     * @return boolean 
83
+     */
84
+    public function equals($o) {
85
+        if($o instanceof LoggerLevel) {
86
+            if($this->level == $o->level) {
87
+                return true;
88
+            }
89
+        } else {
90
+            return false;
91
+        }
92
+    }
93 93
 	
94
-	/**
95
-	 * Returns an Off Level
96
-	 * @static
97
-	 * @return LoggerLevel
98
-	 */
99
-	public static function getLevelOff() {
100
-		if(!isset(self::$levelMap[LoggerLevel::OFF])) {
101
-			self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102
-		}
103
-		return self::$levelMap[LoggerLevel::OFF];
104
-	}
94
+    /**
95
+     * Returns an Off Level
96
+     * @static
97
+     * @return LoggerLevel
98
+     */
99
+    public static function getLevelOff() {
100
+        if(!isset(self::$levelMap[LoggerLevel::OFF])) {
101
+            self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102
+        }
103
+        return self::$levelMap[LoggerLevel::OFF];
104
+    }
105 105
 
106
-	/**
107
-	 * Returns a Fatal Level
108
-	 * @static
109
-	 * @return LoggerLevel
110
-	 */
111
-	public static function getLevelFatal() {
112
-		if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
113
-			self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114
-		}
115
-		return self::$levelMap[LoggerLevel::FATAL];
116
-	}
106
+    /**
107
+     * Returns a Fatal Level
108
+     * @static
109
+     * @return LoggerLevel
110
+     */
111
+    public static function getLevelFatal() {
112
+        if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
113
+            self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114
+        }
115
+        return self::$levelMap[LoggerLevel::FATAL];
116
+    }
117 117
 	
118
-	/**
119
-	 * Returns an Error Level
120
-	 * @static
121
-	 * @return LoggerLevel
122
-	 */
123
-	public static function getLevelError() {
124
-		if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
125
-			self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126
-		}
127
-		return self::$levelMap[LoggerLevel::ERROR];
128
-	}
118
+    /**
119
+     * Returns an Error Level
120
+     * @static
121
+     * @return LoggerLevel
122
+     */
123
+    public static function getLevelError() {
124
+        if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
125
+            self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126
+        }
127
+        return self::$levelMap[LoggerLevel::ERROR];
128
+    }
129 129
 	
130
-	/**
131
-	 * Returns a Warn Level
132
-	 * @static
133
-	 * @return LoggerLevel
134
-	 */
135
-	public static function getLevelWarn() {
136
-		if(!isset(self::$levelMap[LoggerLevel::WARN])) {
137
-			self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138
-		}
139
-		return self::$levelMap[LoggerLevel::WARN];
140
-	}
130
+    /**
131
+     * Returns a Warn Level
132
+     * @static
133
+     * @return LoggerLevel
134
+     */
135
+    public static function getLevelWarn() {
136
+        if(!isset(self::$levelMap[LoggerLevel::WARN])) {
137
+            self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138
+        }
139
+        return self::$levelMap[LoggerLevel::WARN];
140
+    }
141 141
 
142
-	/**
143
-	 * Returns an Info Level
144
-	 * @static
145
-	 * @return LoggerLevel
146
-	 */
147
-	public static function getLevelInfo() {
148
-		if(!isset(self::$levelMap[LoggerLevel::INFO])) {
149
-			self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150
-		}
151
-		return self::$levelMap[LoggerLevel::INFO];
152
-	}
142
+    /**
143
+     * Returns an Info Level
144
+     * @static
145
+     * @return LoggerLevel
146
+     */
147
+    public static function getLevelInfo() {
148
+        if(!isset(self::$levelMap[LoggerLevel::INFO])) {
149
+            self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150
+        }
151
+        return self::$levelMap[LoggerLevel::INFO];
152
+    }
153 153
 
154
-	/**
155
-	 * Returns a Debug Level
156
-	 * @static
157
-	 * @return LoggerLevel
158
-	 */
159
-	public static function getLevelDebug() {
160
-		if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161
-			self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162
-		}
163
-		return self::$levelMap[LoggerLevel::DEBUG];
164
-	}
154
+    /**
155
+     * Returns a Debug Level
156
+     * @static
157
+     * @return LoggerLevel
158
+     */
159
+    public static function getLevelDebug() {
160
+        if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161
+            self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162
+        }
163
+        return self::$levelMap[LoggerLevel::DEBUG];
164
+    }
165 165
 
166
-	/**
167
-	 * Returns an All Level
168
-	 * @static
169
-	 * @return LoggerLevel
170
-	 */
171
-	public static function getLevelAll() {
172
-		if(!isset(self::$levelMap[LoggerLevel::ALL])) {
173
-			self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174
-		}
175
-		return self::$levelMap[LoggerLevel::ALL];
176
-	}
166
+    /**
167
+     * Returns an All Level
168
+     * @static
169
+     * @return LoggerLevel
170
+     */
171
+    public static function getLevelAll() {
172
+        if(!isset(self::$levelMap[LoggerLevel::ALL])) {
173
+            self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174
+        }
175
+        return self::$levelMap[LoggerLevel::ALL];
176
+    }
177 177
 	
178
-	/**
179
-	 * Return the syslog equivalent of this priority as an integer.
180
-	 * @final
181
-	 * @return integer
182
-	 */
183
-	public function getSyslogEquivalent() {
184
-		return $this->syslogEquivalent;
185
-	}
178
+    /**
179
+     * Return the syslog equivalent of this priority as an integer.
180
+     * @final
181
+     * @return integer
182
+     */
183
+    public function getSyslogEquivalent() {
184
+        return $this->syslogEquivalent;
185
+    }
186 186
 
187
-	/**
188
-	 * Returns <i>true</i> if this level has a higher or equal
189
-	 * level than the level passed as argument, <i>false</i>
190
-	 * otherwise.  
191
-	 * 
192
-	 * <p>You should think twice before overriding the default
193
-	 * implementation of <i>isGreaterOrEqual</i> method.
194
-	 *
195
-	 * @param LoggerLevel $r
196
-	 * @return boolean
197
-	 */
198
-	public function isGreaterOrEqual($r) {
199
-		return $this->level >= $r->level;
200
-	}
187
+    /**
188
+     * Returns <i>true</i> if this level has a higher or equal
189
+     * level than the level passed as argument, <i>false</i>
190
+     * otherwise.  
191
+     * 
192
+     * <p>You should think twice before overriding the default
193
+     * implementation of <i>isGreaterOrEqual</i> method.
194
+     *
195
+     * @param LoggerLevel $r
196
+     * @return boolean
197
+     */
198
+    public function isGreaterOrEqual($r) {
199
+        return $this->level >= $r->level;
200
+    }
201 201
 
202
-	/**
203
-	 * Returns the string representation of this priority.
204
-	 * @return string
205
-	 * @final
206
-	 */
207
-	public function toString() {
208
-		return $this->levelStr;
209
-	}
202
+    /**
203
+     * Returns the string representation of this priority.
204
+     * @return string
205
+     * @final
206
+     */
207
+    public function toString() {
208
+        return $this->levelStr;
209
+    }
210 210
 
211
-	/**
212
-	 * Returns the integer representation of this level.
213
-	 * @return integer
214
-	 */
215
-	public function toInt() {
216
-		return $this->level;
217
-	}
211
+    /**
212
+     * Returns the integer representation of this level.
213
+     * @return integer
214
+     */
215
+    public function toInt() {
216
+        return $this->level;
217
+    }
218 218
 
219
-	/**
220
-	 * Convert the string passed as argument to a level. If the
221
-	 * conversion fails, then this method returns a DEBUG Level.
222
-	 *
223
-	 * @param mixed $arg
224
-	 * @param LoggerLevel $default
225
-	 * @static 
226
-	 */
227
-	public static function toLevel($arg, $defaultLevel = null) {
228
-		if($defaultLevel === null) {
229
-			return self::toLevel($arg, self::getLevelDebug());
230
-		} else {
231
-			if(is_int($arg)) {
232
-				switch($arg) {
233
-					case self::ALL:	return self::getLevelAll();
234
-					case self::DEBUG: return self::getLevelDebug();
235
-					case self::INFO: return self::getLevelInfo();
236
-					case self::WARN: return self::getLevelWarn();
237
-					case self::ERROR: return self::getLevelError();
238
-					case self::FATAL: return self::getLevelFatal();
239
-					case self::OFF:	return self::getLevelOff();
240
-					default: return $defaultLevel;
241
-				}
242
-			} else {
243
-				switch(strtoupper($arg)) {
244
-					case 'ALL':	return self::getLevelAll();
245
-					case 'DEBUG': return self::getLevelDebug();
246
-					case 'INFO': return self::getLevelInfo();
247
-					case 'WARN': return self::getLevelWarn();
248
-					case 'ERROR': return self::getLevelError();
249
-					case 'FATAL': return self::getLevelFatal();
250
-					case 'OFF':	return self::getLevelOff();
251
-					default: return $defaultLevel;
252
-				}
253
-			}
254
-		}
255
-	}
219
+    /**
220
+     * Convert the string passed as argument to a level. If the
221
+     * conversion fails, then this method returns a DEBUG Level.
222
+     *
223
+     * @param mixed $arg
224
+     * @param LoggerLevel $default
225
+     * @static 
226
+     */
227
+    public static function toLevel($arg, $defaultLevel = null) {
228
+        if($defaultLevel === null) {
229
+            return self::toLevel($arg, self::getLevelDebug());
230
+        } else {
231
+            if(is_int($arg)) {
232
+                switch($arg) {
233
+                    case self::ALL:	return self::getLevelAll();
234
+                    case self::DEBUG: return self::getLevelDebug();
235
+                    case self::INFO: return self::getLevelInfo();
236
+                    case self::WARN: return self::getLevelWarn();
237
+                    case self::ERROR: return self::getLevelError();
238
+                    case self::FATAL: return self::getLevelFatal();
239
+                    case self::OFF:	return self::getLevelOff();
240
+                    default: return $defaultLevel;
241
+                }
242
+            } else {
243
+                switch(strtoupper($arg)) {
244
+                    case 'ALL':	return self::getLevelAll();
245
+                    case 'DEBUG': return self::getLevelDebug();
246
+                    case 'INFO': return self::getLevelInfo();
247
+                    case 'WARN': return self::getLevelWarn();
248
+                    case 'ERROR': return self::getLevelError();
249
+                    case 'FATAL': return self::getLevelFatal();
250
+                    case 'OFF':	return self::getLevelOff();
251
+                    default: return $defaultLevel;
252
+                }
253
+            }
254
+        }
255
+    }
256 256
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	 * @return boolean 
83 83
 	 */
84 84
 	public function equals($o) {
85
-		if($o instanceof LoggerLevel) {
86
-			if($this->level == $o->level) {
85
+		if ($o instanceof LoggerLevel) {
86
+			if ($this->level == $o->level) {
87 87
 			    return true;
88 88
 			}
89 89
 		} else {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @return LoggerLevel
98 98
 	 */
99 99
 	public static function getLevelOff() {
100
-		if(!isset(self::$levelMap[LoggerLevel::OFF])) {
100
+		if (!isset(self::$levelMap[LoggerLevel::OFF])) {
101 101
 			self::$levelMap[LoggerLevel::OFF] = new LoggerLevel(LoggerLevel::OFF, 'OFF', 0);
102 102
 		}
103 103
 		return self::$levelMap[LoggerLevel::OFF];
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @return LoggerLevel
110 110
 	 */
111 111
 	public static function getLevelFatal() {
112
-		if(!isset(self::$levelMap[LoggerLevel::FATAL])) {
112
+		if (!isset(self::$levelMap[LoggerLevel::FATAL])) {
113 113
 			self::$levelMap[LoggerLevel::FATAL] = new LoggerLevel(LoggerLevel::FATAL, 'FATAL', 0);
114 114
 		}
115 115
 		return self::$levelMap[LoggerLevel::FATAL];
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	 * @return LoggerLevel
122 122
 	 */
123 123
 	public static function getLevelError() {
124
-		if(!isset(self::$levelMap[LoggerLevel::ERROR])) {
124
+		if (!isset(self::$levelMap[LoggerLevel::ERROR])) {
125 125
 			self::$levelMap[LoggerLevel::ERROR] = new LoggerLevel(LoggerLevel::ERROR, 'ERROR', 3);
126 126
 		}
127 127
 		return self::$levelMap[LoggerLevel::ERROR];
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return LoggerLevel
134 134
 	 */
135 135
 	public static function getLevelWarn() {
136
-		if(!isset(self::$levelMap[LoggerLevel::WARN])) {
136
+		if (!isset(self::$levelMap[LoggerLevel::WARN])) {
137 137
 			self::$levelMap[LoggerLevel::WARN] = new LoggerLevel(LoggerLevel::WARN, 'WARN', 4);
138 138
 		}
139 139
 		return self::$levelMap[LoggerLevel::WARN];
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	 * @return LoggerLevel
146 146
 	 */
147 147
 	public static function getLevelInfo() {
148
-		if(!isset(self::$levelMap[LoggerLevel::INFO])) {
148
+		if (!isset(self::$levelMap[LoggerLevel::INFO])) {
149 149
 			self::$levelMap[LoggerLevel::INFO] = new LoggerLevel(LoggerLevel::INFO, 'INFO', 6);
150 150
 		}
151 151
 		return self::$levelMap[LoggerLevel::INFO];
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	 * @return LoggerLevel
158 158
 	 */
159 159
 	public static function getLevelDebug() {
160
-		if(!isset(self::$levelMap[LoggerLevel::DEBUG])) {
160
+		if (!isset(self::$levelMap[LoggerLevel::DEBUG])) {
161 161
 			self::$levelMap[LoggerLevel::DEBUG] = new LoggerLevel(LoggerLevel::DEBUG, 'DEBUG', 7);
162 162
 		}
163 163
 		return self::$levelMap[LoggerLevel::DEBUG];
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	 * @return LoggerLevel
170 170
 	 */
171 171
 	public static function getLevelAll() {
172
-		if(!isset(self::$levelMap[LoggerLevel::ALL])) {
172
+		if (!isset(self::$levelMap[LoggerLevel::ALL])) {
173 173
 			self::$levelMap[LoggerLevel::ALL] = new LoggerLevel(LoggerLevel::ALL, 'ALL', 7);
174 174
 		}
175 175
 		return self::$levelMap[LoggerLevel::ALL];
@@ -225,11 +225,11 @@  discard block
 block discarded – undo
225 225
 	 * @static 
226 226
 	 */
227 227
 	public static function toLevel($arg, $defaultLevel = null) {
228
-		if($defaultLevel === null) {
228
+		if ($defaultLevel === null) {
229 229
 			return self::toLevel($arg, self::getLevelDebug());
230 230
 		} else {
231
-			if(is_int($arg)) {
232
-				switch($arg) {
231
+			if (is_int($arg)) {
232
+				switch ($arg) {
233 233
 					case self::ALL:	return self::getLevelAll();
234 234
 					case self::DEBUG: return self::getLevelDebug();
235 235
 					case self::INFO: return self::getLevelInfo();
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 					default: return $defaultLevel;
241 241
 				}
242 242
 			} else {
243
-				switch(strtoupper($arg)) {
243
+				switch (strtoupper($arg)) {
244 244
 					case 'ALL':	return self::getLevelAll();
245 245
 					case 'DEBUG': return self::getLevelDebug();
246 246
 					case 'INFO': return self::getLevelInfo();
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerLocationInfo.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
 	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63 63
 	 *
64 64
 	 * @param array $trace
65
-	 * @param mixed $caller
65
+	 * @param string $fqcn
66 66
 	 */
67 67
 	public function __construct($trace, $fqcn = null) {
68 68
 		$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@
 block discarded – undo
69 69
 		$this->fileName = isset($trace['file']) ? $trace['file'] : null;
70 70
 		$this->className = isset($trace['class']) ? $trace['class'] : null;
71 71
 		$this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
-		$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
-			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
72
+		$this->fullInfo = $this->getClassName().'.'.$this->getMethodName(). 
73
+			'('.$this->getFileName().':'.$this->getLineNumber().')';
74 74
 	}
75 75
 
76 76
 	public function getClassName() {
Please login to merge, or discard this patch.
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -26,85 +26,85 @@
 block discarded – undo
26 26
  * @since 0.3
27 27
  */
28 28
 class LoggerLocationInfo {
29
-	/**
30
-	 * When location information is not available the constant
31
-	 * <i>NA</i> is returned. Current value of this string
32
-	 * constant is <b>?</b>.  
33
-	 */
34
-	const LOCATION_INFO_NA = 'NA';
29
+    /**
30
+     * When location information is not available the constant
31
+     * <i>NA</i> is returned. Current value of this string
32
+     * constant is <b>?</b>.  
33
+     */
34
+    const LOCATION_INFO_NA = 'NA';
35 35
 	
36
-	/**
37
-	* @var string Caller's line number.
38
-	*/
39
-	protected $lineNumber = null;
36
+    /**
37
+     * @var string Caller's line number.
38
+     */
39
+    protected $lineNumber = null;
40 40
 	
41
-	/**
42
-	* @var string Caller's file name.
43
-	*/
44
-	protected $fileName = null;
41
+    /**
42
+     * @var string Caller's file name.
43
+     */
44
+    protected $fileName = null;
45 45
 	
46
-	/**
47
-	* @var string Caller's fully qualified class name.
48
-	*/
49
-	protected $className = null;
46
+    /**
47
+     * @var string Caller's fully qualified class name.
48
+     */
49
+    protected $className = null;
50 50
 	
51
-	/**
52
-	* @var string Caller's method name.
53
-	*/
54
-	protected $methodName = null;
51
+    /**
52
+     * @var string Caller's method name.
53
+     */
54
+    protected $methodName = null;
55 55
 	
56
-	/**
57
-	* @var string 
58
-	*/
59
-	protected $fullInfo = null;
56
+    /**
57
+     * @var string 
58
+     */
59
+    protected $fullInfo = null;
60 60
 
61
-	/**
62
-	 * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63
-	 *
64
-	 * @param array $trace
65
-	 * @param mixed $caller
66
-	 */
67
-	public function __construct($trace, $fqcn = null) {
68
-		$this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
69
-		$this->fileName = isset($trace['file']) ? $trace['file'] : null;
70
-		$this->className = isset($trace['class']) ? $trace['class'] : null;
71
-		$this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
-		$this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
-			'(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
74
-	}
61
+    /**
62
+     * Instantiate location information based on a {@link PHP_MANUAL#debug_backtrace}.
63
+     *
64
+     * @param array $trace
65
+     * @param mixed $caller
66
+     */
67
+    public function __construct($trace, $fqcn = null) {
68
+        $this->lineNumber = isset($trace['line']) ? $trace['line'] : null;
69
+        $this->fileName = isset($trace['file']) ? $trace['file'] : null;
70
+        $this->className = isset($trace['class']) ? $trace['class'] : null;
71
+        $this->methodName = isset($trace['function']) ? $trace['function'] : null;
72
+        $this->fullInfo = $this->getClassName() . '.' . $this->getMethodName() . 
73
+            '(' . $this->getFileName() . ':' . $this->getLineNumber() . ')';
74
+    }
75 75
 
76
-	public function getClassName() {
77
-		return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; 
78
-	}
76
+    public function getClassName() {
77
+        return ($this->className === null) ? self::LOCATION_INFO_NA : $this->className; 
78
+    }
79 79
 
80
-	/**
81
-	 *	Return the file name of the caller.
82
-	 *	<p>This information is not always available.
83
-	 */
84
-	public function getFileName() {
85
-		return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; 
86
-	}
80
+    /**
81
+     *	Return the file name of the caller.
82
+     *	<p>This information is not always available.
83
+     */
84
+    public function getFileName() {
85
+        return ($this->fileName === null) ? self::LOCATION_INFO_NA : $this->fileName; 
86
+    }
87 87
 
88
-	/**
89
-	 *	Returns the line number of the caller.
90
-	 *	<p>This information is not always available.
91
-	 */
92
-	public function getLineNumber() {
93
-		return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; 
94
-	}
88
+    /**
89
+     *	Returns the line number of the caller.
90
+     *	<p>This information is not always available.
91
+     */
92
+    public function getLineNumber() {
93
+        return ($this->lineNumber === null) ? self::LOCATION_INFO_NA : $this->lineNumber; 
94
+    }
95 95
 
96
-	/**
97
-	 *	Returns the method name of the caller.
98
-	 */
99
-	public function getMethodName() {
100
-		return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; 
101
-	}
96
+    /**
97
+     *	Returns the method name of the caller.
98
+     */
99
+    public function getMethodName() {
100
+        return ($this->methodName === null) ? self::LOCATION_INFO_NA : $this->methodName; 
101
+    }
102 102
 
103
-	/**
104
-	 *	Returns the full information of the caller.
105
-	 */
106
-	public function getFullInfo() {
107
-		return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
108
-	}
103
+    /**
104
+     *	Returns the full information of the caller.
105
+     */
106
+    public function getFullInfo() {
107
+        return ($this->fullInfo === null) ? self::LOCATION_INFO_NA : $this->fullInfo;
108
+    }
109 109
 
110 110
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerLoggingEvent.php 3 patches
Doc Comments   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	* LoggerLoggingEvent are filled when actually needed.
118 118
 	*
119 119
 	* @param string $fqcn name of the caller class.
120
-	* @param mixed $logger The {@link Logger} category of this event or the logger name.
120
+	* @param Logger $logger The {@link Logger} category of this event or the logger name.
121 121
 	* @param LoggerLevel $priority The level of this event.
122 122
 	* @param mixed $message The message of this event.
123 123
 	* @param integer $timeStamp the timestamp of this logging event.
@@ -249,6 +249,7 @@  discard block
 block discarded – undo
249 249
 	/**
250 250
 	 * Returns the the context corresponding to the <code>key</code>
251 251
 	 * parameter.
252
+	 * @param string $key
252 253
 	 * @return string
253 254
 	 */
254 255
 	public function getMDC($key) {
@@ -304,7 +305,7 @@  discard block
 block discarded – undo
304 305
 	
305 306
 	/**
306 307
 	 * Calculates the time of this event.
307
-	 * @return the time after event starttime when this event has occured
308
+	 * @return string time after event starttime when this event has occured
308 309
 	 */
309 310
 	public function getTime() {
310 311
         $eventTime = (float)$this->getTimeStamp();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	*/
125 125
 	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126 126
 		$this->fqcn = $fqcn;
127
-		if($logger instanceof Logger) {
127
+		if ($logger instanceof Logger) {
128 128
 			$this->logger = $logger;
129 129
 			$this->categoryName = $logger->getName();
130 130
 		} else {
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 		}
133 133
 		$this->level = $priority;
134 134
 		$this->message = $message;
135
-		if($timeStamp !== null && is_float($timeStamp)) {
135
+		if ($timeStamp !== null && is_float($timeStamp)) {
136 136
 			$this->timeStamp = $timeStamp;
137 137
 		} else {
138
-			if(function_exists('microtime')) {
138
+			if (function_exists('microtime')) {
139 139
 				// get microtime as float
140 140
 				$this->timeStamp = microtime(true);
141 141
 			} else {
@@ -154,20 +154,20 @@  discard block
 block discarded – undo
154 154
 	 * @return LoggerLocationInfo
155 155
 	 */
156 156
 	public function getLocationInformation() {
157
-		if($this->locationInfo === null) {
157
+		if ($this->locationInfo === null) {
158 158
 
159 159
 			$locationInfo = array();
160 160
 
161
-			if(function_exists('debug_backtrace')) {
161
+			if (function_exists('debug_backtrace')) {
162 162
 				$trace = debug_backtrace();
163 163
 				$prevHop = null;
164 164
 				// make a downsearch to identify the caller
165 165
 				$hop = array_pop($trace);
166
-				while($hop !== null) {
167
-					if(isset($hop['class'])) {
166
+				while ($hop !== null) {
167
+					if (isset($hop['class'])) {
168 168
 						// we are sometimes in functions = no class available: avoid php warning here
169 169
 						$className = strtolower($hop['class']);
170
-						if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
170
+						if (!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171 171
 							strtolower(get_parent_class($className)) == 'logger' or
172 172
 							strtolower(get_parent_class($className)) == 'loggercategory')) {
173 173
 							$locationInfo['line'] = $hop['line'];
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 					$hop = array_pop($trace);
180 180
 				}
181 181
 				$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
-				if(isset($prevHop['function']) and
182
+				if (isset($prevHop['function']) and
183 183
 					$prevHop['function'] !== 'include' and
184 184
 					$prevHop['function'] !== 'include_once' and
185 185
 					$prevHop['function'] !== 'require' and
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @return mixed
225 225
 	 */
226 226
 	public function getMessage() {
227
-		if($this->message !== null) {
227
+		if ($this->message !== null) {
228 228
 			return $this->message;
229 229
 		} else {
230 230
 			return $this->getRenderedMessage();
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	 * @return string  
240 240
 	 */
241 241
 	public function getNDC() {
242
-		if($this->ndcLookupRequired) {
242
+		if ($this->ndcLookupRequired) {
243 243
 			$this->ndcLookupRequired = false;
244 244
 			$this->ndc = implode(' ', LoggerNDC::get());
245 245
 		}
@@ -260,8 +260,8 @@  discard block
 block discarded – undo
260 260
 	 * @return string
261 261
 	 */
262 262
 	public function getRenderedMessage() {
263
-		if($this->renderedMessage === null and $this->message !== null) {
264
-			if(is_string($this->message)) {
263
+		if ($this->renderedMessage === null and $this->message !== null) {
264
+			if (is_string($this->message)) {
265 265
 					$this->renderedMessage = $this->message;
266 266
 			} else {
267 267
 			    // $this->logger might be null or an instance of Logger or RootLogger
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 			    // TODO: Logger::getHierarchy() is marked @deprecated!
271 271
 				$repository = Logger::getHierarchy();
272 272
 				$rendererMap = $repository->getRendererMap();
273
-				$this->renderedMessage= $rendererMap->findAndRender($this->message);
273
+				$this->renderedMessage = $rendererMap->findAndRender($this->message);
274 274
 			}
275 275
 		}
276 276
 		return $this->renderedMessage;
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 	 * @static
285 285
 	 */
286 286
 	public static function getStartTime() {
287
-		if(!isset(self::$startTime)) {
287
+		if (!isset(self::$startTime)) {
288 288
 			if (function_exists('microtime')) {
289 289
 				// microtime as float
290 290
 				self::$startTime = microtime(true);
@@ -307,8 +307,8 @@  discard block
 block discarded – undo
307 307
 	 * @return the time after event starttime when this event has occured
308 308
 	 */
309 309
 	public function getTime() {
310
-        $eventTime = (float)$this->getTimeStamp();
311
-        $eventStartTime = (float)LoggerLoggingEvent::getStartTime();
310
+        $eventTime = (float) $this->getTimeStamp();
311
+        $eventStartTime = (float) LoggerLoggingEvent::getStartTime();
312 312
         return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
313 313
     }
314 314
 	
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 */
318 318
 	public function getThreadName() {
319 319
 		if ($this->threadName === null) {
320
-			$this->threadName = (string)getmypid();
320
+			$this->threadName = (string) getmypid();
321 321
 		}
322 322
 		return $this->threadName;
323 323
 	}
Please login to merge, or discard this patch.
Indentation   +293 added lines, -293 removed lines patch added patch discarded remove patch
@@ -26,334 +26,334 @@
 block discarded – undo
26 26
  */
27 27
 class LoggerLoggingEvent {
28 28
 
29
-	private static $startTime;
29
+    private static $startTime;
30 30
 
31
-	/** 
32
-	* @var string Fully Qualified Class Name of the calling category class.
33
-	*/
34
-	private $fqcn;
31
+    /** 
32
+     * @var string Fully Qualified Class Name of the calling category class.
33
+     */
34
+    private $fqcn;
35 35
 	
36
-	/**
37
-	* @var Logger reference
38
-	*/
39
-	private $logger = null;
36
+    /**
37
+     * @var Logger reference
38
+     */
39
+    private $logger = null;
40 40
 	
41
-	/** 
42
-	* The category (logger) name.
43
-	* This field will be marked as private in future
44
-	* releases. Please do not access it directly. 
45
-	* Use the {@link getLoggerName()} method instead.
46
-	* @deprecated 
47
-	*/
48
-	private $categoryName;
41
+    /** 
42
+     * The category (logger) name.
43
+     * This field will be marked as private in future
44
+     * releases. Please do not access it directly. 
45
+     * Use the {@link getLoggerName()} method instead.
46
+     * @deprecated 
47
+     */
48
+    private $categoryName;
49 49
 	
50
-	/** 
51
-	* Level of logging event.
52
-	* <p> This field should not be accessed directly. You shoud use the
53
-	* {@link getLevel()} method instead.
54
-	*
55
-	* @deprecated
56
-	* @var LoggerLevel
57
-	*/
58
-	protected $level;
50
+    /** 
51
+     * Level of logging event.
52
+     * <p> This field should not be accessed directly. You shoud use the
53
+     * {@link getLevel()} method instead.
54
+     *
55
+     * @deprecated
56
+     * @var LoggerLevel
57
+     */
58
+    protected $level;
59 59
 	
60
-	/** 
61
-	 * @var string The nested diagnostic context (NDC) of logging event. 
62
-	 */
63
-	private $ndc;
60
+    /** 
61
+     * @var string The nested diagnostic context (NDC) of logging event. 
62
+     */
63
+    private $ndc;
64 64
 	
65
-	/** 
66
-	 * Have we tried to do an NDC lookup? If we did, there is no need
67
-	 * to do it again.	Note that its value is always false when
68
-	 * serialized. Thus, a receiving SocketNode will never use it's own
69
-	 * (incorrect) NDC. See also writeObject method.
70
-	 * @var boolean
71
-	 */
72
-	private $ndcLookupRequired = true;
65
+    /** 
66
+     * Have we tried to do an NDC lookup? If we did, there is no need
67
+     * to do it again.	Note that its value is always false when
68
+     * serialized. Thus, a receiving SocketNode will never use it's own
69
+     * (incorrect) NDC. See also writeObject method.
70
+     * @var boolean
71
+     */
72
+    private $ndcLookupRequired = true;
73 73
 	
74
-	/** 
75
-	 * Have we tried to do an MDC lookup? If we did, there is no need
76
-	 * to do it again.	Note that its value is always false when
77
-	 * serialized. See also the getMDC and getMDCCopy methods.
78
-	 * @var boolean	 
79
-	 */
80
-	private $mdcCopyLookupRequired = true;
74
+    /** 
75
+     * Have we tried to do an MDC lookup? If we did, there is no need
76
+     * to do it again.	Note that its value is always false when
77
+     * serialized. See also the getMDC and getMDCCopy methods.
78
+     * @var boolean	 
79
+     */
80
+    private $mdcCopyLookupRequired = true;
81 81
 	
82
-	/** 
83
-	 * @var mixed The application supplied message of logging event. 
84
-	 */
85
-	private $message;
82
+    /** 
83
+     * @var mixed The application supplied message of logging event. 
84
+     */
85
+    private $message;
86 86
 	
87
-	/** 
88
-	 * The application supplied message rendered through the log4php
89
-	 * objet rendering mechanism. At present renderedMessage == message.
90
-	 * @var string
91
-	 */
92
-	private $renderedMessage = null;
87
+    /** 
88
+     * The application supplied message rendered through the log4php
89
+     * objet rendering mechanism. At present renderedMessage == message.
90
+     * @var string
91
+     */
92
+    private $renderedMessage = null;
93 93
 	
94
-	/** 
95
-	 * The name of thread in which this logging event was generated.
96
-	 * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
97
-	 * @var mixed
98
-	 */
99
-	private $threadName = null;
94
+    /** 
95
+     * The name of thread in which this logging event was generated.
96
+     * log4php saves here the process id via {@link PHP_MANUAL#getmypid getmypid()} 
97
+     * @var mixed
98
+     */
99
+    private $threadName = null;
100 100
 	
101
-	/** 
102
-	* The number of seconds elapsed from 1/1/1970 until logging event
103
-	* was created plus microseconds if available.
104
-	* @var float
105
-	*/
106
-	public $timeStamp;
101
+    /** 
102
+     * The number of seconds elapsed from 1/1/1970 until logging event
103
+     * was created plus microseconds if available.
104
+     * @var float
105
+     */
106
+    public $timeStamp;
107 107
 	
108
-	/** 
109
-	* @var LoggerLocationInfo Location information for the caller. 
110
-	*/
111
-	private $locationInfo = null;
108
+    /** 
109
+     * @var LoggerLocationInfo Location information for the caller. 
110
+     */
111
+    private $locationInfo = null;
112 112
 	
113
-	/**
114
-	* Instantiate a LoggingEvent from the supplied parameters.
115
-	*
116
-	* <p>Except {@link $timeStamp} all the other fields of
117
-	* LoggerLoggingEvent are filled when actually needed.
118
-	*
119
-	* @param string $fqcn name of the caller class.
120
-	* @param mixed $logger The {@link Logger} category of this event or the logger name.
121
-	* @param LoggerLevel $priority The level of this event.
122
-	* @param mixed $message The message of this event.
123
-	* @param integer $timeStamp the timestamp of this logging event.
124
-	*/
125
-	public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126
-		$this->fqcn = $fqcn;
127
-		if($logger instanceof Logger) {
128
-			$this->logger = $logger;
129
-			$this->categoryName = $logger->getName();
130
-		} else {
131
-			$this->categoryName = strval($logger);
132
-		}
133
-		$this->level = $priority;
134
-		$this->message = $message;
135
-		if($timeStamp !== null && is_float($timeStamp)) {
136
-			$this->timeStamp = $timeStamp;
137
-		} else {
138
-			if(function_exists('microtime')) {
139
-				// get microtime as float
140
-				$this->timeStamp = microtime(true);
141
-			} else {
142
-				$this->timeStamp = floatval(time());
143
-			}
144
-		}
145
-	}
113
+    /**
114
+     * Instantiate a LoggingEvent from the supplied parameters.
115
+     *
116
+     * <p>Except {@link $timeStamp} all the other fields of
117
+     * LoggerLoggingEvent are filled when actually needed.
118
+     *
119
+     * @param string $fqcn name of the caller class.
120
+     * @param mixed $logger The {@link Logger} category of this event or the logger name.
121
+     * @param LoggerLevel $priority The level of this event.
122
+     * @param mixed $message The message of this event.
123
+     * @param integer $timeStamp the timestamp of this logging event.
124
+     */
125
+    public function __construct($fqcn, $logger, $priority, $message, $timeStamp = null) {
126
+        $this->fqcn = $fqcn;
127
+        if($logger instanceof Logger) {
128
+            $this->logger = $logger;
129
+            $this->categoryName = $logger->getName();
130
+        } else {
131
+            $this->categoryName = strval($logger);
132
+        }
133
+        $this->level = $priority;
134
+        $this->message = $message;
135
+        if($timeStamp !== null && is_float($timeStamp)) {
136
+            $this->timeStamp = $timeStamp;
137
+        } else {
138
+            if(function_exists('microtime')) {
139
+                // get microtime as float
140
+                $this->timeStamp = microtime(true);
141
+            } else {
142
+                $this->timeStamp = floatval(time());
143
+            }
144
+        }
145
+    }
146 146
 
147
-	/**
148
-	 * Set the location information for this logging event. The collected
149
-	 * information is cached for future use.
150
-	 *
151
-	 * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
152
-	 * to collect informations about caller.</p>
153
-	 * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
154
-	 * @return LoggerLocationInfo
155
-	 */
156
-	public function getLocationInformation() {
157
-		if($this->locationInfo === null) {
147
+    /**
148
+     * Set the location information for this logging event. The collected
149
+     * information is cached for future use.
150
+     *
151
+     * <p>This method uses {@link PHP_MANUAL#debug_backtrace debug_backtrace()} function (if exists)
152
+     * to collect informations about caller.</p>
153
+     * <p>It only recognize informations generated by {@link Logger} and its subclasses.</p>
154
+     * @return LoggerLocationInfo
155
+     */
156
+    public function getLocationInformation() {
157
+        if($this->locationInfo === null) {
158 158
 
159
-			$locationInfo = array();
159
+            $locationInfo = array();
160 160
 
161
-			if(function_exists('debug_backtrace')) {
162
-				$trace = debug_backtrace();
163
-				$prevHop = null;
164
-				// make a downsearch to identify the caller
165
-				$hop = array_pop($trace);
166
-				while($hop !== null) {
167
-					if(isset($hop['class'])) {
168
-						// we are sometimes in functions = no class available: avoid php warning here
169
-						$className = strtolower($hop['class']);
170
-						if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171
-							strtolower(get_parent_class($className)) == 'logger' or
172
-							strtolower(get_parent_class($className)) == 'loggercategory')) {
173
-							$locationInfo['line'] = $hop['line'];
174
-							$locationInfo['file'] = $hop['file'];
175
-							break;
176
-						}
177
-					}
178
-					$prevHop = $hop;
179
-					$hop = array_pop($trace);
180
-				}
181
-				$locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
-				if(isset($prevHop['function']) and
183
-					$prevHop['function'] !== 'include' and
184
-					$prevHop['function'] !== 'include_once' and
185
-					$prevHop['function'] !== 'require' and
186
-					$prevHop['function'] !== 'require_once') {
161
+            if(function_exists('debug_backtrace')) {
162
+                $trace = debug_backtrace();
163
+                $prevHop = null;
164
+                // make a downsearch to identify the caller
165
+                $hop = array_pop($trace);
166
+                while($hop !== null) {
167
+                    if(isset($hop['class'])) {
168
+                        // we are sometimes in functions = no class available: avoid php warning here
169
+                        $className = strtolower($hop['class']);
170
+                        if(!empty($className) and ($className == 'logger' or $className == 'loggercategory' or 
171
+                            strtolower(get_parent_class($className)) == 'logger' or
172
+                            strtolower(get_parent_class($className)) == 'loggercategory')) {
173
+                            $locationInfo['line'] = $hop['line'];
174
+                            $locationInfo['file'] = $hop['file'];
175
+                            break;
176
+                        }
177
+                    }
178
+                    $prevHop = $hop;
179
+                    $hop = array_pop($trace);
180
+                }
181
+                $locationInfo['class'] = isset($prevHop['class']) ? $prevHop['class'] : 'main';
182
+                if(isset($prevHop['function']) and
183
+                    $prevHop['function'] !== 'include' and
184
+                    $prevHop['function'] !== 'include_once' and
185
+                    $prevHop['function'] !== 'require' and
186
+                    $prevHop['function'] !== 'require_once') {
187 187
 	
188
-					$locationInfo['function'] = $prevHop['function'];
189
-				} else {
190
-					$locationInfo['function'] = 'main';
191
-				}
192
-			}
188
+                    $locationInfo['function'] = $prevHop['function'];
189
+                } else {
190
+                    $locationInfo['function'] = 'main';
191
+                }
192
+            }
193 193
 					 
194
-			$this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
195
-		}
196
-		return $this->locationInfo;
197
-	}
194
+            $this->locationInfo = new LoggerLocationInfo($locationInfo, $this->fqcn);
195
+        }
196
+        return $this->locationInfo;
197
+    }
198 198
 
199
-	/**
200
-	 * Return the level of this event. Use this form instead of directly
201
-	 * accessing the {@link $level} field.
202
-	 * @return LoggerLevel	
203
-	 */
204
-	public function getLevel() {
205
-		return $this->level;
206
-	}
199
+    /**
200
+     * Return the level of this event. Use this form instead of directly
201
+     * accessing the {@link $level} field.
202
+     * @return LoggerLevel	
203
+     */
204
+    public function getLevel() {
205
+        return $this->level;
206
+    }
207 207
 
208
-	/**
209
-	 * Return the name of the logger. Use this form instead of directly
210
-	 * accessing the {@link $categoryName} field.
211
-	 * @return string  
212
-	 */
213
-	public function getLoggerName() {
214
-		return $this->categoryName;
215
-	}
208
+    /**
209
+     * Return the name of the logger. Use this form instead of directly
210
+     * accessing the {@link $categoryName} field.
211
+     * @return string  
212
+     */
213
+    public function getLoggerName() {
214
+        return $this->categoryName;
215
+    }
216 216
 
217
-	/**
218
-	 * Return the message for this logging event.
219
-	 *
220
-	 * <p>Before serialization, the returned object is the message
221
-	 * passed by the user to generate the logging event. After
222
-	 * serialization, the returned value equals the String form of the
223
-	 * message possibly after object rendering.
224
-	 * @return mixed
225
-	 */
226
-	public function getMessage() {
227
-		if($this->message !== null) {
228
-			return $this->message;
229
-		} else {
230
-			return $this->getRenderedMessage();
231
-		}
232
-	}
217
+    /**
218
+     * Return the message for this logging event.
219
+     *
220
+     * <p>Before serialization, the returned object is the message
221
+     * passed by the user to generate the logging event. After
222
+     * serialization, the returned value equals the String form of the
223
+     * message possibly after object rendering.
224
+     * @return mixed
225
+     */
226
+    public function getMessage() {
227
+        if($this->message !== null) {
228
+            return $this->message;
229
+        } else {
230
+            return $this->getRenderedMessage();
231
+        }
232
+    }
233 233
 
234
-	/**
235
-	 * This method returns the NDC for this event. It will return the
236
-	 * correct content even if the event was generated in a different
237
-	 * thread or even on a different machine. The {@link LoggerNDC::get()} method
238
-	 * should <b>never</b> be called directly.
239
-	 * @return string  
240
-	 */
241
-	public function getNDC() {
242
-		if($this->ndcLookupRequired) {
243
-			$this->ndcLookupRequired = false;
244
-			$this->ndc = implode(' ', LoggerNDC::get());
245
-		}
246
-		return $this->ndc;
247
-	}
234
+    /**
235
+     * This method returns the NDC for this event. It will return the
236
+     * correct content even if the event was generated in a different
237
+     * thread or even on a different machine. The {@link LoggerNDC::get()} method
238
+     * should <b>never</b> be called directly.
239
+     * @return string  
240
+     */
241
+    public function getNDC() {
242
+        if($this->ndcLookupRequired) {
243
+            $this->ndcLookupRequired = false;
244
+            $this->ndc = implode(' ', LoggerNDC::get());
245
+        }
246
+        return $this->ndc;
247
+    }
248 248
 
249
-	/**
250
-	 * Returns the the context corresponding to the <code>key</code>
251
-	 * parameter.
252
-	 * @return string
253
-	 */
254
-	public function getMDC($key) {
255
-		return LoggerMDC::get($key);
256
-	}
249
+    /**
250
+     * Returns the the context corresponding to the <code>key</code>
251
+     * parameter.
252
+     * @return string
253
+     */
254
+    public function getMDC($key) {
255
+        return LoggerMDC::get($key);
256
+    }
257 257
 
258
-	/**
259
-	 * Render message.
260
-	 * @return string
261
-	 */
262
-	public function getRenderedMessage() {
263
-		if($this->renderedMessage === null and $this->message !== null) {
264
-			if(is_string($this->message)) {
265
-					$this->renderedMessage = $this->message;
266
-			} else {
267
-			    // $this->logger might be null or an instance of Logger or RootLogger
268
-			    // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is
269
-			    // no need figure out which one is $this->logger part of.
270
-			    // TODO: Logger::getHierarchy() is marked @deprecated!
271
-				$repository = Logger::getHierarchy();
272
-				$rendererMap = $repository->getRendererMap();
273
-				$this->renderedMessage= $rendererMap->findAndRender($this->message);
274
-			}
275
-		}
276
-		return $this->renderedMessage;
277
-	}
258
+    /**
259
+     * Render message.
260
+     * @return string
261
+     */
262
+    public function getRenderedMessage() {
263
+        if($this->renderedMessage === null and $this->message !== null) {
264
+            if(is_string($this->message)) {
265
+                    $this->renderedMessage = $this->message;
266
+            } else {
267
+                // $this->logger might be null or an instance of Logger or RootLogger
268
+                // But in contrast to log4j, in log4php there is only have one LoggerHierarchy so there is
269
+                // no need figure out which one is $this->logger part of.
270
+                // TODO: Logger::getHierarchy() is marked @deprecated!
271
+                $repository = Logger::getHierarchy();
272
+                $rendererMap = $repository->getRendererMap();
273
+                $this->renderedMessage= $rendererMap->findAndRender($this->message);
274
+            }
275
+        }
276
+        return $this->renderedMessage;
277
+    }
278 278
 
279
-	/**
280
-	 * Returns the time when the application started, in seconds
281
-	 * elapsed since 01.01.1970 plus microseconds if available.
282
-	 *
283
-	 * @return float
284
-	 * @static
285
-	 */
286
-	public static function getStartTime() {
287
-		if(!isset(self::$startTime)) {
288
-			if (function_exists('microtime')) {
289
-				// microtime as float
290
-				self::$startTime = microtime(true);
291
-			} else {
292
-				self::$startTime = floatval(time());
293
-			}
294
-		}
295
-		return self::$startTime; 
296
-	}
279
+    /**
280
+     * Returns the time when the application started, in seconds
281
+     * elapsed since 01.01.1970 plus microseconds if available.
282
+     *
283
+     * @return float
284
+     * @static
285
+     */
286
+    public static function getStartTime() {
287
+        if(!isset(self::$startTime)) {
288
+            if (function_exists('microtime')) {
289
+                // microtime as float
290
+                self::$startTime = microtime(true);
291
+            } else {
292
+                self::$startTime = floatval(time());
293
+            }
294
+        }
295
+        return self::$startTime; 
296
+    }
297 297
 
298
-	/**
299
-	 * @return float
300
-	 */
301
-	public function getTimeStamp() {
302
-		return $this->timeStamp;
303
-	}
298
+    /**
299
+     * @return float
300
+     */
301
+    public function getTimeStamp() {
302
+        return $this->timeStamp;
303
+    }
304 304
 	
305
-	/**
306
-	 * Calculates the time of this event.
307
-	 * @return the time after event starttime when this event has occured
308
-	 */
309
-	public function getTime() {
305
+    /**
306
+     * Calculates the time of this event.
307
+     * @return the time after event starttime when this event has occured
308
+     */
309
+    public function getTime() {
310 310
         $eventTime = (float)$this->getTimeStamp();
311 311
         $eventStartTime = (float)LoggerLoggingEvent::getStartTime();
312 312
         return number_format(($eventTime - $eventStartTime) * 1000, 0, '', '');
313 313
     }
314 314
 	
315
-	/**
316
-	 * @return mixed
317
-	 */
318
-	public function getThreadName() {
319
-		if ($this->threadName === null) {
320
-			$this->threadName = (string)getmypid();
321
-		}
322
-		return $this->threadName;
323
-	}
315
+    /**
316
+     * @return mixed
317
+     */
318
+    public function getThreadName() {
319
+        if ($this->threadName === null) {
320
+            $this->threadName = (string)getmypid();
321
+        }
322
+        return $this->threadName;
323
+    }
324 324
 
325
-	/**
326
-	 * @return mixed null
327
-	 */
328
-	public function getThrowableInformation() {
329
-		return null;
330
-	}
325
+    /**
326
+     * @return mixed null
327
+     */
328
+    public function getThrowableInformation() {
329
+        return null;
330
+    }
331 331
 	
332
-	/**
333
-	 * Serialize this object
334
-	 * @return string
335
-	 */
336
-	public function toString() {
337
-		serialize($this);
338
-	}
332
+    /**
333
+     * Serialize this object
334
+     * @return string
335
+     */
336
+    public function toString() {
337
+        serialize($this);
338
+    }
339 339
 	
340
-	/**
341
-	 * Avoid serialization of the {@link $logger} object
342
-	 */
343
-	public function __sleep() {
344
-		return array(
345
-			'fqcn',
346
-			'categoryName',
347
-			'level',
348
-			'ndc',
349
-			'ndcLookupRequired',
350
-			'message',
351
-			'renderedMessage',
352
-			'threadName',
353
-			'timeStamp',
354
-			'locationInfo',
355
-		);
356
-	}
340
+    /**
341
+     * Avoid serialization of the {@link $logger} object
342
+     */
343
+    public function __sleep() {
344
+        return array(
345
+            'fqcn',
346
+            'categoryName',
347
+            'level',
348
+            'ndc',
349
+            'ndcLookupRequired',
350
+            'message',
351
+            'renderedMessage',
352
+            'threadName',
353
+            'timeStamp',
354
+            'locationInfo',
355
+        );
356
+    }
357 357
 
358 358
 }
359 359
 
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/LoggerReflectionUtils.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,6 +47,10 @@  discard block
 block discarded – undo
47 47
 	 * @static
48 48
 	 */
49 49
 	 // TODO: check, if this is really useful
50
+
51
+	/**
52
+	 * @param string $prefix
53
+	 */
50 54
 	public static function setPropertiesByObject($obj, $properties, $prefix) {
51 55
 		$pSetter = new LoggerReflectionUtils($obj);
52 56
 		return $pSetter->setProperties($properties, $prefix);
@@ -123,7 +127,7 @@  discard block
 block discarded – undo
123 127
 	/**
124 128
 	 * Creates an instances from the given class name.
125 129
 	 *
126
-	 * @param string $classname
130
+	 * @param string $class
127 131
 	 * @return an object from the class with the given classname
128 132
 	 */
129 133
 	public static function createObject($class) {
Please login to merge, or discard this patch.
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -18,123 +18,123 @@
 block discarded – undo
18 18
  * @package log4php
19 19
  */
20 20
  
21
- /**
22
-  * Provides methods for reflective use on php objects
23
-  * @package log4php
24
-  */
21
+    /**
22
+     * Provides methods for reflective use on php objects
23
+     * @package log4php
24
+     */
25 25
 class LoggerReflectionUtils {
26
-		/** the target object */
27
-	private $obj;
26
+        /** the target object */
27
+    private $obj;
28 28
   
29
-	/**
30
-	 * Create a new LoggerReflectionUtils for the specified Object. 
31
-	 * This is done in prepartion for invoking {@link setProperty()} 
32
-	 * one or more times.
33
-	 * @param object &$obj the object for which to set properties
34
-	 */
35
-	public function __construct($obj) {
36
-		$this->obj = $obj;
37
-	}
29
+    /**
30
+     * Create a new LoggerReflectionUtils for the specified Object. 
31
+     * This is done in prepartion for invoking {@link setProperty()} 
32
+     * one or more times.
33
+     * @param object &$obj the object for which to set properties
34
+     */
35
+    public function __construct($obj) {
36
+        $this->obj = $obj;
37
+    }
38 38
   
39
-	/**
40
-	 * Set the properties of an object passed as a parameter in one
41
-	 * go. The <code>properties</code> are parsed relative to a
42
-	 * <code>prefix</code>.
43
-	 *
44
-	 * @param object $obj The object to configure.
45
-	 * @param array $properties An array containing keys and values.
46
-	 * @param string $prefix Only keys having the specified prefix will be set.
47
-	 * @static
48
-	 */
49
-	 // TODO: check, if this is really useful
50
-	public static function setPropertiesByObject($obj, $properties, $prefix) {
51
-		$pSetter = new LoggerReflectionUtils($obj);
52
-		return $pSetter->setProperties($properties, $prefix);
53
-	}
39
+    /**
40
+     * Set the properties of an object passed as a parameter in one
41
+     * go. The <code>properties</code> are parsed relative to a
42
+     * <code>prefix</code>.
43
+     *
44
+     * @param object $obj The object to configure.
45
+     * @param array $properties An array containing keys and values.
46
+     * @param string $prefix Only keys having the specified prefix will be set.
47
+     * @static
48
+     */
49
+        // TODO: check, if this is really useful
50
+    public static function setPropertiesByObject($obj, $properties, $prefix) {
51
+        $pSetter = new LoggerReflectionUtils($obj);
52
+        return $pSetter->setProperties($properties, $prefix);
53
+    }
54 54
   
55 55
 
56
-	/**
57
-	 * Set the properites for the object that match the
58
-	 * <code>prefix</code> passed as parameter.
59
-	 * 
60
-	 * Example:
61
-	 * 
62
-	 * $arr['xxxname'] = 'Joe';
63
- 	 * $arr['xxxmale'] = true;
64
-	 * and prefix xxx causes setName and setMale.	
65
-	 *
66
-	 * @param array $properties An array containing keys and values.
67
-	 * @param string $prefix Only keys having the specified prefix will be set.
68
-	 */
69
-	 // TODO: check, if this is really useful
70
-	public function setProperties($properties, $prefix) {
71
-		$len = strlen($prefix);
72
-		while(list($key,) = each($properties)) {
73
-			if(strpos($key, $prefix) === 0) {
74
-				if(strpos($key, '.', ($len + 1)) > 0) {
75
-					continue;
76
-				}
77
-				$value = LoggerOptionConverter::findAndSubst($key, $properties);
78
-				$key = substr($key, $len);
79
-				if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
80
-					continue;
81
-				}
82
-				$this->setProperty($key, $value);
83
-			}
84
-		}
85
-		$this->activate();
86
-	}
56
+    /**
57
+     * Set the properites for the object that match the
58
+     * <code>prefix</code> passed as parameter.
59
+     * 
60
+     * Example:
61
+     * 
62
+     * $arr['xxxname'] = 'Joe';
63
+     * $arr['xxxmale'] = true;
64
+     * and prefix xxx causes setName and setMale.	
65
+     *
66
+     * @param array $properties An array containing keys and values.
67
+     * @param string $prefix Only keys having the specified prefix will be set.
68
+     */
69
+        // TODO: check, if this is really useful
70
+    public function setProperties($properties, $prefix) {
71
+        $len = strlen($prefix);
72
+        while(list($key,) = each($properties)) {
73
+            if(strpos($key, $prefix) === 0) {
74
+                if(strpos($key, '.', ($len + 1)) > 0) {
75
+                    continue;
76
+                }
77
+                $value = LoggerOptionConverter::findAndSubst($key, $properties);
78
+                $key = substr($key, $len);
79
+                if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
80
+                    continue;
81
+                }
82
+                $this->setProperty($key, $value);
83
+            }
84
+        }
85
+        $this->activate();
86
+    }
87 87
 	
88
-	/**
89
-	 * Set a property on this PropertySetter's Object. If successful, this
90
-	 * method will invoke a setter method on the underlying Object. The
91
-	 * setter is the one for the specified property name and the value is
92
-	 * determined partly from the setter argument type and partly from the
93
-	 * value specified in the call to this method.
94
-	 *
95
-	 * <p>If the setter expects a String no conversion is necessary.
96
-	 * If it expects an int, then an attempt is made to convert 'value'
97
-	 * to an int using new Integer(value). If the setter expects a boolean,
98
-	 * the conversion is by new Boolean(value).
99
-	 *
100
-	 * @param string $name	  name of the property
101
-	 * @param string $value	  String value of the property
102
-	 */
103
-	public function setProperty($name, $value) {
104
-		if($value === null) {
105
-			return;
106
-		}
88
+    /**
89
+     * Set a property on this PropertySetter's Object. If successful, this
90
+     * method will invoke a setter method on the underlying Object. The
91
+     * setter is the one for the specified property name and the value is
92
+     * determined partly from the setter argument type and partly from the
93
+     * value specified in the call to this method.
94
+     *
95
+     * <p>If the setter expects a String no conversion is necessary.
96
+     * If it expects an int, then an attempt is made to convert 'value'
97
+     * to an int using new Integer(value). If the setter expects a boolean,
98
+     * the conversion is by new Boolean(value).
99
+     *
100
+     * @param string $name	  name of the property
101
+     * @param string $value	  String value of the property
102
+     */
103
+    public function setProperty($name, $value) {
104
+        if($value === null) {
105
+            return;
106
+        }
107 107
 		
108
-		$method = "set" . ucfirst($name);
108
+        $method = "set" . ucfirst($name);
109 109
 		
110
-		if(!method_exists($this->obj, $method)) {
111
-			throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
112
-		} else {
113
-			return call_user_func(array($this->obj, $method), $value);
114
-		} 
115
-	}
110
+        if(!method_exists($this->obj, $method)) {
111
+            throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
112
+        } else {
113
+            return call_user_func(array($this->obj, $method), $value);
114
+        } 
115
+    }
116 116
   
117
-	public function activate() {
118
-		if(method_exists($this->obj, 'activateoptions')) {
119
-			return call_user_func(array($this->obj, 'activateoptions'));
120
-		} 
121
-	}
117
+    public function activate() {
118
+        if(method_exists($this->obj, 'activateoptions')) {
119
+            return call_user_func(array($this->obj, 'activateoptions'));
120
+        } 
121
+    }
122 122
 	
123
-	/**
124
-	 * Creates an instances from the given class name.
125
-	 *
126
-	 * @param string $classname
127
-	 * @return an object from the class with the given classname
128
-	 */
129
-	public static function createObject($class) {
130
-		if(!empty($class)) {
131
-			$class = basename($class);
132
-			return new $class();
133
-		}
134
-		return null;
135
-	}
123
+    /**
124
+     * Creates an instances from the given class name.
125
+     *
126
+     * @param string $classname
127
+     * @return an object from the class with the given classname
128
+     */
129
+    public static function createObject($class) {
130
+        if(!empty($class)) {
131
+            $class = basename($class);
132
+            return new $class();
133
+        }
134
+        return null;
135
+    }
136 136
 	
137
-	/**
137
+    /**
138 138
      * @param object $object
139 139
      * @param string $name
140 140
      * @param mixed $value
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 	 // TODO: check, if this is really useful
70 70
 	public function setProperties($properties, $prefix) {
71 71
 		$len = strlen($prefix);
72
-		while(list($key,) = each($properties)) {
73
-			if(strpos($key, $prefix) === 0) {
74
-				if(strpos($key, '.', ($len + 1)) > 0) {
72
+		while (list($key,) = each($properties)) {
73
+			if (strpos($key, $prefix) === 0) {
74
+				if (strpos($key, '.', ($len + 1)) > 0) {
75 75
 					continue;
76 76
 				}
77 77
 				$value = LoggerOptionConverter::findAndSubst($key, $properties);
78 78
 				$key = substr($key, $len);
79
-				if($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
79
+				if ($key == 'layout' and ($this->obj instanceof LoggerAppender)) {
80 80
 					continue;
81 81
 				}
82 82
 				$this->setProperty($key, $value);
@@ -101,13 +101,13 @@  discard block
 block discarded – undo
101 101
 	 * @param string $value	  String value of the property
102 102
 	 */
103 103
 	public function setProperty($name, $value) {
104
-		if($value === null) {
104
+		if ($value === null) {
105 105
 			return;
106 106
 		}
107 107
 		
108
-		$method = "set" . ucfirst($name);
108
+		$method = "set".ucfirst($name);
109 109
 		
110
-		if(!method_exists($this->obj, $method)) {
110
+		if (!method_exists($this->obj, $method)) {
111 111
 			throw new Exception("Error setting log4php property $name to $value: no method $method in class ".get_class($this->obj)."!");
112 112
 		} else {
113 113
 			return call_user_func(array($this->obj, $method), $value);
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	}
116 116
   
117 117
 	public function activate() {
118
-		if(method_exists($this->obj, 'activateoptions')) {
118
+		if (method_exists($this->obj, 'activateoptions')) {
119 119
 			return call_user_func(array($this->obj, 'activateoptions'));
120 120
 		} 
121 121
 	}
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 	 * @return an object from the class with the given classname
128 128
 	 */
129 129
 	public static function createObject($class) {
130
-		if(!empty($class)) {
130
+		if (!empty($class)) {
131 131
 			$class = basename($class);
132 132
 			return new $class();
133 133
 		}
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/lib/log4php/renderers/LoggerRendererMap.php 3 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,7 +58,6 @@  discard block
 block discarded – undo
58 58
 	 * Add a renderer to a hierarchy passed as parameter.
59 59
 	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60 60
 	 *
61
-	 * @param LoggerHierarchy $repository a logger repository.
62 61
 	 * @param string $renderedClassName
63 62
 	 * @param string $renderingClassName
64 63
 	 * @static
@@ -108,7 +107,7 @@  discard block
 block discarded – undo
108 107
 	 * class of the object parameter.
109 108
 	 * 
110 109
 	 * @param mixed $o
111
-	 * @return string
110
+	 * @return LoggerRendererObject
112 111
 	 */
113 112
 	public function getByObject($o) {
114 113
 		return ($o == null) ? null : $this->getByClassName(get_class($o));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	public function addRenderer($renderedClassName, $renderingClassName) {
67 67
 		$renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
-		if($renderer == null) {
68
+		if ($renderer == null) {
69 69
 			return;
70 70
 		} else {
71 71
 			$this->put($renderedClassName, $renderer);
@@ -86,12 +86,12 @@  discard block
 block discarded – undo
86 86
 	 * @return string 
87 87
 	 */
88 88
 	public function findAndRender($o) {
89
-		if($o == null) {
89
+		if ($o == null) {
90 90
 			return null;
91 91
 		} else {
92
-			if(is_object($o)) {
92
+			if (is_object($o)) {
93 93
 				$renderer = $this->getByObject($o);
94
-				if($renderer !== null) {
94
+				if ($renderer !== null) {
95 95
 					return $renderer->render($o);
96 96
 				} else {
97 97
 					return null;
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function getByClassName($class) {
128 128
 		$r = null;
129
-		for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
-			if(isset($this->map[$c])) {
129
+		for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
+			if (isset($this->map[$c])) {
131 131
 				return $this->map[$c];
132 132
 			}
133 133
 		}
Please login to merge, or discard this patch.
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -36,114 +36,114 @@
 block discarded – undo
36 36
  */
37 37
 class LoggerRendererMap {
38 38
 
39
-	/**
40
-	 * @var array
41
-	 */
42
-	private $map;
39
+    /**
40
+     * @var array
41
+     */
42
+    private $map;
43 43
 
44
-	/**
45
-	 * @var LoggerDefaultRenderer
46
-	 */
47
-	private $defaultRenderer;
44
+    /**
45
+     * @var LoggerDefaultRenderer
46
+     */
47
+    private $defaultRenderer;
48 48
 
49
-	/**
50
-	 * Constructor
51
-	 */
52
-	public function __construct() {
53
-		$this->map = array();
54
-		$this->defaultRenderer = new LoggerRendererDefault();
55
-	}
49
+    /**
50
+     * Constructor
51
+     */
52
+    public function __construct() {
53
+        $this->map = array();
54
+        $this->defaultRenderer = new LoggerRendererDefault();
55
+    }
56 56
 
57
-	/**
58
-	 * Add a renderer to a hierarchy passed as parameter.
59
-	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60
-	 *
61
-	 * @param LoggerHierarchy $repository a logger repository.
62
-	 * @param string $renderedClassName
63
-	 * @param string $renderingClassName
64
-	 * @static
65
-	 */
66
-	public function addRenderer($renderedClassName, $renderingClassName) {
67
-		$renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
-		if($renderer == null) {
69
-			return;
70
-		} else {
71
-			$this->put($renderedClassName, $renderer);
72
-		}
73
-	}
57
+    /**
58
+     * Add a renderer to a hierarchy passed as parameter.
59
+     * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
60
+     *
61
+     * @param LoggerHierarchy $repository a logger repository.
62
+     * @param string $renderedClassName
63
+     * @param string $renderingClassName
64
+     * @static
65
+     */
66
+    public function addRenderer($renderedClassName, $renderingClassName) {
67
+        $renderer = LoggerReflectionUtils::createObject($renderingClassName);
68
+        if($renderer == null) {
69
+            return;
70
+        } else {
71
+            $this->put($renderedClassName, $renderer);
72
+        }
73
+    }
74 74
 
75 75
 
76
-	/**
77
-	 * Find the appropriate renderer for the class type of the
78
-	 * <var>o</var> parameter. 
79
-	 *
80
-	 * This is accomplished by calling the {@link getByObject()} 
81
-	 * method if <var>o</var> is object or using {@link LoggerRendererDefault}. 
82
-	 * Once a renderer is found, it is applied on the object <var>o</var> and 
83
-	 * the result is returned as a string.
84
-	 *
85
-	 * @param mixed $o
86
-	 * @return string 
87
-	 */
88
-	public function findAndRender($o) {
89
-		if($o == null) {
90
-			return null;
91
-		} else {
92
-			if(is_object($o)) {
93
-				$renderer = $this->getByObject($o);
94
-				if($renderer !== null) {
95
-					return $renderer->render($o);
96
-				} else {
97
-					return null;
98
-				}
99
-			} else {
100
-				$renderer = $this->defaultRenderer;
101
-				return $renderer->render($o);
102
-			}
103
-		}
104
-	}
76
+    /**
77
+     * Find the appropriate renderer for the class type of the
78
+     * <var>o</var> parameter. 
79
+     *
80
+     * This is accomplished by calling the {@link getByObject()} 
81
+     * method if <var>o</var> is object or using {@link LoggerRendererDefault}. 
82
+     * Once a renderer is found, it is applied on the object <var>o</var> and 
83
+     * the result is returned as a string.
84
+     *
85
+     * @param mixed $o
86
+     * @return string 
87
+     */
88
+    public function findAndRender($o) {
89
+        if($o == null) {
90
+            return null;
91
+        } else {
92
+            if(is_object($o)) {
93
+                $renderer = $this->getByObject($o);
94
+                if($renderer !== null) {
95
+                    return $renderer->render($o);
96
+                } else {
97
+                    return null;
98
+                }
99
+            } else {
100
+                $renderer = $this->defaultRenderer;
101
+                return $renderer->render($o);
102
+            }
103
+        }
104
+    }
105 105
 
106
-	/**
107
-	 * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
108
-	 * class of the object parameter.
109
-	 * 
110
-	 * @param mixed $o
111
-	 * @return string
112
-	 */
113
-	public function getByObject($o) {
114
-		return ($o == null) ? null : $this->getByClassName(get_class($o));
115
-	}
106
+    /**
107
+     * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
108
+     * class of the object parameter.
109
+     * 
110
+     * @param mixed $o
111
+     * @return string
112
+     */
113
+    public function getByObject($o) {
114
+        return ($o == null) ? null : $this->getByClassName(get_class($o));
115
+    }
116 116
 
117 117
 
118
-	/**
119
-	 * Search the parents of <var>clazz</var> for a renderer. 
120
-	 *
121
-	 * The renderer closest in the hierarchy will be returned. If no
122
-	 * renderers could be found, then the default renderer is returned.
123
-	 *
124
-	 * @param string $class
125
-	 * @return LoggerRendererObject
126
-	 */
127
-	public function getByClassName($class) {
128
-		$r = null;
129
-		for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
-			if(isset($this->map[$c])) {
131
-				return $this->map[$c];
132
-			}
133
-		}
134
-		return $this->defaultRenderer;
135
-	}
118
+    /**
119
+     * Search the parents of <var>clazz</var> for a renderer. 
120
+     *
121
+     * The renderer closest in the hierarchy will be returned. If no
122
+     * renderers could be found, then the default renderer is returned.
123
+     *
124
+     * @param string $class
125
+     * @return LoggerRendererObject
126
+     */
127
+    public function getByClassName($class) {
128
+        $r = null;
129
+        for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
130
+            if(isset($this->map[$c])) {
131
+                return $this->map[$c];
132
+            }
133
+        }
134
+        return $this->defaultRenderer;
135
+    }
136 136
 
137
-	public function clear() {
138
-		$this->map = array();
139
-	}
137
+    public function clear() {
138
+        $this->map = array();
139
+    }
140 140
 
141
-	/**
142
-	 * Register a {@link LoggerRendererObject} for <var>clazz</var>.
143
-	 * @param string $class
144
-	 * @param LoggerRendererObject $or
145
-	 */
146
-	private function put($class, $or) {
147
-		$this->map[strtolower($class)] = $or;
148
-	}
141
+    /**
142
+     * Register a {@link LoggerRendererObject} for <var>clazz</var>.
143
+     * @param string $class
144
+     * @param LoggerRendererObject $or
145
+     */
146
+    private function put($class, $or) {
147
+        $this->map[strtolower($class)] = $or;
148
+    }
149 149
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/abstract_renderer.cls.php 5 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,6 @@
 block discarded – undo
98 98
   /**
99 99
    * Render a background image over a rectangular area
100 100
    *
101
-   * @param string $img      The background image to load
102 101
    * @param float  $x        The left edge of the rectangular area
103 102
    * @param float  $y        The top edge of the rectangular area
104 103
    * @param float  $width    The width of the rectangular area
Please login to merge, or discard this patch.
Indentation   +271 added lines, -271 removed lines patch added patch discarded remove patch
@@ -60,57 +60,57 @@  discard block
 block discarded – undo
60 60
  */
61 61
 abstract class Abstract_Renderer {
62 62
 
63
-  /**
64
-   * Rendering backend
65
-   *
66
-   * @var Canvas
67
-   */
68
-  protected $_canvas;
69
-
70
-  /**
71
-   * Current dompdf instance
72
-   *
73
-   * @var DOMPDF
74
-   */
75
-  protected $_dompdf;
63
+    /**
64
+     * Rendering backend
65
+     *
66
+     * @var Canvas
67
+     */
68
+    protected $_canvas;
69
+
70
+    /**
71
+     * Current dompdf instance
72
+     *
73
+     * @var DOMPDF
74
+     */
75
+    protected $_dompdf;
76 76
   
77
-  /**
78
-   * Class constructor
79
-   *
80
-   * @param DOMPDF $dompdf The current dompdf instance
81
-   */
82
-  function __construct(DOMPDF $dompdf) {
77
+    /**
78
+     * Class constructor
79
+     *
80
+     * @param DOMPDF $dompdf The current dompdf instance
81
+     */
82
+    function __construct(DOMPDF $dompdf) {
83 83
     $this->_dompdf = $dompdf;
84 84
     $this->_canvas = $dompdf->get_canvas();
85
-  }
85
+    }
86 86
   
87
-  /**
88
-   * Render a frame.
89
-   *
90
-   * Specialized in child classes
91
-   *
92
-   * @param Frame $frame The frame to render
93
-   */
94
-  abstract function render(Frame $frame);
95
-
96
-  //........................................................................
97
-
98
-  /**
99
-   * Render a background image over a rectangular area
100
-   *
101
-   * @param string $img      The background image to load
102
-   * @param float  $x        The left edge of the rectangular area
103
-   * @param float  $y        The top edge of the rectangular area
104
-   * @param float  $width    The width of the rectangular area
105
-   * @param float  $height   The height of the rectangular area
106
-   * @param Style  $style    The associated Style object
107
-   */
108
-  protected function _background_image($url, $x, $y, $width, $height, $style) {
87
+    /**
88
+     * Render a frame.
89
+     *
90
+     * Specialized in child classes
91
+     *
92
+     * @param Frame $frame The frame to render
93
+     */
94
+    abstract function render(Frame $frame);
95
+
96
+    //........................................................................
97
+
98
+    /**
99
+     * Render a background image over a rectangular area
100
+     *
101
+     * @param string $img      The background image to load
102
+     * @param float  $x        The left edge of the rectangular area
103
+     * @param float  $y        The top edge of the rectangular area
104
+     * @param float  $width    The width of the rectangular area
105
+     * @param float  $height   The height of the rectangular area
106
+     * @param Style  $style    The associated Style object
107
+     */
108
+    protected function _background_image($url, $x, $y, $width, $height, $style) {
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112 112
     if ( $width == 0 || $height == 0 )
113
-      return;
113
+        return;
114 114
 
115 115
     //debugpng
116 116
     if (DEBUGPNG) print '[_background_image '.$url.']';
@@ -122,24 +122,24 @@  discard block
 block discarded – undo
122 122
 
123 123
     // Bail if the image is no good
124 124
     if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
125
-      return;
125
+        return;
126 126
 
127
-	//Try to optimize away reading and composing of same background multiple times
128
-	//Postponing read with imagecreatefrom   ...()
129
-	//final composition paramters and name not known yet
130
-	//Therefore read dimension directly from file, instead of creating gd object first.
127
+    //Try to optimize away reading and composing of same background multiple times
128
+    //Postponing read with imagecreatefrom   ...()
129
+    //final composition paramters and name not known yet
130
+    //Therefore read dimension directly from file, instead of creating gd object first.
131 131
     //$img_w = imagesx($src); $img_h = imagesy($src);
132 132
 
133 133
     list($img_w, $img_h) = getimagesize($img);
134 134
     if (!isset($img_w) || $img_w == 0 || !isset($img_h) || $img_h == 0) {
135
-      return;
135
+        return;
136 136
     }
137 137
 
138 138
     $repeat = $style->background_repeat;
139 139
     $bg_color = $style->background_color;
140 140
 
141
-	//Increase background resolution and dependent box size according to image resolution to be placed in
142
-	//Then image can be copied in without resize
141
+    //Increase background resolution and dependent box size according to image resolution to be placed in
142
+    //Then image can be copied in without resize
143 143
     $bg_width = round((float)($width * DOMPDF_DPI) / 72);
144 144
     $bg_height = round((float)($height * DOMPDF_DPI) / 72);
145 145
 
@@ -148,27 +148,27 @@  discard block
 block discarded – undo
148 148
     list($bg_x, $bg_y) = $style->background_position;
149 149
 
150 150
     if ( is_percent($bg_x) ) {
151
-      // The point $bg_x % from the left edge of the image is placed
152
-      // $bg_x % from the left edge of the background rectangle
153
-      $p = ((float)$bg_x)/100.0;
154
-      $x1 = $p * $img_w;
155
-      $x2 = $p * $bg_width;
151
+        // The point $bg_x % from the left edge of the image is placed
152
+        // $bg_x % from the left edge of the background rectangle
153
+        $p = ((float)$bg_x)/100.0;
154
+        $x1 = $p * $img_w;
155
+        $x2 = $p * $bg_width;
156 156
 
157
-      $bg_x = round($x2 - $x1);
157
+        $bg_x = round($x2 - $x1);
158 158
     } else {
159
-      $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
159
+        $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
160 160
     }
161 161
 
162 162
     if ( is_percent($bg_y) ) {
163
-      // The point $bg_y % from the left edge of the image is placed
164
-      // $bg_y % from the left edge of the background rectangle
165
-      $p = ((float)$bg_y)/100.0;
166
-      $y1 = $p * $img_h;
167
-      $y2 = $p * $bg_height;
163
+        // The point $bg_y % from the left edge of the image is placed
164
+        // $bg_y % from the left edge of the background rectangle
165
+        $p = ((float)$bg_y)/100.0;
166
+        $y1 = $p * $img_h;
167
+        $y2 = $p * $bg_height;
168 168
 
169
-      $bg_y = round($y2 - $y1);
169
+        $bg_y = round($y2 - $y1);
170 170
     } else {
171
-      $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
171
+        $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
172 172
     }
173 173
 
174 174
     //clip background to the image area on partial repeat. Nothing to do if img off area
@@ -177,79 +177,79 @@  discard block
 block discarded – undo
177 177
     //Handle x/y Dimensions separately
178 178
 
179 179
     if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) {
180
-      //No repeat x
181
-      if ($bg_x < 0) {
180
+        //No repeat x
181
+        if ($bg_x < 0) {
182 182
         $bg_width = $img_w + $bg_x;
183
-      } else {
183
+        } else {
184 184
         $x += ($bg_x * 72)/DOMPDF_DPI;
185 185
         $bg_width = $bg_width - $bg_x;
186 186
         if ($bg_width > $img_w) {
187
-          $bg_width = $img_w;
187
+            $bg_width = $img_w;
188 188
         }
189 189
         $bg_x = 0;
190
-      }
191
-      if ($bg_width <= 0) {
192
-      	return;
193
-      }
194
-      $width = (float)($bg_width * 72)/DOMPDF_DPI;
190
+        }
191
+        if ($bg_width <= 0) {
192
+            return;
193
+        }
194
+        $width = (float)($bg_width * 72)/DOMPDF_DPI;
195 195
     } else {
196
-      //repeat x
197
-      if ($bg_x < 0) {
196
+        //repeat x
197
+        if ($bg_x < 0) {
198 198
         $bg_x = - ((-$bg_x) % $img_w);
199
-      } else {
199
+        } else {
200 200
         $bg_x = $bg_x % $img_w;
201 201
         if ($bg_x > 0) {
202
-          $bg_x -= $img_w;
202
+            $bg_x -= $img_w;
203
+        }
203 204
         }
204
-      }
205 205
     }
206 206
 
207 207
     if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) {
208
-      //no repeat y
209
-      if ($bg_y < 0) {
208
+        //no repeat y
209
+        if ($bg_y < 0) {
210 210
         $bg_height = $img_h + $bg_y;
211
-      } else {
211
+        } else {
212 212
         $y += ($bg_y * 72)/DOMPDF_DPI;
213 213
         $bg_height = $bg_height - $bg_y;
214 214
         if ($bg_height > $img_h) {
215
-          $bg_height = $img_h;
215
+            $bg_height = $img_h;
216 216
         }
217 217
         $bg_y = 0;
218
-      }
219
-      if ($bg_height <= 0) {
220
-      	return;
221
-      }
222
-      $height = (float)($bg_height * 72)/DOMPDF_DPI;
218
+        }
219
+        if ($bg_height <= 0) {
220
+            return;
221
+        }
222
+        $height = (float)($bg_height * 72)/DOMPDF_DPI;
223 223
     } else {
224
-      //repeat y
225
-      if ($bg_y < 0) {
224
+        //repeat y
225
+        if ($bg_y < 0) {
226 226
         $bg_y = - ((-$bg_y) % $img_h);
227
-      } else {
227
+        } else {
228 228
         $bg_y = $bg_y % $img_h;
229 229
         if ($bg_y > 0) {
230
-          $bg_y -= $img_h;
230
+            $bg_y -= $img_h;
231
+        }
231 232
         }
232
-      }
233 233
     }
234 234
 
235 235
     //Optimization, if repeat has no effect
236 236
     if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) {
237
-      $repeat = "repeat-x";
237
+        $repeat = "repeat-x";
238 238
     }
239 239
     if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) {
240
-      $repeat = "repeat-y";
240
+        $repeat = "repeat-y";
241 241
     }
242 242
     if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) ||
243 243
          ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) {
244
-      $repeat = "no-repeat";
244
+        $repeat = "no-repeat";
245 245
     }
246 246
 
247
-	//Use filename as indicator only
248
-	//different names for different variants to have different copies in the pdf
249
-	//This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
250
-	//Note: Here, bg_* are the start values, not end values after going through the tile loops!
247
+    //Use filename as indicator only
248
+    //different names for different variants to have different copies in the pdf
249
+    //This is not dependent of background color of box! .'_'.(is_array($bg_color) ? $bg_color["hex"] : $bg_color)
250
+    //Note: Here, bg_* are the start values, not end values after going through the tile loops!
251 251
 
252
-	$filedummy = $img;
252
+    $filedummy = $img;
253 253
 
254 254
     /* 
255 255
     //Make shorter strings with limited characters for cache associative array index - needed?	
@@ -274,50 +274,50 @@  discard block
 block discarded – undo
274 274
 	}
275 275
 	*/
276 276
 	
277
-	$filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat;
277
+    $filedummy .= '_'.$bg_width.'_'.$bg_height.'_'.$bg_x.'_'.$bg_y.'_'.$repeat;
278 278
     //debugpng
279 279
     //if (DEBUGPNG) print '<pre>[_background_image name '.$filedummy.']</pre>';
280 280
 
281 281
     //Optimization to avoid multiple times rendering the same image.
282 282
     //If check functions are existing and identical image already cached,
283 283
     //then skip creation of duplicate, because it is not needed by addImagePng
284
-	if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
-	     method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
-	     method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
-	     $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
288
-	  $bg = null;
284
+    if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
+         method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
+         method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
+         $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
288
+        $bg = null;
289 289
 
290
-      //debugpng
291
-      //if (DEBUGPNG) print '[_background_image skip]';
290
+        //debugpng
291
+        //if (DEBUGPNG) print '[_background_image skip]';
292 292
 
293
-	} else {
293
+    } else {
294 294
 
295 295
     // Create a new image to fit over the background rectangle
296 296
     $bg = imagecreatetruecolor($bg_width, $bg_height);
297 297
     //anyway default
298
-	//imagealphablending($img, true);
298
+    //imagealphablending($img, true);
299 299
 
300 300
     switch (strtolower($ext)) {
301 301
 
302 302
     case "png":
303 303
       $src = imagecreatefrompng($img);
304
-      break;
304
+        break;
305 305
 
306 306
     case "jpg":
307 307
     case "jpeg":
308 308
       $src = imagecreatefromjpeg($img);
309
-      break;
309
+        break;
310 310
 
311 311
     case "gif":
312 312
       $src = imagecreatefromgif($img);
313
-      break;
313
+        break;
314 314
 
315 315
     default:
316 316
       return; // Unsupported image type
317 317
     }
318 318
 
319 319
     if ($src == null) {
320
-      return;
320
+        return;
321 321
     }
322 322
 
323 323
     //Background color if box is not relevant here
@@ -325,34 +325,34 @@  discard block
 block discarded – undo
325 325
     //Transparent image: The image controls the transparency and lets shine through whatever background.
326 326
     //However on transparent imaage preset the composed image with the transparency color,
327 327
     //to keep the transparency when copying over the non transparent parts of the tiles.
328
-	$ti = imagecolortransparent($src);
329
-	if ($ti >= 0) {
330
-	  $tc = imagecolorsforindex($src,$ti);
331
-      $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
-      imagefill($bg,0,0,$ti);
333
-      imagecolortransparent($bg, $ti);
328
+    $ti = imagecolortransparent($src);
329
+    if ($ti >= 0) {
330
+        $tc = imagecolorsforindex($src,$ti);
331
+        $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
+        imagefill($bg,0,0,$ti);
333
+        imagecolortransparent($bg, $ti);
334 334
     }
335 335
 
336 336
     //This has only an effect for the non repeatable dimension.
337 337
     //compute start of src and dest coordinates of the single copy
338 338
     if ( $bg_x < 0 ) {
339
-      $dst_x = 0;
340
-      $src_x = -$bg_x;
339
+        $dst_x = 0;
340
+        $src_x = -$bg_x;
341 341
     } else {
342
-      $src_x = 0;
343
-      $dst_x = $bg_x;
342
+        $src_x = 0;
343
+        $dst_x = $bg_x;
344 344
     }
345 345
 
346 346
     if ( $bg_y < 0 ) {
347
-      $dst_y = 0;
348
-      $src_y = -$bg_y;
347
+        $dst_y = 0;
348
+        $src_y = -$bg_y;
349 349
     } else {
350
-      $src_y = 0;
351
-      $dst_y = $bg_y;
350
+        $src_y = 0;
351
+        $dst_y = $bg_y;
352 352
     }
353 353
 
354
-	//For historical reasons exchange meanings of variables:
355
-	//start_* will be the start values, while bg_* will be the temporary start values in the loops
354
+    //For historical reasons exchange meanings of variables:
355
+    //start_* will be the start values, while bg_* will be the temporary start values in the loops
356 356
     $start_x = $bg_x;
357 357
     $start_y = $bg_y;
358 358
 
@@ -360,117 +360,117 @@  discard block
 block discarded – undo
360 360
 
361 361
     if ( $repeat === "no-repeat" ) {
362 362
 
363
-      // Simply place the image on the background
364
-      imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
363
+        // Simply place the image on the background
364
+        imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
365 365
 
366 366
     } else if ( $repeat === "repeat-x" ) {
367 367
 
368
-      for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
368
+        for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
369 369
         if ( $bg_x < 0 ) {
370
-          $dst_x = 0;
371
-          $src_x = -$bg_x;
372
-          $w = $img_w + $bg_x;
370
+            $dst_x = 0;
371
+            $src_x = -$bg_x;
372
+            $w = $img_w + $bg_x;
373 373
         } else {
374
-          $dst_x = $bg_x;
375
-          $src_x = 0;
376
-          $w = $img_w;
374
+            $dst_x = $bg_x;
375
+            $src_x = 0;
376
+            $w = $img_w;
377 377
         }
378 378
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
379
-      }
379
+        }
380 380
 
381 381
     } else if ( $repeat === "repeat-y" ) {
382 382
 
383
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
383
+        for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
384 384
         if ( $bg_y < 0 ) {
385
-          $dst_y = 0;
386
-          $src_y = -$bg_y;
387
-          $h = $img_h + $bg_y;
385
+            $dst_y = 0;
386
+            $src_y = -$bg_y;
387
+            $h = $img_h + $bg_y;
388 388
         } else {
389
-          $dst_y = $bg_y;
390
-          $src_y = 0;
391
-          $h = $img_h;
389
+            $dst_y = $bg_y;
390
+            $src_y = 0;
391
+            $h = $img_h;
392 392
         }
393 393
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $h);
394 394
 
395
-      }
395
+        }
396 396
 
397 397
     } else if ( $repeat === "repeat" ) {
398 398
 
399
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
399
+        for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
400 400
         for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
401 401
 
402
-          if ( $bg_x < 0 ) {
402
+            if ( $bg_x < 0 ) {
403 403
             $dst_x = 0;
404 404
             $src_x = -$bg_x;
405 405
             $w = $img_w + $bg_x;
406
-          } else {
406
+            } else {
407 407
             $dst_x = $bg_x;
408 408
             $src_x = 0;
409 409
             $w = $img_w;
410
-          }
410
+            }
411 411
 
412
-          if ( $bg_y < 0 ) {
412
+            if ( $bg_y < 0 ) {
413 413
             $dst_y = 0;
414 414
             $src_y = -$bg_y;
415 415
             $h = $img_h + $bg_y;
416
-          } else {
416
+            } else {
417 417
             $dst_y = $bg_y;
418 418
             $src_y = 0;
419 419
             $h = $img_h;
420
-          }
421
-          imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
420
+            }
421
+            imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $h);
422
+        }
422 423
         }
423
-      }
424 424
     } else {
425
- print 'Unknown repeat!';
425
+    print 'Unknown repeat!';
426 426
     }   
427 427
 
428 428
     } /* End optimize away creation of duplicates */
429 429
 
430 430
     //img: image url string
431
-	//img_w, img_h: original image size in px
432
-	//width, height: box size in pt
433
-	//bg_width, bg_height: box size in px
434
-	//x, y: left/top edge of box on page in pt
435
-	//start_x, start_y: placement of image relativ to pattern
436
-	//$repeat: repeat mode
437
-	//$bg: GD object of result image
438
-	//$src: GD object of original image
431
+    //img_w, img_h: original image size in px
432
+    //width, height: box size in pt
433
+    //bg_width, bg_height: box size in px
434
+    //x, y: left/top edge of box on page in pt
435
+    //start_x, start_y: placement of image relativ to pattern
436
+    //$repeat: repeat mode
437
+    //$bg: GD object of result image
438
+    //$src: GD object of original image
439 439
     //When using cpdf and optimization to direct png creation from gd object is available,
440 440
     //don't create temp file, but place gd object directly into the pdf
441
-	if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
442
-      //Note: CPDF_Adapter image converts y position
443
-	  $this->_canvas->get_cpdf()->addImagePng(
444
-	  		$filedummy,
445
-			$x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
446
-	} else {
447
-      $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448
-      //debugpng
449
-      if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
441
+    if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
442
+        //Note: CPDF_Adapter image converts y position
443
+        $this->_canvas->get_cpdf()->addImagePng(
444
+                $filedummy,
445
+            $x, $this->_canvas->get_height() - $y - $height, $width, $height, $bg);
446
+    } else {
447
+        $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448
+        //debugpng
449
+        if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
450 450
 
451
-      imagepng($bg, $tmp_file);
452
-      $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
451
+        imagepng($bg, $tmp_file);
452
+        $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
453 453
 
454
-      //debugpng
455
-      if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
454
+        //debugpng
455
+        if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
456 456
 
457
-      if (!DEBUGKEEPTEMP)
457
+        if (!DEBUGKEEPTEMP)
458 458
         unlink($tmp_file);
459 459
     }
460
-  }
460
+    }
461 461
 
462
-  protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
462
+    protected function _border_none($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
463 463
     return;
464
-  }
464
+    }
465 465
   
466
-  // Border rendering functions
467
-  protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
466
+    // Border rendering functions
467
+    protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 468
     list($top, $right, $bottom, $left) = $widths;
469 469
 
470 470
     if ( $$side < 2 )
471
-      $dash = array($$side, 2);
471
+        $dash = array($$side, 2);
472 472
     else
473
-      $dash = array($$side);
473
+        $dash = array($$side);
474 474
   
475 475
     
476 476
     switch ($side) {
@@ -479,24 +479,24 @@  discard block
 block discarded – undo
479 479
       $delta = $top / 2;
480 480
     case "bottom":
481 481
       $delta = isset($delta) ? $delta : -$bottom / 2;
482
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
-      break;
482
+        $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
+        break;
484 484
 
485 485
     case "left":
486 486
       $delta = $left / 2;
487 487
     case "right":
488 488
       $delta = isset($delta) ? $delta : - $right / 2;
489
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
-      break;
489
+        $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
+        break;
491 491
 
492 492
     default:
493 493
       return;
494 494
 
495 495
     }
496
-  }
496
+    }
497 497
 
498 498
   
499
-  protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
499
+    protected function _border_dashed($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
500 500
     list($top, $right, $bottom, $left) = $widths;
501 501
 
502 502
     switch ($side) {
@@ -505,24 +505,24 @@  discard block
 block discarded – undo
505 505
       $delta = $top / 2;
506 506
     case "bottom":
507 507
       $delta = isset($delta) ? $delta : -$bottom / 2;
508
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
-      break;
508
+        $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
+        break;
510 510
 
511 511
     case "left":
512 512
       $delta = $left / 2;
513 513
     case "right":
514 514
       $delta = isset($delta) ? $delta : - $right / 2;
515
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
-      break;
515
+        $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
+        break;
517 517
 
518 518
     default:
519 519
       return;
520 520
     }
521 521
     
522
-  }
522
+    }
523 523
 
524 524
   
525
-  protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
525
+    protected function _border_solid($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
526 526
     list($top, $right, $bottom, $left) = $widths;
527 527
 
528 528
     // All this polygon business is for beveled corners...
@@ -536,10 +536,10 @@  discard block
 block discarded – undo
536 536
                         $x + $length - $right, $y + $top,
537 537
                         $x + $left, $y + $top);
538 538
         $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
539
+        } else
540 540
         $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
541 541
       
542
-      break;
542
+        break;
543 543
       
544 544
     case "bottom":
545 545
       if ( $corner_style === "bevel" ) {
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
                         $x + $length - $right, $y - $bottom,
549 549
                         $x + $left, $y - $bottom);
550 550
         $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
551
+        } else
552 552
         $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
553 553
       
554
-      break;
554
+        break;
555 555
       
556 556
     case "left":
557 557
       if ( $corner_style === "bevel" ) {
@@ -560,10 +560,10 @@  discard block
 block discarded – undo
560 560
                         $x + $left, $y + $length - $bottom,
561 561
                         $x + $left, $y + $top);
562 562
         $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
563
+        } else
564 564
         $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
565 565
       
566
-      break;
566
+        break;
567 567
       
568 568
     case "right":
569 569
       if ( $corner_style === "bevel" ) {
@@ -572,20 +572,20 @@  discard block
 block discarded – undo
572 572
                         $x - $right, $y + $length - $bottom,
573 573
                         $x - $right, $y + $top);
574 574
         $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
575
+        } else
576 576
         $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577 577
 
578
-      break;
578
+        break;
579 579
 
580 580
     default:
581 581
       return;
582 582
 
583 583
     }
584 584
         
585
-  }
585
+    }
586 586
 
587 587
 
588
-  protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
588
+    protected function _border_double($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
589 589
     list($top, $right, $bottom, $left) = $widths;
590 590
     
591 591
     $line_width = $$side / 4;
@@ -612,12 +612,12 @@  discard block
 block discarded – undo
612 612
                         $x + $left, $y + $top);
613 613
         $this->_canvas->polygon($points, $color, null, null, true);
614 614
 
615
-      } else {
615
+        } else {
616 616
         $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617 617
         $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
618 618
 
619
-      }
620
-      break;
619
+        }
620
+        break;
621 621
       
622 622
     case "bottom":
623 623
       if ( $corner_style === "bevel" ) {
@@ -636,12 +636,12 @@  discard block
 block discarded – undo
636 636
                         $x + $left, $y - $bottom);
637 637
         $this->_canvas->polygon($points, $color, null, null, true);
638 638
 
639
-      } else {
639
+        } else {
640 640
         $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641 641
         $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
-      }
642
+        }
643 643
           
644
-      break;
644
+        break;
645 645
 
646 646
     case "left":
647 647
       if ( $corner_style === "bevel" ) {
@@ -660,12 +660,12 @@  discard block
 block discarded – undo
660 660
                         $x + $left, $y + $top);
661 661
         $this->_canvas->polygon($points, $color, null, null, true);
662 662
 
663
-      } else {
663
+        } else {
664 664
         $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665 665
         $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
-      }
666
+        }
667 667
       
668
-      break;
668
+        break;
669 669
                       
670 670
     case "right":
671 671
       if ( $corner_style === "bevel" ) {
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         
675 675
       
676 676
         $points = array($x, $y,
677
-                      $x, $y + $length,
677
+                        $x, $y + $length,
678 678
                         $x - $line_width, $y + $length - $bottom_line_width,
679 679
                         $x - $line_width, $y + $top_line_width);
680 680
         $this->_canvas->polygon($points, $color, null, null, true);
@@ -685,21 +685,21 @@  discard block
 block discarded – undo
685 685
                         $x - $right, $y + $top);
686 686
         $this->_canvas->polygon($points, $color, null, null, true);
687 687
 
688
-      } else {
688
+        } else {
689 689
         $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690 690
         $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
-      }
691
+        }
692 692
       
693
-      break;
693
+        break;
694 694
 
695 695
     default:
696 696
       return;
697 697
 
698 698
     }
699 699
         
700
-  }
700
+    }
701 701
 
702
-  protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
702
+    protected function _border_groove($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
703 703
     list($top, $right, $bottom, $left) = $widths;
704 704
       
705 705
     $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2);
@@ -710,27 +710,27 @@  discard block
 block discarded – undo
710 710
 
711 711
     case "top":
712 712
       $x += $left / 2;
713
-      $y += $top / 2;
714
-      $length -= $left / 2 + $right / 2;
715
-      break;
713
+        $y += $top / 2;
714
+        $length -= $left / 2 + $right / 2;
715
+        break;
716 716
 
717 717
     case "bottom":
718 718
       $x += $left / 2;
719
-      $y -= $bottom / 2;
720
-      $length -= $left / 2 + $right / 2;
721
-      break;
719
+        $y -= $bottom / 2;
720
+        $length -= $left / 2 + $right / 2;
721
+        break;
722 722
 
723 723
     case "left":
724 724
       $x += $left / 2;
725
-      $y += $top / 2;
726
-      $length -= $top / 2 + $bottom / 2;
727
-      break;
725
+        $y += $top / 2;
726
+        $length -= $top / 2 + $bottom / 2;
727
+        break;
728 728
 
729 729
     case "right":
730 730
       $x -= $right / 2;
731
-      $y += $top / 2;
732
-      $length -= $top / 2 + $bottom / 2;
733
-      break;
731
+        $y += $top / 2;
732
+        $length -= $top / 2 + $bottom / 2;
733
+        break;
734 734
 
735 735
     default:
736 736
       return;
@@ -739,9 +739,9 @@  discard block
 block discarded – undo
739 739
 
740 740
     $this->_border_outset($x, $y, $length, $color, $half_widths, $side);
741 741
     
742
-  }
742
+    }
743 743
   
744
-  protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
744
+    protected function _border_ridge($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
745 745
     list($top, $right, $bottom, $left) = $widths;
746 746
      
747 747
     $half_widths = array($top / 2, $right / 2, $bottom / 2, $left / 2);
@@ -752,27 +752,27 @@  discard block
 block discarded – undo
752 752
 
753 753
     case "top":
754 754
       $x += $left / 2;
755
-      $y += $top / 2;
756
-      $length -= $left / 2 + $right / 2;
757
-      break;
755
+        $y += $top / 2;
756
+        $length -= $left / 2 + $right / 2;
757
+        break;
758 758
 
759 759
     case "bottom":
760 760
       $x += $left / 2;
761
-      $y -= $bottom / 2;
762
-      $length -= $left / 2 + $right / 2;
763
-      break;
761
+        $y -= $bottom / 2;
762
+        $length -= $left / 2 + $right / 2;
763
+        break;
764 764
 
765 765
     case "left":
766 766
       $x += $left / 2;
767
-      $y += $top / 2;
768
-      $length -= $top / 2 + $bottom / 2;
769
-      break;
767
+        $y += $top / 2;
768
+        $length -= $top / 2 + $bottom / 2;
769
+        break;
770 770
 
771 771
     case "right":
772 772
       $x -= $right / 2;
773
-      $y += $top / 2;
774
-      $length -= $top / 2 + $bottom / 2;
775
-      break;
773
+        $y += $top / 2;
774
+        $length -= $top / 2 + $bottom / 2;
775
+        break;
776 776
 
777 777
     default:
778 778
       return;
@@ -781,23 +781,23 @@  discard block
 block discarded – undo
781 781
 
782 782
     $this->_border_inset($x, $y, $length, $color, $half_widths, $side);
783 783
 
784
-  }
784
+    }
785 785
 
786
-  protected function _tint($c) {
786
+    protected function _tint($c) {
787 787
     if ( !is_numeric($c) )
788
-      return $c;
788
+        return $c;
789 789
     
790 790
     return min(1, $c + 0.66);
791
-  }
791
+    }
792 792
 
793
-  protected function _shade($c) {
793
+    protected function _shade($c) {
794 794
     if ( !is_numeric($c) )
795
-      return $c;
795
+        return $c;
796 796
     
797 797
     return max(0, $c - 0.66);
798
-  }
798
+    }
799 799
 
800
-  protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
800
+    protected function _border_inset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
801 801
     list($top, $right, $bottom, $left) = $widths;
802 802
     
803 803
     switch ($side) {
@@ -805,43 +805,43 @@  discard block
 block discarded – undo
805 805
     case "top":
806 806
     case "left":
807 807
       $shade = array_map(array($this, "_shade"), $color);
808
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
-      break;
808
+        $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
+        break;
810 810
 
811 811
     case "bottom":
812 812
     case "right":
813 813
       $tint = array_map(array($this, "_tint"), $color);
814
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
-      break;
814
+        $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
+        break;
816 816
 
817 817
     default:
818 818
       return;
819 819
     }
820
-  }
820
+    }
821 821
   
822
-  protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
822
+    protected function _border_outset($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
823 823
     list($top, $right, $bottom, $left) = $widths;
824 824
     
825 825
     switch ($side) {
826 826
     case "top":
827 827
     case "left":
828 828
       $tint = array_map(array($this, "_tint"), $color);
829
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
-      break;
829
+        $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
+        break;
831 831
 
832 832
     case "bottom":
833 833
     case "right":
834 834
       $shade = array_map(array($this, "_shade"), $color);
835
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
-      break;
835
+        $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
+        break;
837 837
 
838 838
     default:
839 839
       return;
840 840
 
841 841
     }
842
-  }
842
+    }
843 843
 
844
-  //........................................................................
844
+    //........................................................................
845 845
   
846 846
 
847 847
 }
Please login to merge, or discard this patch.
Switch Indentation   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -299,21 +299,21 @@  discard block
 block discarded – undo
299 299
 
300 300
     switch (strtolower($ext)) {
301 301
 
302
-    case "png":
303
-      $src = imagecreatefrompng($img);
304
-      break;
302
+        case "png":
303
+          $src = imagecreatefrompng($img);
304
+          break;
305 305
 
306
-    case "jpg":
307
-    case "jpeg":
308
-      $src = imagecreatefromjpeg($img);
309
-      break;
306
+        case "jpg":
307
+        case "jpeg":
308
+          $src = imagecreatefromjpeg($img);
309
+          break;
310 310
 
311
-    case "gif":
312
-      $src = imagecreatefromgif($img);
313
-      break;
311
+        case "gif":
312
+          $src = imagecreatefromgif($img);
313
+          break;
314 314
 
315
-    default:
316
-      return; // Unsupported image type
315
+        default:
316
+          return; // Unsupported image type
317 317
     }
318 318
 
319 319
     if ($src == null) {
@@ -475,22 +475,22 @@  discard block
 block discarded – undo
475 475
     
476 476
     switch ($side) {
477 477
 
478
-    case "top":
479
-      $delta = $top / 2;
480
-    case "bottom":
481
-      $delta = isset($delta) ? $delta : -$bottom / 2;
482
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
-      break;
484
-
485
-    case "left":
486
-      $delta = $left / 2;
487
-    case "right":
488
-      $delta = isset($delta) ? $delta : - $right / 2;
489
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
-      break;
491
-
492
-    default:
493
-      return;
478
+        case "top":
479
+          $delta = $top / 2;
480
+        case "bottom":
481
+          $delta = isset($delta) ? $delta : -$bottom / 2;
482
+          $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, $dash);
483
+          break;
484
+
485
+        case "left":
486
+          $delta = $left / 2;
487
+        case "right":
488
+          $delta = isset($delta) ? $delta : - $right / 2;
489
+          $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, $dash);
490
+          break;
491
+
492
+        default:
493
+          return;
494 494
 
495 495
     }
496 496
   }
@@ -501,22 +501,22 @@  discard block
 block discarded – undo
501 501
 
502 502
     switch ($side) {
503 503
 
504
-    case "top":
505
-      $delta = $top / 2;
506
-    case "bottom":
507
-      $delta = isset($delta) ? $delta : -$bottom / 2;
508
-      $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
-      break;
510
-
511
-    case "left":
512
-      $delta = $left / 2;
513
-    case "right":
514
-      $delta = isset($delta) ? $delta : - $right / 2;
515
-      $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
-      break;
517
-
518
-    default:
519
-      return;
504
+        case "top":
505
+          $delta = $top / 2;
506
+        case "bottom":
507
+          $delta = isset($delta) ? $delta : -$bottom / 2;
508
+          $this->_canvas->line($x, $y + $delta, $x + $length, $y + $delta, $color, $$side, array(3 * $$side));
509
+          break;
510
+
511
+        case "left":
512
+          $delta = $left / 2;
513
+        case "right":
514
+          $delta = isset($delta) ? $delta : - $right / 2;
515
+          $this->_canvas->line($x + $delta, $y, $x + $delta, $y + $length, $color, $$side, array(3 * $$side));
516
+          break;
517
+
518
+        default:
519
+          return;
520 520
     }
521 521
     
522 522
   }
@@ -528,57 +528,57 @@  discard block
 block discarded – undo
528 528
     // All this polygon business is for beveled corners...
529 529
     switch ($side) {
530 530
 
531
-    case "top":
532
-      if ( $corner_style === "bevel" ) {
531
+        case "top":
532
+          if ( $corner_style === "bevel" ) {
533 533
         
534
-        $points = array($x, $y,
535
-                        $x + $length, $y,
536
-                        $x + $length - $right, $y + $top,
537
-                        $x + $left, $y + $top);
538
-        $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
540
-        $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
534
+            $points = array($x, $y,
535
+                            $x + $length, $y,
536
+                            $x + $length - $right, $y + $top,
537
+                            $x + $left, $y + $top);
538
+            $this->_canvas->polygon($points, $color, null, null, true);
539
+          } else
540
+            $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
541 541
       
542
-      break;
542
+          break;
543 543
       
544
-    case "bottom":
545
-      if ( $corner_style === "bevel" ) {
546
-        $points = array($x, $y,
547
-                        $x + $length, $y,
548
-                        $x + $length - $right, $y - $bottom,
549
-                        $x + $left, $y - $bottom);
550
-        $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
552
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
544
+        case "bottom":
545
+          if ( $corner_style === "bevel" ) {
546
+            $points = array($x, $y,
547
+                            $x + $length, $y,
548
+                            $x + $length - $right, $y - $bottom,
549
+                            $x + $left, $y - $bottom);
550
+            $this->_canvas->polygon($points, $color, null, null, true);
551
+          } else
552
+            $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
553 553
       
554
-      break;
554
+          break;
555 555
       
556
-    case "left":
557
-      if ( $corner_style === "bevel" ) {
558
-        $points = array($x, $y,
559
-                        $x, $y + $length,
560
-                        $x + $left, $y + $length - $bottom,
561
-                        $x + $left, $y + $top);
562
-        $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
564
-        $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
556
+        case "left":
557
+          if ( $corner_style === "bevel" ) {
558
+            $points = array($x, $y,
559
+                            $x, $y + $length,
560
+                            $x + $left, $y + $length - $bottom,
561
+                            $x + $left, $y + $top);
562
+            $this->_canvas->polygon($points, $color, null, null, true);
563
+          } else
564
+            $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
565 565
       
566
-      break;
566
+          break;
567 567
       
568
-    case "right":
569
-      if ( $corner_style === "bevel" ) {
570
-        $points = array($x, $y,
571
-                        $x, $y + $length,
572
-                        $x - $right, $y + $length - $bottom,
573
-                        $x - $right, $y + $top);
574
-        $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
576
-        $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577
-
578
-      break;
579
-
580
-    default:
581
-      return;
568
+        case "right":
569
+          if ( $corner_style === "bevel" ) {
570
+            $points = array($x, $y,
571
+                            $x, $y + $length,
572
+                            $x - $right, $y + $length - $bottom,
573
+                            $x - $right, $y + $top);
574
+            $this->_canvas->polygon($points, $color, null, null, true);
575
+          } else
576
+            $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
577
+
578
+          break;
579
+
580
+        default:
581
+          return;
582 582
 
583 583
     }
584 584
         
@@ -595,105 +595,105 @@  discard block
 block discarded – undo
595 595
     // inner bottom, inner top.
596 596
     switch ($side) {
597 597
 
598
-    case "top":
599
-      if ( $corner_style === "bevel" ) {
600
-        $left_line_width = $left / 4;
601
-        $right_line_width = $right / 4;
598
+        case "top":
599
+          if ( $corner_style === "bevel" ) {
600
+            $left_line_width = $left / 4;
601
+            $right_line_width = $right / 4;
602 602
         
603
-        $points = array($x, $y,
604
-                        $x + $length, $y,
605
-                        $x + $length - $right_line_width, $y + $line_width,
606
-                        $x + $left_line_width, $y + $line_width,);
607
-        $this->_canvas->polygon($points, $color, null, null, true);
603
+            $points = array($x, $y,
604
+                            $x + $length, $y,
605
+                            $x + $length - $right_line_width, $y + $line_width,
606
+                            $x + $left_line_width, $y + $line_width,);
607
+            $this->_canvas->polygon($points, $color, null, null, true);
608 608
         
609
-        $points = array($x + $left - $left_line_width, $y + $top - $line_width,
610
-                        $x + $length - $right + $right_line_width, $y + $top - $line_width,
611
-                        $x + $length - $right, $y + $top,
612
-                        $x + $left, $y + $top);
613
-        $this->_canvas->polygon($points, $color, null, null, true);
609
+            $points = array($x + $left - $left_line_width, $y + $top - $line_width,
610
+                            $x + $length - $right + $right_line_width, $y + $top - $line_width,
611
+                            $x + $length - $right, $y + $top,
612
+                            $x + $left, $y + $top);
613
+            $this->_canvas->polygon($points, $color, null, null, true);
614 614
 
615
-      } else {
616
-        $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617
-        $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
615
+          } else {
616
+            $this->_canvas->filled_rectangle($x, $y, $length, $line_width, $color);
617
+            $this->_canvas->filled_rectangle($x, $y + $top - $line_width, $length, $line_width, $color);
618 618
 
619
-      }
620
-      break;
619
+          }
620
+          break;
621 621
       
622
-    case "bottom":
623
-      if ( $corner_style === "bevel" ) {
624
-        $left_line_width = $left / 4;
625
-        $right_line_width = $right / 4;
622
+        case "bottom":
623
+          if ( $corner_style === "bevel" ) {
624
+            $left_line_width = $left / 4;
625
+            $right_line_width = $right / 4;
626 626
         
627
-        $points = array($x, $y,
628
-                        $x + $length, $y,
629
-                        $x + $length - $right_line_width, $y - $line_width,
630
-                        $x + $left_line_width, $y - $line_width);
631
-        $this->_canvas->polygon($points, $color, null, null, true);
627
+            $points = array($x, $y,
628
+                            $x + $length, $y,
629
+                            $x + $length - $right_line_width, $y - $line_width,
630
+                            $x + $left_line_width, $y - $line_width);
631
+            $this->_canvas->polygon($points, $color, null, null, true);
632 632
         
633
-        $points = array($x + $left - $left_line_width, $y - $bottom + $line_width,
634
-                        $x + $length - $right + $right_line_width, $y - $bottom + $line_width,
635
-                        $x + $length - $right, $y - $bottom,
636
-                        $x + $left, $y - $bottom);
637
-        $this->_canvas->polygon($points, $color, null, null, true);
633
+            $points = array($x + $left - $left_line_width, $y - $bottom + $line_width,
634
+                            $x + $length - $right + $right_line_width, $y - $bottom + $line_width,
635
+                            $x + $length - $right, $y - $bottom,
636
+                            $x + $left, $y - $bottom);
637
+            $this->_canvas->polygon($points, $color, null, null, true);
638 638
 
639
-      } else {
640
-        $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
-      }
639
+          } else {
640
+            $this->_canvas->filled_rectangle($x, $y - $line_width, $length, $line_width, $color);
641
+            $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $line_width, $color);
642
+          }
643 643
           
644
-      break;
644
+          break;
645 645
 
646
-    case "left":
647
-      if ( $corner_style === "bevel" ) {
648
-        $top_line_width = $top / 4;
649
-        $bottom_line_width = $bottom / 4;
646
+        case "left":
647
+          if ( $corner_style === "bevel" ) {
648
+            $top_line_width = $top / 4;
649
+            $bottom_line_width = $bottom / 4;
650 650
         
651
-        $points = array($x, $y,
652
-                        $x, $y + $length,
653
-                        $x + $line_width, $y + $length - $bottom_line_width,
654
-                        $x + $line_width, $y + $top_line_width);
655
-        $this->_canvas->polygon($points, $color, null, null, true);
656
-
657
-        $points = array($x + $left - $line_width, $y + $top - $top_line_width,
658
-                        $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width,
659
-                        $x + $left, $y + $length - $bottom,
660
-                        $x + $left, $y + $top);
661
-        $this->_canvas->polygon($points, $color, null, null, true);
651
+            $points = array($x, $y,
652
+                            $x, $y + $length,
653
+                            $x + $line_width, $y + $length - $bottom_line_width,
654
+                            $x + $line_width, $y + $top_line_width);
655
+            $this->_canvas->polygon($points, $color, null, null, true);
656
+
657
+            $points = array($x + $left - $line_width, $y + $top - $top_line_width,
658
+                            $x + $left - $line_width, $y + $length - $bottom + $bottom_line_width,
659
+                            $x + $left, $y + $length - $bottom,
660
+                            $x + $left, $y + $top);
661
+            $this->_canvas->polygon($points, $color, null, null, true);
662 662
 
663
-      } else {
664
-        $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665
-        $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
-      }
663
+          } else {
664
+            $this->_canvas->filled_rectangle($x, $y, $line_width, $length, $color);
665
+            $this->_canvas->filled_rectangle($x + $left - $line_width, $y, $line_width, $length, $color);
666
+          }
667 667
       
668
-      break;
668
+          break;
669 669
                       
670
-    case "right":
671
-      if ( $corner_style === "bevel" ) {
672
-        $top_line_width = $top / 4;
673
-        $bottom_line_width = $bottom / 4;
670
+        case "right":
671
+          if ( $corner_style === "bevel" ) {
672
+            $top_line_width = $top / 4;
673
+            $bottom_line_width = $bottom / 4;
674 674
         
675 675
       
676
-        $points = array($x, $y,
677
-                      $x, $y + $length,
678
-                        $x - $line_width, $y + $length - $bottom_line_width,
679
-                        $x - $line_width, $y + $top_line_width);
680
-        $this->_canvas->polygon($points, $color, null, null, true);
676
+            $points = array($x, $y,
677
+                          $x, $y + $length,
678
+                            $x - $line_width, $y + $length - $bottom_line_width,
679
+                            $x - $line_width, $y + $top_line_width);
680
+            $this->_canvas->polygon($points, $color, null, null, true);
681 681
         
682
-        $points = array($x - $right + $line_width, $y + $top - $top_line_width,
683
-                        $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width,
684
-                        $x - $right, $y + $length - $bottom,
685
-                        $x - $right, $y + $top);
686
-        $this->_canvas->polygon($points, $color, null, null, true);
682
+            $points = array($x - $right + $line_width, $y + $top - $top_line_width,
683
+                            $x - $right + $line_width, $y + $length - $bottom + $bottom_line_width,
684
+                            $x - $right, $y + $length - $bottom,
685
+                            $x - $right, $y + $top);
686
+            $this->_canvas->polygon($points, $color, null, null, true);
687 687
 
688
-      } else {
689
-        $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690
-        $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
-      }
688
+          } else {
689
+            $this->_canvas->filled_rectangle($x - $line_width, $y, $line_width, $length, $color);
690
+            $this->_canvas->filled_rectangle($x - $right, $y, $line_width, $length, $color);
691
+          }
692 692
       
693
-      break;
693
+          break;
694 694
 
695
-    default:
696
-      return;
695
+        default:
696
+          return;
697 697
 
698 698
     }
699 699
         
@@ -708,32 +708,32 @@  discard block
 block discarded – undo
708 708
 
709 709
     switch ($side) {
710 710
 
711
-    case "top":
712
-      $x += $left / 2;
713
-      $y += $top / 2;
714
-      $length -= $left / 2 + $right / 2;
715
-      break;
716
-
717
-    case "bottom":
718
-      $x += $left / 2;
719
-      $y -= $bottom / 2;
720
-      $length -= $left / 2 + $right / 2;
721
-      break;
722
-
723
-    case "left":
724
-      $x += $left / 2;
725
-      $y += $top / 2;
726
-      $length -= $top / 2 + $bottom / 2;
727
-      break;
728
-
729
-    case "right":
730
-      $x -= $right / 2;
731
-      $y += $top / 2;
732
-      $length -= $top / 2 + $bottom / 2;
733
-      break;
734
-
735
-    default:
736
-      return;
711
+        case "top":
712
+          $x += $left / 2;
713
+          $y += $top / 2;
714
+          $length -= $left / 2 + $right / 2;
715
+          break;
716
+
717
+        case "bottom":
718
+          $x += $left / 2;
719
+          $y -= $bottom / 2;
720
+          $length -= $left / 2 + $right / 2;
721
+          break;
722
+
723
+        case "left":
724
+          $x += $left / 2;
725
+          $y += $top / 2;
726
+          $length -= $top / 2 + $bottom / 2;
727
+          break;
728
+
729
+        case "right":
730
+          $x -= $right / 2;
731
+          $y += $top / 2;
732
+          $length -= $top / 2 + $bottom / 2;
733
+          break;
734
+
735
+        default:
736
+          return;
737 737
 
738 738
     }
739 739
 
@@ -750,32 +750,32 @@  discard block
 block discarded – undo
750 750
 
751 751
     switch ($side) {
752 752
 
753
-    case "top":
754
-      $x += $left / 2;
755
-      $y += $top / 2;
756
-      $length -= $left / 2 + $right / 2;
757
-      break;
758
-
759
-    case "bottom":
760
-      $x += $left / 2;
761
-      $y -= $bottom / 2;
762
-      $length -= $left / 2 + $right / 2;
763
-      break;
764
-
765
-    case "left":
766
-      $x += $left / 2;
767
-      $y += $top / 2;
768
-      $length -= $top / 2 + $bottom / 2;
769
-      break;
770
-
771
-    case "right":
772
-      $x -= $right / 2;
773
-      $y += $top / 2;
774
-      $length -= $top / 2 + $bottom / 2;
775
-      break;
776
-
777
-    default:
778
-      return;
753
+        case "top":
754
+          $x += $left / 2;
755
+          $y += $top / 2;
756
+          $length -= $left / 2 + $right / 2;
757
+          break;
758
+
759
+        case "bottom":
760
+          $x += $left / 2;
761
+          $y -= $bottom / 2;
762
+          $length -= $left / 2 + $right / 2;
763
+          break;
764
+
765
+        case "left":
766
+          $x += $left / 2;
767
+          $y += $top / 2;
768
+          $length -= $top / 2 + $bottom / 2;
769
+          break;
770
+
771
+        case "right":
772
+          $x -= $right / 2;
773
+          $y += $top / 2;
774
+          $length -= $top / 2 + $bottom / 2;
775
+          break;
776
+
777
+        default:
778
+          return;
779 779
 
780 780
     }
781 781
 
@@ -802,20 +802,20 @@  discard block
 block discarded – undo
802 802
     
803 803
     switch ($side) {
804 804
 
805
-    case "top":
806
-    case "left":
807
-      $shade = array_map(array($this, "_shade"), $color);
808
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
-      break;
805
+        case "top":
806
+        case "left":
807
+          $shade = array_map(array($this, "_shade"), $color);
808
+          $this->_border_solid($x, $y, $length, $shade, $widths, $side);
809
+          break;
810 810
 
811
-    case "bottom":
812
-    case "right":
813
-      $tint = array_map(array($this, "_tint"), $color);
814
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
-      break;
811
+        case "bottom":
812
+        case "right":
813
+          $tint = array_map(array($this, "_tint"), $color);
814
+          $this->_border_solid($x, $y, $length, $tint, $widths, $side);
815
+          break;
816 816
 
817
-    default:
818
-      return;
817
+        default:
818
+          return;
819 819
     }
820 820
   }
821 821
   
@@ -823,20 +823,20 @@  discard block
 block discarded – undo
823 823
     list($top, $right, $bottom, $left) = $widths;
824 824
     
825 825
     switch ($side) {
826
-    case "top":
827
-    case "left":
828
-      $tint = array_map(array($this, "_tint"), $color);
829
-      $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
-      break;
831
-
832
-    case "bottom":
833
-    case "right":
834
-      $shade = array_map(array($this, "_shade"), $color);
835
-      $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
-      break;
837
-
838
-    default:
839
-      return;
826
+        case "top":
827
+        case "left":
828
+          $tint = array_map(array($this, "_tint"), $color);
829
+          $this->_border_solid($x, $y, $length, $tint, $widths, $side);
830
+          break;
831
+
832
+        case "bottom":
833
+        case "right":
834
+          $shade = array_map(array($this, "_shade"), $color);
835
+          $this->_border_solid($x, $y, $length, $shade, $widths, $side);
836
+          break;
837
+
838
+        default:
839
+          return;
840 840
 
841 841
     }
842 842
   }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112
-    if ( $width == 0 || $height == 0 )
112
+    if ($width == 0 || $height == 0)
113 113
       return;
114 114
 
115 115
     //debugpng
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                                                 $sheet->get_base_path());
122 122
 
123 123
     // Bail if the image is no good
124
-    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
124
+    if ($img === DOMPDF_LIB_DIR."/res/broken_image.png")
125 125
       return;
126 126
 
127 127
 	//Try to optimize away reading and composing of same background multiple times
@@ -140,35 +140,35 @@  discard block
 block discarded – undo
140 140
 
141 141
 	//Increase background resolution and dependent box size according to image resolution to be placed in
142 142
 	//Then image can be copied in without resize
143
-    $bg_width = round((float)($width * DOMPDF_DPI) / 72);
144
-    $bg_height = round((float)($height * DOMPDF_DPI) / 72);
143
+    $bg_width = round((float) ($width * DOMPDF_DPI) / 72);
144
+    $bg_height = round((float) ($height * DOMPDF_DPI) / 72);
145 145
 
146 146
     //Need %bg_x, $bg_y as background pos, where img starts, converted to pixel
147 147
 
148 148
     list($bg_x, $bg_y) = $style->background_position;
149 149
 
150
-    if ( is_percent($bg_x) ) {
150
+    if (is_percent($bg_x)) {
151 151
       // The point $bg_x % from the left edge of the image is placed
152 152
       // $bg_x % from the left edge of the background rectangle
153
-      $p = ((float)$bg_x)/100.0;
153
+      $p = ((float) $bg_x) / 100.0;
154 154
       $x1 = $p * $img_w;
155 155
       $x2 = $p * $bg_width;
156 156
 
157 157
       $bg_x = round($x2 - $x1);
158 158
     } else {
159
-      $bg_x = round((float)($style->length_in_pt($bg_x)*DOMPDF_DPI) / 72);
159
+      $bg_x = round((float) ($style->length_in_pt($bg_x) * DOMPDF_DPI) / 72);
160 160
     }
161 161
 
162
-    if ( is_percent($bg_y) ) {
162
+    if (is_percent($bg_y)) {
163 163
       // The point $bg_y % from the left edge of the image is placed
164 164
       // $bg_y % from the left edge of the background rectangle
165
-      $p = ((float)$bg_y)/100.0;
165
+      $p = ((float) $bg_y) / 100.0;
166 166
       $y1 = $p * $img_h;
167 167
       $y2 = $p * $bg_height;
168 168
 
169 169
       $bg_y = round($y2 - $y1);
170 170
     } else {
171
-      $bg_y = round((float)($style->length_in_pt($bg_y)*DOMPDF_DPI) / 72);
171
+      $bg_y = round((float) ($style->length_in_pt($bg_y) * DOMPDF_DPI) / 72);
172 172
     }
173 173
 
174 174
     //clip background to the image area on partial repeat. Nothing to do if img off area
@@ -176,12 +176,12 @@  discard block
 block discarded – undo
176 176
     //On no repeat with positive offset: move size/start to have offset==0
177 177
     //Handle x/y Dimensions separately
178 178
 
179
-    if ( $repeat !== "repeat" && $repeat !== "repeat-x" ) {
179
+    if ($repeat !== "repeat" && $repeat !== "repeat-x") {
180 180
       //No repeat x
181 181
       if ($bg_x < 0) {
182 182
         $bg_width = $img_w + $bg_x;
183 183
       } else {
184
-        $x += ($bg_x * 72)/DOMPDF_DPI;
184
+        $x += ($bg_x * 72) / DOMPDF_DPI;
185 185
         $bg_width = $bg_width - $bg_x;
186 186
         if ($bg_width > $img_w) {
187 187
           $bg_width = $img_w;
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
       if ($bg_width <= 0) {
192 192
       	return;
193 193
       }
194
-      $width = (float)($bg_width * 72)/DOMPDF_DPI;
194
+      $width = (float) ($bg_width * 72) / DOMPDF_DPI;
195 195
     } else {
196 196
       //repeat x
197 197
       if ($bg_x < 0) {
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
       }
205 205
     }
206 206
 
207
-    if ( $repeat !== "repeat" && $repeat !== "repeat-y" ) {
207
+    if ($repeat !== "repeat" && $repeat !== "repeat-y") {
208 208
       //no repeat y
209 209
       if ($bg_y < 0) {
210 210
         $bg_height = $img_h + $bg_y;
211 211
       } else {
212
-        $y += ($bg_y * 72)/DOMPDF_DPI;
212
+        $y += ($bg_y * 72) / DOMPDF_DPI;
213 213
         $bg_height = $bg_height - $bg_y;
214 214
         if ($bg_height > $img_h) {
215 215
           $bg_height = $img_h;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
       if ($bg_height <= 0) {
220 220
       	return;
221 221
       }
222
-      $height = (float)($bg_height * 72)/DOMPDF_DPI;
222
+      $height = (float) ($bg_height * 72) / DOMPDF_DPI;
223 223
     } else {
224 224
       //repeat y
225 225
       if ($bg_y < 0) {
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
     }
234 234
 
235 235
     //Optimization, if repeat has no effect
236
-    if ( $repeat === "repeat" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height ) {
236
+    if ($repeat === "repeat" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height) {
237 237
       $repeat = "repeat-x";
238 238
     }
239
-    if ( $repeat === "repeat" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width ) {
239
+    if ($repeat === "repeat" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) {
240 240
       $repeat = "repeat-y";
241 241
     }
242
-    if ( ($repeat === "repeat-x" && $bg_x <= 0 && $img_w+$bg_x >= $bg_width) ||
243
-         ($repeat === "repeat-y" && $bg_y <= 0 && $img_h+$bg_y >= $bg_height) ) {
242
+    if (($repeat === "repeat-x" && $bg_x <= 0 && $img_w + $bg_x >= $bg_width) ||
243
+         ($repeat === "repeat-y" && $bg_y <= 0 && $img_h + $bg_y >= $bg_height)) {
244 244
       $repeat = "no-repeat";
245 245
     }
246 246
 
@@ -281,10 +281,10 @@  discard block
 block discarded – undo
281 281
     //Optimization to avoid multiple times rendering the same image.
282 282
     //If check functions are existing and identical image already cached,
283 283
     //then skip creation of duplicate, because it is not needed by addImagePng
284
-	if ( method_exists( $this->_canvas, "get_cpdf" ) &&
285
-	     method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) &&
286
-	     method_exists( $this->_canvas->get_cpdf(), "image_iscached" ) &&
287
-	     $this->_canvas->get_cpdf()->image_iscached($filedummy) ) {
284
+	if (method_exists($this->_canvas, "get_cpdf") &&
285
+	     method_exists($this->_canvas->get_cpdf(), "addImagePng") &&
286
+	     method_exists($this->_canvas->get_cpdf(), "image_iscached") &&
287
+	     $this->_canvas->get_cpdf()->image_iscached($filedummy)) {
288 288
 	  $bg = null;
289 289
 
290 290
       //debugpng
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
     //to keep the transparency when copying over the non transparent parts of the tiles.
328 328
 	$ti = imagecolortransparent($src);
329 329
 	if ($ti >= 0) {
330
-	  $tc = imagecolorsforindex($src,$ti);
331
-      $ti = imagecolorallocate($bg,$tc['red'],$tc['green'],$tc['blue']);
332
-      imagefill($bg,0,0,$ti);
330
+	  $tc = imagecolorsforindex($src, $ti);
331
+      $ti = imagecolorallocate($bg, $tc['red'], $tc['green'], $tc['blue']);
332
+      imagefill($bg, 0, 0, $ti);
333 333
       imagecolortransparent($bg, $ti);
334 334
     }
335 335
 
336 336
     //This has only an effect for the non repeatable dimension.
337 337
     //compute start of src and dest coordinates of the single copy
338
-    if ( $bg_x < 0 ) {
338
+    if ($bg_x < 0) {
339 339
       $dst_x = 0;
340 340
       $src_x = -$bg_x;
341 341
     } else {
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
       $dst_x = $bg_x;
344 344
     }
345 345
 
346
-    if ( $bg_y < 0 ) {
346
+    if ($bg_y < 0) {
347 347
       $dst_y = 0;
348 348
       $src_y = -$bg_y;
349 349
     } else {
@@ -358,15 +358,15 @@  discard block
 block discarded – undo
358 358
 
359 359
     // Copy regions from the source image to the background
360 360
 
361
-    if ( $repeat === "no-repeat" ) {
361
+    if ($repeat === "no-repeat") {
362 362
 
363 363
       // Simply place the image on the background
364 364
       imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $img_w, $img_h);
365 365
 
366
-    } else if ( $repeat === "repeat-x" ) {
366
+    } else if ($repeat === "repeat-x") {
367 367
 
368
-      for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
369
-        if ( $bg_x < 0 ) {
368
+      for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
369
+        if ($bg_x < 0) {
370 370
           $dst_x = 0;
371 371
           $src_x = -$bg_x;
372 372
           $w = $img_w + $bg_x;
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         imagecopy($bg, $src, $dst_x, $dst_y, $src_x, $src_y, $w, $img_h);
379 379
       }
380 380
 
381
-    } else if ( $repeat === "repeat-y" ) {
381
+    } else if ($repeat === "repeat-y") {
382 382
 
383
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
384
-        if ( $bg_y < 0 ) {
383
+      for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
384
+        if ($bg_y < 0) {
385 385
           $dst_y = 0;
386 386
           $src_y = -$bg_y;
387 387
           $h = $img_h + $bg_y;
@@ -394,12 +394,12 @@  discard block
 block discarded – undo
394 394
 
395 395
       }
396 396
 
397
-    } else if ( $repeat === "repeat" ) {
397
+    } else if ($repeat === "repeat") {
398 398
 
399
-      for ( $bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h ) {
400
-        for ( $bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w ) {
399
+      for ($bg_y = $start_y; $bg_y < $bg_height; $bg_y += $img_h) {
400
+        for ($bg_x = $start_x; $bg_x < $bg_width; $bg_x += $img_w) {
401 401
 
402
-          if ( $bg_x < 0 ) {
402
+          if ($bg_x < 0) {
403 403
             $dst_x = 0;
404 404
             $src_x = -$bg_x;
405 405
             $w = $img_w + $bg_x;
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
             $w = $img_w;
410 410
           }
411 411
 
412
-          if ( $bg_y < 0 ) {
412
+          if ($bg_y < 0) {
413 413
             $dst_y = 0;
414 414
             $src_y = -$bg_y;
415 415
             $h = $img_h + $bg_y;
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 	//$src: GD object of original image
439 439
     //When using cpdf and optimization to direct png creation from gd object is available,
440 440
     //don't create temp file, but place gd object directly into the pdf
441
-	if ( method_exists( $this->_canvas, "get_cpdf" ) && method_exists( $this->_canvas->get_cpdf(), "addImagePng" ) ) {
441
+	if (method_exists($this->_canvas, "get_cpdf") && method_exists($this->_canvas->get_cpdf(), "addImagePng")) {
442 442
       //Note: CPDF_Adapter image converts y position
443 443
 	  $this->_canvas->get_cpdf()->addImagePng(
444 444
 	  		$filedummy,
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
   protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 468
     list($top, $right, $bottom, $left) = $widths;
469 469
 
470
-    if ( $$side < 2 )
470
+    if ($$side < 2)
471 471
       $dash = array($$side, 2);
472 472
     else
473 473
       $dash = array($$side);
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
     switch ($side) {
530 530
 
531 531
     case "top":
532
-      if ( $corner_style === "bevel" ) {
532
+      if ($corner_style === "bevel") {
533 533
         
534 534
         $points = array($x, $y,
535 535
                         $x + $length, $y,
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
       break;
543 543
       
544 544
     case "bottom":
545
-      if ( $corner_style === "bevel" ) {
545
+      if ($corner_style === "bevel") {
546 546
         $points = array($x, $y,
547 547
                         $x + $length, $y,
548 548
                         $x + $length - $right, $y - $bottom,
@@ -554,7 +554,7 @@  discard block
 block discarded – undo
554 554
       break;
555 555
       
556 556
     case "left":
557
-      if ( $corner_style === "bevel" ) {
557
+      if ($corner_style === "bevel") {
558 558
         $points = array($x, $y,
559 559
                         $x, $y + $length,
560 560
                         $x + $left, $y + $length - $bottom,
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
       break;
567 567
       
568 568
     case "right":
569
-      if ( $corner_style === "bevel" ) {
569
+      if ($corner_style === "bevel") {
570 570
         $points = array($x, $y,
571 571
                         $x, $y + $length,
572 572
                         $x - $right, $y + $length - $bottom,
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
     switch ($side) {
597 597
 
598 598
     case "top":
599
-      if ( $corner_style === "bevel" ) {
599
+      if ($corner_style === "bevel") {
600 600
         $left_line_width = $left / 4;
601 601
         $right_line_width = $right / 4;
602 602
         
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
       break;
621 621
       
622 622
     case "bottom":
623
-      if ( $corner_style === "bevel" ) {
623
+      if ($corner_style === "bevel") {
624 624
         $left_line_width = $left / 4;
625 625
         $right_line_width = $right / 4;
626 626
         
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
       break;
645 645
 
646 646
     case "left":
647
-      if ( $corner_style === "bevel" ) {
647
+      if ($corner_style === "bevel") {
648 648
         $top_line_width = $top / 4;
649 649
         $bottom_line_width = $bottom / 4;
650 650
         
@@ -668,7 +668,7 @@  discard block
 block discarded – undo
668 668
       break;
669 669
                       
670 670
     case "right":
671
-      if ( $corner_style === "bevel" ) {
671
+      if ($corner_style === "bevel") {
672 672
         $top_line_width = $top / 4;
673 673
         $bottom_line_width = $bottom / 4;
674 674
         
@@ -784,14 +784,14 @@  discard block
 block discarded – undo
784 784
   }
785 785
 
786 786
   protected function _tint($c) {
787
-    if ( !is_numeric($c) )
787
+    if (!is_numeric($c))
788 788
       return $c;
789 789
     
790 790
     return min(1, $c + 0.66);
791 791
   }
792 792
 
793 793
   protected function _shade($c) {
794
-    if ( !is_numeric($c) )
794
+    if (!is_numeric($c))
795 795
       return $c;
796 796
     
797 797
     return max(0, $c - 0.66);
Please login to merge, or discard this patch.
Braces   +41 added lines, -25 removed lines patch added patch discarded remove patch
@@ -109,11 +109,14 @@  discard block
 block discarded – undo
109 109
     $sheet = $style->get_stylesheet();
110 110
 
111 111
     // Skip degenerate cases
112
-    if ( $width == 0 || $height == 0 )
113
-      return;
112
+    if ( $width == 0 || $height == 0 ) {
113
+          return;
114
+    }
114 115
 
115 116
     //debugpng
116
-    if (DEBUGPNG) print '[_background_image '.$url.']';
117
+    if (DEBUGPNG) {
118
+        print '[_background_image '.$url.']';
119
+    }
117 120
 
118 121
     list($img, $ext) = Image_Cache::resolve_url($url,
119 122
                                                 $sheet->get_protocol(),
@@ -121,8 +124,9 @@  discard block
 block discarded – undo
121 124
                                                 $sheet->get_base_path());
122 125
 
123 126
     // Bail if the image is no good
124
-    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" )
125
-      return;
127
+    if ( $img === DOMPDF_LIB_DIR . "/res/broken_image.png" ) {
128
+          return;
129
+    }
126 130
 
127 131
 	//Try to optimize away reading and composing of same background multiple times
128 132
 	//Postponing read with imagecreatefrom   ...()
@@ -446,16 +450,21 @@  discard block
 block discarded – undo
446 450
 	} else {
447 451
       $tmp_file = tempnam(DOMPDF_TEMP_DIR, "bg_dompdf_img_").'.png';
448 452
       //debugpng
449
-      if (DEBUGPNG) print '[_background_image '.$tmp_file.']';
453
+      if (DEBUGPNG) {
454
+          print '[_background_image '.$tmp_file.']';
455
+      }
450 456
 
451 457
       imagepng($bg, $tmp_file);
452 458
       $this->_canvas->image($tmp_file, "png", $x, $y, $width, $height);
453 459
 
454 460
       //debugpng
455
-      if (DEBUGPNG) print '[_background_image unlink '.$tmp_file.']';
461
+      if (DEBUGPNG) {
462
+          print '[_background_image unlink '.$tmp_file.']';
463
+      }
456 464
 
457
-      if (!DEBUGKEEPTEMP)
458
-        unlink($tmp_file);
465
+      if (!DEBUGKEEPTEMP) {
466
+              unlink($tmp_file);
467
+      }
459 468
     }
460 469
   }
461 470
 
@@ -467,10 +476,11 @@  discard block
 block discarded – undo
467 476
   protected function _border_dotted($x, $y, $length, $color, $widths, $side, $corner_style = "bevel") {
468 477
     list($top, $right, $bottom, $left) = $widths;
469 478
 
470
-    if ( $$side < 2 )
471
-      $dash = array($$side, 2);
472
-    else
473
-      $dash = array($$side);
479
+    if ( $$side < 2 ) {
480
+          $dash = array($$side, 2);
481
+    } else {
482
+          $dash = array($$side);
483
+    }
474 484
   
475 485
     
476 486
     switch ($side) {
@@ -536,8 +546,9 @@  discard block
 block discarded – undo
536 546
                         $x + $length - $right, $y + $top,
537 547
                         $x + $left, $y + $top);
538 548
         $this->_canvas->polygon($points, $color, null, null, true);
539
-      } else
540
-        $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
549
+      } else {
550
+              $this->_canvas->filled_rectangle($x, $y, $length, $top, $color);
551
+      }
541 552
       
542 553
       break;
543 554
       
@@ -548,8 +559,9 @@  discard block
 block discarded – undo
548 559
                         $x + $length - $right, $y - $bottom,
549 560
                         $x + $left, $y - $bottom);
550 561
         $this->_canvas->polygon($points, $color, null, null, true);
551
-      } else
552
-        $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
562
+      } else {
563
+              $this->_canvas->filled_rectangle($x, $y - $bottom, $length, $bottom, $color);
564
+      }
553 565
       
554 566
       break;
555 567
       
@@ -560,8 +572,9 @@  discard block
 block discarded – undo
560 572
                         $x + $left, $y + $length - $bottom,
561 573
                         $x + $left, $y + $top);
562 574
         $this->_canvas->polygon($points, $color, null, null, true);
563
-      } else
564
-        $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
575
+      } else {
576
+              $this->_canvas->filled_rectangle($x, $y, $left, $length, $color);
577
+      }
565 578
       
566 579
       break;
567 580
       
@@ -572,8 +585,9 @@  discard block
 block discarded – undo
572 585
                         $x - $right, $y + $length - $bottom,
573 586
                         $x - $right, $y + $top);
574 587
         $this->_canvas->polygon($points, $color, null, null, true);
575
-      } else
576
-        $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
588
+      } else {
589
+              $this->_canvas->filled_rectangle($x - $right, $y, $right, $length, $color);
590
+      }
577 591
 
578 592
       break;
579 593
 
@@ -784,15 +798,17 @@  discard block
 block discarded – undo
784 798
   }
785 799
 
786 800
   protected function _tint($c) {
787
-    if ( !is_numeric($c) )
788
-      return $c;
801
+    if ( !is_numeric($c) ) {
802
+          return $c;
803
+    }
789 804
     
790 805
     return min(1, $c + 0.66);
791 806
   }
792 807
 
793 808
   protected function _shade($c) {
794
-    if ( !is_numeric($c) )
795
-      return $c;
809
+    if ( !is_numeric($c) ) {
810
+          return $c;
811
+    }
796 812
     
797 813
     return max(0, $c - 0.66);
798 814
   }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/block_frame_decorator.cls.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -106,6 +106,9 @@
 block discarded – undo
106 106
       unset($this->_lines[$i]);
107 107
   }
108 108
 
109
+  /**
110
+   * @param integer $lineno
111
+   */
109 112
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 113
 
111 114
     if ( is_array($y) )
Please login to merge, or discard this patch.
Switch Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -266,32 +266,32 @@
 block discarded – undo
266 266
 
267 267
     switch ($type) {
268 268
 
269
-    default:
270
-    case "decimal":
271
-      return $this->_counters[$id];
269
+        default:
270
+        case "decimal":
271
+          return $this->_counters[$id];
272 272
 
273
-    case "decimal-leading-zero":
274
-      return str_pad($this->_counters[$id], 2, "0");
273
+        case "decimal-leading-zero":
274
+          return str_pad($this->_counters[$id], 2, "0");
275 275
 
276
-    case "lower-roman":
277
-      return dec2roman($this->_counters[$id]);
276
+        case "lower-roman":
277
+          return dec2roman($this->_counters[$id]);
278 278
 
279
-    case "upper-roman":
280
-      return mb_strtoupper(dec2roman($this->_counters[$id]));
279
+        case "upper-roman":
280
+          return mb_strtoupper(dec2roman($this->_counters[$id]));
281 281
 
282
-    case "lower-latin":
283
-    case "lower-alpha":
284
-      return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
282
+        case "lower-latin":
283
+        case "lower-alpha":
284
+          return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
285 285
 
286
-    case "upper-latin":
287
-    case "upper-alpha":
288
-      return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
286
+        case "upper-latin":
287
+        case "upper-alpha":
288
+          return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
289 289
 
290
-    case "lower-greek":
291
-      return chr($this->_counters[$id] + 944);
290
+        case "lower-greek":
291
+          return chr($this->_counters[$id] + 944);
292 292
 
293
-    case "upper-greek":
294
-      return chr($this->_counters[$id] + 912);
293
+        case "upper-greek":
294
+          return chr($this->_counters[$id] + 912);
295 295
     }
296 296
   }
297 297
 }
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
   protected $_lines; // array( [num] => array([frames] => array(<frame list>),
53 53
                      //                 y, w, h) )
54 54
   protected $_counters; // array([id] => counter_value) (for generated content)
55
-  protected $_cl;    // current line index
55
+  protected $_cl; // current line index
56 56
 
57 57
   //........................................................................
58 58
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 
88 88
   function get_current_line($i = null) {
89 89
     $cl = $this->_lines[$this->_cl];
90
-    if ( isset($i) )
90
+    if (isset($i))
91 91
       return $cl[$i];
92 92
     return $cl;
93 93
   }
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
   }
103 103
 
104 104
   function clear_line($i) {
105
-    if ( isset($this->_lines[$i]) )
105
+    if (isset($this->_lines[$i]))
106 106
       unset($this->_lines[$i]);
107 107
   }
108 108
 
109 109
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 110
 
111
-    if ( is_array($y) )
111
+    if (is_array($y))
112 112
       extract($y);
113 113
 
114 114
     if (is_numeric($y))
@@ -126,37 +126,37 @@  discard block
 block discarded – undo
126 126
   function add_frame_to_line(Frame $frame) {
127 127
 
128 128
     // Handle inline frames (which are effectively wrappers)
129
-    if ( $frame instanceof Inline_Frame_Decorator ) {
129
+    if ($frame instanceof Inline_Frame_Decorator) {
130 130
 
131 131
       // Handle line breaks
132
-      if ( $frame->get_node()->nodeName === "br" ) {
133
-        $this->maximize_line_height( $frame->get_style()->length_in_pt($frame->get_style()->line_height) );
132
+      if ($frame->get_node()->nodeName === "br") {
133
+        $this->maximize_line_height($frame->get_style()->length_in_pt($frame->get_style()->line_height));
134 134
         $this->add_line();
135 135
         return;
136 136
       }
137 137
 
138 138
       // Add each child of the inline frame to the line individually
139 139
       foreach ($frame->get_children() as $child)
140
-        $this->add_frame_to_line( $child );
140
+        $this->add_frame_to_line($child);
141 141
 
142 142
       return;
143 143
     }
144 144
 
145 145
     // Trim leading text if this is an empty line.  Kinda a hack to put it here,
146 146
     // but what can you do...
147
-    if ( $this->_lines[$this->_cl]["w"] == 0 &&
147
+    if ($this->_lines[$this->_cl]["w"] == 0 &&
148 148
          $frame->get_node()->nodeName === "#text" &&
149 149
          ($frame->get_style()->white_space !== "pre" ||
150
-          $frame->get_style()->white_space !== "pre-wrap") ) {
150
+          $frame->get_style()->white_space !== "pre-wrap")) {
151 151
 
152
-      $frame->set_text( ltrim($frame->get_text()) );
152
+      $frame->set_text(ltrim($frame->get_text()));
153 153
       $frame->recalculate_width();
154 154
 
155 155
     }
156 156
 
157 157
     $w = $frame->get_margin_width();
158 158
 
159
-    if ( $w == 0 )
159
+    if ($w == 0)
160 160
       return;
161 161
 
162 162
     // Debugging code:
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 
185 185
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 186
 
187
-    if ( $frame->get_node()->nodeName === "#text")
187
+    if ($frame->get_node()->nodeName === "#text")
188 188
       $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
189 189
 
190 190
     $this->_lines[$this->_cl]["w"] += $w;
@@ -197,12 +197,12 @@  discard block
 block discarded – undo
197 197
     $i = $this->_cl;
198 198
 
199 199
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
200
+      if (($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false)
201 201
         break;
202 202
       $i--;
203 203
     }
204 204
 
205
-    if ( $j === false )
205
+    if ($j === false)
206 206
       return;
207 207
 
208 208
     // Remove $frame and all frames that follow
@@ -215,22 +215,22 @@  discard block
 block discarded – undo
215 215
     // Recalculate the height of the line
216 216
     $h = 0;
217 217
     foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
218
+      $h = max($h, $f->get_margin_height());
219 219
 
220 220
     $this->_lines[$i]["h"] = $h;
221 221
 
222 222
     // Remove all lines that follow
223 223
     while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
224
+      unset($this->_lines[$this->_cl--]);
225 225
 
226 226
   }
227 227
 
228 228
   function increase_line_width($w) {
229
-    $this->_lines[ $this->_cl ]["w"] += $w;
229
+    $this->_lines[$this->_cl]["w"] += $w;
230 230
   }
231 231
 
232 232
   function maximize_line_height($val) {
233
-    $this->_lines[ $this->_cl ]["h"] = max($this->_lines[ $this->_cl ]["h"], $val);
233
+    $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $val);
234 234
   }
235 235
 
236 236
   function add_line() {
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
     $y = $this->_lines[$this->_cl]["y"] + $this->_lines[$this->_cl]["h"];
242 242
 
243
-    $this->_lines[ ++$this->_cl ] = array("frames" => array(),
243
+    $this->_lines[ ++$this->_cl] = array("frames" => array(),
244 244
                                           "wc" => 0,
245 245
                                           "y" => $y, "w" => 0, "h" => 0);
246 246
   }
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
   }
253 253
 
254 254
   function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255
-    if ( !isset($this->_counters[$id]) )
255
+    if (!isset($this->_counters[$id]))
256 256
       $this->_counters[$id] = $increment;
257 257
     else
258 258
       $this->_counters[$id] += $increment;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
   function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 263
     $type = mb_strtolower($type);
264
-    if ( !isset($this->_counters[$id]) )
264
+    if (!isset($this->_counters[$id]))
265 265
       $this->_counters[$id] = 0;
266 266
 
267 267
     switch ($type) {
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 
282 282
     case "lower-latin":
283 283
     case "lower-alpha":
284
-      return chr( ($this->_counters[$id] % 26) + ord('a') - 1);
284
+      return chr(($this->_counters[$id] % 26) + ord('a') - 1);
285 285
 
286 286
     case "upper-latin":
287 287
     case "upper-alpha":
288
-      return chr( ($this->_counters[$id] % 26) + ord('A') - 1);
288
+      return chr(($this->_counters[$id] % 26) + ord('A') - 1);
289 289
 
290 290
     case "lower-greek":
291 291
       return chr($this->_counters[$id] + 944);
Please login to merge, or discard this patch.
Braces   +50 added lines, -34 removed lines patch added patch discarded remove patch
@@ -87,8 +87,9 @@  discard block
 block discarded – undo
87 87
 
88 88
   function get_current_line($i = null) {
89 89
     $cl = $this->_lines[$this->_cl];
90
-    if ( isset($i) )
91
-      return $cl[$i];
90
+    if ( isset($i) ) {
91
+          return $cl[$i];
92
+    }
92 93
     return $cl;
93 94
   }
94 95
 
@@ -102,23 +103,28 @@  discard block
 block discarded – undo
102 103
   }
103 104
 
104 105
   function clear_line($i) {
105
-    if ( isset($this->_lines[$i]) )
106
-      unset($this->_lines[$i]);
106
+    if ( isset($this->_lines[$i]) ) {
107
+          unset($this->_lines[$i]);
108
+    }
107 109
   }
108 110
 
109 111
   function set_line($lineno, $y = null, $w = null, $h = null) {
110 112
 
111
-    if ( is_array($y) )
112
-      extract($y);
113
+    if ( is_array($y) ) {
114
+          extract($y);
115
+    }
113 116
 
114
-    if (is_numeric($y))
115
-      $this->_lines[$lineno]["y"] = $y;
117
+    if (is_numeric($y)) {
118
+          $this->_lines[$lineno]["y"] = $y;
119
+    }
116 120
 
117
-    if (is_numeric($w))
118
-      $this->_lines[$lineno]["w"] = $w;
121
+    if (is_numeric($w)) {
122
+          $this->_lines[$lineno]["w"] = $w;
123
+    }
119 124
 
120
-    if (is_numeric($h))
121
-      $this->_lines[$lineno]["h"] = $h;
125
+    if (is_numeric($h)) {
126
+          $this->_lines[$lineno]["h"] = $h;
127
+    }
122 128
 
123 129
   }
124 130
 
@@ -136,8 +142,9 @@  discard block
 block discarded – undo
136 142
       }
137 143
 
138 144
       // Add each child of the inline frame to the line individually
139
-      foreach ($frame->get_children() as $child)
140
-        $this->add_frame_to_line( $child );
145
+      foreach ($frame->get_children() as $child) {
146
+              $this->add_frame_to_line( $child );
147
+      }
141 148
 
142 149
       return;
143 150
     }
@@ -156,8 +163,9 @@  discard block
 block discarded – undo
156 163
 
157 164
     $w = $frame->get_margin_width();
158 165
 
159
-    if ( $w == 0 )
160
-      return;
166
+    if ( $w == 0 ) {
167
+          return;
168
+    }
161 169
 
162 170
     // Debugging code:
163 171
     /*
@@ -176,16 +184,18 @@  discard block
 block discarded – undo
176 184
     */
177 185
     // End debugging
178 186
 
179
-    if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w"))
180
-      $this->add_line();
187
+    if ($this->_lines[$this->_cl]["w"] + $w > $this->get_containing_block("w")) {
188
+          $this->add_line();
189
+    }
181 190
 
182 191
     $frame->position();
183 192
 
184 193
 
185 194
     $this->_lines[$this->_cl]["frames"][] = $frame;
186 195
 
187
-    if ( $frame->get_node()->nodeName === "#text")
188
-      $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
196
+    if ( $frame->get_node()->nodeName === "#text") {
197
+          $this->_lines[$this->_cl]["wc"] += count(preg_split("/\s+/", $frame->get_text()));
198
+    }
189 199
 
190 200
     $this->_lines[$this->_cl]["w"] += $w;
191 201
     $this->_lines[$this->_cl]["h"] = max($this->_lines[$this->_cl]["h"], $frame->get_margin_height());
@@ -197,13 +207,15 @@  discard block
 block discarded – undo
197 207
     $i = $this->_cl;
198 208
 
199 209
     while ($i >= 0) {
200
-      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false )
201
-        break;
210
+      if ( ($j = in_array($frame, $this->_lines[$i]["frames"], true)) !== false ) {
211
+              break;
212
+      }
202 213
       $i--;
203 214
     }
204 215
 
205
-    if ( $j === false )
206
-      return;
216
+    if ( $j === false ) {
217
+          return;
218
+    }
207 219
 
208 220
     // Remove $frame and all frames that follow
209 221
     while ($j < count($this->_lines[$i]["frames"])) {
@@ -214,14 +226,16 @@  discard block
 block discarded – undo
214 226
 
215 227
     // Recalculate the height of the line
216 228
     $h = 0;
217
-    foreach ($this->_lines[$i]["frames"] as $f)
218
-      $h = max( $h, $f->get_margin_height() );
229
+    foreach ($this->_lines[$i]["frames"] as $f) {
230
+          $h = max( $h, $f->get_margin_height() );
231
+    }
219 232
 
220 233
     $this->_lines[$i]["h"] = $h;
221 234
 
222 235
     // Remove all lines that follow
223
-    while ($this->_cl > $i)
224
-      unset($this->_lines[ $this->_cl-- ]);
236
+    while ($this->_cl > $i) {
237
+          unset($this->_lines[ $this->_cl-- ]);
238
+    }
225 239
 
226 240
   }
227 241
 
@@ -252,17 +266,19 @@  discard block
 block discarded – undo
252 266
   }
253 267
 
254 268
   function increment_counter($id = self::DEFAULT_COUNTER, $increment = 1) {
255
-    if ( !isset($this->_counters[$id]) )
256
-      $this->_counters[$id] = $increment;
257
-    else
258
-      $this->_counters[$id] += $increment;
269
+    if ( !isset($this->_counters[$id]) ) {
270
+          $this->_counters[$id] = $increment;
271
+    } else {
272
+          $this->_counters[$id] += $increment;
273
+    }
259 274
 
260 275
   }
261 276
 
262 277
   function counter_value($id = self::DEFAULT_COUNTER, $type = "decimal") {
263 278
     $type = mb_strtolower($type);
264
-    if ( !isset($this->_counters[$id]) )
265
-      $this->_counters[$id] = 0;
279
+    if ( !isset($this->_counters[$id]) ) {
280
+          $this->_counters[$id] = 0;
281
+    }
266 282
 
267 283
     switch ($type) {
268 284
 
Please login to merge, or discard this 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/canvas_factory.cls.php 4 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -54,6 +54,10 @@
 block discarded – undo
54 54
    */
55 55
   private function __construct() { }
56 56
 
57
+  /**
58
+   * @param string $paper
59
+   * @param string $orientation
60
+   */
57 61
   static function get_instance($paper = null, $orientation = null,  $class = null) {
58 62
 
59 63
     $backend = strtolower(DOMPDF_PDF_BACKEND);
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -54,24 +54,24 @@
 block discarded – undo
54 54
    */
55 55
   private function __construct() { }
56 56
 
57
-  static function get_instance($paper = null, $orientation = null,  $class = null) {
57
+  static function get_instance($paper = null, $orientation = null, $class = null) {
58 58
 
59 59
     $backend = strtolower(DOMPDF_PDF_BACKEND);
60 60
     
61
-    if ( isset($class) && class_exists($class, false) )
61
+    if (isset($class) && class_exists($class, false))
62 62
       $class .= "_Adapter";
63 63
     
64
-    else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
65
-              class_exists("PDFLib", false) )
64
+    else if ((DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib") &&
65
+              class_exists("PDFLib", false))
66 66
       $class = "PDFLib_Adapter";
67 67
 
68
-    else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
68
+    else if ((DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf"))
69 69
       $class = "CPDF_Adapter";
70 70
 
71
-    else if ( ( $backend === "tcpdf") )
71
+    else if (($backend === "tcpdf"))
72 72
       $class = "TCPDF_Adapter";
73 73
       
74
-    else if ( $backend === "gd" )
74
+    else if ($backend === "gd")
75 75
       $class = "GD_Adapter";
76 76
     
77 77
     else
Please login to merge, or discard this patch.
Braces   +14 added lines, -18 removed lines patch added patch discarded remove patch
@@ -58,24 +58,20 @@
 block discarded – undo
58 58
 
59 59
     $backend = strtolower(DOMPDF_PDF_BACKEND);
60 60
     
61
-    if ( isset($class) && class_exists($class, false) )
62
-      $class .= "_Adapter";
63
-    
64
-    else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
65
-              class_exists("PDFLib", false) )
66
-      $class = "PDFLib_Adapter";
67
-
68
-    else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
69
-      $class = "CPDF_Adapter";
70
-
71
-    else if ( ( $backend === "tcpdf") )
72
-      $class = "TCPDF_Adapter";
73
-      
74
-    else if ( $backend === "gd" )
75
-      $class = "GD_Adapter";
76
-    
77
-    else
78
-      $class = "CPDF_Adapter";
61
+    if ( isset($class) && class_exists($class, false) ) {
62
+          $class .= "_Adapter";
63
+    } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
64
+              class_exists("PDFLib", false) ) {
65
+          $class = "PDFLib_Adapter";
66
+    } else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") ) {
67
+          $class = "CPDF_Adapter";
68
+    } else if ( ( $backend === "tcpdf") ) {
69
+          $class = "TCPDF_Adapter";
70
+    } else if ( $backend === "gd" ) {
71
+          $class = "GD_Adapter";
72
+    } else {
73
+          $class = "CPDF_Adapter";
74
+    }
79 75
 
80 76
     return new $class($paper, $orientation);
81 77
         
Please login to merge, or discard this patch.
Indentation   +12 added lines, -13 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_factory.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */
@@ -49,35 +48,35 @@  discard block
 block discarded – undo
49 48
  */
50 49
 class Canvas_Factory {
51 50
 
52
-  /**
53
-   * Constructor is private: this is a static class
54
-   */
55
-  private function __construct() { }
51
+    /**
52
+     * Constructor is private: this is a static class
53
+     */
54
+    private function __construct() { }
56 55
 
57
-  static function get_instance($paper = null, $orientation = null,  $class = null) {
56
+    static function get_instance($paper = null, $orientation = null,  $class = null) {
58 57
 
59 58
     $backend = strtolower(DOMPDF_PDF_BACKEND);
60 59
     
61 60
     if ( isset($class) && class_exists($class, false) )
62
-      $class .= "_Adapter";
61
+        $class .= "_Adapter";
63 62
     
64 63
     else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "pdflib" ) &&
65 64
               class_exists("PDFLib", false) )
66
-      $class = "PDFLib_Adapter";
65
+        $class = "PDFLib_Adapter";
67 66
 
68 67
     else if ( (DOMPDF_PDF_BACKEND === "auto" || $backend === "cpdf") )
69
-      $class = "CPDF_Adapter";
68
+        $class = "CPDF_Adapter";
70 69
 
71 70
     else if ( ( $backend === "tcpdf") )
72
-      $class = "TCPDF_Adapter";
71
+        $class = "TCPDF_Adapter";
73 72
       
74 73
     else if ( $backend === "gd" )
75
-      $class = "GD_Adapter";
74
+        $class = "GD_Adapter";
76 75
     
77 76
     else
78
-      $class = "CPDF_Adapter";
77
+        $class = "CPDF_Adapter";
79 78
 
80 79
     return new $class($paper, $orientation);
81 80
         
82
-  }
81
+    }
83 82
 }
Please login to merge, or discard this patch.
main/inc/lib/phpdocx/pdf/include/cellmap.cls.php 4 patches
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -194,6 +194,9 @@  discard block
 block discarded – undo
194 194
     return $this->_rows[$j];
195 195
   }
196 196
 
197
+  /**
198
+   * @param string $h_v
199
+   */
197 200
   function get_border($i, $j, $h_v, $prop = null) {
198 201
     if ( !isset($this->_borders[$i][$j][$h_v]) )
199 202
       $this->_borders[$i][$j][$h_v] = array("width" => 0,
@@ -318,6 +321,11 @@  discard block
 block discarded – undo
318 321
   //........................................................................
319 322
 
320 323
 
324
+  /**
325
+   * @param integer $i
326
+   * @param integer $j
327
+   * @param string $h_v
328
+   */
321 329
   protected function _resolve_border($i, $j, $h_v, $border_spec) {
322 330
     $n_width = $border_spec["width"];
323 331
     $n_style = $border_spec["style"];
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
   }
171 171
 
172 172
   function &get_column($i) {
173
-    if ( !isset($this->_columns[$i]) )
173
+    if (!isset($this->_columns[$i]))
174 174
       $this->_columns[$i] = array("x" => 0,
175 175
                                   "min-width" => 0,
176 176
                                   "max-width" => 0,
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
   }
188 188
 
189 189
   function &get_row($j) {
190
-    if ( !isset($this->_rows[$j]) )
190
+    if (!isset($this->_rows[$j]))
191 191
       $this->_rows[$j] = array("y" => 0,
192 192
                                "first-column" => 0,
193 193
                                "height" => null);
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
   }
196 196
 
197 197
   function get_border($i, $j, $h_v, $prop = null) {
198
-    if ( !isset($this->_borders[$i][$j][$h_v]) )
198
+    if (!isset($this->_borders[$i][$j][$h_v]))
199 199
       $this->_borders[$i][$j][$h_v] = array("width" => 0,
200 200
                                            "style" => "solid",
201 201
                                            "color" => "black");
202
-    if ( isset($prop) )
202
+    if (isset($prop))
203 203
       return $this->_borders[$i][$j][$h_v][$prop];
204 204
 
205 205
     return $this->_borders[$i][$j][$h_v];
@@ -208,9 +208,9 @@  discard block
 block discarded – undo
208 208
   function get_border_properties($i, $j) {
209 209
 
210 210
     $left = $this->get_border($i, $j, "vertical");
211
-    $right = $this->get_border($i, $j+1, "vertical");
211
+    $right = $this->get_border($i, $j + 1, "vertical");
212 212
     $top = $this->get_border($i, $j, "horizontal");
213
-    $bottom = $this->get_border($i+1, $j, "horizontal");
213
+    $bottom = $this->get_border($i + 1, $j, "horizontal");
214 214
 
215 215
     return compact("top", "bottom", "left", "right");
216 216
   }
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
   function get_spanned_cells($frame) {
221 221
     $key = $frame->get_id();
222 222
 
223
-    if ( !isset($this->_frames[$key]) ) {
223
+    if (!isset($this->_frames[$key])) {
224 224
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
225 225
     }
226 226
 
@@ -238,20 +238,20 @@  discard block
 block discarded – undo
238 238
 
239 239
     $key = $frame->get_id();
240 240
 
241
-    if ( !isset($this->_frames[$key]) ) {
241
+    if (!isset($this->_frames[$key])) {
242 242
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
243 243
     }
244 244
 
245 245
     $col = $this->_frames[$key]["columns"][0];
246 246
     $row = $this->_frames[$key]["rows"][0];
247 247
 
248
-    if ( !isset($this->_columns[$col])) {
248
+    if (!isset($this->_columns[$col])) {
249 249
       $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
250 250
       $x = 0;
251 251
     } else
252 252
       $x = $this->_columns[$col]["x"];
253 253
 
254
-    if ( !isset($this->_rows[$row])) {
254
+    if (!isset($this->_rows[$row])) {
255 255
       $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
256 256
       $y = 0;
257 257
     } else
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
   function get_frame_width($frame) {
264 264
     $key = $frame->get_id();
265 265
 
266
-    if ( !isset($this->_frames[$key]) ) {
266
+    if (!isset($this->_frames[$key])) {
267 267
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
268 268
     }
269 269
 
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
   function get_frame_height($frame) {
280 280
     $key = $frame->get_id();
281 281
 
282
-    if ( !isset($this->_frames[$key]) )
282
+    if (!isset($this->_frames[$key]))
283 283
       throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
284 284
 
285 285
     $rows = $this->_frames[$key]["rows"];
286 286
     $h = 0;
287 287
     foreach ($rows as $i) {
288
-      if ( !isset($this->_rows[$i]) )  {
288
+      if (!isset($this->_rows[$i])) {
289 289
         throw new Exception("foo");
290 290
       }
291 291
       $h += $this->_rows[$i]["height"];
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
   //........................................................................
299 299
 
300 300
   function set_column_width($j, $width) {
301
-    $col =& $this->get_column($j);
301
+    $col = & $this->get_column($j);
302 302
     $col["used-width"] = $width;
303
-    $next_col =& $this->get_column($j+1);
303
+    $next_col = & $this->get_column($j + 1);
304 304
     $next_col["x"] = $next_col["x"] + $width;
305 305
   }
306 306
 
307 307
   function set_row_height($i, $height) {
308
-    $row =& $this->get_row($i);
309
-    if ( $height <= $row["height"] )
308
+    $row = & $this->get_row($i);
309
+    if ($height <= $row["height"])
310 310
       return;
311 311
 
312 312
     $row["height"] = $height;
313
-    $next_row =& $this->get_row($i+1);
313
+    $next_row = & $this->get_row($i + 1);
314 314
     $next_row["y"] = $row["y"] + $height;
315 315
 
316 316
   }
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
     $n_style = $border_spec["style"];
324 324
     $n_color = $border_spec["color"];
325 325
 
326
-    if ( !isset($this->_borders[$i][$j][$h_v]) ) {
326
+    if (!isset($this->_borders[$i][$j][$h_v])) {
327 327
       $this->_borders[$i][$j][$h_v] = $border_spec;
328 328
       return $this->_borders[$i][$j][$h_v]["width"];
329 329
     }
@@ -332,15 +332,15 @@  discard block
 block discarded – undo
332 332
     $o_style = $this->_borders[$i][$j][$h_v]["style"];
333 333
     $o_color = $this->_borders[$i][$j][$h_v]["color"];
334 334
 
335
-    if ( ($n_style === "hidden" ||
336
-          $n_width  >  $o_width ||
335
+    if (($n_style === "hidden" ||
336
+          $n_width > $o_width ||
337 337
           $o_style === "none")
338 338
 
339 339
          or
340 340
 
341 341
          ($o_width == $n_width &&
342 342
           in_array($n_style, self::$_BORDER_STYLE_SCORE) &&
343
-          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) )
343
+          self::$_BORDER_STYLE_SCORE[$n_style] > self::$_BORDER_STYLE_SCORE[$o_style]))
344 344
       $this->_borders[$i][$j][$h_v] = $border_spec;
345 345
 
346 346
     return $this->_borders[$i][$j][$h_v]["width"];
@@ -356,37 +356,37 @@  discard block
 block discarded – undo
356 356
     $collapse = $this->_table->get_style()->border_collapse == "collapse";
357 357
 
358 358
     // Recursively add the frames within tables, table-row-groups and table-rows
359
-    if ( $display == "table-row" ||
359
+    if ($display == "table-row" ||
360 360
          $display == "table" ||
361 361
          $display == "inline-table" ||
362
-         in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
362
+         in_array($display, Table_Frame_Decorator::$ROW_GROUPS)) {
363 363
 
364 364
       $start_row = $this->__row;
365
-      foreach ( $frame->get_children() as $child )
366
-        $this->add_frame( $child );
365
+      foreach ($frame->get_children() as $child)
366
+        $this->add_frame($child);
367 367
 
368
-      if ( $display == "table-row" )
368
+      if ($display == "table-row")
369 369
         $this->add_row();
370 370
 
371 371
       $num_rows = $this->__row - $start_row - 1;
372 372
       $key = $frame->get_id();
373 373
 
374 374
       // Row groups always span across the entire table
375
-      $this->_frames[ $key ]["columns"] = range(0,max(0,$this->_num_cols-1));
376
-      $this->_frames[ $key ]["rows"] = range($start_row, max(0, $this->__row - 1));
377
-      $this->_frames[ $key ]["frame"] = $frame;
375
+      $this->_frames[$key]["columns"] = range(0, max(0, $this->_num_cols - 1));
376
+      $this->_frames[$key]["rows"] = range($start_row, max(0, $this->__row - 1));
377
+      $this->_frames[$key]["frame"] = $frame;
378 378
 
379
-      if ( $display != "table-row" && $collapse ) {
379
+      if ($display != "table-row" && $collapse) {
380 380
 
381 381
         $bp = $style->get_border_properties();
382 382
 
383 383
         // Resolve the borders
384
-        for ( $i = 0; $i < $num_rows+1; $i++) {
384
+        for ($i = 0; $i < $num_rows + 1; $i++) {
385 385
           $this->_resolve_border($start_row + $i, 0, "vertical", $bp["left"]);
386 386
           $this->_resolve_border($start_row + $i, $this->_num_cols, "vertical", $bp["right"]);
387 387
         }
388 388
 
389
-        for ( $j = 0; $j < $this->_num_cols; $j++) {
389
+        for ($j = 0; $j < $this->_num_cols; $j++) {
390 390
           $this->_resolve_border($start_row, $j, "horizontal", $bp["top"]);
391 391
           $this->_resolve_border($this->__row, $j, "horizontal", $bp["bottom"]);
392 392
         }
@@ -400,14 +400,14 @@  discard block
 block discarded – undo
400 400
     $colspan = $frame->get_node()->getAttribute("colspan");
401 401
     $rowspan = $frame->get_node()->getAttribute("rowspan");
402 402
 
403
-    if ( !$colspan ) {
403
+    if (!$colspan) {
404 404
       $colspan = 1;
405
-      $frame->get_node()->setAttribute("colspan",1);
405
+      $frame->get_node()->setAttribute("colspan", 1);
406 406
     }
407 407
 
408
-    if ( !$rowspan ) {
408
+    if (!$rowspan) {
409 409
       $rowspan = 1;
410
-      $frame->get_node()->setAttribute("rowspan",1);
410
+      $frame->get_node()->setAttribute("rowspan", 1);
411 411
     }
412 412
     $key = $frame->get_id();
413 413
 
@@ -419,20 +419,20 @@  discard block
 block discarded – undo
419 419
 
420 420
     // Find the next available column (fix by Ciro Mondueri)
421 421
     $ac = $this->__col;
422
-    while ( isset($this->_cells[$this->__row][$ac]) )
422
+    while (isset($this->_cells[$this->__row][$ac]))
423 423
        $ac++;
424 424
     $this->__col = $ac;
425 425
 
426 426
     // Rows:
427
-    for ( $i = 0; $i < $rowspan; $i++ ) {
427
+    for ($i = 0; $i < $rowspan; $i++) {
428 428
       $row = $this->__row + $i;
429 429
 
430
-      $this->_frames[ $key ]["rows"][] = $row;
430
+      $this->_frames[$key]["rows"][] = $row;
431 431
 
432
-      for ( $j = 0; $j < $colspan; $j++)
432
+      for ($j = 0; $j < $colspan; $j++)
433 433
         $this->_cells[$row][$this->__col + $j] = $frame;
434 434
 
435
-      if ( $collapse ) {
435
+      if ($collapse) {
436 436
         // Resolve vertical borders
437 437
         $max_left = max($max_left, $this->_resolve_border($row, $this->__col, "vertical", $bp["left"]));
438 438
         $max_right = max($max_right, $this->_resolve_border($row, $this->__col + $colspan, "vertical", $bp["right"]));
@@ -442,21 +442,21 @@  discard block
 block discarded – undo
442 442
     $max_top = $max_bottom = 0;
443 443
 
444 444
     // Columns:
445
-    for ( $j = 0; $j < $colspan; $j++ ) {
445
+    for ($j = 0; $j < $colspan; $j++) {
446 446
       $col = $this->__col + $j;
447
-      $this->_frames[ $key ]["columns"][] = $col;
447
+      $this->_frames[$key]["columns"][] = $col;
448 448
 
449
-      if ( $collapse ) {
449
+      if ($collapse) {
450 450
         // Resolve horizontal borders
451 451
         $max_top = max($max_top, $this->_resolve_border($this->__row, $col, "horizontal", $bp["top"]));
452 452
         $max_bottom = max($max_bottom, $this->_resolve_border($this->__row + $rowspan, $col, "horizontal", $bp["bottom"]));
453 453
       }
454 454
     }
455 455
 
456
-    $this->_frames[ $key ]["frame"] = $frame;
456
+    $this->_frames[$key]["frame"] = $frame;
457 457
 
458 458
     // Handle seperated border model
459
-    if ( !$collapse ) {
459
+    if (!$collapse) {
460 460
       list($h, $v) = $this->_table->get_style()->border_spacing;
461 461
 
462 462
       // Border spacing is effectively a margin between cells
@@ -481,26 +481,26 @@  discard block
 block discarded – undo
481 481
 
482 482
     $width = $style->width;
483 483
 
484
-    if ( is_percent($width) ) {
484
+    if (is_percent($width)) {
485 485
       $var = "percent";
486
-      $val = (float)rtrim($width, "% ") / $colspan;
486
+      $val = (float) rtrim($width, "% ") / $colspan;
487 487
 
488
-    } else if ( $width !== "auto" ) {
488
+    } else if ($width !== "auto") {
489 489
       $var = "absolute";
490 490
       $val = $style->length_in_pt($frame_min) / $colspan;
491 491
     }
492 492
 
493 493
     $min = 0;
494 494
     $max = 0;
495
-    for ( $cs = 0; $cs < $colspan; $cs++ ) {
495
+    for ($cs = 0; $cs < $colspan; $cs++) {
496 496
 
497 497
       // Resolve the frame's width(s) with other cells
498
-      $col =& $this->get_column( $this->__col + $cs );
498
+      $col = & $this->get_column($this->__col + $cs);
499 499
 
500 500
       // Note: $var is either 'percent' or 'absolute'.  We compare the
501 501
       // requested percentage or absolute values with the existing widths
502 502
       // and adjust accordingly.
503
-      if ( isset($var) && $val > $col[$var] ) {
503
+      if (isset($var) && $val > $col[$var]) {
504 504
         $col[$var] = $val;
505 505
         $col["auto"] = false;
506 506
       }
@@ -510,25 +510,25 @@  discard block
 block discarded – undo
510 510
     }
511 511
 
512 512
 
513
-    if ( $frame_min > $min ) {
513
+    if ($frame_min > $min) {
514 514
       // The frame needs more space.  Expand each sub-column
515 515
       $inc = ($frame_min - $min) / $colspan;
516 516
       for ($c = 0; $c < $colspan; $c++) {
517
-        $col =& $this->get_column($this->__col + $c);
517
+        $col = & $this->get_column($this->__col + $c);
518 518
         $col["min-width"] += $inc;
519 519
       }
520 520
     }
521 521
 
522
-    if ( $frame_max > $max ) {
522
+    if ($frame_max > $max) {
523 523
       $inc = ($frame_max - $max) / $colspan;
524 524
       for ($c = 0; $c < $colspan; $c++) {
525
-        $col =& $this->get_column($this->__col + $c);
525
+        $col = & $this->get_column($this->__col + $c);
526 526
         $col["max-width"] += $inc;
527 527
       }
528 528
     }
529 529
 
530 530
     $this->__col += $colspan;
531
-    if ( $this->__col > $this->_num_cols )
531
+    if ($this->__col > $this->_num_cols)
532 532
       $this->_num_cols = $this->__col;
533 533
 
534 534
   }
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 
543 543
     // Find the next available column
544 544
     $i = 0;
545
-    while ( isset($this->_cells[$this->__row][$i]) )
545
+    while (isset($this->_cells[$this->__row][$i]))
546 546
       $i++;
547 547
 
548 548
     $this->__col = $i;
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
   function remove_row(Frame $row) {
560 560
 
561 561
     $key = $row->get_id();
562
-    if ( !isset($this->_frames[$key]) )
563
-      return;  // Presumably this row has alredy been removed
562
+    if (!isset($this->_frames[$key]))
563
+      return; // Presumably this row has alredy been removed
564 564
 
565 565
     $this->_row = $this->_num_rows--;
566 566
 
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
     $columns = $this->_frames[$key]["columns"];
569 569
 
570 570
     // Remove all frames from this row
571
-    foreach ( $rows as $r ) {
572
-      foreach ( $columns as $c ) {
573
-        if ( isset($this->_cells[$r][$c]) ) {
571
+    foreach ($rows as $r) {
572
+      foreach ($columns as $c) {
573
+        if (isset($this->_cells[$r][$c])) {
574 574
           $frame = $this->_cells[$r][$c];
575
-          unset($this->_frames[ $frame->get_id() ]);
575
+          unset($this->_frames[$frame->get_id()]);
576 576
           unset($this->_cells[$r][$c]);
577 577
         }
578 578
       }
@@ -591,8 +591,8 @@  discard block
 block discarded – undo
591 591
   function remove_row_group(Frame $group) {
592 592
 
593 593
     $key = $group->get_id();
594
-    if ( !isset($this->_frames[$key]) )
595
-      return;  // Presumably this row has alredy been removed
594
+    if (!isset($this->_frames[$key]))
595
+      return; // Presumably this row has alredy been removed
596 596
 
597 597
     $iter = $group->get_first_child();
598 598
     while ($iter) {
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
     $r_key = $last_row->get_id();
616 616
 
617 617
     $r_rows = $this->_frames[$r_key]["rows"];
618
-    $this->_frames[$g_key]["rows"] = range( $this->_frames[$g_key]["rows"][0], end($r_rows) );
618
+    $this->_frames[$g_key]["rows"] = range($this->_frames[$g_key]["rows"][0], end($r_rows));
619 619
 
620 620
   }
621 621
 
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     // column[0]["x"] must be set.
627 627
 
628 628
     $x = $this->_columns[0]["x"];
629
-    foreach ( array_keys($this->_columns) as $j ) {
629
+    foreach (array_keys($this->_columns) as $j) {
630 630
       $this->_columns[$j]["x"] = $x;
631 631
       $x += $this->_columns[$j]["used-width"];
632 632
 
@@ -638,18 +638,18 @@  discard block
 block discarded – undo
638 638
     // Pre-condition: widths and heights of each column & row must be
639 639
     // calcluated
640 640
 
641
-    foreach ( $this->_frames as $arr ) {
641
+    foreach ($this->_frames as $arr) {
642 642
       $frame = $arr["frame"];
643 643
 
644 644
       $h = 0;
645
-      foreach( $arr["rows"] as $row ) {
646
-        if ( !isset($this->_rows[$row]) )
645
+      foreach ($arr["rows"] as $row) {
646
+        if (!isset($this->_rows[$row]))
647 647
           // The row has been removed because of a page split, so skip it.
648 648
           continue;
649 649
         $h += $this->_rows[$row]["height"];
650 650
       }
651 651
 
652
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
652
+      if ($frame instanceof Table_Cell_Frame_Decorator)
653 653
         $frame->set_cell_height($h);
654 654
       else
655 655
         $frame->get_style()->height = $h;
@@ -666,12 +666,12 @@  discard block
 block discarded – undo
666 666
 
667 667
 
668 668
     // Distribute the increased height proportionally amongst each row
669
-    foreach ( $this->_frames as $arr ) {
669
+    foreach ($this->_frames as $arr) {
670 670
       $frame = $arr["frame"];
671 671
 
672 672
       $h = 0;
673
-      foreach ($arr["rows"] as $row ) {
674
-        if ( !isset($this->_rows[$row]) )
673
+      foreach ($arr["rows"] as $row) {
674
+        if (!isset($this->_rows[$row]))
675 675
           continue;
676 676
 
677 677
         $h += $this->_rows[$row]["height"];
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 
680 680
       $new_height = ($h / $content_height) * $table_height;
681 681
 
682
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
682
+      if ($frame instanceof Table_Cell_Frame_Decorator)
683 683
         $frame->set_cell_height($new_height);
684 684
       else
685 685
         $frame->get_style()->height = $new_height;
@@ -694,19 +694,19 @@  discard block
 block discarded – undo
694 694
     $str = "";
695 695
     $str .= "Columns:<br/>";
696 696
     $str .= pre_r($this->_columns, true);
697
-    $str .=  "Rows:<br/>";
697
+    $str .= "Rows:<br/>";
698 698
     $str .= pre_r($this->_rows, true);
699 699
 
700
-    $str .=  "Frames:<br/>";
700
+    $str .= "Frames:<br/>";
701 701
     $arr = array();
702
-    foreach ( $this->_frames as $key => $val )
702
+    foreach ($this->_frames as $key => $val)
703 703
       $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
704 704
 
705 705
     $str .= pre_r($arr, true);
706 706
 
707
-    if ( php_sapi_name() == "cli" )
708
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
709
-                                    array("\n",chr(27)."[01;33m", chr(27)."[0m"),
707
+    if (php_sapi_name() == "cli")
708
+      $str = strip_tags(str_replace(array("<br/>", "<b>", "</b>"),
709
+                                    array("\n", chr(27)."[01;33m", chr(27)."[0m"),
710 710
                                     $str));
711 711
     return $str;
712 712
   }
Please login to merge, or discard this patch.
Braces   +78 added lines, -52 removed lines patch added patch discarded remove patch
@@ -170,14 +170,15 @@  discard block
 block discarded – undo
170 170
   }
171 171
 
172 172
   function &get_column($i) {
173
-    if ( !isset($this->_columns[$i]) )
174
-      $this->_columns[$i] = array("x" => 0,
173
+    if ( !isset($this->_columns[$i]) ) {
174
+          $this->_columns[$i] = array("x" => 0,
175 175
                                   "min-width" => 0,
176 176
                                   "max-width" => 0,
177 177
                                   "used-width" => null,
178 178
                                   "absolute" => 0,
179 179
                                   "percent" => 0,
180 180
                                   "auto" => true);
181
+    }
181 182
 
182 183
     return $this->_columns[$i];
183 184
   }
@@ -187,20 +188,23 @@  discard block
 block discarded – undo
187 188
   }
188 189
 
189 190
   function &get_row($j) {
190
-    if ( !isset($this->_rows[$j]) )
191
-      $this->_rows[$j] = array("y" => 0,
191
+    if ( !isset($this->_rows[$j]) ) {
192
+          $this->_rows[$j] = array("y" => 0,
192 193
                                "first-column" => 0,
193 194
                                "height" => null);
195
+    }
194 196
     return $this->_rows[$j];
195 197
   }
196 198
 
197 199
   function get_border($i, $j, $h_v, $prop = null) {
198
-    if ( !isset($this->_borders[$i][$j][$h_v]) )
199
-      $this->_borders[$i][$j][$h_v] = array("width" => 0,
200
+    if ( !isset($this->_borders[$i][$j][$h_v]) ) {
201
+          $this->_borders[$i][$j][$h_v] = array("width" => 0,
200 202
                                            "style" => "solid",
201 203
                                            "color" => "black");
202
-    if ( isset($prop) )
203
-      return $this->_borders[$i][$j][$h_v][$prop];
204
+    }
205
+    if ( isset($prop) ) {
206
+          return $this->_borders[$i][$j][$h_v][$prop];
207
+    }
204 208
 
205 209
     return $this->_borders[$i][$j][$h_v];
206 210
   }
@@ -248,14 +252,16 @@  discard block
 block discarded – undo
248 252
     if ( !isset($this->_columns[$col])) {
249 253
       $_dompdf_warnings[] = "Frame not found in columns array.  Check your table layout for missing or extra TDs.";
250 254
       $x = 0;
251
-    } else
252
-      $x = $this->_columns[$col]["x"];
255
+    } else {
256
+          $x = $this->_columns[$col]["x"];
257
+    }
253 258
 
254 259
     if ( !isset($this->_rows[$row])) {
255 260
       $_dompdf_warnings[] = "Frame not found in row array.  Check your table layout for missing or extra TDs.";
256 261
       $y = 0;
257
-    } else
258
-      $y = $this->_rows[$row]["y"];
262
+    } else {
263
+          $y = $this->_rows[$row]["y"];
264
+    }
259 265
 
260 266
     return array($x, $y, "x" => $x, "y" => $y);
261 267
   }
@@ -269,8 +275,9 @@  discard block
 block discarded – undo
269 275
 
270 276
     $cols = $this->_frames[$key]["columns"];
271 277
     $w = 0;
272
-    foreach ($cols as $i)
273
-      $w += $this->_columns[$i]["used-width"];
278
+    foreach ($cols as $i) {
279
+          $w += $this->_columns[$i]["used-width"];
280
+    }
274 281
 
275 282
     return $w;
276 283
 
@@ -279,8 +286,9 @@  discard block
 block discarded – undo
279 286
   function get_frame_height($frame) {
280 287
     $key = $frame->get_id();
281 288
 
282
-    if ( !isset($this->_frames[$key]) )
283
-      throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
289
+    if ( !isset($this->_frames[$key]) ) {
290
+          throw new DOMPDF_Internal_Exception("Frame not found in cellmap");
291
+    }
284 292
 
285 293
     $rows = $this->_frames[$key]["rows"];
286 294
     $h = 0;
@@ -306,8 +314,9 @@  discard block
 block discarded – undo
306 314
 
307 315
   function set_row_height($i, $height) {
308 316
     $row =& $this->get_row($i);
309
-    if ( $height <= $row["height"] )
310
-      return;
317
+    if ( $height <= $row["height"] ) {
318
+          return;
319
+    }
311 320
 
312 321
     $row["height"] = $height;
313 322
     $next_row =& $this->get_row($i+1);
@@ -340,8 +349,9 @@  discard block
 block discarded – undo
340 349
 
341 350
          ($o_width == $n_width &&
342 351
           in_array($n_style, self::$_BORDER_STYLE_SCORE) &&
343
-          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) )
344
-      $this->_borders[$i][$j][$h_v] = $border_spec;
352
+          self::$_BORDER_STYLE_SCORE[ $n_style ] > self::$_BORDER_STYLE_SCORE[ $o_style ]) ) {
353
+          $this->_borders[$i][$j][$h_v] = $border_spec;
354
+    }
345 355
 
346 356
     return $this->_borders[$i][$j][$h_v]["width"];
347 357
   }
@@ -362,11 +372,13 @@  discard block
 block discarded – undo
362 372
          in_array($display, Table_Frame_Decorator::$ROW_GROUPS) ) {
363 373
 
364 374
       $start_row = $this->__row;
365
-      foreach ( $frame->get_children() as $child )
366
-        $this->add_frame( $child );
375
+      foreach ( $frame->get_children() as $child ) {
376
+              $this->add_frame( $child );
377
+      }
367 378
 
368
-      if ( $display == "table-row" )
369
-        $this->add_row();
379
+      if ( $display == "table-row" ) {
380
+              $this->add_row();
381
+      }
370 382
 
371 383
       $num_rows = $this->__row - $start_row - 1;
372 384
       $key = $frame->get_id();
@@ -419,8 +431,9 @@  discard block
 block discarded – undo
419 431
 
420 432
     // Find the next available column (fix by Ciro Mondueri)
421 433
     $ac = $this->__col;
422
-    while ( isset($this->_cells[$this->__row][$ac]) )
423
-       $ac++;
434
+    while ( isset($this->_cells[$this->__row][$ac]) ) {
435
+           $ac++;
436
+    }
424 437
     $this->__col = $ac;
425 438
 
426 439
     // Rows:
@@ -429,8 +442,9 @@  discard block
 block discarded – undo
429 442
 
430 443
       $this->_frames[ $key ]["rows"][] = $row;
431 444
 
432
-      for ( $j = 0; $j < $colspan; $j++)
433
-        $this->_cells[$row][$this->__col + $j] = $frame;
445
+      for ( $j = 0; $j < $colspan; $j++) {
446
+              $this->_cells[$row][$this->__col + $j] = $frame;
447
+      }
434 448
 
435 449
       if ( $collapse ) {
436 450
         // Resolve vertical borders
@@ -528,8 +542,9 @@  discard block
 block discarded – undo
528 542
     }
529 543
 
530 544
     $this->__col += $colspan;
531
-    if ( $this->__col > $this->_num_cols )
532
-      $this->_num_cols = $this->__col;
545
+    if ( $this->__col > $this->_num_cols ) {
546
+          $this->_num_cols = $this->__col;
547
+    }
533 548
 
534 549
   }
535 550
 
@@ -542,8 +557,9 @@  discard block
 block discarded – undo
542 557
 
543 558
     // Find the next available column
544 559
     $i = 0;
545
-    while ( isset($this->_cells[$this->__row][$i]) )
546
-      $i++;
560
+    while ( isset($this->_cells[$this->__row][$i]) ) {
561
+          $i++;
562
+    }
547 563
 
548 564
     $this->__col = $i;
549 565
 
@@ -559,8 +575,10 @@  discard block
 block discarded – undo
559 575
   function remove_row(Frame $row) {
560 576
 
561 577
     $key = $row->get_id();
562
-    if ( !isset($this->_frames[$key]) )
563
-      return;  // Presumably this row has alredy been removed
578
+    if ( !isset($this->_frames[$key]) ) {
579
+          return;
580
+    }
581
+    // Presumably this row has alredy been removed
564 582
 
565 583
     $this->_row = $this->_num_rows--;
566 584
 
@@ -591,8 +609,10 @@  discard block
 block discarded – undo
591 609
   function remove_row_group(Frame $group) {
592 610
 
593 611
     $key = $group->get_id();
594
-    if ( !isset($this->_frames[$key]) )
595
-      return;  // Presumably this row has alredy been removed
612
+    if ( !isset($this->_frames[$key]) ) {
613
+          return;
614
+    }
615
+    // Presumably this row has alredy been removed
596 616
 
597 617
     $iter = $group->get_first_child();
598 618
     while ($iter) {
@@ -643,16 +663,18 @@  discard block
 block discarded – undo
643 663
 
644 664
       $h = 0;
645 665
       foreach( $arr["rows"] as $row ) {
646
-        if ( !isset($this->_rows[$row]) )
647
-          // The row has been removed because of a page split, so skip it.
666
+        if ( !isset($this->_rows[$row]) ) {
667
+                  // The row has been removed because of a page split, so skip it.
648 668
           continue;
669
+        }
649 670
         $h += $this->_rows[$row]["height"];
650 671
       }
651 672
 
652
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
653
-        $frame->set_cell_height($h);
654
-      else
655
-        $frame->get_style()->height = $h;
673
+      if ( $frame instanceof Table_Cell_Frame_Decorator ) {
674
+              $frame->set_cell_height($h);
675
+      } else {
676
+              $frame->get_style()->height = $h;
677
+      }
656 678
     }
657 679
 
658 680
   }
@@ -671,18 +693,20 @@  discard block
 block discarded – undo
671 693
 
672 694
       $h = 0;
673 695
       foreach ($arr["rows"] as $row ) {
674
-        if ( !isset($this->_rows[$row]) )
675
-          continue;
696
+        if ( !isset($this->_rows[$row]) ) {
697
+                  continue;
698
+        }
676 699
 
677 700
         $h += $this->_rows[$row]["height"];
678 701
       }
679 702
 
680 703
       $new_height = ($h / $content_height) * $table_height;
681 704
 
682
-      if ( $frame instanceof Table_Cell_Frame_Decorator )
683
-        $frame->set_cell_height($new_height);
684
-      else
685
-        $frame->get_style()->height = $new_height;
705
+      if ( $frame instanceof Table_Cell_Frame_Decorator ) {
706
+              $frame->set_cell_height($new_height);
707
+      } else {
708
+              $frame->get_style()->height = $new_height;
709
+      }
686 710
     }
687 711
 
688 712
   }
@@ -699,15 +723,17 @@  discard block
 block discarded – undo
699 723
 
700 724
     $str .=  "Frames:<br/>";
701 725
     $arr = array();
702
-    foreach ( $this->_frames as $key => $val )
703
-      $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
726
+    foreach ( $this->_frames as $key => $val ) {
727
+          $arr[$key] = array("columns" => $val["columns"], "rows" => $val["rows"]);
728
+    }
704 729
 
705 730
     $str .= pre_r($arr, true);
706 731
 
707
-    if ( php_sapi_name() == "cli" )
708
-      $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
732
+    if ( php_sapi_name() == "cli" ) {
733
+          $str = strip_tags(str_replace(array("<br/>","<b>","</b>"),
709 734
                                     array("\n",chr(27)."[01;33m", chr(27)."[0m"),
710 735
                                     $str));
736
+    }
711 737
     return $str;
712 738
   }
713 739
 }
Please login to merge, or discard this patch.
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.