本文整理汇总了PHP中eZContentObject::mapLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::mapLanguage方法的具体用法?PHP eZContentObject::mapLanguage怎么用?PHP eZContentObject::mapLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::mapLanguage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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.
//.........这里部分代码省略.........