本文整理汇总了PHP中eZURLAliasML::choosePrioritizedRow方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURLAliasML::choosePrioritizedRow方法的具体用法?PHP eZURLAliasML::choosePrioritizedRow怎么用?PHP eZURLAliasML::choosePrioritizedRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURLAliasML
的用法示例。
在下文中一共展示了eZURLAliasML::choosePrioritizedRow方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterRows
private static function filterRows($rows, $onlyPrioritized)
{
if (!$onlyPrioritized) {
return $rows;
}
$idMap = array();
foreach ($rows as $row) {
if (!isset($idMap[$row['id']])) {
$idMap[$row['id']] = array();
}
$idMap[$row['id']][] = $row;
}
$rows = array();
foreach ($idMap as $id => $langRows) {
$rows[] = eZURLAliasML::choosePrioritizedRow($langRows);
}
return $rows;
}
示例2: testChoosePrioritizedRow
public function testChoosePrioritizedRow()
{
// Make sure we can see all languages
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'enabled');
$action = "eznode:" . mt_rand();
$name = __FUNCTION__ . mt_rand();
$engGB = eZContentLanguage::fetchByLocale('eng-GB');
$norNO = eZContentLanguage::fetchByLocale('nor-NO');
// Create an english entry
$url1 = eZURLAliasML::create($name . " en", $action, 0, $engGB->attribute('id'));
$url1->store();
// Create a norwegian entry
$url2 = eZURLAliasML::create($name . " no", $action, 0, $norNO->attribute('id'));
$url2->store();
// Fetch the created entries. choosePrioritizedRow() wants rows from the
// database so our eZURLAliasML objects wont work.
$db = eZDB::instance();
$rows = $db->arrayQuery("SELECT * FROM ezurlalias_ml where action = '{$action}'");
// -------------------------------------------------------------------
// TEST PART 1 - NORMAL PRIORITIZATION -------------------------------
// The order of the language array also determines the prioritization.
// In this case 'eng-GB' should be prioritized before 'nor-NO'.
$languageList = array("eng-GB", "nor-NO");
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', $languageList);
eZContentLanguage::clearPrioritizedLanguages();
$row = eZURLAliasML::choosePrioritizedRow($rows);
// The prioritzed language should be 'eng-GB'
self::assertEquals($engGB->attribute('id'), $row["lang_mask"]);
// -------------------------------------------------------------------
// TEST PART 2 - REVERSED PRIORITIZATION -----------------------------
// Reverse the order of the specified languages, this will also
// reverse the priority.
$languageList = array_reverse($languageList);
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', $languageList);
eZContentLanguage::clearPrioritizedLanguages();
$row = eZURLAliasML::choosePrioritizedRow($rows);
// The prioritzed language should be 'nor-NO'
self::assertEquals($norNO->attribute('id'), $row["lang_mask"]);
// -------------------------------------------------------------------
// TEST TEAR DOWN ----------------------------------------------------
ezpINIHelper::restoreINISettings();
// -------------------------------------------------------------------
}
示例3: getPathArray
function getPathArray()
{
if ($this->PathArray !== null) {
return $this->PathArray;
}
// Fetch path 'text' elements of correct parent path
$path = array($this);
$id = (int) $this->Parent;
$db = eZDB::instance();
while ($id != 0) {
$query = "SELECT * FROM ezurlalias_ml WHERE id={$id}";
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
break;
}
$result = eZURLAliasML::choosePrioritizedRow($rows);
if (!$result) {
$result = $rows[0];
}
$id = (int) $result['parent'];
array_unshift($path, new eZPathElement($result));
}
$this->PathArray = $path;
return $this->PathArray;
}
示例4: testChoosePrioritizedRow
public function testChoosePrioritizedRow()
{
// TEST SETUP --------------------------------------------------------
$ini = eZINI::instance();
// Make sure to preserve ini settings in case other tests depend on them
$orgShowUntranslatedObjects = $ini->variable('RegionalSettings', 'ShowUntranslatedObjects');
$orgSiteLanguageList = $ini->variable('RegionalSettings', 'SiteLanguageList');
// Make sure we can see all languages
$ini->setVariable('RegionalSettings', 'ShowUntranslatedObjects', 'enabled');
$action = "eznode:" . mt_rand();
$name = __FUNCTION__ . mt_rand();
// Create an english entry
$url1 = eZURLAliasML::create($name . " en", $action, 0, 2);
$url1->store();
// Create a norwegian entry
$url2 = eZURLAliasML::create($name . " no", $action, 0, 4);
$url2->store();
// Fetch the created entries. choosePrioritizedRow() wants rows from the
// database so our eZURLAliasML objects wont work.
$db = eZDB::instance();
$rows = $db->arrayQuery("SELECT * FROM ezurlalias_ml where action = '{$action}'");
// -------------------------------------------------------------------
// TEST PART 1 - NORMAL PRIORITIZATION -------------------------------
// The order of the language array also determines the prioritization.
// In this case 'eng-GB' should be prioritized before 'nor-NO'.
$languageList = array("eng-GB", "nor-NO");
$ini->setVariable('RegionalSettings', 'SiteLanguageList', $languageList);
eZContentLanguage::clearPrioritizedLanguages();
$row = eZURLAliasML::choosePrioritizedRow($rows);
// The prioritzed language should be 'eng-GB' (lang_mask = 2)
self::assertEquals(2, $row["lang_mask"]);
// -------------------------------------------------------------------
// TEST PART 2 - REVERSED PRIORITIZATION -----------------------------
// Reverse the order of the specified languages, this will also
// reverse the priority.
$languageList = array_reverse($languageList);
$ini->setVariable('RegionalSettings', 'SiteLanguageList', $languageList);
eZContentLanguage::clearPrioritizedLanguages();
$row = eZURLAliasML::choosePrioritizedRow($rows);
// The prioritzed language should be 'nor-NO' (lang_mask = 4)
self::assertEquals(4, $row["lang_mask"]);
// -------------------------------------------------------------------
// TEST TEAR DOWN ----------------------------------------------------
$ini->setVariable('RegionalSettings', 'ShowUntranslatedObjects', $orgShowUntranslatedObjects);
$ini->setVariable('RegionalSettings', 'SiteLanguageList', $orgSiteLanguageList);
// -------------------------------------------------------------------
}