kernel/classes/datatypes/ezxmltext/ezxmltexttype.php
function onPublish( $contentObjectAttribute, $object, $publishedNodes )
    {
        $currentVersion = $object->currentVersion();
        $langMask = $currentVersion->attribute( 'language_mask' );

        // We find all translations present in the current version. We calculate
        // this from the language mask already present in the fetched version,
        // so no further round-trip to the DB is required.
        $languageList = eZContentLanguage::decodeLanguageMask( $langMask, true );
        $languageList = $languageList['language_list'];

        // We want to have the class attribute identifier of the attribute
        // containing the current ezxmltext, as we then can use the more efficient
        // eZContentObject->fetchAttributesByIdentifier() to get the data
        $identifier = $contentObjectAttribute->attribute( 'contentclass_attribute_identifier' );

        $attributeArray = $object->fetchAttributesByIdentifier( array( $identifier ),
                                                                $currentVersion->attribute( 'version' ),
                                                                $languageList );

        foreach ( $attributeArray as $attribute )
        {
            $xmlText = eZXMLTextType::rawXMLText( $attribute );

            $dom = new DOMDocument( '1.0', 'utf-8' );
            if ( !$dom->loadXML( $xmlText ) )
                continue;

            // urls
            $urlIdArray = array();
            foreach ( $dom->getElementsByTagName( 'link' ) as $link )
            {
                // We are looking for external 'http://'-style links, not the internal
                // object or node links.
                if ( $link->hasAttribute( 'url_id' ) )
                {
                    $urlIdArray[] = $link->getAttribute( 'url_id' );
                }
            }
            $urlIdArray = array_unique( $urlIdArray );

            $db = eZDB::instance();
            $db->begin();
            eZSimplifiedXMLInput::updateUrlObjectLinks( $attribute, $urlIdArray );
            $db->commit();

            // linked objects
            $linkedObjectIdArray = $this->getRelatedObjectList( $dom->getElementsByTagName( 'link' ) );

            // embedded objects
            $embeddedObjectIdArray = array_merge(
                $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed' ) ),
                $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed-inline' ) )
            );

            if ( !empty( $embeddedObjectIdArray ) )
            {
                $object->appendInputRelationList( $embeddedObjectIdArray, eZContentObject::RELATION_EMBED );
            }

            if ( !empty( $linkedObjectIdArray ) )
            {
                $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK );
            }
            if ( !empty( $linkedObjectIdArray ) || !empty( $embeddedObjectIdArray ) )
            {
                $object->commitInputRelations( $currentVersion->attribute( 'version' ) );
            }

        }
    }
function onPublish( $contentObjectAttribute, $object, $publishedNodes )
    {
        $currentVersion = $object->currentVersion();
        $langMask = $currentVersion->attribute( 'language_mask' );

        // We find all translations present in the current version. We calculate
        // this from the language mask already present in the fetched version,
        // so no further round-trip to the DB is required.
        $languageList = eZContentLanguage::decodeLanguageMask( $langMask, true );
        $languageList = $languageList['language_list'];

        // We want to have the class attribute identifier of the attribute
        // containing the current ezxmltext, as we then can use the more efficient
        // eZContentObject->fetchAttributesByIdentifier() to get the data
        $identifier = $contentObjectAttribute->attribute( 'contentclass_attribute_identifier' );

        $attributeArray = $object->fetchAttributesByIdentifier( array( $identifier ),
                                                                $currentVersion->attribute( 'version' ),
                                                                $languageList );

        foreach ( $attributeArray as $attribute )
        {
            $xmlText = eZXMLTextType::rawXMLText( $attribute );

            $dom = new DOMDocument( '1.0', 'utf-8' );
            if ( !$dom->loadXML( $xmlText ) )
                continue;

            // urls
            $urlIdArray = array();
            foreach ( $dom->getElementsByTagName( 'link' ) as $link )
            {
                // We are looking for external 'http://'-style links, not the internal
                // object or node links.
                if ( $link->hasAttribute( 'url_id' ) )
                {
                    $urlIdArray[] = $link->getAttribute( 'url_id' );
                }
            }
            $urlIdArray = array_unique( $urlIdArray );

            $db = eZDB::instance();
            $db->begin();
            eZSimplifiedXMLInput::updateUrlObjectLinks( $attribute, $urlIdArray );
            $db->commit();

            // linked objects
            $linkedObjectIdArray = $this->getRelatedObjectList( $dom->getElementsByTagName( 'link' ) );

            // embedded objects
            $embeddedObjectIdArray = array_merge(
                $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed' ) ),
                $this->getRelatedObjectList( $dom->getElementsByTagName( 'embed-inline' ) )
            );

            if ( !empty( $embeddedObjectIdArray ) )
            {
                $object->appendInputRelationList( $embeddedObjectIdArray, eZContentObject::RELATION_EMBED );
            }

            if ( !empty( $linkedObjectIdArray ) )
            {
                $object->appendInputRelationList( $linkedObjectIdArray, eZContentObject::RELATION_LINK );
            }
            if ( !empty( $linkedObjectIdArray ) || !empty( $embeddedObjectIdArray ) )
            {
                $object->commitInputRelations( $currentVersion->attribute( 'version' ) );
            }

        }
    }
function onPublish ( $ contentObjectAttribute , $ object , $ publishedNodes ) { $ currentVersion = $ object -> currentVersion ( ) ; $ langMask = $ currentVersion -> attribute ( 'language_mask' ) ; // We find all translations present in the current version. We calculate // this from the language mask already present in the fetched version, // so no further round-trip to the DB is required. $ languageList = eZContentLanguage :: decodeLanguageMask ( $ langMask , true ) ; $ languageList = $ languageList [ 'language_list' ] ; // We want to have the class attribute identifier of the attribute // containing the current ezxmltext, as we then can use the more efficient // eZContentObject->fetchAttributesByIdentifier() to get the data $ identifier = $ contentObjectAttribute -> attribute ( 'contentclass_attribute_identifier' ) ; $ attributeArray = $ object -> fetchAttributesByIdentifier ( array ( $ identifier ) , $ currentVersion -> attribute ( 'version' ) , $ languageList ) ; foreach ( $ attributeArray as $ attribute ) { $ xmlText = eZXMLTextType :: rawXMLText ( $ attribute ) ; $ dom = new DOMDocument ( '1.0' , 'utf-8' ) ; if ( ! $ dom -> loadXML ( $ xmlText ) ) continue ; // urls $ urlIdArray = array ( ) ; foreach ( $ dom -> getElementsByTagName ( 'link' ) as $ link ) { // We are looking for external 'http://'-style links, not the internal // object or node links. if ( $ link -> hasAttribute ( 'url_id' ) ) { $ urlIdArray [ ] = $ link -> getAttribute ( 'url_id' ) ; } } $ urlIdArray = array_unique ( $ urlIdArray ) ; $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; eZSimplifiedXMLInput :: updateUrlObjectLinks ( $ attribute , $ urlIdArray ) ; $ db -> commit ( ) ; // linked objects $ linkedObjectIdArray = $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'link' ) ) ; // embedded objects $ embeddedObjectIdArray = array_merge ( $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'embed' ) ) , $ this -> getRelatedObjectList ( $ dom -> getElementsByTagName ( 'embed-inline' ) ) ) ; if ( ! empty ( $ embeddedObjectIdArray ) ) { $ object -> appendInputRelationList ( $ embeddedObjectIdArray , eZContentObject :: RELATION_EMBED ) ; } if ( ! empty ( $ linkedObjectIdArray ) ) { $ object -> appendInputRelationList ( $ linkedObjectIdArray , eZContentObject :: RELATION_LINK ) ; } if ( ! empty ( $ linkedObjectIdArray ) || ! empty ( $ embeddedObjectIdArray ) ) { $ object -> commitInputRelations ( $ currentVersion -> attribute ( 'version' ) ) ; } } }
Method triggered on publish for xml text datatype

This method makes sure that links from all translations of an xml text
are registered in the ezurl_object_link table, and thus retained, if
previous versions of an object are removed.

It also checks for embedded objects in other languages xml, and makes
sure the matching object relations are stored for the publish version.

@param eZContentObjectAttribute $contentObjectAttribute
@param eZContentObject $object
@param array $publishedNodes
@return boolean
Method triggered on publish for xml text datatype