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: 5.95 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\Emoji;
009  use s9e\TextFormatter\Configurator\Helpers\ConfigHelper;
010  use s9e\TextFormatter\Configurator\Helpers\RegexpBuilder;
011  use s9e\TextFormatter\Configurator\Items\Regexp;
012  use s9e\TextFormatter\Plugins\ConfiguratorBase;
013  class Configurator extends ConfiguratorBase
014  {
015      protected $attrName = 'seq';
016      protected $aliases = array();
017      protected $forceImageSize = \true;
018      protected $imageSet = 'emojione';
019      protected $imageSize = 16;
020      protected $imageType = 'png';
021      protected $tagName = 'EMOJI';
022      protected $twemojiAliases = array(
023          '00a9'                    => 'a9',
024          '00ae'                    => 'ae',
025          '0023-20e3'               => '23-20e3',
026          '002a-20e3'               => '2a-20e3',
027          '0030-20e3'               => '30-20e3',
028          '0031-20e3'               => '31-20e3',
029          '0032-20e3'               => '32-20e3',
030          '0033-20e3'               => '33-20e3',
031          '0034-20e3'               => '34-20e3',
032          '0035-20e3'               => '35-20e3',
033          '0036-20e3'               => '36-20e3',
034          '0037-20e3'               => '37-20e3',
035          '0038-20e3'               => '38-20e3',
036          '0039-20e3'               => '39-20e3',
037          '1f3f3-1f308'             => '1f3f3-fe0f-200d-1f308',
038          '1f3f4-2620'              => '1f3f4-200d-2620-fe0f',
039          '1f441-1f5e8'             => '1f441-200d-1f5e8',
040          '1f468-1f468-1f466-1f466' => '1f468-200d-1f468-200d-1f466-200d-1f466',
041          '1f468-1f468-1f466'       => '1f468-200d-1f468-200d-1f466',
042          '1f468-1f468-1f467-1f466' => '1f468-200d-1f468-200d-1f467-200d-1f466',
043          '1f468-1f468-1f467-1f467' => '1f468-200d-1f468-200d-1f467-200d-1f467',
044          '1f468-1f468-1f467'       => '1f468-200d-1f468-200d-1f467',
045          '1f468-1f469-1f466-1f466' => '1f468-200d-1f469-200d-1f466-200d-1f466',
046          '1f468-1f469-1f466'       => '1f468-200d-1f469-200d-1f466',
047          '1f468-1f469-1f467-1f466' => '1f468-200d-1f469-200d-1f467-200d-1f466',
048          '1f468-1f469-1f467-1f467' => '1f468-200d-1f469-200d-1f467-200d-1f467',
049          '1f468-1f469-1f467'       => '1f468-200d-1f469-200d-1f467',
050          '1f468-2764-1f468'        => '1f468-200d-2764-fe0f-200d-1f468',
051          '1f468-2764-1f48b-1f468'  => '1f468-200d-2764-fe0f-200d-1f48b-200d-1f468',
052          '1f469-1f469-1f466-1f466' => '1f469-200d-1f469-200d-1f466-200d-1f466',
053          '1f469-1f469-1f466'       => '1f469-200d-1f469-200d-1f466',
054          '1f469-1f469-1f467-1f466' => '1f469-200d-1f469-200d-1f467-200d-1f466',
055          '1f469-1f469-1f467-1f467' => '1f469-200d-1f469-200d-1f467-200d-1f467',
056          '1f469-1f469-1f467'       => '1f469-200d-1f469-200d-1f467',
057          '1f469-2764-1f468'        => '1f469-200d-2764-fe0f-200d-1f468',
058          '1f469-2764-1f469'        => '1f469-200d-2764-fe0f-200d-1f469',
059          '1f469-2764-1f48b-1f468'  => '1f469-200d-2764-fe0f-200d-1f48b-200d-1f468',
060          '1f469-2764-1f48b-1f469'  => '1f469-200d-2764-fe0f-200d-1f48b-200d-1f469'
061      );
062      protected function setUp()
063      {
064          if (isset($this->configurator->tags[$this->tagName]))
065              return;
066          $tag = $this->configurator->tags->add($this->tagName);
067          $tag->attributes->add($this->attrName)->filterChain->append(
068              $this->configurator->attributeFilters['#identifier']
069          );
070          $this->resetTemplate();
071      }
072      public function addAlias($alias, $emoji)
073      {
074          $this->aliases[$alias] = $emoji;
075      }
076      public function forceImageSize()
077      {
078          $this->forceImageSize = \true;
079          $this->resetTemplate();
080      }
081      public function removeAlias($alias)
082      {
083          unset($this->aliases[$alias]);
084      }
085      public function omitImageSize()
086      {
087          $this->forceImageSize = \false;
088          $this->resetTemplate();
089      }
090      public function getAliases()
091      {
092          return $this->aliases;
093      }
094      public function setImageSize($size)
095      {
096          $this->imageSize = (int) $size;
097          $this->resetTemplate();
098      }
099      public function useEmojiOne()
100      {
101          $this->imageSet = 'emojione';
102          $this->resetTemplate();
103      }
104      public function usePNG()
105      {
106          $this->imageType = 'png';
107          $this->resetTemplate();
108      }
109      public function useSVG()
110      {
111          $this->imageType = 'svg';
112          $this->resetTemplate();
113      }
114      public function useTwemoji()
115      {
116          $this->imageSet = 'twemoji';
117          $this->resetTemplate();
118      }
119      public function asConfig()
120      {
121          $config = array(
122              'attrName' => $this->attrName,
123              'tagName'  => $this->tagName
124          );
125          if (!empty($this->aliases))
126          {
127              $aliases = \array_keys($this->aliases);
128              $regexp  = '/' . RegexpBuilder::fromList($aliases) . '/';
129              $config['aliases']       = $this->aliases;
130              $config['aliasesRegexp'] = new Regexp($regexp, \true);
131              $quickMatch = ConfigHelper::generateQuickMatchFromList($aliases);
132              if ($quickMatch !== \false)
133                  $config['aliasesQuickMatch'] = $quickMatch;
134          }
135          return $config;
136      }
137      public function getJSHints()
138      {
139          $quickMatch = ConfigHelper::generateQuickMatchFromList(\array_keys($this->aliases));
140          return array(
141              'EMOJI_HAS_ALIASES'          => !empty($this->aliases),
142              'EMOJI_HAS_ALIAS_QUICKMATCH' => ($quickMatch !== \false)
143          );
144      }
145      protected function getEmojiOneSrc()
146      {
147          $src  = '//cdn.jsdelivr.net/emojione/assets/' . $this->imageType . '/';
148          $src .= '<xsl:value-of select="@seq"/>';
149          $src .= '.' . $this->imageType;
150          return $src;
151      }
152      protected function getTemplate()
153      {
154          $template = '<img alt="{.}" class="emoji" draggable="false"';
155          if ($this->forceImageSize)
156              $template .= ' width="' . $this->imageSize . '" height="' . $this->imageSize . '"';
157          $template .= '><xsl:attribute name="src">';
158          $template .= ($this->imageSet === 'emojione') ? $this->getEmojiOneSrc() :  $this->getTwemojiSrc();
159          $template .= '</xsl:attribute></img>';
160          return $template;
161      }
162      protected function getTwemojiSrc()
163      {
164          $src  = '//twemoji.maxcdn.com/2/';
165          $src .= ($this->imageType === 'svg') ? 'svg' : '72x72';
166          $src .= '/<xsl:choose>';
167          foreach ($this->twemojiAliases as $seq => $filename)
168              $src .= '<xsl:when test="@seq=\'' . $seq . '\'">' . $filename . '</xsl:when>';
169          $src .= '<xsl:otherwise><xsl:value-of select="@seq"/></xsl:otherwise></xsl:choose>';
170          $src .= '.' . $this->imageType;
171          return $src;
172      }
173      protected function resetTemplate()
174      {
175          $this->getTag()->template = $this->getTemplate();
176      }
177  }