本文整理汇总了PHP中eZContentObjectVersion::fetchFiltered方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectVersion::fetchFiltered方法的具体用法?PHP eZContentObjectVersion::fetchFiltered怎么用?PHP eZContentObjectVersion::fetchFiltered使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectVersion
的用法示例。
在下文中一共展示了eZContentObjectVersion::fetchFiltered方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDraftVersions
public function getDraftVersions($objects)
{
$return = array();
$user = eZUser::currentUser();
foreach ($objects as $object) {
// If this user already has a draft in this language
$filters = array('contentobject_id' => $object->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)), 'creator_id' => $user->attribute('contentobject_id'));
$existingDrafts = eZContentObjectVersion::fetchFiltered($filters, 0, 1);
if (!empty($existingDrafts)) {
$return[] = $existingDrafts[0];
} else {
$return[] = $object->createNewVersion(false, true);
}
}
return $return;
}
示例2: removeVersions
static function removeVersions( $versionStatus = false, $limit = false, $expiryTime = false, $fetchPortionSize = 50 )
{
$statuses = array( eZContentObjectVersion::STATUS_DRAFT,
eZContentObjectVersion::STATUS_PENDING,
eZContentObjectVersion::STATUS_REJECTED,
eZContentObjectVersion::STATUS_ARCHIVED,
eZContentObjectVersion::STATUS_INTERNAL_DRAFT );
if ( $versionStatus === false )
{
$versionStatus = $statuses;
}
else if ( !is_array( $versionStatus ) )
{
$versionStatus = array( $versionStatus );
}
$versionStatus = array_unique( $versionStatus );
$checkIntersect = array_intersect( $versionStatus, $statuses );
if ( count( $checkIntersect ) != count( $versionStatus ) )
{
eZDebug::writeError( 'Invalid version status was passed in.', __METHOD__ );
return false;
}
if ( $limit !== false and ( !is_numeric( $limit ) or $limit < 0 ) )
{
eZDebug::writeError( '$limit must be either false or positive numeric value.', __METHOD__ );
return false;
}
if ( !is_numeric( $fetchPortionSize ) or $fetchPortionSize < 1 )
$fetchPortionSize = 50;
$filters = array();
$filters['status'] = array( $versionStatus );
if ( $expiryTime !== false )
$filters['modified'] = array( '<', $expiryTime );
$processedCount = 0;
$db = eZDB::instance();
while ( $processedCount < $limit or !$limit )
{
// fetch by versions by preset portion at a time to avoid memory overflow
$tmpLimit = ( !$limit or ( $limit - $processedCount ) > $fetchPortionSize ) ?
$fetchPortionSize : $limit - $processedCount;
$versions = eZContentObjectVersion::fetchFiltered( $filters, 0, $tmpLimit );
if ( count( $versions ) < 1 )
break;
foreach ( $versions as $version )
{
$db->begin();
$version->removeThis();
$db->commit();
}
$processedCount += count( $versions );
}
return $processedCount;
}
示例3: getCurrentDraft
/**
* Returns current draft for current content object.
* If there is no current draft, a new one will be created in provided language.
* @param string|bool $lang Valid locale xxx-XX. If not provided, default edit language will be used
* @see eZContentObject::createNewVersionIn()
* @return eZContentObjectVersion
*/
public function getCurrentDraft($lang = false)
{
$currentDraft = null;
$db = eZDB::instance();
// First check if we already have a draft
$aFilter = array('contentobject_id' => $this->contentObject->attribute('id'), 'status' => array(array(eZContentObjectVersion::STATUS_DRAFT, eZContentObjectVersion::STATUS_INTERNAL_DRAFT)));
$res = eZContentObjectVersion::fetchFiltered($aFilter, null, null);
if (count($res) > 0 && $res[0] instanceof eZContentObjectVersion) {
$currentDraft = $res[0];
// FIXME : Fetch may result several drafts. We should take the last one (highest version)
$currentDraft->setAttribute('modified', eZDateTime::currentTimeStamp());
$currentDraft->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$currentDraft->store();
} else {
$db->begin();
$currentDraft = $this->contentObject->createNewVersionIn($lang, false, $this->contentObject->attribute('current_version'));
$currentDraft->store();
$db->commit();
}
return $currentDraft;
}