Esempio n. 1
0
 protected static function addSiteTag(Tag $tag, TagStack $tagStack, $siteId)
 {
     $endTag = $tag->getEndTag() ?: $tag;
     $lpos = $tag->getPos();
     $rpos = $endTag->getPos() + $endTag->getLen();
     $newTag = $tagStack->addSelfClosingTag(\strtoupper($siteId), $lpos, $rpos - $lpos);
     $newTag->setAttributes($tag->getAttributes());
     $newTag->setSortPriority($tag->getSortPriority());
 }
Esempio n. 2
0
 public static function hasNonDefaultAttribute(Tag $tag)
 {
     foreach ($tag->getAttributes() as $attrName => $void) {
         if ($attrName !== 'url') {
             return \true;
         }
     }
     return \false;
 }
Esempio n. 3
0
 /**
  * Add a site tag
  *
  * @param  Tag      $tag      The original tag
  * @param  TagStack $tagStack Parser instance, so that we can add the new tag to the stack
  * @param  string   $siteId   Site ID
  * @return void
  */
 protected static function addSiteTag(Tag $tag, TagStack $tagStack, $siteId)
 {
     $endTag = $tag->getEndTag() ?: $tag;
     // Compute the boundaries of our new tag
     $lpos = $tag->getPos();
     $rpos = $endTag->getPos() + $endTag->getLen();
     // Create a new tag and copy this tag's attributes and priority
     $newTag = $tagStack->addSelfClosingTag(strtoupper($siteId), $lpos, $rpos - $lpos);
     $newTag->setAttributes($tag->getAttributes());
     $newTag->setSortPriority($tag->getSortPriority());
 }
Esempio n. 4
0
 /**
  * @testdox removeAttribute('foo') unsets attribute 'foo'
  */
 public function testRemoveAttribute()
 {
     $tag = new Tag(Tag::START_TAG, 'X', 0, 0);
     $tag->setAttribute('foo', 'bar');
     $tag->setAttribute('baz', 'quux');
     $tag->removeAttribute('foo');
     $this->assertSame(['baz' => 'quux'], $tag->getAttributes());
 }
Esempio n. 5
0
 public function addCopyTag(Tag $tag, $pos, $len)
 {
     $copy = $this->addTag($tag->getType(), $tag->getName(), $pos, $len);
     $copy->setAttributes($tag->getAttributes());
     $copy->setSortPriority($tag->getSortPriority());
     return $copy;
 }