本文整理汇总了PHP中eZContentClass::fetchByIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClass::fetchByIdentifier方法的具体用法?PHP eZContentClass::fetchByIdentifier怎么用?PHP eZContentClass::fetchByIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentClass
的用法示例。
在下文中一共展示了eZContentClass::fetchByIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($id, $createIfNotExists = false, $options = array(), $remoteUrl = null)
{
$this->notifications = array(self::ERROR => array(), self::WARNING => array(), self::NOTICE => array());
if ($remoteUrl !== NULL) {
self::setRemoteUrl($remoteUrl);
}
$class = eZContentClass::fetch(intval($id));
$this->options = $options;
$this->data = new stdClass();
if (!$class instanceof eZContentClass) {
$class = eZContentClass::fetchByIdentifier($id);
}
if (!$class instanceof eZContentClass) {
if (!$createIfNotExists) {
throw new Exception("Classe {$id} non trovata");
} else {
if (!is_numeric($id)) {
eZDebug::writeWarning("Creazione della classe {$id}");
$class = $this->createNew($id);
if (!$class instanceof eZContentClass) {
throw new Exception("Fallita la creazionde della classe {$id}");
}
} else {
throw new Exception("Per creare automaticamente una nuova classe è necessario fornire l'identificativo e non l'id numerico");
}
}
}
$this->currentClass = $class;
$this->id = $this->currentClass->attribute('id');
$this->identifier = $this->currentClass->attribute('identifier');
}
示例2: 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;
}
示例3: 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";
}
示例4: notificationAvailableTags
/**
* Ritorna l'elengo dei tag disponibili
*
* @return eZTagsObject[]
*/
public static function notificationAvailableTags()
{
$class = eZContentClass::fetchByIdentifier(self::CLASS_IDENTIFIER);
if ($class instanceof eZContentClass) {
$classAttribute = $class->fetchAttributeByIdentifier(self::TAG_ATTRIBUTE_IDENTIFIER);
if ($classAttribute instanceof eZContentClassAttribute) {
$tagRoot = eZTagsObject::fetch(intval($classAttribute->attribute(eZTagsType::SUBTREE_LIMIT_FIELD)));
return $tagRoot->getChildren();
}
}
return array();
}
示例5: 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')));
}
示例6: __construct
public function __construct($classIdentifier, $parentNodeID = false, $creatorID = 14, $section = 1, $languageCode = false)
{
$this->class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$this->class instanceof eZContentClass) {
throw new ezcBaseValueException('class', isset($this->class) ? get_class($this->class) : null, 'eZContentClass ($classIdentifier was: ' . $classIdentifier . ' ) ', 'member');
}
$this->object = $this->class->instantiate($creatorID, $section, false, $languageCode);
// Create main node
if (is_numeric($parentNodeID)) {
$this->mainNode = new ezpNode($this->object, $parentNodeID, true);
}
$this->nodes = array($this->mainNode);
}
示例7: testVersionHistoryLimitWithObjectParameter
/**
* Unit test for eZContentClass::versionHistoryLimit() with object parameters
*
* Replica of testVersionHistoryLimit() but you cannot make calls
* to the eZ API which relies on a database, as this is not present
* in the provider methods.
*/
public function testVersionHistoryLimitWithObjectParameter()
{
// different custom limits (article: 13, image: 6) and object as a parameter
$INISettings = array(array('VersionHistoryClass', array('article' => 13, 'image' => 6)));
$class = eZContentClass::fetchByIdentifier('image');
$expectedLimit = 6;
// change the INI limit settings
foreach ($INISettings as $settings) {
list($INIVariable, $INIValue) = $settings;
ezpINIHelper::setINISetting('content.ini', 'VersionManagement', $INIVariable, $INIValue);
}
$limit = eZContentClass::versionHistoryLimit($class);
self::assertEquals($expectedLimit, $limit);
ezpINIHelper::restoreINISettings();
}
示例8: updateContentObject
private function updateContentObject(eZContentObject $eZContentObject)
{
$mainNodeID = $eZContentObject->mainNodeID();
$parentNodeID = eZContentObjectTreeNode::getParentNodeId($mainNodeID);
$classIdentifier = $eZContentObject->ClassIdentifier;
$remoteID = $eZContentObject->RemoteID;
if (!eZContentClass::fetchByIdentifier($classIdentifier)) {
throw new Exception("La classe" . $classIdentifier . "non esiste in questa installazione");
}
$params = array();
$params['class_identifier'] = $classIdentifier;
$params['remote_id'] = $remoteID;
$params['parent_node_id'] = $parentNodeID;
$params['attributes'] = $this->getAttributesStringArray($eZContentObject);
$result = eZContentFunctions::updateAndPublishObject($eZContentObject, $params);
return $result;
}
示例9: modify
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
{
switch ($operatorName) {
case 'class_extra_parameters':
$classIdentifier = $namedParameters['class_identifier'];
$handler = $namedParameters['handler'];
$class = eZContentClass::fetchByIdentifier($classIdentifier);
if ($class instanceof eZContentClass) {
$extraParametersManager = OCClassExtraParametersManager::instance($class);
if (is_string($handler)) {
$operatorValue = $extraParametersManager->getHandler($handler);
} else {
$operatorValue = $extraParametersManager->getHandlers();
}
}
break;
}
}
示例10: providerTestGetFieldName
/**
* Data provider for testGetFieldName
**/
public static function providerTestGetFieldName()
{
$providerArray = array();
$providerArray[] = array(ezfSolrDocumentFieldBase::ATTR_FIELD_PREFIX . 'title_t', 'article/title');
if ($contentClass = eZContentClass::fetchByIdentifier('article')) {
$contentClassId = $contentClass->attribute('id');
$providerArray[] = array(array('fieldName' => ezfSolrDocumentFieldBase::ATTR_FIELD_PREFIX . 'title_t', 'contentClassId' => $contentClassId), 'article/title', true);
}
/*
if ( $contentClass = eZContentClass::fetchByIdentifier( 'article' ) )
{
$providerArray[] = array(
ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . 'image-alternative_text_t',
'article/image/alternative_text'
);
}
*/
return $providerArray;
}
示例11: fetch
public function fetch($parameters, $publishedAfter, $publishedBeforeOrAt)
{
$ini = eZINI::instance('block.ini');
$limit = 5;
if ($ini->hasVariable('Keywords', 'NumberOfValidItems')) {
$limit = $ini->variable('Keywords', 'NumberOfValidItems');
}
if (isset($parameters['Source']) && $parameters['Source'] != '') {
$nodeID = $parameters['Source'];
$node = eZContentObjectTreeNode::fetch($nodeID, false, false);
// not as an object
if ($node && $node['modified_subnode'] <= $publishedAfter) {
return array();
}
} else {
$nodeID = false;
}
$sortBy = array('published', false);
$classIDs = array();
if (isset($parameters['Classes']) && $parameters['Classes'] != '') {
$classIdentifiers = explode(',', $parameters['Classes']);
foreach ($classIdentifiers as $classIdentifier) {
$class = eZContentClass::fetchByIdentifier($classIdentifier, false);
// not as an object
if ($class) {
$classIDs[] = $class['id'];
}
}
}
if (isset($parameters['Keywords'])) {
$keywords = $parameters['Keywords'];
}
$result = eZFunctionHandler::execute('content', 'keyword', array('alphabet' => $keywords, 'classid' => $classIDs, 'offset' => 0, 'limit' => $limit, 'parent_node_id' => $nodeID, 'include_duplicates' => false, 'sort_by' => $sortBy, 'strict_matching' => false));
if ($result === null) {
return array();
}
$fetchResult = array();
foreach ($result as $item) {
$fetchResult[] = array('object_id' => $item['link_object']->attribute('contentobject_id'), 'node_id' => $item['link_object']->attribute('node_id'), 'ts_publication' => $item['link_object']->object()->attribute('published'));
}
return $fetchResult;
}
示例12: createObject
function createObject($classIdentifier, $parentNodeID, $name)
{
$user = eZUser::currentUser();
$Class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$Class) {
eZDebug::writeError("No class with identifier {$classIdentifier}", "classCreation");
return false;
}
$contentObject = $Class->instantiate($user->attribute('contentobject_id'));
$nodeAssignment = eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'), 'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentNodeID, 'is_main' => 1));
$nodeAssignment->store();
$version = $contentObject->version(1);
$version->setAttribute('modified', eZDateTime::currentTimeStamp());
$version->setAttribute('status', eZContentObjectVersion::STATUS_DRAFT);
$version->store();
$contentObjectID = $contentObject->attribute('id');
$attributes = $contentObject->attribute('contentobject_attributes');
$attributes[0]->fromString($name);
$attributes[0]->store();
$operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $contentObjectID, 'version' => 1));
return true;
}
示例13: unserialize
/**
* Unserialize xml structure. Creates an object from xml input.
*
* Transaction unsafe. If you call several transaction unsafe methods you must enclose
* the calls within a db transaction; thus within db->begin and db->commit.
*
* @param mixed $package
* @param DOMElement $domNode
* @param array $options
* @param int|bool $ownerID Override owner ID, null to use XML owner id (optional)
* @param string $handlerType
* @return array|bool|eZContentObject|null created object, false if could not create object/xml invalid
*/
static function unserialize( $package, $domNode, &$options, $ownerID = false, $handlerType = 'ezcontentobject' )
{
if ( $domNode->localName != 'object' )
{
$retValue = false;
return $retValue;
}
$initialLanguage = eZContentObject::mapLanguage( $domNode->getAttribute( 'initial_language' ), $options );
if( $initialLanguage === 'skip' )
{
$retValue = true;
return $retValue;
}
$sectionID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'section_id' );
if ( $ownerID === false )
{
$ownerID = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'owner_id' );
}
$remoteID = $domNode->getAttribute( 'remote_id' );
$name = $domNode->getAttribute( 'name' );
$classRemoteID = $domNode->getAttribute( 'class_remote_id' );
$classIdentifier = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'class_identifier' );
$alwaysAvailable = ( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'always_available' ) == '1' );
$contentClass = eZContentClass::fetchByRemoteID( $classRemoteID );
if ( !$contentClass )
{
$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier );
}
if ( !$contentClass )
{
$options['error'] = array( 'error_code' => self::PACKAGE_ERROR_NO_CLASS,
'element_id' => $remoteID,
'description' => "Can't install object '$name': Unable to fetch class with remoteID: $classRemoteID." );
$retValue = false;
return $retValue;
}
/** @var DOMElement $versionListNode */
$versionListNode = $domNode->getElementsByTagName( 'version-list' )->item( 0 );
$importedLanguages = array();
foreach( $versionListNode->getElementsByTagName( 'version' ) as $versionDOMNode )
{
/** @var DOMElement $versionDOMNode */
foreach ( $versionDOMNode->getElementsByTagName( 'object-translation' ) as $versionDOMNodeChild )
{
/** @var DOMElement $versionDOMNodeChild */
$importedLanguage = eZContentObject::mapLanguage( $versionDOMNodeChild->getAttribute( 'language' ), $options );
$language = eZContentLanguage::fetchByLocale( $importedLanguage );
// Check if the language is allowed in this setup.
if ( $language )
{
$hasTranslation = true;
}
else
{
if ( $importedLanguage == 'skip' )
continue;
// if there is no needed translation in system then add it
$locale = eZLocale::instance( $importedLanguage );
$translationName = $locale->internationalLanguageName();
$translationLocale = $locale->localeCode();
if ( $locale->isValid() )
{
eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
$hasTranslation = true;
}
else
$hasTranslation = false;
}
if ( $hasTranslation )
{
$importedLanguages[] = $importedLanguage;
$importedLanguages = array_unique( $importedLanguages );
}
}
}
// If object exists we return a error.
// Minimum install element is an object now.
//.........这里部分代码省略.........
示例14: getContentClass
/**
* Returns the content class to use when creating the content object from
* the file
*
* @param array $mimeData
* @return eZContentClass
* @throw RuntimeException if the found class identifier does not exists
* @throw DomainException if objects of the found class are not allowed
*/
public function getContentClass(array $mimeData)
{
$upload = new eZContentUpload();
$classIdentifier = $upload->detectClassIdentifier($mimeData['name']);
$class = eZContentClass::fetchByIdentifier($classIdentifier);
if (!$class instanceof eZContentClass) {
throw new RuntimeException(ezpI18n::tr('extension/ezjscore/ajaxuploader', 'Unable to load the class which identifier is "%class",' . ' this is probably a configuration issue in upload.ini.', null, array('%class' => $classIdentifier)));
}
$classContent = $this->attribute->attribute('class_content');
if (!empty($classContent['class_constraint_list']) && !in_array($classIdentifier, $classContent['class_constraint_list'])) {
throw new DomainException(ezpI18n::tr('extension/ezjscore/ajaxuploader', 'The file cannot be processed because' . ' it would result in a \'%class\' object and this relation' . ' does not accept this type of object.', null, array('%class' => $class->attribute('name'))));
}
return $class;
}
示例15:
}
if ($http->hasPostVariable('NewButton') || $module->isCurrentAction('NewObjectAddNodeAssignment')) {
$hasClassInformation = false;
$contentClassID = false;
$contentClassIdentifier = false;
$languageCode = false;
$class = false;
if ($http->hasPostVariable('ClassID')) {
$contentClassID = $http->postVariable('ClassID');
if ($contentClassID) {
$hasClassInformation = true;
}
} else {
if ($http->hasPostVariable('ClassIdentifier')) {
$contentClassIdentifier = $http->postVariable('ClassIdentifier');
$class = eZContentClass::fetchByIdentifier($contentClassIdentifier);
if (is_object($class)) {
$contentClassID = $class->attribute('id');
if ($contentClassID) {
$hasClassInformation = true;
}
}
}
}
if ($http->hasPostVariable('ContentLanguageCode')) {
$languageCode = $http->postVariable('ContentLanguageCode');
$languageID = eZContentLanguage::idByLocale($languageCode);
if ($languageID === false) {
eZDebug::writeError("The language code [{$languageCode}] specified in ContentLanguageCode does not exist in the system.");
return $module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}