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


PHP eZContentClass::versionHistoryLimit方法代码示例

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


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

示例1: testVersionHistoryLimitWithObjectParameter

 /**
  * Unit test for eZContentClass::versionHistoryLimit() with object parameters
  *
  * Replica of testVersionHistoryLimit() but you cannot make calls
  * to the eZ API which relies on a database, as this is not present
  * in the provider methods.
  */
 public function testVersionHistoryLimitWithObjectParameter()
 {
     // different custom limits (article: 13, image: 6) and object as a parameter
     $INISettings = array(array('VersionHistoryClass', array('article' => 13, 'image' => 6)));
     $class = eZContentClass::fetchByIdentifier('image');
     $expectedLimit = 6;
     // change the INI limit settings
     foreach ($INISettings as $settings) {
         list($INIVariable, $INIValue) = $settings;
         ezpINIHelper::setINISetting('content.ini', 'VersionManagement', $INIVariable, $INIValue);
     }
     $limit = eZContentClass::versionHistoryLimit($class);
     self::assertEquals($expectedLimit, $limit);
     ezpINIHelper::restoreINISettings();
 }
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:22,代码来源:ezcontentclass_test.php

示例2: array

    // Check permission for object in specified language
    if ( !$obj->canEdit( false, false, false, $EditLanguage ) )
    {
        return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel',
                                     array( 'AccessList' => $obj->accessList( 'edit' ) ) );
    }
    $isAccessChecked = true;

    // Kept for backwards compatibility
    if ( $http->hasPostVariable( 'ContentObjectLanguageCode' ) )
    {
        $EditLanguage = $http->postVariable( 'ContentObjectLanguageCode' );
    }

    // Check the new version against history limit for class $classID
    $versionlimit = eZContentClass::versionHistoryLimit( $classID );
    $versionCount = $obj->getVersionCount();
    if ( $versionCount < $versionlimit )
    {
        $version = $obj->createNewVersionIn( $EditLanguage, $FromLanguage, false, true, eZContentObjectVersion::STATUS_INTERNAL_DRAFT );
        if ( !$http->hasPostVariable( 'DoNotEditAfterNewDraft' ) )
        {
            return $Module->redirectToView( 'edit', array( $ObjectID, $version->attribute( 'version' ), $EditLanguage ) );
        }
        else
        {
            return $Module->redirectToView( 'edit', array( $ObjectID, 'f', $EditLanguage ) );
        }
    }
    else
    {
开发者ID:robinmuilwijk,项目名称:ezpublish,代码行数:31,代码来源:edit.php

示例3: createNewVersion

    /**
     * Creates a new version and returns it as an eZContentObjectVersion object.
     *
     * 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 int|bool $copyFromVersion If given, that version is used to create a copy.
     * @param bool $versionCheck If \c true it will check if there are too many version and remove some of them to make room for a new.
     * @param string|bool $languageCode
     * @param string|bool $copyFromLanguageCode
     * @param int $status
     *
     * @return eZContentObjectVersion
     */
    function createNewVersion( $copyFromVersion = false, $versionCheck = true, $languageCode = false, $copyFromLanguageCode = false, $status = eZContentObjectVersion::STATUS_DRAFT )
    {
        $db = eZDB::instance();
        $db->begin();

        // get the next available version number
        $nextVersionNumber = $this->nextVersion();

        if ( $copyFromVersion == false )
        {
            $version = $this->currentVersion();
        }
        else
        {
            $version = $this->version( $copyFromVersion );
        }

        if ( !$languageCode )
        {
            $initialLanguage = $version->initialLanguage();
            if ( !$initialLanguage )
            {
                $initialLanguage = $this->initialLanguage();
            }

            if ( $initialLanguage )
            {
                $languageCode = $initialLanguage->attribute( 'locale' );
            }
        }

        $copiedVersion = $this->copyVersion( $this, $version, $nextVersionNumber, false, $status, $languageCode, $copyFromLanguageCode );

        // We need to make sure the copied version contains node-assignment for the existing nodes.
        // This is required for BC since scripts might traverse the node-assignments and mark
        // some of them for removal.
        $parentMap = array();
        $copiedNodeAssignmentList = $copiedVersion->attribute( 'node_assignments' );
        foreach ( $copiedNodeAssignmentList as $copiedNodeAssignment )
        {
            $parentMap[$copiedNodeAssignment->attribute( 'parent_node' )] = $copiedNodeAssignment;
        }
        $nodes = $this->assignedNodes();
        foreach ( $nodes as $node )
        {
            $remoteID = 0;
            // Remove assignments which conflicts with existing nodes, but keep remote_id
            if ( isset( $parentMap[$node->attribute( 'parent_node_id' )] ) )
            {
                $copiedNodeAssignment = $parentMap[$node->attribute( 'parent_node_id' )];
                $remoteID = $copiedNodeAssignment->attribute( 'remote_id' );
                $copiedNodeAssignment->purge();
            }
            $newNodeAssignment = $copiedVersion->assignToNode( $node->attribute( 'parent_node_id' ), $node->attribute( 'is_main' ), 0,
                                                               $node->attribute( 'sort_field' ), $node->attribute( 'sort_order' ),
                                                               $remoteID, $node->attribute( 'remote_id' ) );
            // Reset execution bit
            $newNodeAssignment->setAttribute( 'op_code', $newNodeAssignment->attribute( 'op_code' ) & ~1 );
            $newNodeAssignment->store();
        }

        // Removing last item if we don't have enough space in version list
        if ( $versionCheck )
        {
            $versionlimit = eZContentClass::versionHistoryLimit( $this->attribute( 'contentclass_id' ) );
            $versionCount = $this->getVersionCount();
            if ( $versionCount > $versionlimit )
            {
                // Remove oldest archived version
                $params = array( 'conditions'=> array( 'status' => eZContentObjectVersion::STATUS_ARCHIVED ) );
                $versions = $this->versions( true, $params );
                if ( count( $versions ) > 0 )
                {
                    $modified = $versions[0]->attribute( 'modified' );
                    $removeVersion = $versions[0];
                    foreach ( $versions as $version )
                    {
                        $currentModified = $version->attribute( 'modified' );
                        if ( $currentModified < $modified )
                        {
                            $modified = $currentModified;
                            $removeVersion = $version;
                        }
                    }
                    $removeVersion->removeThis();
                }
//.........这里部分代码省略.........
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:101,代码来源:ezcontentobject.php

示例4: array

 if (!$versionID or $version->attribute('status') == eZContentObjectVersion::STATUS_INTERNAL_DRAFT) {
     $currentVersion = $object->attribute('current_version');
     $Module->redirectToView('history', array($ObjectID, $currentVersion));
     return eZModule::HOOK_STATUS_CANCEL_RUN;
 }
 $languages = $Module->actionParameter('LanguageArray');
 if ($languages && array_key_exists($versionID, $languages)) {
     $language = $languages[$versionID];
 } else {
     $language = $version->initialLanguageCode();
 }
 if (!$object->checkAccess('edit', false, false, false, $language)) {
     return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
 }
 // Check the version limit for the object's class
 $versionlimit = eZContentClass::versionHistoryLimit($object->attribute('contentclass_id'));
 $versionCount = $object->getVersionCount();
 if ($versionCount < $versionlimit) {
     $db = eZDB::instance();
     $db->begin();
     $newVersionID = $object->copyRevertTo($versionID, $language);
     $db->commit();
     if (!$http->hasPostVariable('DoNotEditAfterCopy')) {
         return $Module->redirectToView('edit', array($ObjectID, $newVersionID, $language));
     }
 } else {
     $params = array('conditions' => array('status' => eZContentObjectVersion::STATUS_ARCHIVED));
     $versions = $object->versions(true, $params);
     if (count($versions) > 0) {
         $modified = $versions[0]->attribute('modified');
         $removeVersion = $versions[0];
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:history.php

示例5: while

$total = eZContentObjectTreeNode::subTreeCountByNodeID($subTreeParams, 1);
$cli->output("{$total} objects to check... (In the progess bar, 'R' means that at least a version was removed)");
$script->setIterationData('R', '.');
$script->resetIteration($total);
$subTreeParams['Offset'] = 0;
$subTreeParams['Limit'] = 100;
$db = eZDB::instance();
while (true) {
    $nodes = eZContentObjectTreeNode::subTreeByNodeID($subTreeParams, 1);
    if (empty($nodes)) {
        break;
    }
    foreach ($nodes as $node) {
        $object = $node->attribute('object');
        $versionCount = $object->getVersionCount();
        $versionLimit = eZContentClass::versionHistoryLimit($object->attribute('content_class'));
        if ($versionCount <= $versionLimit) {
            $script->iterate($cli, false, "Nothing to do on object #{$object->attribute('id')}");
            continue;
        }
        $versionToRemove = $versionCount - $versionLimit;
        $versions = $object->versions(true, array('conditions' => array('status' => eZContentObjectVersion::STATUS_ARCHIVED), 'sort' => array('modified' => 'asc'), 'limit' => array('limit' => $versionToRemove, 'offset' => 0)));
        $removedVersion = 0;
        $db->begin();
        foreach ($versions as $version) {
            $version->removeThis();
            $removedVersion++;
        }
        $db->commit();
        if ($removedVersion > 0) {
            $script->iterate($cli, true, "Removed {$removedVersion} archived versions of object #{$object->attribute('id')}");
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:31,代码来源:cleanupversions.php


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