当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentObjectTreeNode::unserialize方法代码示例

本文整理汇总了PHP中eZContentObjectTreeNode::unserialize方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::unserialize方法的具体用法?PHP eZContentObjectTreeNode::unserialize怎么用?PHP eZContentObjectTreeNode::unserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZContentObjectTreeNode的用法示例。


在下文中一共展示了eZContentObjectTreeNode::unserialize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: unserialize

    static function unserialize( $domNode, $contentObject, $ownerID, $sectionID, $activeVersion, $firstVersion, &$nodeList, &$options, $package, $handlerType = 'ezcontentobject' )
    {

        $oldVersion = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'version' );
        $status = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
        $languageNodeArray = $domNode->getElementsByTagName( 'object-translation' );

        $initialLanguage   = false;
        $importedLanguages = $options['language_array'];
        $currentLanguages  = array();
        foreach( $languageNodeArray as $languageNode )
        {
            $language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
            if ( in_array( $language, $importedLanguages ) )
            {
                $currentLanguages[] = $language;
            }
        }
        foreach ( eZContentLanguage::prioritizedLanguages() as $language )
        {
            if ( in_array( $language->attribute( 'locale' ), $currentLanguages ) )
            {
                $initialLanguage = $language->attribute( 'locale' );
                break;
            }
        }
        if ( !$initialLanguage )
        {
            $initialLanguage = $currentLanguages[0];
        }

        if ( $firstVersion )
        {
            $contentObjectVersion = $contentObject->version( 1 );
        }
        else
        {
            // Create new version in specific language but with empty data.
            $contentObjectVersion = $contentObject->createNewVersionIn( $initialLanguage );
        }

        $created = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'created' ) );
        $modified = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) );
        $contentObjectVersion->setAttribute( 'created', $created );
        $contentObjectVersion->setAttribute( 'modified', $modified );

        $contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
        $contentObjectVersion->store();

        $db = eZDB::instance();
        $db->begin();
        foreach( $languageNodeArray as $languageNode )
        {
            $language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
            // Only import allowed languages.
            if ( !in_array( $language, $importedLanguages ) )
            {
                continue;
            }

            $attributeArray = $contentObjectVersion->contentObjectAttributes( $language );
            if ( count( $attributeArray ) == 0)
            {
                $hasTranslation = eZContentLanguage::fetchByLocale( $language );

                if ( !$hasTranslation )
                {
                    // if there is no needed translation in system then add it
                    $locale = eZLocale::instance( $language );

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

                if ( $hasTranslation )
                {
                    // Add translated attributes for the translation
                    $originalContentAttributes = $contentObjectVersion->contentObjectAttributes( $initialLanguage );
                    foreach ( $originalContentAttributes as $originalContentAttribute )
                    {
                        $contentAttribute = $originalContentAttribute->translateTo( $language );
                        $contentAttribute->sync();
                        $attributeArray[] = $contentAttribute;
                    }
                }

                // unserialize object name in current version-translation
                $objectName = $languageNode->getAttribute( 'object_name' );
                if ( $objectName )
                    $contentObject->setName( $objectName, $contentObjectVersion->attribute( 'version' ), $language );
            }

            $xpath = new DOMXPath( $domNode->ownerDocument );
            $xpath->registerNamespace( 'ezobject', 'http://ez.no/object/' );
            $xpath->registerNamespace( 'ezremote', 'http://ez.no/ezobject' );
//.........这里部分代码省略.........
开发者ID:ataxel,项目名称:tp,代码行数:101,代码来源:ezcontentobjectversion.php


注:本文中的eZContentObjectTreeNode::unserialize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。