[ 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\HTMLElements; 9 use s9e\TextFormatter\Parser\Tag; 10 use s9e\TextFormatter\Plugins\ParserBase; 11 class Parser extends ParserBase 12 { 13 public function parse($text, array $matches) 14 { 15 foreach ($matches as $m) 16 { 17 $isEnd = (bool) ($text[$m[0][1] + 1] === '/'); 18 $pos = $m[0][1]; 19 $len = \strlen($m[0][0]); 20 $elName = \strtolower($m[2 - $isEnd][0]); 21 $tagName = (isset($this->config['aliases'][$elName][''])) 22 ? $this->config['aliases'][$elName][''] 23 : $this->config['prefix'] . ':' . $elName; 24 if ($isEnd) 25 { 26 $this->parser->addEndTag($tagName, $pos, $len); 27 continue; 28 } 29 $tag = (\preg_match('/(<\\S+|[\'"\\s])\\/>$/', $m[0][0])) 30 ? $this->parser->addTagPair($tagName, $pos, $len, $pos + $len, 0) 31 : $this->parser->addStartTag($tagName, $pos, $len); 32 $this->captureAttributes($tag, $elName, $m[3][0]); 33 } 34 } 35 protected function captureAttributes(Tag $tag, $elName, $str) 36 { 37 \preg_match_all( 38 '/[a-z][-a-z0-9]*(?>\\s*=\\s*(?>"[^"]*"|\'[^\']*\'|[^\\s"\'=<>`]+))?/i', 39 $str, 40 $attrMatches 41 ); 42 foreach ($attrMatches[0] as $attrMatch) 43 { 44 $pos = \strpos($attrMatch, '='); 45 if ($pos === \false) 46 { 47 $pos = \strlen($attrMatch); 48 $attrMatch .= '=' . \strtolower($attrMatch); 49 } 50 $attrName = \strtolower(\trim(\substr($attrMatch, 0, $pos))); 51 $attrValue = \trim(\substr($attrMatch, 1 + $pos)); 52 if (isset($this->config['aliases'][$elName][$attrName])) 53 $attrName = $this->config['aliases'][$elName][$attrName]; 54 if ($attrValue[0] === '"' || $attrValue[0] === "'") 55 $attrValue = \substr($attrValue, 1, -1); 56 $tag->setAttribute($attrName, \html_entity_decode($attrValue, \ENT_QUOTES, 'UTF-8')); 57 } 58 } 59 }
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 |