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


PHP eZContentObject::fetchSameClassListCount方法代码示例

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


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

示例1: array

        $validation['class_errors'][] = array('text' => ezpI18n::tr('kernel/class', 'There is a class already having the same identifier.'));
        $basicClassPropertiesValid = false;
    }
    unset($classList);
    if (!$basicClassPropertiesValid) {
        $db->commit();
        $canStore = false;
        $validation['processed'] = false;
    } else {
        if (!$http->hasSessionVariable('ClassCanStoreTicket')) {
            $db->commit();
            return $Module->redirectToView('view', array($ClassID), array('Language' => $EditLanguage));
        }
        $unorderedParameters = array('Language' => $EditLanguage);
        // Is there existing objects of this content class?
        if (eZContentObject::fetchSameClassListCount($ClassID) > 0) {
            eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'ContentClassEditHandler')))->store($class, $attributes, $unorderedParameters);
        } else {
            $unorderedParameters['ScheduledScriptID'] = 0;
            $class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
        }
        $db->commit();
        $http->removeSessionVariable('ClassCanStoreTicket');
        ezpEvent::getInstance()->notify('content/class/cache', array($ClassID));
        return $Module->redirectToView('view', array($ClassID), $unorderedParameters);
    }
}
// Store changes
if ($canStore) {
    $class->store($attributes);
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:31,代码来源:edit.php

示例2: install

 function install($package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
 {
     $serializedNameListNode = $content->getElementsByTagName('serialized-name-list')->item(0);
     $serializedNameList = $serializedNameListNode ? $serializedNameListNode->textContent : false;
     $classNameList = new eZContentClassNameList($serializedNameList);
     if ($classNameList->isEmpty()) {
         $classNameList->initFromString($content->getElementsByTagName('name')->item(0)->textContent);
         // for backward compatibility( <= 3.8 )
     }
     $classNameList->validate();
     $serializedDescriptionListNode = $content->getElementsByTagName('serialized-description-list')->item(0);
     $serializedDescriptionList = $serializedDescriptionListNode ? $serializedDescriptionListNode->textContent : false;
     $classDescriptionList = new eZSerializedObjectNameList($serializedDescriptionList);
     $classIdentifier = $content->getElementsByTagName('identifier')->item(0)->textContent;
     $classRemoteID = $content->getElementsByTagName('remote-id')->item(0)->textContent;
     $classObjectNamePattern = $content->getElementsByTagName('object-name-pattern')->item(0)->textContent;
     $classURLAliasPattern = is_object($content->getElementsByTagName('url-alias-pattern')->item(0)) ? $content->getElementsByTagName('url-alias-pattern')->item(0)->textContent : null;
     $classIsContainer = $content->getAttribute('is-container');
     if ($classIsContainer !== false) {
         $classIsContainer = $classIsContainer == 'true' ? 1 : 0;
     }
     $classRemoteNode = $content->getElementsByTagName('remote')->item(0);
     $classID = $classRemoteNode->getElementsByTagName('id')->item(0)->textContent;
     $classGroupsNode = $classRemoteNode->getElementsByTagName('groups')->item(0);
     $classCreated = $classRemoteNode->getElementsByTagName('created')->item(0)->textContent;
     $classModified = $classRemoteNode->getElementsByTagName('modified')->item(0)->textContent;
     $classCreatorNode = $classRemoteNode->getElementsByTagName('creator')->item(0);
     $classModifierNode = $classRemoteNode->getElementsByTagName('modifier')->item(0);
     $classAttributesNode = $content->getElementsByTagName('attributes')->item(0);
     $dateTime = time();
     $classCreated = $dateTime;
     $classModified = $dateTime;
     $userID = false;
     if (isset($installParameters['user_id'])) {
         $userID = $installParameters['user_id'];
     }
     $class = eZContentClass::fetchByRemoteID($classRemoteID);
     if ($class) {
         $className = $class->name();
         $description = ezpI18n::tr('kernel/package', "Class '%classname' already exists.", false, array('%classname' => $className));
         $choosenAction = $this->errorChoosenAction(self::ERROR_EXISTS, $installParameters, $description, $this->HandlerType);
         switch ($choosenAction) {
             case eZPackage::NON_INTERACTIVE:
             case self::ACTION_REPLACE:
                 if (eZContentClassOperations::remove($class->attribute('id')) == false) {
                     eZDebug::writeWarning("Unable to remove class '{$className}'.");
                     return true;
                 }
                 eZDebug::writeNotice("Class '{$className}' will be replaced.", 'eZContentClassPackageHandler');
                 break;
             case self::ACTION_SKIP:
                 return true;
             case self::ACTION_NEW:
                 $class->setAttribute('remote_id', eZRemoteIdUtility::generate('class'));
                 $class->store();
                 $classNameList->appendGroupName(" (imported)");
                 break;
             default:
                 $installParameters['error'] = array('error_code' => self::ERROR_EXISTS, 'element_id' => $classRemoteID, 'description' => $description, 'actions' => array());
                 if ($class->isRemovable()) {
                     $errorMsg = ezpI18n::tr('kernel/package', "Replace existing class");
                     $objectsCount = eZContentObject::fetchSameClassListCount($class->attribute('id'));
                     if ($objectsCount) {
                         $errorMsg .= ' ' . ezpI18n::tr('kernel/package', "(Warning! {$objectsCount} content object(s) and their sub-items will be removed)");
                     }
                     $installParameters['error']['actions'][self::ACTION_REPLACE] = $errorMsg;
                 }
                 $installParameters['error']['actions'][self::ACTION_SKIP] = ezpI18n::tr('kernel/package', 'Skip installing this class');
                 $installParameters['error']['actions'][self::ACTION_NEW] = ezpI18n::tr('kernel/package', 'Keep existing and create a new one');
                 return false;
         }
     }
     unset($class);
     // Try to create a unique class identifier
     $currentClassIdentifier = $classIdentifier;
     $unique = false;
     while (!$unique) {
         $classList = eZContentClass::fetchByIdentifier($currentClassIdentifier);
         if ($classList) {
             // "increment" class identifier
             if (preg_match('/^(.*)_(\\d+)$/', $currentClassIdentifier, $matches)) {
                 $currentClassIdentifier = $matches[1] . '_' . ($matches[2] + 1);
             } else {
                 $currentClassIdentifier = $currentClassIdentifier . '_1';
             }
         } else {
             $unique = true;
         }
         unset($classList);
     }
     $classIdentifier = $currentClassIdentifier;
     $values = array('version' => 0, 'serialized_name_list' => $classNameList->serializeNames(), 'serialized_description_list' => $classDescriptionList->serializeNames(), 'create_lang_if_not_exist' => true, 'identifier' => $classIdentifier, 'remote_id' => $classRemoteID, 'contentobject_name' => $classObjectNamePattern, 'url_alias_name' => $classURLAliasPattern, 'is_container' => $classIsContainer, 'created' => $classCreated, 'modified' => $classModified);
     if ($content->hasAttribute('sort-field')) {
         $values['sort_field'] = eZContentObjectTreeNode::sortFieldID($content->getAttribute('sort-field'));
     } else {
         eZDebug::writeNotice('The sort field was not specified in the content class package. ' . 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__);
     }
     if ($content->hasAttribute('sort-order')) {
         $values['sort_order'] = $content->getAttribute('sort-order');
     } else {
//.........这里部分代码省略.........
开发者ID:legende91,项目名称:ez,代码行数:101,代码来源:ezcontentclasspackagehandler.php

示例3: updateClass

function updateClass($classId)
{
    global $cli, $script, $db, $scheduledScript;
    // 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);
    if (!$class) {
        $cli->error('Could not fetch class with ID: ' . $classId);
        return;
    }
    $classAttributes = $class->fetchAttributes();
    $classAttributeIDs = array();
    foreach ($classAttributes as $classAttribute) {
        $classAttributeIDs[] = $classAttribute->attribute('id');
    }
    $objectCount = eZContentObject::fetchSameClassListCount($classId);
    $cli->output('Number of objects to be processed: ' . $objectCount);
    $counter = 0;
    $offset = 0;
    $limit = 100;
    $objects = eZContentObject::fetchSameClassList($classId, true, $offset, $limit);
    // Add and/or remove attributes for all versions and translations of all objects of this class
    while (count($objects) > 0) {
        // Run a transaction per $limit objects
        $db->begin();
        foreach ($objects as $object) {
            $contentObjectID = $object->attribute('id');
            $objectVersions = $object->versions();
            foreach ($objectVersions as $objectVersion) {
                $versionID = $objectVersion->attribute('version');
                $translations = $objectVersion->translations();
                foreach ($translations as $translation) {
                    $translationName = $translation->attribute('language_code');
                    // Class attribute IDs of object attributes (not necessarily the same as those in the class, hence the manual sql)
                    $objectClassAttributeIDs = array();
                    $rows = $db->arrayQuery("SELECT id,contentclassattribute_id, data_type_string\n                                              FROM ezcontentobject_attribute\n                                              WHERE contentobject_id = '{$contentObjectID}' AND\n                                                    version = '{$versionID}' AND\n                                                    language_code='{$translationName}'");
                    foreach ($rows as $row) {
                        $objectClassAttributeIDs[$row['id']] = $row['contentclassattribute_id'];
                    }
                    // Quick array diffs
                    $attributesToRemove = array_diff($objectClassAttributeIDs, $classAttributeIDs);
                    // Present in the object, not in the class
                    $attributesToAdd = array_diff($classAttributeIDs, $objectClassAttributeIDs);
                    // Present in the class, not in the object
                    // Remove old attributes
                    foreach ($attributesToRemove as $objectAttributeID => $classAttributeID) {
                        $objectAttribute = eZContentObjectAttribute::fetch($objectAttributeID, $versionID);
                        if (!is_object($objectAttribute)) {
                            continue;
                        }
                        $objectAttribute->remove($objectAttributeID);
                    }
                    // Add new attributes
                    foreach ($attributesToAdd as $classAttributeID) {
                        $objectAttribute = eZContentObjectAttribute::create($classAttributeID, $contentObjectID, $versionID, $translationName);
                        if (!is_object($objectAttribute)) {
                            continue;
                        }
                        $objectAttribute->setAttribute('language_code', $translationName);
                        $objectAttribute->initialize();
                        $objectAttribute->store();
                        $objectAttribute->postInitialize();
                    }
                }
            }
            // Progress bar and Script Monitor progress
            $cli->output('.', false);
            $counter++;
            if ($counter % 70 == 0 or $counter >= $objectCount) {
                $progressPercentage = $counter / $objectCount * 100;
                $cli->output(sprintf(' %01.1f %%', $progressPercentage));
                if ($scheduledScript) {
                    $scheduledScript->updateProgress($progressPercentage);
                }
            }
        }
        $db->commit();
        $offset += $limit;
        $objects = eZContentObject::fetchSameClassList($classId, true, $offset, $limit);
    }
    // Set the object name to the first attribute, if not set
    $classAttributes = $class->fetchAttributes();
    // Fetch the first attribute
    if (count($classAttributes) > 0 && trim($class->attribute('contentobject_name')) == '') {
        $db->begin();
        $identifier = $classAttributes[0]->attribute('identifier');
        $identifier = '<' . $identifier . '>';
        $class->setAttribute('contentobject_name', $identifier);
        $class->store();
        $db->commit();
    }
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:97,代码来源:addmissingobjectattributes.php

示例4: array

global $cli;
global $currencyList;
$currencyList = false;
$cli = eZCLI::instance();
$script = eZScript::instance(array('description' => "\n" . "This script will convert objects with 'price' datatype to\n" . "the objects with 'multiprice' datatype.\n", 'use-session' => false, 'use-modules' => true, 'use-extensions' => true, 'user' => true));
$script->startup();
$scriptOptions = $script->getOptions("", "", array(), false, array('user' => true));
$script->initialize();
$convertedObjectsCount = 0;
$classList = eZContentClass::fetchList();
$db = eZDB::instance();
$db->begin();
foreach ($classList as $class) {
    if (eZShopFunctions::isSimplePriceClass($class)) {
        $classID = $class->attribute('id');
        $objectListCount = eZContentObject::fetchSameClassListCount($classID);
        if ($objectListCount == 0) {
            $cli->output("No objects found for '" . $class->attribute('name') . "' class");
            continue;
        }
        $cli->output("Processing objects of the '" . $class->attribute('name') . "' class");
        $defaultCurrency = currencyForLocale();
        if (!$defaultCurrency) {
            $script->shutdown(1);
        }
        $defaultCurrencyCode = $defaultCurrency->attribute('code');
        $priceClassAttribute = eZShopFunctions::priceAttribute($class);
        $priceClassAttributeID = $priceClassAttribute->attribute('id');
        // replace 'ezprice' class attribute with 'ezmultiprice'.
        $priceClassAttribute->setAttribute('data_type_string', 'ezmultiprice');
        $priceClassAttribute->setAttribute(eZMultiPriceType::DEFAULT_CURRENCY_CODE_FIELD, $defaultCurrencyCode);
开发者ID:netbliss,项目名称:ezpublish,代码行数:31,代码来源:convertprice2multiprice.php

示例5: deleteClass

 private function deleteClass($classIdentifier)
 {
     $chunkSize = 1000;
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $contentClass = eZContentClass::fetch($classId);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]");
     }
     $totalObjectCount = eZContentObject::fetchSameClassListCount($classId);
     echo "Deleting " . $totalObjectCount . " objects.\n";
     $moreToDelete = 0 < $totalObjectCount;
     $totalDeleted = 0;
     // need to operate in a privileged account - use doug@mugo.ca
     $adminUserObject = eZUser::fetch(eepSetting::PrivilegedAccountId);
     $adminUserObject->loginCurrent();
     while ($moreToDelete) {
         $params["IgnoreVisibility"] = true;
         $params['Limitation'] = array();
         $params['Limit'] = $chunkSize;
         $params['ClassFilterType'] = "include";
         $params['ClassFilterArray'] = array($classIdentifier);
         $children = eZContentObjectTreeNode::subTreeByNodeID($params, 2);
         foreach ($children as $child) {
             $info = eZContentObjectTreeNode::subtreeRemovalInformation(array($child->NodeID));
             if (!$info["can_remove_all"]) {
                 $msg = " permission is denied for nodeid=" . $child->NodeID;
                 // todo, this can yield an infinite loop if some objects are
                 // not deleteable, but you don't take that number into account
                 // at the bottom of the loop - where there will always be
                 // some >0 number of undeleteable objects left
                 echo $msg . "\n";
                 continue;
             }
             $removeResult = eZContentObjectTreeNode::removeSubtrees(array($child->NodeID), false, false);
             if (true === $removeResult) {
                 $totalDeleted += 1;
             } else {
                 $msg = " failed to delete nodeid=" . $child->NodeID;
                 echo $msg . "\n";
             }
             echo "Percent complete: " . sprintf("% 3.3f", $totalDeleted / $totalObjectCount * 100.0) . "%\r";
             unset($GLOBALS['eZContentObjectContentObjectCache']);
             unset($GLOBALS['eZContentObjectDataMapCache']);
             unset($GLOBALS['eZContentObjectVersionCache']);
         }
         $moreToDelete = 0 < eZContentObject::fetchSameClassListCount($classId);
     }
     echo "\nDone deleting objects.\n";
     $adminUserObject->logoutCurrent();
     eZContentClassClassGroup::removeClassMembers($classId, 0);
     eZContentClassClassGroup::removeClassMembers($classId, 1);
     // Fetch real version and remove it
     $contentClass->remove(true);
     // this seems to mainly cause an exception, might be an idea to simply skip it
     // Fetch temp version and remove it
     $tempDeleteClass = eZContentClass::fetch($classId, true, 1);
     if ($tempDeleteClass != null) {
         $tempDeleteClass->remove(true, 1);
     }
 }
开发者ID:truffo,项目名称:eep,代码行数:60,代码来源:index.php

示例6: sync


//.........这里部分代码省略.........
             $mainGroupID = $classGroups[0]->attribute('group_id');
             $mainGroupName = $classGroups[0]->attribute('group_name');
         }
     } else {
         $user = eZUser::currentUser();
         $contentIni = eZINI::instance('content.ini');
         $timeOut = $contentIni->variable('ClassSettings', 'DraftTimeout');
         /** @var eZContentClassClassGroup[] $groupList */
         $groupList = $temporary->fetchGroupList();
         if (count($groupList) > 0) {
             $mainGroupID = $groupList[0]->attribute('group_id');
             $mainGroupName = $groupList[0]->attribute('group_name');
         }
         if ($temporary->attribute('modifier_id') != $user->attribute('contentobject_id') && $temporary->attribute('modified') + $timeOut > time()) {
             throw new Exception("Modifica alla classe non permessa");
         }
     }
     /** @var eZContentClassAttribute[] $localeAttributes */
     $localeAttributes = array();
     foreach ($this->currentClass->fetchAttributes() as $attribute) {
         /** @var eZContentClassAttribute $attribute */
         $attribute->setAttribute('version', eZContentClass::VERSION_STATUS_TEMPORARY);
         $localeAttributes[$attribute->attribute('identifier')] = $attribute;
     }
     $this->currentClass->setAttribute('version', eZContentClass::VERSION_STATUS_TEMPORARY);
     $remote = $this->getRemote();
     if ($remote === null) {
         throw new Exception("Classe remota non trovata");
     }
     if ($force && $this->getData()->hasError) {
         foreach ($this->getData()->errors as $identifier => $value) {
             if (!$localeAttributes[$identifier] instanceof eZContentClassAttribute) {
                 throw new Exception('Errore forzando la sincronizzazione');
             }
             foreach ($remote->DataMap[0] as $originalAttribute) {
                 if ($originalAttribute->Identifier == $identifier) {
                     ezpEvent::getInstance()->notify('classtools/switch_class_attribute', array($localeAttributes[$identifier], $originalAttribute));
                     if ($value == 'data_type_string') {
                         $localeAttributes[$identifier]->setAttribute('data_type_string', $originalAttribute->DataTypeString);
                         $localeAttributes[$identifier]->store();
                         $this->changeContentObjectAttributeDataTypeString($localeAttributes[$identifier], $originalAttribute->DataTypeString);
                         unset($this->notifications[self::ERROR][$originalAttribute->Identifier]);
                     } else {
                         $this->data->missingAttributes[] = $originalAttribute;
                         $this->currentClass->removeAttributes(array($localeAttributes[$identifier]));
                         unset($localeAttributes[$identifier]);
                     }
                     break;
                 }
             }
         }
     }
     $attributes = array();
     foreach ($this->properties as $identifier => $remoteProperty) {
         if ($remote->{$remoteProperty} != $this->currentClass->attribute($identifier)) {
             $this->currentClass->setAttribute($identifier, $remote->{$remoteProperty});
             if ($identifier == 'serialized_name_list') {
                 $nameList = new eZContentClassNameList();
                 $nameList->initFromSerializedList($remote->{$remoteProperty});
                 $this->currentClass->NameList = $nameList;
             } elseif ($identifier == 'serialized_description_list') {
                 $descriptionList = new eZSerializedObjectNameList();
                 $descriptionList->initFromSerializedList($remote->{$remoteProperty});
                 $this->currentClass->DescriptionList = $descriptionList;
             }
         }
     }
     foreach ($this->getData()->missingAttributes as $originalAttribute) {
         $add = $this->addAttribute($originalAttribute);
         if ($add) {
             $attributes[] = $add;
         }
     }
     foreach ($remote->DataMap[0] as $originalAttribute) {
         if (isset($localeAttributes[$originalAttribute->Identifier])) {
             $modified = $this->syncAttribute($originalAttribute, $localeAttributes[$originalAttribute->Identifier]);
             if ($modified) {
                 $attributes[] = $modified;
             }
         }
     }
     if (!$removeExtras) {
         foreach ($this->extraContentObjectAttributes as $extra) {
             $extra->setAttribute('placement', count($attributes) + 1);
             $attributes[] = $extra;
         }
     }
     $this->currentClass->store($attributes);
     $db = eZDB::instance();
     $db->begin();
     $unorderedParameters = array('Language' => $this->EditLanguage);
     if (eZContentObject::fetchSameClassListCount($this->id) > 0) {
         eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'ContentClassEditHandler')))->store($this->currentClass, $attributes, $unorderedParameters);
     } else {
         $unorderedParameters['ScheduledScriptID'] = 0;
         $this->currentClass->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
     }
     $db->commit();
     $this->syncGroups();
 }
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:101,代码来源:occlasstools.php

示例7: updateContentObjectAttributes

 /**
  * update all the objects with the new attribute info
  * todo; this might have to support processing in batches
  */
 static function updateContentObjectAttributes($contentClass, $classAttributeID, $identifier = false)
 {
     $classId = $contentClass->attribute("id");
     // update object attributes
     $countProcessed = 0;
     $batchSize = 200;
     $totalObjectCount = eZContentObject::fetchSameClassListCount($classId);
     for ($offset = 0; $offset < $totalObjectCount; $offset += $batchSize) {
         $objects = eZContentObject::fetchSameClassList($classId, false, $offset, $batchSize);
         foreach ($objects as $num => $object) {
             $object = eZContentObject::fetch($object["id"]);
             if ($object) {
                 $contentobjectID = $object->attribute("id");
                 $objectVersions = $object->versions();
                 foreach ($objectVersions as $objectVersion) {
                     $translations = $objectVersion->translations(false);
                     $version = $objectVersion->attribute("version");
                     $dataMap = $objectVersion->attribute("data_map");
                     if ($identifier && isset($dataMap[$identifier])) {
                         // Attribute already exists for this object version
                     } else {
                         foreach ($translations as $translation) {
                             $objectAttribute = eZContentObjectAttribute::create($classAttributeID, $contentobjectID, $version);
                             $objectAttribute->setAttribute("language_code", $translation);
                             $objectAttribute->initialize();
                             $objectAttribute->store();
                             $objectAttribute->postInitialize();
                         }
                     }
                 }
                 $countProcessed += 1;
             }
             echo "Percent complete: " . sprintf("% 3.2f", $countProcessed / $totalObjectCount * 100.0) . "%\r";
         }
         unset($GLOBALS["eZContentObjectContentObjectCache"]);
         unset($GLOBALS["eZContentObjectDataMapCache"]);
         unset($GLOBALS["eZContentObjectVersionCache"]);
         unset($objects);
     }
     echo "\n";
 }
开发者ID:truffo,项目名称:eep,代码行数:45,代码来源:AttributeFunctions.php

示例8: ezcConsoleProgressbar

<?php

$db     = eZDB::instance();
$class  = eZContentClass::fetchByIdentifier('article');
$count  = (int) eZContentObject::fetchSameClassListCount($class->ID);
$offset = 0;

$db->arrayQuery('TRUNCATE TABLE mm_rating;');
$db->arrayQuery('TRUNCATE TABLE mm_readcount;');

$progressBar = new ezcConsoleProgressbar( new ezcConsoleOutput(), $count, array(
    'emptyChar' => ' ',
    'barChar'   => '='
) );

$ratingQuery = 'INSERT INTO mm_rating (object_id, cluster_identifier, rating, counter, to_reindex) VALUES ';
$readQuery   = 'INSERT INTO mm_readcount (node_id, cluster_identifier, date, count, to_reindex) VALUES ';

while($count > 0)
{
    $objects = eZContentObject::fetchSameClassList($class->ID, false, $offset, 100);

    foreach($objects as $row)
    {
        $ratingValues = array();

        for($i=1; $i <= 10; $i++)
        {
            $ratingValues[] = sprintf("(%s, 'cluster_france', %s, %s, 1)", $row['id'], $i, mt_rand(0, 200));
        }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:30,代码来源:update_rating.php

示例9: addClassAttributes

 public static function addClassAttributes($class_identifier, $attributesInfo)
 {
     if (isset($class_identifier)) {
         $class = eZContentClass::fetchByIdentifier($class_identifier);
     }
     if (!is_object($class)) {
         return;
     }
     $classID = $class->attribute('id');
     foreach ($attributesInfo as $attributeInfo) {
         $classAttributeIdentifier = $attributeInfo['identifier'];
         $classAttributeName = $attributeInfo['name'];
         $datatype = $attributeInfo['data_type_string'];
         $defaultValue = isset($attributeInfo['default_value']) ? $attributeInfo['default_value'] : false;
         $canTranslate = isset($attributeInfo['can_translate']) ? $attributeInfo['can_translate'] : 1;
         $isRequired = isset($attributeInfo['is_required']) ? $attributeInfo['is_required'] : 0;
         $isSearchable = isset($attributeInfo['is_searchable']) ? $attributeInfo['is_searchable'] : 1;
         $attrContent = isset($attributeInfo['content']) ? $attributeInfo['content'] : false;
         $attrCreateInfo = array('identifier' => $classAttributeIdentifier, 'name' => $classAttributeName, 'can_translate' => $canTranslate, 'is_required' => $isRequired, 'is_searchable' => $isSearchable);
         $newAttribute = eZContentClassAttribute::create($classID, $datatype, $attrCreateInfo);
         $dataType = $newAttribute->dataType();
         $dataType->initializeClassAttribute($newAttribute);
         // not all datatype can have 'default_value'. do check here.
         if ($defaultValue !== false) {
             switch ($datatype) {
                 case 'ezboolean':
                     $newAttribute->setAttribute('data_int3', $defaultValue);
                     break;
                 default:
                     break;
             }
         }
         if ($attrContent) {
             $newAttribute->setContent($attrContent);
         }
         // store attribute, update placement, etc...
         $attributes = $class->fetchAttributes();
         $attributes[] = $newAttribute;
         // remove temporary version
         if ($newAttribute->attribute('id') !== null) {
             $newAttribute->remove();
         }
         $newAttribute->setAttribute('version', eZContentClass::VERSION_STATUS_DEFINED);
         $newAttribute->setAttribute('placement', count($attributes));
         $class->adjustAttributePlacements($attributes);
         foreach ($attributes as $attribute) {
             $attribute->storeDefined();
         }
         // update objects
         $classAttributeID = $newAttribute->attribute('id');
         $count = eZContentObject::fetchSameClassListCount($class->ID);
         $output = new ezcConsoleOutput();
         $bar = new ezcConsoleProgressbar($output, (int) $count);
         $offset = 0;
         $limit = 50;
         while (true) {
             if ($offset > $count) {
                 break;
             }
             $objects = eZContentObject::fetchSameClassList($classID, true, $offset, $limit);
             foreach ($objects as $object) {
                 $contentobjectID = $object->attribute('id');
                 $objectVersions = $object->versions();
                 foreach ($objectVersions as $objectVersion) {
                     $translations = $objectVersion->translations(false);
                     $version = $objectVersion->attribute('version');
                     foreach ($translations as $translation) {
                         $objectAttribute = eZContentObjectAttribute::create($classAttributeID, $contentobjectID, $version);
                         $objectAttribute->setAttribute('language_code', $translation);
                         $objectAttribute->initialize();
                         $objectAttribute->store();
                         $objectAttribute->postInitialize();
                     }
                 }
                 $bar->advance();
             }
             eZContentObject::clearCache();
             $offset += $limit;
         }
         $bar->finish();
     }
 }
开发者ID:rantoniazzi,项目名称:xrowmetadata,代码行数:82,代码来源:xrowsiteupdater.php


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