[ 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\Parser; 9 class Tag 10 { 11 const START_TAG = 1; 12 const END_TAG = 2; 13 const SELF_CLOSING_TAG = 3; 14 protected $attributes = []; 15 protected $cascade = []; 16 protected $endTag = \null; 17 protected $flags = 0; 18 protected $invalid = \false; 19 protected $len; 20 protected $name; 21 protected $pos; 22 protected $sortPriority; 23 protected $startTag = \null; 24 protected $type; 25 public function __construct($type, $name, $pos, $len, $priority = 0) 26 { 27 $this->type = (int) $type; 28 $this->name = $name; 29 $this->pos = (int) $pos; 30 $this->len = (int) $len; 31 $this->sortPriority = (int) $priority; 32 } 33 public function addFlags($flags) 34 { 35 $this->flags |= $flags; 36 } 37 public function cascadeInvalidationTo(Tag $tag) 38 { 39 $this->cascade[] = $tag; 40 if ($this->invalid) 41 $tag->invalidate(); 42 } 43 public function invalidate() 44 { 45 if ($this->invalid) 46 return; 47 $this->invalid = \true; 48 foreach ($this->cascade as $tag) 49 $tag->invalidate(); 50 } 51 public function pairWith(Tag $tag) 52 { 53 if ($this->name === $tag->name) 54 if ($this->type === self::START_TAG 55 && $tag->type === self::END_TAG 56 && $tag->pos >= $this->pos) 57 { 58 $this->endTag = $tag; 59 $tag->startTag = $this; 60 $this->cascadeInvalidationTo($tag); 61 } 62 elseif ($this->type === self::END_TAG 63 && $tag->type === self::START_TAG 64 && $tag->pos <= $this->pos) 65 { 66 $this->startTag = $tag; 67 $tag->endTag = $this; 68 } 69 } 70 public function removeFlags($flags) 71 { 72 $this->flags &= ~$flags; 73 } 74 public function setFlags($flags) 75 { 76 $this->flags = $flags; 77 } 78 public function getAttributes() 79 { 80 return $this->attributes; 81 } 82 public function getEndTag() 83 { 84 return $this->endTag; 85 } 86 public function getFlags() 87 { 88 return $this->flags; 89 } 90 public function getLen() 91 { 92 return $this->len; 93 } 94 public function getName() 95 { 96 return $this->name; 97 } 98 public function getPos() 99 { 100 return $this->pos; 101 } 102 public function getSortPriority() 103 { 104 return $this->sortPriority; 105 } 106 public function getStartTag() 107 { 108 return $this->startTag; 109 } 110 public function getType() 111 { 112 return $this->type; 113 } 114 public function canClose(Tag $startTag) 115 { 116 if ($this->invalid 117 || $this->name !== $startTag->name 118 || $startTag->type !== self::START_TAG 119 || $this->type !== self::END_TAG 120 || $this->pos < $startTag->pos 121 || ($this->startTag && $this->startTag !== $startTag) 122 || ($startTag->endTag && $startTag->endTag !== $this)) 123 return \false; 124 return \true; 125 } 126 public function isBrTag() 127 { 128 return ($this->name === 'br'); 129 } 130 public function isEndTag() 131 { 132 return (bool) ($this->type & self::END_TAG); 133 } 134 public function isIgnoreTag() 135 { 136 return ($this->name === 'i'); 137 } 138 public function isInvalid() 139 { 140 return $this->invalid; 141 } 142 public function isParagraphBreak() 143 { 144 return ($this->name === 'pb'); 145 } 146 public function isSelfClosingTag() 147 { 148 return ($this->type === self::SELF_CLOSING_TAG); 149 } 150 public function isSystemTag() 151 { 152 return (\strpos('br i pb v', $this->name) !== \false); 153 } 154 public function isStartTag() 155 { 156 return (bool) ($this->type & self::START_TAG); 157 } 158 public function isVerbatim() 159 { 160 return ($this->name === 'v'); 161 } 162 public function getAttribute($attrName) 163 { 164 return $this->attributes[$attrName]; 165 } 166 public function hasAttribute($attrName) 167 { 168 return isset($this->attributes[$attrName]); 169 } 170 public function removeAttribute($attrName) 171 { 172 unset($this->attributes[$attrName]); 173 } 174 public function setAttribute($attrName, $attrValue) 175 { 176 $this->attributes[$attrName] = $attrValue; 177 } 178 public function setAttributes(array $attributes) 179 { 180 $this->attributes = $attributes; 181 } 182 }
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 |