本文整理汇总了PHP中eZContentClassClassGroup类的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClassClassGroup类的具体用法?PHP eZContentClassClassGroup怎么用?PHP eZContentClassClassGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZContentClassClassGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testContentClassStillInGroupAfterEdition
/**
* Test that saving a content class in DEFINED version status
* correctly manipulate associated class groups
*
* @link http://issues.ez.no/16197
*/
public function testContentClassStillInGroupAfterEdition()
{
$class = eZContentClass::fetch( $this->class->id );
// This is logic contained in kernel/class/edit.php
foreach ( eZContentClassClassGroup::fetchGroupList( $class->attribute( 'id' ),
eZContentClass::VERSION_STATUS_DEFINED ) as $classGroup )
{
eZContentClassClassGroup::create( $class->attribute( 'id' ),
eZContentClass::VERSION_STATUS_TEMPORARY,
$classGroup->attribute( 'group_id' ),
$classGroup->attribute( 'group_name' ) )
->store();
}
$attributes = $class->fetchAttributes();
$class->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
$class->NameList->setHasDirtyData();
foreach ( $attributes as $attribute )
{
$attribute->setAttribute( 'version', eZContentClass::VERSION_STATUS_TEMPORARY );
if ( $dataType = $attribute->dataType() )
$dataType->initializeClassAttribute( $attribute );
}
$class->store( $attributes );
$db = eZDB::instance();
$db->begin();
$class->storeVersioned( $attributes, eZContentClass::VERSION_STATUS_DEFINED );
$db->commit();
$this->assertTrue( eZContentClassClassGroup::classInGroup( $class->attribute( 'id' ),
eZContentClass::VERSION_STATUS_DEFINED,
1 ) );
}
示例2: 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;
}
示例3: removeGroup
static function removeGroup( $classID, $classVersion, $selectedGroup )
{
$class = eZContentClass::fetch( $classID, true, eZContentClass::VERSION_STATUS_DEFINED );
if ( !$class )
return false;
$groups = $class->attribute( 'ingroup_list' );
foreach ( array_keys( $groups ) as $key )
{
if ( in_array( $groups[$key]->attribute( 'group_id' ), $selectedGroup ) )
{
unset( $groups[$key] );
}
}
if ( count( $groups ) == 0 )
{
return false;
}
else
{
foreach( $selectedGroup as $group_id )
{
eZContentClassClassGroup::removeGroup( $classID, $classVersion, $group_id );
}
}
return true;
}
示例4: __construct
/**
* Initialize ezpClass object
*
* @param string $name
* @param string $identifier
* @param string $contentObjectName
* @param int $creatorID
* @param string $language
* @param int $groupID
* @param string $groupName
*/
public function __construct($name = 'Test class', $identifier = 'test_class', $contentObjectName = '<test_attribute>', $creatorID = 14, $language = 'eng-GB', $groupID = 1, $groupName = 'Content')
{
if (eZContentLanguage::fetchByLocale($language) === false) {
$topPriorityLanguage = eZContentLanguage::topPriorityLanguage();
if ($topPriorityLanguage) {
$language = $topPriorityLanguage->attribute('locale');
}
}
$this->language = $language;
$this->class = eZContentClass::create($creatorID, array(), $this->language);
$this->class->setName($name, $this->language);
$this->class->setAttribute('contentobject_name', $contentObjectName);
$this->class->setAttribute('identifier', $identifier);
$this->class->store();
$languageID = eZContentLanguage::idByLocale($this->language);
$this->class->setAlwaysAvailableLanguageID($languageID);
$this->classGroup = eZContentClassClassGroup::create($this->id, $this->version, $groupID, $groupName);
$this->classGroup->store();
}
示例5: getGroupedClasses
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));
}
示例6: storeVersioned
/**
* Stores the current class as a modified version, updates the contentobject_name
* attribute and recreates the class group entries.
*
* @note It will remove classes in the previous and specified version before storing.
*
* @param array $attributes array of attributes
* @param int $version version status
* @since Version 4.3
*/
public function storeVersioned($attributes, $version)
{
$previousVersion = $this->attribute('version');
$db = eZDB::instance();
$db->begin();
// Before removing anything from the attributes, load attribute information
// which might otherwise not accessible when recreating them below.
// See issue #18164
foreach ($attributes as $attribute) {
$attribute->content();
}
$this->removeAttributes(false, $version);
$this->removeAttributes(false, $previousVersion);
$this->remove(false);
$this->setVersion($version, $attributes);
$this->setAttribute("modifier_id", eZUser::currentUser()->attribute("contentobject_id"));
$this->setAttribute("modified", time());
$this->adjustAttributePlacements($attributes);
foreach ($attributes as $attribute) {
$attribute->storeVersioned($version);
}
// Set contentobject_name to something sensible if it is missing
if (count($attributes) > 0 && trim($this->attribute('contentobject_name')) == '') {
$this->setAttribute('contentobject_name', '<' . $attributes[0]->attribute('identifier') . '>');
}
// Recreate class member entries
eZContentClassClassGroup::removeClassMembers($this->ID, $version);
foreach (eZContentClassClassGroup::fetchGroupList($this->ID, $previousVersion) as $classgroup) {
$classgroup->setAttribute('contentclass_version', $version);
$classgroup->store();
}
eZContentClassClassGroup::removeClassMembers($this->ID, $previousVersion);
eZExpiryHandler::registerShutdownFunction();
$handler = eZExpiryHandler::instance();
$time = time();
$handler->setTimestamp('user-class-cache', $time);
$handler->setTimestamp('class-identifier-cache', $time);
$handler->setTimestamp('sort-key-cache', $time);
$handler->store();
eZContentCacheManager::clearAllContentCache();
$this->setAttribute('serialized_name_list', $this->NameList->serializeNames());
$this->setAttribute('serialized_description_list', $this->DescriptionList->serializeNames());
eZPersistentObject::store();
$this->NameList->store($this);
$db->commit();
}
示例7: appendClass
function appendClass($class, $version = false)
{
if ($class instanceof eZContentClass) {
$classID = $class->attribute('id');
$version = $class->attribute('version');
} else {
$classID = $class;
}
$classGroupLink = eZContentClassClassGroup::create($classID, $version, $this->attribute('id'), $this->attribute('name'));
$classGroupLink->store();
return $classGroupLink;
}
示例8: array
$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")) {
$Module->redirectTo('/class/grouplist/');
示例9: count
if (isset($Params["GroupID"])) {
$GroupID = $Params["GroupID"];
}
$class = eZContentClass::fetch($ClassID);
$ClassName = $class->attribute('name');
$classObjects = eZContentObject::fetchSameClassList($ClassID);
$ClassObjectsCount = count($classObjects);
if ($ClassObjectsCount == 0) {
$ClassObjectsCount .= " object";
} else {
$ClassObjectsCount .= " objects";
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable("ConfirmButton")) {
$class->remove(true);
eZContentClassClassGroup::removeClassMembers($ClassID, 0);
ezpEvent::getInstance()->notify('content/class/cache', array($ClassID));
$Module->redirectTo('/class/classlist/' . $GroupID);
}
if ($http->hasPostVariable("CancelButton")) {
$Module->redirectTo('/class/classlist/' . $GroupID);
}
$Module->setTitle("Deletion of class " . $ClassID);
$tpl = eZTemplate::factory();
$tpl->setVariable("module", $Module);
$tpl->setVariable("GroupID", $GroupID);
$tpl->setVariable("ClassID", $ClassID);
$tpl->setVariable("ClassName", $ClassName);
$tpl->setVariable("ClassObjectsCount", $ClassObjectsCount);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/delete.tpl");
示例10: foreach
$Module->setTitle( ezpI18n::tr( 'kernel/class', 'Class list of group' ) . ' ' . $GroupID );
$tpl = eZTemplate::factory();
$user = eZUser::currentUser();
foreach( $TemplateData as $tpldata )
{
$tplname = $tpldata["name"];
$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();
示例11: classInGroup
static function classInGroup($contentclassID, $contentclassVersion, $groupID)
{
$rows = eZPersistentObject::fetchObjectList(eZContentClassClassGroup::definition(), null, array('group_id' => $groupID, "contentclass_id" => $contentclassID, "contentclass_version" => $contentclassVersion), null, null, false);
return count($rows) > 0;
}
示例12: syncGroups
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
//}
}
示例13: createClass
private function createClass($displayName, $classIdentifier, $groupIdentifier, $groupId)
{
$adminUserObject = eZUser::fetchByName("admin");
$adminUserObject->loginCurrent();
$adminUserId = $adminUserObject->attribute('contentobject_id');
$language = eZContentLanguage::topPriorityLanguage();
$editLanguage = $language->attribute('locale');
$class = eZContentClass::create($adminUserId, array(), $editLanguage);
// this is the display name, ez automatically creates the content-class-identifier from it
$class->setName($displayName, $editLanguage);
$class->setAttribute("identifier", $classIdentifier);
// default naming for objects - content classes should update this value once they have attributes added
$class->setAttribute('contentobject_name', 'eep-created-content-class');
$class->store();
$editLanguageID = eZContentLanguage::idByLocale($editLanguage);
$class->setAlwaysAvailableLanguageID($editLanguageID);
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$ingroup = eZContentClassClassGroup::create($ClassID, $ClassVersion, $groupId, $groupIdentifier);
$ingroup->store();
// clean up the content class status
$class->storeDefined(array());
$adminUserObject->logoutCurrent();
}
示例14: fetchUserGroupClassNames
static function fetchUserGroupClassNames()
{
// Get names of user classes
$userClassNames = array();
$userClasses = eZUser::fetchUserClassList(false, array('identifier'));
foreach ($userClasses as $class) {
$userClassNames[] = $class['identifier'];
}
// Get names of all allowed content-classes for the Users subtree
$contentIni = eZINI::instance("content.ini");
$userGroupClassNames = array();
if ($contentIni->hasVariable('ClassGroupIDs', 'Users') and is_numeric($usersClassGroupID = $contentIni->variable('ClassGroupIDs', 'Users')) and count($usersClassList = eZContentClassClassGroup::fetchClassList(eZContentClass::VERSION_STATUS_DEFINED, $usersClassGroupID)) > 0) {
foreach ($usersClassList as $userClass) {
$userGroupClassNames[] = $userClass->attribute('identifier');
}
}
// Get names of user-group classes
$groupClassNames = array_diff($userGroupClassNames, $userClassNames);
return $groupClassNames;
}
示例15: array
}
// Find out the group where class is created or edited from.
if ($http->hasSessionVariable('FromGroupID')) {
$fromGroupID = $http->sessionVariable('FromGroupID');
} else {
$fromGroupID = false;
}
$ClassID = $class->attribute('id');
$ClassVersion = $class->attribute('version');
$validation = array('processed' => false, 'groups' => array(), 'attributes' => array(), 'class_errors' => array());
$unvalidatedAttributes = array();
if ($http->hasPostVariable('DiscardButton')) {
$http->removeSessionVariable('ClassCanStoreTicket');
$class->setVersion(eZContentClass::VERSION_STATUS_TEMPORARY);
$class->remove(true, eZContentClass::VERSION_STATUS_TEMPORARY);
eZContentClassClassGroup::removeClassMembers($ClassID, eZContentClass::VERSION_STATUS_TEMPORARY);
if ($fromGroupID === false) {
$Module->redirectToView('grouplist');
} else {
$Module->redirectTo($Module->functionURI('classlist') . '/' . $fromGroupID . '/');
}
return;
}
if ($http->hasPostVariable('AddGroupButton') && $http->hasPostVariable('ContentClass_group')) {
eZClassFunctions::addGroup($ClassID, $ClassVersion, $http->postVariable('ContentClass_group'));
$lastChangedID = 'group';
}
if ($http->hasPostVariable('RemoveGroupButton') && $http->hasPostVariable('group_id_checked')) {
if (!eZClassFunctions::removeGroup($ClassID, $ClassVersion, $http->postVariable('group_id_checked'))) {
$validation['groups'][] = array('text' => ezpI18n::tr('kernel/class', 'You have to have at least one group that the class belongs to!'));
$validation['processed'] = true;