本文整理汇总了PHP中eZContentObjectAttribute::count方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectAttribute::count方法的具体用法?PHP eZContentObjectAttribute::count怎么用?PHP eZContentObjectAttribute::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectAttribute
的用法示例。
在下文中一共展示了eZContentObjectAttribute::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateClass
function updateClass($classId, $scheduledScript)
{
$cli = eZCLI::instance();
/*
// If the class is not stored yet, store it now
$class = eZContentClass::fetch( $classId, true, eZContentClass::VERSION_STATUS_TEMPORARY );
if ( $class )
{
$cli->output( "Storing class" );
$class->storeDefined( $class->fetchAttributes() );
}
*/
// Fetch the stored class
$class = eZContentClass::fetch($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
if (!$class) {
$cli->error('No class in a modified version status with ID: ' . $classId);
return;
}
// Fetch attributes and definitions
$attributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
$oldClassAttributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_DEFINED);
// Delete object attributes which have been removed.
foreach ($oldClassAttributes as $oldClassAttribute) {
$attributeExist = false;
$oldClassAttributeID = $oldClassAttribute->attribute('id');
foreach ($attributes as $newClassAttribute) {
if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
$attributeExist = true;
}
}
if (!$attributeExist) {
$ezscriptmonitorINI = eZINI::instance('ezscriptmonitor.ini');
$objectLimit = $ezscriptmonitorINI->variable('GeneralSettings', 'ObjectLimit');
$limit = array('offset' => 0, 'length' => $objectLimit);
do {
$objectAttributes = eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID, false, false, false, $limit);
$objectAttributeCount = count($objectAttributes);
$conditions = array("contentclassattribute_id" => $oldClassAttributeID);
$totalObjectAttributeCount = eZContentObjectAttribute::count(eZContentObjectAttribute::definition(), array("contentclassattribute_id" => $oldClassAttributeID));
if (is_array($objectAttributes) && $objectAttributeCount > 0) {
$db = eZDB::instance();
$db->begin();
foreach ($objectAttributes as $objectAttribute) {
$objectAttribute = new eZContentObjectAttribute($objectAttribute);
$objectAttribute->removeThis($objectAttribute->attribute('id'));
}
$db->commit();
$limit['offset'] += $objectAttributeCount;
$percentage = round(100 * $limit['offset'] / $totalObjectAttributeCount, 2);
// for ezscriptmonitor 100 means the script is all the way done
if ($percentage < 100 && $scheduledScript !== false) {
$scheduledScript->updateProgress($percentage);
}
$cli->output("Removing attributes - Progress: " . $percentage . " %");
}
} while ($objectAttributeCount == $objectLimit);
}
}
$class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
// Add object attributes which have been added.
foreach ($attributes as $newClassAttribute) {
$attributeExist = false;
foreach ($oldClassAttributes as $oldClassAttribute) {
if ($oldClassAttribute->attribute('id') == $newClassAttribute->attribute('id')) {
$attributeExist = true;
break;
}
}
if (!$attributeExist) {
$objects = null;
$cli->output("Adding attribute : " . $newClassAttribute->attribute('name'));
$newClassAttribute->initializeObjectAttributes($objects);
}
}
if ($scheduledScript !== false) {
$scheduledScript->updateProgress(100);
}
}