本文整理汇总了PHP中eZContentClass类的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClass类的具体用法?PHP eZContentClass怎么用?PHP eZContentClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZContentClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Create a scheduled script that will store the modification made to an eZContentClass.
*
* @param eZContentClass Content class to be stored.
* @param array[eZContentClassAttribute] Attributes of the new content class.
* @param array Unordered view parameters
*/
public function store(eZContentClass $class, array $attributes, array &$unorderedParameters)
{
$script = eZScheduledScript::create('syncobjectattributes.php', eZINI::instance('ezscriptmonitor.ini')->variable('GeneralSettings', 'PhpCliCommand') . ' extension/ezscriptmonitor/bin/' . eZScheduledScript::SCRIPT_NAME_STRING . ' -s ' . eZScheduledScript::SITE_ACCESS_STRING . ' --classid=' . $class->attribute('id'));
$script->store();
$unorderedParameters['ScheduledScriptID'] = $script->attribute('id');
$class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_MODIFIED);
}
示例2: store
/**
* Store the modification made to an eZContentClass.
*
* @param eZContentClass Content class to be stored.
* @param array[eZContentClassAttribute] Attributes of the new content class.
* @param array Unordered view parameters
*/
public function store(eZContentClass $class, array $attributes, array &$unorderedParameters)
{
$oldClassAttributes = $class->fetchAttributes($class->attribute('id'), true, eZContentClass::VERSION_STATUS_DEFINED);
// Delete object attributes which have been removed.
foreach ($oldClassAttributes as $oldClassAttribute) {
$attributeExists = false;
$oldClassAttributeID = $oldClassAttribute->attribute('id');
foreach ($class->fetchAttributes() as $newClassAttribute) {
if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
$attributeExists = true;
break;
}
}
if (!$attributeExists) {
foreach (eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID) as $objectAttribute) {
$objectAttribute->removeThis($objectAttribute->attribute('id'));
}
}
}
$class->storeDefined($attributes);
// Add object attributes which have been added.
foreach ($attributes as $newClassAttribute) {
$attributeExists = false;
$newClassAttributeID = $newClassAttribute->attribute('id');
foreach ($oldClassAttributes as $oldClassAttribute) {
if ($newClassAttributeID == $oldClassAttribute->attribute('id')) {
$attributeExists = true;
break;
}
}
if (!$attributeExists) {
$newClassAttribute->initializeObjectAttributes($objects);
}
}
}
示例3: instance
public static function instance(eZContentClass $class)
{
if (!$class instanceof eZContentClass) {
throw new Exception("Class not found (" . __METHOD__ . ")");
}
if (!isset(self::$instances[$class->attribute('identifier')])) {
self::$instances[$class->attribute('identifier')] = new OCClassExtraParametersManager($class);
}
return self::$instances[$class->attribute('identifier')];
}
示例4: 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
//}
}
示例5: 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 ) );
}
示例6: 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;
}
示例7: 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;
}
示例8: modify
function modify($tpl, $operatorName, $operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
$canCreateClassList = $namedParameters['can_create_class_list'];
switch ($operatorName) {
case 'ezcreateclasslistgroups':
$groupArray = array();
$ini = eZINI::instance('websitetoolbar.ini');
foreach ($canCreateClassList as $class) {
$contentClass = eZContentClass::fetch($class['id']);
if (!$contentClass) {
return false;
}
foreach ($contentClass->fetchGroupList() as $group) {
$isHidden = false;
if (in_array($contentClass->attribute('identifier'), $ini->variable('WebsiteToolbarSettings', 'HiddenContentClasses'))) {
$isHidden = true;
}
if (array_key_exists($group->attribute('group_id'), $groupArray)) {
if (!$isHidden) {
$groupArray[$group->attribute('group_id')]['items'][] = $contentClass;
}
} else {
if (!$isHidden) {
$groupArray[$group->attribute('group_id')]['items'] = array($contentClass);
$groupArray[$group->attribute('group_id')]['group_name'] = $group->attribute('group_name');
}
}
}
}
$operatorValue = $groupArray;
break;
}
}
示例9: attribute
function attribute($attr)
{
switch ($attr) {
case 'contentclass_list':
return eZContentClass::fetchList(eZContentClass::VERSION_STATUS_DEFINED, true);
break;
case 'contentclassattribute_list':
// $postvarname = 'WorkflowEvent' . '_event_ezwaituntildate_' .'class_' . $workflowEvent->attribute( 'id' ); and $http->hasPostVariable( $postvarname )
if (isset($GLOBALS['eZWaitUntilDateSelectedClass'])) {
$classID = $GLOBALS['eZWaitUntilDateSelectedClass'];
} else {
// if nothing was preselected, we will use the first one:
// POSSIBLE ENHANCEMENT: in the common case, the contentclass_list fetch will be called twice
$classList = eZWaitUntilDateType::attribute('contentclass_list');
if (isset($classList[0])) {
$classID = $classList[0]->attribute('id');
} else {
$classID = false;
}
}
if ($classID) {
return eZContentClassAttribute::fetchListByClassID($classID);
}
return array();
break;
case 'has_class_attributes':
// for the backward compatibility:
return 1;
break;
default:
return eZWorkflowEventType::attribute($attr);
}
}
示例10: createUser
/**
* Creates a user with provided auth data
*
* @param array $authResult
*
* @return bool|eZUser
*/
public static function createUser($authResult)
{
$ngConnectINI = eZINI::instance('ngconnect.ini');
$siteINI = eZINI::instance('site.ini');
$defaultUserPlacement = $ngConnectINI->variable('LoginMethod_' . $authResult['login_method'], 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
$defaultUserPlacement = $siteINI->variable('UserSettings', 'DefaultUserPlacement');
$placementNode = eZContentObjectTreeNode::fetch($defaultUserPlacement);
if (!$placementNode instanceof eZContentObjectTreeNode) {
return false;
}
}
$contentClass = eZContentClass::fetch($siteINI->variable('UserSettings', 'UserClassID'));
$userCreatorID = $siteINI->variable('UserSettings', 'UserCreatorID');
$defaultSectionID = $siteINI->variable('UserSettings', 'DefaultSectionID');
$db = eZDB::instance();
$db->begin();
$contentObject = $contentClass->instantiate($userCreatorID, $defaultSectionID);
$contentObject->store();
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => 1, 'parent_node' => $placementNode->attribute('node_id'), 'is_main' => 1));
$nodeAssignment->store();
$currentTimeStamp = eZDateTime::currentTimeStamp();
/** @var eZContentObjectVersion $version */
$version = $contentObject->currentVersion();
$version->setAttribute('modified', $currentTimeStamp);
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$dataMap = $version->dataMap();
self::fillUserObject($version->dataMap(), $authResult);
if (!isset($dataMap['user_account'])) {
$db->rollback();
return false;
}
$userLogin = 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'];
$userPassword = (string) rand() . 'ngconnect_' . $authResult['login_method'] . '_' . $authResult['id'] . (string) rand();
$userExists = false;
if (eZUser::requireUniqueEmail()) {
$userExists = eZUser::fetchByEmail($authResult['email']) instanceof eZUser;
}
if (empty($authResult['email']) || $userExists) {
$email = md5('ngconnect_' . $authResult['login_method'] . '_' . $authResult['id']) . '@localhost.local';
} else {
$email = $authResult['email'];
}
$user = new eZUser(array('contentobject_id' => $contentObject->attribute('id'), 'email' => $email, 'login' => $userLogin, 'password_hash' => md5("{$userLogin}\n{$userPassword}"), 'password_hash_type' => 1));
$user->store();
$userSetting = new eZUserSetting(array('is_enabled' => true, 'max_login' => 0, 'user_id' => $contentObject->attribute('id')));
$userSetting->store();
$dataMap['user_account']->setContent($user);
$dataMap['user_account']->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObject->attribute('id'), 'version' => $version->attribute('version')));
if (array_key_exists('status', $operationResult) && $operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
$db->commit();
return $user;
}
$db->rollback();
return false;
}
示例11: className
function className()
{
if ($this->ClassName === null) {
$contentClass = eZContentClass::fetch($this->attribute('contentclass_id'));
$this->ClassName = $contentClass->attribute('name');
}
return $this->ClassName;
}
示例12: execute
public function execute($process, $event)
{
$processParameters = $process->attribute('parameter_list');
$object = eZContentObject::fetch($processParameters['object_id']);
$targetClassIdentifier = $object->contentClass()->attribute('identifier');
$iniGroups = eZINI::instance('ngindexer.ini')->groups();
$targets = array();
foreach ($iniGroups as $iniGroupName => $iniGroup) {
$iniGroupNameArray = explode('/', $iniGroupName);
if (is_array($iniGroupNameArray) && count($iniGroupNameArray) == 3) {
$class = eZContentClass::fetchByIdentifier($iniGroupNameArray[0]);
if ($class instanceof eZContentClass) {
$classAttribute = $class->fetchAttributeByIdentifier($iniGroupNameArray[1]);
if ($classAttribute instanceof eZContentClassAttribute) {
$indexTarget = isset($iniGroup['IndexTarget']) ? trim($iniGroup['IndexTarget']) : '';
$referencedClassIdentifiers = isset($iniGroup['ClassIdentifiers']) && is_array($iniGroup['ClassIdentifiers']) ? $iniGroup['ClassIdentifiers'] : null;
if ($referencedClassIdentifiers != null && (empty($referencedClassIdentifiers) || in_array($targetClassIdentifier, $referencedClassIdentifiers))) {
switch ($indexTarget) {
case 'parent':
case 'parent_line':
$children = eZContentObjectTreeNode::subTreeByNodeID(array('ClassFilterType' => 'include', 'ClassFilterArray' => array($iniGroupNameArray[0]), 'Depth' => $indexTarget == 'parent' ? 1 : false), $object->mainNode()->attribute('node_id'));
if (is_array($children)) {
$targets = array_merge($targets, $children);
}
break;
case 'children':
$parentNode = $object->mainNode()->fetchParent();
if ($parentNode->classIdentifier() == $iniGroupNameArray[0]) {
$targets[] = $parentNode;
}
break;
case 'subtree':
$path = $object->mainNode()->fetchPath();
foreach ($path as $pathNode) {
if ($pathNode->classIdentifier() == $iniGroupNameArray[0]) {
$targets[] = $parentNode;
}
}
break;
default:
continue;
}
}
}
}
}
}
$filteredTargets = array();
foreach ($targets as $target) {
$objectID = $target->attribute('contentobject_id');
$version = $target->object()->attribute('current_version');
if (!isset($filteredTargets[$objectID])) {
$filteredTargets[$objectID] = $version;
eZContentOperationCollection::registerSearchObject($objectID, $version);
}
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例13: 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";
}
示例14: updateClass
function updateClass($classId, $scheduledScript)
{
$cli = eZCLI::instance();
/*
// If the class is not stored yet, store it now
$class = eZContentClass::fetch( $classId, true, eZContentClass::VERSION_STATUS_TEMPORARY );
if ( $class )
{
$cli->output( "Storing class" );
$class->storeDefined( $class->fetchAttributes() );
}
*/
// Fetch the stored class
$class = eZContentClass::fetch($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
if (!$class) {
$cli->error('No class in a modified version status with ID: ' . $classId);
return;
}
// Fetch attributes and definitions
$attributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_MODIFIED);
$oldClassAttributes = $class->fetchAttributes($classId, true, eZContentClass::VERSION_STATUS_DEFINED);
// Delete object attributes which have been removed.
foreach ($oldClassAttributes as $oldClassAttribute) {
$attributeExist = false;
$oldClassAttributeID = $oldClassAttribute->attribute('id');
foreach ($attributes as $newClassAttribute) {
if ($oldClassAttributeID == $newClassAttribute->attribute('id')) {
$attributeExist = true;
}
}
if (!$attributeExist) {
foreach (eZContentObjectAttribute::fetchSameClassAttributeIDList($oldClassAttributeID) as $objectAttribute) {
$objectAttribute->removeThis($objectAttribute->attribute('id'));
}
}
}
$class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_DEFINED);
// Add object attributes which have been added.
foreach ($attributes as $newClassAttribute) {
$attributeExist = false;
foreach ($oldClassAttributes as $oldClassAttribute) {
if ($oldClassAttribute->attribute('id') == $newClassAttribute->attribute('id')) {
$attributeExist = true;
break;
}
}
if (!$attributeExist) {
$objects = null;
$newClassAttribute->initializeObjectAttributes($objects);
}
}
if ($scheduledScript !== false) {
$scheduledScript->updateProgress(100);
}
}
示例15: contentClassList
private function contentClassList()
{
$db = eZDB::instance();
$query = "SELECT ezcontentclass.id\n FROM ezcontentclass,\n ezcontentclass_attribute ezcontentclass_attribute1,\n ezcontentclass_attribute ezcontentclass_attribute2\n WHERE ezcontentclass.version='0' AND\n ezcontentclass.id=ezcontentclass_attribute1.contentclass_id AND\n ezcontentclass_attribute1.is_information_collector='0' AND\n ezcontentclass.id=ezcontentclass_attribute2.contentclass_id AND\n ezcontentclass_attribute2.is_information_collector='0' AND\n ezcontentclass_attribute1.contentclass_id=ezcontentclass_attribute2.contentclass_id AND\n ezcontentclass_attribute1.data_type_string='ezxmltext' AND\n ezcontentclass_attribute2.data_type_string='eztext'";
$contentClassArray = $db->arrayQuery($query);
$retArray = array();
foreach ($contentClassArray as $contentClass) {
$retArray[] = eZContentClass::fetch($contentClass['id']);
}
return $retArray;
}