本文整理汇总了PHP中eZContentObjectVersion::mapLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectVersion::mapLanguage方法的具体用法?PHP eZContentObjectVersion::mapLanguage怎么用?PHP eZContentObjectVersion::mapLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectVersion
的用法示例。
在下文中一共展示了eZContentObjectVersion::mapLanguage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unserialize
static function unserialize( $domNode, $contentObject, $ownerID, $sectionID, $activeVersion, $firstVersion, &$nodeList, &$options, $package, $handlerType = 'ezcontentobject' )
{
$oldVersion = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'version' );
$status = $domNode->getAttributeNS( 'http://ez.no/ezobject', 'status' );
$languageNodeArray = $domNode->getElementsByTagName( 'object-translation' );
$initialLanguage = false;
$importedLanguages = $options['language_array'];
$currentLanguages = array();
foreach( $languageNodeArray as $languageNode )
{
$language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
if ( in_array( $language, $importedLanguages ) )
{
$currentLanguages[] = $language;
}
}
foreach ( eZContentLanguage::prioritizedLanguages() as $language )
{
if ( in_array( $language->attribute( 'locale' ), $currentLanguages ) )
{
$initialLanguage = $language->attribute( 'locale' );
break;
}
}
if ( !$initialLanguage )
{
$initialLanguage = $currentLanguages[0];
}
if ( $firstVersion )
{
$contentObjectVersion = $contentObject->version( 1 );
}
else
{
// Create new version in specific language but with empty data.
$contentObjectVersion = $contentObject->createNewVersionIn( $initialLanguage );
}
$created = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'created' ) );
$modified = eZDateUtils::textToDate( $domNode->getAttributeNS( 'http://ez.no/ezobject', 'modified' ) );
$contentObjectVersion->setAttribute( 'created', $created );
$contentObjectVersion->setAttribute( 'modified', $modified );
$contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT );
$contentObjectVersion->store();
$db = eZDB::instance();
$db->begin();
foreach( $languageNodeArray as $languageNode )
{
$language = eZContentObjectVersion::mapLanguage( $languageNode->getAttribute( 'language' ), $options );
// Only import allowed languages.
if ( !in_array( $language, $importedLanguages ) )
{
continue;
}
$attributeArray = $contentObjectVersion->contentObjectAttributes( $language );
if ( count( $attributeArray ) == 0)
{
$hasTranslation = eZContentLanguage::fetchByLocale( $language );
if ( !$hasTranslation )
{
// if there is no needed translation in system then add it
$locale = eZLocale::instance( $language );
if ( $locale->isValid() )
{
eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
$hasTranslation = true;
}
else
$hasTranslation = false;
}
if ( $hasTranslation )
{
// Add translated attributes for the translation
$originalContentAttributes = $contentObjectVersion->contentObjectAttributes( $initialLanguage );
foreach ( $originalContentAttributes as $originalContentAttribute )
{
$contentAttribute = $originalContentAttribute->translateTo( $language );
$contentAttribute->sync();
$attributeArray[] = $contentAttribute;
}
}
// unserialize object name in current version-translation
$objectName = $languageNode->getAttribute( 'object_name' );
if ( $objectName )
$contentObject->setName( $objectName, $contentObjectVersion->attribute( 'version' ), $language );
}
$xpath = new DOMXPath( $domNode->ownerDocument );
$xpath->registerNamespace( 'ezobject', 'http://ez.no/object/' );
$xpath->registerNamespace( 'ezremote', 'http://ez.no/ezobject' );
//.........这里部分代码省略.........