Ejemplo n.º 1
0
 /**
  * Create a PAOS Request element.
  *
  * @param DOMElement|NULL $xml  The XML element we should load.
  */
 public function __construct(DOMElement $xml = NULL)
 {
     if ($xml === NULL) {
         return;
     }
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) {
         throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.');
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') {
         throw new Exception('Invalid value of soap-env:mustUnderstand attribute in <paos:Request>.');
     }
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) {
         throw new Exception('Missing soap-env:mustUnderstand attribute in <paos:Request>.');
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') {
         throw new Exception('Invalid value of soap-env:actor attribute in <paos:Request>.');
     }
     if (!$xml->hasAttribute('responseConsumerURL')) {
         throw new Exception('Missing responseConsumerURL attribute in <paos:Request>.');
     }
     $this->responseConsumerURL = $xml->getAttribute('responseConsumerURL');
     if (!$xml->hasAttribute('service')) {
         throw new Exception('Missing service attribute in <paos:Request>.');
     }
     $this->service = $xml->getAttribute('service');
     if ($xml->hasAttribute('messageID')) {
         $this->messageID = $xml->getAttribute('messageID');
     }
 }
Ejemplo n.º 2
0
 /**
  * Basic check of the given XML, it is not part of __construct in order to reduce NPath Complexity
  *
  * @param DOMElement|NULL $xml  The XML element we should check before loading.
  */
 public function checkXML(DOMElement $xml)
 {
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) {
         return 'Missing soap-env:mustUnderstand attribute in <ecp:Request>.';
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') {
         return 'Invalid value of soap-env:mustUnderstand attribute in <ecp:Request>.';
     }
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) {
         return 'Missing soap-env:mustUnderstand attribute in <ecp:Request>.';
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') {
         return 'Invalid value of soap-env:actor attribute in <ecp:Request>.';
     }
     return TRUE;
 }
Ejemplo n.º 3
0
 /**
  * @param DOMElement $element
  * @param array $style
  * @return array
  */
 function parseStyles(DOMElement $element, $style = array())
 {
     if ($element->hasAttributeNS($this->ttsNS, 'fontWeight') && $element->getAttributeNS($this->ttsNS, 'fontWeight') == 'bold') {
         $style['bold'] = true;
     }
     if ($element->hasAttributeNS($this->ttsNS, 'fontStyle') && $element->getAttributeNS($this->ttsNS, 'fontStyle') == 'italic') {
         $style['italic'] = true;
     }
     $copiedAtts = array('textAlign', 'displayAlign', 'color', 'backgroundColor', 'fontFamily', 'fontSize');
     foreach ($copiedAtts as $copiedAtt) {
         if ($element->hasAttributeNS($this->ttsNS, $copiedAtt)) {
             $style[$copiedAtt] = $element->getAttributeNS($this->ttsNS, $copiedAtt);
         }
     }
     return $style;
 }
Ejemplo n.º 4
0
 /**
  * Filter a single element.
  *
  * @param DOMElement $element
  * @return void
  */
 public function filterElement(DOMElement $element)
 {
     $currentLevel = $element->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'outline-level');
     $parent = $element->parentNode;
     $siblings = $parent->childNodes;
     $section = new ezcDocumentPropertyContainerDomElement('section', null, ezcDocumentOdt::NS_EZC);
     $parent->replaceChild($section, $element);
     $section->setProperty('type', 'section');
     $section->setProperty('level', $currentLevel);
     $section->appendChild($element);
     $element->setProperty('type', 'title');
     for ($i = 0; $i < $siblings->length; ++$i) {
         if ($siblings->item($i)->isSameNode($section)) {
             break;
         }
     }
     ++$i;
     while (($sibling = $siblings->item($i)) !== null) {
         if ($sibling->nodeType === XML_ELEMENT_NODE && $sibling->namespaceURI === ezcDocumentOdt::NS_EZC && $sibling->getProperty('level') <= $currentLevel) {
             // Reached next higher or same level section
             break;
         }
         $section->appendChild($sibling->cloneNode(true));
         $parent->removeChild($sibling);
     }
 }
Ejemplo n.º 5
0
 /**
  * Create a ECP RelayState element.
  *
  * @param DOMElement|NULL $xml  The XML element we should load.
  */
 public function __construct(DOMElement $xml = NULL)
 {
     if ($xml === NULL) {
         return;
     }
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand')) {
         throw new Exception('Missing soap-env:mustUnderstand attribute in <ecp:RelayState>.');
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'mustUnderstand') !== '1') {
         throw new Exception('Invalid value of soap-env:mustUnderstand attribute in <ecp:RelayState>.');
     }
     if (!$xml->hasAttributeNS(SAML2_Const::NS_SOAP, 'actor')) {
         throw new Exception('Missing soap-env:mustUnderstand attribute in <ecp:RelayState>.');
     } elseif ($xml->getAttributeNS(SAML2_Const::NS_SOAP, 'actor') !== 'http://schemas.xmlsoap.org/soap/actor/next') {
         throw new Exception('Invalid value of soap-env:actor attribute in <ecp:RelayState>.');
     }
     $this->RelayState = $xml->textContent;
 }
Ejemplo n.º 6
0
 /**
  * Required by the ArrayAccess interface.
  *
  * @param  string $offset
  * @return string
  */
 public function offsetGet($offset)
 {
     if (strpos($offset, ':') !== false) {
         list($ns, $attr) = explode(':', $offset, 2);
         return $this->_element->getAttributeNS(Zend_Feed::lookupNamespace($ns), $attr);
     } else {
         return $this->_element->getAttribute($offset);
     }
 }
Ejemplo n.º 7
0
 /**
  * Get an attribute value
  *
  * @param string $name
  * @return string
  */
 public function getAttribute($name)
 {
     list($namespace, $localName) = $this->resolveTagName($name);
     if ($namespace != '') {
         return parent::getAttributeNS($namespace, $localName);
     } else {
         return parent::getAttribute($name);
     }
 }
Ejemplo n.º 8
0
 /**
  * Filter a single element.
  *
  * @param DOMElement $element
  * @return void
  */
 public function filterElement(DOMElement $element)
 {
     $element->setProperty('type', 'ulink');
     $attrs = $element->getProperty('attributes');
     if (!is_array($attrs)) {
         $attrs = array();
     }
     // @todo: Can we convert more attributes here? Maybe <ulink type="…"/>?
     $attrs['url'] = $element->getAttributeNS(ezcDocumentOdt::NS_XLINK, 'href');
     $element->setProperty('attributes', $attrs);
 }
Ejemplo n.º 9
0
 /**
  * Filter a single element.
  *
  * @param DOMElement $element
  * @return void
  */
 public function filterElement(DOMElement $element)
 {
     $spaces = '';
     switch ($element->localName) {
         case 's':
             $count = $element->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'c');
             $spaces = str_repeat(' ', $count !== '' ? (int) $count : 1);
             break;
         case 'tab':
             $spaces = "\t";
             break;
         case 'line-break':
             $spaces = "\n";
             break;
     }
     $element->setProperty('spaces', $spaces);
 }
    /**
     * Unserialize xml structure. Creates an object from xml input.
     *
     * Transaction unsafe. If you call several transaction unsafe methods you must enclose
     * the calls within a db transaction; thus within db->begin and db->commit.
     *
     * @param mixed $package
     * @param DOMElement $domNode
     * @param array $options
     * @param int|bool $ownerID Override owner ID, null to use XML owner id (optional)
     * @param string $handlerType
     * @return array|bool|eZContentObject|null created object, false if could not create object/xml invalid
     */
    static function unserialize( $package, $domNode, &$options, $ownerID = false, $handlerType = 'ezcontentobject' )
    {
        if ( $domNode->localName != 'object' )
        {
            $retValue = false;
            return $retValue;
        }

        $initialLanguage = eZContentObject::mapLanguage( $domNode->getAttribute( 'initial_language' ), $options );
        if( $initialLanguage === 'skip' )
        {
            $retValue = true;
            return $retValue;
        }

        $sectionID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'section_id' );
        if ( $ownerID === false )
        {
            $ownerID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'owner_id' );
        }
        $remoteID = $domNode->getAttribute( 'remote_id' );
        $name = $domNode->getAttribute( 'name' );
        $classRemoteID = $domNode->getAttribute( 'class_remote_id' );
        $classIdentifier = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'class_identifier' );
        $alwaysAvailable = ( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'always_available' ) == '1' );

        $contentClass = eZContentClass::fetchByRemoteID( $classRemoteID );
        if ( !$contentClass )
        {
            $contentClass = eZContentClass::fetchByIdentifier( $classIdentifier );
        }

        if ( !$contentClass )
        {
            $options['error'] = array( 'error_code' => self::PACKAGE_ERROR_NO_CLASS,
                                       'element_id' => $remoteID,
                                       'description' => "Can't install object '$name': Unable to fetch class with remoteID: $classRemoteID." );
            $retValue = false;
            return $retValue;
        }

        /** @var DOMElement $versionListNode */
        $versionListNode = $domNode->getElementsByTagName( 'version-list' )->item( 0 );

        $importedLanguages = array();
        foreach( $versionListNode->getElementsByTagName( 'version' ) as $versionDOMNode )
        {
            /** @var DOMElement $versionDOMNode */
            foreach ( $versionDOMNode->getElementsByTagName( 'object-translation' ) as $versionDOMNodeChild )
            {
                /** @var DOMElement $versionDOMNodeChild */
                $importedLanguage = eZContentObject::mapLanguage( $versionDOMNodeChild->getAttribute( 'language' ), $options );
                $language = eZContentLanguage::fetchByLocale( $importedLanguage );
                // Check if the language is allowed in this setup.
                if ( $language )
                {
                    $hasTranslation = true;
                }
                else
                {
                    if ( $importedLanguage == 'skip' )
                        continue;

                    // if there is no needed translation in system then add it
                    $locale = eZLocale::instance( $importedLanguage );
                    $translationName = $locale->internationalLanguageName();
                    $translationLocale = $locale->localeCode();

                    if ( $locale->isValid() )
                    {
                        eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
                        $hasTranslation = true;
                    }
                    else
                        $hasTranslation = false;
                }
                if ( $hasTranslation )
                {
                    $importedLanguages[] = $importedLanguage;
                    $importedLanguages = array_unique( $importedLanguages );
                }
            }
        }

        // If object exists we return a error.
        // Minimum install element is an object now.

        $contentObject = eZContentObject::fetchByRemoteID( $remoteID );
        // Figure out initial language
        if ( !$initialLanguage ||
             !in_array( $initialLanguage, $importedLanguages ) )
        {
            $initialLanguage = false;
            foreach ( eZContentLanguage::prioritizedLanguages() as $language )
            {
                if ( in_array( $language->attribute( 'locale' ), $importedLanguages ) )
                {
                    $initialLanguage = $language->attribute( 'locale' );
                    break;
                }
            }
        }
        if ( !$contentObject )
        {
            $firstVersion = true;
            $contentObject = $contentClass->instantiateIn( $initialLanguage, $ownerID, $sectionID );
        }
        else
        {
            $firstVersion = false;
            $description = "Object '$name' already exists.";

            $choosenAction = eZPackageHandler::errorChoosenAction( self::PACKAGE_ERROR_EXISTS,
                                                                   $options, $description, $handlerType, false );

            switch( $choosenAction )
            {
                case eZPackage::NON_INTERACTIVE:
                case self::PACKAGE_UPDATE:
                {
                    // Keep existing contentobject.
                } break;

                case self::PACKAGE_REPLACE:
                {
                    eZContentObjectOperations::remove( $contentObject->attribute( 'id' ) );

                    unset( $contentObject );
                    $contentObject = $contentClass->instantiateIn( $initialLanguage, $ownerID, $sectionID );
                    $firstVersion = true;
                } break;

                case self::PACKAGE_SKIP:
                {
                    $retValue = true;
                    return $retValue;
                } break;

                case self::PACKAGE_NEW:
                {
                    $contentObject->setAttribute( 'remote_id', eZRemoteIdUtility::generate( 'object' ) );
                    $contentObject->store();
                    unset( $contentObject );
                    $contentObject = $contentClass->instantiateIn( $initialLanguage, $ownerID, $sectionID );
                    $firstVersion = true;
                } break;

                default:
                {
                    $options['error'] = array( 'error_code' => self::PACKAGE_ERROR_EXISTS,
                                               'element_id' => $remoteID,
                                               'description' => $description,
                                               'actions' => array( self::PACKAGE_REPLACE => ezpI18n::tr( 'kernel/classes', 'Replace existing object' ),
                                                                   self::PACKAGE_SKIP    => ezpI18n::tr( 'kernel/classes', 'Skip object' ),
                                                                   self::PACKAGE_NEW     => ezpI18n::tr( 'kernel/classes', 'Keep existing and create a new one' ),
                                                                   self::PACKAGE_UPDATE  => ezpI18n::tr( 'kernel/classes', 'Update existing object' ) ) );
                    $retValue = false;
                    return $retValue;
                } break;
            }
        }

        $db = eZDB::instance();
        $db->begin();

        if ( $alwaysAvailable )
        {
            // Make sure always available bit is set.
            $contentObject->setAttribute( 'language_mask', (int)$contentObject->attribute( 'language_mask' ) | 1 );
        }

        $contentObject->setAttribute( 'section_id', $sectionID );
        $contentObject->store();
        $activeVersion = false;
        $lastVersion = false;
        $versionListActiveVersion = $versionListNode->getAttribute( 'active_version' );

        $contentObject->setAttribute( 'remote_id', $remoteID );
        $contentObject->setAttribute( 'contentclass_id', $contentClass->attribute( 'id' ) );
        $contentObject->store();

        $sectionObject = eZSection::fetch( $sectionID );
        if ( $sectionObject instanceof eZSection )
        {
            $updateWithParentSection = false;
        }
        else
        {
            $updateWithParentSection = true;
        }

        $options['language_array'] = $importedLanguages;
        $versionList = array();
        foreach( $versionListNode->getElementsByTagName( 'version' ) as $versionDOMNode )
        {
            unset( $nodeList );
            $nodeList = array();
            $contentObjectVersion = eZContentObjectVersion::unserialize( $versionDOMNode,
                                                                         $contentObject,
                                                                         $ownerID,
                                                                         $sectionID,
                                                                         $versionListActiveVersion,
                                                                         $firstVersion,
                                                                         $nodeList,
                                                                         $options,
                                                                         $package,
                                                                         'ezcontentobject',
                                                                         $initialLanguage );

            if ( !$contentObjectVersion )
            {
                $db->commit();

                $retValue = false;
                return $retValue;
            }

            $versionStatus = $versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
            $versionList[$versionDOMNode->getAttributeNS( 'http://ez.no/ezobject', 'version' )] = array( 'node_list' => $nodeList,
                                                                                                         'status' =>    $versionStatus );
            unset( $versionStatus );

            $firstVersion = false;
            $lastVersion = $contentObjectVersion->attribute( 'version' );
            if ( $versionDOMNode->getAttribute( 'version' ) == $versionListActiveVersion )
            {
                $activeVersion = $contentObjectVersion->attribute( 'version' );
            }
            eZNodeAssignment::setNewMainAssignment( $contentObject->attribute( 'id' ), $lastVersion );

            eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ),
                                                                      'version' => $lastVersion ) );

            $mainNodeInfo = null;
            foreach ( $nodeList as $nodeInfo )
            {
                if ( $nodeInfo['is_main'] )
                {
                    $mainNodeInfo =& $nodeInfo;
                    break;
                }
            }
            if ( $mainNodeInfo )
            {
                $existingMainNode = eZContentObjectTreeNode::fetchByRemoteID( $mainNodeInfo['parent_remote_id'], false );
                if ( $existingMainNode )
                {
                    eZContentObjectTreeNode::updateMainNodeID( $existingMainNode['node_id'],
                                                               $mainNodeInfo['contentobject_id'],
                                                               $mainNodeInfo['contentobject_version'],
                                                               $mainNodeInfo['parent_node'],
                                                               $updateWithParentSection );
                }
            }
            unset( $mainNodeInfo );
            // Refresh $contentObject from DB.
            $contentObject = eZContentObject::fetch( $contentObject->attribute( 'id' ) );
        }
        if ( !$activeVersion )
        {
            $activeVersion = $lastVersion;
        }

        /*
        $contentObject->setAttribute( 'current_version', $activeVersion );
        */
        $contentObject->setAttribute( 'name', $name );
        if ( isset( $options['use_dates_from_package'] ) && $options['use_dates_from_package'] )
        {
            $contentObject->setAttribute( 'published', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'published' ) ) );
            $contentObject->setAttribute( 'modified', eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) ) );
        }
        $contentObject->store();

        $versions   = $contentObject->versions();
        $objectName = $contentObject->name();
        $objectID   = $contentObject->attribute( 'id' );
        foreach ( $versions as $version )
        {
            $versionNum       = $version->attribute( 'version' );
            $oldVersionStatus = $version->attribute( 'status' );
            $newVersionStatus = isset( $versionList[$versionNum] ) ? $versionList[$versionNum]['status'] : null;

            // set the correct status for non-published versions
            if ( isset( $newVersionStatus ) && $oldVersionStatus != $newVersionStatus && $newVersionStatus != eZContentObjectVersion::STATUS_PUBLISHED )
            {
                $version->setAttribute( 'status', $newVersionStatus );
                $version->store( array( 'status' ) );
            }

            // when translation does not have object name set then we copy object name from the current object version
            $translations = $version->translations( false );
            if ( !$translations )
                continue;
            foreach ( $translations as $translation )
            {
                if ( ! $contentObject->name( $versionNum, $translation ) )
                {
                    eZDebug::writeNotice( "Setting name '$objectName' for version ($versionNum) of the content object ($objectID) in language($translation)" );
                    $contentObject->setName( $objectName, $versionNum, $translation );
                }
            }
        }

        foreach ( $versionList[$versionListActiveVersion]['node_list'] as $nodeInfo )
        {
            unset( $parentNode );
            $parentNode = eZContentObjectTreeNode::fetchNode( $contentObject->attribute( 'id' ),
                                                               $nodeInfo['parent_node'] );
            if ( is_object( $parentNode ) )
            {
                $parentNode->setAttribute( 'priority', $nodeInfo['priority'] );
                $parentNode->store( array( 'priority' ) );
            }
        }

        $db->commit();

        return $contentObject;
    }
Ejemplo n.º 11
0
 /**
  * Parses the provided XML element object and stores it as a feed textinput in
  * the provided ezcFeed object.
  *
  * @param ezcFeed $feed The feed object in which to store the parsed XML element as a feed textinput
  * @param DOMElement $xml The XML element object to parse
  */
 private function parseTextInput(ezcFeed $feed, DOMElement $xml = null)
 {
     $textInput = $feed->add('textInput');
     if ($xml !== null) {
         foreach ($xml->childNodes as $itemChild) {
             if ($itemChild->nodeType == XML_ELEMENT_NODE) {
                 $tagName = $itemChild->tagName;
                 switch ($tagName) {
                     case 'title':
                     case 'description':
                     case 'name':
                     case 'link':
                         $textInput->{$tagName} = $itemChild->textContent;
                         break;
                 }
             }
         }
         if ($xml->hasAttributeNS(self::NAMESPACE_URI, 'about')) {
             $textInput->about = $xml->getAttributeNS(self::NAMESPACE_URI, 'about');
         }
     }
 }
Ejemplo n.º 12
0
 /**
  * @return bool
  */
 public function isOptional()
 {
     return $this->element->getAttributeNS('http://www.w3.org/1999/xlink', 'use') == 'optional';
 }
Ejemplo n.º 13
0
 /**
  * @return string
  */
 public function getRole()
 {
     return $this->element->getAttributeNS('http://www.w3.org/1999/xlink', 'role');
 }
Ejemplo n.º 14
0
Archivo: list.php Proyecto: bmdevel/ezc
 /**
  * Returns the <text:list-style> DOMElement assigned to $odtList.
  * 
  * @param DOMElement $odtList 
  * @param ezcDocumentOdtStyleInformation $styleInfo 
  * @return DOMElement
  */
 protected function retrieveListStyle($odtList, ezcDocumentOdtStyleInformation $styleInfo)
 {
     $styleName = $odtList->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'style-name');
     $xpath = new DOMXpath($styleInfo->automaticStyleSection->ownerDocument);
     $xpath->registerNamespace(ezcDocumentOdt::NS_ODT_TEXT, 'text');
     $xpath->registerNamespace(ezcDocumentOdt::NS_ODT_STYLE, 'style');
     $styleList = $xpath->query("text:list-style[@style:name='{$styleName}']", $styleInfo->automaticStyleSection);
     if ($styleList->length !== 1) {
         throw new RuntimeException("Inconsistent style section. Found {$styleList->length} list styles with name '{$styleName}'");
     }
     return $styleList->item(0);
 }
Ejemplo n.º 15
0
 private function isElementValueNull(\DOMElement $element)
 {
     $namespaceUri = 'http://www.w3.org/2001/XMLSchema-instance';
     if (!$element->hasAttributeNS($namespaceUri, 'nil')) {
         return false;
     }
     return 'true' === $element->getAttributeNS($namespaceUri, 'nil') || '1' === $element->getAttributeNS($namespaceUri, 'nil');
 }
Ejemplo n.º 16
0
 /**
  * Add Encrypted Key
  *
  * @param XMLSecEnc    $key
  * @param \DOMElement  $token
  *
  * @return bool
  */
 public function addEncryptedKey(XMLSecEnc $key, \DOMElement $token)
 {
     if (!$key->encKey) {
         return false;
     }
     $encKey = $key->encKey;
     $security = $this->locateSecurityHeader();
     $doc = $security->ownerDocument;
     if (!$doc->isSameNode($encKey->ownerDocument)) {
         $key->encKey = $security->ownerDocument->importNode($encKey, true);
         $encKey = $key->encKey;
     }
     if (!empty($key->guid)) {
         return true;
     }
     $lastToken = null;
     $findTokens = $security->firstChild;
     while ($findTokens) {
         if ($findTokens->localName == 'BinarySecurityToken') {
             $lastToken = $findTokens;
         }
         $findTokens = $findTokens->nextSibling;
     }
     if ($lastToken) {
         $lastToken = $lastToken->nextSibling;
     }
     $security->insertBefore($encKey, $lastToken);
     $key->guid = XMLSecurityDSig::generateGUID();
     $encKey->setAttribute('Id', $key->guid);
     $encMethod = $encKey->firstChild;
     while ($encMethod && $encMethod->localName != 'EncryptionMethod') {
         $encMethod = $encMethod->nextChild;
     }
     if ($encMethod) {
         $encMethod = $encMethod->nextSibling;
     }
     $objDoc = $encKey->ownerDocument;
     $keyInfo = $objDoc->createElementNS('http://www.w3.org/2000/09/xmldsig#', 'dsig:KeyInfo');
     $encKey->insertBefore($keyInfo, $encMethod);
     $tokenURI = '#' . $token->getAttributeNS(WSSESoap::WSUNS, "Id");
     $tokenRef = $objDoc->createElementNS(WSSESoap::WSSENS, WSSESoap::WSSEPFX . ':SecurityTokenReference');
     $keyInfo->appendChild($tokenRef);
     $reference = $objDoc->createElementNS(WSSESoap::WSSENS, WSSESoap::WSSEPFX . ':Reference');
     $reference->setAttribute("URI", $tokenURI);
     $tokenRef->appendChild($reference);
     return true;
 }
Ejemplo n.º 17
0
 public static function getVarname(\DOMElement $node)
 {
     return "__a" . sha1($node->getAttributeNS(Twital::NS, '__internal-id__') . spl_object_hash($node));
 }
Ejemplo n.º 18
0
 /**
  * Wrapper to DomElement->getAttributeNS with default value option
  *
  * Note: A set but empty attribute does NOT trigger use of the default
  *
  * @param string $ns      Namespace of attribute
  * @param string $attr    Attribute to access
  * @param string $default Default value to use if the attribute is not set
  *
  * @return string
  */
 public function getAttributeNS($ns, $attr, $default = '')
 {
     return $this->hasAttributeNS($ns, $attr) ? parent::getAttributeNS($ns, $attr) : $default;
 }
Ejemplo n.º 19
0
 /**
  * Parses a list level style.
  *
  * Parses the given $listLevelElement and returns a corresponding 
  * list-level style object.
  * 
  * @param DOMElement $listLevelElement 
  * @return ezcDocumentOdtListLevelStyle
  */
 protected function parseListLevel(DOMElement $listLevelElement)
 {
     if (!isset(self::$listClassMap[$listLevelElement->localName])) {
         throw new RuntimeException("Unknown list-level element {$listLevelElement->localName}.");
     }
     $listLevelClass = self::$listClassMap[$listLevelElement->localName];
     $listLevel = new $listLevelClass($listLevelElement->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'level'));
     foreach (self::$listAttributeMap[$listLevelElement->localName] as $ns => $attrs) {
         foreach ($attrs as $xmlAttr => $objAttr) {
             if ($listLevelElement->hasAttributeNS($ns, $xmlAttr)) {
                 $listLevel->{$objAttr} = $listLevelElement->getAttributeNS($ns, $xmlAttr);
             }
         }
     }
     return $listLevel;
 }
Ejemplo n.º 20
0
 protected function getAsyncAfter(\DOMElement $el)
 {
     return strtolower($el->getAttributeNS(self::NS_IMPL, 'asyncAfter')) == 'true';
 }
Ejemplo n.º 21
0
 /**
  * @param \DOMElement $node
  * @return string
  */
 private function getName(\DOMElement $node)
 {
     if ($node->hasAttributeNS(self::XMLNS_JSONDOM, 'name')) {
         return $node->getAttributeNS(self::XMLNS_JSONDOM, 'name');
     } else {
         return $node->localName;
     }
 }
Ejemplo n.º 22
0
 /**
  * @param \DOMElement $node
  * @return string
  */
 private function getType(\DOMElement $node)
 {
     if ($node->hasAttributeNS(self::XMLNS_JSONDOM, 'type')) {
         return $node->getAttributeNS(self::XMLNS_JSONDOM, 'type');
     } else {
         $xpath = new Xpath($node->ownerDocument);
         return $xpath('count(*) > 0', $node) ? 'object' : 'string';
     }
 }
 public function getChildAttribute(\DOMElement $node)
 {
     $name = $node->getAttributeNS($this->namespaces['sv'], 'name');
     $type = strtolower($node->getAttributeNS($this->namespaces['sv'], 'type'));
     $values = array();
     if ($name == 'jcr:created') {
         $values[] = date(self::DATEFORMAT);
     } else {
         foreach ($node->getElementsByTagNameNS($this->namespaces['sv'], 'value') as $nodeValue) {
             $values[] = $nodeValue->nodeValue;
         }
     }
     $isMultiValue = false;
     if ($name == 'jcr:mixinTypes' || count($values) > 1 || $node->hasAttributeNS($this->namespaces['sv'], 'multiple') && $node->getAttributeNS($this->namespaces['sv'], 'multiple') == 'true') {
         $isMultiValue = true;
     }
     return array($name, array('type' => $type, 'value' => $values, 'multiValued' => $isMultiValue));
 }
Ejemplo n.º 24
0
 /**
  * Returns the list style name of the given $odtElement.
  *
  * Recursively searches for the style name of the given list element. The 
  * style name is only present at the top most list (for nested lists).
  * 
  * @param DOMElement $odtElement 
  * @return string
  */
 protected function getListStyleName(DOMElement $odtElement)
 {
     if ($odtElement->namespaceURI === ezcDocumentOdt::NS_ODT_TEXT && $odtElement->localName === 'list' && $odtElement->hasAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'style-name')) {
         return $odtElement->getAttributeNS(ezcDocumentOdt::NS_ODT_TEXT, 'style-name');
     }
     if ($odtElement->parentNode === null) {
         throw new RuntimeException('No list style name found.');
     }
     return $this->getListStyleName($odtElement->parentNode);
 }
Ejemplo n.º 25
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');
     }
 }
Ejemplo n.º 26
0
 /**
  * Get attribute workaround helper.
  *
  * Work around method for the fact that DOMDocument adds some mysterious namespache "xmlns:default"
  * when the root NS is the requested XMLNS and setAttributeNS() is used.
  *
  * @param \DOMElement $node The node from which the attribute shall be read.
  *
  * @param string      $name The name of the attribute.
  *
  * @return string
  */
 protected function getAttribute(\DOMElement $node, $name)
 {
     if ($this->rootNSWorkaround()) {
         return $node->getAttribute($name);
     }
     return $node->getAttributeNS(self::NS, $name);
 }
Ejemplo n.º 27
0
 /**
  * Get a attribute value
  *
  * @param DOMElement $nod
  * @param string $name
  * @param string $ns
  * @return string
  */
 public function get_attr_value(&$nod, $name, $ns = null)
 {
     return is_null($ns) ? $nod->hasAttribute($name) ? $nod->getAttribute($name) : null : ($nod->hasAttributeNS($ns, $name) ? $nod->getAttributeNS($ns, $name) : null);
 }
Ejemplo n.º 28
0
 /**
  * Retrieve a namespaced attribute value.
  * Unlike DOMElement::getAttributeNS(), this method accepts an optional
  * default return value.
  *
  * @param      string A namespace URI.
  * @param      string An attribute name.
  * @param      mixed  A default attribute value.
  *
  * @return     mixed An attribute value, if the attribute exists, otherwise
  *                   null or the given default.
  *
  * @see        DOMElement::getAttributeNS()
  *
  * @author     David Zülke <*****@*****.**>
  * @since      1.0.0
  */
 public function getAttributeNS($namespaceUri, $localName, $default = null)
 {
     $retval = parent::getAttributeNS($namespaceUri, $localName);
     if ($retval === null) {
         $retval = $default;
     }
     return $retval;
 }