Example #1
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @param  string $offset
  * @return boolean
  */
 public function offsetUnset($offset)
 {
     if (strpos($offset, ':') !== false) {
         list($ns, $attr) = explode(':', $offset, 2);
         return $this->_element->removeAttributeNS(Zend_Feed::lookupNamespace($ns), $attr);
     } else {
         return $this->_element->removeAttribute($offset);
     }
 }
Example #2
0
 /**
  * Create an AttributeValue.
  *
  * @param mixed $value The value of this element. Can be one of:
  *  - string                      Create an attribute value with a simple string.
  *  - DOMElement(AttributeValue)  Create an attribute value of the given DOMElement.
  *  - DOMElement                  Create an attribute value with the given DOMElement as a child.
  */
 public function __construct($value)
 {
     assert('is_string($value) || $value instanceof DOMElement');
     if (is_string($value)) {
         $doc = new DOMDocument();
         $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
         $this->element->setAttributeNS(SAML2_Const::NS_XSI, 'xsi:type', 'xs:string');
         $this->element->appendChild($doc->createTextNode($value));
         /* Make sure that the xs-namespace is available in the AttributeValue (for xs:string). */
         $this->element->setAttributeNS(SAML2_Const::NS_XS, 'xs:tmp', 'tmp');
         $this->element->removeAttributeNS(SAML2_Const::NS_XS, 'tmp');
         return;
     }
     if ($value->namespaceURI === SAML2_Const::NS_SAML && $value->localName === 'AttributeValue') {
         $this->element = SAML2_Utils::copyElement($value);
         return;
     }
     $doc = new DOMDocument();
     $this->element = $doc->createElementNS(SAML2_Const::NS_SAML, 'saml:AttributeValue');
     SAML2_Utils::copyElement($value, $this->element);
 }
Example #3
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @internal
  */
 public function offsetUnset($offset)
 {
     if (strpos($offset, ':') !== false) {
         list($ns, $attr) = explode(':', $offset, 2);
         $result = $this->_element->removeAttributeNS(Horde_Xml_Element::lookupNamespace($ns), $attr);
     } else {
         $result = $this->_element->removeAttribute($offset);
     }
     if ($result) {
         $this->_expireCachedChildren();
         return true;
     } else {
         return false;
     }
 }
Example #4
0
 /**
  * Clean the xlink:hrefs of script and data embeds
  *
  * @param \DOMElement $element
  */
 protected function cleanXlinkHrefs(\DOMElement &$element)
 {
     $xlinks = $element->getAttributeNS('http://www.w3.org/1999/xlink', 'href');
     if (preg_match(self::SCRIPT_REGEX, $xlinks) === 1) {
         $element->removeAttributeNS('http://www.w3.org/1999/xlink', 'href');
     }
 }
Example #5
0
 /**
  * Set an attribute on an element
  *
  * @param string $name
  * @return bool
  */
 public function removeAttribute($name)
 {
     list($namespace, $localName) = $this->resolveTagName($name);
     if ($namespace != '') {
         return parent::removeAttributeNS($namespace, $localName);
     } else {
         return parent::removeAttribute($name);
     }
 }