本文整理汇总了PHP中eZContentLanguage::prioritizedLanguageCodes方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::prioritizedLanguageCodes方法的具体用法?PHP eZContentLanguage::prioritizedLanguageCodes怎么用?PHP eZContentLanguage::prioritizedLanguageCodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::prioritizedLanguageCodes方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue19174
/**
* Regression test for issue {@see #19174 http://issues.ez.no/19174}
*/
public function testIssue19174()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// create related objects
$relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
$xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
$xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
// Create an article in eng-GB, and embed related object one in the intro
$article = new ezpObject('article', 2, 14, 1, 'eng-GB');
$article->title = __METHOD__ . ' eng-GB';
$article->intro = $xmlTextEn;
$articleId = $article->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
$relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
self::assertEquals(4, count($relatedObjects));
$expectedRelations = array_flip($relatedObjectsIds);
foreach ($relatedObjects as $relatedObject) {
if (isset($expectedRelations[$relatedObject->ID])) {
unset($expectedRelations[$relatedObject->ID]);
}
}
self::assertEquals(0, count($expectedRelations));
$article->remove();
$translation->removeThis();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例2: fetchUrlAlias
public function fetchUrlAlias($nodeId = null, $path = null, $locale)
{
if (!$nodeId && !$path) {
return array('result' => false);
}
if (empty($locale) || !is_string($locale)) {
return array('result' => false);
}
if (is_numeric($nodeId)) {
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
} else {
if (is_string($path)) {
$nodeId = eZURLAliasML::fetchNodeIDByPath($path);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, $locale, false);
}
}
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// Either no translation exists for $locale or $path was not pointing to a node
return array('result' => false);
}
$currentLanguageCodes = eZContentLanguage::prioritizedLanguageCodes();
array_unshift($currentLanguageCodes, $locale);
$currentLanguageCodes = array_unique($currentLanguageCodes);
$urlAlias = $destinationElement[0]->getPath($locale, $currentLanguageCodes);
return array('result' => $urlAlias);
}
示例3: modify
function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
{
$ret = '';
switch ($operatorName) {
case 'get_url_alias_by_lang':
$node = eZContentObjectTreeNode::fetch($namedParameters['node_id'], $namedParameters['lang_code']);
$originalPrioritizedLanguages = eZContentLanguage::prioritizedLanguageCodes();
eZContentLanguage::setPrioritizedLanguages(array($namedParameters['lang_code']));
$urlAlias = '';
if (is_object($node)) {
$urlAlias = '/' . $node->urlAlias();
}
eZContentLanguage::setPrioritizedLanguages($originalPrioritizedLanguages);
$ret = $urlAlias;
break;
}
$operatorValue = $ret;
}
示例4: testIssue17632
/**
* Regression test for issue {@see #17632 http://issues.ez.no/17632}
*
* In a multi language environment, a node fetched with a language other than the prioritized one(s) will return the
* URL alias in the prioritized language
*/
public function testIssue17632()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
$strNameEngGB = __FUNCTION__ . " eng-GB";
$strNameFreFR = __FUNCTION__ . " fre-FR";
// add a secondary language
$locale = eZLocale::instance( 'fre-FR' );
$translation = eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );
// set the prioritize language list to contain english
// ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) );
eZContentLanguage::setPrioritizedLanguages( array( 'fre-FR' ) );
// Create an object with data in fre-FR and eng-GB
$folder = new ezpObject( 'folder', 2, 14, 1, 'eng-GB' );
$folder->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$folder->addTranslation( 'eng-GB', array( 'name' => $strNameEngGB ) );
$folder->addTranslation( 'fre-FR', array( 'name' => $strNameFreFR ) );
$nodeId = $folder->main_node_id;
// fetch the node with no default parameters. Should return the french URL Alias
$node = eZContentObjectTreeNode::fetch( $nodeId );
self::assertEquals( 'testIssue17632-fre-FR' , $node->attribute( 'url_alias' ) );
// fetch the node in english. Should return the english URL Alias
$node = eZContentObjectTreeNode::fetch( $nodeId, 'eng-GB' );
self::assertEquals( 'testIssue17632-eng-GB' , $node->attribute( 'url_alias' ) );
ezpINIHelper::restoreINISettings();
eZContentLanguage::setPrioritizedLanguages( $bkpLanguages );
}
示例5: canInstantiateLanguages
function canInstantiateLanguages()
{
if (is_array($this->CanInstantiateLanguages)) {
return array_intersect(eZContentLanguage::prioritizedLanguageCodes(), $this->CanInstantiateLanguages);
}
return array();
}
示例6: fetchPrioritizedLanguageCodes
public static function fetchPrioritizedLanguageCodes()
{
$languageCodes = eZContentLanguage::prioritizedLanguageCodes();
if ($languageCodes === null) {
$result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
} else {
$result = array('result' => $languageCodes);
}
return $result;
}
示例7: testIssue23753
/**
* Regression test for issue {@see #23753 http://issues.ez.no/23753}
*
* In a multi language environment, an untranslated node fetched with default language will return the
* full URL alias in the language of the node.
*/
public function testIssue23753()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
$strNameEngGB = __FUNCTION__ . " eng-GB";
$strNameFreFR = __FUNCTION__ . " fre-FR";
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// set the prioritize language list to contain english
eZContentLanguage::setPrioritizedLanguages(array('fre-FR', 'eng-GB'));
// Create an object with data in fre-FR and eng-GB
$folder = new ezpObject('folder', 2, 14, 1, 'eng-GB');
$folder->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$folder->addTranslation('eng-GB', array('name' => $strNameEngGB));
$folder->addTranslation('fre-FR', array('name' => $strNameFreFR));
$article = new ezpObject('article', $folder->main_node_id, 14, 1, 'eng-GB');
$article->publish();
// Workaround as setting article->name directly doesn't produce the expected result
$article->addTranslation('eng-GB', array('title' => $strNameEngGB));
$nodeId = $article->main_node_id;
// fetch the node with no default parameters. Should return the french URL Alias when applicable
$node = eZContentObjectTreeNode::fetch($nodeId);
self::assertEquals('testIssue23753-fre-FR/testIssue23753-eng-GB', $node->attribute('url_alias'));
// fetch the node in english. Should return the full english URL Alias
$node = eZContentObjectTreeNode::fetch($nodeId, 'eng-GB');
self::assertEquals('testIssue23753-eng-GB/testIssue23753-eng-GB', $node->attribute('url_alias'));
// Test that PathPrefix is correctly removed from UrlAlias
ezpINIHelper::setINISetting('site.ini', 'SiteAccessSettings', 'PathPrefix', 'testIssue23753-fre-FR');
$node = eZContentObjectTreeNode::fetch($nodeId);
self::assertEquals('testIssue23753-eng-GB', $node->attribute('url_alias'));
$folder->remove();
$translation->removeThis();
ezpINIHelper::restoreINISettings();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例8: array
if (!$node instanceof eZContentObjectTreeNode) {
$node = eZContentObjectTreeNode::fetch((int) $nodeID);
if (!$node instanceof eZContentObjectTreeNode) {
return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
} else {
if ($languageCode) {
$foundInRequestedLanguage = true;
}
}
// Hacky solution to tackle a bug in eZ Publish prior to version 4.5
// that always fetched url_alias in locale defined in site.ini.
// Not very happy about it, but it works
$urlAlias = $node->urlAlias();
if ($foundInRequestedLanguage) {
$originalPrioritizedLanguages = eZContentLanguage::prioritizedLanguageCodes();
eZContentLanguage::setPrioritizedLanguages(array($languageCode));
$urlAlias = $node->urlAlias();
eZContentLanguage::setPrioritizedLanguages($originalPrioritizedLanguages);
}
$tagsArray = array();
$keywordArray = array();
foreach ($node->dataMap() as $objectAttribute) {
if ($objectAttribute->hasContent()) {
if ($objectAttribute->attribute('data_type_string') == 'eztags') {
$keywords = str_replace(' ', '', $objectAttribute->content()->keywordString());
$keywords = explode('|#', $keywords);
if (is_array($keywords) && !empty($keywords)) {
$tagsArray = array_merge($tagsArray, $keywords);
}
} else {