本文整理汇总了PHP中eZContentClass::attribute方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClass::attribute方法的具体用法?PHP eZContentClass::attribute怎么用?PHP eZContentClass::attribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentClass
的用法示例。
在下文中一共展示了eZContentClass::attribute方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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')];
}
示例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: 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);
}
示例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: getForm
/**
* @return string
*/
protected function getForm()
{
$classKeyArray = array(array('class_identifier', $this->contentClass->attribute('identifier')));
$tpl = eZTemplate::factory();
$tpl->setVariable('class', $this->contentClass);
$tpl->setVariable('remote_class_id', $this->remoteContentClassDefinition->ID);
$tpl->setVariable('client', $this);
$attributeFields = array();
$dataMap = $this->contentClass->attribute('data_map');
$disabled = array();
if (eZINI::instance('ocsearchtools.ini')->hasVariable('RemoteClassSearchFormSettings', 'DisabledAttributes')) {
$disabled = eZINI::instance('ocsearchtools.ini')->variable('RemoteClassSearchFormSettings', 'DisabledAttributes');
}
/** @var $dataMap eZContentClassAttribute[] */
foreach ($dataMap as $attribute) {
if (!in_array($this->contentClass->attribute('identifier') . '/' . $attribute->attribute('identifier'), $disabled) && $attribute->attribute('is_searchable')) {
if (isset($this->remoteContentClassDefinition->DataMap[0]->{$attribute->attribute('identifier')})) {
$attribute->setAttribute('data_type_string', $this->remoteContentClassDefinition->DataMap[0]->{$attribute->attribute('identifier')}->DataTypeString);
$inputField = OCRemoteClassSearchFormAttributeField::instance($attribute, $this->remoteContentClassDefinition->DataMap[0]->{$attribute->attribute('identifier')}, $this);
$keyArray = array(array('class_identifier', $this->contentClass->attribute('identifier')), array('attribute_identifier', $inputField->contentClassAttribute->attribute('identifier')));
$tpl = eZTemplate::factory();
$tpl->setVariable('class', $this->contentClass);
$tpl->setVariable('attribute', $inputField->contentClassAttribute);
$tpl->setVariable('input', $inputField);
$res = eZTemplateDesignResource::instance();
$res->setKeys($keyArray);
$templateName = $inputField->contentClassAttribute->attribute('data_type_string');
$attributeFields[$inputField->attribute('id')] = $tpl->fetch('design:class_search_form/datatypes/' . $templateName . '.tpl');
}
}
}
$tpl->setVariable('attribute_fields', $attributeFields);
$parameters = array('action' => 'search');
$tpl->setVariable('parameters', $parameters);
$formAction = $this->attributes['definition']['ClientBasePath'];
eZURI::transformURI($formAction);
$tpl->setVariable('form_action', $formAction);
$res = eZTemplateDesignResource::instance();
$res->setKeys($classKeyArray);
return $tpl->fetch('design:repository/contentclass_client/remote_class_search_form.tpl');
}
示例6: getObjectsWithCollectedInformation
public static function getObjectsWithCollectedInformation($offset = 0, $limit = 10)
{
$db = eZDB::instance();
$objects = $db->arrayQuery('SELECT DISTINCT ezinfocollection.contentobject_id,
ezcontentobject.name,
ezcontentobject_tree.main_node_id,
ezcontentclass.*,
ezcontentclass.identifier AS class_identifier
FROM ezinfocollection,
ezcontentobject,
ezcontentobject_tree,
ezcontentclass
WHERE ezinfocollection.contentobject_id=ezcontentobject.id
AND ezcontentobject.contentclass_id=ezcontentclass.id
AND ezinfocollection.contentobject_id=ezcontentobject_tree.contentobject_id', array('limit' => (int) $limit, 'offset' => (int) $offset));
foreach (array_keys($objects) as $i) {
$collections = eZInformationCollection::fetchCollectionsList((int) $objects[$i]['contentobject_id'], false, false, false, false, false);
$class = new eZContentClass($objects[$i]);
$objects[$i]['class_name'] = $class->attribute('name');
$first = $collections[0]['created'];
$last = $first;
for ($j = 0; $j < count($collections); $j++) {
$current = $collections[$j]['created'];
if ($current < $first) {
$first = $current;
}
if ($current > $last) {
$last = $current;
}
}
$objects[$i]['first_collection'] = $first;
$objects[$i]['last_collection'] = $last;
$objects[$i]['collections'] = count($collections);
}
return $objects;
}
示例7: getBrowseItems
/**
* Returns a struct containing the following values:
* - limit the number of element by page
* - offset the current offset
* - items array, each element contains
* - has_child boolean
* - can_create boolean
* - node eZContentObjectTreeNode
* - has_prev boolean, true if there's a previous page
* - has_next boolean, true if there's a next page
*
* @param eZContentObjectTreeNode $start the node where the browse will start
* @param eZContentClass $class class of the object to be created
* @param int $offset
* @return array
*/
private static function getBrowseItems( eZContentObjectTreeNode $start, eZContentClass $class, $offset = 0 )
{
$result = array(
'limit' => 10,
'offset' => $offset,
'items' => array(),
'has_prev' => ( $offset != 0 ),
'has_next' => false
);
$containerClasses = eZPersistentObject::fetchObjectList(
eZContentClass::definition(), null,
array(
'version' => eZContentClass::VERSION_STATUS_DEFINED,
'is_container' => 1
)
);
$classFilterArray = array();
foreach ( $containerClasses as $c )
{
$classFilterArray[] = $c->attribute( 'identifier' );
}
$children = $start->subTree(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1,
'Limit' => $result['limit'],
'Offset' => $offset
)
);
$count = $start->subTreeCount(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1
)
);
if ( $count > ( $offset + $result['limit'] ) )
{
$result['has_next'] = true;
}
foreach( $children as $node )
{
$elt = array();
$elt['node'] = $node;
$canCreateClassist = $node->canCreateClassList();
foreach( $canCreateClassist as $c )
{
if ( $c['id'] == $class->attribute( 'id' ) )
{
$elt['can_create'] = true;
break;
}
}
if ( !isset( $elt['can_create'] ) )
{
$elt['can_create'] = false;
}
$childrenContainerCount = $node->subTreeCount(
array(
'ClassFilterArray' => $classFilterArray,
'ClassFilterType' => 'include',
'Depth' => 1
)
);
$elt['has_child'] = ( $childrenContainerCount > 0 );
$result['items'][] = $elt;
}
return $result;
}
示例8: createClassDOMElement
/**
* Create Class element.
*
* @param DOMDocument Owner DOMDocument
* @param eZContentClass eZContentClass object.
*
* @return DOMElement Class DOMDocument, example:
*
* <Class ID="12" identifier="comment" primaryLanguage="eng-GB">
* <NameList>
* <Name locale="eng-GB">eZ Publish rocks</Name>
* </NameList>
* </Class>
*/
protected function createClassDOMElement(DOMDocument $domDocument, eZContentClass $class)
{
$classElement = $domDocument->createElement('Class');
// Set attributes
$classElement->setAttribute('ID', $class->attribute('id'));
$classElement->setAttribute('primaryLanguage', $class->attribute('top_priority_language_locale'));
$classElement->setAttribute('identifier', $class->attribute('identifier'));
// Add Language list.
$classElement->appendChild($this->createNameListDOMElement($domDocument, $class->NameList));
return $classElement;
}
示例9: checkAccess
protected function checkAccess()
{
$user = eZUser::currentUser();
$userID = $user->attribute('contentobject_id');
$accessResult = $user->hasAccessTo('exportas', $this->functionName);
$accessWord = $accessResult['accessWord'];
if ($accessWord == 'yes') {
return true;
} else {
if ($accessWord == 'no') {
return false;
} else {
$policies =& $accessResult['policies'];
$access = 'denied';
foreach (array_keys($policies) as $pkey) {
$limitationArray =& $policies[$pkey];
if ($access == 'allowed') {
break;
}
$limitationList = array();
if (isset($limitationArray['Subtree'])) {
$checkedSubtree = false;
} else {
$checkedSubtree = true;
$accessSubtree = false;
}
if (isset($limitationArray['Node'])) {
$checkedNode = false;
} else {
$checkedNode = true;
$accessNode = false;
}
foreach (array_keys($limitationArray) as $key) {
$access = 'denied';
switch ($key) {
case 'Class':
if (!$this->mainClass) {
$access = 'denied';
$limitationList = array('Limitation' => $key, 'Required' => $limitationArray[$key]);
} elseif (in_array($this->mainClass->attribute('id'), $limitationArray[$key])) {
$access = 'allowed';
} else {
$access = 'denied';
$limitationList = array('Limitation' => $key, 'Required' => $limitationArray[$key]);
}
break;
case 'Section':
case 'User_Section':
if (in_array($this->mainObject->attribute('section_id'), $limitationArray[$key])) {
$access = 'allowed';
} else {
$access = 'denied';
$limitationList = array('Limitation' => $key, 'Required' => $limitationArray[$key]);
}
break;
case 'Node':
$accessNode = false;
$mainNodeID = $this->mainObject->attribute('main_node_id');
foreach ($limitationArray[$key] as $nodeID) {
$node = eZContentObjectTreeNode::fetch($nodeID, false, false);
$limitationNodeID = $node['main_node_id'];
if ($mainNodeID == $limitationNodeID) {
$access = 'allowed';
$accessNode = true;
break;
}
}
$checkedNode = true;
break;
default:
if (strncmp($key, 'StateGroup_', 11) === 0) {
if (count(array_intersect($limitationArray[$key], $this->mainObject->attribute('state_id_array'))) == 0) {
$access = 'denied';
$limitationList = array('Limitation' => $key, 'Required' => $limitationArray[$key]);
} else {
$access = 'allowed';
}
}
}
if ($access == 'denied') {
break;
}
}
$policyList[] = array('PolicyID' => $pkey, 'LimitationList' => $limitationList);
}
if ($access == 'denied') {
return array('FunctionRequired' => array('Module' => 'exportas', 'Function' => $this->functionName), 'PolicyList' => $policyList);
} else {
return true;
}
}
}
}