本文整理汇总了PHP中SEFTools::getHomeQueries方法的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools::getHomeQueries方法的具体用法?PHP SEFTools::getHomeQueries怎么用?PHP SEFTools::getHomeQueries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEFTools
的用法示例。
在下文中一共展示了SEFTools::getHomeQueries方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _isHomePage
function _isHomePage(&$uri, $altered = false)
{
$home_items = SEFTools::getHomeQueries();
$langs = JLanguageHelper::getLanguages('lang_code');
$config = SEFConfig::getConfig();
$Itemid = $uri->getVar('Itemid');
if (array_key_exists($Itemid, $home_items) && $uri->getPath() == 'index.php') {
if ($config->langEnable) {
if (strlen($uri->getVar('lang', '')) == 0) {
$langTag = $home_items[$Itemid]->language;
if (isset($langs[$langTag])) {
$uri->setVar('lang', $langs[$langTag]->sef);
} else {
// Use current language
$langTag = JFactory::getLanguage()->getTag();
if (isset($langs[$langTag])) {
$uri->setVar('lang', $langs[$langTag]->sef);
}
}
}
}
// Set the link queries if not already there
if (!isset($home_items[$Itemid]->linkQuery)) {
$link = new JURI($home_items[$Itemid]->link);
$home_items[$Itemid]->linkQuery = $link->getQuery(true);
$home_items[$Itemid]->normalizedQuery = null;
// Normalize query if an extension is available
$option = $link->getVar('option');
if (!is_null($option)) {
$extFile = JPATH_ROOT . '/components/com_sef/sef_ext/' . $option . '.php';
if (file_exists($extFile)) {
$class = 'SefExt_' . $option;
if (!class_exists($class)) {
require $extFile;
}
$sef_ext = new $class();
$link->setVar('Itemid', $Itemid);
$sef_ext->beforeCreate($link);
$link->delVar('Itemid');
$link->delVar('lang');
$home_items[$Itemid]->normalizedQuery = $link->getQuery(true);
$sef_ext = null;
}
}
}
// The queries need to match 1:1 (except Itemid and lang(?)), not just the variables present in home item!
$uriQuery = $uri->getQuery(true);
if (array_key_exists('Itemid', $uriQuery)) {
unset($uriQuery['Itemid']);
}
if (array_key_exists('lang', $uriQuery)) {
unset($uriQuery['lang']);
}
// Check base link
$same = $uriQuery == $home_items[$Itemid]->linkQuery;
if (!$same && is_array($home_items[$Itemid]->normalizedQuery)) {
// Check normalized link
$same = $uriQuery == $home_items[$Itemid]->normalizedQuery;
}
return $same;
}
return false;
}
示例2: CreateHomeLinks
function CreateHomeLinks()
{
$db =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$links = array();
// Create array of links for each language
$homes = SEFTools::getHomeQueries(false);
if (!is_array($homes) || count($homes) == 0) {
return;
}
// Three cases
if (!$sefConfig->langEnable) {
// No languages, find home link with All languages set
foreach ($homes as $home) {
if ($home->language == '*') {
$links[''] = array('orig' => $home->link, 'Itemid' => $home->id);
break;
}
}
} else {
if (JPluginHelper::isEnabled('system', 'falangdriver')) {
// FaLang, find home link with All languages set and prepare links with lang= for all languages
foreach ($homes as $home) {
if ($home->language == '*') {
// Prepare link with lang=
$link = JoomSEF::_uriToUrl(new JURI($home->link . '&lang='));
// Loop through languages and prepare links
$langs = JLanguageHelper::getLanguages('sef');
foreach ($langs as $sef => $lang) {
$links[$sef] = array('orig' => str_replace('&lang=', '&lang=' . $sef, $link), 'Itemid' => $home->id);
}
break;
}
}
} else {
// Joomla native multilanguage, for each link with language set prepare a home link
$langs = JLanguageHelper::getLanguages('lang_code');
foreach ($homes as $home) {
if ($home->language != '*') {
// Get SEF code for language
if (isset($langs[$home->language])) {
$sef = $langs[$home->language]->sef;
// Prepare link with lang=
$link = JoomSEF::_uriToUrl(new JURI($home->link . '&lang=' . $sef));
$links[$sef] = array('orig' => $link, 'Itemid' => $home->id);
}
}
}
}
}
// Store the links in database if they don't already exist
foreach ($links as $sef => $link) {
$orig = $db->quote($link['orig']);
$query = "SELECT `id` FROM `#__sefurls` WHERE `origurl` = {$orig} AND (`Itemid` IS NULL OR `Itemid` = '{$link['Itemid']}')";
$db->setQuery($query);
$id = $db->loadResult();
if ($id) {
continue;
}
$query = "INSERT INTO `#__sefurls` (`sefurl`, `origurl`, `Itemid`) VALUES ('{$sef}', {$orig}, '{$link['Itemid']}')";
$db->setQuery($query);
$db->query();
}
}
示例3: _isHomePage
function _isHomePage(&$uri, $altered = false)
{
static $homeQuery, $homeId;
if (!isset($homeQuery)) {
list($homeQuery, $homeId) = SEFTools::getHomeQueries(false);
}
// Copy the old uri
$newuri = clone $uri;
// Normalize URI
if (!$altered) {
SEFTools::normalizeURI($newuri);
}
// Check Itemid variable if present
if (!is_null($newuri->getVar('Itemid'))) {
if ($newuri->getVar('Itemid') != $homeId) {
// Itemid does not match
return false;
} else {
// Itemid matches, remove it from query
$newuri->delVar('Itemid');
}
}
// Remove the lang variable if present
$newuri->delVar('lang');
// Convert uri to string
$link = JoomSEF::_uriToUrl($newuri);
// Compare links
if ($link == $homeQuery) {
return true;
}
return false;
}
示例4: CreateHomeLinks
function CreateHomeLinks()
{
$db =& JFactory::getDBO();
$sefConfig =& SEFConfig::getConfig();
$links = array();
// Create array of links for each language
if (SEFTools::JoomFishInstalled()) {
list($homelink, $itemid) = SEFTools::getHomeQueries(true);
$query = "SELECT `shortcode` FROM `#__languages` WHERE `active` = '1'";
$db->setQuery($query);
$langs = $db->loadResultArray();
foreach ($langs as $lang) {
$link = preg_replace('/([&?]lang=)/', '$1' . $lang, $homelink);
if ($lang == $sefConfig->mainLanguage) {
$lang = '';
}
$links[$lang] = $link;
}
} else {
list($homelink, $itemid) = SEFTools::getHomeQueries(false);
$links[''] = $homelink;
}
// Store the links in database if they don't already exist
foreach ($links as $sef => $orig) {
$orig = $db->quote($orig);
$query = "SELECT `id`, `trashed` FROM `#__sefurls` WHERE `origurl` = {$orig}";
$db->setQuery($query);
$row = $db->loadObject();
if (!is_null($row) && !(bool) $row->trashed) {
continue;
}
if (is_null($row)) {
$query = "INSERT INTO `#__sefurls` (`sefurl`, `origurl`, `Itemid`) VALUES ('{$sef}', {$orig}, '{$itemid}')";
} else {
// Trashed
$query = "UPDATE `#__sefurls` SET `sefurl` = '{$sef}', `origurl` = {$orig}, `Itemid` = '{$itemid}', `trashed` = '0' WHERE `id` = '{$row->id}'";
}
$db->setQuery($query);
$db->query();
}
}