Esempio n. 1
0
 static function fetchList($user_id = false, $asObject = true)
 {
     $conds = array();
     if ($user_id !== false and is_numeric($user_id)) {
         $conds["creator_id"] = $user_id;
     }
     return eZPersistentObject::fetchObjectList(eZContentClassGroup::definition(), null, $conds, null, null, $asObject);
 }
 public static function getGroupedClasses()
 {
     /** @var ContainerInterface $container */
     $container = ezpKernel::instance()->getServiceContainer();
     $params = $container->getParameter('kaliop_class_select');
     $classInclude = $classExclude = $groupInclude = $groupExclude = false;
     $cgparams = array();
     if (!empty($params['classes']['include'])) {
         $classInclude = true;
         $cgparams = $params['classes']['include'];
     } elseif (!empty($params['classes']['exclude'])) {
         $classExclude = true;
         $cgparams = $params['classes']['exclude'];
     } elseif (!empty($params['class_groups']['include'])) {
         $groupInclude = true;
         $cgparams = $params['class_groups']['include'];
     } elseif (!empty($params['class_groups']['exclude'])) {
         $groupExclude = true;
         $cgparams = $params['class_groups']['exclude'];
     }
     $groups = eZContentClassGroup::fetchList(false, true);
     $return = array();
     $count = 0;
     foreach ($groups as $group) {
         if ($groupInclude and (in_array($group->attribute('id'), $cgparams) or in_array($group->attribute('name'), $cgparams)) or !$groupInclude and $groupExclude and (!in_array($group->attribute('id'), $cgparams) or !in_array($group->attribute('name'), $cgparams)) or !$groupInclude and !$groupExclude) {
             $array = array('name' => $group->attribute('name'), 'classes' => array());
             $count++;
             $classes = eZContentClassClassGroup::fetchClassList(0, $group->attribute('id'), true);
             foreach ($classes as $class) {
                 if ($classInclude and (in_array($class->attribute('id'), $cgparams) or in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and $classExclude and (!in_array($class->attribute('id'), $cgparams) or !in_array($class->attribute('identifier'), $cgparams)) or !$classInclude and !$classExclude) {
                     $array['classes'][] = array('identifier' => $class->attribute('identifier'), 'name' => $class->attribute('name'));
                     $count++;
                 }
             }
             $return[] = $array;
         }
     }
     return array('result' => array('groups' => $return, 'total' => $count));
 }
 static function classDOMTree($class)
 {
     if (!$class) {
         $retValue = false;
         return $retValue;
     }
     $dom = new DOMDocument('1.0', 'utf-8');
     $classNode = $dom->createElement('content-class');
     $dom->appendChild($classNode);
     $serializedNameListNode = $dom->createElement('serialized-name-list');
     $serializedNameListNode->appendChild($dom->createTextNode($class->attribute('serialized_name_list')));
     $classNode->appendChild($serializedNameListNode);
     $identifierNode = $dom->createElement('identifier');
     $identifierNode->appendChild($dom->createTextNode($class->attribute('identifier')));
     $classNode->appendChild($identifierNode);
     $serializedDescriptionListNode = $dom->createElement('serialized-description-list');
     $serializedDescriptionListNode->appendChild($dom->createTextNode($class->attribute('serialized_description_list')));
     $classNode->appendChild($serializedDescriptionListNode);
     $remoteIDNode = $dom->createElement('remote-id');
     $remoteIDNode->appendChild($dom->createTextNode($class->attribute('remote_id')));
     $classNode->appendChild($remoteIDNode);
     $objectNamePatternNode = $dom->createElement('object-name-pattern');
     $objectNamePatternNode->appendChild($dom->createTextNode($class->attribute('contentobject_name')));
     $classNode->appendChild($objectNamePatternNode);
     $urlAliasPatternNode = $dom->createElement('url-alias-pattern');
     $urlAliasPatternNode->appendChild($dom->createTextNode($class->attribute('url_alias_name')));
     $classNode->appendChild($urlAliasPatternNode);
     $isContainer = $class->attribute('is_container') ? 'true' : 'false';
     $classNode->setAttribute('is-container', $isContainer);
     $classNode->setAttribute('always-available', $class->attribute('always_available') ? 'true' : 'false');
     $classNode->setAttribute('sort-field', eZContentObjectTreeNode::sortFieldName($class->attribute('sort_field')));
     $classNode->setAttribute('sort-order', $class->attribute('sort_order'));
     // Remote data start
     $remoteNode = $dom->createElement('remote');
     $classNode->appendChild($remoteNode);
     $ini = eZINI::instance();
     $siteName = $ini->variable('SiteSettings', 'SiteURL');
     $classURL = 'http://' . $siteName . '/class/view/' . $class->attribute('id');
     $siteURL = 'http://' . $siteName . '/';
     $siteUrlNode = $dom->createElement('site-url');
     $siteUrlNode->appendChild($dom->createTextNode($siteURL));
     $remoteNode->appendChild($siteUrlNode);
     $urlNode = $dom->createElement('url');
     $urlNode->appendChild($dom->createTextNode($classURL));
     $remoteNode->appendChild($urlNode);
     $classGroupsNode = $dom->createElement('groups');
     $classGroupList = eZContentClassClassGroup::fetchGroupList($class->attribute('id'), $class->attribute('version'));
     foreach ($classGroupList as $classGroupLink) {
         $classGroup = eZContentClassGroup::fetch($classGroupLink->attribute('group_id'));
         if ($classGroup) {
             unset($groupNode);
             $groupNode = $dom->createElement('group');
             $groupNode->setAttribute('id', $classGroup->attribute('id'));
             $groupNode->setAttribute('name', $classGroup->attribute('name'));
             $classGroupsNode->appendChild($groupNode);
         }
     }
     $remoteNode->appendChild($classGroupsNode);
     $idNode = $dom->createElement('id');
     $idNode->appendChild($dom->createTextNode($class->attribute('id')));
     $remoteNode->appendChild($idNode);
     $createdNode = $dom->createElement('created');
     $createdNode->appendChild($dom->createTextNode($class->attribute('created')));
     $remoteNode->appendChild($createdNode);
     $modifiedNode = $dom->createElement('modified');
     $modifiedNode->appendChild($dom->createTextNode($class->attribute('modified')));
     $remoteNode->appendChild($modifiedNode);
     $creatorNode = $dom->createElement('creator');
     $remoteNode->appendChild($creatorNode);
     $creatorIDNode = $dom->createElement('user-id');
     $creatorIDNode->appendChild($dom->createTextNode($class->attribute('creator_id')));
     $creatorNode->appendChild($creatorIDNode);
     $creator = $class->attribute('creator');
     if ($creator) {
         $creatorLoginNode = $dom->createElement('user-login');
         $creatorLoginNode->appendChild($dom->createTextNode($creator->attribute('login')));
         $creatorNode->appendChild($creatorLoginNode);
     }
     $modifierNode = $dom->createElement('modifier');
     $remoteNode->appendChild($modifierNode);
     $modifierIDNode = $dom->createElement('user-id');
     $modifierIDNode->appendChild($dom->createTextNode($class->attribute('modifier_id')));
     $modifierNode->appendChild($modifierIDNode);
     $modifier = $class->attribute('modifier');
     if ($modifier) {
         $modifierLoginNode = $dom->createElement('user-login');
         $modifierLoginNode->appendChild($dom->createTextNode($modifier->attribute('login')));
         $modifierNode->appendChild($modifierLoginNode);
     }
     // Remote data end
     $attributesNode = $dom->createElementNS('http://ezpublish/contentclassattribute', 'ezcontentclass-attribute:attributes');
     $classNode->appendChild($attributesNode);
     $attributes = $class->fetchAttributes();
     foreach ($attributes as $attribute) {
         $attributeNode = $dom->createElement('attribute');
         $attributeNode->setAttribute('datatype', $attribute->attribute('data_type_string'));
         $required = $attribute->attribute('is_required') ? 'true' : 'false';
         $attributeNode->setAttribute('required', $required);
         $searchable = $attribute->attribute('is_searchable') ? 'true' : 'false';
         $attributeNode->setAttribute('searchable', $searchable);
         $informationCollector = $attribute->attribute('is_information_collector') ? 'true' : 'false';
         $attributeNode->setAttribute('information-collector', $informationCollector);
         $translatable = $attribute->attribute('can_translate') ? 'true' : 'false';
         $attributeNode->setAttribute('translatable', $translatable);
         $attributeRemoteNode = $dom->createElement('remote');
         $attributeNode->appendChild($attributeRemoteNode);
         $attributeIDNode = $dom->createElement('id');
         $attributeIDNode->appendChild($dom->createTextNode($attribute->attribute('id')));
         $attributeRemoteNode->appendChild($attributeIDNode);
         $attributeSerializedNameListNode = $dom->createElement('serialized-name-list');
         $attributeSerializedNameListNode->appendChild($dom->createTextNode($attribute->attribute('serialized_name_list')));
         $attributeNode->appendChild($attributeSerializedNameListNode);
         $attributeIdentifierNode = $dom->createElement('identifier');
         $attributeIdentifierNode->appendChild($dom->createTextNode($attribute->attribute('identifier')));
         $attributeNode->appendChild($attributeIdentifierNode);
         $attributeSerializedDescriptionListNode = $dom->createElement('serialized-description-list');
         $attributeSerializedDescriptionListNode->appendChild($dom->createTextNode($attribute->attribute('serialized_description_list')));
         $attributeNode->appendChild($attributeSerializedDescriptionListNode);
         $attributeCategoryNode = $dom->createElement('category');
         $attributeCategoryNode->appendChild($dom->createTextNode($attribute->attribute('category')));
         $attributeNode->appendChild($attributeCategoryNode);
         $attributeSerializedDataTextNode = $dom->createElement('serialized-data-text');
         $attributeSerializedDataTextNode->appendChild($dom->createTextNode($attribute->attribute('serialized_data_text')));
         $attributeNode->appendChild($attributeSerializedDataTextNode);
         $attributePlacementNode = $dom->createElement('placement');
         $attributePlacementNode->appendChild($dom->createTextNode($attribute->attribute('placement')));
         $attributeNode->appendChild($attributePlacementNode);
         $attributeParametersNode = $dom->createElement('datatype-parameters');
         $attributeNode->appendChild($attributeParametersNode);
         $dataType = $attribute->dataType();
         if (is_object($dataType)) {
             $dataType->serializeContentClassAttribute($attribute, $attributeNode, $attributeParametersNode);
         }
         $attributesNode->appendChild($attributeNode);
     }
     eZDebug::writeDebug($dom->saveXML(), 'content class package XML');
     return $classNode;
 }
Esempio n. 4
0
 function fetchAllGroups()
 {
     $this->AllGroups = eZContentClassGroup::fetchList();
     return $this->AllGroups;
 }
Esempio n. 5
0
                $className = $classObject->attribute("name");
                $deletedClassName .= " '" . $className . "'";
                $deleteClassIDList[] = $classID;
                $groupClassesInfo[] = array('class_name' => $className, 'object_count' => $classObject->objectCount());
            }
        }
        if ($deletedClassName == '') {
            $deletedClassName = ezpI18n::tr('kernel/class', '(no classes)');
        }
        $deleteResult[] = array('groupName' => $GroupName, 'deletedClassName' => $deletedClassName);
        $groupsInfo[] = array('group_name' => $GroupName, 'class_list' => $groupClassesInfo);
    }
}
if ($http->hasPostVariable("ConfirmButton")) {
    foreach ($deleteIDArray as $deleteID) {
        eZContentClassGroup::removeSelected($deleteID);
        eZContentClassClassGroup::removeGroupMembers($deleteID);
        foreach ($deleteClassIDList as $deleteClassID) {
            $deleteClass = eZContentClass::fetch($deleteClassID);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
            $deleteClass = eZContentClass::fetch($deleteClassID, true, eZContentClass::VERSION_STATUS_TEMPORARY);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
        }
    }
    $Module->redirectTo('/class/grouplist/');
}
if ($http->hasPostVariable("CancelButton")) {
Esempio n. 6
0
    $groupInfo =  eZContentClassGroup::fetch( $GroupID );

    if( !$groupInfo )
    {
       return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' );
    }

    $list = eZContentClassClassGroup::fetchClassList( 0, $GroupID, $asObject = true );
    $groupModifier = eZContentObject::fetch( $groupInfo->attribute( 'modifier_id') );
    $tpl->setVariable( $tplname, $list );
    $tpl->setVariable( "class_count", count( $list ) );
    $tpl->setVariable( "GroupID", $GroupID );
    $tpl->setVariable( "group", $groupInfo );
    $tpl->setVariable( "group_modifier", $groupModifier );
}

$group = eZContentClassGroup::fetch( $GroupID );
$groupName = $group->attribute( 'name' );


$tpl->setVariable( "module", $Module );

$Result = array();
$Result['content'] = $tpl->fetch( "design:class/classlist.tpl" );
$Result['path'] = array( array( 'url' => '/class/grouplist/',
                                'text' => ezpI18n::tr( 'kernel/class', 'Class groups' ) ),
                         array( 'url' => false,
                                'text' => $groupName ) );
?>
Esempio n. 7
0
    $Module->run("groupedit", $params);
    return;
}
if ($http->hasPostVariable("NewClassButton")) {
    if ($http->hasPostVariable("SelectedGroupID")) {
        $groupID = $http->postVariable("SelectedGroupID");
        $group = eZContentClassGroup::fetch($groupID);
        $groupName = $group->attribute('name');
        $params = array(null, $groupID, $groupName);
        return $Module->run("edit", $params);
    }
}
if (!isset($TemplateData) or !is_array($TemplateData)) {
    $TemplateData = array(array("name" => "groups", "http_base" => "ContentClass", "data" => array("command" => "group_list", "type" => "class")));
}
$Module->setTitle(ezpI18n::tr('kernel/class', 'Class group list'));
$tpl = eZTemplate::factory();
$user = eZUser::currentUser();
foreach ($TemplateData as $tpldata) {
    $tplname = $tpldata["name"];
    $data = $tpldata["data"];
    $asObject = isset($data["as_object"]) ? $data["as_object"] : true;
    $base = $tpldata["http_base"];
    unset($list);
    $list = eZContentClassGroup::fetchList(false, $asObject);
    $tpl->setVariable($tplname, $list);
}
$tpl->setVariable("module", $Module);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/grouplist.tpl");
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('kernel/class', 'Class groups')));
Esempio n. 8
0
File: index.php Progetto: truffo/eep
 private function fetchall()
 {
     $limit = false;
     $results = array();
     $results[] = array("ID", "Name");
     if (isset($additional["limit"])) {
         $limit = $additional["limit"];
     }
     $offset = false;
     if (isset($additional["offset"])) {
         $offset = $additional["offset"];
     }
     $allInstances = eZContentClassGroup::fetchList(false, false);
     $title = "Viewing all groups";
     foreach ($allInstances as $group) {
         $results[] = array($group["id"], $group["name"]);
     }
     eep::printTable($results, $title);
 }
Esempio n. 9
0
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.6
 * @package kernel
 */
$Module = $Params['Module'];
$GroupID = null;
if (isset($Params["GroupID"])) {
    $GroupID = $Params["GroupID"];
}
if (is_numeric($GroupID)) {
    $classgroup = eZContentClassGroup::fetch($GroupID);
} else {
    $user = eZUser::currentUser();
    $user_id = $user->attribute("contentobject_id");
    $classgroup = eZContentClassGroup::create($user_id);
    $classgroup->setAttribute("name", ezpI18n::tr('kernel/class/groupedit', "New Group"));
    $classgroup->store();
    $GroupID = $classgroup->attribute("id");
    $Module->redirectTo($Module->functionURI("groupedit") . "/" . $GroupID);
    return;
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable("DiscardButton")) {
    $Module->redirectTo($Module->functionURI("grouplist"));
    return;
}
if ($http->hasPostVariable("StoreButton")) {
    if ($http->hasPostVariable("Group_name")) {
        $name = $http->postVariable("Group_name");
    }
Esempio n. 10
0
 function execute($xml)
 {
     $classList = $xml->getElementsByTagName('ContentClass');
     $refArray = array();
     $availableLanguageList = eZContentLanguage::fetchLocaleList();
     foreach ($classList as $class) {
         $this->adjustAttributesPlacement = false;
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
         $classIdentifier = $class->getAttribute('identifier');
         $classRemoteID = $class->getAttribute('remoteID');
         $classObjectNamePattern = $class->getAttribute('objectNamePattern');
         $classExistAction = $class->getAttribute('classExistAction');
         $referenceID = $class->getAttribute('referenceID');
         $this->writeMessage("\tClass '{$classIdentifier}' will be updated.", 'notice');
         $classURLAliasPattern = $class->getAttribute('urlAliasPattern') ? $class->getAttribute('urlAliasPattern') : null;
         $classIsContainer = $class->getAttribute('isContainer');
         if ($classIsContainer !== false) {
             $classIsContainer = $classIsContainer == 'true' ? 1 : 0;
         }
         $classGroupsNode = $class->getElementsByTagName('Groups')->item(0);
         $classAttributesNode = $class->getElementsByTagName('Attributes')->item(0);
         $nameList = array();
         $nameListObject = $class->getElementsByTagName('Names')->item(0);
         if ($nameListObject && $nameListObject->parentNode === $class && $nameListObject->hasAttributes()) {
             $attributes = $nameListObject->attributes;
             if (!is_null($attributes)) {
                 foreach ($attributes as $index => $attr) {
                     if (in_array($attr->name, $availableLanguageList)) {
                         $nameList[$attr->name] = $attr->value;
                     }
                 }
             }
         }
         if (!empty($nameList)) {
             $classNameList = new eZContentClassNameList(serialize($nameList));
             $classNameList->validate();
         } else {
             $classNameList = null;
         }
         $dateTime = time();
         $classCreated = $dateTime;
         $classModified = $dateTime;
         $class = eZContentClass::fetchByRemoteID($classRemoteID);
         if (!$class) {
             $class = eZContentClass::fetchByIdentifier($classIdentifier);
         }
         if ($class) {
             $className = $class->name();
             switch ($classExistAction) {
                 case 'replace':
                     $this->writeMessage("\t\tClass '{$classIdentifier}' will be replaced.", 'notice');
                     foreach ($nameList as $lang => $name) {
                         if (in_array($lang, $availableLanguageList)) {
                             $class->setName($name, $lang);
                         }
                     }
                     $class->setAttribute('contentobject_name', $classObjectNamePattern);
                     $class->setAttribute('identifier', $classIdentifier);
                     $class->setAttribute('is_container', $classIsContainer);
                     $class->setAttribute('url_alias_name', $classURLAliasPattern);
                     $class->store();
                     $class->removeAttributes();
                     break;
                 case 'new':
                     unset($class);
                     $class = false;
                     break;
                     break;
                 case 'extend':
                     $this->writeMessage("\t\tClass '{$classIdentifier}' will be extended.", 'notice');
                     foreach ($nameList as $lang => $name) {
                         if (in_array($lang, $availableLanguageList)) {
                             $class->setName($name, $lang);
                         }
                     }
                     $class->setAttribute('contentobject_name', $classObjectNamePattern);
                     $class->setAttribute('identifier', $classIdentifier);
                     $class->setAttribute('is_container', $classIsContainer);
                     $class->setAttribute('url_alias_name', $classURLAliasPattern);
                     $class->store();
                     break;
                 case 'skip':
                 default:
                     continue;
                     break;
             }
         }
         if (!$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;
             // create class
             $class = eZContentClass::create($userID, array('version' => 1, 'serialized_name_list' => $classNameList->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));
             $class->store();
             $attributes = $class->fetchAttributes();
             $class->storeDefined($attributes);
             $classID = $class->attribute('id');
             $this->writeMessage("\t\tClass '{$classIdentifier}' will be newly created.", 'notice');
         }
         // create class attributes
         $classAttributeList = $classAttributesNode->getElementsByTagName('Attribute');
         $classDataMap = $class->attribute('data_map');
         $updateAttributeList = array();
         if ($classDataMap == NULL) {
             $classDataMap = array();
         }
         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();
 }
Esempio n. 11
0
File: index.php Progetto: truffo/eep
 public function run($argv, $additional)
 {
     $command = @$argv[2];
     $param1 = @$argv[3];
     $param2 = @$argv[4];
     if (!in_array($command, $this->availableCommands)) {
         throw new Exception("Command '" . $command . "' not recognized.");
     }
     $eepCache = eepCache::getInstance();
     switch ($command) {
         case "help":
             echo "\nAvailable commands:: " . implode(", ", $this->availableCommands) . "\n";
             echo "\n" . $this->help . "\n";
             break;
         case self::contentclass_listattributes:
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             if ($param1) {
                 $classIdentifier = $param1;
             }
             AttributeFunctions::listAttributes($classIdentifier);
             break;
         case self::contentclass_deleteclass:
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             if ($param1) {
                 $classIdentifier = $param1;
             }
             $this->deleteClass($classIdentifier);
             break;
         case self::contentclass_fetchallinstances:
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             if ($param1) {
                 $classIdentifier = $param1;
             }
             $this->fetchallinstances($classIdentifier, $additional);
             break;
         case self::contentclass_appendtogroup:
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             if ($param1) {
                 $classIdentifier = $param1;
             }
             if ($param2) {
                 $groupIdentifier = $param2;
             } else {
                 $groupIdentifier = null;
             }
             $this->appendToGroup($classIdentifier, $groupIdentifier);
             break;
         case self::contentclass_removefromgroup:
             $classIdentifier = $eepCache->readFromCache(eepCache::use_key_contentclass);
             if ($param1) {
                 $classIdentifier = $param1;
             }
             if ($param2) {
                 $groupIdentifier = $param2;
             } else {
                 $groupIdentifier = null;
             }
             $this->removeFromGroup($classIdentifier, $groupIdentifier);
             break;
             // eep createclass <Display name> <Content class group identifier>
         // eep createclass <Display name> <Content class group identifier>
         case self::contentclass_createclass:
             $displayName = $param1;
             // convert the display name to lowercase and solo underscores
             $classIdentifier = strtolower(trim($displayName));
             $classIdentifier = preg_replace("/[^a-z0-9]/", "_", $classIdentifier);
             $classIdentifier = preg_replace("/_[_]+/", "_", $classIdentifier);
             if (0 == strlen($classIdentifier)) {
                 throw new Exception("Empty content class identifier");
             }
             $classId = eZContentClass::classIDByIdentifier($classIdentifier);
             if ($classId) {
                 throw new Exception("This content class identifier is already used: '" . $classIdentifier . "'");
             }
             $groupIdentifier = $param2;
             $groupObject = eZContentClassGroup::fetchByName($groupIdentifier);
             if (!is_object($groupObject)) {
                 throw new Exception("Failed to locate the content class group '" . $groupIdentifier . "'");
             }
             $groupId = $groupObject->ID;
             $this->createClass($displayName, $classIdentifier, $groupIdentifier, $groupId);
             echo "created " . $classIdentifier . " ok\n";
             break;
             // eep contentclass setclassobjectidentifier <class identifier> <object naming string or pattern>
         // eep contentclass setclassobjectidentifier <class identifier> <object naming string or pattern>
         case self::contentclass_setclassobjectidentifier:
             $classIdentifier = $param1;
             $classId = eZContentClass::classIDByIdentifier($classIdentifier);
             $contentClass = eZContentClass::fetch($classId);
             if (!is_object($contentClass)) {
                 throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]");
             }
             $contentClass->setAttribute('contentobject_name', $param2);
             $contentClass->store();
             break;
         case self::contentclass_setiscontainer:
             $classIdentifier = $param1;
             $classId = eZContentClass::classIDByIdentifier($classIdentifier);
             $contentClass = eZContentClass::fetch($classId);
             if (!is_object($contentClass)) {
                 throw new Exception("Failed to instantiate content class. [" . $classIdentifier . "]");
             }
             $newSetting = 0;
             if (0 != $param2) {
                 $newSetting = 1;
             }
             $contentClass->setAttribute('is_container', $newSetting);
             $contentClass->store();
             break;
     }
 }
 protected function syncGroups()
 {
     $remote = $this->getRemote();
     if ($remote === null) {
         throw new Exception("Classe remota non trovata");
     }
     $this->syncAllGroups($remote);
     $locale = $this->currentClass;
     /** @var eZContentClassClassGroup[] $localGroups */
     $localGroups = $locale->fetchGroupList();
     //$localGroupsNames = array();
     //$remoteGroupsNames = array();
     foreach ($localGroups as $group) {
         /** @var eZContentClassGroup $classGroup */
         $classGroup = eZContentClassGroup::fetchByName($group->attribute('group_name'));
         if ($classGroup) {
             eZContentClassClassGroup::removeGroup($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id'));
         }
     }
     foreach ($remote->InGroups as $group) {
         /** @var eZContentClassGroup $classGroup */
         $classGroup = eZContentClassGroup::fetchByName($group->GroupName);
         if ($classGroup) {
             $ingroup = eZContentClassClassGroup::create($this->currentClass->attribute('id'), $this->currentClass->attribute('version'), $classGroup->attribute('id'), $classGroup->attribute('name'));
             $ingroup->store();
         }
     }
     //$groups = $this->currentClass->attribute( 'ingroup_list' );
     //if ( count( $groups ) == 0 )
     //{
     //    //@todo
     //}
 }