@@ -26,85 +26,85 @@ |
||
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 | } |
@@ -26,334 +26,334 @@ |
||
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 |
@@ -47,85 +47,84 @@ |
||
47 | 47 | * Tue Sep 8 21:51:04 2009,120 [5485] FATAL root - Some critical message! |
48 | 48 | * Tue Sep 8 21:51:06 2009,120 [5485] FATAL root - Some more critical message! |
49 | 49 | * </pre> |
50 | - |
|
51 | 50 | * @version $Revision: 883108 $ |
52 | 51 | * @package log4php |
53 | 52 | * @subpackage appenders |
54 | 53 | */ |
55 | 54 | class LoggerAppenderMail extends LoggerAppender { |
56 | 55 | |
57 | - /** @var string 'from' field */ |
|
58 | - private $from = null; |
|
56 | + /** @var string 'from' field */ |
|
57 | + private $from = null; |
|
59 | 58 | |
60 | - /** @var string 'subject' field */ |
|
61 | - private $subject = 'Log4php Report'; |
|
59 | + /** @var string 'subject' field */ |
|
60 | + private $subject = 'Log4php Report'; |
|
62 | 61 | |
63 | - /** @var string 'to' field */ |
|
64 | - private $to = null; |
|
62 | + /** @var string 'to' field */ |
|
63 | + private $to = null; |
|
65 | 64 | |
66 | - /** @var indiciates if this appender should run in dry mode */ |
|
67 | - private $dry = false; |
|
65 | + /** @var indiciates if this appender should run in dry mode */ |
|
66 | + private $dry = false; |
|
68 | 67 | |
69 | - /** @var string used to create mail body */ |
|
70 | - private $body = ''; |
|
68 | + /** @var string used to create mail body */ |
|
69 | + private $body = ''; |
|
71 | 70 | |
72 | - /** |
|
73 | - * Constructor. |
|
74 | - * |
|
75 | - * @param string $name appender name |
|
76 | - */ |
|
77 | - public function __construct($name = '') { |
|
78 | - parent::__construct($name); |
|
79 | - $this->requiresLayout = true; |
|
80 | - } |
|
71 | + /** |
|
72 | + * Constructor. |
|
73 | + * |
|
74 | + * @param string $name appender name |
|
75 | + */ |
|
76 | + public function __construct($name = '') { |
|
77 | + parent::__construct($name); |
|
78 | + $this->requiresLayout = true; |
|
79 | + } |
|
81 | 80 | |
82 | - public function __destruct() { |
|
83 | - $this->close(); |
|
84 | - } |
|
81 | + public function __destruct() { |
|
82 | + $this->close(); |
|
83 | + } |
|
85 | 84 | |
86 | - public function activateOptions() { |
|
87 | - $this->closed = false; |
|
88 | - } |
|
85 | + public function activateOptions() { |
|
86 | + $this->closed = false; |
|
87 | + } |
|
89 | 88 | |
90 | - public function close() { |
|
91 | - if($this->closed != true) { |
|
92 | - $from = $this->from; |
|
93 | - $to = $this->to; |
|
89 | + public function close() { |
|
90 | + if($this->closed != true) { |
|
91 | + $from = $this->from; |
|
92 | + $to = $this->to; |
|
94 | 93 | |
95 | - if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
96 | - $subject = $this->subject; |
|
97 | - if(!$this->dry) { |
|
98 | - mail( |
|
99 | - $to, $subject, |
|
100 | - $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
101 | - "From: {$from}\r\n"); |
|
102 | - } else { |
|
103 | - echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body; |
|
104 | - } |
|
105 | - } |
|
106 | - $this->closed = true; |
|
107 | - } |
|
108 | - } |
|
94 | + if(!empty($this->body) and $from !== null and $to !== null and $this->layout !== null) { |
|
95 | + $subject = $this->subject; |
|
96 | + if(!$this->dry) { |
|
97 | + mail( |
|
98 | + $to, $subject, |
|
99 | + $this->layout->getHeader() . $this->body . $this->layout->getFooter(), |
|
100 | + "From: {$from}\r\n"); |
|
101 | + } else { |
|
102 | + echo "DRY MODE OF MAIL APP.: Send mail to: ".$to." with content: ".$this->body; |
|
103 | + } |
|
104 | + } |
|
105 | + $this->closed = true; |
|
106 | + } |
|
107 | + } |
|
109 | 108 | |
110 | - public function setSubject($subject) { |
|
111 | - $this->subject = $subject; |
|
112 | - } |
|
109 | + public function setSubject($subject) { |
|
110 | + $this->subject = $subject; |
|
111 | + } |
|
113 | 112 | |
114 | - public function setTo($to) { |
|
115 | - $this->to = $to; |
|
116 | - } |
|
113 | + public function setTo($to) { |
|
114 | + $this->to = $to; |
|
115 | + } |
|
117 | 116 | |
118 | - public function setFrom($from) { |
|
119 | - $this->from = $from; |
|
120 | - } |
|
117 | + public function setFrom($from) { |
|
118 | + $this->from = $from; |
|
119 | + } |
|
121 | 120 | |
122 | - public function setDry($dry) { |
|
123 | - $this->dry = $dry; |
|
124 | - } |
|
121 | + public function setDry($dry) { |
|
122 | + $this->dry = $dry; |
|
123 | + } |
|
125 | 124 | |
126 | - public function append(LoggerLoggingEvent $event) { |
|
127 | - if($this->layout !== null) { |
|
128 | - $this->body .= $this->layout->format($event); |
|
129 | - } |
|
130 | - } |
|
125 | + public function append(LoggerLoggingEvent $event) { |
|
126 | + if($this->layout !== null) { |
|
127 | + $this->body .= $this->layout->format($event); |
|
128 | + } |
|
129 | + } |
|
131 | 130 | } |
@@ -46,47 +46,47 @@ |
||
46 | 46 | */ |
47 | 47 | class LoggerAppenderDailyFile extends LoggerAppenderFile { |
48 | 48 | |
49 | - /** |
|
50 | - * Format date. |
|
51 | - * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>. |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - public $datePattern = "Ymd"; |
|
49 | + /** |
|
50 | + * Format date. |
|
51 | + * It follows the {@link PHP_MANUAL#date()} formatting rules and <b>should always be set before {@link $file} param</b>. |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + public $datePattern = "Ymd"; |
|
55 | 55 | |
56 | - public function __destruct() { |
|
57 | - parent::__destruct(); |
|
58 | - } |
|
56 | + public function __destruct() { |
|
57 | + parent::__destruct(); |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Sets date format for the file name. |
|
62 | - * @param string $format a regular date() string format |
|
63 | - */ |
|
64 | - public function setDatePattern($format) { |
|
65 | - $this->datePattern = $format; |
|
66 | - } |
|
60 | + /** |
|
61 | + * Sets date format for the file name. |
|
62 | + * @param string $format a regular date() string format |
|
63 | + */ |
|
64 | + public function setDatePattern($format) { |
|
65 | + $this->datePattern = $format; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * @return string returns date format for the filename |
|
70 | - */ |
|
71 | - public function getDatePattern() { |
|
72 | - return $this->datePattern; |
|
73 | - } |
|
68 | + /** |
|
69 | + * @return string returns date format for the filename |
|
70 | + */ |
|
71 | + public function getDatePattern() { |
|
72 | + return $this->datePattern; |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * The File property takes a string value which should be the name of the file to append to. |
|
77 | - * Sets and opens the file where the log output will go. |
|
78 | - * |
|
79 | - * @see LoggerAppenderFile::setFile() |
|
80 | - */ |
|
81 | - public function setFile() { |
|
82 | - $numargs = func_num_args(); |
|
83 | - $args = func_get_args(); |
|
75 | + /** |
|
76 | + * The File property takes a string value which should be the name of the file to append to. |
|
77 | + * Sets and opens the file where the log output will go. |
|
78 | + * |
|
79 | + * @see LoggerAppenderFile::setFile() |
|
80 | + */ |
|
81 | + public function setFile() { |
|
82 | + $numargs = func_num_args(); |
|
83 | + $args = func_get_args(); |
|
84 | 84 | |
85 | - if($numargs == 1 and is_string($args[0])) { |
|
86 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) ); |
|
87 | - } else if ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) { |
|
88 | - parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] ); |
|
89 | - } |
|
90 | - } |
|
85 | + if($numargs == 1 and is_string($args[0])) { |
|
86 | + parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) ); |
|
87 | + } else if ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) { |
|
88 | + parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] ); |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
@@ -42,129 +42,129 @@ |
||
42 | 42 | */ |
43 | 43 | class LoggerAppenderFile extends LoggerAppender { |
44 | 44 | |
45 | - /** |
|
46 | - * @var boolean if {@link $file} exists, appends events. |
|
47 | - */ |
|
48 | - private $append = true; |
|
49 | - /** |
|
50 | - * @var string the file name used to append events |
|
51 | - */ |
|
52 | - protected $fileName; |
|
53 | - /** |
|
54 | - * @var mixed file resource |
|
55 | - */ |
|
56 | - protected $fp = false; |
|
45 | + /** |
|
46 | + * @var boolean if {@link $file} exists, appends events. |
|
47 | + */ |
|
48 | + private $append = true; |
|
49 | + /** |
|
50 | + * @var string the file name used to append events |
|
51 | + */ |
|
52 | + protected $fileName; |
|
53 | + /** |
|
54 | + * @var mixed file resource |
|
55 | + */ |
|
56 | + protected $fp = false; |
|
57 | 57 | |
58 | - public function __construct($name = '') { |
|
59 | - parent::__construct($name); |
|
60 | - $this->requiresLayout = true; |
|
61 | - } |
|
58 | + public function __construct($name = '') { |
|
59 | + parent::__construct($name); |
|
60 | + $this->requiresLayout = true; |
|
61 | + } |
|
62 | 62 | |
63 | - public function __destruct() { |
|
64 | - $this->close(); |
|
65 | - } |
|
63 | + public function __destruct() { |
|
64 | + $this->close(); |
|
65 | + } |
|
66 | 66 | |
67 | - public function activateOptions() { |
|
68 | - $fileName = $this->getFile(); |
|
67 | + public function activateOptions() { |
|
68 | + $fileName = $this->getFile(); |
|
69 | 69 | |
70 | - if(!is_file($fileName)) { |
|
71 | - $dir = dirname($fileName); |
|
72 | - if(!is_dir($dir)) { |
|
73 | - mkdir($dir, 0777, true); |
|
74 | - } |
|
75 | - } |
|
70 | + if(!is_file($fileName)) { |
|
71 | + $dir = dirname($fileName); |
|
72 | + if(!is_dir($dir)) { |
|
73 | + mkdir($dir, 0777, true); |
|
74 | + } |
|
75 | + } |
|
76 | 76 | |
77 | - $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | - if($this->fp) { |
|
79 | - if(flock($this->fp, LOCK_EX)) { |
|
80 | - if($this->getAppend()) { |
|
81 | - fseek($this->fp, 0, SEEK_END); |
|
82 | - } |
|
83 | - fwrite($this->fp, $this->layout->getHeader()); |
|
84 | - flock($this->fp, LOCK_UN); |
|
85 | - $this->closed = false; |
|
86 | - } else { |
|
87 | - // TODO: should we take some action in this case? |
|
88 | - $this->closed = true; |
|
89 | - } |
|
90 | - } else { |
|
91 | - $this->closed = true; |
|
92 | - } |
|
93 | - } |
|
77 | + $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); |
|
78 | + if($this->fp) { |
|
79 | + if(flock($this->fp, LOCK_EX)) { |
|
80 | + if($this->getAppend()) { |
|
81 | + fseek($this->fp, 0, SEEK_END); |
|
82 | + } |
|
83 | + fwrite($this->fp, $this->layout->getHeader()); |
|
84 | + flock($this->fp, LOCK_UN); |
|
85 | + $this->closed = false; |
|
86 | + } else { |
|
87 | + // TODO: should we take some action in this case? |
|
88 | + $this->closed = true; |
|
89 | + } |
|
90 | + } else { |
|
91 | + $this->closed = true; |
|
92 | + } |
|
93 | + } |
|
94 | 94 | |
95 | - public function close() { |
|
96 | - if($this->closed != true) { |
|
97 | - if($this->fp and $this->layout !== null) { |
|
98 | - if(flock($this->fp, LOCK_EX)) { |
|
99 | - fwrite($this->fp, $this->layout->getFooter()); |
|
100 | - flock($this->fp, LOCK_UN); |
|
101 | - } |
|
102 | - fclose($this->fp); |
|
103 | - } |
|
104 | - $this->closed = true; |
|
105 | - } |
|
106 | - } |
|
95 | + public function close() { |
|
96 | + if($this->closed != true) { |
|
97 | + if($this->fp and $this->layout !== null) { |
|
98 | + if(flock($this->fp, LOCK_EX)) { |
|
99 | + fwrite($this->fp, $this->layout->getFooter()); |
|
100 | + flock($this->fp, LOCK_UN); |
|
101 | + } |
|
102 | + fclose($this->fp); |
|
103 | + } |
|
104 | + $this->closed = true; |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - public function append(LoggerLoggingEvent $event) { |
|
109 | - if($this->fp and $this->layout !== null) { |
|
110 | - if(flock($this->fp, LOCK_EX)) { |
|
111 | - fwrite($this->fp, $this->layout->format($event)); |
|
112 | - flock($this->fp, LOCK_UN); |
|
113 | - } else { |
|
114 | - $this->closed = true; |
|
115 | - } |
|
116 | - } |
|
117 | - } |
|
108 | + public function append(LoggerLoggingEvent $event) { |
|
109 | + if($this->fp and $this->layout !== null) { |
|
110 | + if(flock($this->fp, LOCK_EX)) { |
|
111 | + fwrite($this->fp, $this->layout->format($event)); |
|
112 | + flock($this->fp, LOCK_UN); |
|
113 | + } else { |
|
114 | + $this->closed = true; |
|
115 | + } |
|
116 | + } |
|
117 | + } |
|
118 | 118 | |
119 | - /** |
|
120 | - * Sets and opens the file where the log output will go. |
|
121 | - * |
|
122 | - * This is an overloaded method. It can be called with: |
|
123 | - * - setFile(string $fileName) to set filename. |
|
124 | - * - setFile(string $fileName, boolean $append) to set filename and append. |
|
125 | - * |
|
126 | - * TODO: remove overloading. Use only file as alias to filename |
|
127 | - */ |
|
128 | - public function setFile() { |
|
129 | - $numargs = func_num_args(); |
|
130 | - $args = func_get_args(); |
|
119 | + /** |
|
120 | + * Sets and opens the file where the log output will go. |
|
121 | + * |
|
122 | + * This is an overloaded method. It can be called with: |
|
123 | + * - setFile(string $fileName) to set filename. |
|
124 | + * - setFile(string $fileName, boolean $append) to set filename and append. |
|
125 | + * |
|
126 | + * TODO: remove overloading. Use only file as alias to filename |
|
127 | + */ |
|
128 | + public function setFile() { |
|
129 | + $numargs = func_num_args(); |
|
130 | + $args = func_get_args(); |
|
131 | 131 | |
132 | - if($numargs == 1 and is_string($args[0])) { |
|
133 | - $this->setFileName($args[0]); |
|
134 | - } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | - $this->setFile($args[0]); |
|
136 | - $this->setAppend($args[1]); |
|
137 | - } |
|
138 | - } |
|
132 | + if($numargs == 1 and is_string($args[0])) { |
|
133 | + $this->setFileName($args[0]); |
|
134 | + } else if ($numargs >=2 and is_string($args[0]) and is_bool($args[1])) { |
|
135 | + $this->setFile($args[0]); |
|
136 | + $this->setAppend($args[1]); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | |
140 | - /** |
|
141 | - * @return string |
|
142 | - */ |
|
143 | - public function getFile() { |
|
144 | - return $this->getFileName(); |
|
145 | - } |
|
140 | + /** |
|
141 | + * @return string |
|
142 | + */ |
|
143 | + public function getFile() { |
|
144 | + return $this->getFileName(); |
|
145 | + } |
|
146 | 146 | |
147 | - /** |
|
148 | - * @return boolean |
|
149 | - */ |
|
150 | - public function getAppend() { |
|
151 | - return $this->append; |
|
152 | - } |
|
147 | + /** |
|
148 | + * @return boolean |
|
149 | + */ |
|
150 | + public function getAppend() { |
|
151 | + return $this->append; |
|
152 | + } |
|
153 | 153 | |
154 | - public function setAppend($flag) { |
|
155 | - $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
156 | - } |
|
154 | + public function setAppend($flag) { |
|
155 | + $this->append = LoggerOptionConverter::toBoolean($flag, true); |
|
156 | + } |
|
157 | 157 | |
158 | - public function setFileName($fileName) { |
|
159 | - $this->fileName = $fileName; |
|
160 | - } |
|
158 | + public function setFileName($fileName) { |
|
159 | + $this->fileName = $fileName; |
|
160 | + } |
|
161 | 161 | |
162 | - /** |
|
163 | - * @return string |
|
164 | - */ |
|
165 | - public function getFileName() { |
|
166 | - return $this->fileName; |
|
167 | - } |
|
162 | + /** |
|
163 | + * @return string |
|
164 | + */ |
|
165 | + public function getFileName() { |
|
166 | + return $this->fileName; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | |
170 | 170 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: image_renderer.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,7 +46,7 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Image_Renderer extends Abstract_Renderer { |
49 | 48 | |
50 | - function render(Frame $frame) { |
|
49 | + function render(Frame $frame) { |
|
51 | 50 | |
52 | 51 | // Render background & borders |
53 | 52 | //parent::render($frame); |
@@ -65,5 +64,5 @@ discard block |
||
65 | 64 | |
66 | 65 | $this->_canvas->image( $frame->get_image_url(), $frame->get_image_ext(), $x, $y, $w, $h); |
67 | 66 | |
68 | - } |
|
67 | + } |
|
69 | 68 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: block_frame_decorator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,16 +46,16 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
293 | 292 | case "upper-greek": |
294 | 293 | return chr($this->_counters[$id] + 912); |
295 | 294 | } |
296 | - } |
|
295 | + } |
|
297 | 296 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: frame_tree.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -52,118 +51,118 @@ discard block |
||
52 | 51 | */ |
53 | 52 | class Frame_Tree { |
54 | 53 | |
55 | - /** |
|
56 | - * Tags to ignore while parsing the tree |
|
57 | - * |
|
58 | - * @var array |
|
59 | - */ |
|
60 | - static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style", |
|
61 | - "meta", "title", "colgroup", |
|
62 | - "noembed", "noscript", "param", "#comment"); |
|
63 | - /** |
|
64 | - * The main DomDocument |
|
65 | - * |
|
66 | - * @see http://ca2.php.net/manual/en/ref.dom.php |
|
67 | - * @var DomDocument |
|
68 | - */ |
|
69 | - protected $_dom; |
|
70 | - |
|
71 | - /** |
|
72 | - * The root node of the FrameTree. |
|
73 | - * |
|
74 | - * @var Frame |
|
75 | - */ |
|
76 | - protected $_root; |
|
77 | - |
|
78 | - /** |
|
79 | - * Subtrees of absolutely positioned elements |
|
80 | - * |
|
81 | - * @var array of Frames |
|
82 | - */ |
|
83 | - protected $_absolute_frames; |
|
84 | - |
|
85 | - /** |
|
86 | - * A mapping of {@link Frame} objects to DomNode objects |
|
87 | - * |
|
88 | - * @var array |
|
89 | - */ |
|
90 | - protected $_registry; |
|
54 | + /** |
|
55 | + * Tags to ignore while parsing the tree |
|
56 | + * |
|
57 | + * @var array |
|
58 | + */ |
|
59 | + static protected $_HIDDEN_TAGS = array("area", "base", "basefont", "head", "style", |
|
60 | + "meta", "title", "colgroup", |
|
61 | + "noembed", "noscript", "param", "#comment"); |
|
62 | + /** |
|
63 | + * The main DomDocument |
|
64 | + * |
|
65 | + * @see http://ca2.php.net/manual/en/ref.dom.php |
|
66 | + * @var DomDocument |
|
67 | + */ |
|
68 | + protected $_dom; |
|
69 | + |
|
70 | + /** |
|
71 | + * The root node of the FrameTree. |
|
72 | + * |
|
73 | + * @var Frame |
|
74 | + */ |
|
75 | + protected $_root; |
|
76 | + |
|
77 | + /** |
|
78 | + * Subtrees of absolutely positioned elements |
|
79 | + * |
|
80 | + * @var array of Frames |
|
81 | + */ |
|
82 | + protected $_absolute_frames; |
|
83 | + |
|
84 | + /** |
|
85 | + * A mapping of {@link Frame} objects to DomNode objects |
|
86 | + * |
|
87 | + * @var array |
|
88 | + */ |
|
89 | + protected $_registry; |
|
91 | 90 | |
92 | 91 | |
93 | - /** |
|
94 | - * Class constructor |
|
95 | - * |
|
96 | - * @param DomDocument $dom the main DomDocument object representing the current html document |
|
97 | - */ |
|
98 | - function __construct(DomDocument $dom) { |
|
92 | + /** |
|
93 | + * Class constructor |
|
94 | + * |
|
95 | + * @param DomDocument $dom the main DomDocument object representing the current html document |
|
96 | + */ |
|
97 | + function __construct(DomDocument $dom) { |
|
99 | 98 | $this->_dom = $dom; |
100 | 99 | $this->_root = null; |
101 | 100 | $this->_registry = array(); |
102 | - } |
|
103 | - |
|
104 | - /** |
|
105 | - * Returns the DomDocument object representing the curent html document |
|
106 | - * |
|
107 | - * @return DomDocument |
|
108 | - */ |
|
109 | - function get_dom() { return $this->_dom; } |
|
110 | - |
|
111 | - /** |
|
112 | - * Returns the root frame of the tree |
|
113 | - * |
|
114 | - * @return Frame |
|
115 | - */ |
|
116 | - function get_root() { return $this->_root; } |
|
117 | - |
|
118 | - /** |
|
119 | - * Returns a specific frame given its id |
|
120 | - * |
|
121 | - * @param string $id |
|
122 | - * @return Frame |
|
123 | - */ |
|
124 | - function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns a post-order iterator for all frames in the tree |
|
128 | - * |
|
129 | - * @return FrameTreeList |
|
130 | - */ |
|
131 | - function get_frames() { return new FrameTreeList($this->_root); } |
|
101 | + } |
|
102 | + |
|
103 | + /** |
|
104 | + * Returns the DomDocument object representing the curent html document |
|
105 | + * |
|
106 | + * @return DomDocument |
|
107 | + */ |
|
108 | + function get_dom() { return $this->_dom; } |
|
109 | + |
|
110 | + /** |
|
111 | + * Returns the root frame of the tree |
|
112 | + * |
|
113 | + * @return Frame |
|
114 | + */ |
|
115 | + function get_root() { return $this->_root; } |
|
116 | + |
|
117 | + /** |
|
118 | + * Returns a specific frame given its id |
|
119 | + * |
|
120 | + * @param string $id |
|
121 | + * @return Frame |
|
122 | + */ |
|
123 | + function get_frame($id) { return isset($this->_registry[$id]) ? $this->_registry[$id] : null; } |
|
124 | + |
|
125 | + /** |
|
126 | + * Returns a post-order iterator for all frames in the tree |
|
127 | + * |
|
128 | + * @return FrameTreeList |
|
129 | + */ |
|
130 | + function get_frames() { return new FrameTreeList($this->_root); } |
|
132 | 131 | |
133 | - /** |
|
134 | - * Builds the tree |
|
135 | - */ |
|
136 | - function build_tree() { |
|
132 | + /** |
|
133 | + * Builds the tree |
|
134 | + */ |
|
135 | + function build_tree() { |
|
137 | 136 | $html = $this->_dom->getElementsByTagName("html")->item(0); |
138 | 137 | if ( is_null($html) ) |
139 | - $html = $this->_dom->firstChild; |
|
138 | + $html = $this->_dom->firstChild; |
|
140 | 139 | |
141 | 140 | if ( is_null($html) ) |
142 | - throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
141 | + throw new DOMPDF_Exception("Requested HTML document contains no data."); |
|
143 | 142 | |
144 | 143 | $this->_root = $this->_build_tree_r($html); |
145 | 144 | |
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Recursively adds {@link Frame} objects to the tree |
|
150 | - * |
|
151 | - * Recursively build a tree of Frame objects based on a dom tree. |
|
152 | - * No layout information is calculated at this time, although the |
|
153 | - * tree may be adjusted (i.e. nodes and frames for generated content |
|
154 | - * and images may be created). |
|
155 | - * |
|
156 | - * @param DomNode $node the current DomNode being considered |
|
157 | - * @return Frame |
|
158 | - */ |
|
159 | - protected function _build_tree_r(DomNode $node) { |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Recursively adds {@link Frame} objects to the tree |
|
149 | + * |
|
150 | + * Recursively build a tree of Frame objects based on a dom tree. |
|
151 | + * No layout information is calculated at this time, although the |
|
152 | + * tree may be adjusted (i.e. nodes and frames for generated content |
|
153 | + * and images may be created). |
|
154 | + * |
|
155 | + * @param DomNode $node the current DomNode being considered |
|
156 | + * @return Frame |
|
157 | + */ |
|
158 | + protected function _build_tree_r(DomNode $node) { |
|
160 | 159 | |
161 | 160 | $frame = new Frame($node); |
162 | 161 | $id = $frame->get_id(); |
163 | 162 | $this->_registry[ $id ] = $frame; |
164 | 163 | |
165 | 164 | if ( !$node->hasChildNodes() ) |
166 | - return $frame; |
|
165 | + return $frame; |
|
167 | 166 | |
168 | 167 | // Fixes 'cannot access undefined property for object with |
169 | 168 | // overloaded access', fix by Stefan radulian |
@@ -173,55 +172,55 @@ discard block |
||
173 | 172 | // Store the children in an array so that the tree can be modified |
174 | 173 | $children = array(); |
175 | 174 | for ($i = 0; $i < $node->childNodes->length; $i++) |
176 | - $children[] = $node->childNodes->item($i); |
|
175 | + $children[] = $node->childNodes->item($i); |
|
177 | 176 | |
178 | 177 | foreach ($children as $child) { |
179 | - // Skip non-displaying nodes |
|
180 | - if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
|
178 | + // Skip non-displaying nodes |
|
179 | + if ( in_array( mb_strtolower($child->nodeName), self::$_HIDDEN_TAGS) ) { |
|
181 | 180 | if ( mb_strtolower($child->nodeName) !== "head" && |
182 | 181 | mb_strtolower($child->nodeName) !== "style" ) |
183 | - $child->parentNode->removeChild($child); |
|
182 | + $child->parentNode->removeChild($child); |
|
184 | 183 | continue; |
185 | - } |
|
184 | + } |
|
186 | 185 | |
187 | - // Skip empty text nodes |
|
188 | - if ( $child->nodeName === "#text" && $child->nodeValue == "" ) { |
|
186 | + // Skip empty text nodes |
|
187 | + if ( $child->nodeName === "#text" && $child->nodeValue == "" ) { |
|
189 | 188 | $child->parentNode->removeChild($child); |
190 | 189 | continue; |
191 | - } |
|
190 | + } |
|
192 | 191 | |
193 | - // Skip empty image nodes |
|
194 | - if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) { |
|
192 | + // Skip empty image nodes |
|
193 | + if ( $child->nodeName === "img" && $child->getAttribute("src") == "" ) { |
|
195 | 194 | $child->parentNode->removeChild($child); |
196 | 195 | continue; |
197 | - } |
|
196 | + } |
|
198 | 197 | |
199 | - // Add a container frame for images |
|
200 | - if ( $child->nodeName === "img" ) { |
|
198 | + // Add a container frame for images |
|
199 | + if ( $child->nodeName === "img" ) { |
|
201 | 200 | $img_node = $child->ownerDocument->createElement("img_inner"); |
202 | 201 | |
203 | 202 | // Move attributes to inner node |
204 | 203 | foreach ( $child->attributes as $attr => $attr_node ) { |
205 | - // Skip style, but move all other attributes |
|
206 | - if ( $attr === "style" ) |
|
204 | + // Skip style, but move all other attributes |
|
205 | + if ( $attr === "style" ) |
|
207 | 206 | continue; |
208 | 207 | |
209 | - $img_node->setAttribute($attr, $attr_node->value); |
|
208 | + $img_node->setAttribute($attr, $attr_node->value); |
|
210 | 209 | } |
211 | 210 | |
212 | 211 | foreach ( $child->attributes as $attr => $node ) { |
213 | - if ( $attr === "style" ) |
|
212 | + if ( $attr === "style" ) |
|
214 | 213 | continue; |
215 | - $child->removeAttribute($attr); |
|
214 | + $child->removeAttribute($attr); |
|
216 | 215 | } |
217 | 216 | |
218 | 217 | $child->appendChild($img_node); |
219 | - } |
|
218 | + } |
|
220 | 219 | |
221 | - $frame->append_child($this->_build_tree_r($child), false); |
|
220 | + $frame->append_child($this->_build_tree_r($child), false); |
|
222 | 221 | |
223 | 222 | } |
224 | 223 | |
225 | 224 | return $frame; |
226 | - } |
|
225 | + } |
|
227 | 226 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: canvas.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -54,207 +53,207 @@ discard block |
||
54 | 53 | */ |
55 | 54 | interface Canvas { |
56 | 55 | |
57 | - /** |
|
58 | - * Returns the current page number |
|
59 | - * |
|
60 | - * @return int |
|
61 | - */ |
|
62 | - function get_page_number(); |
|
56 | + /** |
|
57 | + * Returns the current page number |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + function get_page_number(); |
|
63 | 62 | |
64 | - /** |
|
65 | - * Returns the total number of pages |
|
66 | - * |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - function get_page_count(); |
|
63 | + /** |
|
64 | + * Returns the total number of pages |
|
65 | + * |
|
66 | + * @return int |
|
67 | + */ |
|
68 | + function get_page_count(); |
|
70 | 69 | |
71 | - /** |
|
72 | - * Sets the total number of pages |
|
73 | - * |
|
74 | - * @param int $count |
|
75 | - */ |
|
76 | - function set_page_count($count); |
|
70 | + /** |
|
71 | + * Sets the total number of pages |
|
72 | + * |
|
73 | + * @param int $count |
|
74 | + */ |
|
75 | + function set_page_count($count); |
|
77 | 76 | |
78 | - /** |
|
79 | - * Draws a line from x1,y1 to x2,y2 |
|
80 | - * |
|
81 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
82 | - * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
83 | - * $style parameter (aka dash). |
|
84 | - * |
|
85 | - * @param float $x1 |
|
86 | - * @param float $y1 |
|
87 | - * @param float $x2 |
|
88 | - * @param float $y2 |
|
89 | - * @param array $color |
|
90 | - * @param float $width |
|
91 | - * @param array $style |
|
92 | - */ |
|
93 | - function line($x1, $y1, $x2, $y2, $color, $width, $style = null); |
|
77 | + /** |
|
78 | + * Draws a line from x1,y1 to x2,y2 |
|
79 | + * |
|
80 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
81 | + * See {@link Cpdf::setLineStyle()} for a description of the format of the |
|
82 | + * $style parameter (aka dash). |
|
83 | + * |
|
84 | + * @param float $x1 |
|
85 | + * @param float $y1 |
|
86 | + * @param float $x2 |
|
87 | + * @param float $y2 |
|
88 | + * @param array $color |
|
89 | + * @param float $width |
|
90 | + * @param array $style |
|
91 | + */ |
|
92 | + function line($x1, $y1, $x2, $y2, $color, $width, $style = null); |
|
94 | 93 | |
95 | - /** |
|
96 | - * Draws a rectangle at x1,y1 with width w and height h |
|
97 | - * |
|
98 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
99 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
100 | - * parameter (aka dash) |
|
101 | - * |
|
102 | - * @param float $x1 |
|
103 | - * @param float $y1 |
|
104 | - * @param float $w |
|
105 | - * @param float $h |
|
106 | - * @param array $color |
|
107 | - * @param float $width |
|
108 | - * @param array $style |
|
109 | - */ |
|
110 | - function rectangle($x1, $y1, $w, $h, $color, $width, $style = null); |
|
94 | + /** |
|
95 | + * Draws a rectangle at x1,y1 with width w and height h |
|
96 | + * |
|
97 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
98 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
99 | + * parameter (aka dash) |
|
100 | + * |
|
101 | + * @param float $x1 |
|
102 | + * @param float $y1 |
|
103 | + * @param float $w |
|
104 | + * @param float $h |
|
105 | + * @param array $color |
|
106 | + * @param float $width |
|
107 | + * @param array $style |
|
108 | + */ |
|
109 | + function rectangle($x1, $y1, $w, $h, $color, $width, $style = null); |
|
111 | 110 | |
112 | - /** |
|
113 | - * Draws a filled rectangle at x1,y1 with width w and height h |
|
114 | - * |
|
115 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
116 | - * |
|
117 | - * @param float $x1 |
|
118 | - * @param float $y1 |
|
119 | - * @param float $w |
|
120 | - * @param float $h |
|
121 | - * @param array $color |
|
122 | - */ |
|
123 | - function filled_rectangle($x1, $y1, $w, $h, $color); |
|
111 | + /** |
|
112 | + * Draws a filled rectangle at x1,y1 with width w and height h |
|
113 | + * |
|
114 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
115 | + * |
|
116 | + * @param float $x1 |
|
117 | + * @param float $y1 |
|
118 | + * @param float $w |
|
119 | + * @param float $h |
|
120 | + * @param array $color |
|
121 | + */ |
|
122 | + function filled_rectangle($x1, $y1, $w, $h, $color); |
|
124 | 123 | |
125 | - /** |
|
126 | - * Draws a polygon |
|
127 | - * |
|
128 | - * The polygon is formed by joining all the points stored in the $points |
|
129 | - * array. $points has the following structure: |
|
130 | - * <code> |
|
131 | - * array(0 => x1, |
|
132 | - * 1 => y1, |
|
133 | - * 2 => x2, |
|
134 | - * 3 => y2, |
|
135 | - * ... |
|
136 | - * ); |
|
137 | - * </code> |
|
138 | - * |
|
139 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
140 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
141 | - * parameter (aka dash) |
|
142 | - * |
|
143 | - * @param array $points |
|
144 | - * @param array $color |
|
145 | - * @param float $width |
|
146 | - * @param array $style |
|
147 | - * @param bool $fill Fills the polygon if true |
|
148 | - */ |
|
149 | - function polygon($points, $color, $width = null, $style = null, $fill = false); |
|
124 | + /** |
|
125 | + * Draws a polygon |
|
126 | + * |
|
127 | + * The polygon is formed by joining all the points stored in the $points |
|
128 | + * array. $points has the following structure: |
|
129 | + * <code> |
|
130 | + * array(0 => x1, |
|
131 | + * 1 => y1, |
|
132 | + * 2 => x2, |
|
133 | + * 3 => y2, |
|
134 | + * ... |
|
135 | + * ); |
|
136 | + * </code> |
|
137 | + * |
|
138 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
139 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
140 | + * parameter (aka dash) |
|
141 | + * |
|
142 | + * @param array $points |
|
143 | + * @param array $color |
|
144 | + * @param float $width |
|
145 | + * @param array $style |
|
146 | + * @param bool $fill Fills the polygon if true |
|
147 | + */ |
|
148 | + function polygon($points, $color, $width = null, $style = null, $fill = false); |
|
150 | 149 | |
151 | - /** |
|
152 | - * Draws a circle at $x,$y with radius $r |
|
153 | - * |
|
154 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
155 | - * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
156 | - * parameter (aka dash) |
|
157 | - * |
|
158 | - * @param float $x |
|
159 | - * @param float $y |
|
160 | - * @param float $r |
|
161 | - * @param array $color |
|
162 | - * @param float $width |
|
163 | - * @param array $style |
|
164 | - * @param bool $fill Fills the circle if true |
|
165 | - */ |
|
166 | - function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false); |
|
150 | + /** |
|
151 | + * Draws a circle at $x,$y with radius $r |
|
152 | + * |
|
153 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
154 | + * See {@link Cpdf::setLineStyle()} for a description of the $style |
|
155 | + * parameter (aka dash) |
|
156 | + * |
|
157 | + * @param float $x |
|
158 | + * @param float $y |
|
159 | + * @param float $r |
|
160 | + * @param array $color |
|
161 | + * @param float $width |
|
162 | + * @param array $style |
|
163 | + * @param bool $fill Fills the circle if true |
|
164 | + */ |
|
165 | + function circle($x, $y, $r, $color, $width = null, $style = null, $fill = false); |
|
167 | 166 | |
168 | - /** |
|
169 | - * Add an image to the pdf. |
|
170 | - * |
|
171 | - * The image is placed at the specified x and y coordinates with the |
|
172 | - * given width and height. |
|
173 | - * |
|
174 | - * @param string $img_url the path to the image |
|
175 | - * @param string $img_type the type (e.g. extension) of the image |
|
176 | - * @param float $x x position |
|
177 | - * @param float $y y position |
|
178 | - * @param int $w width (in pixels) |
|
179 | - * @param int $h height (in pixels) |
|
180 | - */ |
|
181 | - function image($img_url, $img_type, $x, $y, $w, $h); |
|
167 | + /** |
|
168 | + * Add an image to the pdf. |
|
169 | + * |
|
170 | + * The image is placed at the specified x and y coordinates with the |
|
171 | + * given width and height. |
|
172 | + * |
|
173 | + * @param string $img_url the path to the image |
|
174 | + * @param string $img_type the type (e.g. extension) of the image |
|
175 | + * @param float $x x position |
|
176 | + * @param float $y y position |
|
177 | + * @param int $w width (in pixels) |
|
178 | + * @param int $h height (in pixels) |
|
179 | + */ |
|
180 | + function image($img_url, $img_type, $x, $y, $w, $h); |
|
182 | 181 | |
183 | - /** |
|
184 | - * Writes text at the specified x and y coordinates |
|
185 | - * |
|
186 | - * See {@link Style::munge_colour()} for the format of the colour array. |
|
187 | - * |
|
188 | - * @param float $x |
|
189 | - * @param float $y |
|
190 | - * @param string $text the text to write |
|
191 | - * @param string $font the font file to use |
|
192 | - * @param float $size the font size, in points |
|
193 | - * @param array $color |
|
194 | - * @param float $adjust word spacing adjustment |
|
195 | - */ |
|
196 | - function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0); |
|
182 | + /** |
|
183 | + * Writes text at the specified x and y coordinates |
|
184 | + * |
|
185 | + * See {@link Style::munge_colour()} for the format of the colour array. |
|
186 | + * |
|
187 | + * @param float $x |
|
188 | + * @param float $y |
|
189 | + * @param string $text the text to write |
|
190 | + * @param string $font the font file to use |
|
191 | + * @param float $size the font size, in points |
|
192 | + * @param array $color |
|
193 | + * @param float $adjust word spacing adjustment |
|
194 | + */ |
|
195 | + function text($x, $y, $text, $font, $size, $color = array(0,0,0), $adjust = 0); |
|
197 | 196 | |
198 | - /** |
|
199 | - * Add a named destination (similar to <a name="foo">...</a> in html) |
|
200 | - * |
|
201 | - * @param string $anchorname The name of the named destination |
|
202 | - */ |
|
203 | - function add_named_dest($anchorname); |
|
197 | + /** |
|
198 | + * Add a named destination (similar to <a name="foo">...</a> in html) |
|
199 | + * |
|
200 | + * @param string $anchorname The name of the named destination |
|
201 | + */ |
|
202 | + function add_named_dest($anchorname); |
|
204 | 203 | |
205 | - /** |
|
206 | - * Add a link to the pdf |
|
207 | - * |
|
208 | - * @param string $url The url to link to |
|
209 | - * @param float $x The x position of the link |
|
210 | - * @param float $y The y position of the link |
|
211 | - * @param float $width The width of the link |
|
212 | - * @param float $height The height of the link |
|
213 | - */ |
|
214 | - function add_link($url, $x, $y, $width, $height); |
|
204 | + /** |
|
205 | + * Add a link to the pdf |
|
206 | + * |
|
207 | + * @param string $url The url to link to |
|
208 | + * @param float $x The x position of the link |
|
209 | + * @param float $y The y position of the link |
|
210 | + * @param float $width The width of the link |
|
211 | + * @param float $height The height of the link |
|
212 | + */ |
|
213 | + function add_link($url, $x, $y, $width, $height); |
|
215 | 214 | |
216 | - /** |
|
217 | - * Calculates text size, in points |
|
218 | - * |
|
219 | - * @param string $text the text to be sized |
|
220 | - * @param string $font the desired font |
|
221 | - * @param float $size the desired font size |
|
222 | - * @param float $spacing word spacing, if any |
|
223 | - * @return float |
|
224 | - */ |
|
225 | - function get_text_width($text, $font, $size, $spacing = 0); |
|
215 | + /** |
|
216 | + * Calculates text size, in points |
|
217 | + * |
|
218 | + * @param string $text the text to be sized |
|
219 | + * @param string $font the desired font |
|
220 | + * @param float $size the desired font size |
|
221 | + * @param float $spacing word spacing, if any |
|
222 | + * @return float |
|
223 | + */ |
|
224 | + function get_text_width($text, $font, $size, $spacing = 0); |
|
226 | 225 | |
227 | - /** |
|
228 | - * Calculates font height, in points |
|
229 | - * |
|
230 | - * @param string $font |
|
231 | - * @param float $size |
|
232 | - * @return float |
|
233 | - */ |
|
234 | - function get_font_height($font, $size); |
|
226 | + /** |
|
227 | + * Calculates font height, in points |
|
228 | + * |
|
229 | + * @param string $font |
|
230 | + * @param float $size |
|
231 | + * @return float |
|
232 | + */ |
|
233 | + function get_font_height($font, $size); |
|
235 | 234 | |
236 | 235 | |
237 | - /** |
|
238 | - * Starts a new page |
|
239 | - * |
|
240 | - * Subsequent drawing operations will appear on the new page. |
|
241 | - */ |
|
242 | - function new_page(); |
|
236 | + /** |
|
237 | + * Starts a new page |
|
238 | + * |
|
239 | + * Subsequent drawing operations will appear on the new page. |
|
240 | + */ |
|
241 | + function new_page(); |
|
243 | 242 | |
244 | - /** |
|
245 | - * Streams the PDF directly to the browser |
|
246 | - * |
|
247 | - * @param string $filename the name of the PDF file |
|
248 | - * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
249 | - */ |
|
250 | - function stream($filename, $options = null); |
|
243 | + /** |
|
244 | + * Streams the PDF directly to the browser |
|
245 | + * |
|
246 | + * @param string $filename the name of the PDF file |
|
247 | + * @param array $options associative array, 'Attachment' => 0 or 1, 'compress' => 1 or 0 |
|
248 | + */ |
|
249 | + function stream($filename, $options = null); |
|
251 | 250 | |
252 | - /** |
|
253 | - * Returns the PDF as a string |
|
254 | - * |
|
255 | - * @param array $options associative array: 'compress' => 1 or 0 |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - function output($options = null); |
|
251 | + /** |
|
252 | + * Returns the PDF as a string |
|
253 | + * |
|
254 | + * @param array $options associative array: 'compress' => 1 or 0 |
|
255 | + * @return string |
|
256 | + */ |
|
257 | + function output($options = null); |
|
259 | 258 | |
260 | 259 | } |