本文整理汇总了PHP中eZContentLanguage::clearPrioritizedLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::clearPrioritizedLanguages方法的具体用法?PHP eZContentLanguage::clearPrioritizedLanguages怎么用?PHP eZContentLanguage::clearPrioritizedLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::clearPrioritizedLanguages方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
$this->xxx = eZContentLanguage::addLanguage('xxx-XX', 'XXXX');
ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('xxx-XX', 'eng-GB'));
eZContentLanguage::clearPrioritizedLanguages();
}
示例2: getPath
function getPath($locale = null, $incomingLanguageList = null)
{
if ($this->Path !== null) {
return $this->Path;
}
// Fetch path 'text' elements of correct parent path
$path = array($this->Text);
$id = (int) $this->Parent;
$db = eZDB::instance();
while ($id != 0) {
$query = "SELECT parent, lang_mask, text FROM ezurlalias_ml WHERE id={$id}";
if ($locale !== null && is_string($locale)) {
// We also want to consider the prioritized language list for the
// destination siteaccess, so that untranslated objects, are not
// disregarded from the URL.
if ($incomingLanguageList !== null) {
eZContentLanguage::setPrioritizedLanguages($incomingLanguageList);
}
$langMask = trim(eZContentLanguage::languagesSQLFilter('ezurlalias_ml', 'lang_mask'));
$query .= " AND ({$langMask})";
}
$rows = $db->arrayQuery($query);
if (count($rows) == 0) {
if ($incomingLanguageList !== null) {
eZContentLanguage::clearPrioritizedLanguages();
}
break;
}
$result = eZURLAliasML::choosePrioritizedRow($rows);
if ($incomingLanguageList !== null) {
eZContentLanguage::clearPrioritizedLanguages();
}
if (!$result) {
$result = $rows[0];
}
$id = (int) $result['parent'];
array_unshift($path, $result['text']);
}
$this->Path = implode('/', $path);
return $this->Path;
}
示例3: 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();
// -------------------------------------------------------------------
}
示例4: subTreeCountByNodeID
static function subTreeCountByNodeID($params = array(), $nodeID)
{
if (!is_numeric($nodeID) and !is_array($nodeID)) {
return null;
}
$language = isset($params['Language']) ? $params['Language'] : false;
if ($language) {
if (!is_array($language)) {
$language = array($language);
}
eZContentLanguage::setPrioritizedLanguages($language);
}
$depth = isset($params['Depth']) && is_numeric($params['Depth']) ? $params['Depth'] : false;
$depthOperator = isset($params['DepthOperator']) ? $params['DepthOperator'] : false;
$pathStringCond = '';
$notEqParentString = '';
// If the node(s) doesn't exist we return null.
if (!eZContentObjectTreeNode::createPathConditionAndNotEqParentSQLStrings($pathStringCond, $notEqParentString, $nodeID, $depth, $depthOperator)) {
return null;
}
$db = eZDB::instance();
$ini = eZINI::instance();
// Check for class filtering
$classCondition = '';
if (isset($params['ClassFilterType']) and isset($params['ClassFilterArray']) and ($params['ClassFilterType'] == 'include' or $params['ClassFilterType'] == 'exclude') and count($params['ClassFilterArray']) > 0) {
$classCondition = ' ';
$i = 0;
$classCount = count($params['ClassFilterArray']);
$classIDArray = array();
foreach ($params['ClassFilterArray'] as $classID) {
$originalClassID = $classID;
// Check if classes are recerenced by identifier
if (is_string($classID) && !is_numeric($classID)) {
$classID = eZContentClass::classIDByIdentifier($classID);
}
if (is_numeric($classID)) {
$classIDArray[] = $classID;
} else {
eZDebugSetting::writeWarning('kernel-content-class', "Invalid class identifier in subTree() classfilterarray, classID : " . $originalClassID);
}
}
if (count($classIDArray) > 0) {
$classCondition .= " ezcontentobject.contentclass_id ";
if ($params['ClassFilterType'] == 'include') {
$classCondition .= " IN ";
} else {
$classCondition .= " NOT IN ";
}
$classIDString = implode(', ', $classIDArray);
$classCondition .= ' ( ' . $classIDString . ' ) AND';
}
}
// Main node check
$mainNodeOnlyCond = '';
if (isset($params['MainNodeOnly']) && $params['MainNodeOnly'] === true) {
$mainNodeOnlyCond = 'ezcontentobject_tree.node_id = ezcontentobject_tree.main_node_id AND';
}
$languageFilter = ' AND ' . eZContentLanguage::languagesSQLFilter('ezcontentobject');
$objectNameLanguageFilter = eZContentLanguage::sqlFilter('ezcontentobject_name', 'ezcontentobject');
if ($language) {
eZContentLanguage::clearPrioritizedLanguages();
}
$objectNameFilter = isset($params['ObjectNameFilter']) ? $params['ObjectNameFilter'] : false;
$attributeFilterParam = isset($params['AttributeFilter']) ? $params['AttributeFilter'] : false;
$sortingInfo = array('sortCount' => 0, 'attributeJoinCount' => 0);
$attributeFilter = eZContentObjectTreeNode::createAttributeFilterSQLStrings($attributeFilterParam, $sortingInfo, $language);
if ($attributeFilter === false) {
return null;
}
$objectNameFilterSQL = eZContentObjectTreeNode::createObjectNameFilterConditionSQLString($objectNameFilter);
$extendedAttributeFilter = eZContentObjectTreeNode::createExtendedAttributeFilterSQLStrings($params['ExtendedAttributeFilter']);
// Determine whether we should show invisible nodes.
$ignoreVisibility = isset($params['IgnoreVisibility']) ? $params['IgnoreVisibility'] : false;
$showInvisibleNodesCond = eZContentObjectTreeNode::createShowInvisibleSQLString(!$ignoreVisibility);
$limitation = isset($params['Limitation']) && is_array($params['Limitation']) ? $params['Limitation'] : false;
$limitationList = eZContentObjectTreeNode::getLimitationList($limitation);
$sqlPermissionChecking = eZContentObjectTreeNode::createPermissionCheckingSQL($limitationList);
$query = "SELECT\n count( DISTINCT ezcontentobject_tree.node_id ) as count\n FROM\n ezcontentobject_tree\n INNER JOIN ezcontentobject ON (ezcontentobject.id = ezcontentobject_tree.contentobject_id)\n INNER JOIN ezcontentclass ON (ezcontentclass.id = ezcontentobject.contentclass_id)\n INNER JOIN ezcontentobject_name ON (\n ezcontentobject_name.contentobject_id = ezcontentobject_tree.contentobject_id AND\n ezcontentobject_name.content_version = ezcontentobject_tree.contentobject_version\n )\n {$attributeFilter['from']}\n {$extendedAttributeFilter['tables']}\n {$sqlPermissionChecking['from']}\n WHERE {$pathStringCond}\n {$extendedAttributeFilter['joins']}\n {$mainNodeOnlyCond}\n {$classCondition}\n {$attributeFilter['where']}\n ezcontentclass.version=0 AND\n {$notEqParentString}\n {$objectNameLanguageFilter}\n {$showInvisibleNodesCond}\n {$sqlPermissionChecking['where']}\n {$objectNameFilterSQL}\n {$languageFilter} ";
$server = count($sqlPermissionChecking['temp_tables']) > 0 ? eZDBInterface::SERVER_SLAVE : false;
$nodeListArray = $db->arrayQuery($query, array(), $server);
// cleanup temp tables
$db->dropTempTableList($sqlPermissionChecking['temp_tables']);
return $nodeListArray[0]['count'];
}
示例5: fetchLatestTags
/**
* Fetches latest modified tags by specified parameters
*
* @static
*
* @param int|bool $parentTagID
* @param int $limit
* @param mixed $language
*
* @return array
*/
public static function fetchLatestTags($parentTagID = false, $limit = 0, $language = false)
{
$parentTagID = (int) $parentTagID;
$filterArray = array();
$filterArray['main_tag_id'] = 0;
$filterArray['id'] = array('!=', $parentTagID);
if ($parentTagID > 0) {
$filterArray['path_string'] = array('like', '%/' . $parentTagID . '/%');
}
if ($language) {
if (!is_array($language)) {
$language = array($language);
}
eZContentLanguage::setPrioritizedLanguages($language);
}
$result = eZTagsObject::fetchList($filterArray, array('offset' => 0, 'limit' => $limit), array('modified' => 'desc'));
if ($language) {
eZContentLanguage::clearPrioritizedLanguages();
}
if (is_array($result) && !empty($result)) {
return array('result' => $result);
}
return array('result' => false);
}
示例6: createAndMultipleFilterSqlParts
/**
* Creates and returns SQL parts used in fetch functions
*
* @param array $params where 'tag_id' is an array of arrays; at least one tag ID from each array must match
*
* @return array
*/
public function createAndMultipleFilterSqlParts($params)
{
$returnArray = array('tables' => '', 'joins' => '', 'columns' => '');
if (!isset($params['tag_id'])) {
return $returnArray;
}
if (is_array($params['tag_id'])) {
$tagIDsArray = $params['tag_id'];
} else {
return $returnArray;
}
$returnArray['tables'] = " INNER JOIN eztags_attribute_link i1 ON (i1.object_id = ezcontentobject.id AND i1.objectattribute_version = ezcontentobject.current_version)\n INNER JOIN eztags i2 ON (i1.keyword_id = i2.id)\n INNER JOIN eztags_keyword i3 ON (i2.id = i3.keyword_id)";
$dbStrings = array();
$db = eZDB::instance();
foreach ($tagIDsArray as $tagIDGroup) {
$tagIDGroup = (array) $tagIDGroup;
if (!isset($params['include_synonyms']) || isset($params['include_synonyms']) && (bool) $params['include_synonyms'] == true) {
/** @var eZTagsObject[] $tags */
$tags = eZTagsObject::fetchList(array('main_tag_id' => array($tagIDGroup)));
if (is_array($tags)) {
foreach ($tags as $tag) {
$tagIDGroup[] = $tag->attribute('id');
}
}
}
$dbStrings[] = "EXISTS (\n SELECT 1\n FROM\n eztags_attribute_link j1,\n ezcontentobject j2\n WHERE " . $db->generateSQLINStatement($tagIDGroup, 'j1.keyword_id', false, true, 'int') . " AND j1.object_id = j2.id\n AND j2.id = ezcontentobject.id\n AND j1.objectattribute_version = j2.current_version\n )";
}
$dbString = implode(" AND ", $dbStrings);
if (isset($params['language'])) {
$language = $params['language'];
if (!is_array($language)) {
$language = array($language);
}
eZContentLanguage::setPrioritizedLanguages($language);
}
$returnArray['joins'] = " {$dbString}\n AND " . eZContentLanguage::languagesSQLFilter('i2') . " AND " . eZContentLanguage::sqlFilter('i3', 'i2') . " AND ";
if (isset($params['language'])) {
eZContentLanguage::clearPrioritizedLanguages();
}
return $returnArray;
}
示例7: destinationUrl
/**
* Returns URL alias for the specified <var>$locale</var>
*
* @param string $url
* @param string $locale
* @return void
*/
public function destinationUrl()
{
$nodeId = $this->origUrl;
$urlAlias = '';
if (!is_numeric($this->origUrl)) {
if (!$this->isUrlPointingToModule($this->origUrl)) {
$this->origUrl = self::addPathPrefixIfNeeded($this->origUrl);
}
$nodeId = eZURLAliasML::fetchNodeIDByPath($this->origUrl);
}
$siteLanguageList = $this->getSiteAccessIni()->variable('RegionalSettings', 'SiteLanguageList');
// set prioritized languages of destination SA, and fetch corresponding (prioritized) URL alias
eZContentLanguage::setPrioritizedLanguages($siteLanguageList);
$destinationElement = eZURLAliasML::fetchByAction('eznode', $nodeId, false, true);
eZContentLanguage::clearPrioritizedLanguages();
if (empty($destinationElement) || !isset($destinationElement[0]) && !$destinationElement[0] instanceof eZURLAliasML) {
// If the return of fetchByAction is empty, it can mean a couple
// of different things:
// Either we are looking at a module, and we should pass the
// original URL on
//
// Or we are looking at URL which does not exist in the
// destination siteaccess, for instance an untranslated object. In
// which case we will point to the root of the site, unless it is
// available as a fallback.
if ($nodeId) {
$urlAlias = $this->origUrl;
// if applicable, remove destination PathPrefix from url
if (!self::removePathPrefixIfNeeded($this->getSiteAccessIni(), $urlAlias)) {
// If destination siteaccess has a PathPrefix but url is not matched,
// also check current SA's prefix, and remove if it matches.
self::removePathPrefixIfNeeded(eZINI::instance('site.ini'), $urlAlias);
}
} else {
if ($this->isUrlPointingToModule($this->origUrl)) {
$urlAlias = $this->origUrl;
}
}
} else {
// Translated object found, forwarding to new URL.
$urlAlias = $destinationElement[0]->getPath($this->destinationLocale, $siteLanguageList);
// if applicable, remove destination PathPrefix from url
self::removePathPrefixIfNeeded($this->getSiteAccessIni(), $urlAlias);
$urlAlias .= $this->userParamString;
}
$this->baseDestinationUrl = rtrim($this->baseDestinationUrl, '/');
$ini = eZINI::instance();
if ($GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI && !($ini->variable('SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess') === "enabled" && $ini->variable('SiteSettings', 'DefaultAccess') == $this->destinationSiteAccess)) {
$finalUrl = $this->baseDestinationUrl . '/' . $this->destinationSiteAccess . '/' . $urlAlias;
} else {
$finalUrl = $this->baseDestinationUrl . '/' . $urlAlias;
}
if ($this->queryString != '') {
$finalUrl .= '?' . $this->queryString;
}
return $finalUrl;
}
示例8: 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);
// -------------------------------------------------------------------
}