collection = new EmoticonCollection; if (!$this->configurator->tags->exists($this->tagName)) $this->configurator->tags->add($this->tagName); } public function finalize() { $tag = $this->getTag(); if (!isset($tag->template)) $tag->template = $this->getTemplate(); } public function asConfig() { if (!\count($this->collection)) return; $codes = \array_keys(\iterator_to_array($this->collection)); $regexp = '/'; if ($this->notAfter !== '') $regexp .= '(?notAfter . ')'; $regexp .= RegexpBuilder::fromList($codes); if ($this->notBefore !== '') $regexp .= '(?!' . $this->notBefore . ')'; $regexp .= '/S'; if (\preg_match('/\\\\[pP](?>\\{\\^?\\w+\\}|\\w\\w?)/', $regexp)) $regexp .= 'u'; $regexp = \preg_replace('/(?\\\\\\\\)*)\\(\\?:/', '$1(?>', $regexp); $config = [ 'quickMatch' => $this->quickMatch, 'regexp' => $regexp, 'tagName' => $this->tagName ]; if ($this->notAfter !== '') { $lpos = 6 + \strlen($this->notAfter); $rpos = \strrpos($regexp, '/'); $jsRegexp = RegexpConvertor::toJS('/' . \substr($regexp, $lpos, $rpos - $lpos) . '/', \true); $config['regexp'] = new Regexp($regexp); $config['regexp']->setJS($jsRegexp); $config['notAfter'] = new Regexp('/' . $this->notAfter . '/'); } if ($this->quickMatch === \false) $config['quickMatch'] = ConfigHelper::generateQuickMatchFromList($codes); return $config; } public function getJSHints() { return ['EMOTICONS_NOT_AFTER' => (int) !empty($this->notAfter)]; } public function getTemplate() { $xsl = ''; if (!empty($this->notIfCondition)) $xsl .= ''; foreach ($this->collection as $code => $template) $xsl .= '' . $template . ''; $xsl .= ''; $xsl .= ''; if (!empty($this->notIfCondition)) $xsl .= ''; return $xsl; } }