[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2019 The s9e Authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Plugins\Emoticons; 9 use ArrayAccess; 10 use Countable; 11 use Iterator; 12 use s9e\TextFormatter\Configurator\Helpers\ConfigHelper; 13 use s9e\TextFormatter\Configurator\Helpers\RegexpBuilder; 14 use s9e\TextFormatter\Configurator\Items\Regexp; 15 use s9e\TextFormatter\Configurator\JavaScript\RegexpConvertor; 16 use s9e\TextFormatter\Configurator\Traits\CollectionProxy; 17 use s9e\TextFormatter\Plugins\ConfiguratorBase; 18 use s9e\TextFormatter\Plugins\Emoticons\Configurator\EmoticonCollection; 19 use s9e\TextFormatter\Utils\XPath; 20 class Configurator extends ConfiguratorBase implements ArrayAccess, Countable, Iterator 21 { 22 use CollectionProxy; 23 protected $collection; 24 public $notAfter = ''; 25 public $notBefore = ''; 26 public $notIfCondition; 27 protected $onDuplicateAction = 'replace'; 28 protected $tagName = 'E'; 29 protected function setUp() 30 { 31 $this->collection = new EmoticonCollection; 32 if (!$this->configurator->tags->exists($this->tagName)) 33 $this->configurator->tags->add($this->tagName); 34 } 35 public function finalize() 36 { 37 $tag = $this->getTag(); 38 if (!isset($tag->template)) 39 $tag->template = $this->getTemplate(); 40 } 41 public function asConfig() 42 { 43 if (!\count($this->collection)) 44 return; 45 $codes = \array_keys(\iterator_to_array($this->collection)); 46 $regexp = '/'; 47 if ($this->notAfter !== '') 48 $regexp .= '(?<!' . $this->notAfter . ')'; 49 $regexp .= RegexpBuilder::fromList($codes); 50 if ($this->notBefore !== '') 51 $regexp .= '(?!' . $this->notBefore . ')'; 52 $regexp .= '/S'; 53 if (\preg_match('/\\\\[pP](?>\\{\\^?\\w+\\}|\\w\\w?)/', $regexp)) 54 $regexp .= 'u'; 55 $regexp = \preg_replace('/(?<!\\\\)((?>\\\\\\\\)*)\\(\\?:/', '$1(?>', $regexp); 56 $config = [ 57 'quickMatch' => $this->quickMatch, 58 'regexp' => $regexp, 59 'tagName' => $this->tagName 60 ]; 61 if ($this->notAfter !== '') 62 { 63 $lpos = 6 + \strlen($this->notAfter); 64 $rpos = \strrpos($regexp, '/'); 65 $jsRegexp = RegexpConvertor::toJS('/' . \substr($regexp, $lpos, $rpos - $lpos) . '/', \true); 66 $config['regexp'] = new Regexp($regexp); 67 $config['regexp']->setJS($jsRegexp); 68 $config['notAfter'] = new Regexp('/' . $this->notAfter . '/'); 69 } 70 if ($this->quickMatch === \false) 71 $config['quickMatch'] = ConfigHelper::generateQuickMatchFromList($codes); 72 return $config; 73 } 74 public function getJSHints() 75 { 76 return ['EMOTICONS_NOT_AFTER' => (int) !empty($this->notAfter)]; 77 } 78 public function getTemplate() 79 { 80 $xsl = '<xsl:choose>'; 81 if (!empty($this->notIfCondition)) 82 $xsl .= '<xsl:when test="' . \htmlspecialchars($this->notIfCondition) . '"><xsl:value-of select="."/></xsl:when><xsl:otherwise><xsl:choose>'; 83 foreach ($this->collection as $code => $template) 84 $xsl .= '<xsl:when test=".=' . \htmlspecialchars(XPath::export($code)) . '">' 85 . $template 86 . '</xsl:when>'; 87 $xsl .= '<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>'; 88 $xsl .= '</xsl:choose>'; 89 if (!empty($this->notIfCondition)) 90 $xsl .= '</xsl:otherwise></xsl:choose>'; 91 return $xsl; 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |