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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Configurator.php

Zuletzt modifiziert: 09.10.2024, 12:58 - Dateigröße: 2.67 KiB


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\Keywords;
009  use s9e\TextFormatter\Configurator\Collections\NormalizedList;
010  use s9e\TextFormatter\Configurator\Helpers\RegexpBuilder;
011  use s9e\TextFormatter\Configurator\Items\Regexp;
012  use s9e\TextFormatter\Configurator\Traits\CollectionProxy;
013  use s9e\TextFormatter\Plugins\ConfiguratorBase;
014  class Configurator extends ConfiguratorBase
015  {
016      public function __call($methodName, $args)
017      {
018          return \call_user_func_array(array($this->collection, $methodName), $args);
019      }
020      public function offsetExists($offset)
021      {
022          return isset($this->collection[$offset]);
023      }
024      public function offsetGet($offset)
025      {
026          return $this->collection[$offset];
027      }
028      public function offsetSet($offset, $value)
029      {
030          $this->collection[$offset] = $value;
031      }
032      public function offsetUnset($offset)
033      {
034          unset($this->collection[$offset]);
035      }
036      public function count()
037      {
038          return \count($this->collection);
039      }
040      public function current()
041      {
042          return $this->collection->current();
043      }
044      public function key()
045      {
046          return $this->collection->key();
047      }
048      public function next()
049      {
050          return $this->collection->next();
051      }
052      public function rewind()
053      {
054          $this->collection->rewind();
055      }
056      public function valid()
057      {
058          return $this->collection->valid();
059      }
060      protected $attrName = 'value';
061      public $caseSensitive = \true;
062      protected $collection;
063      public $onlyFirst = \false;
064      protected $tagName = 'KEYWORD';
065      protected function setUp()
066      {
067          $this->collection = new NormalizedList;
068          $this->configurator->tags->add($this->tagName)->attributes->add($this->attrName);
069      }
070      public function asConfig()
071      {
072          if (!\count($this->collection))
073              return;
074          $config = array(
075              'attrName' => $this->attrName,
076              'tagName'  => $this->tagName
077          );
078          if (!empty($this->onlyFirst))
079              $config['onlyFirst'] = $this->onlyFirst;
080          $keywords = \array_unique(\iterator_to_array($this->collection));
081          \sort($keywords);
082          $groups   = array();
083          $groupKey = 0;
084          $groupLen = 0;
085          foreach ($keywords as $keyword)
086          {
087              $keywordLen  = 4 + \strlen($keyword);
088              $groupLen   += $keywordLen;
089              if ($groupLen > 30000)
090              {
091                  $groupLen = $keywordLen;
092                  ++$groupKey;
093              }
094              $groups[$groupKey][] = $keyword;
095          }
096          foreach ($groups as $keywords)
097          {
098              $regexp = RegexpBuilder::fromList(
099                  $keywords,
100                  array('caseInsensitive' => !$this->caseSensitive)
101              );
102              $regexp = '/\\b' . $regexp . '\\b/S';
103              if (!$this->caseSensitive)
104                  $regexp .= 'i';
105              if (\preg_match('/[^[:ascii:]]/', $regexp))
106                  $regexp .= 'u';
107              $config['regexps'][] = new Regexp($regexp, \true);
108          }
109          return $config;
110      }
111  }