Completed
Push — developer ( 07972d...14e3b3 )
by Błażej
208:43 queued 165:33
created
admin/include/Viewer.php 1 patch
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -28,8 +28,9 @@  discard block
 block discarded – undo
28 28
 	protected function log($message, $delimiter = "\n")
29 29
 	{
30 30
 		static $file = null;
31
-		if ($file === null)
32
-			$file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log';
31
+		if ($file === null) {
32
+					$file = dirname(__FILE__) . '/../../cache/logs/viewer-debug.log';
33
+		}
33 34
 		if (self::$debugViewer) {
34 35
 			file_put_contents($file, $message . $delimiter, FILE_APPEND);
35 36
 		}
@@ -173,10 +174,11 @@  discard block
 block discarded – undo
173 174
 			foreach ($this->tpl_vars as $key => $smarty_variable) {
174 175
 				// Determine type of value being pased.
175 176
 				$valueType = 'literal';
176
-				if (is_object($smarty_variable->value))
177
-					$valueType = get_class($smarty_variable->value);
178
-				else if (is_array($smarty_variable->value))
179
-					$valueType = 'array';
177
+				if (is_object($smarty_variable->value)) {
178
+									$valueType = get_class($smarty_variable->value);
179
+				} else if (is_array($smarty_variable->value)) {
180
+									$valueType = 'array';
181
+				}
180 182
 				$this->log(sprintf("DATA: %s, TYPE: %s", $key, $valueType));
181 183
 			}
182 184
 		}
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_security.php 1 patch
Indentation   +705 added lines, -705 removed lines patch added patch discarded remove patch
@@ -13,710 +13,710 @@
 block discarded – undo
13 13
  */
14 14
 class Smarty_Security
15 15
 {
16
-    /**
17
-     * This determines how Smarty handles "<?php ... ?>" tags in templates.
18
-     * possible values:
19
-     * <ul>
20
-     *   <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li>
21
-     *   <li>Smarty::PHP_QUOTE    -> escape tags as entities</li>
22
-     *   <li>Smarty::PHP_REMOVE   -> remove php tags</li>
23
-     *   <li>Smarty::PHP_ALLOW    -> execute php tags</li>
24
-     * </ul>
25
-     *
26
-     * @var integer
27
-     */
28
-    public $php_handling = Smarty::PHP_PASSTHRU;
29
-
30
-    /**
31
-     * This is the list of template directories that are considered secure.
32
-     * $template_dir is in this list implicitly.
33
-     *
34
-     * @var array
35
-     */
36
-    public $secure_dir = array();
37
-
38
-    /**
39
-     * This is an array of directories where trusted php scripts reside.
40
-     * {@link $security} is disabled during their inclusion/execution.
41
-     *
42
-     * @var array
43
-     */
44
-    public $trusted_dir = array();
45
-
46
-    /**
47
-     * List of regular expressions (PCRE) that include trusted URIs
48
-     *
49
-     * @var array
50
-     */
51
-    public $trusted_uri = array();
52
-
53
-    /**
54
-     * List of trusted constants names
55
-     *
56
-     * @var array
57
-     */
58
-    public $trusted_constants = array();
59
-
60
-    /**
61
-     * This is an array of trusted static classes.
62
-     * If empty access to all static classes is allowed.
63
-     * If set to 'none' none is allowed.
64
-     *
65
-     * @var array
66
-     */
67
-    public $static_classes = array();
68
-
69
-    /**
70
-     * This is an nested array of trusted classes and static methods.
71
-     * If empty access to all static classes and methods is allowed.
72
-     * Format:
73
-     * array (
74
-     *         'class_1' => array('method_1', 'method_2'), // allowed methods listed
75
-     *         'class_2' => array(),                       // all methods of class allowed
76
-     *       )
77
-     * If set to null none is allowed.
78
-     *
79
-     * @var array
80
-     */
81
-    public $trusted_static_methods = array();
82
-
83
-    /**
84
-     * This is an array of trusted static properties.
85
-     * If empty access to all static classes and properties is allowed.
86
-     * Format:
87
-     * array (
88
-     *         'class_1' => array('prop_1', 'prop_2'), // allowed properties listed
89
-     *         'class_2' => array(),                   // all properties of class allowed
90
-     *       )
91
-     * If set to null none is allowed.
92
-     *
93
-     * @var array
94
-     */
95
-    public $trusted_static_properties = array();
96
-
97
-    /**
98
-     * This is an array of trusted PHP functions.
99
-     * If empty all functions are allowed.
100
-     * To disable all PHP functions set $php_functions = null.
101
-     *
102
-     * @var array
103
-     */
104
-    public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',);
105
-
106
-    /**
107
-     * This is an array of trusted PHP modifiers.
108
-     * If empty all modifiers are allowed.
109
-     * To disable all modifier set $php_modifiers = null.
110
-     *
111
-     * @var array
112
-     */
113
-    public $php_modifiers = array('escape', 'count', 'nl2br',);
114
-
115
-    /**
116
-     * This is an array of allowed tags.
117
-     * If empty no restriction by allowed_tags.
118
-     *
119
-     * @var array
120
-     */
121
-    public $allowed_tags = array();
122
-
123
-    /**
124
-     * This is an array of disabled tags.
125
-     * If empty no restriction by disabled_tags.
126
-     *
127
-     * @var array
128
-     */
129
-    public $disabled_tags = array();
130
-
131
-    /**
132
-     * This is an array of allowed modifier plugins.
133
-     * If empty no restriction by allowed_modifiers.
134
-     *
135
-     * @var array
136
-     */
137
-    public $allowed_modifiers = array();
138
-
139
-    /**
140
-     * This is an array of disabled modifier plugins.
141
-     * If empty no restriction by disabled_modifiers.
142
-     *
143
-     * @var array
144
-     */
145
-    public $disabled_modifiers = array();
146
-
147
-    /**
148
-     * This is an array of disabled special $smarty variables.
149
-     *
150
-     * @var array
151
-     */
152
-    public $disabled_special_smarty_vars = array();
153
-
154
-    /**
155
-     * This is an array of trusted streams.
156
-     * If empty all streams are allowed.
157
-     * To disable all streams set $streams = null.
158
-     *
159
-     * @var array
160
-     */
161
-    public $streams = array('file');
162
-
163
-    /**
164
-     * + flag if constants can be accessed from template
165
-     *
166
-     * @var boolean
167
-     */
168
-    public $allow_constants = true;
169
-
170
-    /**
171
-     * + flag if super globals can be accessed from template
172
-     *
173
-     * @var boolean
174
-     */
175
-    public $allow_super_globals = true;
176
-
177
-    /**
178
-     * max template nesting level
179
-     *
180
-     * @var int
181
-     */
182
-    public $max_template_nesting = 0;
183
-
184
-    /**
185
-     * current template nesting level
186
-     *
187
-     * @var int
188
-     */
189
-    private $_current_template_nesting = 0;
190
-
191
-    /**
192
-     * Cache for $resource_dir lookup
193
-     *
194
-     * @var array
195
-     */
196
-    protected $_resource_dir = array();
197
-
198
-    /**
199
-     * Cache for $template_dir lookup
200
-     *
201
-     * @var array
202
-     */
203
-    protected $_template_dir = array();
204
-
205
-    /**
206
-     * Cache for $config_dir lookup
207
-     *
208
-     * @var array
209
-     */
210
-    protected $_config_dir = array();
211
-
212
-    /**
213
-     * Cache for $secure_dir lookup
214
-     *
215
-     * @var array
216
-     */
217
-    protected $_secure_dir = array();
218
-
219
-    /**
220
-     * Cache for $php_resource_dir lookup
221
-     *
222
-     * @var array
223
-     */
224
-    protected $_php_resource_dir = null;
225
-
226
-    /**
227
-     * Cache for $trusted_dir lookup
228
-     *
229
-     * @var array
230
-     */
231
-    protected $_trusted_dir = null;
232
-
233
-    /**
234
-     * Cache for include path status
235
-     *
236
-     * @var bool
237
-     */
238
-    protected $_include_path_status = false;
239
-
240
-    /**
241
-     * Cache for $_include_array lookup
242
-     *
243
-     * @var array
244
-     */
245
-    protected $_include_dir = array();
246
-
247
-    /**
248
-     * @param Smarty $smarty
249
-     */
250
-    public function __construct($smarty)
251
-    {
252
-        $this->smarty = $smarty;
253
-        $this->smarty->_cache[ 'template_dir_new' ] = true;
254
-        $this->smarty->_cache[ 'config_dir_new' ] = true;
255
-    }
256
-
257
-    /**
258
-     * Check if PHP function is trusted.
259
-     *
260
-     * @param  string $function_name
261
-     * @param  object $compiler compiler object
262
-     *
263
-     * @return boolean                 true if function is trusted
264
-     * @throws SmartyCompilerException if php function is not trusted
265
-     */
266
-    public function isTrustedPhpFunction($function_name, $compiler)
267
-    {
268
-        if (isset($this->php_functions) &&
269
-            (empty($this->php_functions) || in_array($function_name, $this->php_functions))
270
-        ) {
271
-            return true;
272
-        }
273
-
274
-        $compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting");
275
-
276
-        return false; // should not, but who knows what happens to the compiler in the future?
277
-    }
278
-
279
-    /**
280
-     * Check if static class is trusted.
281
-     *
282
-     * @param  string $class_name
283
-     * @param  object $compiler compiler object
284
-     *
285
-     * @return boolean                 true if class is trusted
286
-     * @throws SmartyCompilerException if static class is not trusted
287
-     */
288
-    public function isTrustedStaticClass($class_name, $compiler)
289
-    {
290
-        if (isset($this->static_classes) &&
291
-            (empty($this->static_classes) || in_array($class_name, $this->static_classes))
292
-        ) {
293
-            return true;
294
-        }
295
-
296
-        $compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting");
297
-
298
-        return false; // should not, but who knows what happens to the compiler in the future?
299
-    }
300
-
301
-    /**
302
-     * Check if static class method/property is trusted.
303
-     *
304
-     * @param  string $class_name
305
-     * @param  string $params
306
-     * @param  object $compiler compiler object
307
-     *
308
-     * @return boolean                 true if class method is trusted
309
-     * @throws SmartyCompilerException if static class method is not trusted
310
-     */
311
-    public function isTrustedStaticClassAccess($class_name, $params, $compiler)
312
-    {
313
-        if (!isset($params[ 2 ])) {
314
-            // fall back
315
-            return $this->isTrustedStaticClass($class_name, $compiler);
316
-        }
317
-        if ($params[ 2 ] == 'method') {
318
-            $allowed = $this->trusted_static_methods;
319
-            $name = substr($params[ 0 ], 0, strpos($params[ 0 ], '('));
320
-        } else {
321
-            $allowed = $this->trusted_static_properties;
322
-            // strip '$'
323
-            $name = substr($params[ 0 ], 1);
324
-        }
325
-        if (isset($allowed)) {
326
-            if (empty($allowed)) {
327
-                // fall back
328
-                return $this->isTrustedStaticClass($class_name, $compiler);
329
-            }
330
-            if (isset($allowed[ $class_name ]) &&
331
-                (empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ]))
332
-            ) {
333
-                return true;
334
-            }
335
-        }
336
-        $compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting");
337
-        return false; // should not, but who knows what happens to the compiler in the future?
338
-    }
339
-
340
-    /**
341
-     * Check if PHP modifier is trusted.
342
-     *
343
-     * @param  string $modifier_name
344
-     * @param  object $compiler compiler object
345
-     *
346
-     * @return boolean                 true if modifier is trusted
347
-     * @throws SmartyCompilerException if modifier is not trusted
348
-     */
349
-    public function isTrustedPhpModifier($modifier_name, $compiler)
350
-    {
351
-        if (isset($this->php_modifiers) &&
352
-            (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))
353
-        ) {
354
-            return true;
355
-        }
356
-
357
-        $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting");
358
-
359
-        return false; // should not, but who knows what happens to the compiler in the future?
360
-    }
361
-
362
-    /**
363
-     * Check if tag is trusted.
364
-     *
365
-     * @param  string $tag_name
366
-     * @param  object $compiler compiler object
367
-     *
368
-     * @return boolean                 true if tag is trusted
369
-     * @throws SmartyCompilerException if modifier is not trusted
370
-     */
371
-    public function isTrustedTag($tag_name, $compiler)
372
-    {
373
-        // check for internal always required tags
374
-        if (in_array($tag_name,
375
-                     array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin',
376
-                           'private_object_block_function', 'private_object_function', 'private_registered_function',
377
-                           'private_registered_block', 'private_special_variable', 'private_print_expression',
378
-                           'private_modifier'))) {
379
-            return true;
380
-        }
381
-        // check security settings
382
-        if (empty($this->allowed_tags)) {
383
-            if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
384
-                return true;
385
-            } else {
386
-                $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true);
387
-            }
388
-        } elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
389
-            return true;
390
-        } else {
391
-            $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true);
392
-        }
393
-
394
-        return false; // should not, but who knows what happens to the compiler in the future?
395
-    }
396
-
397
-    /**
398
-     * Check if special $smarty variable is trusted.
399
-     *
400
-     * @param  string $var_name
401
-     * @param  object $compiler compiler object
402
-     *
403
-     * @return boolean                 true if tag is trusted
404
-     * @throws SmartyCompilerException if modifier is not trusted
405
-     */
406
-    public function isTrustedSpecialSmartyVar($var_name, $compiler)
407
-    {
408
-        if (!in_array($var_name, $this->disabled_special_smarty_vars)) {
409
-            return true;
410
-        } else {
411
-            $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting",
412
-                                              null, true);
413
-        }
414
-
415
-        return false; // should not, but who knows what happens to the compiler in the future?
416
-    }
417
-
418
-    /**
419
-     * Check if modifier plugin is trusted.
420
-     *
421
-     * @param  string $modifier_name
422
-     * @param  object $compiler compiler object
423
-     *
424
-     * @return boolean                 true if tag is trusted
425
-     * @throws SmartyCompilerException if modifier is not trusted
426
-     */
427
-    public function isTrustedModifier($modifier_name, $compiler)
428
-    {
429
-        // check for internal always allowed modifier
430
-        if (in_array($modifier_name, array('default'))) {
431
-            return true;
432
-        }
433
-        // check security settings
434
-        if (empty($this->allowed_modifiers)) {
435
-            if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
436
-                return true;
437
-            } else {
438
-                $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null,
439
-                                                  true);
440
-            }
441
-        } elseif (in_array($modifier_name, $this->allowed_modifiers) &&
442
-                  !in_array($modifier_name, $this->disabled_modifiers)
443
-        ) {
444
-            return true;
445
-        } else {
446
-            $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null,
447
-                                              true);
448
-        }
449
-
450
-        return false; // should not, but who knows what happens to the compiler in the future?
451
-    }
452
-
453
-    /**
454
-     * Check if constants are enabled or trusted
455
-     *
456
-     * @param  string $const    constant name
457
-     * @param  object $compiler compiler object
458
-     *
459
-     * @return bool
460
-     */
461
-    public function isTrustedConstant($const, $compiler)
462
-    {
463
-        if (in_array($const, array('true', 'false', 'null'))) {
464
-            return true;
465
-        }
466
-        if (!empty($this->trusted_constants)) {
467
-            if (!in_array($const, $this->trusted_constants)) {
468
-                $compiler->trigger_template_error("Security: access to constant '{$const}' not permitted");
469
-                return false;
470
-            }
471
-            return true;
472
-        }
473
-        if ($this->allow_constants) {
474
-            return true;
475
-        }
476
-        $compiler->trigger_template_error("Security: access to constants not permitted");
477
-        return false;
478
-    }
479
-
480
-    /**
481
-     * Check if stream is trusted.
482
-     *
483
-     * @param  string $stream_name
484
-     *
485
-     * @return boolean         true if stream is trusted
486
-     * @throws SmartyException if stream is not trusted
487
-     */
488
-    public function isTrustedStream($stream_name)
489
-    {
490
-        if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) {
491
-            return true;
492
-        }
493
-
494
-        throw new SmartyException("stream '{$stream_name}' not allowed by security setting");
495
-    }
496
-
497
-    /**
498
-     * Check if directory of file resource is trusted.
499
-     *
500
-     * @param  string   $filepath
501
-     * @param null|bool $isConfig
502
-     *
503
-     * @return bool true if directory is trusted
504
-     * @throws \SmartyException if directory is not trusted
505
-     */
506
-    public function isTrustedResourceDir($filepath, $isConfig = null)
507
-    {
508
-        if ($this->_include_path_status !== $this->smarty->use_include_path) {
509
-            foreach ($this->_include_dir as $directory) {
510
-                unset($this->_resource_dir[ $directory ]);
511
-            }
512
-            if ($this->smarty->use_include_path) {
513
-                $this->_include_dir = array();
514
-                $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty);
515
-                foreach ($_dirs as $directory) {
516
-                    $this->_include_dir[] = $directory;
517
-                    $this->_resource_dir[ $directory ] = true;
518
-                }
519
-            }
520
-            $this->_include_path_status = $this->smarty->use_include_path;
521
-        }
522
-        if ($isConfig !== true &&
523
-            (!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ])
524
-        ) {
525
-            $_dir = $this->smarty->getTemplateDir();
526
-            if ($this->_template_dir !== $_dir) {
527
-                foreach ($this->_template_dir as $directory) {
528
-                    unset($this->_resource_dir[ $directory ]);
529
-                }
530
-                foreach ($_dir as $directory) {
531
-                    $this->_resource_dir[ $directory ] = true;
532
-                }
533
-                $this->_template_dir = $_dir;
534
-            }
535
-            $this->smarty->_cache[ 'template_dir_new' ] = false;
536
-        }
537
-        if ($isConfig !== false &&
538
-            (!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ])
539
-        ) {
540
-            $_dir = $this->smarty->getConfigDir();
541
-            if ($this->_config_dir !== $_dir) {
542
-                foreach ($this->_config_dir as $directory) {
543
-                    unset($this->_resource_dir[ $directory ]);
544
-                }
545
-                foreach ($_dir as $directory) {
546
-                    $this->_resource_dir[ $directory ] = true;
547
-                }
548
-                $this->_config_dir = $_dir;
549
-            }
550
-            $this->smarty->_cache[ 'config_dir_new' ] = false;
551
-        }
552
-        if ($this->_secure_dir !== (array) $this->secure_dir) {
553
-            foreach ($this->_secure_dir as $directory) {
554
-                unset($this->_resource_dir[ $directory ]);
555
-            }
556
-            foreach ((array) $this->secure_dir as $directory) {
557
-                $directory = $this->smarty->_realpath($directory . DS, true);
558
-                $this->_resource_dir[ $directory ] = true;
559
-            }
560
-            $this->_secure_dir = (array) $this->secure_dir;
561
-        }
562
-        $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir);
563
-        return true;
564
-    }
565
-
566
-    /**
567
-     * Check if URI (e.g. {fetch} or {html_image}) is trusted
568
-     * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}".
569
-     * So "http://username:[email protected]:8080/some-path?some=query-string"
570
-     * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}.
571
-     *
572
-     * @param  string $uri
573
-     *
574
-     * @return boolean         true if URI is trusted
575
-     * @throws SmartyException if URI is not trusted
576
-     * @uses $trusted_uri for list of patterns to match against $uri
577
-     */
578
-    public function isTrustedUri($uri)
579
-    {
580
-        $_uri = parse_url($uri);
581
-        if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) {
582
-            $_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ];
583
-            foreach ($this->trusted_uri as $pattern) {
584
-                if (preg_match($pattern, $_uri)) {
585
-                    return true;
586
-                }
587
-            }
588
-        }
589
-
590
-        throw new SmartyException("URI '{$uri}' not allowed by security setting");
591
-    }
592
-
593
-    /**
594
-     * Check if directory of file resource is trusted.
595
-     *
596
-     * @param  string $filepath
597
-     *
598
-     * @return boolean         true if directory is trusted
599
-     * @throws SmartyException if PHP directory is not trusted
600
-     */
601
-    public function isTrustedPHPDir($filepath)
602
-    {
603
-        if (empty($this->trusted_dir)) {
604
-            throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
605
-        }
606
-
607
-        // check if index is outdated
608
-        if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) {
609
-            $this->_php_resource_dir = array();
610
-
611
-            $this->_trusted_dir = $this->trusted_dir;
612
-            foreach ((array) $this->trusted_dir as $directory) {
613
-                $directory = $this->smarty->_realpath($directory . DS, true);
614
-                $this->_php_resource_dir[ $directory ] = true;
615
-            }
616
-        }
617
-
618
-        $this->_php_resource_dir =
619
-            $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir);
620
-        return true;
621
-    }
16
+	/**
17
+	 * This determines how Smarty handles "<?php ... ?>" tags in templates.
18
+	 * possible values:
19
+	 * <ul>
20
+	 *   <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li>
21
+	 *   <li>Smarty::PHP_QUOTE    -> escape tags as entities</li>
22
+	 *   <li>Smarty::PHP_REMOVE   -> remove php tags</li>
23
+	 *   <li>Smarty::PHP_ALLOW    -> execute php tags</li>
24
+	 * </ul>
25
+	 *
26
+	 * @var integer
27
+	 */
28
+	public $php_handling = Smarty::PHP_PASSTHRU;
29
+
30
+	/**
31
+	 * This is the list of template directories that are considered secure.
32
+	 * $template_dir is in this list implicitly.
33
+	 *
34
+	 * @var array
35
+	 */
36
+	public $secure_dir = array();
37
+
38
+	/**
39
+	 * This is an array of directories where trusted php scripts reside.
40
+	 * {@link $security} is disabled during their inclusion/execution.
41
+	 *
42
+	 * @var array
43
+	 */
44
+	public $trusted_dir = array();
45
+
46
+	/**
47
+	 * List of regular expressions (PCRE) that include trusted URIs
48
+	 *
49
+	 * @var array
50
+	 */
51
+	public $trusted_uri = array();
52
+
53
+	/**
54
+	 * List of trusted constants names
55
+	 *
56
+	 * @var array
57
+	 */
58
+	public $trusted_constants = array();
59
+
60
+	/**
61
+	 * This is an array of trusted static classes.
62
+	 * If empty access to all static classes is allowed.
63
+	 * If set to 'none' none is allowed.
64
+	 *
65
+	 * @var array
66
+	 */
67
+	public $static_classes = array();
68
+
69
+	/**
70
+	 * This is an nested array of trusted classes and static methods.
71
+	 * If empty access to all static classes and methods is allowed.
72
+	 * Format:
73
+	 * array (
74
+	 *         'class_1' => array('method_1', 'method_2'), // allowed methods listed
75
+	 *         'class_2' => array(),                       // all methods of class allowed
76
+	 *       )
77
+	 * If set to null none is allowed.
78
+	 *
79
+	 * @var array
80
+	 */
81
+	public $trusted_static_methods = array();
82
+
83
+	/**
84
+	 * This is an array of trusted static properties.
85
+	 * If empty access to all static classes and properties is allowed.
86
+	 * Format:
87
+	 * array (
88
+	 *         'class_1' => array('prop_1', 'prop_2'), // allowed properties listed
89
+	 *         'class_2' => array(),                   // all properties of class allowed
90
+	 *       )
91
+	 * If set to null none is allowed.
92
+	 *
93
+	 * @var array
94
+	 */
95
+	public $trusted_static_properties = array();
96
+
97
+	/**
98
+	 * This is an array of trusted PHP functions.
99
+	 * If empty all functions are allowed.
100
+	 * To disable all PHP functions set $php_functions = null.
101
+	 *
102
+	 * @var array
103
+	 */
104
+	public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',);
105
+
106
+	/**
107
+	 * This is an array of trusted PHP modifiers.
108
+	 * If empty all modifiers are allowed.
109
+	 * To disable all modifier set $php_modifiers = null.
110
+	 *
111
+	 * @var array
112
+	 */
113
+	public $php_modifiers = array('escape', 'count', 'nl2br',);
114
+
115
+	/**
116
+	 * This is an array of allowed tags.
117
+	 * If empty no restriction by allowed_tags.
118
+	 *
119
+	 * @var array
120
+	 */
121
+	public $allowed_tags = array();
122
+
123
+	/**
124
+	 * This is an array of disabled tags.
125
+	 * If empty no restriction by disabled_tags.
126
+	 *
127
+	 * @var array
128
+	 */
129
+	public $disabled_tags = array();
130
+
131
+	/**
132
+	 * This is an array of allowed modifier plugins.
133
+	 * If empty no restriction by allowed_modifiers.
134
+	 *
135
+	 * @var array
136
+	 */
137
+	public $allowed_modifiers = array();
138
+
139
+	/**
140
+	 * This is an array of disabled modifier plugins.
141
+	 * If empty no restriction by disabled_modifiers.
142
+	 *
143
+	 * @var array
144
+	 */
145
+	public $disabled_modifiers = array();
146
+
147
+	/**
148
+	 * This is an array of disabled special $smarty variables.
149
+	 *
150
+	 * @var array
151
+	 */
152
+	public $disabled_special_smarty_vars = array();
153
+
154
+	/**
155
+	 * This is an array of trusted streams.
156
+	 * If empty all streams are allowed.
157
+	 * To disable all streams set $streams = null.
158
+	 *
159
+	 * @var array
160
+	 */
161
+	public $streams = array('file');
162
+
163
+	/**
164
+	 * + flag if constants can be accessed from template
165
+	 *
166
+	 * @var boolean
167
+	 */
168
+	public $allow_constants = true;
169
+
170
+	/**
171
+	 * + flag if super globals can be accessed from template
172
+	 *
173
+	 * @var boolean
174
+	 */
175
+	public $allow_super_globals = true;
176
+
177
+	/**
178
+	 * max template nesting level
179
+	 *
180
+	 * @var int
181
+	 */
182
+	public $max_template_nesting = 0;
183
+
184
+	/**
185
+	 * current template nesting level
186
+	 *
187
+	 * @var int
188
+	 */
189
+	private $_current_template_nesting = 0;
190
+
191
+	/**
192
+	 * Cache for $resource_dir lookup
193
+	 *
194
+	 * @var array
195
+	 */
196
+	protected $_resource_dir = array();
197
+
198
+	/**
199
+	 * Cache for $template_dir lookup
200
+	 *
201
+	 * @var array
202
+	 */
203
+	protected $_template_dir = array();
204
+
205
+	/**
206
+	 * Cache for $config_dir lookup
207
+	 *
208
+	 * @var array
209
+	 */
210
+	protected $_config_dir = array();
211
+
212
+	/**
213
+	 * Cache for $secure_dir lookup
214
+	 *
215
+	 * @var array
216
+	 */
217
+	protected $_secure_dir = array();
218
+
219
+	/**
220
+	 * Cache for $php_resource_dir lookup
221
+	 *
222
+	 * @var array
223
+	 */
224
+	protected $_php_resource_dir = null;
225
+
226
+	/**
227
+	 * Cache for $trusted_dir lookup
228
+	 *
229
+	 * @var array
230
+	 */
231
+	protected $_trusted_dir = null;
232
+
233
+	/**
234
+	 * Cache for include path status
235
+	 *
236
+	 * @var bool
237
+	 */
238
+	protected $_include_path_status = false;
239
+
240
+	/**
241
+	 * Cache for $_include_array lookup
242
+	 *
243
+	 * @var array
244
+	 */
245
+	protected $_include_dir = array();
246
+
247
+	/**
248
+	 * @param Smarty $smarty
249
+	 */
250
+	public function __construct($smarty)
251
+	{
252
+		$this->smarty = $smarty;
253
+		$this->smarty->_cache[ 'template_dir_new' ] = true;
254
+		$this->smarty->_cache[ 'config_dir_new' ] = true;
255
+	}
256
+
257
+	/**
258
+	 * Check if PHP function is trusted.
259
+	 *
260
+	 * @param  string $function_name
261
+	 * @param  object $compiler compiler object
262
+	 *
263
+	 * @return boolean                 true if function is trusted
264
+	 * @throws SmartyCompilerException if php function is not trusted
265
+	 */
266
+	public function isTrustedPhpFunction($function_name, $compiler)
267
+	{
268
+		if (isset($this->php_functions) &&
269
+			(empty($this->php_functions) || in_array($function_name, $this->php_functions))
270
+		) {
271
+			return true;
272
+		}
273
+
274
+		$compiler->trigger_template_error("PHP function '{$function_name}' not allowed by security setting");
275
+
276
+		return false; // should not, but who knows what happens to the compiler in the future?
277
+	}
278
+
279
+	/**
280
+	 * Check if static class is trusted.
281
+	 *
282
+	 * @param  string $class_name
283
+	 * @param  object $compiler compiler object
284
+	 *
285
+	 * @return boolean                 true if class is trusted
286
+	 * @throws SmartyCompilerException if static class is not trusted
287
+	 */
288
+	public function isTrustedStaticClass($class_name, $compiler)
289
+	{
290
+		if (isset($this->static_classes) &&
291
+			(empty($this->static_classes) || in_array($class_name, $this->static_classes))
292
+		) {
293
+			return true;
294
+		}
295
+
296
+		$compiler->trigger_template_error("access to static class '{$class_name}' not allowed by security setting");
297
+
298
+		return false; // should not, but who knows what happens to the compiler in the future?
299
+	}
300
+
301
+	/**
302
+	 * Check if static class method/property is trusted.
303
+	 *
304
+	 * @param  string $class_name
305
+	 * @param  string $params
306
+	 * @param  object $compiler compiler object
307
+	 *
308
+	 * @return boolean                 true if class method is trusted
309
+	 * @throws SmartyCompilerException if static class method is not trusted
310
+	 */
311
+	public function isTrustedStaticClassAccess($class_name, $params, $compiler)
312
+	{
313
+		if (!isset($params[ 2 ])) {
314
+			// fall back
315
+			return $this->isTrustedStaticClass($class_name, $compiler);
316
+		}
317
+		if ($params[ 2 ] == 'method') {
318
+			$allowed = $this->trusted_static_methods;
319
+			$name = substr($params[ 0 ], 0, strpos($params[ 0 ], '('));
320
+		} else {
321
+			$allowed = $this->trusted_static_properties;
322
+			// strip '$'
323
+			$name = substr($params[ 0 ], 1);
324
+		}
325
+		if (isset($allowed)) {
326
+			if (empty($allowed)) {
327
+				// fall back
328
+				return $this->isTrustedStaticClass($class_name, $compiler);
329
+			}
330
+			if (isset($allowed[ $class_name ]) &&
331
+				(empty($allowed[ $class_name ]) || in_array($name, $allowed[ $class_name ]))
332
+			) {
333
+				return true;
334
+			}
335
+		}
336
+		$compiler->trigger_template_error("access to static class '{$class_name}' {$params[2]} '{$name}' not allowed by security setting");
337
+		return false; // should not, but who knows what happens to the compiler in the future?
338
+	}
339
+
340
+	/**
341
+	 * Check if PHP modifier is trusted.
342
+	 *
343
+	 * @param  string $modifier_name
344
+	 * @param  object $compiler compiler object
345
+	 *
346
+	 * @return boolean                 true if modifier is trusted
347
+	 * @throws SmartyCompilerException if modifier is not trusted
348
+	 */
349
+	public function isTrustedPhpModifier($modifier_name, $compiler)
350
+	{
351
+		if (isset($this->php_modifiers) &&
352
+			(empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))
353
+		) {
354
+			return true;
355
+		}
356
+
357
+		$compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting");
358
+
359
+		return false; // should not, but who knows what happens to the compiler in the future?
360
+	}
361
+
362
+	/**
363
+	 * Check if tag is trusted.
364
+	 *
365
+	 * @param  string $tag_name
366
+	 * @param  object $compiler compiler object
367
+	 *
368
+	 * @return boolean                 true if tag is trusted
369
+	 * @throws SmartyCompilerException if modifier is not trusted
370
+	 */
371
+	public function isTrustedTag($tag_name, $compiler)
372
+	{
373
+		// check for internal always required tags
374
+		if (in_array($tag_name,
375
+					 array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin',
376
+						   'private_object_block_function', 'private_object_function', 'private_registered_function',
377
+						   'private_registered_block', 'private_special_variable', 'private_print_expression',
378
+						   'private_modifier'))) {
379
+			return true;
380
+		}
381
+		// check security settings
382
+		if (empty($this->allowed_tags)) {
383
+			if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
384
+				return true;
385
+			} else {
386
+				$compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true);
387
+			}
388
+		} elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
389
+			return true;
390
+		} else {
391
+			$compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true);
392
+		}
393
+
394
+		return false; // should not, but who knows what happens to the compiler in the future?
395
+	}
396
+
397
+	/**
398
+	 * Check if special $smarty variable is trusted.
399
+	 *
400
+	 * @param  string $var_name
401
+	 * @param  object $compiler compiler object
402
+	 *
403
+	 * @return boolean                 true if tag is trusted
404
+	 * @throws SmartyCompilerException if modifier is not trusted
405
+	 */
406
+	public function isTrustedSpecialSmartyVar($var_name, $compiler)
407
+	{
408
+		if (!in_array($var_name, $this->disabled_special_smarty_vars)) {
409
+			return true;
410
+		} else {
411
+			$compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting",
412
+											  null, true);
413
+		}
414
+
415
+		return false; // should not, but who knows what happens to the compiler in the future?
416
+	}
417
+
418
+	/**
419
+	 * Check if modifier plugin is trusted.
420
+	 *
421
+	 * @param  string $modifier_name
422
+	 * @param  object $compiler compiler object
423
+	 *
424
+	 * @return boolean                 true if tag is trusted
425
+	 * @throws SmartyCompilerException if modifier is not trusted
426
+	 */
427
+	public function isTrustedModifier($modifier_name, $compiler)
428
+	{
429
+		// check for internal always allowed modifier
430
+		if (in_array($modifier_name, array('default'))) {
431
+			return true;
432
+		}
433
+		// check security settings
434
+		if (empty($this->allowed_modifiers)) {
435
+			if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
436
+				return true;
437
+			} else {
438
+				$compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null,
439
+												  true);
440
+			}
441
+		} elseif (in_array($modifier_name, $this->allowed_modifiers) &&
442
+				  !in_array($modifier_name, $this->disabled_modifiers)
443
+		) {
444
+			return true;
445
+		} else {
446
+			$compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null,
447
+											  true);
448
+		}
449
+
450
+		return false; // should not, but who knows what happens to the compiler in the future?
451
+	}
452
+
453
+	/**
454
+	 * Check if constants are enabled or trusted
455
+	 *
456
+	 * @param  string $const    constant name
457
+	 * @param  object $compiler compiler object
458
+	 *
459
+	 * @return bool
460
+	 */
461
+	public function isTrustedConstant($const, $compiler)
462
+	{
463
+		if (in_array($const, array('true', 'false', 'null'))) {
464
+			return true;
465
+		}
466
+		if (!empty($this->trusted_constants)) {
467
+			if (!in_array($const, $this->trusted_constants)) {
468
+				$compiler->trigger_template_error("Security: access to constant '{$const}' not permitted");
469
+				return false;
470
+			}
471
+			return true;
472
+		}
473
+		if ($this->allow_constants) {
474
+			return true;
475
+		}
476
+		$compiler->trigger_template_error("Security: access to constants not permitted");
477
+		return false;
478
+	}
479
+
480
+	/**
481
+	 * Check if stream is trusted.
482
+	 *
483
+	 * @param  string $stream_name
484
+	 *
485
+	 * @return boolean         true if stream is trusted
486
+	 * @throws SmartyException if stream is not trusted
487
+	 */
488
+	public function isTrustedStream($stream_name)
489
+	{
490
+		if (isset($this->streams) && (empty($this->streams) || in_array($stream_name, $this->streams))) {
491
+			return true;
492
+		}
493
+
494
+		throw new SmartyException("stream '{$stream_name}' not allowed by security setting");
495
+	}
496
+
497
+	/**
498
+	 * Check if directory of file resource is trusted.
499
+	 *
500
+	 * @param  string   $filepath
501
+	 * @param null|bool $isConfig
502
+	 *
503
+	 * @return bool true if directory is trusted
504
+	 * @throws \SmartyException if directory is not trusted
505
+	 */
506
+	public function isTrustedResourceDir($filepath, $isConfig = null)
507
+	{
508
+		if ($this->_include_path_status !== $this->smarty->use_include_path) {
509
+			foreach ($this->_include_dir as $directory) {
510
+				unset($this->_resource_dir[ $directory ]);
511
+			}
512
+			if ($this->smarty->use_include_path) {
513
+				$this->_include_dir = array();
514
+				$_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty);
515
+				foreach ($_dirs as $directory) {
516
+					$this->_include_dir[] = $directory;
517
+					$this->_resource_dir[ $directory ] = true;
518
+				}
519
+			}
520
+			$this->_include_path_status = $this->smarty->use_include_path;
521
+		}
522
+		if ($isConfig !== true &&
523
+			(!isset($this->smarty->_cache[ 'template_dir_new' ]) || $this->smarty->_cache[ 'template_dir_new' ])
524
+		) {
525
+			$_dir = $this->smarty->getTemplateDir();
526
+			if ($this->_template_dir !== $_dir) {
527
+				foreach ($this->_template_dir as $directory) {
528
+					unset($this->_resource_dir[ $directory ]);
529
+				}
530
+				foreach ($_dir as $directory) {
531
+					$this->_resource_dir[ $directory ] = true;
532
+				}
533
+				$this->_template_dir = $_dir;
534
+			}
535
+			$this->smarty->_cache[ 'template_dir_new' ] = false;
536
+		}
537
+		if ($isConfig !== false &&
538
+			(!isset($this->smarty->_cache[ 'config_dir_new' ]) || $this->smarty->_cache[ 'config_dir_new' ])
539
+		) {
540
+			$_dir = $this->smarty->getConfigDir();
541
+			if ($this->_config_dir !== $_dir) {
542
+				foreach ($this->_config_dir as $directory) {
543
+					unset($this->_resource_dir[ $directory ]);
544
+				}
545
+				foreach ($_dir as $directory) {
546
+					$this->_resource_dir[ $directory ] = true;
547
+				}
548
+				$this->_config_dir = $_dir;
549
+			}
550
+			$this->smarty->_cache[ 'config_dir_new' ] = false;
551
+		}
552
+		if ($this->_secure_dir !== (array) $this->secure_dir) {
553
+			foreach ($this->_secure_dir as $directory) {
554
+				unset($this->_resource_dir[ $directory ]);
555
+			}
556
+			foreach ((array) $this->secure_dir as $directory) {
557
+				$directory = $this->smarty->_realpath($directory . DS, true);
558
+				$this->_resource_dir[ $directory ] = true;
559
+			}
560
+			$this->_secure_dir = (array) $this->secure_dir;
561
+		}
562
+		$this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir);
563
+		return true;
564
+	}
565
+
566
+	/**
567
+	 * Check if URI (e.g. {fetch} or {html_image}) is trusted
568
+	 * To simplify things, isTrustedUri() resolves all input to "{$PROTOCOL}://{$HOSTNAME}".
569
+	 * So "http://username:[email protected]:8080/some-path?some=query-string"
570
+	 * is reduced to "http://hello.world.example.org" prior to applying the patters from {@link $trusted_uri}.
571
+	 *
572
+	 * @param  string $uri
573
+	 *
574
+	 * @return boolean         true if URI is trusted
575
+	 * @throws SmartyException if URI is not trusted
576
+	 * @uses $trusted_uri for list of patterns to match against $uri
577
+	 */
578
+	public function isTrustedUri($uri)
579
+	{
580
+		$_uri = parse_url($uri);
581
+		if (!empty($_uri[ 'scheme' ]) && !empty($_uri[ 'host' ])) {
582
+			$_uri = $_uri[ 'scheme' ] . '://' . $_uri[ 'host' ];
583
+			foreach ($this->trusted_uri as $pattern) {
584
+				if (preg_match($pattern, $_uri)) {
585
+					return true;
586
+				}
587
+			}
588
+		}
589
+
590
+		throw new SmartyException("URI '{$uri}' not allowed by security setting");
591
+	}
592
+
593
+	/**
594
+	 * Check if directory of file resource is trusted.
595
+	 *
596
+	 * @param  string $filepath
597
+	 *
598
+	 * @return boolean         true if directory is trusted
599
+	 * @throws SmartyException if PHP directory is not trusted
600
+	 */
601
+	public function isTrustedPHPDir($filepath)
602
+	{
603
+		if (empty($this->trusted_dir)) {
604
+			throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
605
+		}
606
+
607
+		// check if index is outdated
608
+		if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) {
609
+			$this->_php_resource_dir = array();
610
+
611
+			$this->_trusted_dir = $this->trusted_dir;
612
+			foreach ((array) $this->trusted_dir as $directory) {
613
+				$directory = $this->smarty->_realpath($directory . DS, true);
614
+				$this->_php_resource_dir[ $directory ] = true;
615
+			}
616
+		}
617
+
618
+		$this->_php_resource_dir =
619
+			$this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir);
620
+		return true;
621
+	}
622 622
     
623
-    /**
624
-     * Check if file is inside a valid directory
625
-     *
626
-     * @param string $filepath
627
-     * @param array  $dirs valid directories
628
-     *
629
-     * @return array
630
-     * @throws \SmartyException
631
-     */
632
-    private function _checkDir($filepath, $dirs)
633
-    {
634
-        $directory = dirname($filepath) . DS;
635
-        $_directory = array();
636
-        while (true) {
637
-            // remember the directory to add it to _resource_dir in case we're successful
638
-            $_directory[ $directory ] = true;
639
-            // test if the directory is trusted
640
-            if (isset($dirs[ $directory ])) {
641
-                // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
642
-                $dirs = array_merge($dirs, $_directory);
643
-
644
-                return $dirs;
645
-            }
646
-            // abort if we've reached root
647
-            if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) {
648
-                break;
649
-            }
650
-            // bubble up one level
651
-            $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory);
652
-        }
653
-
654
-        // give up
655
-        throw new SmartyException("directory '{$filepath}' not allowed by security setting");
656
-    }
657
-
658
-    /**
659
-     * Loads security class and enables security
660
-     *
661
-     * @param \Smarty                 $smarty
662
-     * @param  string|Smarty_Security $security_class if a string is used, it must be class-name
663
-     *
664
-     * @return \Smarty current Smarty instance for chaining
665
-     * @throws \SmartyException when an invalid class name is provided
666
-     */
667
-    public static function enableSecurity(Smarty $smarty, $security_class)
668
-    {
669
-        if ($security_class instanceof Smarty_Security) {
670
-            $smarty->security_policy = $security_class;
671
-            return;
672
-        } elseif (is_object($security_class)) {
673
-            throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
674
-        }
675
-        if ($security_class === null) {
676
-            $security_class = $smarty->security_class;
677
-        }
678
-        if (!class_exists($security_class)) {
679
-            throw new SmartyException("Security class '$security_class' is not defined");
680
-        } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
681
-            throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
682
-        } else {
683
-            $smarty->security_policy = new $security_class($smarty);
684
-        }
685
-        return;
686
-    }
687
-    /**
688
-     * Start template processing
689
-     *
690
-     * @param $template
691
-     *
692
-     * @throws SmartyException
693
-     */
694
-    public function startTemplate($template)
695
-    {
696
-        if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) {
697
-            throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'");
698
-        }
699
-    }
700
-
701
-    /**
702
-     * Exit template processing
703
-     *
704
-     */
705
-    public function endTemplate()
706
-    {
707
-        if ($this->max_template_nesting > 0) {
708
-            $this->_current_template_nesting --;
709
-        }
710
-    }
711
-
712
-    /**
713
-     * Register callback functions call at start/end of template rendering
714
-     *
715
-     * @param \Smarty_Internal_Template $template
716
-     */
717
-    public function registerCallBacks(Smarty_Internal_Template $template)
718
-    {
719
-        $template->startRenderCallbacks[] = array($this, 'startTemplate');
720
-        $template->endRenderCallbacks[] = array($this, 'endTemplate');
721
-    }
623
+	/**
624
+	 * Check if file is inside a valid directory
625
+	 *
626
+	 * @param string $filepath
627
+	 * @param array  $dirs valid directories
628
+	 *
629
+	 * @return array
630
+	 * @throws \SmartyException
631
+	 */
632
+	private function _checkDir($filepath, $dirs)
633
+	{
634
+		$directory = dirname($filepath) . DS;
635
+		$_directory = array();
636
+		while (true) {
637
+			// remember the directory to add it to _resource_dir in case we're successful
638
+			$_directory[ $directory ] = true;
639
+			// test if the directory is trusted
640
+			if (isset($dirs[ $directory ])) {
641
+				// merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
642
+				$dirs = array_merge($dirs, $_directory);
643
+
644
+				return $dirs;
645
+			}
646
+			// abort if we've reached root
647
+			if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) {
648
+				break;
649
+			}
650
+			// bubble up one level
651
+			$directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory);
652
+		}
653
+
654
+		// give up
655
+		throw new SmartyException("directory '{$filepath}' not allowed by security setting");
656
+	}
657
+
658
+	/**
659
+	 * Loads security class and enables security
660
+	 *
661
+	 * @param \Smarty                 $smarty
662
+	 * @param  string|Smarty_Security $security_class if a string is used, it must be class-name
663
+	 *
664
+	 * @return \Smarty current Smarty instance for chaining
665
+	 * @throws \SmartyException when an invalid class name is provided
666
+	 */
667
+	public static function enableSecurity(Smarty $smarty, $security_class)
668
+	{
669
+		if ($security_class instanceof Smarty_Security) {
670
+			$smarty->security_policy = $security_class;
671
+			return;
672
+		} elseif (is_object($security_class)) {
673
+			throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
674
+		}
675
+		if ($security_class === null) {
676
+			$security_class = $smarty->security_class;
677
+		}
678
+		if (!class_exists($security_class)) {
679
+			throw new SmartyException("Security class '$security_class' is not defined");
680
+		} elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
681
+			throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
682
+		} else {
683
+			$smarty->security_policy = new $security_class($smarty);
684
+		}
685
+		return;
686
+	}
687
+	/**
688
+	 * Start template processing
689
+	 *
690
+	 * @param $template
691
+	 *
692
+	 * @throws SmartyException
693
+	 */
694
+	public function startTemplate($template)
695
+	{
696
+		if ($this->max_template_nesting > 0 && $this->_current_template_nesting ++ >= $this->max_template_nesting) {
697
+			throw new SmartyException("maximum template nesting level of '{$this->max_template_nesting}' exceeded when calling '{$template->template_resource}'");
698
+		}
699
+	}
700
+
701
+	/**
702
+	 * Exit template processing
703
+	 *
704
+	 */
705
+	public function endTemplate()
706
+	{
707
+		if ($this->max_template_nesting > 0) {
708
+			$this->_current_template_nesting --;
709
+		}
710
+	}
711
+
712
+	/**
713
+	 * Register callback functions call at start/end of template rendering
714
+	 *
715
+	 * @param \Smarty_Internal_Template $template
716
+	 */
717
+	public function registerCallBacks(Smarty_Internal_Template $template)
718
+	{
719
+		$template->startRenderCallbacks[] = array($this, 'startTemplate');
720
+		$template->endRenderCallbacks[] = array($this, 'endTemplate');
721
+	}
722 722
 }
Please login to merge, or discard this patch.
libraries/log4php.debug/LoggerAppenderSkeleton.php 2 patches
Indentation   +268 added lines, -268 removed lines patch added patch discarded remove patch
@@ -41,315 +41,315 @@
 block discarded – undo
41 41
  */
42 42
 class LoggerAppenderSkeleton extends LoggerAppender {
43 43
 
44
-    /**
45
-     * @var boolean closed appender flag
46
-     */
47
-    public $closed;
44
+	/**
45
+	 * @var boolean closed appender flag
46
+	 */
47
+	public $closed;
48 48
     
49
-    /**
50
-     * @var object unused
51
-     */
52
-    public $errorHandler;
49
+	/**
50
+	 * @var object unused
51
+	 */
52
+	public $errorHandler;
53 53
            
54
-    /**
55
-     * The first filter in the filter chain
56
-     * @var LoggerFilter
57
-     */
58
-    public $headFilter = null;
54
+	/**
55
+	 * The first filter in the filter chain
56
+	 * @var LoggerFilter
57
+	 */
58
+	public $headFilter = null;
59 59
             
60
-    /**
61
-     * LoggerLayout for this appender. It can be null if appender has its own layout
62
-     * @var LoggerLayout
63
-     */
64
-    public $layout = null; 
60
+	/**
61
+	 * LoggerLayout for this appender. It can be null if appender has its own layout
62
+	 * @var LoggerLayout
63
+	 */
64
+	public $layout = null; 
65 65
            
66
-    /**
67
-     * @var string Appender name
68
-     */
69
-    public $name;
66
+	/**
67
+	 * @var string Appender name
68
+	 */
69
+	public $name;
70 70
            
71
-    /**
72
-     * The last filter in the filter chain
73
-     * @var LoggerFilter
74
-     */
75
-    public $tailFilter = null; 
71
+	/**
72
+	 * The last filter in the filter chain
73
+	 * @var LoggerFilter
74
+	 */
75
+	public $tailFilter = null; 
76 76
            
77
-    /**
78
-     * @var LoggerLevel There is no level threshold filtering by default.
79
-     */
80
-    public $threshold = null;
77
+	/**
78
+	 * @var LoggerLevel There is no level threshold filtering by default.
79
+	 */
80
+	public $threshold = null;
81 81
     
82
-    /**
83
-     * @var boolean needs a layout formatting ?
84
-     */
85
-    public $requiresLayout = false;
82
+	/**
83
+	 * @var boolean needs a layout formatting ?
84
+	 */
85
+	public $requiresLayout = false;
86 86
     
87 87
 /* --------------------------------------------------------------------------*/
88 88
 /* --------------------------------------------------------------------------*/
89 89
 /* --------------------------------------------------------------------------*/
90 90
     
91
-    /**
92
-     * Constructor
93
-     *
94
-     * @param string $name appender name
95
-     */
96
-    public function LoggerAppenderSkeleton($name)
97
-    {
98
-        $this->name = $name;
99
-        $this->clearFilters();
100
-    }
91
+	/**
92
+	 * Constructor
93
+	 *
94
+	 * @param string $name appender name
95
+	 */
96
+	public function LoggerAppenderSkeleton($name)
97
+	{
98
+		$this->name = $name;
99
+		$this->clearFilters();
100
+	}
101 101
 
102
-    /**
103
-     * @param LoggerFilter $newFilter add a new LoggerFilter
104
-     * @see LoggerAppender::addFilter()
105
-     */
106
-    public function addFilter($newFilter)
107
-    {
108
-        if($this->headFilter === null) {
109
-            $this->headFilter = $newFilter;
110
-            $this->tailFilter =& $this->headFilter;
111
-        } else {
112
-            $this->tailFilter->next = $newFilter;
113
-            $this->tailFilter =& $this->tailFilter->next;
114
-        }
115
-    }
102
+	/**
103
+	 * @param LoggerFilter $newFilter add a new LoggerFilter
104
+	 * @see LoggerAppender::addFilter()
105
+	 */
106
+	public function addFilter($newFilter)
107
+	{
108
+		if($this->headFilter === null) {
109
+			$this->headFilter = $newFilter;
110
+			$this->tailFilter =& $this->headFilter;
111
+		} else {
112
+			$this->tailFilter->next = $newFilter;
113
+			$this->tailFilter =& $this->tailFilter->next;
114
+		}
115
+	}
116 116
     
117
-    /**
118
-     * Derived appenders should override this method if option structure
119
-     * requires it.
120
-     */
121
-    public function activateOptions() 
122
-    { 
117
+	/**
118
+	 * Derived appenders should override this method if option structure
119
+	 * requires it.
120
+	 */
121
+	public function activateOptions() 
122
+	{ 
123 123
 
124
-    }
124
+	}
125 125
     
126
-    /**
127
-     * Subclasses of {@link LoggerAppenderSkeleton} should implement 
128
-     * this method to perform actual logging.
129
-     *
130
-     * @param LoggerLoggingEvent $event
131
-     * @see doAppend()
132
-     * @abstract
133
-     */
134
-    public function append($event)
135
-    { 
136
-        // override me
137
-    }
126
+	/**
127
+	 * Subclasses of {@link LoggerAppenderSkeleton} should implement 
128
+	 * this method to perform actual logging.
129
+	 *
130
+	 * @param LoggerLoggingEvent $event
131
+	 * @see doAppend()
132
+	 * @abstract
133
+	 */
134
+	public function append($event)
135
+	{ 
136
+		// override me
137
+	}
138 138
  
139
-    /**
140
-     * @see LoggerAppender::clearFilters()
141
-     */
142
-    public function clearFilters()
143
-    {
144
-        unset($this->headFilter);
145
-        unset($this->tailFilter);
146
-        $this->headFilter = null;
147
-        $this->tailFilter = null;
148
-    }
139
+	/**
140
+	 * @see LoggerAppender::clearFilters()
141
+	 */
142
+	public function clearFilters()
143
+	{
144
+		unset($this->headFilter);
145
+		unset($this->tailFilter);
146
+		$this->headFilter = null;
147
+		$this->tailFilter = null;
148
+	}
149 149
            
150
-    /**
151
-     * @see LoggerAppender::close()
152
-     */
153
-    public function close()
154
-    {
155
-        //override me
156
-    }
150
+	/**
151
+	 * @see LoggerAppender::close()
152
+	 */
153
+	public function close()
154
+	{
155
+		//override me
156
+	}
157 157
             
158
-    /**
159
-     * Finalize this appender by calling the derived class' <i>close()</i> method.
160
-     */
161
-    public function finalize() 
162
-    {
163
-        // An appender might be closed then garbage collected. There is no
164
-        // point in closing twice.
165
-        if ($this->closed) return;
158
+	/**
159
+	 * Finalize this appender by calling the derived class' <i>close()</i> method.
160
+	 */
161
+	public function finalize() 
162
+	{
163
+		// An appender might be closed then garbage collected. There is no
164
+		// point in closing twice.
165
+		if ($this->closed) return;
166 166
         
167
-        LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}].");
167
+		LoggerLog::debug("LoggerAppenderSkeleton::finalize():name=[{$this->name}].");
168 168
         
169
-        $this->close();
170
-    }
169
+		$this->close();
170
+	}
171 171
     
172
-    /**
173
-     * Do not use this method.
174
-     * @see LoggerAppender::getErrorHandler()
175
-     * @return object
176
-     */
177
-    public function &getErrorHandler()
178
-    {
179
-        return $this->errorHandler;
180
-    } 
172
+	/**
173
+	 * Do not use this method.
174
+	 * @see LoggerAppender::getErrorHandler()
175
+	 * @return object
176
+	 */
177
+	public function &getErrorHandler()
178
+	{
179
+		return $this->errorHandler;
180
+	} 
181 181
            
182
-    /**
183
-     * @see LoggerAppender::getFilter()
184
-     * @return Filter
185
-     */
186
-    public function &getFilter()
187
-    {
188
-        return $this->headFilter;
189
-    } 
182
+	/**
183
+	 * @see LoggerAppender::getFilter()
184
+	 * @return Filter
185
+	 */
186
+	public function &getFilter()
187
+	{
188
+		return $this->headFilter;
189
+	} 
190 190
 
191
-    /** 
192
-     * Return the first filter in the filter chain for this Appender. 
193
-     * The return value may be <i>null</i> if no is filter is set.
194
-     * @return Filter
195
-     */
196
-    public function &getFirstFilter()
197
-    {
198
-        return $this->headFilter;
199
-    }
191
+	/** 
192
+	 * Return the first filter in the filter chain for this Appender. 
193
+	 * The return value may be <i>null</i> if no is filter is set.
194
+	 * @return Filter
195
+	 */
196
+	public function &getFirstFilter()
197
+	{
198
+		return $this->headFilter;
199
+	}
200 200
             
201
-    /**
202
-     * @see LoggerAppender::getLayout()
203
-     * @return LoggerLayout
204
-     */
205
-    public function &getLayout()
206
-    {
207
-        return $this->layout;
208
-    }
201
+	/**
202
+	 * @see LoggerAppender::getLayout()
203
+	 * @return LoggerLayout
204
+	 */
205
+	public function &getLayout()
206
+	{
207
+		return $this->layout;
208
+	}
209 209
            
210
-    /**
211
-     * @see LoggerAppender::getName()
212
-     * @return string
213
-     */
214
-    public function getName()
215
-    {
216
-        return $this->name;
217
-    }
210
+	/**
211
+	 * @see LoggerAppender::getName()
212
+	 * @return string
213
+	 */
214
+	public function getName()
215
+	{
216
+		return $this->name;
217
+	}
218 218
     
219
-    /**
220
-     * Returns this appenders threshold level. 
221
-     * See the {@link setThreshold()} method for the meaning of this option.
222
-     * @return LoggerLevel
223
-     */
224
-    public function &getThreshold()
225
-    { 
226
-        return $this->threshold;
227
-    }
219
+	/**
220
+	 * Returns this appenders threshold level. 
221
+	 * See the {@link setThreshold()} method for the meaning of this option.
222
+	 * @return LoggerLevel
223
+	 */
224
+	public function &getThreshold()
225
+	{ 
226
+		return $this->threshold;
227
+	}
228 228
     
229
-    /**
230
-     * Check whether the message level is below the appender's threshold. 
231
-     *
232
-     *
233
-     * If there is no threshold set, then the return value is always <i>true</i>.
234
-     * @param LoggerLevel $priority
235
-     * @return boolean true if priority is greater or equal than threshold  
236
-     */
237
-    public function isAsSevereAsThreshold($priority)
238
-    {
239
-        if ($this->threshold === null)
240
-            return true;
229
+	/**
230
+	 * Check whether the message level is below the appender's threshold. 
231
+	 *
232
+	 *
233
+	 * If there is no threshold set, then the return value is always <i>true</i>.
234
+	 * @param LoggerLevel $priority
235
+	 * @return boolean true if priority is greater or equal than threshold  
236
+	 */
237
+	public function isAsSevereAsThreshold($priority)
238
+	{
239
+		if ($this->threshold === null)
240
+			return true;
241 241
             
242
-        return $priority->isGreaterOrEqual($this->getThreshold());
243
-    }
242
+		return $priority->isGreaterOrEqual($this->getThreshold());
243
+	}
244 244
     
245
-    /**
246
-     * @see LoggerAppender::doAppend()
247
-     * @param LoggerLoggingEvent $event
248
-     */
249
-    public function doAppend($event)
250
-    {
251
-        LoggerLog::debug("LoggerAppenderSkeleton::doAppend()"); 
245
+	/**
246
+	 * @see LoggerAppender::doAppend()
247
+	 * @param LoggerLoggingEvent $event
248
+	 */
249
+	public function doAppend($event)
250
+	{
251
+		LoggerLog::debug("LoggerAppenderSkeleton::doAppend()"); 
252 252
 
253
-        if ($this->closed) {
254
-            LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
255
-            return;
256
-        }
257
-        if(!$this->isAsSevereAsThreshold($event->getLevel())) {
258
-            LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
259
-            return;
260
-        }
253
+		if ($this->closed) {
254
+			LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
255
+			return;
256
+		}
257
+		if(!$this->isAsSevereAsThreshold($event->getLevel())) {
258
+			LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
259
+			return;
260
+		}
261 261
 
262
-        $f = $this->getFirstFilter();
262
+		$f = $this->getFirstFilter();
263 263
     
264
-        while($f !== null) {
265
-            switch ($f->decide($event)) {
266
-                case LOG4PHP_LOGGER_FILTER_DENY: return;
267
-                case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event);
268
-                case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next;
269
-            }
270
-        }
271
-        $this->append($event);    
272
-    }    
264
+		while($f !== null) {
265
+			switch ($f->decide($event)) {
266
+				case LOG4PHP_LOGGER_FILTER_DENY: return;
267
+				case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event);
268
+				case LOG4PHP_LOGGER_FILTER_NEUTRAL: $f = $f->next;
269
+			}
270
+		}
271
+		$this->append($event);    
272
+	}    
273 273
         
274 274
             
275
-    /**
276
-     * @see LoggerAppender::requiresLayout()
277
-     * @return boolean
278
-     */
279
-    public function requiresLayout()
280
-    {
281
-        return $this->requiresLayout;
282
-    }
275
+	/**
276
+	 * @see LoggerAppender::requiresLayout()
277
+	 * @return boolean
278
+	 */
279
+	public function requiresLayout()
280
+	{
281
+		return $this->requiresLayout;
282
+	}
283 283
             
284
-    /**
285
-     * @see LoggerAppender::setErrorHandler()
286
-     * @param object
287
-     */
288
-    public function setErrorHandler($errorHandler)
289
-    {
290
-        if($errorHandler === null) {
291
-          // We do not throw exception here since the cause is probably a
292
-          // bad config file.
293
-            LoggerLog::warn("You have tried to set a null error-handler.");
294
-        } else {
295
-            $this->errorHandler = $errorHandler;
296
-        }
297
-    } 
284
+	/**
285
+	 * @see LoggerAppender::setErrorHandler()
286
+	 * @param object
287
+	 */
288
+	public function setErrorHandler($errorHandler)
289
+	{
290
+		if($errorHandler === null) {
291
+		  // We do not throw exception here since the cause is probably a
292
+		  // bad config file.
293
+			LoggerLog::warn("You have tried to set a null error-handler.");
294
+		} else {
295
+			$this->errorHandler = $errorHandler;
296
+		}
297
+	} 
298 298
            
299
-    /**
300
-     * @see LoggerAppender::setLayout()
301
-     * @param LoggerLayout $layout
302
-     */
303
-    public function setLayout($layout)
304
-    {
305
-        if ($this->requiresLayout())
306
-            $this->layout = $layout;
307
-    } 
299
+	/**
300
+	 * @see LoggerAppender::setLayout()
301
+	 * @param LoggerLayout $layout
302
+	 */
303
+	public function setLayout($layout)
304
+	{
305
+		if ($this->requiresLayout())
306
+			$this->layout = $layout;
307
+	} 
308 308
  
309
-    /**
310
-     * @see LoggerAppender::setName()
311
-     * @param string $name
312
-     */
313
-    public function setName($name) 
314
-    {
315
-        $this->name = $name;    
316
-    }
309
+	/**
310
+	 * @see LoggerAppender::setName()
311
+	 * @param string $name
312
+	 */
313
+	public function setName($name) 
314
+	{
315
+		$this->name = $name;    
316
+	}
317 317
     
318
-    /**
319
-     * Set the threshold level of this appender.
320
-     *
321
-     * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
322
-     * @see LoggerOptionConverter::toLevel()
323
-     */
324
-    public function setThreshold($threshold)
325
-    {
326
-        if (is_string($threshold)) {
327
-           $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
328
-        }elseif (is_a($threshold, 'loggerlevel')) {
329
-           $this->threshold = $threshold;
330
-        }
331
-    }
318
+	/**
319
+	 * Set the threshold level of this appender.
320
+	 *
321
+	 * @param mixed $threshold can be a {@link LoggerLevel} object or a string.
322
+	 * @see LoggerOptionConverter::toLevel()
323
+	 */
324
+	public function setThreshold($threshold)
325
+	{
326
+		if (is_string($threshold)) {
327
+		   $this->threshold = LoggerOptionConverter::toLevel($threshold, null);
328
+		}elseif (is_a($threshold, 'loggerlevel')) {
329
+		   $this->threshold = $threshold;
330
+		}
331
+	}
332 332
     
333
-    /**
334
-     * Perform actions before object serialization.
335
-     *
336
-     * Call {@link finalize()} to properly close the appender.
337
-     */
338
-    public function __sleep()
339
-    {
340
-        $this->finalize();
341
-        return array_keys(get_object_vars($this)); 
342
-    }
333
+	/**
334
+	 * Perform actions before object serialization.
335
+	 *
336
+	 * Call {@link finalize()} to properly close the appender.
337
+	 */
338
+	public function __sleep()
339
+	{
340
+		$this->finalize();
341
+		return array_keys(get_object_vars($this)); 
342
+	}
343 343
     
344
-    /**
345
-     * Perform actions after object deserialization.
346
-     *
347
-     * Call {@link activateOptions()} to properly setup the appender.
348
-     */
349
-    public function __wakeup()
350
-    {
351
-        $this->activateOptions();
352
-    }
344
+	/**
345
+	 * Perform actions after object deserialization.
346
+	 *
347
+	 * Call {@link activateOptions()} to properly setup the appender.
348
+	 */
349
+	public function __wakeup()
350
+	{
351
+		$this->activateOptions();
352
+	}
353 353
     
354 354
 }
355 355
 ?>
356 356
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -105,12 +105,12 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function addFilter($newFilter)
107 107
     {
108
-        if($this->headFilter === null) {
108
+        if ($this->headFilter === null) {
109 109
             $this->headFilter = $newFilter;
110
-            $this->tailFilter =& $this->headFilter;
110
+            $this->tailFilter = & $this->headFilter;
111 111
         } else {
112 112
             $this->tailFilter->next = $newFilter;
113
-            $this->tailFilter =& $this->tailFilter->next;
113
+            $this->tailFilter = & $this->tailFilter->next;
114 114
         }
115 115
     }
116 116
     
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
             LoggerLog::debug("LoggerAppenderSkeleton::doAppend() Attempted to append to closed appender named [{$this->name}].");
255 255
             return;
256 256
         }
257
-        if(!$this->isAsSevereAsThreshold($event->getLevel())) {
257
+        if (!$this->isAsSevereAsThreshold($event->getLevel())) {
258 258
             LoggerLog::debug("LoggerAppenderSkeleton::doAppend() event level is less severe than threshold.");
259 259
             return;
260 260
         }
261 261
 
262 262
         $f = $this->getFirstFilter();
263 263
     
264
-        while($f !== null) {
264
+        while ($f !== null) {
265 265
             switch ($f->decide($event)) {
266 266
                 case LOG4PHP_LOGGER_FILTER_DENY: return;
267 267
                 case LOG4PHP_LOGGER_FILTER_ACCEPT: return $this->append($event);
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public function setErrorHandler($errorHandler)
289 289
     {
290
-        if($errorHandler === null) {
290
+        if ($errorHandler === null) {
291 291
           // We do not throw exception here since the cause is probably a
292 292
           // bad config file.
293 293
             LoggerLog::warn("You have tried to set a null error-handler.");
Please login to merge, or discard this patch.
libraries/log4php.debug/LoggerHierarchy.php 2 patches
Indentation   +289 added lines, -289 removed lines patch added patch discarded remove patch
@@ -52,196 +52,196 @@  discard block
 block discarded – undo
52 52
  */
53 53
 class LoggerHierarchy {
54 54
 
55
-    /**
56
-     * @var object currently unused
57
-     */
58
-    public $defaultFactory;
55
+	/**
56
+	 * @var object currently unused
57
+	 */
58
+	public $defaultFactory;
59 59
     
60
-    /**
61
-     * @var boolean activate internal logging
62
-     * @see LoggerLog
63
-     */
64
-    public $debug = false;
60
+	/**
61
+	 * @var boolean activate internal logging
62
+	 * @see LoggerLog
63
+	 */
64
+	public $debug = false;
65 65
 
66
-    /**
67
-     * @var array hierarchy tree. saves here all loggers
68
-     */
69
-    public $ht = array();
66
+	/**
67
+	 * @var array hierarchy tree. saves here all loggers
68
+	 */
69
+	public $ht = array();
70 70
     
71
-    /**
72
-     * @var LoggerRoot
73
-     */
74
-    public $root = null;
71
+	/**
72
+	 * @var LoggerRoot
73
+	 */
74
+	public $root = null;
75 75
     
76
-    /**
77
-     * @var LoggerRendererMap
78
-     */
79
-    public $rendererMap;
76
+	/**
77
+	 * @var LoggerRendererMap
78
+	 */
79
+	public $rendererMap;
80 80
 
81
-    /**
82
-     * @var LoggerLevel main level threshold
83
-     */
84
-    public $threshold;
81
+	/**
82
+	 * @var LoggerLevel main level threshold
83
+	 */
84
+	public $threshold;
85 85
     
86
-    /**
87
-     * @var boolean currently unused
88
-     */
89
-    public $emittedNoAppenderWarning       = false;
86
+	/**
87
+	 * @var boolean currently unused
88
+	 */
89
+	public $emittedNoAppenderWarning       = false;
90 90
 
91
-    /**
92
-     * @var boolean currently unused
93
-     */
94
-    public $emittedNoResourceBundleWarning = false;
91
+	/**
92
+	 * @var boolean currently unused
93
+	 */
94
+	public $emittedNoResourceBundleWarning = false;
95 95
     
96 96
     
97 97
 /* --------------------------------------------------------------------------*/
98 98
 /* --------------------------------------------------------------------------*/
99 99
 /* --------------------------------------------------------------------------*/
100 100
 
101
-    public function &singleton()
102
-    {
103
-        static $instance;
101
+	public function &singleton()
102
+	{
103
+		static $instance;
104 104
         
105
-        if (!isset($instance))
106
-            $instance = new LoggerHierarchy(new LoggerRoot());
107
-        return $instance;
108
-    }
105
+		if (!isset($instance))
106
+			$instance = new LoggerHierarchy(new LoggerRoot());
107
+		return $instance;
108
+	}
109 109
     
110
-    /**
111
-     * Create a new logger hierarchy.
112
-     * @param object $root the root logger
113
-     */
114
-    public function LoggerHierarchy($root)
115
-    {
116
-        $this->root    =& $root;
117
-        // Enable all level levels by default.
118
-        $this->setThreshold(LoggerLevel::getLevelAll());
119
-        $this->root->setHierarchy($this);
120
-        $this->rendererMap = new LoggerRendererMap();
121
-        $this->defaultFactory = new LoggerDefaultCategoryFactory();        
122
-    }
110
+	/**
111
+	 * Create a new logger hierarchy.
112
+	 * @param object $root the root logger
113
+	 */
114
+	public function LoggerHierarchy($root)
115
+	{
116
+		$this->root    =& $root;
117
+		// Enable all level levels by default.
118
+		$this->setThreshold(LoggerLevel::getLevelAll());
119
+		$this->root->setHierarchy($this);
120
+		$this->rendererMap = new LoggerRendererMap();
121
+		$this->defaultFactory = new LoggerDefaultCategoryFactory();        
122
+	}
123 123
      
124
-    /**
125
-     * Add a HierarchyEventListener event to the repository. 
126
-     * Not Yet Impl.
127
-     */
128
-    public function addHierarchyEventListener($listener)
129
-    {
130
-        return;
131
-    }
124
+	/**
125
+	 * Add a HierarchyEventListener event to the repository. 
126
+	 * Not Yet Impl.
127
+	 */
128
+	public function addHierarchyEventListener($listener)
129
+	{
130
+		return;
131
+	}
132 132
      
133
-    /**
134
-     * Add an object renderer for a specific class.
135
-     * Not Yet Impl.
136
-     */
137
-    public function addRenderer($classToRender, $or)
138
-    {
139
-        $this->rendererMap->put($classToRender, $or);
140
-    } 
133
+	/**
134
+	 * Add an object renderer for a specific class.
135
+	 * Not Yet Impl.
136
+	 */
137
+	public function addRenderer($classToRender, $or)
138
+	{
139
+		$this->rendererMap->put($classToRender, $or);
140
+	} 
141 141
     
142
-    /**
143
-     * This call will clear all logger definitions from the internal hashtable.
144
-     */
145
-    public function clear()
146
-    {
147
-        $this->ht = array();
148
-    }
142
+	/**
143
+	 * This call will clear all logger definitions from the internal hashtable.
144
+	 */
145
+	public function clear()
146
+	{
147
+		$this->ht = array();
148
+	}
149 149
       
150
-    public function emitNoAppenderWarning($cat)
151
-    {
152
-        return;
153
-    }
150
+	public function emitNoAppenderWarning($cat)
151
+	{
152
+		return;
153
+	}
154 154
     
155
-    /**
156
-     * Check if the named logger exists in the hierarchy.
157
-     * @param string $name
158
-     * @return boolean
159
-     */
160
-    public function exists($name)
161
-    {
162
-        return in_array($name, array_keys($this->ht));
163
-    }
155
+	/**
156
+	 * Check if the named logger exists in the hierarchy.
157
+	 * @param string $name
158
+	 * @return boolean
159
+	 */
160
+	public function exists($name)
161
+	{
162
+		return in_array($name, array_keys($this->ht));
163
+	}
164 164
 
165
-    public function fireAddAppenderEvent($logger, $appender)
166
-    {
167
-        return;
168
-    }
165
+	public function fireAddAppenderEvent($logger, $appender)
166
+	{
167
+		return;
168
+	}
169 169
     
170
-    /**
171
-     * @deprecated Please use {@link getCurrentLoggers()} instead.
172
-     */
173
-    public function &getCurrentCategories()
174
-    {
175
-        return $this->getCurrentLoggers();
176
-    }
170
+	/**
171
+	 * @deprecated Please use {@link getCurrentLoggers()} instead.
172
+	 */
173
+	public function &getCurrentCategories()
174
+	{
175
+		return $this->getCurrentLoggers();
176
+	}
177 177
     
178
-    /**
179
-     * Returns all the currently defined categories in this hierarchy as an array.
180
-     * @return array
181
-     */  
182
-    public function &getCurrentLoggers()
183
-    {
184
-        $loggers = array();
185
-        $loggerNames = array_keys($this->ht);
186
-        $enumLoggers = sizeof($loggerNames);
187
-        for ($i = 0; $i < $enumLoggers; $i++) {
188
-            $loggerName = $loggerNames[$i];
189
-            $loggers[] =& $this->ht[$loggerName];
190
-        }
191
-        return $loggers; 
192
-    }
178
+	/**
179
+	 * Returns all the currently defined categories in this hierarchy as an array.
180
+	 * @return array
181
+	 */  
182
+	public function &getCurrentLoggers()
183
+	{
184
+		$loggers = array();
185
+		$loggerNames = array_keys($this->ht);
186
+		$enumLoggers = sizeof($loggerNames);
187
+		for ($i = 0; $i < $enumLoggers; $i++) {
188
+			$loggerName = $loggerNames[$i];
189
+			$loggers[] =& $this->ht[$loggerName];
190
+		}
191
+		return $loggers; 
192
+	}
193 193
     
194
-    /**
195
-     * Return a new logger instance named as the first parameter using the default factory.
196
-     * 
197
-     * @param string $name logger name
198
-     * @param LoggerFactory $factory a {@link LoggerFactory} instance or null     
199
-     * @return Logger
200
-     */
201
-    public function &getLogger($name, $factory = null)
202
-    {
203
-        if ($factory === null) {
204
-            return $this->getLoggerByFactory($name, $this->defaultFactory);
205
-        } else {
206
-            return $this->getLoggerByFactory($name, $factory);
207
-        }
208
-    } 
194
+	/**
195
+	 * Return a new logger instance named as the first parameter using the default factory.
196
+	 * 
197
+	 * @param string $name logger name
198
+	 * @param LoggerFactory $factory a {@link LoggerFactory} instance or null     
199
+	 * @return Logger
200
+	 */
201
+	public function &getLogger($name, $factory = null)
202
+	{
203
+		if ($factory === null) {
204
+			return $this->getLoggerByFactory($name, $this->defaultFactory);
205
+		} else {
206
+			return $this->getLoggerByFactory($name, $factory);
207
+		}
208
+	} 
209 209
     
210
-    /**
211
-     * Return a new logger instance named as the first parameter using the default factory.
212
-     * 
213
-     * @param string $name logger name
214
-     * @return Logger
215
-     * @todo merge with {@link getLogger()}
216
-     */
217
-    public function &getLoggerByFactory($name, $factory)
218
-    {
219
-        if (!isset($this->ht[$name])) {
220
-            LoggerLog::debug("LoggerHierarchy::getLoggerByFactory():name=[$name]:factory=[".get_class($factory)."] creating a new logger...");
221
-            $this->ht[$name] = $factory->makeNewLoggerInstance($name);
222
-            $this->ht[$name]->setHierarchy($this);
223
-            $nodes = explode('.', $name);
224
-            $firstNode = array_shift($nodes);
225
-            if ( $firstNode != $name && isset($this->ht[$firstNode])) {
226
-                LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$firstNode]");            
227
-                $this->ht[$name]->parent =& $this->ht[$firstNode];
228
-            } else {
229
-                LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [root]");            
230
-                $this->ht[$name]->parent =& $this->root;
231
-            } 
232
-            if (sizeof($nodes) > 0) {
233
-                // find parent node
234
-                foreach ($nodes as $node) {
235
-                    $parentNode = "$firstNode.$node";
236
-                    if (isset($this->ht[$parentNode]) && $parentNode != $name) {
237
-                        LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$parentNode]");                    
238
-                        $this->ht[$name]->parent =& $this->ht[$parentNode];
239
-                    }
240
-                    $firstNode .= ".$node";
241
-                }
242
-            }
243
-            // update children
244
-            /*
210
+	/**
211
+	 * Return a new logger instance named as the first parameter using the default factory.
212
+	 * 
213
+	 * @param string $name logger name
214
+	 * @return Logger
215
+	 * @todo merge with {@link getLogger()}
216
+	 */
217
+	public function &getLoggerByFactory($name, $factory)
218
+	{
219
+		if (!isset($this->ht[$name])) {
220
+			LoggerLog::debug("LoggerHierarchy::getLoggerByFactory():name=[$name]:factory=[".get_class($factory)."] creating a new logger...");
221
+			$this->ht[$name] = $factory->makeNewLoggerInstance($name);
222
+			$this->ht[$name]->setHierarchy($this);
223
+			$nodes = explode('.', $name);
224
+			$firstNode = array_shift($nodes);
225
+			if ( $firstNode != $name && isset($this->ht[$firstNode])) {
226
+				LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$firstNode]");            
227
+				$this->ht[$name]->parent =& $this->ht[$firstNode];
228
+			} else {
229
+				LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [root]");            
230
+				$this->ht[$name]->parent =& $this->root;
231
+			} 
232
+			if (sizeof($nodes) > 0) {
233
+				// find parent node
234
+				foreach ($nodes as $node) {
235
+					$parentNode = "$firstNode.$node";
236
+					if (isset($this->ht[$parentNode]) && $parentNode != $name) {
237
+						LoggerLog::debug("LoggerHierarchy::getLogger($name) parent is now [$parentNode]");                    
238
+						$this->ht[$name]->parent =& $this->ht[$parentNode];
239
+					}
240
+					$firstNode .= ".$node";
241
+				}
242
+			}
243
+			// update children
244
+			/*
245 245
             $children = array();
246 246
             foreach (array_keys($this->ht) as $nodeName) {
247 247
                 if ($nodeName != $name && substr($nodeName, 0, strlen($name)) == $name) {
@@ -249,140 +249,140 @@  discard block
 block discarded – undo
249 249
                 }
250 250
             }
251 251
             */
252
-        }            
253
-        return $this->ht[$name];
254
-    }
252
+		}            
253
+		return $this->ht[$name];
254
+	}
255 255
     
256
-    /**
257
-     * @return LoggerRendererMap Get the renderer map for this hierarchy.
258
-     */
259
-    public function &getRendererMap()
260
-    {
261
-        return $this->rendererMap;
262
-    }
256
+	/**
257
+	 * @return LoggerRendererMap Get the renderer map for this hierarchy.
258
+	 */
259
+	public function &getRendererMap()
260
+	{
261
+		return $this->rendererMap;
262
+	}
263 263
     
264
-    /**
265
-     * @return LoggerRoot Get the root of this hierarchy.
266
-     */ 
267
-    public function &getRootLogger()
268
-    {
269
-        if (!isset($this->root) || $this->root === null)
270
-            $this->root = new LoggerRoot();
271
-        return $this->root;
272
-    }
264
+	/**
265
+	 * @return LoggerRoot Get the root of this hierarchy.
266
+	 */ 
267
+	public function &getRootLogger()
268
+	{
269
+		if (!isset($this->root) || $this->root === null)
270
+			$this->root = new LoggerRoot();
271
+		return $this->root;
272
+	}
273 273
      
274
-    /**
275
-     * @return LoggerLevel Returns the threshold Level.
276
-     */
277
-    public function getThreshold()
278
-    {
279
-        return $this->threshold;
280
-    } 
274
+	/**
275
+	 * @return LoggerLevel Returns the threshold Level.
276
+	 */
277
+	public function getThreshold()
278
+	{
279
+		return $this->threshold;
280
+	} 
281 281
 
282
-    /**
283
-     * This method will return true if this repository is disabled 
284
-     * for level object passed as parameter and false otherwise.
285
-     * @return boolean
286
-     */
287
-    public function isDisabled($level)
288
-    {
289
-        return ($this->threshold->level > $level->level);
290
-    }
282
+	/**
283
+	 * This method will return true if this repository is disabled 
284
+	 * for level object passed as parameter and false otherwise.
285
+	 * @return boolean
286
+	 */
287
+	public function isDisabled($level)
288
+	{
289
+		return ($this->threshold->level > $level->level);
290
+	}
291 291
     
292
-    /**
293
-     * @deprecated Deprecated with no replacement.
294
-     */
295
-    public function overrideAsNeeded($override)
296
-    {
297
-        return;
298
-    } 
292
+	/**
293
+	 * @deprecated Deprecated with no replacement.
294
+	 */
295
+	public function overrideAsNeeded($override)
296
+	{
297
+		return;
298
+	} 
299 299
     
300
-    /**
301
-     * Reset all values contained in this hierarchy instance to their
302
-     * default. 
303
-     *
304
-     * This removes all appenders from all categories, sets
305
-     * the level of all non-root categories to <i>null</i>,
306
-     * sets their additivity flag to <i>true</i> and sets the level
307
-     * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
308
-     * message disabling is set its default "off" value.
309
-     * 
310
-     * <p>Existing categories are not removed. They are just reset.
311
-     *
312
-     * <p>This method should be used sparingly and with care as it will
313
-     * block all logging until it is completed.</p>
314
-     */
315
-    public function resetConfiguration()
316
-    {
317
-        $root =& $this->getRootLogger();
300
+	/**
301
+	 * Reset all values contained in this hierarchy instance to their
302
+	 * default. 
303
+	 *
304
+	 * This removes all appenders from all categories, sets
305
+	 * the level of all non-root categories to <i>null</i>,
306
+	 * sets their additivity flag to <i>true</i> and sets the level
307
+	 * of the root logger to {@link LOGGER_LEVEL_DEBUG}.  Moreover,
308
+	 * message disabling is set its default "off" value.
309
+	 * 
310
+	 * <p>Existing categories are not removed. They are just reset.
311
+	 *
312
+	 * <p>This method should be used sparingly and with care as it will
313
+	 * block all logging until it is completed.</p>
314
+	 */
315
+	public function resetConfiguration()
316
+	{
317
+		$root =& $this->getRootLogger();
318 318
         
319
-        $root->setLevel(LoggerLevel::getLevelDebug());
320
-        $this->setThreshold(LoggerLevel::getLevelAll());
321
-        $this->shutDown();
322
-        $loggers =& $this->getCurrentLoggers();
323
-        $enumLoggers = sizeof($loggers);
324
-        for ($i = 0; $i < $enumLoggers; $i++) {
325
-            $loggers[$i]->setLevel(null);
326
-        	$loggers[$i]->setAdditivity(true);
327
-        	$loggers[$i]->setResourceBundle(null);
328
-        }
329
-        $this->rendererMap->clear();
330
-    }
319
+		$root->setLevel(LoggerLevel::getLevelDebug());
320
+		$this->setThreshold(LoggerLevel::getLevelAll());
321
+		$this->shutDown();
322
+		$loggers =& $this->getCurrentLoggers();
323
+		$enumLoggers = sizeof($loggers);
324
+		for ($i = 0; $i < $enumLoggers; $i++) {
325
+			$loggers[$i]->setLevel(null);
326
+			$loggers[$i]->setAdditivity(true);
327
+			$loggers[$i]->setResourceBundle(null);
328
+		}
329
+		$this->rendererMap->clear();
330
+	}
331 331
       
332
-    /**
333
-     * @deprecated Deprecated with no replacement.
334
-     */
335
-    public function setDisableOverride($override)
336
-    {
337
-        return;
338
-    }
332
+	/**
333
+	 * @deprecated Deprecated with no replacement.
334
+	 */
335
+	public function setDisableOverride($override)
336
+	{
337
+		return;
338
+	}
339 339
     
340
-    /**
341
-     * Used by subclasses to add a renderer to the hierarchy passed as parameter.
342
-     * @param string $renderedClass a LoggerRenderer class name
343
-     * @param LoggerRenderer $renderer
344
-     *
345
-     */
346
-    public function setRenderer($renderedClass, $renderer)
347
-    {
348
-        $this->rendererMap->put($renderedClass, $renderer);
349
-    }
340
+	/**
341
+	 * Used by subclasses to add a renderer to the hierarchy passed as parameter.
342
+	 * @param string $renderedClass a LoggerRenderer class name
343
+	 * @param LoggerRenderer $renderer
344
+	 *
345
+	 */
346
+	public function setRenderer($renderedClass, $renderer)
347
+	{
348
+		$this->rendererMap->put($renderedClass, $renderer);
349
+	}
350 350
     
351
-    /**
352
-     * set a new threshold level
353
-     *
354
-     * @param LoggerLevel $l
355
-     */
356
-    public function setThreshold($l)
357
-    {
358
-        if ($l !== null)
359
-            $this->threshold = $l;
360
-    }
351
+	/**
352
+	 * set a new threshold level
353
+	 *
354
+	 * @param LoggerLevel $l
355
+	 */
356
+	public function setThreshold($l)
357
+	{
358
+		if ($l !== null)
359
+			$this->threshold = $l;
360
+	}
361 361
     
362
-    /**
363
-     * Shutting down a hierarchy will <i>safely</i> close and remove
364
-     * all appenders in all categories including the root logger.
365
-     * 
366
-     * <p>Some appenders such as {@link LoggerSocketAppender}
367
-     * need to be closed before the
368
-     * application exists. Otherwise, pending logging events might be
369
-     * lost.
370
-     * 
371
-     * <p>The shutdown method is careful to close nested
372
-     * appenders before closing regular appenders. This is allows
373
-     * configurations where a regular appender is attached to a logger
374
-     * and again to a nested appender.
375
-     */
376
-    public function shutdown()
377
-    {
378
-        $this->root->removeAllAppenders();
379
-        $cats =& $this->getCurrentLoggers();
380
-        $enumCats = sizeof($cats);        
381
-        if ($enumCats > 0) {
382
-            for ($i = 0; $i < $enumCats; $i++) {
383
-                $cats[$i]->removeAllAppenders();
384
-            }
385
-        }
386
-    }  
362
+	/**
363
+	 * Shutting down a hierarchy will <i>safely</i> close and remove
364
+	 * all appenders in all categories including the root logger.
365
+	 * 
366
+	 * <p>Some appenders such as {@link LoggerSocketAppender}
367
+	 * need to be closed before the
368
+	 * application exists. Otherwise, pending logging events might be
369
+	 * lost.
370
+	 * 
371
+	 * <p>The shutdown method is careful to close nested
372
+	 * appenders before closing regular appenders. This is allows
373
+	 * configurations where a regular appender is attached to a logger
374
+	 * and again to a nested appender.
375
+	 */
376
+	public function shutdown()
377
+	{
378
+		$this->root->removeAllAppenders();
379
+		$cats =& $this->getCurrentLoggers();
380
+		$enumCats = sizeof($cats);        
381
+		if ($enumCats > 0) {
382
+			for ($i = 0; $i < $enumCats; $i++) {
383
+				$cats[$i]->removeAllAppenders();
384
+			}
385
+		}
386
+	}  
387 387
 } 
388 388
 ?>
389 389
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +12 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * @ignore 
21 21
  */
22
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__)); 
22
+if (!defined('LOG4PHP_DIR')) {
23
+	define('LOG4PHP_DIR', dirname(__FILE__));
24
+}
23 25
 
24 26
 /**
25 27
  */
@@ -102,8 +104,9 @@  discard block
 block discarded – undo
102 104
     {
103 105
         static $instance;
104 106
         
105
-        if (!isset($instance))
106
-            $instance = new LoggerHierarchy(new LoggerRoot());
107
+        if (!isset($instance)) {
108
+                    $instance = new LoggerHierarchy(new LoggerRoot());
109
+        }
107 110
         return $instance;
108 111
     }
109 112
     
@@ -266,8 +269,9 @@  discard block
 block discarded – undo
266 269
      */ 
267 270
     public function &getRootLogger()
268 271
     {
269
-        if (!isset($this->root) || $this->root === null)
270
-            $this->root = new LoggerRoot();
272
+        if (!isset($this->root) || $this->root === null) {
273
+                    $this->root = new LoggerRoot();
274
+        }
271 275
         return $this->root;
272 276
     }
273 277
      
@@ -355,8 +359,9 @@  discard block
 block discarded – undo
355 359
      */
356 360
     public function setThreshold($l)
357 361
     {
358
-        if ($l !== null)
359
-            $this->threshold = $l;
362
+        if ($l !== null) {
363
+                    $this->threshold = $l;
364
+        }
360 365
     }
361 366
     
362 367
     /**
Please login to merge, or discard this patch.
libraries/log4php.debug/helpers/LoggerPatternConverter.php 2 patches
Indentation   +347 added lines, -347 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
  * Used by {@link LoggerPatternConverter::spacePad()}.  
32 32
  */
33 33
 $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", "  ", "    ", "        ", //1,2,4,8 spaces
34
-			    "                ", // 16 spaces
35
-			    "                                " ); // 32 spaces
34
+				"                ", // 16 spaces
35
+				"                                " ); // 32 spaces
36 36
 
37 37
 /**
38 38
  * LoggerPatternConverter is an abstract class that provides the formatting 
@@ -51,101 +51,101 @@  discard block
 block discarded – undo
51 51
  */
52 52
 class LoggerPatternConverter {
53 53
 
54
-    /**
55
-     * @var LoggerPatternConverter next converter in converter chain
56
-     */
57
-    public $next = null;
54
+	/**
55
+	 * @var LoggerPatternConverter next converter in converter chain
56
+	 */
57
+	public $next = null;
58 58
     
59
-    public $min = -1;
60
-    public $max = 0x7FFFFFFF;
61
-    public $leftAlign = false;
62
-
63
-    /**
64
-     * Constructor 
65
-     *
66
-     * @param LoggerFormattingInfo $fi
67
-     */
68
-    public function LoggerPatternConverter($fi = null) 
69
-    {  
70
-        if ($fi !== null) {
71
-            $this->min = $fi->min;
72
-            $this->max = $fi->max;
73
-            $this->leftAlign = $fi->leftAlign;
74
-        }
75
-    }
59
+	public $min = -1;
60
+	public $max = 0x7FFFFFFF;
61
+	public $leftAlign = false;
62
+
63
+	/**
64
+	 * Constructor 
65
+	 *
66
+	 * @param LoggerFormattingInfo $fi
67
+	 */
68
+	public function LoggerPatternConverter($fi = null) 
69
+	{  
70
+		if ($fi !== null) {
71
+			$this->min = $fi->min;
72
+			$this->max = $fi->max;
73
+			$this->leftAlign = $fi->leftAlign;
74
+		}
75
+	}
76 76
   
77
-    /**
78
-     * Derived pattern converters must override this method in order to
79
-     * convert conversion specifiers in the correct way.
80
-     *
81
-     * @param LoggerLoggingEvent $event
82
-     */
83
-    public function convert($event) {}
84
-
85
-    /**
86
-     * A template method for formatting in a converter specific way.
87
-     *
88
-     * @param string &$sbuf string buffer
89
-     * @param LoggerLoggingEvent $e
90
-     */
91
-    public function format(&$sbuf, $e)
92
-    {
93
-        LoggerLog::debug("LoggerPatternConverter::format() sbuf='$sbuf'");    
77
+	/**
78
+	 * Derived pattern converters must override this method in order to
79
+	 * convert conversion specifiers in the correct way.
80
+	 *
81
+	 * @param LoggerLoggingEvent $event
82
+	 */
83
+	public function convert($event) {}
84
+
85
+	/**
86
+	 * A template method for formatting in a converter specific way.
87
+	 *
88
+	 * @param string &$sbuf string buffer
89
+	 * @param LoggerLoggingEvent $e
90
+	 */
91
+	public function format(&$sbuf, $e)
92
+	{
93
+		LoggerLog::debug("LoggerPatternConverter::format() sbuf='$sbuf'");    
94 94
     
95
-        $s = $this->convert($e);
95
+		$s = $this->convert($e);
96 96
         
97
-        LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'");    
97
+		LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'");    
98 98
         
99 99
     
100
-        if($s === null || empty($s)) {
101
-            if(0 < $this->min)
102
-                $this->spacePad($sbuf, $this->min);
103
-            return;
104
-        }
100
+		if($s === null || empty($s)) {
101
+			if(0 < $this->min)
102
+				$this->spacePad($sbuf, $this->min);
103
+			return;
104
+		}
105 105
         
106
-        $len = strlen($s);
106
+		$len = strlen($s);
107 107
     
108
-        if($len > $this->max) {
109
-            $sbuf .= substr($s , 0, ($len - $this->max));
110
-        } elseif($len < $this->min) {
111
-            if($this->leftAlign) {	
112
-                $sbuf .= $s;
113
-                $this->spacePad($sbuf, ($this->min - $len));
114
-            } else {
115
-                $this->spacePad($sbuf, ($this->min - $len));
116
-                $sbuf .= $s;
117
-            }
118
-        } else {
119
-            $sbuf .= $s;
120
-        }
121
-    }	
122
-
123
-
124
-    /**
125
-     * Fast space padding method.
126
-     *
127
-     * @param string    &$sbuf     string buffer
128
-     * @param integer   $length    pad length
129
-     *
130
-     * @todo reimplement using PHP string functions
131
-     */
132
-    public function spacePad(&$sbuf, $length)
133
-    {
134
-        LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'");        
108
+		if($len > $this->max) {
109
+			$sbuf .= substr($s , 0, ($len - $this->max));
110
+		} elseif($len < $this->min) {
111
+			if($this->leftAlign) {	
112
+				$sbuf .= $s;
113
+				$this->spacePad($sbuf, ($this->min - $len));
114
+			} else {
115
+				$this->spacePad($sbuf, ($this->min - $len));
116
+				$sbuf .= $s;
117
+			}
118
+		} else {
119
+			$sbuf .= $s;
120
+		}
121
+	}	
122
+
123
+
124
+	/**
125
+	 * Fast space padding method.
126
+	 *
127
+	 * @param string    &$sbuf     string buffer
128
+	 * @param integer   $length    pad length
129
+	 *
130
+	 * @todo reimplement using PHP string functions
131
+	 */
132
+	public function spacePad(&$sbuf, $length)
133
+	{
134
+		LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'");        
135 135
     
136
-        while($length >= 32) {
137
-          $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5];
138
-          $length -= 32;
139
-        }
136
+		while($length >= 32) {
137
+		  $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5];
138
+		  $length -= 32;
139
+		}
140 140
         
141
-        for($i = 4; $i >= 0; $i--) {	
142
-            if(($length & (1<<$i)) != 0) {
143
-    	        $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i];
144
-            }
145
-        }
146
-
147
-        // $sbuf = str_pad($sbuf, $length);
148
-    }
141
+		for($i = 4; $i >= 0; $i--) {	
142
+			if(($length & (1<<$i)) != 0) {
143
+				$sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i];
144
+			}
145
+		}
146
+
147
+		// $sbuf = str_pad($sbuf, $length);
148
+	}
149 149
 }
150 150
 
151 151
 // ---------------------------------------------------------------------
@@ -159,54 +159,54 @@  discard block
 block discarded – undo
159 159
  */
160 160
 class LoggerBasicPatternConverter extends LoggerPatternConverter {
161 161
 
162
-    /**
163
-     * @var integer
164
-     */
165
-    public $type;
166
-
167
-    /**
168
-     * Constructor
169
-     *
170
-     * @param string $formattingInfo
171
-     * @param integer $type
172
-     */
173
-    public function LoggerBasicPatternConverter($formattingInfo, $type)
174
-    {
175
-      LoggerLog::debug("LoggerBasicPatternConverter::LoggerBasicPatternConverter() type='$type'");    
162
+	/**
163
+	 * @var integer
164
+	 */
165
+	public $type;
166
+
167
+	/**
168
+	 * Constructor
169
+	 *
170
+	 * @param string $formattingInfo
171
+	 * @param integer $type
172
+	 */
173
+	public function LoggerBasicPatternConverter($formattingInfo, $type)
174
+	{
175
+	  LoggerLog::debug("LoggerBasicPatternConverter::LoggerBasicPatternConverter() type='$type'");    
176 176
     
177
-      $this->LoggerPatternConverter($formattingInfo);
178
-      $this->type = $type;
179
-    }
180
-
181
-    /**
182
-     * @param LoggerLoggingEvent $event
183
-     * @return string
184
-     */
185
-    public function convert($event)
186
-    {
187
-        switch($this->type) {
188
-            case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
189
-                $timeStamp = $event->getTimeStamp();
190
-                $startTime = LoggerLoggingEvent::getStartTime();
191
-	            return (string)(int)($timeStamp * 1000 - $startTime * 1000);
177
+	  $this->LoggerPatternConverter($formattingInfo);
178
+	  $this->type = $type;
179
+	}
180
+
181
+	/**
182
+	 * @param LoggerLoggingEvent $event
183
+	 * @return string
184
+	 */
185
+	public function convert($event)
186
+	{
187
+		switch($this->type) {
188
+			case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
189
+				$timeStamp = $event->getTimeStamp();
190
+				$startTime = LoggerLoggingEvent::getStartTime();
191
+				return (string)(int)($timeStamp * 1000 - $startTime * 1000);
192 192
                 
193
-            case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
194
-	            return $event->getThreadName();
193
+			case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
194
+				return $event->getThreadName();
195 195
 
196
-            case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER:
197
-                $level = $event->getLevel();
198
-	            return $level->toString();
196
+			case LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER:
197
+				$level = $event->getLevel();
198
+				return $level->toString();
199 199
 
200
-            case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER:
201
-	            return $event->getNDC();
200
+			case LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER:
201
+				return $event->getNDC();
202 202
 
203
-            case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER:
204
-	            return $event->getRenderedMessage();
203
+			case LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER:
204
+				return $event->getRenderedMessage();
205 205
                 
206
-            default: 
207
-                return '';
208
-        }
209
-    }
206
+			default: 
207
+				return '';
208
+		}
209
+	}
210 210
 }
211 211
 
212 212
 /**
@@ -216,40 +216,40 @@  discard block
 block discarded – undo
216 216
  */
217 217
 class LoggerLiteralPatternConverter extends LoggerPatternConverter {
218 218
     
219
-    /**
220
-     * @var string
221
-     */
222
-    public $literal;
223
-
224
-    /**
225
-     * Constructor
226
-     *
227
-     * @param string $value
228
-     */
229
-    public function LoggerLiteralPatternConverter($value)
230
-    {
231
-        LoggerLog::debug("LoggerLiteralPatternConverter::LoggerLiteralPatternConverter() value='$value'");    
219
+	/**
220
+	 * @var string
221
+	 */
222
+	public $literal;
223
+
224
+	/**
225
+	 * Constructor
226
+	 *
227
+	 * @param string $value
228
+	 */
229
+	public function LoggerLiteralPatternConverter($value)
230
+	{
231
+		LoggerLog::debug("LoggerLiteralPatternConverter::LoggerLiteralPatternConverter() value='$value'");    
232 232
     
233
-        $this->literal = $value;
234
-    }
235
-
236
-    /**
237
-     * @param string &$sbuf
238
-     * @param LoggerLoggingEvent $event
239
-     */
240
-    public function format(&$sbuf, $event)
241
-    {
242
-        $sbuf .= $this->literal;
243
-    }
244
-
245
-    /**
246
-     * @param LoggerLoggingEvent $event
247
-     * @return string
248
-     */
249
-    public function convert($event)
250
-    {
251
-      return $this->literal;
252
-    }
233
+		$this->literal = $value;
234
+	}
235
+
236
+	/**
237
+	 * @param string &$sbuf
238
+	 * @param LoggerLoggingEvent $event
239
+	 */
240
+	public function format(&$sbuf, $event)
241
+	{
242
+		$sbuf .= $this->literal;
243
+	}
244
+
245
+	/**
246
+	 * @param LoggerLoggingEvent $event
247
+	 * @return string
248
+	 */
249
+	public function convert($event)
250
+	{
251
+	  return $this->literal;
252
+	}
253 253
 }
254 254
 
255 255
 /**
@@ -259,38 +259,38 @@  discard block
 block discarded – undo
259 259
  */
260 260
 class LoggerDatePatternConverter extends LoggerPatternConverter {
261 261
 
262
-    /**
263
-     * @var string
264
-     */
265
-    public $df;
262
+	/**
263
+	 * @var string
264
+	 */
265
+	public $df;
266 266
     
267
-    /**
268
-     * Constructor
269
-     *
270
-     * @param string $formattingInfo
271
-     * @param string $df
272
-     */
273
-    public function LoggerDatePatternConverter($formattingInfo, $df)
274
-    {
275
-        LoggerLog::debug("LoggerDatePatternConverter::LoggerDatePatternConverter() dateFormat='$df'");    
267
+	/**
268
+	 * Constructor
269
+	 *
270
+	 * @param string $formattingInfo
271
+	 * @param string $df
272
+	 */
273
+	public function LoggerDatePatternConverter($formattingInfo, $df)
274
+	{
275
+		LoggerLog::debug("LoggerDatePatternConverter::LoggerDatePatternConverter() dateFormat='$df'");    
276 276
     
277
-        $this->LoggerPatternConverter($formattingInfo);
278
-        $this->df = $df;
279
-    }
280
-
281
-    /**
282
-     * @param LoggerLoggingEvent $event
283
-     * @return string
284
-     */
285
-    public function convert($event)
286
-    {
287
-        $timeStamp = $event->getTimeStamp();
288
-        $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
289
-        $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df));
277
+		$this->LoggerPatternConverter($formattingInfo);
278
+		$this->df = $df;
279
+	}
280
+
281
+	/**
282
+	 * @param LoggerLoggingEvent $event
283
+	 * @return string
284
+	 */
285
+	public function convert($event)
286
+	{
287
+		$timeStamp = $event->getTimeStamp();
288
+		$usecs = round(($timeStamp - (int)$timeStamp) * 1000);
289
+		$this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df));
290 290
          
291
-        return date($this->df, $event->getTimeStamp());
291
+		return date($this->df, $event->getTimeStamp());
292 292
         
293
-    }
293
+	}
294 294
 }
295 295
 
296 296
 /**
@@ -300,33 +300,33 @@  discard block
 block discarded – undo
300 300
  */
301 301
 class LoggerMDCPatternConverter extends LoggerPatternConverter {
302 302
 
303
-    /**
304
-     * @var string
305
-     */
306
-    public $key;
307
-
308
-    /**
309
-     * Constructor
310
-     *
311
-     * @param string $formattingInfo
312
-     * @param string $key
313
-     */
314
-    public function LoggerMDCPatternConverter($formattingInfo, $key)
315
-    {
316
-      LoggerLog::debug("LoggerMDCPatternConverter::LoggerMDCPatternConverter() key='$key'");    
317
-
318
-      $this->LoggerPatternConverter($formattingInfo);
319
-      $this->key = $key;
320
-    }
321
-
322
-    /**
323
-     * @param LoggerLoggingEvent $event
324
-     * @return string
325
-     */
326
-    public function convert($event)
327
-    {
328
-        return $event->getMDC($this->key);
329
-    }
303
+	/**
304
+	 * @var string
305
+	 */
306
+	public $key;
307
+
308
+	/**
309
+	 * Constructor
310
+	 *
311
+	 * @param string $formattingInfo
312
+	 * @param string $key
313
+	 */
314
+	public function LoggerMDCPatternConverter($formattingInfo, $key)
315
+	{
316
+	  LoggerLog::debug("LoggerMDCPatternConverter::LoggerMDCPatternConverter() key='$key'");    
317
+
318
+	  $this->LoggerPatternConverter($formattingInfo);
319
+	  $this->key = $key;
320
+	}
321
+
322
+	/**
323
+	 * @param LoggerLoggingEvent $event
324
+	 * @return string
325
+	 */
326
+	public function convert($event)
327
+	{
328
+		return $event->getMDC($this->key);
329
+	}
330 330
 }
331 331
 
332 332
 /**
@@ -336,45 +336,45 @@  discard block
 block discarded – undo
336 336
  */
337 337
 class LoggerLocationPatternConverter extends LoggerPatternConverter {
338 338
     
339
-    /**
340
-     * @var integer
341
-     */
342
-    public $type;
343
-
344
-    /**
345
-     * Constructor
346
-     *
347
-     * @param string $formattingInfo
348
-     * @param integer $type
349
-     */
350
-    public function LoggerLocationPatternConverter($formattingInfo, $type)
351
-    {
352
-      LoggerLog::debug("LoggerLocationPatternConverter::LoggerLocationPatternConverter() type='$type'");    
339
+	/**
340
+	 * @var integer
341
+	 */
342
+	public $type;
343
+
344
+	/**
345
+	 * Constructor
346
+	 *
347
+	 * @param string $formattingInfo
348
+	 * @param integer $type
349
+	 */
350
+	public function LoggerLocationPatternConverter($formattingInfo, $type)
351
+	{
352
+	  LoggerLog::debug("LoggerLocationPatternConverter::LoggerLocationPatternConverter() type='$type'");    
353 353
     
354
-      $this->LoggerPatternConverter($formattingInfo);
355
-      $this->type = $type;
356
-    }
357
-
358
-    /**
359
-     * @param LoggerLoggingEvent $event
360
-     * @return string
361
-     */
362
-    public function convert($event)
363
-    {
364
-        $locationInfo = $event->getLocationInformation();
365
-        switch($this->type) {
366
-            case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
367
-	            return $locationInfo->fullInfo;
368
-            case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
369
-	            return $locationInfo->getMethodName();
370
-            case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER:
371
-	            return $locationInfo->getLineNumber();
372
-            case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER:
373
-	            return $locationInfo->getFileName();
374
-            default: 
375
-                return '';
376
-        }
377
-    }
354
+	  $this->LoggerPatternConverter($formattingInfo);
355
+	  $this->type = $type;
356
+	}
357
+
358
+	/**
359
+	 * @param LoggerLoggingEvent $event
360
+	 * @return string
361
+	 */
362
+	public function convert($event)
363
+	{
364
+		$locationInfo = $event->getLocationInformation();
365
+		switch($this->type) {
366
+			case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
367
+				return $locationInfo->fullInfo;
368
+			case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
369
+				return $locationInfo->getMethodName();
370
+			case LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER:
371
+				return $locationInfo->getLineNumber();
372
+			case LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER:
373
+				return $locationInfo->getFileName();
374
+			default: 
375
+				return '';
376
+		}
377
+	}
378 378
 }
379 379
 
380 380
 /**
@@ -385,60 +385,60 @@  discard block
 block discarded – undo
385 385
  */
386 386
 class LoggerNamedPatternConverter extends LoggerPatternConverter {
387 387
 
388
-    /**
389
-     * @var integer
390
-     */
391
-    public $precision;
392
-
393
-    /**
394
-     * Constructor
395
-     *
396
-     * @param string $formattingInfo
397
-     * @param integer $precision
398
-     */
399
-    public function LoggerNamedPatternConverter($formattingInfo, $precision)
400
-    {
401
-      LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'");    
388
+	/**
389
+	 * @var integer
390
+	 */
391
+	public $precision;
392
+
393
+	/**
394
+	 * Constructor
395
+	 *
396
+	 * @param string $formattingInfo
397
+	 * @param integer $precision
398
+	 */
399
+	public function LoggerNamedPatternConverter($formattingInfo, $precision)
400
+	{
401
+	  LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'");    
402 402
     
403
-      $this->LoggerPatternConverter($formattingInfo);
404
-      $this->precision =  $precision;
405
-    }
406
-
407
-    /**
408
-     * @param LoggerLoggingEvent $event
409
-     * @return string
410
-     * @abstract
411
-     */
412
-    public function getFullyQualifiedName($event)
413
-    { 
414
-        // abstract
415
-        return;
416
-    }
417
-
418
-    /**
419
-     * @param LoggerLoggingEvent $event
420
-     * @return string
421
-     */
422
-    public function convert($event)
423
-    {
424
-        $n = $this->getFullyQualifiedName($event);
425
-        if ($this->precision <= 0) {
426
-	        return $n;
427
-        } else {
428
-	        $len = strlen($n);
403
+	  $this->LoggerPatternConverter($formattingInfo);
404
+	  $this->precision =  $precision;
405
+	}
406
+
407
+	/**
408
+	 * @param LoggerLoggingEvent $event
409
+	 * @return string
410
+	 * @abstract
411
+	 */
412
+	public function getFullyQualifiedName($event)
413
+	{ 
414
+		// abstract
415
+		return;
416
+	}
417
+
418
+	/**
419
+	 * @param LoggerLoggingEvent $event
420
+	 * @return string
421
+	 */
422
+	public function convert($event)
423
+	{
424
+		$n = $this->getFullyQualifiedName($event);
425
+		if ($this->precision <= 0) {
426
+			return $n;
427
+		} else {
428
+			$len = strlen($n);
429 429
             
430
-        	// We substract 1 from 'len' when assigning to 'end' to avoid out of
431
-        	// bounds exception in return r.substring(end+1, len). This can happen if
432
-        	// precision is 1 and the category name ends with a dot.
433
-        	$end = $len -1 ;
434
-        	for($i = $this->precision; $i > 0; $i--) {
435
-        	    $end = strrpos(substr($n, 0, ($end - 1)), '.');
436
-        	    if ($end === false)
437
-        	        return $n;
438
-        	}
439
-        	return substr($n, ($end + 1), $len);
440
-        }
441
-    }
430
+			// We substract 1 from 'len' when assigning to 'end' to avoid out of
431
+			// bounds exception in return r.substring(end+1, len). This can happen if
432
+			// precision is 1 and the category name ends with a dot.
433
+			$end = $len -1 ;
434
+			for($i = $this->precision; $i > 0; $i--) {
435
+				$end = strrpos(substr($n, 0, ($end - 1)), '.');
436
+				if ($end === false)
437
+					return $n;
438
+			}
439
+			return substr($n, ($end + 1), $len);
440
+		}
441
+	}
442 442
 }
443 443
 
444 444
 /**
@@ -448,27 +448,27 @@  discard block
 block discarded – undo
448 448
  */
449 449
 class LoggerClassNamePatternConverter extends LoggerNamedPatternConverter {
450 450
 
451
-    /**
452
-     * Constructor
453
-     *
454
-     * @param string $formattingInfo
455
-     * @param integer $precision
456
-     */
457
-    public function LoggerClassNamePatternConverter($formattingInfo, $precision)
458
-    {
459
-        LoggerLog::debug("LoggerClassNamePatternConverter::LoggerClassNamePatternConverter() precision='$precision'");    
451
+	/**
452
+	 * Constructor
453
+	 *
454
+	 * @param string $formattingInfo
455
+	 * @param integer $precision
456
+	 */
457
+	public function LoggerClassNamePatternConverter($formattingInfo, $precision)
458
+	{
459
+		LoggerLog::debug("LoggerClassNamePatternConverter::LoggerClassNamePatternConverter() precision='$precision'");    
460 460
     
461
-        $this->LoggerNamedPatternConverter($formattingInfo, $precision);
462
-    }
463
-
464
-    /**
465
-     * @param LoggerLoggingEvent $event
466
-     * @return string
467
-     */
468
-    public function getFullyQualifiedName($event)
469
-    {
470
-        return $event->fqcn;
471
-    }
461
+		$this->LoggerNamedPatternConverter($formattingInfo, $precision);
462
+	}
463
+
464
+	/**
465
+	 * @param LoggerLoggingEvent $event
466
+	 * @return string
467
+	 */
468
+	public function getFullyQualifiedName($event)
469
+	{
470
+		return $event->fqcn;
471
+	}
472 472
 }
473 473
 
474 474
 /**
@@ -478,27 +478,27 @@  discard block
 block discarded – undo
478 478
  */
479 479
 class LoggerCategoryPatternConverter extends LoggerNamedPatternConverter {
480 480
 
481
-    /**
482
-     * Constructor
483
-     *
484
-     * @param string $formattingInfo
485
-     * @param integer $precision
486
-     */
487
-    public function LoggerCategoryPatternConverter($formattingInfo, $precision)
488
-    {
489
-        LoggerLog::debug("LoggerCategoryPatternConverter::LoggerCategoryPatternConverter() precision='$precision'");    
481
+	/**
482
+	 * Constructor
483
+	 *
484
+	 * @param string $formattingInfo
485
+	 * @param integer $precision
486
+	 */
487
+	public function LoggerCategoryPatternConverter($formattingInfo, $precision)
488
+	{
489
+		LoggerLog::debug("LoggerCategoryPatternConverter::LoggerCategoryPatternConverter() precision='$precision'");    
490 490
     
491
-        $this->LoggerNamedPatternConverter($formattingInfo, $precision);
492
-    }
493
-
494
-    /**
495
-     * @param LoggerLoggingEvent $event
496
-     * @return string
497
-     */
498
-    public function getFullyQualifiedName($event)
499
-    {
500
-      return $event->getLoggerName();
501
-    }
491
+		$this->LoggerNamedPatternConverter($formattingInfo, $precision);
492
+	}
493
+
494
+	/**
495
+	 * @param LoggerLoggingEvent $event
496
+	 * @return string
497
+	 */
498
+	public function getFullyQualifiedName($event)
499
+	{
500
+	  return $event->getLoggerName();
501
+	}
502 502
 }
503 503
 
504 504
 ?>
505 505
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 $GLOBALS['log4php.LoggerPatternConverter.spaces'] = array(" ", "  ", "    ", "        ", //1,2,4,8 spaces
34 34
 			    "                ", // 16 spaces
35
-			    "                                " ); // 32 spaces
35
+			    "                                "); // 32 spaces
36 36
 
37 37
 /**
38 38
  * LoggerPatternConverter is an abstract class that provides the formatting 
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
         LoggerLog::debug("LoggerPatternConverter::format() converted event is '$s'");    
98 98
         
99 99
     
100
-        if($s === null || empty($s)) {
101
-            if(0 < $this->min)
100
+        if ($s === null || empty($s)) {
101
+            if (0 < $this->min)
102 102
                 $this->spacePad($sbuf, $this->min);
103 103
             return;
104 104
         }
105 105
         
106 106
         $len = strlen($s);
107 107
     
108
-        if($len > $this->max) {
109
-            $sbuf .= substr($s , 0, ($len - $this->max));
110
-        } elseif($len < $this->min) {
111
-            if($this->leftAlign) {	
108
+        if ($len > $this->max) {
109
+            $sbuf .= substr($s, 0, ($len - $this->max));
110
+        } elseif ($len < $this->min) {
111
+            if ($this->leftAlign) {	
112 112
                 $sbuf .= $s;
113 113
                 $this->spacePad($sbuf, ($this->min - $len));
114 114
             } else {
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
     {
134 134
         LoggerLog::debug("LoggerPatternConverter::spacePad() sbuf='$sbuf' len='$length'");        
135 135
     
136
-        while($length >= 32) {
136
+        while ($length >= 32) {
137 137
           $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][5];
138 138
           $length -= 32;
139 139
         }
140 140
         
141
-        for($i = 4; $i >= 0; $i--) {	
142
-            if(($length & (1<<$i)) != 0) {
141
+        for ($i = 4; $i >= 0; $i--) {	
142
+            if (($length & (1 << $i)) != 0) {
143 143
     	        $sbuf .= $GLOBALS['log4php.LoggerPatternConverter.spaces'][$i];
144 144
             }
145 145
         }
@@ -184,11 +184,11 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public function convert($event)
186 186
     {
187
-        switch($this->type) {
187
+        switch ($this->type) {
188 188
             case LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER:
189 189
                 $timeStamp = $event->getTimeStamp();
190 190
                 $startTime = LoggerLoggingEvent::getStartTime();
191
-	            return (string)(int)($timeStamp * 1000 - $startTime * 1000);
191
+	            return (string) (int) ($timeStamp * 1000 - $startTime * 1000);
192 192
                 
193 193
             case LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER:
194 194
 	            return $event->getThreadName();
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
     public function convert($event)
286 286
     {
287 287
         $timeStamp = $event->getTimeStamp();
288
-        $usecs = round(($timeStamp - (int)$timeStamp) * 1000);
288
+        $usecs = round(($timeStamp - (int) $timeStamp) * 1000);
289 289
         $this->df = str_replace("\u", "u", ereg_replace("[^\\]u", sprintf(',%03d', $usecs), $this->df));
290 290
          
291 291
         return date($this->df, $event->getTimeStamp());
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     public function convert($event)
363 363
     {
364 364
         $locationInfo = $event->getLocationInformation();
365
-        switch($this->type) {
365
+        switch ($this->type) {
366 366
             case LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER:
367 367
 	            return $locationInfo->fullInfo;
368 368
             case LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER:
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
       LoggerLog::debug("LoggerNamedPatternConverter::LoggerNamedPatternConverter() precision='$precision'");    
402 402
     
403 403
       $this->LoggerPatternConverter($formattingInfo);
404
-      $this->precision =  $precision;
404
+      $this->precision = $precision;
405 405
     }
406 406
 
407 407
     /**
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
         	// We substract 1 from 'len' when assigning to 'end' to avoid out of
431 431
         	// bounds exception in return r.substring(end+1, len). This can happen if
432 432
         	// precision is 1 and the category name ends with a dot.
433
-        	$end = $len -1 ;
434
-        	for($i = $this->precision; $i > 0; $i--) {
433
+        	$end = $len - 1;
434
+        	for ($i = $this->precision; $i > 0; $i--) {
435 435
         	    $end = strrpos(substr($n, 0, ($end - 1)), '.');
436 436
         	    if ($end === false)
437 437
         	        return $n;
Please login to merge, or discard this patch.
libraries/log4php.debug/helpers/LoggerOptionConverter.php 2 patches
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -41,310 +41,310 @@
 block discarded – undo
41 41
  */
42 42
 class LoggerOptionConverter {
43 43
 
44
-    /** 
45
-     * OptionConverter is a static class. 
46
-     */
47
-    public function OptionConverter() 
48
-    {
49
-        return;
50
-    }
44
+	/** 
45
+	 * OptionConverter is a static class. 
46
+	 */
47
+	public function OptionConverter() 
48
+	{
49
+		return;
50
+	}
51 51
 
52
-    /**
53
-     * @param array $l
54
-     * @param array $r
55
-     * @return array
56
-     *
57
-     * @static
58
-     */
59
-    public function concatanateArrays($l, $r)
60
-    {
61
-        return array_merge($l, $r);
62
-    }
52
+	/**
53
+	 * @param array $l
54
+	 * @param array $r
55
+	 * @return array
56
+	 *
57
+	 * @static
58
+	 */
59
+	public function concatanateArrays($l, $r)
60
+	{
61
+		return array_merge($l, $r);
62
+	}
63 63
 
64
-    /**
65
-    * Read a predefined var.
66
-    *
67
-    * It returns a value referenced by <var>$key</var> using this search criteria:
68
-    * - if <var>$key</var> is a constant then return it. Else
69
-    * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
70
-    * - return <var>$def</var>. 
71
-    *
72
-    * @param string $key The key to search for.
73
-    * @param string $def The default value to return.
74
-    * @return string    the string value of the system property, or the default
75
-    *                   value if there is no property with that key.
76
-    *
77
-    * @static
78
-    */
79
-    public function getSystemProperty($key, $def)
80
-    {
81
-        LoggerLog::debug("LoggerOptionConverter::getSystemProperty():key=[{$key}]:def=[{$def}].");
64
+	/**
65
+	 * Read a predefined var.
66
+	 *
67
+	 * It returns a value referenced by <var>$key</var> using this search criteria:
68
+	 * - if <var>$key</var> is a constant then return it. Else
69
+	 * - if <var>$key</var> is set in <var>$_ENV</var> then return it. Else
70
+	 * - return <var>$def</var>. 
71
+	 *
72
+	 * @param string $key The key to search for.
73
+	 * @param string $def The default value to return.
74
+	 * @return string    the string value of the system property, or the default
75
+	 *                   value if there is no property with that key.
76
+	 *
77
+	 * @static
78
+	 */
79
+	public function getSystemProperty($key, $def)
80
+	{
81
+		LoggerLog::debug("LoggerOptionConverter::getSystemProperty():key=[{$key}]:def=[{$def}].");
82 82
 
83
-        if (defined($key)) {
84
-            return (string)constant($key);
85
-        } elseif (isset($_ENV[$key])) {
86
-            return (string)$_ENV[$key];
87
-        } else {
88
-            return $def;
89
-        }
90
-    }
83
+		if (defined($key)) {
84
+			return (string)constant($key);
85
+		} elseif (isset($_ENV[$key])) {
86
+			return (string)$_ENV[$key];
87
+		} else {
88
+			return $def;
89
+		}
90
+	}
91 91
 
92
-    /**
93
-     * If <var>$value</var> is <i>true</i>, then <i>true</i> is
94
-     * returned. If <var>$value</var> is <i>false</i>, then
95
-     * <i>true</i> is returned. Otherwise, <var>$default</var> is
96
-     * returned.
97
-     *
98
-     * <p>Case of value is unimportant.</p>
99
-     *
100
-     * @param string $value
101
-     * @param boolean $default
102
-     * @return boolean
103
-     *
104
-     * @static
105
-     */
106
-    public function toBoolean($value, $default)
107
-    {
108
-        if($value === null)
109
-            return $default;
110
-        if ($value == 1)
111
-            return true;
112
-        $trimmedVal = strtolower(trim($value));
113
-        if ("true" == $trimmedVal || "yes" == $trimmedVal)
114
-            return true;
115
-        if ("false" == $trimmedVal)
116
-            return false;
117
-        return $default;
118
-    }
92
+	/**
93
+	 * If <var>$value</var> is <i>true</i>, then <i>true</i> is
94
+	 * returned. If <var>$value</var> is <i>false</i>, then
95
+	 * <i>true</i> is returned. Otherwise, <var>$default</var> is
96
+	 * returned.
97
+	 *
98
+	 * <p>Case of value is unimportant.</p>
99
+	 *
100
+	 * @param string $value
101
+	 * @param boolean $default
102
+	 * @return boolean
103
+	 *
104
+	 * @static
105
+	 */
106
+	public function toBoolean($value, $default)
107
+	{
108
+		if($value === null)
109
+			return $default;
110
+		if ($value == 1)
111
+			return true;
112
+		$trimmedVal = strtolower(trim($value));
113
+		if ("true" == $trimmedVal || "yes" == $trimmedVal)
114
+			return true;
115
+		if ("false" == $trimmedVal)
116
+			return false;
117
+		return $default;
118
+	}
119 119
 
120
-    /**
121
-     * @param string $value
122
-     * @param integer $default
123
-     * @return integer
124
-     * @static
125
-     */
126
-    public function toInt($value, $default)
127
-    {
128
-        $value = trim($value);
129
-        if (is_numeric($value)) {
130
-            return (int)$value;
131
-        } else {
132
-            return $default;
133
-        }
134
-    }
120
+	/**
121
+	 * @param string $value
122
+	 * @param integer $default
123
+	 * @return integer
124
+	 * @static
125
+	 */
126
+	public function toInt($value, $default)
127
+	{
128
+		$value = trim($value);
129
+		if (is_numeric($value)) {
130
+			return (int)$value;
131
+		} else {
132
+			return $default;
133
+		}
134
+	}
135 135
 
136
-    /**
137
-     * Converts a standard or custom priority level to a Level
138
-     * object.
139
-     *
140
-     * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
141
-     * where <i>full_file_classname</i> means the class filename with path
142
-     * but without php extension, then the specified class' <i>toLevel()</i> method
143
-     * is called to process the specified level string; if no '#'
144
-     * character is present, then the default {@link LoggerLevel}
145
-     * class is used to process the level value.</p>
146
-     *
147
-     * <p>As a special case, if the <var>$value</var> parameter is
148
-     * equal to the string "NULL", then the value <i>null</i> will
149
-     * be returned.</p>
150
-     *
151
-     * <p>If any error occurs while converting the value to a level,
152
-     * the <var>$defaultValue</var> parameter, which may be
153
-     * <i>null</i>, is returned.</p>
154
-     *
155
-     * <p>Case of <var>$value</var> is insignificant for the level level, but is
156
-     * significant for the class name part, if present.</p>
157
-     *
158
-     * @param string $value
159
-     * @param LoggerLevel $defaultValue
160
-     * @return LoggerLevel a {@link LoggerLevel} or null
161
-     * @static
162
-     */
163
-    public function toLevel($value, $defaultValue)
164
-    {
165
-        if($value === null)
166
-            return $defaultValue;
136
+	/**
137
+	 * Converts a standard or custom priority level to a Level
138
+	 * object.
139
+	 *
140
+	 * <p> If <var>$value</var> is of form "<b>level#full_file_classname</b>",
141
+	 * where <i>full_file_classname</i> means the class filename with path
142
+	 * but without php extension, then the specified class' <i>toLevel()</i> method
143
+	 * is called to process the specified level string; if no '#'
144
+	 * character is present, then the default {@link LoggerLevel}
145
+	 * class is used to process the level value.</p>
146
+	 *
147
+	 * <p>As a special case, if the <var>$value</var> parameter is
148
+	 * equal to the string "NULL", then the value <i>null</i> will
149
+	 * be returned.</p>
150
+	 *
151
+	 * <p>If any error occurs while converting the value to a level,
152
+	 * the <var>$defaultValue</var> parameter, which may be
153
+	 * <i>null</i>, is returned.</p>
154
+	 *
155
+	 * <p>Case of <var>$value</var> is insignificant for the level level, but is
156
+	 * significant for the class name part, if present.</p>
157
+	 *
158
+	 * @param string $value
159
+	 * @param LoggerLevel $defaultValue
160
+	 * @return LoggerLevel a {@link LoggerLevel} or null
161
+	 * @static
162
+	 */
163
+	public function toLevel($value, $defaultValue)
164
+	{
165
+		if($value === null)
166
+			return $defaultValue;
167 167
 
168
-        $hashIndex = strpos($value, '#');
169
-        if ($hashIndex === false) {
170
-            if("NULL" == strtoupper($value)) {
171
-	            return null;
172
-            } else {
173
-	            // no class name specified : use standard Level class
174
-	            return LoggerLevel::toLevel($value, $defaultValue);
175
-            }
176
-        }
168
+		$hashIndex = strpos($value, '#');
169
+		if ($hashIndex === false) {
170
+			if("NULL" == strtoupper($value)) {
171
+				return null;
172
+			} else {
173
+				// no class name specified : use standard Level class
174
+				return LoggerLevel::toLevel($value, $defaultValue);
175
+			}
176
+		}
177 177
 
178
-        $result = $defaultValue;
178
+		$result = $defaultValue;
179 179
 
180
-        $clazz = substr($value, ($hashIndex + 1));
181
-        $levelName = substr($value, 0, $hashIndex);
180
+		$clazz = substr($value, ($hashIndex + 1));
181
+		$levelName = substr($value, 0, $hashIndex);
182 182
 
183
-        // This is degenerate case but you never know.
184
-        if("NULL" == strtoupper($levelName)) {
185
-        	return null;
186
-        }
183
+		// This is degenerate case but you never know.
184
+		if("NULL" == strtoupper($levelName)) {
185
+			return null;
186
+		}
187 187
 
188
-        LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]");
188
+		LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}]:pri=[{$levelName}]");
189 189
 
190
-        if (!class_exists($clazz))
191
-            @include_once("{$clazz}.php");
190
+		if (!class_exists($clazz))
191
+			@include_once("{$clazz}.php");
192 192
 
193
-        $clazz = basename($clazz);
193
+		$clazz = basename($clazz);
194 194
 
195
-        if (class_exists($clazz)) {
196
-            $result = @call_user_func(array($clazz, 'toLevel'), $value, $defaultValue);
197
-            if (!is_a($result, 'loggerlevel')) {
198
-                LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default.");            
199
-                $result = $defaultValue;
200
-            }
201
-        } else {
202
-            LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists.");
203
-        }
204
-        return $result;
205
-    }
195
+		if (class_exists($clazz)) {
196
+			$result = @call_user_func(array($clazz, 'toLevel'), $value, $defaultValue);
197
+			if (!is_a($result, 'loggerlevel')) {
198
+				LoggerLog::debug("LoggerOptionConverter::toLevel():class=[{$clazz}] cannot call toLevel(). Returning default.");            
199
+				$result = $defaultValue;
200
+			}
201
+		} else {
202
+			LoggerLog::warn("LoggerOptionConverter::toLevel() class '{$clazz}' doesnt exists.");
203
+		}
204
+		return $result;
205
+	}
206 206
 
207
-    /**
208
-     * @param string $value
209
-     * @param float $default
210
-     * @return float
211
-     *
212
-     * @static
213
-     */
214
-    public function toFileSize($value, $default)
215
-    {
216
-        if ($value === null)
217
-            return $default;
207
+	/**
208
+	 * @param string $value
209
+	 * @param float $default
210
+	 * @return float
211
+	 *
212
+	 * @static
213
+	 */
214
+	public function toFileSize($value, $default)
215
+	{
216
+		if ($value === null)
217
+			return $default;
218 218
 
219
-        $s = strtoupper(trim($value));
220
-        $multiplier = (float)1;
221
-        if(($index = strpos($s, 'KB')) !== false) {
222
-            $multiplier = 1024;
223
-            $s = substr($s, 0, $index);
224
-        } elseif(($index = strpos($s, 'MB')) !== false) {
225
-            $multiplier = 1024 * 1024;
226
-            $s = substr($s, 0, $index);
227
-        } elseif(($index = strpos($s, 'GB')) !== false) {
228
-            $multiplier = 1024 * 1024 * 1024;
229
-            $s = substr($s, 0, $index);
230
-        }
231
-        if(is_numeric($s)) {
232
-            return (float)$s * $multiplier;
233
-        } else {
234
-            LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form.");
235
-        }
236
-        return $default;
237
-    }
219
+		$s = strtoupper(trim($value));
220
+		$multiplier = (float)1;
221
+		if(($index = strpos($s, 'KB')) !== false) {
222
+			$multiplier = 1024;
223
+			$s = substr($s, 0, $index);
224
+		} elseif(($index = strpos($s, 'MB')) !== false) {
225
+			$multiplier = 1024 * 1024;
226
+			$s = substr($s, 0, $index);
227
+		} elseif(($index = strpos($s, 'GB')) !== false) {
228
+			$multiplier = 1024 * 1024 * 1024;
229
+			$s = substr($s, 0, $index);
230
+		}
231
+		if(is_numeric($s)) {
232
+			return (float)$s * $multiplier;
233
+		} else {
234
+			LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form.");
235
+		}
236
+		return $default;
237
+	}
238 238
 
239
-    /**
240
-     * Find the value corresponding to <var>$key</var> in
241
-     * <var>$props</var>. Then perform variable substitution on the
242
-     * found value.
243
-     *
244
-     * @param string $key
245
-     * @param array $props
246
-     * @return string
247
-     *
248
-     * @static
249
-     */
250
-    public function findAndSubst($key, $props)
251
-    {
252
-        $value = @$props[$key];
253
-        if(empty($value)) {
254
-            return null;
255
-        }
256
-        return LoggerOptionConverter::substVars($value, $props);
257
-    }
239
+	/**
240
+	 * Find the value corresponding to <var>$key</var> in
241
+	 * <var>$props</var>. Then perform variable substitution on the
242
+	 * found value.
243
+	 *
244
+	 * @param string $key
245
+	 * @param array $props
246
+	 * @return string
247
+	 *
248
+	 * @static
249
+	 */
250
+	public function findAndSubst($key, $props)
251
+	{
252
+		$value = @$props[$key];
253
+		if(empty($value)) {
254
+			return null;
255
+		}
256
+		return LoggerOptionConverter::substVars($value, $props);
257
+	}
258 258
 
259
-    /**
260
-     * Perform variable substitution in string <var>$val</var> from the
261
-     * values of keys found with the {@link getSystemProperty()} method.
262
-     * 
263
-     * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
264
-     * 
265
-     * <p>For example, if the "MY_CONSTANT" contains "value", then
266
-     * the call
267
-     * <code>
268
-     * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
269
-     * </code>
270
-     * will set the variable <i>$s</i> to "Value of key is value.".</p>
271
-     * 
272
-     * <p>If no value could be found for the specified key, then the
273
-     * <var>$props</var> parameter is searched, if the value could not
274
-     * be found there, then substitution defaults to the empty string.</p>
275
-     * 
276
-     * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
277
-     * "inexistentKey", then the call
278
-     * <code>
279
-     * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
280
-     * </code>
281
-     * will set <var>$s</var> to "Value of inexistentKey is []".</p>
282
-     * 
283
-     * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
284
-     * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
285
-     * 
286
-     * @log4j-author Avy Sharell
287
-     * 
288
-     * @param string $val The string on which variable substitution is performed.
289
-     * @param array $props
290
-     * @return string
291
-     *
292
-     * @static
293
-     */
294
-    public function substVars($val, $props = null)
295
-    {
296
-        LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
259
+	/**
260
+	 * Perform variable substitution in string <var>$val</var> from the
261
+	 * values of keys found with the {@link getSystemProperty()} method.
262
+	 * 
263
+	 * <p>The variable substitution delimeters are <b>${</b> and <b>}</b>.
264
+	 * 
265
+	 * <p>For example, if the "MY_CONSTANT" contains "value", then
266
+	 * the call
267
+	 * <code>
268
+	 * $s = LoggerOptionConverter::substituteVars("Value of key is ${MY_CONSTANT}.");
269
+	 * </code>
270
+	 * will set the variable <i>$s</i> to "Value of key is value.".</p>
271
+	 * 
272
+	 * <p>If no value could be found for the specified key, then the
273
+	 * <var>$props</var> parameter is searched, if the value could not
274
+	 * be found there, then substitution defaults to the empty string.</p>
275
+	 * 
276
+	 * <p>For example, if {@link getSystemProperty()} cannot find any value for the key
277
+	 * "inexistentKey", then the call
278
+	 * <code>
279
+	 * $s = LoggerOptionConverter::substVars("Value of inexistentKey is [${inexistentKey}]");
280
+	 * </code>
281
+	 * will set <var>$s</var> to "Value of inexistentKey is []".</p>
282
+	 * 
283
+	 * <p>A warn is thrown if <var>$val</var> contains a start delimeter "${" 
284
+	 * which is not balanced by a stop delimeter "}" and an empty string is returned.</p>
285
+	 * 
286
+	 * @log4j-author Avy Sharell
287
+	 * 
288
+	 * @param string $val The string on which variable substitution is performed.
289
+	 * @param array $props
290
+	 * @return string
291
+	 *
292
+	 * @static
293
+	 */
294
+	public function substVars($val, $props = null)
295
+	{
296
+		LoggerLog::debug("LoggerOptionConverter::substVars():val=[{$val}]");
297 297
         
298
-        $sbuf = '';
299
-        $i = 0;
300
-        while(true) {
301
-            $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
302
-            if ($j === false) {
303
-                LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
304
-	            // no more variables
305
-	            if ($i == 0) { // this is a simple string
306
-                    LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
307
-	                return $val;
308
-            	} else { // add the tail string which contails no variables and return the result.
309
-                    $sbuf .= substr($val, $i);
310
-                    LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");                    
311
-                    return $sbuf;
312
-	            }
313
-            } else {
298
+		$sbuf = '';
299
+		$i = 0;
300
+		while(true) {
301
+			$j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
302
+			if ($j === false) {
303
+				LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
304
+				// no more variables
305
+				if ($i == 0) { // this is a simple string
306
+					LoggerLog::debug("LoggerOptionConverter::substVars() simple string");
307
+					return $val;
308
+				} else { // add the tail string which contails no variables and return the result.
309
+					$sbuf .= substr($val, $i);
310
+					LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]. Returning sbuf");                    
311
+					return $sbuf;
312
+				}
313
+			} else {
314 314
             
315
-	            $sbuf .= substr($val, $i, $j-$i);
316
-                LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
317
-            	$k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
318
-            	if ($k === false) {
319
-                    LoggerLog::warn(
320
-                        "LoggerOptionConverter::substVars() " .
321
-                        "'{$val}' has no closing brace. Opening brace at position {$j}."
322
-                    );
323
-                    return '';
324
-	            } else {
325
-	                $j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN;
326
-	                $key = substr($val, $j, $k - $j);
327
-                    // first try in System properties
328
-	                $replacement = LoggerOptionConverter::getSystemProperty($key, null);
329
-	                // then try props parameter
330
-	                if($replacement === null && $props !== null) {
331
-            	        $replacement = @$props[$key];
332
-	                }
315
+				$sbuf .= substr($val, $i, $j-$i);
316
+				LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
317
+				$k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
318
+				if ($k === false) {
319
+					LoggerLog::warn(
320
+						"LoggerOptionConverter::substVars() " .
321
+						"'{$val}' has no closing brace. Opening brace at position {$j}."
322
+					);
323
+					return '';
324
+				} else {
325
+					$j += LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN;
326
+					$key = substr($val, $j, $k - $j);
327
+					// first try in System properties
328
+					$replacement = LoggerOptionConverter::getSystemProperty($key, null);
329
+					// then try props parameter
330
+					if($replacement === null && $props !== null) {
331
+						$replacement = @$props[$key];
332
+					}
333 333
 
334
-                    if(!empty($replacement)) {
335
-	                    // Do variable substitution on the replacement string
336
-                	    // such that we can solve "Hello ${x2}" as "Hello p1" 
337
-                        // the where the properties are
338
-                	    // x1=p1
339
-                        // x2=${x1}
340
-	                    $recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
341
-                	    $sbuf .= $recursiveReplacement;
342
-	                }
343
-	                $i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
344
-	            }
345
-            }
346
-        }
347
-    }
334
+					if(!empty($replacement)) {
335
+						// Do variable substitution on the replacement string
336
+						// such that we can solve "Hello ${x2}" as "Hello p1" 
337
+						// the where the properties are
338
+						// x1=p1
339
+						// x2=${x1}
340
+						$recursiveReplacement = LoggerOptionConverter::substVars($replacement, $props);
341
+						$sbuf .= $recursiveReplacement;
342
+					}
343
+					$i = $k + LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN;
344
+				}
345
+			}
346
+		}
347
+	}
348 348
 
349 349
 }
350 350
 ?>
351 351
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
 
25 25
 require_once(LOG4PHP_DIR . '/LoggerLevel.php');
26 26
 
27
-define('LOG4PHP_OPTION_CONVERTER_DELIM_START',      '${');
28
-define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP',       '}');
29
-define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN',  2);
30
-define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN',   1);
27
+define('LOG4PHP_OPTION_CONVERTER_DELIM_START', '${');
28
+define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP', '}');
29
+define('LOG4PHP_OPTION_CONVERTER_DELIM_START_LEN', 2);
30
+define('LOG4PHP_OPTION_CONVERTER_DELIM_STOP_LEN', 1);
31 31
 
32 32
 /**
33 33
  * A convenience class to convert property values to specific types.
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
         LoggerLog::debug("LoggerOptionConverter::getSystemProperty():key=[{$key}]:def=[{$def}].");
82 82
 
83 83
         if (defined($key)) {
84
-            return (string)constant($key);
84
+            return (string) constant($key);
85 85
         } elseif (isset($_ENV[$key])) {
86
-            return (string)$_ENV[$key];
86
+            return (string) $_ENV[$key];
87 87
         } else {
88 88
             return $def;
89 89
         }
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function toBoolean($value, $default)
107 107
     {
108
-        if($value === null)
108
+        if ($value === null)
109 109
             return $default;
110 110
         if ($value == 1)
111 111
             return true;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     {
128 128
         $value = trim($value);
129 129
         if (is_numeric($value)) {
130
-            return (int)$value;
130
+            return (int) $value;
131 131
         } else {
132 132
             return $default;
133 133
         }
@@ -162,12 +162,12 @@  discard block
 block discarded – undo
162 162
      */
163 163
     public function toLevel($value, $defaultValue)
164 164
     {
165
-        if($value === null)
165
+        if ($value === null)
166 166
             return $defaultValue;
167 167
 
168 168
         $hashIndex = strpos($value, '#');
169 169
         if ($hashIndex === false) {
170
-            if("NULL" == strtoupper($value)) {
170
+            if ("NULL" == strtoupper($value)) {
171 171
 	            return null;
172 172
             } else {
173 173
 	            // no class name specified : use standard Level class
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
         $levelName = substr($value, 0, $hashIndex);
182 182
 
183 183
         // This is degenerate case but you never know.
184
-        if("NULL" == strtoupper($levelName)) {
184
+        if ("NULL" == strtoupper($levelName)) {
185 185
         	return null;
186 186
         }
187 187
 
@@ -217,19 +217,19 @@  discard block
 block discarded – undo
217 217
             return $default;
218 218
 
219 219
         $s = strtoupper(trim($value));
220
-        $multiplier = (float)1;
221
-        if(($index = strpos($s, 'KB')) !== false) {
220
+        $multiplier = (float) 1;
221
+        if (($index = strpos($s, 'KB')) !== false) {
222 222
             $multiplier = 1024;
223 223
             $s = substr($s, 0, $index);
224
-        } elseif(($index = strpos($s, 'MB')) !== false) {
224
+        } elseif (($index = strpos($s, 'MB')) !== false) {
225 225
             $multiplier = 1024 * 1024;
226 226
             $s = substr($s, 0, $index);
227
-        } elseif(($index = strpos($s, 'GB')) !== false) {
227
+        } elseif (($index = strpos($s, 'GB')) !== false) {
228 228
             $multiplier = 1024 * 1024 * 1024;
229 229
             $s = substr($s, 0, $index);
230 230
         }
231
-        if(is_numeric($s)) {
232
-            return (float)$s * $multiplier;
231
+        if (is_numeric($s)) {
232
+            return (float) $s * $multiplier;
233 233
         } else {
234 234
             LoggerLog::warn("LoggerOptionConverter::toFileSize() [{$s}] is not in proper form.");
235 235
         }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     public function findAndSubst($key, $props)
251 251
     {
252 252
         $value = @$props[$key];
253
-        if(empty($value)) {
253
+        if (empty($value)) {
254 254
             return null;
255 255
         }
256 256
         return LoggerOptionConverter::substVars($value, $props);
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
         
298 298
         $sbuf = '';
299 299
         $i = 0;
300
-        while(true) {
300
+        while (true) {
301 301
             $j = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_START, $i);
302 302
             if ($j === false) {
303 303
                 LoggerLog::debug("LoggerOptionConverter::substVars() no more variables");
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	            }
313 313
             } else {
314 314
             
315
-	            $sbuf .= substr($val, $i, $j-$i);
315
+	            $sbuf .= substr($val, $i, $j - $i);
316 316
                 LoggerLog::debug("LoggerOptionConverter::substVars():sbuf=[{$sbuf}]:i={$i}:j={$j}.");
317 317
             	$k = strpos($val, LOG4PHP_OPTION_CONVERTER_DELIM_STOP, $j);
318 318
             	if ($k === false) {
@@ -327,11 +327,11 @@  discard block
 block discarded – undo
327 327
                     // first try in System properties
328 328
 	                $replacement = LoggerOptionConverter::getSystemProperty($key, null);
329 329
 	                // then try props parameter
330
-	                if($replacement === null && $props !== null) {
330
+	                if ($replacement === null && $props !== null) {
331 331
             	        $replacement = @$props[$key];
332 332
 	                }
333 333
 
334
-                    if(!empty($replacement)) {
334
+                    if (!empty($replacement)) {
335 335
 	                    // Do variable substitution on the replacement string
336 336
                 	    // such that we can solve "Hello ${x2}" as "Hello p1" 
337 337
                         // the where the properties are
Please login to merge, or discard this patch.
libraries/log4php.debug/helpers/LoggerPatternParser.php 2 patches
Indentation   +321 added lines, -321 removed lines patch added patch discarded remove patch
@@ -23,17 +23,17 @@  discard block
 block discarded – undo
23 23
 if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__) . '/..');
24 24
 
25 25
 if (!defined('LOG4PHP_LINE_SEP')) {
26
-    if (substr(php_uname(), 0, 7) == "Windows") {
27
-        /**
28
-         * @ignore
29
-         */
30
-        define('LOG4PHP_LINE_SEP', "\r\n");
31
-    } else {
32
-        /**
33
-         * @ignore
34
-         */
35
-        define('LOG4PHP_LINE_SEP', "\n");
36
-    }
26
+	if (substr(php_uname(), 0, 7) == "Windows") {
27
+		/**
28
+		 * @ignore
29
+		 */
30
+		define('LOG4PHP_LINE_SEP', "\r\n");
31
+	} else {
32
+		/**
33
+		 * @ignore
34
+		 */
35
+		define('LOG4PHP_LINE_SEP', "\n");
36
+	}
37 37
 }
38 38
  
39 39
 /**
@@ -83,335 +83,335 @@  discard block
 block discarded – undo
83 83
  */
84 84
 class LoggerPatternParser {
85 85
 
86
-    public $state;
87
-    public $currentLiteral;
88
-    public $patternLength;
89
-    public $i;
86
+	public $state;
87
+	public $currentLiteral;
88
+	public $patternLength;
89
+	public $i;
90 90
     
91
-    /**
92
-     * @var LoggerPatternConverter
93
-     */
94
-    public $head = null;
91
+	/**
92
+	 * @var LoggerPatternConverter
93
+	 */
94
+	public $head = null;
95 95
      
96
-    /**
97
-     * @var LoggerPatternConverter
98
-     */
99
-    public $tail = null;
96
+	/**
97
+	 * @var LoggerPatternConverter
98
+	 */
99
+	public $tail = null;
100 100
     
101
-    /**
102
-     * @var LoggerFormattingInfo
103
-     */
104
-    public $formattingInfo;
101
+	/**
102
+	 * @var LoggerFormattingInfo
103
+	 */
104
+	public $formattingInfo;
105 105
     
106
-    /**
107
-     * @var string pattern to parse
108
-     */
109
-    public $pattern;
106
+	/**
107
+	 * @var string pattern to parse
108
+	 */
109
+	public $pattern;
110 110
 
111
-    /**
112
-     * Constructor 
113
-     *
114
-     * @param string $pattern
115
-     */
116
-    public function LoggerPatternParser($pattern)
117
-    {
118
-        LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'");
111
+	/**
112
+	 * Constructor 
113
+	 *
114
+	 * @param string $pattern
115
+	 */
116
+	public function LoggerPatternParser($pattern)
117
+	{
118
+		LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'");
119 119
     
120
-        $this->pattern = $pattern;
121
-        $this->patternLength =  strlen($pattern);
122
-        $this->formattingInfo = new LoggerFormattingInfo();
123
-        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
124
-    }
120
+		$this->pattern = $pattern;
121
+		$this->patternLength =  strlen($pattern);
122
+		$this->formattingInfo = new LoggerFormattingInfo();
123
+		$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
124
+	}
125 125
 
126
-    /**
127
-     * @param LoggerPatternConverter $pc
128
-     */
129
-    public function addToList($pc)
130
-    {
131
-        // LoggerLog::debug("LoggerPatternParser::addToList()");
126
+	/**
127
+	 * @param LoggerPatternConverter $pc
128
+	 */
129
+	public function addToList($pc)
130
+	{
131
+		// LoggerLog::debug("LoggerPatternParser::addToList()");
132 132
     
133
-        if($this->head === null) {
134
-            $this->head = $pc;
135
-            $this->tail =& $this->head;
136
-        } else {
137
-            $this->tail->next = $pc;
138
-            $this->tail =& $this->tail->next;
139
-        }
140
-    }
133
+		if($this->head === null) {
134
+			$this->head = $pc;
135
+			$this->tail =& $this->head;
136
+		} else {
137
+			$this->tail->next = $pc;
138
+			$this->tail =& $this->tail->next;
139
+		}
140
+	}
141 141
 
142
-    /**
143
-     * @return string
144
-     */
145
-    public function extractOption()
146
-    {
147
-        if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) {
148
-            $end = strpos($this->pattern, '}' , $this->i);
149
-            if ($end !== false) {
150
-                $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
151
-	            $this->i= $end + 1;
152
-        	    return $r;
153
-            }
154
-        }
155
-        return null;
156
-    }
142
+	/**
143
+	 * @return string
144
+	 */
145
+	public function extractOption()
146
+	{
147
+		if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) {
148
+			$end = strpos($this->pattern, '}' , $this->i);
149
+			if ($end !== false) {
150
+				$r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
151
+				$this->i= $end + 1;
152
+				return $r;
153
+			}
154
+		}
155
+		return null;
156
+	}
157 157
 
158
-    /**
159
-     * The option is expected to be in decimal and positive. In case of
160
-     * error, zero is returned.  
161
-     */
162
-    public function extractPrecisionOption()
163
-    {
164
-        $opt = $this->extractOption();
165
-        $r = 0;
166
-        if ($opt !== null) {
167
-            if (is_numeric($opt)) {
168
-    	        $r = (int)$opt;
169
-            	if($r <= 0) {
170
-            	    LoggerLog::warn("Precision option ({$opt}) isn't a positive integer.");
171
-            	    $r = 0;
172
-            	}
173
-            } else {
174
-                LoggerLog::warn("Category option \"{$opt}\" not a decimal integer.");
175
-            }
176
-        }
177
-        return $r;
178
-    }
158
+	/**
159
+	 * The option is expected to be in decimal and positive. In case of
160
+	 * error, zero is returned.  
161
+	 */
162
+	public function extractPrecisionOption()
163
+	{
164
+		$opt = $this->extractOption();
165
+		$r = 0;
166
+		if ($opt !== null) {
167
+			if (is_numeric($opt)) {
168
+				$r = (int)$opt;
169
+				if($r <= 0) {
170
+					LoggerLog::warn("Precision option ({$opt}) isn't a positive integer.");
171
+					$r = 0;
172
+				}
173
+			} else {
174
+				LoggerLog::warn("Category option \"{$opt}\" not a decimal integer.");
175
+			}
176
+		}
177
+		return $r;
178
+	}
179 179
 
180
-    public function parse()
181
-    {
182
-        LoggerLog::debug("LoggerPatternParser::parse()");
180
+	public function parse()
181
+	{
182
+		LoggerLog::debug("LoggerPatternParser::parse()");
183 183
     
184
-        $c = '';
185
-        $this->i = 0;
186
-        $this->currentLiteral = '';
187
-        while ($this->i < $this->patternLength) {
188
-            $c = $this->pattern{$this->i++};
184
+		$c = '';
185
+		$this->i = 0;
186
+		$this->currentLiteral = '';
187
+		while ($this->i < $this->patternLength) {
188
+			$c = $this->pattern{$this->i++};
189 189
 //            LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'");            
190
-            switch($this->state) {
191
-                case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE:
192
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'");
193
-                    // In literal state, the last char is always a literal.
194
-                    if($this->i == $this->patternLength) {
195
-                        $this->currentLiteral .= $c;
196
-                        continue;
197
-                    }
198
-                    if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
199
-                        // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char");                    
200
-                        // peek at the next char.
201
-                        switch($this->pattern{$this->i}) {
202
-                            case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR:
203
-                                // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char");                    
204
-                                $this->currentLiteral .= $c;
205
-                                $this->i++; // move pointer
206
-                                break;
207
-                            case 'n':
208
-                                // LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'");                            
209
-                                $this->currentLiteral .= LOG4PHP_LINE_SEP;
210
-                                $this->i++; // move pointer
211
-                                break;
212
-                            default:
213
-                                if(strlen($this->currentLiteral) != 0) {
214
-                                    $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
215
-                                    LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
216
-                                }
217
-                                $this->currentLiteral = $c;
218
-                                $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE;
219
-                                $this->formattingInfo->reset();
220
-                        }
221
-                    } else {
222
-                        $this->currentLiteral .= $c;
223
-                    }
224
-                    break;
225
-              case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE:
226
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'");              
227
-                	$this->currentLiteral .= $c;
228
-                	switch($c) {
229
-                    	case '-':
230
-                            $this->formattingInfo->leftAlign = true;
231
-                            break;
232
-                    	case '.':
233
-                            $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
234
-	                        break;
235
-                    	default:
236
-                            if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
237
-                        	    $this->formattingInfo->min = ord($c) - ord('0');
238
-                        	    $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE;
239
-                            } else {
240
-                                $this->finalizeConverter($c);
241
-                            }
242
-                  	} // switch
243
-                    break;
244
-              case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE:
245
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'");              
246
-	                $this->currentLiteral .= $c;
247
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
248
-                        $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0'));
249
-                	} elseif ($c == '.') {
250
-                        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
251
-                    } else {
252
-                    	$this->finalizeConverter($c);
253
-                	}
254
-                	break;
255
-              case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE:
256
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'");              
257
-                	$this->currentLiteral .= $c;
258
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
259
-                        $this->formattingInfo->max = ord($c) - ord('0');
260
-	                    $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE;
261
-                    } else {
262
-                	  LoggerLog::warn("LoggerPatternParser::parse() Error occured in position {$this->i}. Was expecting digit, instead got char \"{$c}\".");
263
-	                  $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
264
-                    }
265
-                	break;
266
-              case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE:
267
-                    // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'");              
268
-                	$this->currentLiteral .= $c;
269
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
270
-                        $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
271
-	                } else {
272
-                	  $this->finalizeConverter($c);
273
-                      $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
274
-	                }
275
-                	break;
276
-            } // switch
277
-        } // while
278
-        if(strlen($this->currentLiteral) != 0) {
279
-            $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
280
-            // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
281
-        }
282
-        return $this->head;
283
-    }
190
+			switch($this->state) {
191
+				case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE:
192
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'");
193
+					// In literal state, the last char is always a literal.
194
+					if($this->i == $this->patternLength) {
195
+						$this->currentLiteral .= $c;
196
+						continue;
197
+					}
198
+					if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
199
+						// LoggerLog::debug("LoggerPatternParser::parse() char is an escape char");                    
200
+						// peek at the next char.
201
+						switch($this->pattern{$this->i}) {
202
+							case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR:
203
+								// LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char");                    
204
+								$this->currentLiteral .= $c;
205
+								$this->i++; // move pointer
206
+								break;
207
+							case 'n':
208
+								// LoggerLog::debug("LoggerPatternParser::parse() next char is 'n'");                            
209
+								$this->currentLiteral .= LOG4PHP_LINE_SEP;
210
+								$this->i++; // move pointer
211
+								break;
212
+							default:
213
+								if(strlen($this->currentLiteral) != 0) {
214
+									$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
215
+									LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
216
+								}
217
+								$this->currentLiteral = $c;
218
+								$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE;
219
+								$this->formattingInfo->reset();
220
+						}
221
+					} else {
222
+						$this->currentLiteral .= $c;
223
+					}
224
+					break;
225
+			  case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE:
226
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'");              
227
+					$this->currentLiteral .= $c;
228
+					switch($c) {
229
+						case '-':
230
+							$this->formattingInfo->leftAlign = true;
231
+							break;
232
+						case '.':
233
+							$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
234
+							break;
235
+						default:
236
+							if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
237
+								$this->formattingInfo->min = ord($c) - ord('0');
238
+								$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE;
239
+							} else {
240
+								$this->finalizeConverter($c);
241
+							}
242
+				  	} // switch
243
+					break;
244
+			  case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE:
245
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'");              
246
+					$this->currentLiteral .= $c;
247
+					if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
248
+						$this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0'));
249
+					} elseif ($c == '.') {
250
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
251
+					} else {
252
+						$this->finalizeConverter($c);
253
+					}
254
+					break;
255
+			  case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE:
256
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'");              
257
+					$this->currentLiteral .= $c;
258
+					if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
259
+						$this->formattingInfo->max = ord($c) - ord('0');
260
+						$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE;
261
+					} else {
262
+					  LoggerLog::warn("LoggerPatternParser::parse() Error occured in position {$this->i}. Was expecting digit, instead got char \"{$c}\".");
263
+					  $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
264
+					}
265
+					break;
266
+			  case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE:
267
+					// LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'");              
268
+					$this->currentLiteral .= $c;
269
+					if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
270
+						$this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
271
+					} else {
272
+					  $this->finalizeConverter($c);
273
+					  $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
274
+					}
275
+					break;
276
+			} // switch
277
+		} // while
278
+		if(strlen($this->currentLiteral) != 0) {
279
+			$this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
280
+			// LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
281
+		}
282
+		return $this->head;
283
+	}
284 284
 
285
-    public function finalizeConverter($c)
286
-    {
287
-        LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'");    
285
+	public function finalizeConverter($c)
286
+	{
287
+		LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'");    
288 288
 
289
-        $pc = null;
290
-        switch($c) {
291
-            case 'c':
292
-                $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
293
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter.");
294
-                $this->currentLiteral = '';
295
-                break;
296
-            case 'C':
297
-                $pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
298
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() CLASSNAME converter.");
299
-                $this->currentLiteral = '';
300
-                break;
301
-            case 'd':
302
-                $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
303
-                $dOpt = $this->extractOption();
289
+		$pc = null;
290
+		switch($c) {
291
+			case 'c':
292
+				$pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
293
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter.");
294
+				$this->currentLiteral = '';
295
+				break;
296
+			case 'C':
297
+				$pc = new LoggerClassNamePatternConverter($this->formattingInfo, $this->extractPrecisionOption());
298
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() CLASSNAME converter.");
299
+				$this->currentLiteral = '';
300
+				break;
301
+			case 'd':
302
+				$dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
303
+				$dOpt = $this->extractOption();
304 304
 
305
-                if($dOpt !== null)
306
-	                $dateFormatStr = $dOpt;
305
+				if($dOpt !== null)
306
+					$dateFormatStr = $dOpt;
307 307
                     
308
-                if ($dateFormatStr == 'ISO8601') {
309
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
310
-                } elseif($dateFormatStr == 'ABSOLUTE') {
311
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
312
-                } elseif($dateFormatStr == 'DATE') {
313
-                    $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
314
-                } else {
315
-                    $df = $dateFormatStr;
316
-                    if ($df === null) {
317
-                        $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
318
-                    }
319
-	            }
320
-                $pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
321
-                $this->currentLiteral = '';
322
-                break;
323
-            case 'F':
324
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER);
325
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() File name converter.");
326
-                //formattingInfo.dump();
327
-                $this->currentLiteral = '';
328
-                break;
329
-            case 'l':
330
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER);
331
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() Location converter.");
332
-                //formattingInfo.dump();
333
-                $this->currentLiteral = '';
334
-                break;
335
-            case 'L':
336
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER);
337
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() LINE NUMBER converter.");
338
-                //formattingInfo.dump();
339
-                $this->currentLiteral = '';
340
-                break;
341
-            case 'm':
342
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER);
343
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() MESSAGE converter.");
344
-                //formattingInfo.dump();
345
-                $this->currentLiteral = '';
346
-                break;
347
-            case 'M':
348
-                $pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER);
349
-                //LogLog.debug("METHOD converter.");
350
-                //formattingInfo.dump();
351
-                $this->currentLiteral = '';
352
-                break;
353
-            case 'p':
354
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER);
355
-                //LogLog.debug("LEVEL converter.");
356
-                //formattingInfo.dump();
357
-                $this->currentLiteral = '';
358
-                break;
359
-            case 'r':
360
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER);
361
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() RELATIVE TIME converter.");
362
-                //formattingInfo.dump();
363
-                $this->currentLiteral = '';
364
-                break;
365
-            case 't':
366
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER);
367
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() THREAD converter.");
368
-                //formattingInfo.dump();
369
-                $this->currentLiteral = '';
370
-                break;
371
-            case 'u':
372
-                if($this->i < $this->patternLength) {
373
-	                $cNext = $this->pattern{$this->i};
374
-                    if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) {
375
-	                    $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
376
-                        LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}].");
377
-	                    // formattingInfo.dump();
378
-                        $this->currentLiteral = '';
379
-	                    $this->i++;
380
-	                } else {
381
-                        LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char '{$cNext}' at position {$this->i}.");
382
-                    }
383
-                }
384
-                break;
385
-            case 'x':
386
-                $pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER);
387
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() NDC converter.");
388
-                $this->currentLiteral = '';
389
-                break;
308
+				if ($dateFormatStr == 'ISO8601') {
309
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
310
+				} elseif($dateFormatStr == 'ABSOLUTE') {
311
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
312
+				} elseif($dateFormatStr == 'DATE') {
313
+					$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
314
+				} else {
315
+					$df = $dateFormatStr;
316
+					if ($df === null) {
317
+						$df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
318
+					}
319
+				}
320
+				$pc = new LoggerDatePatternConverter($this->formattingInfo, $df);
321
+				$this->currentLiteral = '';
322
+				break;
323
+			case 'F':
324
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER);
325
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() File name converter.");
326
+				//formattingInfo.dump();
327
+				$this->currentLiteral = '';
328
+				break;
329
+			case 'l':
330
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER);
331
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() Location converter.");
332
+				//formattingInfo.dump();
333
+				$this->currentLiteral = '';
334
+				break;
335
+			case 'L':
336
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER);
337
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() LINE NUMBER converter.");
338
+				//formattingInfo.dump();
339
+				$this->currentLiteral = '';
340
+				break;
341
+			case 'm':
342
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER);
343
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() MESSAGE converter.");
344
+				//formattingInfo.dump();
345
+				$this->currentLiteral = '';
346
+				break;
347
+			case 'M':
348
+				$pc = new LoggerLocationPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER);
349
+				//LogLog.debug("METHOD converter.");
350
+				//formattingInfo.dump();
351
+				$this->currentLiteral = '';
352
+				break;
353
+			case 'p':
354
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER);
355
+				//LogLog.debug("LEVEL converter.");
356
+				//formattingInfo.dump();
357
+				$this->currentLiteral = '';
358
+				break;
359
+			case 'r':
360
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER);
361
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() RELATIVE TIME converter.");
362
+				//formattingInfo.dump();
363
+				$this->currentLiteral = '';
364
+				break;
365
+			case 't':
366
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER);
367
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() THREAD converter.");
368
+				//formattingInfo.dump();
369
+				$this->currentLiteral = '';
370
+				break;
371
+			case 'u':
372
+				if($this->i < $this->patternLength) {
373
+					$cNext = $this->pattern{$this->i};
374
+					if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) {
375
+						$pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
376
+						LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}].");
377
+						// formattingInfo.dump();
378
+						$this->currentLiteral = '';
379
+						$this->i++;
380
+					} else {
381
+						LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char '{$cNext}' at position {$this->i}.");
382
+					}
383
+				}
384
+				break;
385
+			case 'x':
386
+				$pc = new LoggerBasicPatternConverter($this->formattingInfo, LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER);
387
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() NDC converter.");
388
+				$this->currentLiteral = '';
389
+				break;
390 390
 
391
-            case 'X':
392
-                $xOpt = $this->extractOption();
393
-                $pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
394
-                LoggerLog::debug("LoggerPatternParser::finalizeConverter() MDC converter.");
395
-                $this->currentLiteral = '';
396
-                break;
397
-            default:
398
-                LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char [$c] at position {$this->i} in conversion pattern.");
399
-                $pc = new LoggerLiteralPatternConverter($this->currentLiteral);
400
-                $this->currentLiteral = '';
401
-        }
402
-        $this->addConverter($pc);
403
-    }
391
+			case 'X':
392
+				$xOpt = $this->extractOption();
393
+				$pc = new LoggerMDCPatternConverter($this->formattingInfo, $xOpt);
394
+				LoggerLog::debug("LoggerPatternParser::finalizeConverter() MDC converter.");
395
+				$this->currentLiteral = '';
396
+				break;
397
+			default:
398
+				LoggerLog::warn("LoggerPatternParser::finalizeConverter() Unexpected char [$c] at position {$this->i} in conversion pattern.");
399
+				$pc = new LoggerLiteralPatternConverter($this->currentLiteral);
400
+				$this->currentLiteral = '';
401
+		}
402
+		$this->addConverter($pc);
403
+	}
404 404
 
405
-    public function addConverter($pc)
406
-    {
407
-        $this->currentLiteral = '';
408
-        // Add the pattern converter to the list.
409
-        $this->addToList($pc);
410
-        // Next pattern is assumed to be a literal.
411
-        $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
412
-        // Reset formatting info
413
-        $this->formattingInfo->reset();
414
-    }
405
+	public function addConverter($pc)
406
+	{
407
+		$this->currentLiteral = '';
408
+		// Add the pattern converter to the list.
409
+		$this->addToList($pc);
410
+		// Next pattern is assumed to be a literal.
411
+		$this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
412
+		// Reset formatting info
413
+		$this->formattingInfo->reset();
414
+	}
415 415
 }
416 416
 
417 417
 ?>
418 418
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -42,30 +42,30 @@  discard block
 block discarded – undo
42 42
 require_once(LOG4PHP_DIR . '/helpers/LoggerPatternConverter.php');
43 43
 require_once(LOG4PHP_DIR . '/LoggerLog.php');
44 44
 
45
-define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR',         '%');
45
+define('LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR', '%');
46 46
 
47
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE',       0);
48
-define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE',     1);
49
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE',         2);
50
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE',           3);
51
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE',           4);
52
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE',           5);
47
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE', 0);
48
+define('LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE', 1);
49
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MINUS_STATE', 2);
50
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE', 3);
51
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE', 4);
52
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE', 5);
53 53
 
54
-define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER',         1000);
55
-define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER',       1001);
56
-define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER',        1002);
57
-define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER',         1003);
58
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER',         1004);
54
+define('LOG4PHP_LOGGER_PATTERN_PARSER_FULL_LOCATION_CONVERTER', 1000);
55
+define('LOG4PHP_LOGGER_PATTERN_PARSER_METHOD_LOCATION_CONVERTER', 1001);
56
+define('LOG4PHP_LOGGER_PATTERN_PARSER_CLASS_LOCATION_CONVERTER', 1002);
57
+define('LOG4PHP_LOGGER_PATTERN_PARSER_FILE_LOCATION_CONVERTER', 1003);
58
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LINE_LOCATION_CONVERTER', 1004);
59 59
 
60
-define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER',         2000);
61
-define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER',                2001);
62
-define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER',                 2002);
63
-define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER',                   2003);
64
-define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER',               2004);
60
+define('LOG4PHP_LOGGER_PATTERN_PARSER_RELATIVE_TIME_CONVERTER', 2000);
61
+define('LOG4PHP_LOGGER_PATTERN_PARSER_THREAD_CONVERTER', 2001);
62
+define('LOG4PHP_LOGGER_PATTERN_PARSER_LEVEL_CONVERTER', 2002);
63
+define('LOG4PHP_LOGGER_PATTERN_PARSER_NDC_CONVERTER', 2003);
64
+define('LOG4PHP_LOGGER_PATTERN_PARSER_MESSAGE_CONVERTER', 2004);
65 65
 
66
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601',    'Y-m-d H:i:s,u'); 
67
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE',   'H:i:s');
68
-define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE',       'd M Y H:i:s,u');
66
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601', 'Y-m-d H:i:s,u'); 
67
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE', 'H:i:s');
68
+define('LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE', 'd M Y H:i:s,u');
69 69
 
70 70
 /**
71 71
  * Most of the work of the {@link LoggerPatternLayout} class 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
         LoggerLog::debug("LoggerPatternParser::LoggerPatternParser() pattern='$pattern'");
119 119
     
120 120
         $this->pattern = $pattern;
121
-        $this->patternLength =  strlen($pattern);
121
+        $this->patternLength = strlen($pattern);
122 122
         $this->formattingInfo = new LoggerFormattingInfo();
123 123
         $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE;
124 124
     }
@@ -130,12 +130,12 @@  discard block
 block discarded – undo
130 130
     {
131 131
         // LoggerLog::debug("LoggerPatternParser::addToList()");
132 132
     
133
-        if($this->head === null) {
133
+        if ($this->head === null) {
134 134
             $this->head = $pc;
135
-            $this->tail =& $this->head;
135
+            $this->tail = & $this->head;
136 136
         } else {
137 137
             $this->tail->next = $pc;
138
-            $this->tail =& $this->tail->next;
138
+            $this->tail = & $this->tail->next;
139 139
         }
140 140
     }
141 141
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
      */
145 145
     public function extractOption()
146 146
     {
147
-        if(($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) {
148
-            $end = strpos($this->pattern, '}' , $this->i);
147
+        if (($this->i < $this->patternLength) && ($this->pattern{$this->i} == '{')) {
148
+            $end = strpos($this->pattern, '}', $this->i);
149 149
             if ($end !== false) {
150 150
                 $r = substr($this->pattern, ($this->i + 1), ($end - $this->i - 1));
151
-	            $this->i= $end + 1;
151
+	            $this->i = $end + 1;
152 152
         	    return $r;
153 153
             }
154 154
         }
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
         $r = 0;
166 166
         if ($opt !== null) {
167 167
             if (is_numeric($opt)) {
168
-    	        $r = (int)$opt;
169
-            	if($r <= 0) {
168
+    	        $r = (int) $opt;
169
+            	if ($r <= 0) {
170 170
             	    LoggerLog::warn("Precision option ({$opt}) isn't a positive integer.");
171 171
             	    $r = 0;
172 172
             	}
@@ -187,18 +187,18 @@  discard block
 block discarded – undo
187 187
         while ($this->i < $this->patternLength) {
188 188
             $c = $this->pattern{$this->i++};
189 189
 //            LoggerLog::debug("LoggerPatternParser::parse() char is now '$c' and currentLiteral is '{$this->currentLiteral}'");            
190
-            switch($this->state) {
190
+            switch ($this->state) {
191 191
                 case LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE:
192 192
                     // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_LITERAL_STATE'");
193 193
                     // In literal state, the last char is always a literal.
194
-                    if($this->i == $this->patternLength) {
194
+                    if ($this->i == $this->patternLength) {
195 195
                         $this->currentLiteral .= $c;
196 196
                         continue;
197 197
                     }
198
-                    if($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
198
+                    if ($c == LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR) {
199 199
                         // LoggerLog::debug("LoggerPatternParser::parse() char is an escape char");                    
200 200
                         // peek at the next char.
201
-                        switch($this->pattern{$this->i}) {
201
+                        switch ($this->pattern{$this->i}) {
202 202
                             case LOG4PHP_LOGGER_PATTERN_PARSER_ESCAPE_CHAR:
203 203
                                 // LoggerLog::debug("LoggerPatternParser::parse() next char is an escape char");                    
204 204
                                 $this->currentLiteral .= $c;
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
                                 $this->i++; // move pointer
211 211
                                 break;
212 212
                             default:
213
-                                if(strlen($this->currentLiteral) != 0) {
213
+                                if (strlen($this->currentLiteral) != 0) {
214 214
                                     $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
215 215
                                     LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
216 216
                                 }
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
               case LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE:
226 226
                     // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_CONVERTER_STATE'");              
227 227
                 	$this->currentLiteral .= $c;
228
-                	switch($c) {
228
+                	switch ($c) {
229 229
                     	case '-':
230 230
                             $this->formattingInfo->leftAlign = true;
231 231
                             break;
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
                             $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
234 234
 	                        break;
235 235
                     	default:
236
-                            if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
236
+                            if (ord($c) >= ord('0') && ord($c) <= ord('9')) {
237 237
                         	    $this->formattingInfo->min = ord($c) - ord('0');
238 238
                         	    $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE;
239 239
                             } else {
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
               case LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE:
245 245
                     // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MIN_STATE'");              
246 246
 	                $this->currentLiteral .= $c;
247
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
247
+                    if (ord($c) >= ord('0') && ord($c) <= ord('9')) {
248 248
                         $this->formattingInfo->min = ($this->formattingInfo->min * 10) + (ord(c) - ord('0'));
249 249
                 	} elseif ($c == '.') {
250 250
                         $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE;
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
               case LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE:
256 256
                     // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_DOT_STATE'");              
257 257
                 	$this->currentLiteral .= $c;
258
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
258
+                    if (ord($c) >= ord('0') && ord($c) <= ord('9')) {
259 259
                         $this->formattingInfo->max = ord($c) - ord('0');
260 260
 	                    $this->state = LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE;
261 261
                     } else {
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
               case LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE:
267 267
                     // LoggerLog::debug("LoggerPatternParser::parse() state is 'LOG4PHP_LOGGER_PATTERN_PARSER_MAX_STATE'");              
268 268
                 	$this->currentLiteral .= $c;
269
-                    if(ord($c) >= ord('0') && ord($c) <= ord('9')) {
269
+                    if (ord($c) >= ord('0') && ord($c) <= ord('9')) {
270 270
                         $this->formattingInfo->max = ($this->formattingInfo->max * 10) + (ord($c) - ord('0'));
271 271
 	                } else {
272 272
                 	  $this->finalizeConverter($c);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
                 	break;
276 276
             } // switch
277 277
         } // while
278
-        if(strlen($this->currentLiteral) != 0) {
278
+        if (strlen($this->currentLiteral) != 0) {
279 279
             $this->addToList(new LoggerLiteralPatternConverter($this->currentLiteral));
280 280
             // LoggerLog::debug("LoggerPatternParser::parse() Parsed LITERAL converter: \"{$this->currentLiteral}\".");
281 281
         }
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
         LoggerLog::debug("LoggerPatternParser::finalizeConverter() with char '$c'");    
288 288
 
289 289
         $pc = null;
290
-        switch($c) {
290
+        switch ($c) {
291 291
             case 'c':
292 292
                 $pc = new LoggerCategoryPatternConverter($this->formattingInfo, $this->extractPrecisionOption());
293 293
                 LoggerLog::debug("LoggerPatternParser::finalizeConverter() CATEGORY converter.");
@@ -302,14 +302,14 @@  discard block
 block discarded – undo
302 302
                 $dateFormatStr = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601; // ISO8601_DATE_FORMAT;
303 303
                 $dOpt = $this->extractOption();
304 304
 
305
-                if($dOpt !== null)
305
+                if ($dOpt !== null)
306 306
 	                $dateFormatStr = $dOpt;
307 307
                     
308 308
                 if ($dateFormatStr == 'ISO8601') {
309 309
                     $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ISO8601;
310
-                } elseif($dateFormatStr == 'ABSOLUTE') {
310
+                } elseif ($dateFormatStr == 'ABSOLUTE') {
311 311
                     $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_ABSOLUTE;
312
-                } elseif($dateFormatStr == 'DATE') {
312
+                } elseif ($dateFormatStr == 'DATE') {
313 313
                     $df = LOG4PHP_LOGGER_PATTERN_PARSER_DATE_FORMAT_DATE;
314 314
                 } else {
315 315
                     $df = $dateFormatStr;
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
                 $this->currentLiteral = '';
370 370
                 break;
371 371
             case 'u':
372
-                if($this->i < $this->patternLength) {
372
+                if ($this->i < $this->patternLength) {
373 373
 	                $cNext = $this->pattern{$this->i};
374
-                    if(ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) {
375
-	                    $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string)(ord($cNext) - ord('0')));
374
+                    if (ord($cNext) >= ord('0') && ord($cNext) <= ord('9')) {
375
+	                    $pc = new LoggerUserFieldPatternConverter($this->formattingInfo, (string) (ord($cNext) - ord('0')));
376 376
                         LoggerLog::debug("LoggerPatternParser::finalizeConverter() USER converter [{$cNext}].");
377 377
 	                    // formattingInfo.dump();
378 378
                         $this->currentLiteral = '';
Please login to merge, or discard this patch.
libraries/log4php.debug/LoggerRoot.php 2 patches
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -36,66 +36,66 @@
 block discarded – undo
36 36
  */
37 37
 class LoggerRoot extends Logger {
38 38
 
39
-    /**
40
-     * @var string name of logger 
41
-     */
42
-    public $name   = 'root';
39
+	/**
40
+	 * @var string name of logger 
41
+	 */
42
+	public $name   = 'root';
43 43
 
44
-    /**
45
-     * @var object must be null for LoggerRoot
46
-     */
47
-    public $parent = null;
44
+	/**
45
+	 * @var object must be null for LoggerRoot
46
+	 */
47
+	public $parent = null;
48 48
     
49 49
 
50
-    /**
51
-     * Constructor
52
-     *
53
-     * @param integer $level initial log level
54
-     */
55
-    public function LoggerRoot($level = null)
56
-    {
57
-        $this->Logger($this->name);
58
-        if ($level === null)
59
-            $level = LoggerLevel::getLevelAll();
60
-        $this->setLevel($level);
61
-    } 
50
+	/**
51
+	 * Constructor
52
+	 *
53
+	 * @param integer $level initial log level
54
+	 */
55
+	public function LoggerRoot($level = null)
56
+	{
57
+		$this->Logger($this->name);
58
+		if ($level === null)
59
+			$level = LoggerLevel::getLevelAll();
60
+		$this->setLevel($level);
61
+	} 
62 62
     
63
-    /**
64
-     * @return integer the level
65
-     */
66
-    public function getChainedLevel()
67
-    {
68
-        return $this->level;
69
-    } 
63
+	/**
64
+	 * @return integer the level
65
+	 */
66
+	public function getChainedLevel()
67
+	{
68
+		return $this->level;
69
+	} 
70 70
     
71
-    /**
72
-     * Setting a null value to the level of the root category may have catastrophic results.
73
-     * @param LoggerLevel $level
74
-     */
75
-    public function setLevel($level)
76
-    {
77
-        $this->level = $level;
78
-    }    
71
+	/**
72
+	 * Setting a null value to the level of the root category may have catastrophic results.
73
+	 * @param LoggerLevel $level
74
+	 */
75
+	public function setLevel($level)
76
+	{
77
+		$this->level = $level;
78
+	}    
79 79
  
80
-    /**
81
-     * Please use setLevel() instead.
82
-     * @param LoggerLevel $level
83
-     * @deprecated
84
-     */
85
-    public function setPriority($level)
86
-    {
87
-        $this->setLevel($level); 
88
-    }
80
+	/**
81
+	 * Please use setLevel() instead.
82
+	 * @param LoggerLevel $level
83
+	 * @deprecated
84
+	 */
85
+	public function setPriority($level)
86
+	{
87
+		$this->setLevel($level); 
88
+	}
89 89
     
90
-    /**
91
-     * Always returns false.
92
-     * Because LoggerRoot has no parents, it returns false.
93
-     * @param Logger $parent
94
-     * @return boolean
95
-     */
96
-    public function setParent($parent)
97
-    {
98
-        return false;
99
-    }  
90
+	/**
91
+	 * Always returns false.
92
+	 * Because LoggerRoot has no parents, it returns false.
93
+	 * @param Logger $parent
94
+	 * @return boolean
95
+	 */
96
+	public function setParent($parent)
97
+	{
98
+		return false;
99
+	}  
100 100
 }
101 101
 ?>
102 102
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@  discard block
 block discarded – undo
19 19
 /**
20 20
  * @ignore 
21 21
  */
22
-if (!defined('LOG4PHP_DIR')) define('LOG4PHP_DIR', dirname(__FILE__));
22
+if (!defined('LOG4PHP_DIR')) {
23
+	define('LOG4PHP_DIR', dirname(__FILE__));
24
+}
23 25
  
24 26
 /**
25 27
  */
@@ -55,8 +57,9 @@  discard block
 block discarded – undo
55 57
     public function LoggerRoot($level = null)
56 58
     {
57 59
         $this->Logger($this->name);
58
-        if ($level === null)
59
-            $level = LoggerLevel::getLevelAll();
60
+        if ($level === null) {
61
+                    $level = LoggerLevel::getLevelAll();
62
+        }
60 63
         $this->setLevel($level);
61 64
     } 
62 65
     
Please login to merge, or discard this patch.
libraries/log4php.debug/or/LoggerRendererMap.php 2 patches
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -39,146 +39,146 @@
 block discarded – undo
39 39
  */
40 40
 class LoggerRendererMap {
41 41
 
42
-    /**
43
-     * @var array
44
-     */
45
-    public $map;
42
+	/**
43
+	 * @var array
44
+	 */
45
+	public $map;
46 46
 
47
-    /**
48
-     * @var LoggerDefaultRenderer
49
-     */
50
-    public $defaultRenderer;
47
+	/**
48
+	 * @var LoggerDefaultRenderer
49
+	 */
50
+	public $defaultRenderer;
51 51
 
52
-    /**
53
-     * Constructor
54
-     */
55
-    public function LoggerRendererMap()
56
-    {
57
-        $this->map = array();
58
-        $this->defaultRenderer = new LoggerDefaultRenderer();
59
-    }
52
+	/**
53
+	 * Constructor
54
+	 */
55
+	public function LoggerRendererMap()
56
+	{
57
+		$this->map = array();
58
+		$this->defaultRenderer = new LoggerDefaultRenderer();
59
+	}
60 60
 
61
-    /**
62
-     * Add a renderer to a hierarchy passed as parameter.
63
-     * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
64
-     *
65
-     * @param LoggerHierarchy &$repository a logger repository.
66
-     * @param string &$renderedClassName
67
-     * @param string &$renderingClassName
68
-     * @static
69
-     */
70
-    public function addRenderer(&$repository, $renderedClassName, $renderingClassName)
71
-    {
72
-        LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
73
-        $renderer = LoggerObjectRenderer::factory($renderingClassName);
74
-        if($renderer === null) {
75
-            LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
76
-            return;
77
-        } else {
78
-            $repository->setRenderer($renderedClassName, $renderer);
79
-        }
80
-    }
61
+	/**
62
+	 * Add a renderer to a hierarchy passed as parameter.
63
+	 * Note that hierarchy must implement getRendererMap() and setRenderer() methods.
64
+	 *
65
+	 * @param LoggerHierarchy &$repository a logger repository.
66
+	 * @param string &$renderedClassName
67
+	 * @param string &$renderingClassName
68
+	 * @static
69
+	 */
70
+	public function addRenderer(&$repository, $renderedClassName, $renderingClassName)
71
+	{
72
+		LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
73
+		$renderer = LoggerObjectRenderer::factory($renderingClassName);
74
+		if($renderer === null) {
75
+			LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
76
+			return;
77
+		} else {
78
+			$repository->setRenderer($renderedClassName, $renderer);
79
+		}
80
+	}
81 81
 
82 82
 
83
-    /**
84
-     * Find the appropriate renderer for the class type of the
85
-     * <var>o</var> parameter. 
86
-     *
87
-     * This is accomplished by calling the {@link getByObject()} 
88
-     * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}. 
89
-     * Once a renderer is found, it is applied on the object <var>o</var> and 
90
-     * the result is returned as a string.
91
-     *
92
-     * @param mixed $o
93
-     * @return string 
94
-     */
95
-    public function findAndRender($o)
96
-    {
97
-        if($o === null) {
98
-            return null;
99
-        } else {
100
-            if (is_object($o)) {
101
-                $renderer = $this->getByObject($o);
102
-                if ($renderer !== null) {
103
-                    return $renderer->doRender($o);
104
-                } else {
105
-                    return null;
106
-                }
107
-            } else {
108
-                $renderer = $this->defaultRenderer;
109
-                return $renderer->doRender($o);
110
-            }
111
-        }
112
-    }
83
+	/**
84
+	 * Find the appropriate renderer for the class type of the
85
+	 * <var>o</var> parameter. 
86
+	 *
87
+	 * This is accomplished by calling the {@link getByObject()} 
88
+	 * method if <var>o</var> is object or using {@link LoggerDefaultRenderer}. 
89
+	 * Once a renderer is found, it is applied on the object <var>o</var> and 
90
+	 * the result is returned as a string.
91
+	 *
92
+	 * @param mixed $o
93
+	 * @return string 
94
+	 */
95
+	public function findAndRender($o)
96
+	{
97
+		if($o === null) {
98
+			return null;
99
+		} else {
100
+			if (is_object($o)) {
101
+				$renderer = $this->getByObject($o);
102
+				if ($renderer !== null) {
103
+					return $renderer->doRender($o);
104
+				} else {
105
+					return null;
106
+				}
107
+			} else {
108
+				$renderer = $this->defaultRenderer;
109
+				return $renderer->doRender($o);
110
+			}
111
+		}
112
+	}
113 113
 
114
-    /**
115
-     * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
116
-     * class of the object parameter.
117
-     * 
118
-     * @param mixed $o
119
-     * @return string
120
-     */
121
-    public function &getByObject($o)
122
-    {
123
-        return ($o === null) ? null : $this->getByClassName(get_class($o));
124
-    }
114
+	/**
115
+	 * Syntactic sugar method that calls {@link PHP_MANUAL#get_class} with the
116
+	 * class of the object parameter.
117
+	 * 
118
+	 * @param mixed $o
119
+	 * @return string
120
+	 */
121
+	public function &getByObject($o)
122
+	{
123
+		return ($o === null) ? null : $this->getByClassName(get_class($o));
124
+	}
125 125
 
126 126
 
127
-    /**
128
-     * Search the parents of <var>clazz</var> for a renderer. 
129
-     *
130
-     * The renderer closest in the hierarchy will be returned. If no
131
-     * renderers could be found, then the default renderer is returned.
132
-     *
133
-     * @param string $class
134
-     * @return LoggerObjectRenderer
135
-     */
136
-    public function &getByClassName($class)
137
-    {
138
-        $r = null;
139
-        for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
140
-            if (isset($this->map[$c])) {
141
-                return  $this->map[$c];
142
-            }
143
-        }
144
-        return $this->defaultRenderer;
145
-    }
127
+	/**
128
+	 * Search the parents of <var>clazz</var> for a renderer. 
129
+	 *
130
+	 * The renderer closest in the hierarchy will be returned. If no
131
+	 * renderers could be found, then the default renderer is returned.
132
+	 *
133
+	 * @param string $class
134
+	 * @return LoggerObjectRenderer
135
+	 */
136
+	public function &getByClassName($class)
137
+	{
138
+		$r = null;
139
+		for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
140
+			if (isset($this->map[$c])) {
141
+				return  $this->map[$c];
142
+			}
143
+		}
144
+		return $this->defaultRenderer;
145
+	}
146 146
 
147
-    /**
148
-     * @return LoggerDefaultRenderer
149
-     */
150
-    public function &getDefaultRenderer()
151
-    {
152
-        return $this->defaultRenderer;
153
-    }
147
+	/**
148
+	 * @return LoggerDefaultRenderer
149
+	 */
150
+	public function &getDefaultRenderer()
151
+	{
152
+		return $this->defaultRenderer;
153
+	}
154 154
 
155 155
 
156
-    public function clear()
157
-    {
158
-        $this->map = array();
159
-    }
156
+	public function clear()
157
+	{
158
+		$this->map = array();
159
+	}
160 160
 
161
-    /**
162
-     * Register a {@link LoggerObjectRenderer} for <var>clazz</var>.
163
-     * @param string $class
164
-     * @param LoggerObjectRenderer $or
165
-     */
166
-    public function put($class, $or)
167
-    {
168
-        $this->map[strtolower($class)] = $or;
169
-    }
161
+	/**
162
+	 * Register a {@link LoggerObjectRenderer} for <var>clazz</var>.
163
+	 * @param string $class
164
+	 * @param LoggerObjectRenderer $or
165
+	 */
166
+	public function put($class, $or)
167
+	{
168
+		$this->map[strtolower($class)] = $or;
169
+	}
170 170
     
171
-    /**
172
-     * @param string $class
173
-     * @return boolean
174
-     */
175
-    public function rendererExists($class)
176
-    {
177
-        $class = basename($class);
178
-        if (!class_exists($class)) {
179
-            @include_once(LOG4PHP_DIR ."/or/{$class}.php");
180
-        }
181
-        return class_exists($class);
182
-    }
171
+	/**
172
+	 * @param string $class
173
+	 * @return boolean
174
+	 */
175
+	public function rendererExists($class)
176
+	{
177
+		$class = basename($class);
178
+		if (!class_exists($class)) {
179
+			@include_once(LOG4PHP_DIR ."/or/{$class}.php");
180
+		}
181
+		return class_exists($class);
182
+	}
183 183
 }
184 184
 ?>
185 185
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
     {
72 72
         LoggerLog::debug("LoggerRendererMap::addRenderer() Rendering class: [{$renderingClassName}], Rendered class: [{$renderedClassName}].");
73 73
         $renderer = LoggerObjectRenderer::factory($renderingClassName);
74
-        if($renderer === null) {
74
+        if ($renderer === null) {
75 75
             LoggerLog::warn("LoggerRendererMap::addRenderer() Could not instantiate renderer [{$renderingClassName}].");
76 76
             return;
77 77
         } else {
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function findAndRender($o)
96 96
     {
97
-        if($o === null) {
97
+        if ($o === null) {
98 98
             return null;
99 99
         } else {
100 100
             if (is_object($o)) {
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
     public function &getByClassName($class)
137 137
     {
138 138
         $r = null;
139
-        for($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
139
+        for ($c = strtolower($class); !empty($c); $c = get_parent_class($c)) {
140 140
             if (isset($this->map[$c])) {
141 141
                 return  $this->map[$c];
142 142
             }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $class = basename($class);
178 178
         if (!class_exists($class)) {
179
-            @include_once(LOG4PHP_DIR ."/or/{$class}.php");
179
+            @include_once(LOG4PHP_DIR . "/or/{$class}.php");
180 180
         }
181 181
         return class_exists($class);
182 182
     }
Please login to merge, or discard this patch.