本文整理汇总了PHP中eZContentClass::fetchByRemoteID方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClass::fetchByRemoteID方法的具体用法?PHP eZContentClass::fetchByRemoteID怎么用?PHP eZContentClass::fetchByRemoteID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentClass
的用法示例。
在下文中一共展示了eZContentClass::fetchByRemoteID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
function install($package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData)
{
$serializedNameListNode = $content->getElementsByTagName('serialized-name-list')->item(0);
$serializedNameList = $serializedNameListNode ? $serializedNameListNode->textContent : false;
$classNameList = new eZContentClassNameList($serializedNameList);
if ($classNameList->isEmpty()) {
$classNameList->initFromString($content->getElementsByTagName('name')->item(0)->textContent);
// for backward compatibility( <= 3.8 )
}
$classNameList->validate();
$serializedDescriptionListNode = $content->getElementsByTagName('serialized-description-list')->item(0);
$serializedDescriptionList = $serializedDescriptionListNode ? $serializedDescriptionListNode->textContent : false;
$classDescriptionList = new eZSerializedObjectNameList($serializedDescriptionList);
$classIdentifier = $content->getElementsByTagName('identifier')->item(0)->textContent;
$classRemoteID = $content->getElementsByTagName('remote-id')->item(0)->textContent;
$classObjectNamePattern = $content->getElementsByTagName('object-name-pattern')->item(0)->textContent;
$classURLAliasPattern = is_object($content->getElementsByTagName('url-alias-pattern')->item(0)) ? $content->getElementsByTagName('url-alias-pattern')->item(0)->textContent : null;
$classIsContainer = $content->getAttribute('is-container');
if ($classIsContainer !== false) {
$classIsContainer = $classIsContainer == 'true' ? 1 : 0;
}
$classRemoteNode = $content->getElementsByTagName('remote')->item(0);
$classID = $classRemoteNode->getElementsByTagName('id')->item(0)->textContent;
$classGroupsNode = $classRemoteNode->getElementsByTagName('groups')->item(0);
$classCreated = $classRemoteNode->getElementsByTagName('created')->item(0)->textContent;
$classModified = $classRemoteNode->getElementsByTagName('modified')->item(0)->textContent;
$classCreatorNode = $classRemoteNode->getElementsByTagName('creator')->item(0);
$classModifierNode = $classRemoteNode->getElementsByTagName('modifier')->item(0);
$classAttributesNode = $content->getElementsByTagName('attributes')->item(0);
$dateTime = time();
$classCreated = $dateTime;
$classModified = $dateTime;
$userID = false;
if (isset($installParameters['user_id'])) {
$userID = $installParameters['user_id'];
}
$class = eZContentClass::fetchByRemoteID($classRemoteID);
if ($class) {
$className = $class->name();
$description = ezpI18n::tr('kernel/package', "Class '%classname' already exists.", false, array('%classname' => $className));
$choosenAction = $this->errorChoosenAction(self::ERROR_EXISTS, $installParameters, $description, $this->HandlerType);
switch ($choosenAction) {
case eZPackage::NON_INTERACTIVE:
case self::ACTION_REPLACE:
if (eZContentClassOperations::remove($class->attribute('id')) == false) {
eZDebug::writeWarning("Unable to remove class '{$className}'.");
return true;
}
eZDebug::writeNotice("Class '{$className}' will be replaced.", 'eZContentClassPackageHandler');
break;
case self::ACTION_SKIP:
return true;
case self::ACTION_NEW:
$class->setAttribute('remote_id', eZRemoteIdUtility::generate('class'));
$class->store();
$classNameList->appendGroupName(" (imported)");
break;
default:
$installParameters['error'] = array('error_code' => self::ERROR_EXISTS, 'element_id' => $classRemoteID, 'description' => $description, 'actions' => array());
if ($class->isRemovable()) {
$errorMsg = ezpI18n::tr('kernel/package', "Replace existing class");
$objectsCount = eZContentObject::fetchSameClassListCount($class->attribute('id'));
if ($objectsCount) {
$errorMsg .= ' ' . ezpI18n::tr('kernel/package', "(Warning! {$objectsCount} content object(s) and their sub-items will be removed)");
}
$installParameters['error']['actions'][self::ACTION_REPLACE] = $errorMsg;
}
$installParameters['error']['actions'][self::ACTION_SKIP] = ezpI18n::tr('kernel/package', 'Skip installing this class');
$installParameters['error']['actions'][self::ACTION_NEW] = ezpI18n::tr('kernel/package', 'Keep existing and create a new one');
return false;
}
}
unset($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;
$values = array('version' => 0, 'serialized_name_list' => $classNameList->serializeNames(), 'serialized_description_list' => $classDescriptionList->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);
if ($content->hasAttribute('sort-field')) {
$values['sort_field'] = eZContentObjectTreeNode::sortFieldID($content->getAttribute('sort-field'));
} else {
eZDebug::writeNotice('The sort field was not specified in the content class package. ' . 'This property is exported and imported since eZ Publish 4.0.2', __METHOD__);
}
if ($content->hasAttribute('sort-order')) {
$values['sort_order'] = $content->getAttribute('sort-order');
} else {
//.........这里部分代码省略.........
示例2: 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.
//.........这里部分代码省略.........
示例3: installFetchAliases
function installFetchAliases( $fetchAliasListNode, &$parameters )
{
if ( !$fetchAliasListNode )
{
return true;
}
$fetchAliasINIArray = array();
foreach( $fetchAliasListNode->getElementsByTagName( 'fetch-alias' ) as $blockNode )
{
if ( isset( $parameters['site_access_map'][$blockNode->getAttribute( 'site-access' )] ) )
{
$newSiteAccess = $parameters['site_access_map'][$blockNode->getAttribute( 'site-access' )];
}
else
{
$newSiteAccess = $parameters['site_access_map']['*'];
}
if ( !isset( $fetchAliasINIArray[$newSiteAccess] ) )
{
$fetchAliasINIArray[$newSiteAccess] = eZINI::instance( 'fetchalias.ini.append.php', "settings/siteaccess/$newSiteAccess", null, null, true );
}
$blockArray = array();
$blockName = $blockNode->getAttribute( 'name' );
$blockArray[$blockName] = eZContentObjectPackageHandler::createArrayFromDOMNode( $blockNode->getElementsByTagName( $blockName )->item( 0 ) );
//$blockArray[$blockName] = $blockArray[$blockName][0];
if ( isset( $blockArray[$blockName]['Constant'] ) && is_array( $blockArray[$blockName]['Constant'] ) && count( $blockArray[$blockName]['Constant'] ) > 0 )
{
foreach( $blockArray[$blockName]['Constant'] as $matchKey => $value )
{
if ( strpos( $matchKey, 'class_' ) === 0 &&
is_int( $value ) )
{
$contentClass = eZContentClass::fetchByRemoteID( $blockArray[$blockName]['Constant']['class_remote_id'] );
$blockArray[$blockName]['Constant'][$matchKey] = $contentClass->attribute( 'id' );
unset( $blockArray[$blockName]['Constant']['class_remote_id'] );
}
if( strpos( $matchKey, 'node_' ) === 0 &&
is_int( $value ) )
{
$contentTreeNode = eZContentObjectTreeNode::fetchByRemoteID( $blockArray[$blockName]['Constant']['node_remote_id'] );
$blockArray[$blockName]['Constant'][$matchKey] = $contentTreeNode->attribute( 'node_id' );
unset( $blockArray[$blockName]['Constant']['node_remote_id'] );
}
if( strpos( $matchKey, 'parent_node_' ) === 0 &&
is_int( $value ) )
{
$contentTreeNode = eZContentObjectTreeNode::fetchByRemoteID( $blockArray[$blockName]['Constant']['parent_node_remote_id'] );
$blockArray[$blockName]['Constant'][$matchKey] = $contentTreeNode->attribute( 'node_id' );
unset( $blockArray[$blockName]['Constant']['parent_node_remote_id'] );
}
if( strpos( $matchKey, 'object_' ) === 0 &&
is_int( $value ) )
{
$contentObject = eZContentObject::fetchByRemoteID( $blockArray[$blockName]['Constant']['object_remote_id'] );
$blockArray[$blockName]['Constant'][$matchKey] = $contentTreeNode->attribute( 'id' );
unset( $blockArray[$blockName]['Constant']['object_remote_id'] );
}
}
}
$fetchAliasINIArray[$newSiteAccess]->setVariables( $blockArray );
}
foreach( $fetchAliasINIArray as $siteAccess => $iniFetchAlias )
{
$fetchAliasINIArray[$siteAccess]->save();
}
return true;
}
示例4: execute
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';
//.........这里部分代码省略.........