1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xoops\Core\Text\Sanitizer;
13:
14: use Xoops\Core\Text\Sanitizer;
15:
16: /**
17: * Configuration for Sanitizer Filters and Extensions
18: *
19: * @category Sanitizer
20: * @package Xoops\Core\Text
21: * @author Richrd Griffith <richard@geekwright.com>
22: * @copyright 2015 XOOPS Project (http://xoops.org)
23: * @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html)
24: * @link http://xoops.org
25: */
26: abstract class SanitizerConfigurable
27: {
28: /**
29: * @var array default configuration values
30: */
31: protected static $defaultConfiguration = [];
32:
33: /**
34: * get the default configuration for a component
35: *
36: * @return array [componentName] => [ ... configuration items ... ]
37: */
38: final public static function getDefaultConfig()
39: {
40: $fullName = get_called_class();
41: $shortName = ($pos = strrpos($fullName, '\\')) ? substr($fullName, $pos + 1) : $fullName;
42: $defaults = static::$defaultConfiguration;
43: $defaults['configured_class'] = $fullName;
44: $defaults['type'] = 'extension';
45: if (is_a($defaults['configured_class'], 'Xoops\Core\Text\Sanitizer\FilterAbstract', true)) {
46: $defaults['type'] = 'filter';
47: } elseif (is_a($defaults['configured_class'], 'Xoops\Core\Text\Sanitizer', true)) {
48: $defaults['type'] = 'sanitizer';
49: }
50: if (!array_key_exists('enabled', $defaults)) {
51: $defaults['enabled'] = false;
52: }
53: $return[strtolower($shortName)] = $defaults;
54:
55: return $return;
56: }
57: }
58: