Esempio n. 1
0
 protected function setAttrName($attrName)
 {
     if (!\property_exists($this, 'attrName')) {
         throw new RuntimeException("Unknown property 'attrName'");
     }
     $this->attrName = AttributeName::normalize($attrName);
 }
 /**
  * Add an attribute preprocessor
  *
  * @param  string $attrName Original name
  * @param  string $regexp   Preprocessor's regexp
  * @return AttributePreprocessor
  */
 public function add($attrName, $regexp)
 {
     $attrName = AttributeName::normalize($attrName);
     $k = serialize([$attrName, $regexp]);
     $this->items[$k] = new AttributePreprocessor($regexp);
     return $this->items[$k];
 }
Esempio n. 3
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);
 }
Esempio n. 5
0
 /**
  * Set the default attribute name for this BBCode
  *
  * @param string $attrName
  */
 public function setDefaultAttribute($attrName)
 {
     $this->defaultAttribute = AttributeName::normalize($attrName);
 }
Esempio n. 6
0
 /**
  * Alias the HTML attribute of given HTML element to a given attribute name
  *
  * NOTE: will *not* create the target attribute
  *
  * @param  string $elName   Name of the HTML element
  * @param  string $attrName Name of the HTML attribute
  * @param  string $alias    Alias
  * @return void
  */
 public function aliasAttribute($elName, $attrName, $alias)
 {
     $elName = $this->normalizeElementName($elName);
     $attrName = $this->normalizeAttributeName($attrName);
     $this->aliases[$elName][$attrName] = AttributeName::normalize($alias);
 }
 public function normalizeKey($key)
 {
     return AttributeName::normalize($key);
 }
 /**
  * @testdox "foo\n" is invalid (no newlines allowed)
  */
 public function testInvalid7E3265A8()
 {
     $this->assertFalse(AttributeName::isValid("foo\n"));
 }
Esempio n. 9
0
 public function normalizeValue($attrName)
 {
     return AttributeName::normalize($attrName);
 }