@@ -29,193 +29,193 @@ discard block |
||
29 | 29 | */ |
30 | 30 | class LoggerOptionConverter { |
31 | 31 | |
32 | - const DELIM_START = '${'; |
|
33 | - const DELIM_STOP = '}'; |
|
34 | - const DELIM_START_LEN = 2; |
|
35 | - const DELIM_STOP_LEN = 1; |
|
32 | + const DELIM_START = '${'; |
|
33 | + const DELIM_STOP = '}'; |
|
34 | + const DELIM_START_LEN = 2; |
|
35 | + const DELIM_STOP_LEN = 1; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Read a predefined var. |
|
39 | - * |
|
40 | - * It returns a value referenced by <var>$key</var> using this search criteria: |
|
41 | - * - if <var>$key</var> is a constant then return it. Else |
|
42 | - * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else |
|
43 | - * - return <var>$def</var>. |
|
44 | - * |
|
45 | - * @param string $key The key to search for. |
|
46 | - * @param string $def The default value to return. |
|
47 | - * @return string the string value of the system property, or the default |
|
48 | - * value if there is no property with that key. |
|
49 | - * |
|
50 | - * @static |
|
51 | - */ |
|
52 | - public static function getSystemProperty($key, $def) { |
|
53 | - if(defined($key)) { |
|
54 | - return (string)constant($key); |
|
55 | - } else if(isset($_SERVER[$key])) { |
|
56 | - return (string)$_SERVER[$key]; |
|
57 | - } else if(isset($_ENV[$key])) { |
|
58 | - return (string)$_ENV[$key]; |
|
59 | - } else { |
|
60 | - return $def; |
|
61 | - } |
|
62 | - } |
|
37 | + /** |
|
38 | + * Read a predefined var. |
|
39 | + * |
|
40 | + * It returns a value referenced by <var>$key</var> using this search criteria: |
|
41 | + * - if <var>$key</var> is a constant then return it. Else |
|
42 | + * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else |
|
43 | + * - return <var>$def</var>. |
|
44 | + * |
|
45 | + * @param string $key The key to search for. |
|
46 | + * @param string $def The default value to return. |
|
47 | + * @return string the string value of the system property, or the default |
|
48 | + * value if there is no property with that key. |
|
49 | + * |
|
50 | + * @static |
|
51 | + */ |
|
52 | + public static function getSystemProperty($key, $def) { |
|
53 | + if(defined($key)) { |
|
54 | + return (string)constant($key); |
|
55 | + } else if(isset($_SERVER[$key])) { |
|
56 | + return (string)$_SERVER[$key]; |
|
57 | + } else if(isset($_ENV[$key])) { |
|
58 | + return (string)$_ENV[$key]; |
|
59 | + } else { |
|
60 | + return $def; |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * If <var>$value</var> is <i>true</i>, then <i>true</i> is |
|
66 | - * returned. If <var>$value</var> is <i>false</i>, then |
|
67 | - * <i>true</i> is returned. Otherwise, <var>$default</var> is |
|
68 | - * returned. |
|
69 | - * |
|
70 | - * <p>Case of value is unimportant.</p> |
|
71 | - * |
|
72 | - * @param string $value |
|
73 | - * @param boolean $default |
|
74 | - * @return boolean |
|
75 | - * |
|
76 | - * @static |
|
77 | - */ |
|
78 | - public static function toBoolean($value, $default=true) { |
|
79 | - if (is_null($value)) { |
|
80 | - return $default; |
|
81 | - } elseif (is_string($value)) { |
|
82 | - $trimmedVal = strtolower(trim($value)); |
|
64 | + /** |
|
65 | + * If <var>$value</var> is <i>true</i>, then <i>true</i> is |
|
66 | + * returned. If <var>$value</var> is <i>false</i>, then |
|
67 | + * <i>true</i> is returned. Otherwise, <var>$default</var> is |
|
68 | + * returned. |
|
69 | + * |
|
70 | + * <p>Case of value is unimportant.</p> |
|
71 | + * |
|
72 | + * @param string $value |
|
73 | + * @param boolean $default |
|
74 | + * @return boolean |
|
75 | + * |
|
76 | + * @static |
|
77 | + */ |
|
78 | + public static function toBoolean($value, $default=true) { |
|
79 | + if (is_null($value)) { |
|
80 | + return $default; |
|
81 | + } elseif (is_string($value)) { |
|
82 | + $trimmedVal = strtolower(trim($value)); |
|
83 | 83 | |
84 | 84 | if("1" == $trimmedVal or "true" == $trimmedVal or "yes" == $trimmedVal or "on" == $trimmedVal) { |
85 | - return true; |
|
85 | + return true; |
|
86 | 86 | } else if ("" == $trimmedVal or "0" == $trimmedVal or "false" == $trimmedVal or "no" == $trimmedVal or "off" == $trimmedVal) { |
87 | - return false; |
|
88 | - } |
|
89 | - } elseif (is_bool($value)) { |
|
90 | - return $value; |
|
91 | - } elseif (is_int($value)) { |
|
92 | - return !($value == 0); // true is everything but 0 like in C |
|
93 | - } |
|
87 | + return false; |
|
88 | + } |
|
89 | + } elseif (is_bool($value)) { |
|
90 | + return $value; |
|
91 | + } elseif (is_int($value)) { |
|
92 | + return !($value == 0); // true is everything but 0 like in C |
|
93 | + } |
|
94 | 94 | |
95 | - trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING); |
|
96 | - return $default; |
|
97 | - } |
|
95 | + trigger_error("Could not convert ".var_export($value,1)." to boolean!", E_USER_WARNING); |
|
96 | + return $default; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * @param string $value |
|
101 | - * @param integer $default |
|
102 | - * @return integer |
|
103 | - * @static |
|
104 | - */ |
|
105 | - public static function toInt($value, $default) { |
|
106 | - $value = trim($value); |
|
107 | - if(is_numeric($value)) { |
|
108 | - return (int)$value; |
|
109 | - } else { |
|
110 | - return $default; |
|
111 | - } |
|
112 | - } |
|
99 | + /** |
|
100 | + * @param string $value |
|
101 | + * @param integer $default |
|
102 | + * @return integer |
|
103 | + * @static |
|
104 | + */ |
|
105 | + public static function toInt($value, $default) { |
|
106 | + $value = trim($value); |
|
107 | + if(is_numeric($value)) { |
|
108 | + return (int)$value; |
|
109 | + } else { |
|
110 | + return $default; |
|
111 | + } |
|
112 | + } |
|
113 | 113 | |
114 | - /** |
|
115 | - * Converts a standard or custom priority level to a Level |
|
116 | - * object. |
|
117 | - * |
|
118 | - * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>", |
|
119 | - * where <i>full_file_classname</i> means the class filename with path |
|
120 | - * but without php extension, then the specified class' <i>toLevel()</i> method |
|
121 | - * is called to process the specified level string; if no '#' |
|
122 | - * character is present, then the default {@link LoggerLevel} |
|
123 | - * class is used to process the level value.</p> |
|
124 | - * |
|
125 | - * <p>As a special case, if the <var>$value</var> parameter is |
|
126 | - * equal to the string "NULL", then the value <i>null</i> will |
|
127 | - * be returned.</p> |
|
128 | - * |
|
129 | - * <p>If any error occurs while converting the value to a level, |
|
130 | - * the <var>$defaultValue</var> parameter, which may be |
|
131 | - * <i>null</i>, is returned.</p> |
|
132 | - * |
|
133 | - * <p>Case of <var>$value</var> is insignificant for the level level, but is |
|
134 | - * significant for the class name part, if present.</p> |
|
135 | - * |
|
136 | - * @param string $value |
|
137 | - * @param LoggerLevel $defaultValue |
|
138 | - * @return LoggerLevel a {@link LoggerLevel} or null |
|
139 | - * @static |
|
140 | - */ |
|
141 | - public static function toLevel($value, $defaultValue) { |
|
142 | - if($value === null) { |
|
143 | - return $defaultValue; |
|
144 | - } |
|
145 | - $hashIndex = strpos($value, '#'); |
|
146 | - if($hashIndex === false) { |
|
147 | - if("NULL" == strtoupper($value)) { |
|
148 | - return null; |
|
149 | - } else { |
|
150 | - // no class name specified : use standard Level class |
|
151 | - return LoggerLevel::toLevel($value, $defaultValue); |
|
152 | - } |
|
153 | - } |
|
114 | + /** |
|
115 | + * Converts a standard or custom priority level to a Level |
|
116 | + * object. |
|
117 | + * |
|
118 | + * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>", |
|
119 | + * where <i>full_file_classname</i> means the class filename with path |
|
120 | + * but without php extension, then the specified class' <i>toLevel()</i> method |
|
121 | + * is called to process the specified level string; if no '#' |
|
122 | + * character is present, then the default {@link LoggerLevel} |
|
123 | + * class is used to process the level value.</p> |
|
124 | + * |
|
125 | + * <p>As a special case, if the <var>$value</var> parameter is |
|
126 | + * equal to the string "NULL", then the value <i>null</i> will |
|
127 | + * be returned.</p> |
|
128 | + * |
|
129 | + * <p>If any error occurs while converting the value to a level, |
|
130 | + * the <var>$defaultValue</var> parameter, which may be |
|
131 | + * <i>null</i>, is returned.</p> |
|
132 | + * |
|
133 | + * <p>Case of <var>$value</var> is insignificant for the level level, but is |
|
134 | + * significant for the class name part, if present.</p> |
|
135 | + * |
|
136 | + * @param string $value |
|
137 | + * @param LoggerLevel $defaultValue |
|
138 | + * @return LoggerLevel a {@link LoggerLevel} or null |
|
139 | + * @static |
|
140 | + */ |
|
141 | + public static function toLevel($value, $defaultValue) { |
|
142 | + if($value === null) { |
|
143 | + return $defaultValue; |
|
144 | + } |
|
145 | + $hashIndex = strpos($value, '#'); |
|
146 | + if($hashIndex === false) { |
|
147 | + if("NULL" == strtoupper($value)) { |
|
148 | + return null; |
|
149 | + } else { |
|
150 | + // no class name specified : use standard Level class |
|
151 | + return LoggerLevel::toLevel($value, $defaultValue); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - $result = $defaultValue; |
|
155 | + $result = $defaultValue; |
|
156 | 156 | |
157 | - $clazz = substr($value, ($hashIndex + 1)); |
|
158 | - $levelName = substr($value, 0, $hashIndex); |
|
157 | + $clazz = substr($value, ($hashIndex + 1)); |
|
158 | + $levelName = substr($value, 0, $hashIndex); |
|
159 | 159 | |
160 | - // This is degenerate case but you never know. |
|
161 | - if("NULL" == strtoupper($levelName)) { |
|
162 | - return null; |
|
163 | - } |
|
160 | + // This is degenerate case but you never know. |
|
161 | + if("NULL" == strtoupper($levelName)) { |
|
162 | + return null; |
|
163 | + } |
|
164 | 164 | |
165 | - $clazz = basename($clazz); |
|
165 | + $clazz = basename($clazz); |
|
166 | 166 | |
167 | - if(class_exists($clazz)) { |
|
168 | - $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
|
169 | - if(!$result instanceof LoggerLevel) { |
|
170 | - $result = $defaultValue; |
|
171 | - } |
|
172 | - } |
|
173 | - return $result; |
|
174 | - } |
|
167 | + if(class_exists($clazz)) { |
|
168 | + $result = @call_user_func(array($clazz, 'toLevel'), $levelName, $defaultValue); |
|
169 | + if(!$result instanceof LoggerLevel) { |
|
170 | + $result = $defaultValue; |
|
171 | + } |
|
172 | + } |
|
173 | + return $result; |
|
174 | + } |
|
175 | 175 | |
176 | - /** |
|
177 | - * @param string $value |
|
178 | - * @param float $default |
|
179 | - * @return float |
|
180 | - * |
|
181 | - * @static |
|
182 | - */ |
|
183 | - public static function toFileSize($value, $default) { |
|
184 | - if($value === null) { |
|
185 | - return $default; |
|
186 | - } |
|
176 | + /** |
|
177 | + * @param string $value |
|
178 | + * @param float $default |
|
179 | + * @return float |
|
180 | + * |
|
181 | + * @static |
|
182 | + */ |
|
183 | + public static function toFileSize($value, $default) { |
|
184 | + if($value === null) { |
|
185 | + return $default; |
|
186 | + } |
|
187 | 187 | |
188 | - $s = strtoupper(trim($value)); |
|
189 | - $multiplier = (float)1; |
|
190 | - if(($index = strpos($s, 'KB')) !== false) { |
|
191 | - $multiplier = 1024; |
|
192 | - $s = substr($s, 0, $index); |
|
193 | - } else if(($index = strpos($s, 'MB')) !== false) { |
|
194 | - $multiplier = 1024 * 1024; |
|
195 | - $s = substr($s, 0, $index); |
|
196 | - } else if(($index = strpos($s, 'GB')) !== false) { |
|
197 | - $multiplier = 1024 * 1024 * 1024; |
|
198 | - $s = substr($s, 0, $index); |
|
199 | - } |
|
200 | - if(is_numeric($s)) { |
|
201 | - return (float)$s * $multiplier; |
|
202 | - } |
|
203 | - return $default; |
|
204 | - } |
|
188 | + $s = strtoupper(trim($value)); |
|
189 | + $multiplier = (float)1; |
|
190 | + if(($index = strpos($s, 'KB')) !== false) { |
|
191 | + $multiplier = 1024; |
|
192 | + $s = substr($s, 0, $index); |
|
193 | + } else if(($index = strpos($s, 'MB')) !== false) { |
|
194 | + $multiplier = 1024 * 1024; |
|
195 | + $s = substr($s, 0, $index); |
|
196 | + } else if(($index = strpos($s, 'GB')) !== false) { |
|
197 | + $multiplier = 1024 * 1024 * 1024; |
|
198 | + $s = substr($s, 0, $index); |
|
199 | + } |
|
200 | + if(is_numeric($s)) { |
|
201 | + return (float)$s * $multiplier; |
|
202 | + } |
|
203 | + return $default; |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * Find the value corresponding to <var>$key</var> in |
|
208 | - * <var>$props</var>. Then perform variable substitution on the |
|
209 | - * found value. |
|
210 | - * |
|
211 | - * @param string $key |
|
212 | - * @param array $props |
|
213 | - * @return string |
|
214 | - * |
|
215 | - * @static |
|
216 | - */ |
|
217 | - public static function findAndSubst($key, $props) { |
|
218 | - $value = @$props[$key]; |
|
206 | + /** |
|
207 | + * Find the value corresponding to <var>$key</var> in |
|
208 | + * <var>$props</var>. Then perform variable substitution on the |
|
209 | + * found value. |
|
210 | + * |
|
211 | + * @param string $key |
|
212 | + * @param array $props |
|
213 | + * @return string |
|
214 | + * |
|
215 | + * @static |
|
216 | + */ |
|
217 | + public static function findAndSubst($key, $props) { |
|
218 | + $value = @$props[$key]; |
|
219 | 219 | |
220 | 220 | // If coming from the LoggerConfiguratorIni, some options were |
221 | 221 | // already mangled by parse_ini_file: |
@@ -233,90 +233,90 @@ discard block |
||
233 | 233 | // explicitly set by the user and is different from an option which |
234 | 234 | // has not been specified and therefore keeps its default value. |
235 | 235 | // |
236 | - // if(!empty($value)) { |
|
237 | - return LoggerOptionConverter::substVars($value, $props); |
|
238 | - // } |
|
236 | + // if(!empty($value)) { |
|
237 | + return LoggerOptionConverter::substVars($value, $props); |
|
238 | + // } |
|
239 | 239 | } |
240 | 240 | |
241 | - /** |
|
242 | - * Perform variable substitution in string <var>$val</var> from the |
|
243 | - * values of keys found with the {@link getSystemProperty()} method. |
|
244 | - * |
|
245 | - * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>. |
|
246 | - * |
|
247 | - * <p>For example, if the "MY_CONSTANT" contains "value", then |
|
248 | - * the call |
|
249 | - * <code> |
|
250 | - * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}."); |
|
251 | - * </code> |
|
252 | - * will set the variable <i>$s</i> to "Value of key is value.".</p> |
|
253 | - * |
|
254 | - * <p>If no value could be found for the specified key, then the |
|
255 | - * <var>$props</var> parameter is searched, if the value could not |
|
256 | - * be found there, then substitution defaults to the empty string.</p> |
|
257 | - * |
|
258 | - * <p>For example, if {@link getSystemProperty()} cannot find any value for the key |
|
259 | - * "inexistentKey", then the call |
|
260 | - * <code> |
|
261 | - * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]"); |
|
262 | - * </code> |
|
263 | - * will set <var>$s</var> to "Value of inexistentKey is []".</p> |
|
264 | - * |
|
265 | - * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" |
|
266 | - * which is not balanced by a stop delimeter "}" and an empty string is returned.</p> |
|
267 | - * |
|
268 | - * @author Avy Sharell |
|
269 | - * |
|
270 | - * @param string $val The string on which variable substitution is performed. |
|
271 | - * @param array $props |
|
272 | - * @return string |
|
273 | - * |
|
274 | - * @static |
|
275 | - */ |
|
276 | - // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd |
|
277 | - public static function substVars($val, $props = null) { |
|
278 | - $sbuf = ''; |
|
279 | - $i = 0; |
|
280 | - while(true) { |
|
281 | - $j = strpos($val, self::DELIM_START, $i); |
|
282 | - if($j === false) { |
|
283 | - // no more variables |
|
284 | - if($i == 0) { // this is a simple string |
|
285 | - return $val; |
|
286 | - } else { // add the tail string which contails no variables and return the result. |
|
287 | - $sbuf .= substr($val, $i); |
|
288 | - return $sbuf; |
|
289 | - } |
|
290 | - } else { |
|
241 | + /** |
|
242 | + * Perform variable substitution in string <var>$val</var> from the |
|
243 | + * values of keys found with the {@link getSystemProperty()} method. |
|
244 | + * |
|
245 | + * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>. |
|
246 | + * |
|
247 | + * <p>For example, if the "MY_CONSTANT" contains "value", then |
|
248 | + * the call |
|
249 | + * <code> |
|
250 | + * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}."); |
|
251 | + * </code> |
|
252 | + * will set the variable <i>$s</i> to "Value of key is value.".</p> |
|
253 | + * |
|
254 | + * <p>If no value could be found for the specified key, then the |
|
255 | + * <var>$props</var> parameter is searched, if the value could not |
|
256 | + * be found there, then substitution defaults to the empty string.</p> |
|
257 | + * |
|
258 | + * <p>For example, if {@link getSystemProperty()} cannot find any value for the key |
|
259 | + * "inexistentKey", then the call |
|
260 | + * <code> |
|
261 | + * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]"); |
|
262 | + * </code> |
|
263 | + * will set <var>$s</var> to "Value of inexistentKey is []".</p> |
|
264 | + * |
|
265 | + * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" |
|
266 | + * which is not balanced by a stop delimeter "}" and an empty string is returned.</p> |
|
267 | + * |
|
268 | + * @author Avy Sharell |
|
269 | + * |
|
270 | + * @param string $val The string on which variable substitution is performed. |
|
271 | + * @param array $props |
|
272 | + * @return string |
|
273 | + * |
|
274 | + * @static |
|
275 | + */ |
|
276 | + // TODO: this method doesn't work correctly with key = true, it needs key = "true" which is odd |
|
277 | + public static function substVars($val, $props = null) { |
|
278 | + $sbuf = ''; |
|
279 | + $i = 0; |
|
280 | + while(true) { |
|
281 | + $j = strpos($val, self::DELIM_START, $i); |
|
282 | + if($j === false) { |
|
283 | + // no more variables |
|
284 | + if($i == 0) { // this is a simple string |
|
285 | + return $val; |
|
286 | + } else { // add the tail string which contails no variables and return the result. |
|
287 | + $sbuf .= substr($val, $i); |
|
288 | + return $sbuf; |
|
289 | + } |
|
290 | + } else { |
|
291 | 291 | |
292 | - $sbuf .= substr($val, $i, $j-$i); |
|
293 | - $k = strpos($val, self::DELIM_STOP, $j); |
|
294 | - if($k === false) { |
|
295 | - // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
|
296 | - return ''; |
|
297 | - } else { |
|
298 | - $j += self::START_LEN; |
|
299 | - $key = substr($val, $j, $k - $j); |
|
300 | - // first try in System properties |
|
301 | - $replacement = LoggerOptionConverter::getSystemProperty($key, null); |
|
302 | - // then try props parameter |
|
303 | - if($replacement == null and $props !== null) { |
|
304 | - $replacement = @$props[$key]; |
|
305 | - } |
|
292 | + $sbuf .= substr($val, $i, $j-$i); |
|
293 | + $k = strpos($val, self::DELIM_STOP, $j); |
|
294 | + if($k === false) { |
|
295 | + // LoggerOptionConverter::substVars() has no closing brace. Opening brace |
|
296 | + return ''; |
|
297 | + } else { |
|
298 | + $j += self::START_LEN; |
|
299 | + $key = substr($val, $j, $k - $j); |
|
300 | + // first try in System properties |
|
301 | + $replacement = LoggerOptionConverter::getSystemProperty($key, null); |
|
302 | + // then try props parameter |
|
303 | + if($replacement == null and $props !== null) { |
|
304 | + $replacement = @$props[$key]; |
|
305 | + } |
|
306 | 306 | |
307 | - if(!empty($replacement)) { |
|
308 | - // Do variable substitution on the replacement string |
|
309 | - // such that we can solve "Hello ${x2}" as "Hello p1" |
|
310 | - // the where the properties are |
|
311 | - // x1=p1 |
|
312 | - // x2=${x1} |
|
313 | - $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props); |
|
314 | - $sbuf .= $recursiveReplacement; |
|
315 | - } |
|
316 | - $i = $k + self::DELIM_STOP_LEN; |
|
317 | - } |
|
318 | - } |
|
319 | - } |
|
320 | - } |
|
307 | + if(!empty($replacement)) { |
|
308 | + // Do variable substitution on the replacement string |
|
309 | + // such that we can solve "Hello ${x2}" as "Hello p1" |
|
310 | + // the where the properties are |
|
311 | + // x1=p1 |
|
312 | + // x2=${x1} |
|
313 | + $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props); |
|
314 | + $sbuf .= $recursiveReplacement; |
|
315 | + } |
|
316 | + $i = $k + self::DELIM_STOP_LEN; |
|
317 | + } |
|
318 | + } |
|
319 | + } |
|
320 | + } |
|
321 | 321 | |
322 | 322 | } |
@@ -50,19 +50,19 @@ |
||
50 | 50 | */ |
51 | 51 | class LoggerLayoutTTCC extends LoggerLayout { |
52 | 52 | |
53 | - /** |
|
54 | - * String constant designating no time information. Current value of |
|
55 | - * this constant is <b>NULL</b>. |
|
56 | - */ |
|
57 | - // TODO: not used? |
|
58 | - const LOG4PHP_LOGGER_LAYOUT_NULL_DATE_FORMAT = 'NULL'; |
|
53 | + /** |
|
54 | + * String constant designating no time information. Current value of |
|
55 | + * this constant is <b>NULL</b>. |
|
56 | + */ |
|
57 | + // TODO: not used? |
|
58 | + const LOG4PHP_LOGGER_LAYOUT_NULL_DATE_FORMAT = 'NULL'; |
|
59 | 59 | |
60 | - /** |
|
61 | - * String constant designating relative time. Current value of |
|
62 | - * this constant is <b>RELATIVE</b>. |
|
63 | - */ |
|
64 | - // TODO: not used? |
|
65 | - const LOG4PHP_LOGGER_LAYOUT_RELATIVE_TIME_DATE_FORMAT = 'RELATIVE'; |
|
60 | + /** |
|
61 | + * String constant designating relative time. Current value of |
|
62 | + * this constant is <b>RELATIVE</b>. |
|
63 | + */ |
|
64 | + // TODO: not used? |
|
65 | + const LOG4PHP_LOGGER_LAYOUT_RELATIVE_TIME_DATE_FORMAT = 'RELATIVE'; |
|
66 | 66 | |
67 | 67 | // Internal representation of options |
68 | 68 | protected $threadPrinting = true; |
@@ -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: generated_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,22 +46,22 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Generated_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - protected $_reflower; // Decoration target |
|
49 | + protected $_reflower; // Decoration target |
|
51 | 50 | |
52 | - function __construct(Frame $frame) { |
|
51 | + function __construct(Frame $frame) { |
|
53 | 52 | parent::__construct($frame); |
54 | - } |
|
53 | + } |
|
55 | 54 | |
56 | - function set_reflower(Frame_Reflower $reflow) { |
|
55 | + function set_reflower(Frame_Reflower $reflow) { |
|
57 | 56 | $this->_reflower = $reflow; |
58 | - } |
|
57 | + } |
|
59 | 58 | |
60 | - //........................................................................ |
|
59 | + //........................................................................ |
|
61 | 60 | |
62 | - protected function _parse_string($string) { |
|
61 | + protected function _parse_string($string) { |
|
63 | 62 | $string = trim($string, "'\""); |
64 | 63 | $string = str_replace(array("\\\n",'\\"',"\\'"), |
65 | - array("",'"',"'"), $string); |
|
64 | + array("",'"',"'"), $string); |
|
66 | 65 | |
67 | 66 | // Convert escaped hex characters into ascii characters (e.g. \A => newline) |
68 | 67 | $string = preg_replace_callback("/\\\\([0-9a-fA-F]{0,6})(\s)?(?(2)|(?=[^0-9a-fA-F]))/", |
@@ -70,40 +69,40 @@ discard block |
||
70 | 69 | 'return chr(hexdec($matches[1]));'), |
71 | 70 | $string); |
72 | 71 | return $string; |
73 | - } |
|
72 | + } |
|
74 | 73 | |
75 | - protected function _parse_content() { |
|
74 | + protected function _parse_content() { |
|
76 | 75 | $style = $this->_frame->get_style(); |
77 | 76 | |
78 | 77 | // Matches generated content |
79 | 78 | $re = "/\n". |
80 | - "\s(counters?\\([^)]*\\))|\n". |
|
81 | - "\A(counters?\\([^)]*\\))|\n". |
|
82 | - "\s([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\3|\n". |
|
83 | - "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n" . |
|
84 | - "\s([^\s\"']+)|\n" . |
|
85 | - "\A([^\s\"']+)\n". |
|
86 | - "/xi"; |
|
79 | + "\s(counters?\\([^)]*\\))|\n". |
|
80 | + "\A(counters?\\([^)]*\\))|\n". |
|
81 | + "\s([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\3|\n". |
|
82 | + "\A([\"']) ( (?:[^\"']|\\\\[\"'])+ )(?<!\\\\)\\5|\n" . |
|
83 | + "\s([^\s\"']+)|\n" . |
|
84 | + "\A([^\s\"']+)\n". |
|
85 | + "/xi"; |
|
87 | 86 | |
88 | 87 | $content = $style->content; |
89 | 88 | |
90 | 89 | // split on spaces, except within quotes |
91 | 90 | if (!preg_match_all($re, $content, $matches, PREG_SET_ORDER)) |
92 | - return; |
|
91 | + return; |
|
93 | 92 | |
94 | 93 | $text = ""; |
95 | 94 | |
96 | 95 | foreach ($matches as $match) { |
97 | - if ( isset($match[2]) && $match[2] !== "" ) |
|
96 | + if ( isset($match[2]) && $match[2] !== "" ) |
|
98 | 97 | $match[1] = $match[1]; |
99 | 98 | |
100 | - if ( isset($match[6]) && $match[6] !== "" ) |
|
99 | + if ( isset($match[6]) && $match[6] !== "" ) |
|
101 | 100 | $match[4] = $match[6]; |
102 | 101 | |
103 | - if ( isset($match[8]) && $match[8] !== "" ) |
|
102 | + if ( isset($match[8]) && $match[8] !== "" ) |
|
104 | 103 | $match[7] = $match[8]; |
105 | 104 | |
106 | - if ( isset($match[1]) && $match[1] !== "" ) { |
|
105 | + if ( isset($match[1]) && $match[1] !== "" ) { |
|
107 | 106 | // counters?(...) |
108 | 107 | $match[1] = mb_strtolower(trim($match[1])); |
109 | 108 | |
@@ -112,85 +111,85 @@ discard block |
||
112 | 111 | |
113 | 112 | $i = mb_strpos($match[1], ")"); |
114 | 113 | if ( $i === false ) |
115 | - continue; |
|
114 | + continue; |
|
116 | 115 | |
117 | 116 | $args = explode(",", mb_substr($match[1], 7, $i - 7)); |
118 | 117 | $counter_id = $args[0]; |
119 | 118 | |
120 | 119 | if ( $match[1]{7} === "(" ) { |
121 | - // counter(name [,style]) |
|
120 | + // counter(name [,style]) |
|
122 | 121 | |
123 | - if ( isset($args[1]) ) |
|
122 | + if ( isset($args[1]) ) |
|
124 | 123 | $type = $args[1]; |
125 | - else |
|
124 | + else |
|
126 | 125 | $type = null; |
127 | 126 | |
128 | 127 | |
129 | - $p = $this->_frame->find_block_parent(); |
|
128 | + $p = $this->_frame->find_block_parent(); |
|
130 | 129 | |
131 | - $text .= $p->counter_value($counter_id, $type); |
|
130 | + $text .= $p->counter_value($counter_id, $type); |
|
132 | 131 | |
133 | 132 | } else if ( $match[1]{7} === "s" ) { |
134 | - // counters(name, string [,style]) |
|
135 | - if ( isset($args[1]) ) |
|
133 | + // counters(name, string [,style]) |
|
134 | + if ( isset($args[1]) ) |
|
136 | 135 | $string = $this->_parse_string(trim($args[1])); |
137 | - else |
|
136 | + else |
|
138 | 137 | $string = ""; |
139 | 138 | |
140 | - if ( isset($args[2]) ) |
|
139 | + if ( isset($args[2]) ) |
|
141 | 140 | $type = $args[2]; |
142 | - else |
|
141 | + else |
|
143 | 142 | $type = null; |
144 | 143 | |
145 | - $p = $this->_frame->find_block_parent(); |
|
146 | - $tmp = ""; |
|
147 | - while ($p) { |
|
144 | + $p = $this->_frame->find_block_parent(); |
|
145 | + $tmp = ""; |
|
146 | + while ($p) { |
|
148 | 147 | $tmp = $p->counter_value($counter_id, $type) . $string . $tmp; |
149 | 148 | $p = $p->find_block_parent(); |
150 | - } |
|
151 | - $text .= $tmp; |
|
149 | + } |
|
150 | + $text .= $tmp; |
|
152 | 151 | |
153 | 152 | } else |
154 | - // countertops? |
|
155 | - continue; |
|
153 | + // countertops? |
|
154 | + continue; |
|
156 | 155 | |
157 | - } else if ( isset($match[4]) && $match[4] !== "" ) { |
|
156 | + } else if ( isset($match[4]) && $match[4] !== "" ) { |
|
158 | 157 | // String match |
159 | 158 | $text .= $this->_parse_string($match[4]); |
160 | 159 | |
161 | - } else if ( isset($match[7]) && $match[7] !== "" ) { |
|
160 | + } else if ( isset($match[7]) && $match[7] !== "" ) { |
|
162 | 161 | // Directive match |
163 | 162 | |
164 | 163 | if ( $match[7] === "open-quote" ) { |
165 | - // FIXME: do something here |
|
164 | + // FIXME: do something here |
|
166 | 165 | } else if ( $match[7] === "close-quote" ) { |
167 | - // FIXME: do something else here |
|
166 | + // FIXME: do something else here |
|
168 | 167 | } else if ( $match[7] === "no-open-quote" ) { |
169 | - // FIXME: |
|
168 | + // FIXME: |
|
170 | 169 | } else if ( $match[7] === "no-close-quote" ) { |
171 | - // FIXME: |
|
170 | + // FIXME: |
|
172 | 171 | } else if ( mb_strpos($match[7],"attr(") === 0 ) { |
173 | 172 | |
174 | - $i = mb_strpos($match[7],")"); |
|
175 | - if ( $i === false ) |
|
173 | + $i = mb_strpos($match[7],")"); |
|
174 | + if ( $i === false ) |
|
176 | 175 | continue; |
177 | 176 | |
178 | - $attr = mb_substr($match[7], 6, $i - 6); |
|
179 | - if ( $attr == "" ) |
|
177 | + $attr = mb_substr($match[7], 6, $i - 6); |
|
178 | + if ( $attr == "" ) |
|
180 | 179 | continue; |
181 | 180 | |
182 | - $text .= $this->_frame->get_node()->getAttribute($attr); |
|
181 | + $text .= $this->_frame->get_node()->getAttribute($attr); |
|
183 | 182 | } else |
184 | - continue; |
|
183 | + continue; |
|
185 | 184 | |
186 | - } |
|
185 | + } |
|
187 | 186 | } |
188 | 187 | |
189 | 188 | return $text; |
190 | 189 | |
191 | - } |
|
190 | + } |
|
192 | 191 | |
193 | - function reflow() { |
|
192 | + function reflow() { |
|
194 | 193 | $style = $this->_frame->get_style(); |
195 | 194 | |
196 | 195 | $text = $this->_parse_content(); |
@@ -202,5 +201,5 @@ discard block |
||
202 | 201 | |
203 | 202 | $this->_frame->prepend_child(Frame_Factory::decorate_frame($t_frame)); |
204 | 203 | $this->_reflower->reflow(); |
205 | - } |
|
204 | + } |
|
206 | 205 | } |
@@ -34,7 +34,6 @@ discard block |
||
34 | 34 | * @copyright 2004 Benj Carson |
35 | 35 | * @author Benj Carson <[email protected]> |
36 | 36 | * @package dompdf |
37 | - |
|
38 | 37 | */ |
39 | 38 | |
40 | 39 | /* $Id: table_row_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -48,17 +47,17 @@ discard block |
||
48 | 47 | class Table_Row_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | 49 | |
51 | - function __construct(Table_Row_Frame_Decorator $frame) { |
|
50 | + function __construct(Table_Row_Frame_Decorator $frame) { |
|
52 | 51 | parent::__construct($frame); |
53 | - } |
|
52 | + } |
|
54 | 53 | |
55 | - //........................................................................ |
|
54 | + //........................................................................ |
|
56 | 55 | |
57 | - function reflow() { |
|
56 | + function reflow() { |
|
58 | 57 | $page = $this->_frame->get_root(); |
59 | 58 | |
60 | 59 | if ( $page->is_full() ) |
61 | - return; |
|
60 | + return; |
|
62 | 61 | |
63 | 62 | $this->_frame->position(); |
64 | 63 | $style = $this->_frame->get_style(); |
@@ -66,16 +65,16 @@ discard block |
||
66 | 65 | |
67 | 66 | foreach ($this->_frame->get_children() as $child) { |
68 | 67 | |
69 | - if ( $page->is_full() ) |
|
68 | + if ( $page->is_full() ) |
|
70 | 69 | return; |
71 | 70 | |
72 | - $child->set_containing_block($cb); |
|
73 | - $child->reflow(); |
|
71 | + $child->set_containing_block($cb); |
|
72 | + $child->reflow(); |
|
74 | 73 | |
75 | 74 | } |
76 | 75 | |
77 | 76 | if ( $page->is_full() ) |
78 | - return; |
|
77 | + return; |
|
79 | 78 | |
80 | 79 | $table = Table_Frame_Decorator::find_parent_table($this->_frame); |
81 | 80 | $cellmap = $table->get_cellmap(); |
@@ -84,11 +83,11 @@ discard block |
||
84 | 83 | |
85 | 84 | $this->_frame->set_position($cellmap->get_frame_position($this->_frame)); |
86 | 85 | |
87 | - } |
|
86 | + } |
|
88 | 87 | |
89 | - //........................................................................ |
|
88 | + //........................................................................ |
|
90 | 89 | |
91 | - function get_min_max_width() { |
|
90 | + function get_min_max_width() { |
|
92 | 91 | throw new DOMPDF_Exception("Min/max width is undefined for table rows"); |
93 | - } |
|
92 | + } |
|
94 | 93 | } |
@@ -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: php_evaluator.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,15 +46,15 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class PHP_Evaluator { |
49 | 48 | |
50 | - protected $_canvas; |
|
49 | + protected $_canvas; |
|
51 | 50 | |
52 | - function __construct(Canvas $canvas) { |
|
51 | + function __construct(Canvas $canvas) { |
|
53 | 52 | $this->_canvas = $canvas; |
54 | - } |
|
53 | + } |
|
55 | 54 | |
56 | - function evaluate($code, $vars = array()) { |
|
55 | + function evaluate($code, $vars = array()) { |
|
57 | 56 | if ( !DOMPDF_ENABLE_PHP ) |
58 | - return; |
|
57 | + return; |
|
59 | 58 | |
60 | 59 | // Set up some variables for the inline code |
61 | 60 | $pdf = $this->_canvas; |
@@ -68,9 +67,9 @@ discard block |
||
68 | 67 | } |
69 | 68 | |
70 | 69 | eval(utf8_decode($code)); |
71 | - } |
|
70 | + } |
|
72 | 71 | |
73 | - function render($frame) { |
|
72 | + function render($frame) { |
|
74 | 73 | $this->evaluate($frame->get_node()->nodeValue); |
75 | - } |
|
74 | + } |
|
76 | 75 | } |
@@ -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: page_frame_reflower.cls.php 216 2010-03-11 22:49:18Z ryan.masten $ */ |
@@ -47,25 +46,25 @@ discard block |
||
47 | 46 | */ |
48 | 47 | class Page_Frame_Reflower extends Frame_Reflower { |
49 | 48 | |
50 | - /** |
|
51 | - * Cache of the callbacks array |
|
52 | - * |
|
53 | - * @var array |
|
54 | - */ |
|
55 | - private $_callbacks; |
|
49 | + /** |
|
50 | + * Cache of the callbacks array |
|
51 | + * |
|
52 | + * @var array |
|
53 | + */ |
|
54 | + private $_callbacks; |
|
56 | 55 | |
57 | - /** |
|
58 | - * Cache of the canvas |
|
59 | - * |
|
60 | - * @var Canvas |
|
61 | - */ |
|
62 | - private $_canvas; |
|
56 | + /** |
|
57 | + * Cache of the canvas |
|
58 | + * |
|
59 | + * @var Canvas |
|
60 | + */ |
|
61 | + private $_canvas; |
|
63 | 62 | |
64 | - function __construct(Page_Frame_Decorator $frame) { parent::__construct($frame); } |
|
63 | + function __construct(Page_Frame_Decorator $frame) { parent::__construct($frame); } |
|
65 | 64 | |
66 | - //........................................................................ |
|
65 | + //........................................................................ |
|
67 | 66 | |
68 | - function reflow() { |
|
67 | + function reflow() { |
|
69 | 68 | $style = $this->_frame->get_style(); |
70 | 69 | |
71 | 70 | // Paged layout: |
@@ -88,74 +87,74 @@ discard block |
||
88 | 87 | |
89 | 88 | while ($child) { |
90 | 89 | |
91 | - $child->set_containing_block($content_x, $content_y, $content_width, $content_height); |
|
90 | + $child->set_containing_block($content_x, $content_y, $content_width, $content_height); |
|
92 | 91 | |
93 | - // Check for begin reflow callback |
|
94 | - $this->_check_callbacks("begin_page_reflow", $child); |
|
92 | + // Check for begin reflow callback |
|
93 | + $this->_check_callbacks("begin_page_reflow", $child); |
|
95 | 94 | |
96 | - $child->reflow(); |
|
97 | - $next_child = $child->get_next_sibling(); |
|
95 | + $child->reflow(); |
|
96 | + $next_child = $child->get_next_sibling(); |
|
98 | 97 | |
99 | - // Check for begin render callback |
|
100 | - $this->_check_callbacks("begin_page_render", $child); |
|
98 | + // Check for begin render callback |
|
99 | + $this->_check_callbacks("begin_page_render", $child); |
|
101 | 100 | |
102 | - // Render the page |
|
103 | - $this->_frame->get_renderer()->render($child); |
|
101 | + // Render the page |
|
102 | + $this->_frame->get_renderer()->render($child); |
|
104 | 103 | |
105 | - // Check for end render callback |
|
106 | - $this->_check_callbacks("end_page_render", $child); |
|
104 | + // Check for end render callback |
|
105 | + $this->_check_callbacks("end_page_render", $child); |
|
107 | 106 | |
108 | - if ( $next_child ) |
|
109 | - { |
|
107 | + if ( $next_child ) |
|
108 | + { |
|
110 | 109 | $this->_frame->next_page(); |
111 | - } |
|
110 | + } |
|
112 | 111 | |
113 | - // Wait to dispose of all frames on the previous page |
|
114 | - // so callback will have access to them |
|
115 | - if ( $prev_child ) |
|
116 | - { |
|
112 | + // Wait to dispose of all frames on the previous page |
|
113 | + // so callback will have access to them |
|
114 | + if ( $prev_child ) |
|
115 | + { |
|
117 | 116 | $prev_child->dispose(true); |
118 | - } |
|
119 | - $prev_child = $child; |
|
120 | - $child = $next_child; |
|
117 | + } |
|
118 | + $prev_child = $child; |
|
119 | + $child = $next_child; |
|
121 | 120 | } |
122 | 121 | |
123 | 122 | // Dispose of previous page if it still exists |
124 | 123 | if ( $prev_child ) |
125 | 124 | { |
126 | - $prev_child->dispose(true); |
|
125 | + $prev_child->dispose(true); |
|
127 | 126 | } |
128 | - } |
|
127 | + } |
|
129 | 128 | |
130 | - //........................................................................ |
|
129 | + //........................................................................ |
|
131 | 130 | |
132 | - /** |
|
133 | - * Check for callbacks that need to be performed when a given event |
|
134 | - * gets triggered on a page |
|
135 | - * |
|
136 | - * @param string $event the type of event |
|
137 | - * @param Frame $frame the frame that event is triggered on |
|
138 | - */ |
|
139 | - protected function _check_callbacks($event, $frame) { |
|
131 | + /** |
|
132 | + * Check for callbacks that need to be performed when a given event |
|
133 | + * gets triggered on a page |
|
134 | + * |
|
135 | + * @param string $event the type of event |
|
136 | + * @param Frame $frame the frame that event is triggered on |
|
137 | + */ |
|
138 | + protected function _check_callbacks($event, $frame) { |
|
140 | 139 | if (!isset($this->_callbacks)) { |
141 | - $dompdf = $this->_frame->get_dompdf(); |
|
142 | - $this->_callbacks = $dompdf->get_callbacks(); |
|
143 | - $this->_canvas = $dompdf->get_canvas(); |
|
140 | + $dompdf = $this->_frame->get_dompdf(); |
|
141 | + $this->_callbacks = $dompdf->get_callbacks(); |
|
142 | + $this->_canvas = $dompdf->get_canvas(); |
|
144 | 143 | } |
145 | 144 | |
146 | 145 | if (is_array($this->_callbacks) && isset($this->_callbacks[$event])) { |
147 | - $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, |
|
146 | + $info = array(0 => $this->_canvas, "canvas" => $this->_canvas, |
|
148 | 147 | 1 => $frame, "frame" => $frame); |
149 | - $fs = $this->_callbacks[$event]; |
|
150 | - foreach ($fs as $f) { |
|
148 | + $fs = $this->_callbacks[$event]; |
|
149 | + foreach ($fs as $f) { |
|
151 | 150 | if (is_callable($f)) { |
152 | - if (is_array($f)) { |
|
151 | + if (is_array($f)) { |
|
153 | 152 | $f[0]->$f[1]($info); |
154 | - } else { |
|
153 | + } else { |
|
155 | 154 | $f($info); |
156 | - } |
|
155 | + } |
|
156 | + } |
|
157 | 157 | } |
158 | - } |
|
159 | 158 | } |
160 | - } |
|
159 | + } |
|
161 | 160 | } |
@@ -9,194 +9,194 @@ |
||
9 | 9 | // See http://demo.icu-project.org/icu-bin/convexp |
10 | 10 | return array( |
11 | 11 | |
12 | - // UTF-8 multibyte encoding |
|
13 | - |
|
14 | - 'UTF-8' => 'UTF-8', |
|
15 | - 'WINDOWS-65001' => 'UTF-8', |
|
16 | - 'CP65001' => 'UTF-8', |
|
17 | - 'WIN-65001' => 'UTF-8', |
|
18 | - 'WIN65001' => 'UTF-8', |
|
19 | - '65001' => 'UTF-8', |
|
20 | - |
|
21 | - // HTML entities |
|
22 | - |
|
23 | - 'HTML-ENTITIES' => 'HTML-ENTITIES', |
|
24 | - |
|
25 | - // Singlebyte encodings |
|
26 | - |
|
27 | - 'US-ASCII' => 'US-ASCII', |
|
28 | - 'US' => 'US-ASCII', |
|
29 | - 'ASCII' => 'US-ASCII', |
|
30 | - 'CP367' => 'US-ASCII', |
|
31 | - 'ISO646-US' => 'US-ASCII', |
|
32 | - |
|
33 | - 'ISO-8859-1' => '8859-1', |
|
34 | - 'ISO8859-1' => '8859-1', |
|
35 | - '8859-1' => '8859-1', |
|
36 | - 'LATIN1' => '8859-1', |
|
37 | - 'CP819' => '8859-1', |
|
38 | - |
|
39 | - 'ISO-8859-2' => '8859-2', |
|
40 | - 'ISO8859-2' => '8859-2', |
|
41 | - '8859-2' => '8859-2', |
|
42 | - 'LATIN2' => '8859-2', |
|
43 | - 'CP912' => '8859-2', |
|
44 | - |
|
45 | - 'ISO-8859-3' => '8859-3', |
|
46 | - 'ISO8859-3' => '8859-3', |
|
47 | - '8859-3' => '8859-3', |
|
48 | - 'LATIN3' => '8859-3', |
|
49 | - 'CP913' => '8859-3', |
|
50 | - |
|
51 | - 'ISO-8859-4' => '8859-4', |
|
52 | - 'ISO8859-4' => '8859-4', |
|
53 | - '8859-4' => '8859-4', |
|
54 | - 'LATIN4' => '8859-4', |
|
55 | - 'CP914' => '8859-4', |
|
56 | - |
|
57 | - 'ISO-8859-5' => '8859-5', |
|
58 | - 'ISO8859-5' => '8859-5', |
|
59 | - '8859-5' => '8859-5', |
|
60 | - 'CYRILLIC' => '8859-5', |
|
61 | - 'CP915' => '8859-5', |
|
62 | - |
|
63 | - 'ISO-8859-6' => '8859-6', |
|
64 | - 'ISO8859-6' => '8859-6', |
|
65 | - '8859-6' => '8859-6', |
|
66 | - 'ARABIC' => '8859-6', |
|
67 | - 'CP1089' => '8859-6', |
|
68 | - |
|
69 | - 'ISO-8859-7' => '8859-7', |
|
70 | - 'ISO8859-7' => '8859-7', |
|
71 | - '8859-7' => '8859-7', |
|
72 | - 'GREEK' => '8859-7', |
|
73 | - |
|
74 | - 'ISO-8859-8' => '8859-8', |
|
75 | - 'ISO8859-8' => '8859-8', |
|
76 | - '8859-8' => '8859-8', |
|
77 | - 'HEBREW' => '8859-8', |
|
78 | - |
|
79 | - 'ISO-8859-9' => '8859-9', |
|
80 | - 'ISO8859-9' => '8859-9', |
|
81 | - '8859-9' => '8859-9', |
|
82 | - 'LATIN5' => '8859-9', |
|
83 | - 'TURKISH' => '8859-9', |
|
84 | - 'CP920' => '8859-9', |
|
85 | - |
|
86 | - 'ISO-8859-10' => '8859-10', |
|
87 | - 'ISO8859-10' => '8859-10', |
|
88 | - '8859-10' => '8859-10', |
|
89 | - 'LATIN6' => '8859-10', |
|
90 | - |
|
91 | - 'ISO-8859-11' => '8859-11', |
|
92 | - 'ISO8859-11' => '8859-11', |
|
93 | - '8859-11' => '8859-11', |
|
94 | - 'THAI8' => '8859-11', |
|
95 | - |
|
96 | - 'ISO-8859-13' => '8859-13', |
|
97 | - 'ISO8859-13' => '8859-13', |
|
98 | - '8859-13' => '8859-13', |
|
99 | - 'CP921' => '8859-13', |
|
100 | - |
|
101 | - 'ISO-8859-14' => '8859-14', |
|
102 | - 'ISO8859-14' => '8859-14', |
|
103 | - '8859-14' => '8859-14', |
|
104 | - 'LATIN8' => '8859-14', |
|
105 | - 'ISO-CELTIC' => '8859-14', |
|
106 | - |
|
107 | - 'ISO-8859-15' => '8859-15', |
|
108 | - 'ISO8859-15' => '8859-15', |
|
109 | - '8859-15' => '8859-15', |
|
110 | - 'LATIN0' => '8859-15', |
|
111 | - 'LATIN-9' => '8859-15', |
|
112 | - 'CP923' => '8859-15', |
|
113 | - |
|
114 | - 'WINDOWS-855' => 'CP855', |
|
115 | - 'CP855' => 'CP855', |
|
116 | - 'WINDOWS-855' => 'CP855', |
|
117 | - 'WIN-855' => 'CP855', |
|
118 | - 'WIN855' => 'CP855', |
|
119 | - '855' => 'CP855', |
|
120 | - 'IBM-855' => 'CP855', |
|
121 | - 'IBM855' => 'CP855', |
|
122 | - |
|
123 | - 'WINDOWS-866' => 'CP866', |
|
124 | - 'CP866' => 'CP866', |
|
125 | - 'WINDOWS-866' => 'CP866', |
|
126 | - 'WIN-866' => 'CP866', |
|
127 | - 'WIN866' => 'CP866', |
|
128 | - '866' => 'CP866', |
|
129 | - 'IBM-866' => 'CP866', |
|
130 | - 'IBM866' => 'CP866', |
|
131 | - |
|
132 | - 'WINDOWS-874' => 'CP874', |
|
133 | - 'TIS-620' => 'CP874', |
|
134 | - 'CP874' => 'CP874', |
|
135 | - 'EUCTH' => 'CP874', |
|
136 | - 'WIN-874' => 'CP874', |
|
137 | - 'WIN874' => 'CP874', |
|
138 | - '874' => 'CP874', |
|
139 | - |
|
140 | - 'WINDOWS-1250' => 'CP1250', |
|
141 | - 'CP1250' => 'CP1250', |
|
142 | - 'WIN-1250' => 'CP1250', |
|
143 | - 'WIN1250' => 'CP1250', |
|
144 | - '1250' => 'CP1250', |
|
145 | - |
|
146 | - 'WINDOWS-1251' => 'CP1251', |
|
147 | - 'CP1251' => 'CP1251', |
|
148 | - 'ANSI1251' => 'CP1251', |
|
149 | - 'WIN-1251' => 'CP1251', |
|
150 | - 'WIN1251' => 'CP1251', |
|
151 | - '1251' => 'CP1251', |
|
152 | - |
|
153 | - 'WINDOWS-1252' => 'CP1252', |
|
154 | - 'CP1252' => 'CP1252', |
|
155 | - 'WIN-1252' => 'CP1252', |
|
156 | - 'WIN1252' => 'CP1252', |
|
157 | - '1252' => 'CP1252', |
|
158 | - |
|
159 | - 'WINDOWS-1253' => 'CP1253', |
|
160 | - 'CP1253' => 'CP1253', |
|
161 | - 'WIN-1253' => 'CP1253', |
|
162 | - 'WIN1253' => 'CP1253', |
|
163 | - '1253' => 'CP1253', |
|
164 | - |
|
165 | - 'WINDOWS-1254' => 'CP1254', |
|
166 | - 'CP1254' => 'CP1254', |
|
167 | - 'WIN-1254' => 'CP1254', |
|
168 | - 'WIN1254' => 'CP1254', |
|
169 | - '1254' => 'CP1254', |
|
170 | - |
|
171 | - 'WINDOWS-1255' => 'CP1255', |
|
172 | - 'CP1255' => 'CP1255', |
|
173 | - 'WIN-1255' => 'CP1255', |
|
174 | - 'WIN1255' => 'CP1255', |
|
175 | - '1255' => 'CP1255', |
|
176 | - |
|
177 | - 'WINDOWS-1256' => 'CP1256', |
|
178 | - 'CP1256' => 'CP1256', |
|
179 | - 'WIN-1256' => 'CP1256', |
|
180 | - 'WIN1256' => 'CP1256', |
|
181 | - '1256' => 'CP1256', |
|
182 | - |
|
183 | - 'WINDOWS-1257' => 'CP1257', |
|
184 | - 'CP1257' => 'CP1257', |
|
185 | - 'WIN-1257' => 'CP1257', |
|
186 | - 'WIN1257' => 'CP1257', |
|
187 | - '1257' => 'CP1257', |
|
188 | - |
|
189 | - 'WINDOWS-1258' => 'CP1258', |
|
190 | - 'CP1258' => 'CP1258', |
|
191 | - 'WIN-1258' => 'CP1258', |
|
192 | - 'WIN1258' => 'CP1258', |
|
193 | - '1258' => 'CP1258', |
|
194 | - |
|
195 | - 'KOI8-R' => 'KOI8-R', |
|
196 | - 'CP878' => 'KOI8-R', |
|
197 | - 'KOI8R' => 'KOI8-R', |
|
198 | - 'KOI8-RU' => 'KOI8-R', |
|
199 | - |
|
200 | - 'KOI8-U' => 'KOI8-U', |
|
12 | + // UTF-8 multibyte encoding |
|
13 | + |
|
14 | + 'UTF-8' => 'UTF-8', |
|
15 | + 'WINDOWS-65001' => 'UTF-8', |
|
16 | + 'CP65001' => 'UTF-8', |
|
17 | + 'WIN-65001' => 'UTF-8', |
|
18 | + 'WIN65001' => 'UTF-8', |
|
19 | + '65001' => 'UTF-8', |
|
20 | + |
|
21 | + // HTML entities |
|
22 | + |
|
23 | + 'HTML-ENTITIES' => 'HTML-ENTITIES', |
|
24 | + |
|
25 | + // Singlebyte encodings |
|
26 | + |
|
27 | + 'US-ASCII' => 'US-ASCII', |
|
28 | + 'US' => 'US-ASCII', |
|
29 | + 'ASCII' => 'US-ASCII', |
|
30 | + 'CP367' => 'US-ASCII', |
|
31 | + 'ISO646-US' => 'US-ASCII', |
|
32 | + |
|
33 | + 'ISO-8859-1' => '8859-1', |
|
34 | + 'ISO8859-1' => '8859-1', |
|
35 | + '8859-1' => '8859-1', |
|
36 | + 'LATIN1' => '8859-1', |
|
37 | + 'CP819' => '8859-1', |
|
38 | + |
|
39 | + 'ISO-8859-2' => '8859-2', |
|
40 | + 'ISO8859-2' => '8859-2', |
|
41 | + '8859-2' => '8859-2', |
|
42 | + 'LATIN2' => '8859-2', |
|
43 | + 'CP912' => '8859-2', |
|
44 | + |
|
45 | + 'ISO-8859-3' => '8859-3', |
|
46 | + 'ISO8859-3' => '8859-3', |
|
47 | + '8859-3' => '8859-3', |
|
48 | + 'LATIN3' => '8859-3', |
|
49 | + 'CP913' => '8859-3', |
|
50 | + |
|
51 | + 'ISO-8859-4' => '8859-4', |
|
52 | + 'ISO8859-4' => '8859-4', |
|
53 | + '8859-4' => '8859-4', |
|
54 | + 'LATIN4' => '8859-4', |
|
55 | + 'CP914' => '8859-4', |
|
56 | + |
|
57 | + 'ISO-8859-5' => '8859-5', |
|
58 | + 'ISO8859-5' => '8859-5', |
|
59 | + '8859-5' => '8859-5', |
|
60 | + 'CYRILLIC' => '8859-5', |
|
61 | + 'CP915' => '8859-5', |
|
62 | + |
|
63 | + 'ISO-8859-6' => '8859-6', |
|
64 | + 'ISO8859-6' => '8859-6', |
|
65 | + '8859-6' => '8859-6', |
|
66 | + 'ARABIC' => '8859-6', |
|
67 | + 'CP1089' => '8859-6', |
|
68 | + |
|
69 | + 'ISO-8859-7' => '8859-7', |
|
70 | + 'ISO8859-7' => '8859-7', |
|
71 | + '8859-7' => '8859-7', |
|
72 | + 'GREEK' => '8859-7', |
|
73 | + |
|
74 | + 'ISO-8859-8' => '8859-8', |
|
75 | + 'ISO8859-8' => '8859-8', |
|
76 | + '8859-8' => '8859-8', |
|
77 | + 'HEBREW' => '8859-8', |
|
78 | + |
|
79 | + 'ISO-8859-9' => '8859-9', |
|
80 | + 'ISO8859-9' => '8859-9', |
|
81 | + '8859-9' => '8859-9', |
|
82 | + 'LATIN5' => '8859-9', |
|
83 | + 'TURKISH' => '8859-9', |
|
84 | + 'CP920' => '8859-9', |
|
85 | + |
|
86 | + 'ISO-8859-10' => '8859-10', |
|
87 | + 'ISO8859-10' => '8859-10', |
|
88 | + '8859-10' => '8859-10', |
|
89 | + 'LATIN6' => '8859-10', |
|
90 | + |
|
91 | + 'ISO-8859-11' => '8859-11', |
|
92 | + 'ISO8859-11' => '8859-11', |
|
93 | + '8859-11' => '8859-11', |
|
94 | + 'THAI8' => '8859-11', |
|
95 | + |
|
96 | + 'ISO-8859-13' => '8859-13', |
|
97 | + 'ISO8859-13' => '8859-13', |
|
98 | + '8859-13' => '8859-13', |
|
99 | + 'CP921' => '8859-13', |
|
100 | + |
|
101 | + 'ISO-8859-14' => '8859-14', |
|
102 | + 'ISO8859-14' => '8859-14', |
|
103 | + '8859-14' => '8859-14', |
|
104 | + 'LATIN8' => '8859-14', |
|
105 | + 'ISO-CELTIC' => '8859-14', |
|
106 | + |
|
107 | + 'ISO-8859-15' => '8859-15', |
|
108 | + 'ISO8859-15' => '8859-15', |
|
109 | + '8859-15' => '8859-15', |
|
110 | + 'LATIN0' => '8859-15', |
|
111 | + 'LATIN-9' => '8859-15', |
|
112 | + 'CP923' => '8859-15', |
|
113 | + |
|
114 | + 'WINDOWS-855' => 'CP855', |
|
115 | + 'CP855' => 'CP855', |
|
116 | + 'WINDOWS-855' => 'CP855', |
|
117 | + 'WIN-855' => 'CP855', |
|
118 | + 'WIN855' => 'CP855', |
|
119 | + '855' => 'CP855', |
|
120 | + 'IBM-855' => 'CP855', |
|
121 | + 'IBM855' => 'CP855', |
|
122 | + |
|
123 | + 'WINDOWS-866' => 'CP866', |
|
124 | + 'CP866' => 'CP866', |
|
125 | + 'WINDOWS-866' => 'CP866', |
|
126 | + 'WIN-866' => 'CP866', |
|
127 | + 'WIN866' => 'CP866', |
|
128 | + '866' => 'CP866', |
|
129 | + 'IBM-866' => 'CP866', |
|
130 | + 'IBM866' => 'CP866', |
|
131 | + |
|
132 | + 'WINDOWS-874' => 'CP874', |
|
133 | + 'TIS-620' => 'CP874', |
|
134 | + 'CP874' => 'CP874', |
|
135 | + 'EUCTH' => 'CP874', |
|
136 | + 'WIN-874' => 'CP874', |
|
137 | + 'WIN874' => 'CP874', |
|
138 | + '874' => 'CP874', |
|
139 | + |
|
140 | + 'WINDOWS-1250' => 'CP1250', |
|
141 | + 'CP1250' => 'CP1250', |
|
142 | + 'WIN-1250' => 'CP1250', |
|
143 | + 'WIN1250' => 'CP1250', |
|
144 | + '1250' => 'CP1250', |
|
145 | + |
|
146 | + 'WINDOWS-1251' => 'CP1251', |
|
147 | + 'CP1251' => 'CP1251', |
|
148 | + 'ANSI1251' => 'CP1251', |
|
149 | + 'WIN-1251' => 'CP1251', |
|
150 | + 'WIN1251' => 'CP1251', |
|
151 | + '1251' => 'CP1251', |
|
152 | + |
|
153 | + 'WINDOWS-1252' => 'CP1252', |
|
154 | + 'CP1252' => 'CP1252', |
|
155 | + 'WIN-1252' => 'CP1252', |
|
156 | + 'WIN1252' => 'CP1252', |
|
157 | + '1252' => 'CP1252', |
|
158 | + |
|
159 | + 'WINDOWS-1253' => 'CP1253', |
|
160 | + 'CP1253' => 'CP1253', |
|
161 | + 'WIN-1253' => 'CP1253', |
|
162 | + 'WIN1253' => 'CP1253', |
|
163 | + '1253' => 'CP1253', |
|
164 | + |
|
165 | + 'WINDOWS-1254' => 'CP1254', |
|
166 | + 'CP1254' => 'CP1254', |
|
167 | + 'WIN-1254' => 'CP1254', |
|
168 | + 'WIN1254' => 'CP1254', |
|
169 | + '1254' => 'CP1254', |
|
170 | + |
|
171 | + 'WINDOWS-1255' => 'CP1255', |
|
172 | + 'CP1255' => 'CP1255', |
|
173 | + 'WIN-1255' => 'CP1255', |
|
174 | + 'WIN1255' => 'CP1255', |
|
175 | + '1255' => 'CP1255', |
|
176 | + |
|
177 | + 'WINDOWS-1256' => 'CP1256', |
|
178 | + 'CP1256' => 'CP1256', |
|
179 | + 'WIN-1256' => 'CP1256', |
|
180 | + 'WIN1256' => 'CP1256', |
|
181 | + '1256' => 'CP1256', |
|
182 | + |
|
183 | + 'WINDOWS-1257' => 'CP1257', |
|
184 | + 'CP1257' => 'CP1257', |
|
185 | + 'WIN-1257' => 'CP1257', |
|
186 | + 'WIN1257' => 'CP1257', |
|
187 | + '1257' => 'CP1257', |
|
188 | + |
|
189 | + 'WINDOWS-1258' => 'CP1258', |
|
190 | + 'CP1258' => 'CP1258', |
|
191 | + 'WIN-1258' => 'CP1258', |
|
192 | + 'WIN1258' => 'CP1258', |
|
193 | + '1258' => 'CP1258', |
|
194 | + |
|
195 | + 'KOI8-R' => 'KOI8-R', |
|
196 | + 'CP878' => 'KOI8-R', |
|
197 | + 'KOI8R' => 'KOI8-R', |
|
198 | + 'KOI8-RU' => 'KOI8-R', |
|
199 | + |
|
200 | + 'KOI8-U' => 'KOI8-U', |
|
201 | 201 | |
202 | 202 | ); |
@@ -24,7 +24,7 @@ |
||
24 | 24 | |
25 | 25 | // Using the resource linker as a tool for adding resources to the learning path. |
26 | 26 | if ($action == 'add' && $type == 'learnpathitem') { |
27 | - $htmlHeadXtra[] = "<script> |
|
27 | + $htmlHeadXtra[] = "<script> |
|
28 | 28 | window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; |
29 | 29 | </script>"; |
30 | 30 | } |
@@ -44,231 +44,231 @@ |
||
44 | 44 | |
45 | 45 | class PGTStorageFile extends PGTStorage |
46 | 46 | { |
47 | - /** |
|
48 | - * @addtogroup internalPGTStorageFile |
|
49 | - * @{ |
|
50 | - */ |
|
47 | + /** |
|
48 | + * @addtogroup internalPGTStorageFile |
|
49 | + * @{ |
|
50 | + */ |
|
51 | 51 | |
52 | - /** |
|
53 | - * a string telling where PGT's should be stored on the filesystem. Written by |
|
54 | - * PGTStorageFile::PGTStorageFile(), read by getPath(). |
|
55 | - * |
|
56 | - * @private |
|
57 | - */ |
|
58 | - var $_path; |
|
52 | + /** |
|
53 | + * a string telling where PGT's should be stored on the filesystem. Written by |
|
54 | + * PGTStorageFile::PGTStorageFile(), read by getPath(). |
|
55 | + * |
|
56 | + * @private |
|
57 | + */ |
|
58 | + var $_path; |
|
59 | 59 | |
60 | - /** |
|
61 | - * This method returns the name of the directory where PGT's should be stored |
|
62 | - * on the filesystem. |
|
63 | - * |
|
64 | - * @return the name of a directory (with leading and trailing '/') |
|
65 | - * |
|
66 | - * @private |
|
67 | - */ |
|
68 | - function getPath() |
|
60 | + /** |
|
61 | + * This method returns the name of the directory where PGT's should be stored |
|
62 | + * on the filesystem. |
|
63 | + * |
|
64 | + * @return the name of a directory (with leading and trailing '/') |
|
65 | + * |
|
66 | + * @private |
|
67 | + */ |
|
68 | + function getPath() |
|
69 | 69 | { |
70 | - return $this->_path; |
|
70 | + return $this->_path; |
|
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * a string telling the format to use to store PGT's (plain or xml). Written by |
|
75 | - * PGTStorageFile::PGTStorageFile(), read by getFormat(). |
|
76 | - * |
|
77 | - * @private |
|
78 | - */ |
|
79 | - var $_format; |
|
73 | + /** |
|
74 | + * a string telling the format to use to store PGT's (plain or xml). Written by |
|
75 | + * PGTStorageFile::PGTStorageFile(), read by getFormat(). |
|
76 | + * |
|
77 | + * @private |
|
78 | + */ |
|
79 | + var $_format; |
|
80 | 80 | |
81 | - /** |
|
82 | - * This method returns the format to use when storing PGT's on the filesystem. |
|
83 | - * |
|
84 | - * @return a string corresponding to the format used (plain or xml). |
|
85 | - * |
|
86 | - * @private |
|
87 | - */ |
|
88 | - function getFormat() |
|
81 | + /** |
|
82 | + * This method returns the format to use when storing PGT's on the filesystem. |
|
83 | + * |
|
84 | + * @return a string corresponding to the format used (plain or xml). |
|
85 | + * |
|
86 | + * @private |
|
87 | + */ |
|
88 | + function getFormat() |
|
89 | 89 | { |
90 | - return $this->_format; |
|
90 | + return $this->_format; |
|
91 | 91 | } |
92 | 92 | |
93 | - // ######################################################################## |
|
94 | - // DEBUGGING |
|
95 | - // ######################################################################## |
|
93 | + // ######################################################################## |
|
94 | + // DEBUGGING |
|
95 | + // ######################################################################## |
|
96 | 96 | |
97 | - /** |
|
98 | - * This method returns an informational string giving the type of storage |
|
99 | - * used by the object (used for debugging purposes). |
|
100 | - * |
|
101 | - * @return an informational string. |
|
102 | - * @public |
|
103 | - */ |
|
104 | - function getStorageType() |
|
97 | + /** |
|
98 | + * This method returns an informational string giving the type of storage |
|
99 | + * used by the object (used for debugging purposes). |
|
100 | + * |
|
101 | + * @return an informational string. |
|
102 | + * @public |
|
103 | + */ |
|
104 | + function getStorageType() |
|
105 | 105 | { |
106 | - return "file"; |
|
106 | + return "file"; |
|
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * This method returns an informational string giving informations on the |
|
111 | - * parameters of the storage.(used for debugging purposes). |
|
112 | - * |
|
113 | - * @return an informational string. |
|
114 | - * @public |
|
115 | - */ |
|
116 | - function getStorageInfo() |
|
109 | + /** |
|
110 | + * This method returns an informational string giving informations on the |
|
111 | + * parameters of the storage.(used for debugging purposes). |
|
112 | + * |
|
113 | + * @return an informational string. |
|
114 | + * @public |
|
115 | + */ |
|
116 | + function getStorageInfo() |
|
117 | 117 | { |
118 | - return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\''; |
|
118 | + return 'path=`'.$this->getPath().'\', format=`'.$this->getFormat().'\''; |
|
119 | 119 | } |
120 | 120 | |
121 | - // ######################################################################## |
|
122 | - // CONSTRUCTOR |
|
123 | - // ######################################################################## |
|
121 | + // ######################################################################## |
|
122 | + // CONSTRUCTOR |
|
123 | + // ######################################################################## |
|
124 | 124 | |
125 | - /** |
|
126 | - * The class constructor, called by CASClient::SetPGTStorageFile(). |
|
127 | - * |
|
128 | - * @param $cas_parent the CASClient instance that creates the object. |
|
129 | - * @param $format the format used to store the PGT's (`plain' and `xml' allowed). |
|
130 | - * @param $path the path where the PGT's should be stored |
|
131 | - * |
|
132 | - * @public |
|
133 | - */ |
|
134 | - function PGTStorageFile($cas_parent,$format,$path) |
|
125 | + /** |
|
126 | + * The class constructor, called by CASClient::SetPGTStorageFile(). |
|
127 | + * |
|
128 | + * @param $cas_parent the CASClient instance that creates the object. |
|
129 | + * @param $format the format used to store the PGT's (`plain' and `xml' allowed). |
|
130 | + * @param $path the path where the PGT's should be stored |
|
131 | + * |
|
132 | + * @public |
|
133 | + */ |
|
134 | + function PGTStorageFile($cas_parent,$format,$path) |
|
135 | 135 | { |
136 | - phpCAS::traceBegin(); |
|
137 | - // call the ancestor's constructor |
|
138 | - $this->PGTStorage($cas_parent); |
|
136 | + phpCAS::traceBegin(); |
|
137 | + // call the ancestor's constructor |
|
138 | + $this->PGTStorage($cas_parent); |
|
139 | 139 | |
140 | - if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT; |
|
141 | - if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH; |
|
140 | + if (empty($format) ) $format = CAS_PGT_STORAGE_FILE_DEFAULT_FORMAT; |
|
141 | + if (empty($path) ) $path = CAS_PGT_STORAGE_FILE_DEFAULT_PATH; |
|
142 | 142 | |
143 | - // check that the path is an absolute path |
|
144 | - if (getenv("OS")=="Windows_NT"){ |
|
143 | + // check that the path is an absolute path |
|
144 | + if (getenv("OS")=="Windows_NT"){ |
|
145 | 145 | |
146 | - if (!preg_match('`^[a-zA-Z]:`', $path)) { |
|
147 | - phpCAS::error('an absolute path is needed for PGT storage to file'); |
|
148 | - } |
|
146 | + if (!preg_match('`^[a-zA-Z]:`', $path)) { |
|
147 | + phpCAS::error('an absolute path is needed for PGT storage to file'); |
|
148 | + } |
|
149 | 149 | |
150 | - } |
|
151 | - else |
|
152 | - { |
|
150 | + } |
|
151 | + else |
|
152 | + { |
|
153 | 153 | |
154 | - if ( $path[0] != '/' ) { |
|
155 | - phpCAS::error('an absolute path is needed for PGT storage to file'); |
|
156 | - } |
|
154 | + if ( $path[0] != '/' ) { |
|
155 | + phpCAS::error('an absolute path is needed for PGT storage to file'); |
|
156 | + } |
|
157 | 157 | |
158 | - // store the path (with a leading and trailing '/') |
|
159 | - $path = preg_replace('|[/]*$|','/',$path); |
|
160 | - $path = preg_replace('|^[/]*|','/',$path); |
|
161 | - } |
|
158 | + // store the path (with a leading and trailing '/') |
|
159 | + $path = preg_replace('|[/]*$|','/',$path); |
|
160 | + $path = preg_replace('|^[/]*|','/',$path); |
|
161 | + } |
|
162 | 162 | |
163 | - $this->_path = $path; |
|
164 | - // check the format and store it |
|
165 | - switch ($format) { |
|
166 | - case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN: |
|
163 | + $this->_path = $path; |
|
164 | + // check the format and store it |
|
165 | + switch ($format) { |
|
166 | + case CAS_PGT_STORAGE_FILE_FORMAT_PLAIN: |
|
167 | 167 | case CAS_PGT_STORAGE_FILE_FORMAT_XML: |
168 | - $this->_format = $format; |
|
169 | - break; |
|
170 | - default: |
|
171 | - phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)'); |
|
172 | - } |
|
173 | - phpCAS::traceEnd(); |
|
168 | + $this->_format = $format; |
|
169 | + break; |
|
170 | + default: |
|
171 | + phpCAS::error('unknown PGT file storage format (`'.CAS_PGT_STORAGE_FILE_FORMAT_PLAIN.'\' and `'.CAS_PGT_STORAGE_FILE_FORMAT_XML.'\' allowed)'); |
|
172 | + } |
|
173 | + phpCAS::traceEnd(); |
|
174 | 174 | } |
175 | 175 | |
176 | - // ######################################################################## |
|
177 | - // INITIALIZATION |
|
178 | - // ######################################################################## |
|
176 | + // ######################################################################## |
|
177 | + // INITIALIZATION |
|
178 | + // ######################################################################## |
|
179 | 179 | |
180 | - /** |
|
181 | - * This method is used to initialize the storage. Halts on error. |
|
182 | - * |
|
183 | - * @public |
|
184 | - */ |
|
185 | - function init() |
|
180 | + /** |
|
181 | + * This method is used to initialize the storage. Halts on error. |
|
182 | + * |
|
183 | + * @public |
|
184 | + */ |
|
185 | + function init() |
|
186 | 186 | { |
187 | - phpCAS::traceBegin(); |
|
188 | - // if the storage has already been initialized, return immediatly |
|
189 | - if ( $this->isInitialized() ) |
|
190 | - return; |
|
191 | - // call the ancestor's method (mark as initialized) |
|
192 | - parent::init(); |
|
193 | - phpCAS::traceEnd(); |
|
187 | + phpCAS::traceBegin(); |
|
188 | + // if the storage has already been initialized, return immediatly |
|
189 | + if ( $this->isInitialized() ) |
|
190 | + return; |
|
191 | + // call the ancestor's method (mark as initialized) |
|
192 | + parent::init(); |
|
193 | + phpCAS::traceEnd(); |
|
194 | 194 | } |
195 | 195 | |
196 | - // ######################################################################## |
|
197 | - // PGT I/O |
|
198 | - // ######################################################################## |
|
196 | + // ######################################################################## |
|
197 | + // PGT I/O |
|
198 | + // ######################################################################## |
|
199 | 199 | |
200 | - /** |
|
201 | - * This method returns the filename corresponding to a PGT Iou. |
|
202 | - * |
|
203 | - * @param $pgt_iou the PGT iou. |
|
204 | - * |
|
205 | - * @return a filename |
|
206 | - * @private |
|
207 | - */ |
|
208 | - function getPGTIouFilename($pgt_iou) |
|
200 | + /** |
|
201 | + * This method returns the filename corresponding to a PGT Iou. |
|
202 | + * |
|
203 | + * @param $pgt_iou the PGT iou. |
|
204 | + * |
|
205 | + * @return a filename |
|
206 | + * @private |
|
207 | + */ |
|
208 | + function getPGTIouFilename($pgt_iou) |
|
209 | 209 | { |
210 | - phpCAS::traceBegin(); |
|
211 | - $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat(); |
|
212 | - phpCAS::traceEnd($filename); |
|
213 | - return $filename; |
|
210 | + phpCAS::traceBegin(); |
|
211 | + $filename = $this->getPath().$pgt_iou.'.'.$this->getFormat(); |
|
212 | + phpCAS::traceEnd($filename); |
|
213 | + return $filename; |
|
214 | 214 | } |
215 | 215 | |
216 | - /** |
|
217 | - * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a |
|
218 | - * warning on error. |
|
219 | - * |
|
220 | - * @param $pgt the PGT |
|
221 | - * @param $pgt_iou the PGT iou |
|
222 | - * |
|
223 | - * @public |
|
224 | - */ |
|
225 | - function write($pgt,$pgt_iou) |
|
216 | + /** |
|
217 | + * This method stores a PGT and its corresponding PGT Iou into a file. Echoes a |
|
218 | + * warning on error. |
|
219 | + * |
|
220 | + * @param $pgt the PGT |
|
221 | + * @param $pgt_iou the PGT iou |
|
222 | + * |
|
223 | + * @public |
|
224 | + */ |
|
225 | + function write($pgt,$pgt_iou) |
|
226 | 226 | { |
227 | - phpCAS::traceBegin(); |
|
228 | - $fname = $this->getPGTIouFilename($pgt_iou); |
|
229 | - if ( $f=fopen($fname,"w") ) { |
|
230 | - if ( fputs($f,$pgt) === FALSE ) { |
|
231 | - phpCAS::error('could not write PGT to `'.$fname.'\''); |
|
232 | - } |
|
233 | - fclose($f); |
|
234 | - } else { |
|
235 | - phpCAS::error('could not open `'.$fname.'\''); |
|
236 | - } |
|
237 | - phpCAS::traceEnd(); |
|
227 | + phpCAS::traceBegin(); |
|
228 | + $fname = $this->getPGTIouFilename($pgt_iou); |
|
229 | + if ( $f=fopen($fname,"w") ) { |
|
230 | + if ( fputs($f,$pgt) === FALSE ) { |
|
231 | + phpCAS::error('could not write PGT to `'.$fname.'\''); |
|
232 | + } |
|
233 | + fclose($f); |
|
234 | + } else { |
|
235 | + phpCAS::error('could not open `'.$fname.'\''); |
|
236 | + } |
|
237 | + phpCAS::traceEnd(); |
|
238 | 238 | } |
239 | 239 | |
240 | - /** |
|
241 | - * This method reads a PGT corresponding to a PGT Iou and deletes the |
|
242 | - * corresponding file. |
|
243 | - * |
|
244 | - * @param $pgt_iou the PGT iou |
|
245 | - * |
|
246 | - * @return the corresponding PGT, or FALSE on error |
|
247 | - * |
|
248 | - * @public |
|
249 | - */ |
|
250 | - function read($pgt_iou) |
|
240 | + /** |
|
241 | + * This method reads a PGT corresponding to a PGT Iou and deletes the |
|
242 | + * corresponding file. |
|
243 | + * |
|
244 | + * @param $pgt_iou the PGT iou |
|
245 | + * |
|
246 | + * @return the corresponding PGT, or FALSE on error |
|
247 | + * |
|
248 | + * @public |
|
249 | + */ |
|
250 | + function read($pgt_iou) |
|
251 | 251 | { |
252 | - phpCAS::traceBegin(); |
|
253 | - $pgt = FALSE; |
|
254 | - $fname = $this->getPGTIouFilename($pgt_iou); |
|
255 | - if ( !($f=fopen($fname,"r")) ) { |
|
256 | - phpCAS::trace('could not open `'.$fname.'\''); |
|
257 | - } else { |
|
258 | - if ( ($pgt=fgets($f)) === FALSE ) { |
|
259 | - phpCAS::trace('could not read PGT from `'.$fname.'\''); |
|
260 | - } |
|
261 | - fclose($f); |
|
262 | - } |
|
252 | + phpCAS::traceBegin(); |
|
253 | + $pgt = FALSE; |
|
254 | + $fname = $this->getPGTIouFilename($pgt_iou); |
|
255 | + if ( !($f=fopen($fname,"r")) ) { |
|
256 | + phpCAS::trace('could not open `'.$fname.'\''); |
|
257 | + } else { |
|
258 | + if ( ($pgt=fgets($f)) === FALSE ) { |
|
259 | + phpCAS::trace('could not read PGT from `'.$fname.'\''); |
|
260 | + } |
|
261 | + fclose($f); |
|
262 | + } |
|
263 | 263 | |
264 | - // delete the PGT file |
|
265 | - @unlink($fname); |
|
264 | + // delete the PGT file |
|
265 | + @unlink($fname); |
|
266 | 266 | |
267 | - phpCAS::traceEnd($pgt); |
|
268 | - return $pgt; |
|
267 | + phpCAS::traceEnd($pgt); |
|
268 | + return $pgt; |
|
269 | 269 | } |
270 | 270 | |
271 | - /** @} */ |
|
271 | + /** @} */ |
|
272 | 272 | |
273 | 273 | } |
274 | 274 |