Verzeichnisstruktur phpBB-3.2.0
- Veröffentlicht
- 06.01.2017
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ConfiguratorBase.php
001 <?php
002
003 /*
004 * @package s9e\TextFormatter
005 * @copyright Copyright (c) 2010-2016 The s9e Authors
006 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
007 */
008 namespace s9e\TextFormatter\Plugins;
009 use InvalidArgumentException;
010 use RuntimeException;
011 use s9e\TextFormatter\Configurator;
012 use s9e\TextFormatter\Configurator\ConfigProvider;
013 use s9e\TextFormatter\Configurator\Helpers\ConfigHelper;
014 use s9e\TextFormatter\Configurator\JavaScript\Code;
015 use s9e\TextFormatter\Configurator\Validators\AttributeName;
016 use s9e\TextFormatter\Configurator\Validators\TagName;
017 abstract class ConfiguratorBase implements ConfigProvider
018 {
019 protected $configurator;
020 protected $quickMatch = \false;
021 protected $regexpLimit = 10000;
022 final public function __construct(Configurator $configurator, array $overrideProps = array())
023 {
024 $this->configurator = $configurator;
025 foreach ($overrideProps as $k => $v)
026 {
027 $methodName = 'set' . \ucfirst($k);
028 if (\method_exists($this, $methodName))
029 $this->$methodName($v);
030 elseif (\property_exists($this, $k))
031 $this->$k = $v;
032 else
033 throw new RuntimeException("Unknown property '" . $k . "'");
034 }
035 $this->setUp();
036 }
037 protected function setUp()
038 {
039 }
040 public function finalize()
041 {
042 }
043 public function asConfig()
044 {
045 $properties = \get_object_vars($this);
046 unset($properties['configurator']);
047 return ConfigHelper::toArray($properties);
048 }
049 final public function getBaseProperties()
050 {
051 $config = array(
052 'className' => \preg_replace('/Configurator$/', 'Parser', \get_class($this)),
053 'quickMatch' => $this->quickMatch,
054 'regexpLimit' => $this->regexpLimit
055 );
056 $js = $this->getJSParser();
057 if (isset($js))
058 $config['js'] = new Code($js);
059 return $config;
060 }
061 public function getJSHints()
062 {
063 return array();
064 }
065 public function getJSParser()
066 {
067 $className = \get_class($this);
068 if (\strpos($className, 's9e\\TextFormatter\\Plugins\\') === 0)
069 {
070 $p = \explode('\\', $className);
071 $pluginName = $p[3];
072 $filepath = __DIR__ . '/' . $pluginName . '/Parser.js';
073 if (\file_exists($filepath))
074 return \file_get_contents($filepath);
075 }
076 return \null;
077 }
078 public function getTag()
079 {
080 if (!isset($this->tagName))
081 throw new RuntimeException('No tag associated with this plugin');
082 return $this->configurator->tags[$this->tagName];
083 }
084 public function disableQuickMatch()
085 {
086 $this->quickMatch = \false;
087 }
088 protected function setAttrName($attrName)
089 {
090 if (!\property_exists($this, 'attrName'))
091 throw new RuntimeException("Unknown property 'attrName'");
092 $this->attrName = AttributeName::normalize($attrName);
093 }
094 public function setQuickMatch($quickMatch)
095 {
096 if (!\is_string($quickMatch))
097 throw new InvalidArgumentException('quickMatch must be a string');
098 $this->quickMatch = $quickMatch;
099 }
100 public function setRegexpLimit($limit)
101 {
102 $limit = (int) $limit;
103 if ($limit < 1)
104 throw new InvalidArgumentException('regexpLimit must be a number greater than 0');
105 $this->regexpLimit = $limit;
106 }
107 protected function setTagName($tagName)
108 {
109 if (!\property_exists($this, 'tagName'))
110 throw new RuntimeException("Unknown property 'tagName'");
111 $this->tagName = TagName::normalize($tagName);
112 }
113 }