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


PHP eZContentObjectVersion::attribute方法代码示例

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


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

示例1: copyVersion

    /**
     * Creates a new version and returns it as an eZContentObjectVersion object.
     *
     * If version number is given as argument that version is used to create a copy.
     *
     * 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 eZContentObject $newObject
     * @param eZContentObjectVersion $version
     * @param int $newVersionNumber
     * @param int|bool $contentObjectID
     * @param int $status
     * @param string|bool $languageCode If false all languages will be copied, otherwise only specified by the locale code string or an array of the locale code strings.
     * @param string|bool $copyFromLanguageCode
     *
     * @return eZContentObjectVersion
     */
    function copyVersion( &$newObject, &$version, $newVersionNumber, $contentObjectID = false, $status = eZContentObjectVersion::STATUS_DRAFT, $languageCode = false, $copyFromLanguageCode = false )
    {
        $user = eZUser::currentUser();
        $userID = $user->attribute( 'contentobject_id' );

        $nodeAssignmentList = $version->attribute( 'node_assignments' );

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

        // This is part of the new 3.8 code.
        foreach ( $nodeAssignmentList as $nodeAssignment )
        {
            // Only copy assignments which has a remote_id since it will be used in template code.
            if ( $nodeAssignment->attribute( 'remote_id' ) == 0 )
            {
                continue;
            }
            $clonedAssignment = $nodeAssignment->cloneNodeAssignment( $newVersionNumber, $contentObjectID );
            $clonedAssignment->setAttribute( 'op_code', eZNodeAssignment::OP_CODE_SET ); // Make sure op_code is marked to 'set' the data.
            $clonedAssignment->store();
        }

        $currentVersionNumber = $version->attribute( "version" );
        $contentObjectTranslations = $version->translations();

        $clonedVersion = $version->cloneVersion( $newVersionNumber, $userID, $contentObjectID, $status );

        if ( $contentObjectID != false )
        {
            if ( $clonedVersion->attribute( 'status' ) == eZContentObjectVersion::STATUS_PUBLISHED )
                $clonedVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
        }

        $clonedVersion->store();

        // We copy related objects before the attributes, this means that the related objects
        // are available once the datatype code is run.
        $this->copyContentObjectRelations( $currentVersionNumber, $newVersionNumber, $contentObjectID );

        $languageCodeToCopy = false;
        if ( $languageCode && in_array( $languageCode, $this->availableLanguages() ) )
        {
            $languageCodeToCopy = $languageCode;
        }
        if ( $copyFromLanguageCode && in_array( $copyFromLanguageCode, $this->availableLanguages() ) )
        {
            $languageCodeToCopy = $copyFromLanguageCode;
        }

        $haveCopied = false;
        if ( !$languageCode || $languageCodeToCopy )
        {
            foreach ( $contentObjectTranslations as $contentObjectTranslation )
            {
                if ( $languageCode != false && $contentObjectTranslation->attribute( 'language_code' ) != $languageCodeToCopy )
                {
                    continue;
                }

                $contentObjectAttributes = $contentObjectTranslation->objectAttributes();

                foreach ( $contentObjectAttributes as $attribute )
                {
                    $clonedAttribute = $attribute->cloneContentObjectAttribute( $newVersionNumber, $currentVersionNumber, $contentObjectID, $languageCode );
                    $clonedAttribute->sync();
                    eZDebugSetting::writeDebug( 'kernel-content-object-copy', $clonedAttribute, 'copyVersion:cloned attribute' );
                }

                $haveCopied = true;
            }
        }

        if ( !$haveCopied && $languageCode )
        {
            $class = $this->contentClass();
            $classAttributes = $class->fetchAttributes();
            foreach ( $classAttributes as $classAttribute )
            {
                if ( $classAttribute->attribute( 'can_translate' ) == 1 )
                {
                    $classAttribute->instantiate( $contentObjectID? $contentObjectID: $this->attribute( 'id' ), $languageCode, $newVersionNumber );
//.........这里部分代码省略.........
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:101,代码来源:ezcontentobject.php

示例2: queue

 /**
  * Adds a version to the publishing queue
  * @param eZContentObjectVersion $version
  * @return ezpContentPublishingProcess
  */
 public static function queue(eZContentObjectVersion $version)
 {
     $row = array('ezcontentobject_version_id' => $version->attribute('id'), 'created' => time(), 'status' => self::STATUS_PENDING);
     $processObject = new self($row);
     $processObject->store();
     return $processObject;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:12,代码来源:ezpcontentpublishingprocess.php

示例3: refreshDataMap

 /**
  * Refreshes content object attributes for current fields.
  * Mandatory to update good attributes when publishing
  * @param eZContentObjectVersion $version Draft to be published
  * @see SQLIContentPublisher::publish()
  */
 public function refreshDataMap(eZContentObjectVersion $version)
 {
     $contentObject = $version->contentObject();
     // Copy missing translations from published version to current draft if needed
     eZContentOperationCollection::copyTranslations($contentObject->attribute('id'), $version->attribute('version'));
     $dataMap = $contentObject->fetchDataMap($version->attribute('version'), $this->language);
     foreach ($this->fields as $fieldName => $field) {
         if (isset($dataMap[$fieldName])) {
             $field->setRawAttribute($dataMap[$fieldName]);
         } else {
             eZDebug::writeWarning(__METHOD__ . ' => Attribute "' . $fieldName . '" not set in data map. Cannot refresh field.', 'SQLIImport');
         }
     }
 }
开发者ID:nicolasaguenot,项目名称:sqliimport,代码行数:20,代码来源:sqlicontentfiedset.php


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