Example #1
0
 public function asConfig()
 {
     $bbcodes = parent::asConfig();
     foreach ($bbcodes as $bbcodeName => &$bbcode) {
         if (isset($bbcode['tagName']) && TagName::isValid($bbcodeName) && TagName::normalize($bbcodeName) === $bbcode['tagName']) {
             unset($bbcode['tagName']);
         }
         if (isset($bbcode['defaultAttribute']) && AttributeName::isValid($bbcodeName) && AttributeName::normalize($bbcodeName) === $bbcode['defaultAttribute']) {
             unset($bbcode['defaultAttribute']);
         }
     }
     unset($bbcode);
     return new Dictionary($bbcodes);
 }
 /**
  * {@inheritdoc}
  *
  * This method will remove redundant info such as the BBCode's tagName or defaultAttribute values
  * if they are the same as their default values
  */
 public function asConfig()
 {
     $bbcodes = parent::asConfig();
     foreach ($bbcodes as $bbcodeName => &$bbcode) {
         // Remove the tag name if it's the same name as the BBCode
         if (isset($bbcode['tagName']) && TagName::isValid($bbcodeName) && TagName::normalize($bbcodeName) === $bbcode['tagName']) {
             unset($bbcode['tagName']);
         }
         // Remove the defaultAttribute name if it's the same name as the BBCode
         if (isset($bbcode['defaultAttribute']) && AttributeName::isValid($bbcodeName) && AttributeName::normalize($bbcodeName) === $bbcode['defaultAttribute']) {
             unset($bbcode['defaultAttribute']);
         }
     }
     unset($bbcode);
     return new Dictionary($bbcodes);
 }
 /**
  * Set $this->tagName with given tag name, normalized
  *
  * @param  string $tagName New tag name
  * @return void
  */
 protected function setTagName($tagName)
 {
     if (!property_exists($this, 'tagName')) {
         throw new RuntimeException("Unknown property 'tagName'");
     }
     $this->tagName = TagName::normalize($tagName);
 }
Example #4
0
 /**
  * Set the tag name that represents this BBCode in the intermediate representation
  *
  * @param string $tagName
  */
 public function setTagName($tagName)
 {
     $this->tagName = TagName::normalize($tagName);
 }
Example #5
0
 /**
  * Alias an HTML element to a given tag name
  *
  * NOTE: will *not* create the target tag
  *
  * @param  string $elName  Name of the HTML element
  * @param  string $tagName Name of the tag
  * @return void
  */
 public function aliasElement($elName, $tagName)
 {
     $elName = $this->normalizeElementName($elName);
     $this->aliases[$elName][''] = TagName::normalize($tagName);
 }
Example #6
0
 /**
  * @testdox "B\n" is invalid (no newlines allowed)
  */
 public function testInvalid6343D666()
 {
     $this->assertFalse(TagName::isValid("B\n"));
 }
Example #7
0
 public function normalizeValue($attrName)
 {
     return TagName::normalize($attrName);
 }
Example #8
0
 /**
  * Add a targeted rule
  *
  * @param  string $ruleName Name of the rule
  * @param  string $tagName  Name of the target tag
  * @return self
  */
 protected function addTargetedRule($ruleName, $tagName)
 {
     $this->items[$ruleName][] = TagName::normalize($tagName);
     return $this;
 }
Example #9
0
 /**
  * Normalize a tag name used as a key in this colelction
  *
  * @param  string $key Original name
  * @return string      Normalized name
  */
 public function normalizeKey($key)
 {
     return TagName::normalize($key);
 }