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


PHP eZContentObject::fetchSameClassList方法代码示例

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


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

示例1: remove

 static function remove($classID)
 {
     $contentClass = eZContentClass::fetch($classID);
     if ($contentClass == null or !$contentClass->isRemovable()) {
         return false;
     }
     // Remove all objects
     $contentObjects = eZContentObject::fetchSameClassList($classID);
     foreach ($contentObjects as $contentObject) {
         eZContentObjectOperations::remove($contentObject->attribute('id'));
     }
     if (count($contentObjects) == 0) {
         eZContentObject::expireAllViewCache();
     }
     eZContentClassClassGroup::removeClassMembers($classID, 0);
     eZContentClassClassGroup::removeClassMembers($classID, 1);
     // Fetch real version and remove it
     $contentClass->remove(true);
     // Fetch temp version and remove it
     $tempDeleteClass = eZContentClass::fetch($classID, true, 1);
     if ($tempDeleteClass != null) {
         $tempDeleteClass->remove(true, 1);
     }
     return true;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:25,代码来源:ezcontentclassoperations.php

示例2: initSettings

 function initSettings($parameters)
 {
     $siteINI = eZINI::instance();
     $classIdentifier = 'template_look';
     //get the class
     $class = eZContentClass::fetchByIdentifier($classIdentifier, true, eZContentClass::VERSION_STATUS_TEMPORARY);
     if (!$class) {
         $class = eZContentClass::fetchByIdentifier($classIdentifier, true, eZContentClass::VERSION_STATUS_DEFINED);
         if (!$class) {
             eZDebug::writeError("Warning, DEFINED version for class identifier {$classIdentifier} does not exist.");
             return;
         }
     }
     $classId = $class->attribute('id');
     $this->Settings['template_look_class_id'] = $classId;
     $objects = eZContentObject::fetchSameClassList($classId);
     if (!count($objects)) {
         eZDebug::writeError("Object of class {$classIdentifier} does not exist.");
         return;
     }
     $templateLookObject = $objects[0];
     $this->Settings['template_look_object'] = $templateLookObject;
     $this->Settings['template_look_object_id'] = $templateLookObject->attribute('id');
     if (!is_array($parameters)) {
         return;
     }
     $this->addSetting('admin_account_id', eZSiteInstaller::getParam($parameters, 'object_remote_map/1bb4fe25487f05527efa8bfd394cecc7', ''));
     $this->addSetting('guest_accounts_id', eZSiteInstaller::getParam($parameters, 'object_remote_map/5f7f0bdb3381d6a461d8c29ff53d908f', ''));
     $this->addSetting('anonymous_accounts_id', eZSiteInstaller::getParam($parameters, 'object_remote_map/15b256dbea2ae72418ff5facc999e8f9', ''));
     $this->addSetting('package_object', eZSiteInstaller::getParam($parameters, 'package_object', false));
     $this->addSetting('design_list', eZSiteInstaller::getParam($parameters, 'design_list', array()));
     $this->addSetting('main_site_design', strtolower($this->solutionName()));
     $this->addSetting('extension_list', array('ezwt', 'ezstarrating', 'ezgmaplocation', strtolower($this->solutionName())));
     $this->addSetting('version', $this->solutionVersion());
     $this->addSetting('locales', eZSiteInstaller::getParam($parameters, 'all_language_codes', array()));
     // usual user siteaccess like 'ezwebin_site'
     $this->addSetting('user_siteaccess', eZSiteInstaller::getParam($parameters, 'user_siteaccess', ''));
     // usual admin siteaccess like 'ezwebin_site_admin'
     $this->addSetting('admin_siteaccess', eZSiteInstaller::getParam($parameters, 'admin_siteaccess', ''));
     // extra siteaccess based on languages info, like 'eng', 'rus', ...
     $this->addSetting('language_based_siteaccess_list', $this->languageNameListFromLocaleList($this->setting('locales')));
     $this->addSetting('user_siteaccess_list', array_merge(array($this->setting('user_siteaccess')), $this->setting('language_based_siteaccess_list')));
     $this->addSetting('all_siteaccess_list', array_merge($this->setting('user_siteaccess_list'), array($this->setting('admin_siteaccess'))));
     $this->addSetting('access_type', eZSiteInstaller::getParam($parameters, 'site_type/access_type', ''));
     $this->addSetting('access_type_value', eZSiteInstaller::getParam($parameters, 'site_type/access_type_value', ''));
     $this->addSetting('admin_access_type_value', eZSiteInstaller::getParam($parameters, 'site_type/admin_access_type_value', ''));
     $this->addSetting('host', eZSiteInstaller::getParam($parameters, 'host', ''));
     $siteaccessUrls = array('admin' => $this->createSiteaccessUrls(array('siteaccess_list' => array($this->setting('admin_siteaccess')), 'access_type' => $this->setting('access_type'), 'access_type_value' => $this->setting('admin_access_type_value'), 'host' => $this->setting('host'), 'host_prepend_siteaccess' => false)), 'user' => $this->createSiteaccessUrls(array('siteaccess_list' => array($this->setting('user_siteaccess')), 'access_type' => $this->setting('access_type'), 'access_type_value' => $this->setting('access_type_value'), 'host' => $this->setting('host'), 'host_prepend_siteaccess' => false)), 'translation' => $this->createSiteaccessUrls(array('siteaccess_list' => $this->setting('language_based_siteaccess_list'), 'access_type' => $this->setting('access_type'), 'access_type_value' => $this->setting('access_type_value') + 1, 'host' => $this->setting('host'), 'exclude_port_list' => array($this->setting('admin_access_type_value'), $this->setting('access_type_value')))));
     $this->addSetting('siteaccess_urls', $siteaccessUrls);
     $this->addSetting('primary_language', eZSiteInstaller::getParam($parameters, 'all_language_codes/0', ''));
     $this->addSetting('var_dir', eZSiteInstaller::getParam($parameters, 'var_dir', 'var/' . $this->setting('user_siteaccess')));
 }
开发者ID:heliopsis,项目名称:ezwebin,代码行数:52,代码来源:ezwebininstaller.php

示例3: objectList

 function objectList()
 {
     return eZContentObject::fetchSameClassList($this->ID);
 }
开发者ID:nlenardou,项目名称:ezpublish,代码行数:4,代码来源:ezcontentclass.php

示例4: foreach

}
$canRemoveCount = 0;
foreach ($deleteIDArray as $deleteID) {
    $ClassObjectsCount = 0;
    $class = eZContentClass::fetch($deleteID);
    if ($class != null) {
        $class = eZContentClass::fetch($deleteID);
        $ClassID = $class->attribute('id');
        $ClassName = $class->attribute('name');
        if (!$class->isRemovable()) {
            $item = array("className" => $ClassName, 'objectCount' => 0, "is_removable" => false, 'reason' => $class->removableInformation());
            $DeleteResult[] = $item;
            continue;
        }
        ++$canRemoveCount;
        $classObjects = eZContentObject::fetchSameClassList($ClassID);
        $ClassObjectsCount = count($classObjects);
        $item = array("className" => $ClassName, "is_removable" => true, "objectCount" => $ClassObjectsCount);
        $DeleteResult[] = $item;
    }
}
$canRemove = $canRemoveCount > 0;
$Module->setTitle(ezpI18n::tr('kernel/class', 'Remove classes %class_id', null, array('%class_id' => $ClassID)));
$tpl = eZTemplate::factory();
$tpl->setVariable('module', $Module);
$tpl->setVariable('GroupID', $GroupID);
$tpl->setVariable('DeleteResult', $DeleteResult);
$tpl->setVariable('already_removed', $alreadyRemoved);
$tpl->setVariable('can_remove', $canRemove);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/removeclass.tpl");
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:31,代码来源:removeclass.php

示例5: attribute_migrate

 private function attribute_migrate($classIdentifier, $srcAttribute, $conversion, $destAttribute)
 {
     $contentClass = eZContentClass::fetchByIdentifier($classIdentifier);
     if (!$contentClass) {
         throw new Exception("Failed to instantiate content class [" . $classIdentifier . "]");
     }
     $classDataMap = $contentClass->attribute("data_map");
     if (!isset($classDataMap[$srcAttribute])) {
         throw new Exception("Content class '" . $classIdentifier . "' does not contain this attribute: [" . $srcAttribute . "]");
     }
     if (!isset($classDataMap[$destAttribute])) {
         throw new Exception("Content class '" . $classIdentifier . "' does not contain this attribute: [" . $destAttribute . "]");
     }
     $classId = $contentClass->attribute("id");
     $objects = eZContentObject::fetchSameClassList($classId, false);
     $numObjects = count($objects);
     $conversionFunc = null;
     switch ($conversion) {
         default:
             echo "This mapping is not supported: [" . $conversion . "]\n";
             return;
             break;
         case "rot13":
             $conversionFunc = "convertStringToRot13";
             break;
         case "time2integer":
             $conversionFunc = "convertTimeToInteger";
             break;
         case "trim":
             $conversionFunc = "convertTrim";
             break;
         case "date2ts":
             $conversionFunc = "dateToTS";
             break;
     }
     foreach ($objects as $n => $object) {
         $object = eZContentObject::fetch($object["id"]);
         if ($object) {
             // copy data with conversion
             $dataMap = $object->DataMap();
             $src = $dataMap[$srcAttribute];
             $dest = $dataMap[$destAttribute];
             $dest->fromString(eep::$conversionFunc($src->toString()));
             $dest->store();
             // publish to get changes recognized, eg object title updated
             eep::republishObject($object->attribute("id"));
         }
         echo "Percent complete: " . sprintf("% 3.3f", ($n + 1.0) / $numObjects * 100.0) . "%\r";
         // clear caches
         unset($GLOBALS["eZContentObjectContentObjectCache"]);
         unset($GLOBALS["eZContentObjectDataMapCache"]);
         unset($GLOBALS["eZContentObjectVersionCache"]);
         unset($object);
     }
     echo "\n";
 }
开发者ID:truffo,项目名称:eep,代码行数:56,代码来源:index.php

示例6: addClassAttributes

    function addClassAttributes( $params )
    {
        $classInfo = $params['class'];
        $attributesInfo = $params['attributes'];

        $classID = isset( $classInfo['id'] ) ? $classInfo['id'] : false;
        if( $classID )
        {
            $class = eZContentClass::fetch( $classID );
        }
        else
        {
            if( isset( $classInfo['identifier'] ) )
            {
                $class = eZSiteInstaller::classByIdentifier( $classInfo );
            }
            else
            {
                $this->reportError( "neither 'id' nor 'identifier' is set for content class" ,
                                    'eZSiteInstaller::addClassAttribute' );
            }
        }

        if( !is_object( $class ) )
        {
            $this->reportError( "Can't fetch content class" ,
                                'eZSiteInstaller::addClassAttribute' );
            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'] : 0;
            $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' );
            $objects = eZContentObject::fetchSameClassList( $classID );
            foreach( $objects as $object )
            {
                $contentobjectID = $object->attribute( 'id' );
                $objectVersions = $object->versions();
                foreach( $objectVersions as $objectVersion )
                {
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezsiteinstaller.php

示例7: initializeObjectAttributes

    /**
     * Initialize the attribute in the existing objects.
     *
     * @param mixed $objects not used, the existing objects are fetched if
     *        necessary (depending on the datatype of the attribute).
     */
    function initializeObjectAttributes( &$objects = null )
    {
        $classAttributeID = $this->ID;
        $classID = $this->ContentClassID;
        $dataType = $this->attribute( 'data_type' );
        if ( $dataType->supportsBatchInitializeObjectAttribute() )
        {
            $db = eZDB::instance();

            $data = array( 'contentobject_id'         => 'a.contentobject_id',
                           'version'                  => 'a.version',
                           'contentclassattribute_id' => $classAttributeID,
                           'data_type_string'         => "'" . $db->escapeString( $this->DataTypeString ) . "'",
                           'language_code'            => 'a.language_code',
                           'language_id'              => 'MAX(a.language_id)' );

            $datatypeData = $dataType->batchInitializeObjectAttributeData( $this );
            $data = array_merge( $data, $datatypeData );

            $cols = implode( ', ', array_keys( $data ) );
            $values = implode( ', ', $data );

            $sql = "INSERT INTO ezcontentobject_attribute( $cols )
            SELECT $values
            FROM ezcontentobject_attribute a, ezcontentobject o
            WHERE o.id = a.contentobject_id AND
                  o.contentclass_id=$classID
            GROUP BY contentobject_id,
                     version,
                     language_code";

            $db->query( $sql );
            // update ids to keep them same with one attribute for different versions
            if( $db->databaseName() == 'mysql' )
            {
                $updateSql = "UPDATE ezcontentobject_attribute,
                                 ( SELECT contentobject_id, language_code, version, contentclassattribute_id, MIN( id ) AS minid
                                 FROM ezcontentobject_attribute WHERE contentclassattribute_id = $classAttributeID
                              GROUP BY contentobject_id, language_code, version, contentclassattribute_id ) t
                              SET ezcontentobject_attribute.id = t.minid
                              WHERE ezcontentobject_attribute.contentobject_id = t.contentobject_id
                              AND ezcontentobject_attribute.language_code = t.language_code
                              AND ezcontentobject_attribute.contentclassattribute_id = $classAttributeID";
            }
            else if( $db->databaseName() == 'postgresql' )
            {
                $updateSql = "UPDATE ezcontentobject_attribute
                              SET id=t.minid FROM
                                ( SELECT contentobject_id, language_code, version, contentclassattribute_id, MIN( id ) AS minid
                                 FROM ezcontentobject_attribute WHERE contentclassattribute_id = $classAttributeID
                                 GROUP BY contentobject_id, language_code, version, contentclassattribute_id ) t
                              WHERE ezcontentobject_attribute.contentobject_id = t.contentobject_id
                              AND ezcontentobject_attribute.language_code = t.language_code
                              AND ezcontentobject_attribute.contentclassattribute_id = $classAttributeID";
            }
            else if( $db->databaseName() == 'oracle' )
            {
                $updateSql = "UPDATE ezcontentobject_attribute a SET a.id = (
                                 SELECT MIN( id ) FROM ezcontentobject_attribute b
                                 WHERE b.contentclassattribute_id = $classAttributeID
                                       AND b.contentobject_id = a.contentobject_id
                                       AND b.language_code = a.language_code )
                                WHERE a.contentclassattribute_id = $classAttributeID";
            }
            else
            {
                $updateSql = "";
            }
            $db->query( $updateSql );
        }
        else
        {
            $limit = 1000;
            $offset = 0;
            while ( true )
            {
                $contentObjects = eZContentObject::fetchSameClassList( $classID, true, $offset, $limit );
                if ( empty( $contentObjects ) )
                {
                    break;
                }

                foreach ( $contentObjects as $object )
                {
                    $contentobjectID = $object->attribute( 'id' );
                    $objectVersions = $object->versions();
                    // the start version ID, to make sure one attribute in different version has same id.
                    $startAttributeID = array();
                    foreach ( $objectVersions as $objectVersion )
                    {
                        $translations = $objectVersion->translations( false );
                        $version = $objectVersion->attribute( 'version' );
                        foreach ( $translations as $translation )
                        {
//.........这里部分代码省略.........
开发者ID:nottavi,项目名称:ezpublish,代码行数:101,代码来源:ezcontentclassattribute.php

示例8: unset

     $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);
 $priceClassAttribute->store();
 unset($GLOBALS['eZContentClassAttributeCache'][$priceClassAttributeID]);
 // update objects
 $offset = 0;
 $limit = 1000;
 $cli->output('Converting', false);
 while ($offset < $objectListCount) {
     $objectList = eZContentObject::fetchSameClassList($class->attribute('id'), true, $offset, $limit);
     $offset += count($objectList);
     foreach ($objectList as $object) {
         $contentObjectID = $object->attribute('id');
         $objectVersions =& $object->versions();
         foreach ($objectVersions as $objectVersion) {
             $version = $objectVersion->attribute('version');
             $objectAttributeList = eZContentObjectAttribute::fetchSameClassAttributeIDList($priceClassAttributeID, true, $version, $contentObjectID);
             foreach ($objectAttributeList as $objectAttribute) {
                 $priceValue = $objectAttribute->attribute('data_float');
                 $multiprice = eZMultiPriceData::create($objectAttribute->attribute('id'), $version, $defaultCurrencyCode, $priceValue, eZMultiPriceData::VALUE_TYPE_CUSTOM);
                 $multiprice->store();
                 $objectAttribute->setAttribute('data_type_string', 'ezmultiprice');
                 $objectAttribute->setAttribute('data_float', 0);
                 $objectAttribute->setAttribute('sort_key_int', 0);
                 $objectAttribute->store();
开发者ID:netbliss,项目名称:ezpublish,代码行数:31,代码来源:convertprice2multiprice.php

示例9: 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

示例10: execute


//.........这里部分代码省略.........
         }
         foreach ($classAttributeList as $classAttributeNode) {
             $attributeDatatype = $classAttributeNode->getAttribute('datatype');
             $attributeIsRequired = strtolower($classAttributeNode->getAttribute('required')) == 'true';
             $attributeIsSearchable = strtolower($classAttributeNode->getAttribute('searchable')) == 'true';
             $attributeIsInformationCollector = strtolower($classAttributeNode->getAttribute('informationCollector')) == 'true';
             $attributeIsTranslatable = strtolower($classAttributeNode->getAttribute('translatable')) == 'false' ? 0 : 1;
             $attributeIdentifier = $classAttributeNode->getAttribute('identifier');
             $attributePlacement = $classAttributeNode->getAttribute('placement');
             $attributeNameListObject = $classAttributeNode->getElementsByTagName('Names')->item(0);
             if ($attributeNameListObject->hasAttributes()) {
                 if ($attributeNameListObject->hasAttributes()) {
                     $attributes = $attributeNameListObject->attributes;
                     if (!is_null($attributes)) {
                         $attributeNameList = array();
                         foreach ($attributes as $index => $attr) {
                             $attributeNameList[$attr->name] = $attr->value;
                         }
                     }
                 }
             }
             $classAttributeNameList = new eZContentClassNameList(serialize($attributeNameList));
             $classAttributeNameList->validate();
             $attributeDatatypeParameterNode = $classAttributeNode->getElementsByTagName('DatatypeParameters')->item(0);
             $classAttribute = $class->fetchAttributeByIdentifier($attributeIdentifier);
             $params = array();
             $params['identifier'] = $attributeIdentifier;
             $params['name_list'] = $classAttributeNameList;
             $params['data_type_string'] = $attributeDatatype;
             $params['default_value'] = '';
             $params['can_translate'] = $attributeIsTranslatable;
             $params['is_required'] = $attributeIsRequired;
             $params['is_searchable'] = $attributeIsSearchable;
             $params['content'] = '';
             $params['placement'] = $attributePlacement;
             $params['is_information_collector'] = $attributeIsInformationCollector;
             $params['datatype-parameter'] = $this->parseAndReplaceNodeStringReferences($attributeDatatypeParameterNode);
             $params['attribute-node'] = $classAttributeNode;
             if (!array_key_exists($attributeIdentifier, $classDataMap)) {
                 $this->writeMessage("\t\tClass '{$classIdentifier}' will get new Attribute '{$attributeIdentifier}'.", 'notice');
                 $updateAttributeList[] = $this->addClassAttribute($class, $params);
             } else {
                 $this->writeMessage("\t\tClass '{$classIdentifier}' will get updated Attribute '{$attributeIdentifier}'.", 'notice');
                 $this->updateClassAttribute($class, $params);
             }
         }
         if ($this->adjustAttributesPlacement) {
             //once every attribute has been processed, we may reset placement
             $this->writeMessage("\t\tAdjusting attributes placement.", 'notice');
             $this->adjustClassAttributesPlacement($class);
         }
         if (count($updateAttributeList)) {
             $this->writeMessage("\t\tUpdating content object attributes.", 'notice');
             $classID = $class->attribute('id');
             // update object attributes
             $objects = eZContentObject::fetchSameClassList($classID, false);
             foreach ($objects as $objectID) {
                 $object = eZContentObject::fetch($objectID['id']);
                 if ($object) {
                     $contentobjectID = $object->attribute('id');
                     $objectVersions = $object->versions();
                     foreach ($objectVersions as $objectVersion) {
                         $translations = $objectVersion->translations(false);
                         $version = $objectVersion->attribute('version');
                         foreach ($translations as $translation) {
                             foreach ($updateAttributeList as $classAttributeID) {
                                 $objectAttribute = eZContentObjectAttribute::create($classAttributeID, $contentobjectID, $version);
                                 $objectAttribute->setAttribute('language_code', $translation);
                                 $objectAttribute->initialize();
                                 $objectAttribute->store();
                                 $objectAttribute->postInitialize();
                             }
                         }
                     }
                 }
                 unset($object);
             }
         }
         if ($classNameList) {
             $classNameList->store($class);
         }
         // add class to a class group
         $classGroupsList = $classGroupsNode->getElementsByTagName('Group');
         foreach ($classGroupsList as $classGroupNode) {
             $classGroupName = $classGroupNode->getAttribute('name');
             $classGroup = eZContentClassGroup::fetchByName($classGroupName);
             if (!$classGroup) {
                 $classGroup = eZContentClassGroup::create();
                 $classGroup->setAttribute('name', $classGroupName);
                 $classGroup->store();
             }
             $classGroup->appendClass($class);
         }
         if ($referenceID) {
             $refArray[$referenceID] = $class->attribute('id');
         }
     }
     $this->addReference($refArray);
     eZContentCacheManager::clearAllContentCache();
 }
开发者ID:heliopsis,项目名称:ezxmlinstaller,代码行数:101,代码来源:ezcreateclass.php

示例11: initializeObjectAttributes

 function initializeObjectAttributes(&$objects = null)
 {
     $classAttributeID = $this->ID;
     $classID = $this->ContentClassID;
     $dataType = $this->attribute('data_type');
     if ($dataType->supportsBatchInitializeObjectAttribute()) {
         $db = eZDB::instance();
         $data = array('contentobject_id' => 'a.contentobject_id', 'version' => 'a.version', 'contentclassattribute_id' => $classAttributeID, 'data_type_string' => "'" . $db->escapeString($this->DataTypeString) . "'", 'language_code' => 'a.language_code', 'language_id' => 'MAX(a.language_id)');
         $datatypeData = $dataType->batchInitializeObjectAttributeData($this);
         $data = array_merge($data, $datatypeData);
         $cols = implode(', ', array_keys($data));
         $values = implode(', ', $data);
         $sql = "INSERT INTO ezcontentobject_attribute( {$cols} )\n            SELECT {$values}\n            FROM ezcontentobject_attribute a, ezcontentobject o\n            WHERE o.id = a.contentobject_id AND\n                  o.contentclass_id={$classID}\n            GROUP BY contentobject_id,\n                     version,\n                     language_code";
         $db->query($sql);
     } else {
         if (!is_array($objects)) {
             $objects = eZContentObject::fetchSameClassList($classID);
         }
         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, $translation);
                     $objectAttribute->setAttribute('language_code', $translation);
                     $objectAttribute->initialize();
                     $objectAttribute->store();
                     $objectAttribute->postInitialize();
                 }
             }
         }
     }
 }
开发者ID:rmiguel,项目名称:ezpublish,代码行数:35,代码来源:ezcontentclassattribute.php

示例12: fetchallinstances

 private function fetchallinstances($classIdentifier, $additional)
 {
     $limit = false;
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = false;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $classId = eZContentClass::classIDByIdentifier($classIdentifier);
     $allInstances = eZContentObject::fetchSameClassList($classId, false, $offset, $limit);
     $title = "All instances of content class '" . $classIdentifier . "'";
     eep::displayNonObjectList($allInstances, $title);
 }
开发者ID:truffo,项目名称:eep,代码行数:15,代码来源:index.php

示例13: 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

示例14: ezcConsoleProgressbar

$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));
        }

        $db->arrayQuery($ratingQuery . implode(', ', $ratingValues) . ';');

        $readValues = array();
        $nodes = eZContentObjectTreeNode::fetchByContentObjectID($row['id'], false);
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:30,代码来源:update_rating.php

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