function create(&$uri) { $vars = $uri->getQuery(true); extract($vars); $this->params =& SEFTools::getExtParams('com_search'); $newUri = $uri; if (!(isset($task) ? @$task : null)) { $title[] = JoomSEF::_getMenuTitle($option, isset($task) ? $task : null); if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') { $title[] = $searchword; } if (count($title) > 0) { $this->_createNonSefVars($uri); if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') { // Generate meta tags $desc = array(); if (isset($searchword)) { $desc[] = $searchword; } if (isset($searchphrase)) { $desc[] = $searchphrase; } $this->metadesc = implode(', ', $desc); unset($desc); } $metatags = $this->getMetaTags(); $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], $this->nonSefVars, null, $metatags); } } return $newUri; }
function getSefUrlFromDatabase(&$uri) { $db =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); // David (284): ignore Itemid if set to $where = ''; // Get the extension's ignoreSource parameter $option = $uri->getVar('option'); if (!is_null($option)) { $params = SEFTools::getExtParams($option); $extIgnore = $params->get('ignoreSource', 2); } else { $extIgnore = 2; } $ignoreSource = $extIgnore == 2 ? $sefConfig->ignoreSource : $extIgnore; $Itemid = $uri->getVar('Itemid'); // If Itemid is set as ignored for the component, set ignoreSource to 1 if (!is_null($Itemid) && !is_null($option)) { if (SEFTools::isItemidIgnored($option, $Itemid)) { $ignoreSource = 1; } } if (!$ignoreSource && !is_null($Itemid)) { $where = " AND (`Itemid` = '" . $Itemid . "' OR `Itemid` IS NULL)"; } $origurl = $db->Quote(html_entity_decode(urldecode(JoomSEF::_uriToUrl($uri, 'Itemid')))); $query = "SELECT * FROM `#__sefurls` WHERE `origurl` = {$origurl}" . $where . " AND (`trashed` = '0') LIMIT 2"; $db->setQuery($query); $sefurls = $db->loadObjectList('Itemid'); if (!$ignoreSource && !is_null($Itemid)) { if (isset($sefurls[$Itemid])) { $result = $sefurls[$Itemid]; } else { if (isset($sefurls[''])) { // We've found one of the ignored Itemids, update it with the current and return $result = $sefurls['']; $result->Itemid = $Itemid; $query = "UPDATE `#__sefurls` SET `Itemid` = '{$Itemid}' WHERE `id` = '{$result->id}' LIMIT 1"; $db->setQuery($query); $db->query(); } else { $result = reset($sefurls); } } } else { $result = reset($sefurls); } return is_object($result) ? $result : false; /* // removed - was causing problems $sefurls = $db->loadObjectList('Itemid'); // test if current Itemid record exists, if YES, use it, if NO, use first found if (isset($sefurls[$Itemid])) $active = $sefurls[$Itemid]; elseif ($ignoreSource) $active = reset($sefurls); //if (isset($active)) $result = $active->sefurl; return isset($active) ? $active : false; */ }
function getSefUrlFromDatabase(&$uri) { $db =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); // David (284): ignore Itemid if set to $where = ''; // Get the extension's ignoreSource parameter $option = $uri->getVar('option'); if (!is_null($option)) { $params = SEFTools::getExtParams($option); $extIgnore = $params->get('ignoreSource', 2); } else { $extIgnore = 2; } $ignoreSource = $extIgnore == 2 ? $sefConfig->ignoreSource : $extIgnore; $Itemid = $uri->getVar('Itemid'); // If Itemid is set as ignored for the component, set ignoreSource to 1 if (!is_null($Itemid) && !is_null($option)) { if (SEFTools::isItemidIgnored($option, $Itemid)) { $ignoreSource = 1; } } if (!$ignoreSource && !is_null($Itemid)) { $where = " AND (`Itemid` = '" . $Itemid . "' OR `Itemid` IS NULL)"; } $origurl = addslashes(html_entity_decode(urldecode(JoomSEF::_uriToUrl($uri, 'Itemid')))); $query = "SELECT * FROM `#__sefurls` WHERE `origurl` = '" . $origurl . "'" . $where . ' LIMIT 2'; $this->_db->setQuery($query); //echo "<b>".str_replace('#__','jos_',$query)."</b><br><br>"; $sefurls = $this->_db->loadObjectList('Itemid'); if (!is_array($sefurls)) { return false; } if (!$ignoreSource && !is_null($Itemid)) { if (isset($sefurls[$Itemid])) { $result = $sefurls[$Itemid]; } else { if (isset($sefurls[''])) { // We've found one of the ignored Itemids, update it with the current and return $result = $sefurls['']; $result->Itemid = $Itemid; $query = "UPDATE `#__sefurls` SET `Itemid` = '{$Itemid}' WHERE `id` = '{$result->id}' LIMIT 1"; $this->_db->setQuery($query); $this->_db->query(); } else { $result = reset($sefurls); } } } else { $result = reset($sefurls); } return is_object($result) ? $result : false; }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $database =& JFactory::getDBO(); $this->params =& SEFTools::getExtParams('com_weblinks'); // JF translate extension. $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; $vars = $uri->getQuery(true); extract($vars); $title = array(); $title[] = JoomSEF::_getMenuTitle($option, @$this_task); if (@$view == 'category') { $title[] = $this->getCategoryTitle($id, SEFTools::UseAlias($this->params, 'category_alias')); } elseif (empty($this_task) && @$view == 'weblink') { if (isset($catid)) { if ($this->params->get('show_category', '1')) { $title[] = $this->getCategoryTitle($catid, SEFTools::UseAlias($this->params, 'category_alias')); } } if (!empty($id)) { $field = 'title'; if (SEFTools::UseAlias($this->params, 'weblink_alias')) { $field = 'alias'; } $id = intval($id); $database->setQuery("SELECT `{$field}` AS `title` {$jfTranslate} FROM `#__weblinks` WHERE `id` = '{$id}'"); $row = $database->loadObject(); if (is_null($row)) { JoomSefLogger::Log("Weblink with ID {$id} could not be found.", $this, 'com_weblinks'); } elseif (!empty($row->title)) { $name = $row->title; if ($this->params->get('weblink_id', '0')) { $name = $id . '-' . $name; } $title[] = $name; } } else { $title[] = JText::_('Submit'); } } if (isset($task) && $task == 'new') { $title[] = 'new' . $sefConfig->suffix; } $newUri = $uri; if (count($title) > 0) { // Generate meta tags $metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$vars['lang'], null, null, $metatags, $priority, false, null, $sitemap); } return $newUri; }
function create(&$uri) { $vars = $uri->getQuery(true); extract($vars); // Don't SEF opensearch links if (isset($format) && $format == 'opensearch') { return $uri; } $this->params =& SEFTools::getExtParams('com_search'); $newUri = $uri; if (!(isset($task) ? @$task : null)) { $title[] = JoomSEF::_getMenuTitleLang($option, $lang, @$Itemid); if (isset($searchword) && $this->params->get('nonsefphrase', '1') != '1') { $title[] = $searchword; } if (isset($view) && ($view != 'search' || $this->params->get('add_search', '0') == '1')) { $title[] = $view; } if (isset($format)) { $title[] = $format; } $this->_createNonSefVars($uri); if (!isset($searchword) || $this->params->get('nonsefphrase', '1') != '1') { // Generate meta tags $desc = array(); if (isset($searchword)) { $desc[] = $searchword; } if (isset($searchphrase)) { $desc[] = $searchphrase; } $this->metadesc = implode(', ', $desc); unset($desc); } $metatags = $this->getMetaTags(); $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, $this->nonSefVars, null, $metatags, null, true); } return $newUri; }
function create(&$uri) { $sefConfig =& SEFConfig::getConfig(); $this->params =& SEFTools::getExtParams('com_banners'); $vars = $uri->getQuery(true); extract($vars); $title[] = JoomSEF::_getMenuTitleLang(@$option, @$task, @$Itemid); switch (@$task) { case 'click': $title[] = $this->GetBannerName($id); unset($task); break; } $newUri = $uri; if (isset($this->lang)) { $lang = $this->lang; } if (count($title) > 0) { $newUri = JoomSEF::_sefGetLocation($uri, $title, @$task, null, null, @$lang); } return $newUri; }
function create(&$uri) { // Extract variables $vars = $uri->getQuery(true); extract($vars); $title = array(); $this->params = SEFTools::getExtParams('com_contact'); $title[] = JoomSEF::_getMenuTitle(@$option, @$task, @$Itemid); if (isset($view)) { switch ($view) { case 'contact': $title = array_merge($title, $this->getContactName($id)); unset($view); break; case 'category': if (isset($catid)) { $title[] = $this->getCategoryTitle($catid); } unset($view); break; } } if (!empty($format) && $format == 'feed') { if (!empty($type)) { $title[] = $type; } } $newUri = $uri; if (count($title) > 0) { // Generate meta tags $metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); $newUri = JoomSEF::_sefGetLocation($uri, $title, @$view, null, null, @$lang, null, null, $metatags, $priority, false, null, $sitemap); } return $newUri; }
/** * Checks the found row * */ function _checkRow(&$row, $ignoreSource, $Itemid, $url, &$metadata, $temploc, $priority, $option, $host, $sitemapParams) { $realloc = null; $db =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); $numberDuplicates = $sefConfig->numberDuplicates; if (!empty($option)) { $params =& SEFTools::getExtParams($option); $extDuplicates = $params->get('numberDuplicates', '2'); if ($extDuplicates != '2') { $numberDuplicates = $extDuplicates; } } if ($row != false && !is_null($row)) { if ($ignoreSource || !$ignoreSource && (empty($Itemid) || $row->Itemid == $Itemid)) { // ... check that it matches original URL if ($row->origurl == $url) { // found the matching object // it probably should have been found sooner // but is checked again here just for CYA purposes // and to end the loop $realloc = $row->sefurl; } else { if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) { // check if the urls differ only by lang variable if (SEFTools::removeVariable($row->origurl, 'lang') == SEFTools::removeVariable($url, 'lang')) { $db->setQuery("UPDATE `#__sefurls` SET `origurl` = " . $db->Quote(SEFTools::removeVariable($row->origurl, 'lang')) . " WHERE `id` = '{$row->id}' LIMIT 1"); // if error occured. if (!$db->query()) { $msg = JText::_('Could not update SEF URL in database'); if (JDEBUG) { $msg .= ': ' . $db->getErrorMsg(); } JError::raiseError('JoomSEF Error', $msg); } $realloc = $row->sefurl; } } } } // The found URL is not the same if (!$numberDuplicates) { // But duplicates management is turned on // so we can save the same SEF URL for different non-SEF URL JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, false, $host, $sitemapParams); $realloc = $temploc; } } else { // Save URL in the database JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, true, $host, $sitemapParams); $realloc = $temploc; } return $realloc; }
function _getPackageFromServer($extension) { // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { JError::raiseWarning(100, JText::_('WARNINSTALLZLIB')); return false; } // build the appropriate paths $sefConfig =& SEFConfig::getConfig(); $config =& JFactory::getConfig(); if (empty($extension)) { $tmp_dest = $config->getValue('config.tmp_path') . DS . 'joomsef.zip'; } else { $tmp_dest = $config->getValue('config.tmp_path') . DS . $extension . '.zip'; } // Validate the upgrade on server $data = array(); $data['username'] = $sefConfig->artioUserName; $data['password'] = $sefConfig->artioPassword; if (empty($extension)) { $data['download_id'] = $sefConfig->artioDownloadId; $data['file'] = 'com_joomsef'; } else { $params =& SEFTools::getExtParams($extension); $data['download_id'] = $params->get('downloadId', ''); $data['file'] = 'ext_joomsef3_' . substr($extension, 4); } $uri = parse_url(JURI::root()); $url = $uri['host'] . $uri['path']; $url = trim($url, '/'); $data['site'] = $url; $data['ip'] = $_SERVER['SERVER_ADDR']; $lang =& JFactory::getLanguage(); $data['lang'] = $lang->getTag(); $data['cat'] = 'joomsef3'; // Get the server response $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data); // Check the response if ($response === false || $response->code != 200) { JError::raiseWarning(100, JText::_('Connection to server could not be established.')); return false; } // Response OK, check what we got if (strpos($response->header, 'Content-Type: application/zip') === false) { JError::raiseWarning(100, $response->content); return false; } // Seems we got the ZIP installation package, let's save it to disk if (!JFile::write($tmp_dest, $response->content)) { JError::raiseWarning(100, JText::_('Unable to save installation file in temp directory.')); return false; } // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest); // Delete the package file JFile::delete($tmp_dest); return $package; }
/** * Checks, whether the given Itemid is ignored for the given component * * @param string $option * @param string $Itemid * @return bool */ function isItemidIgnored($option, $Itemid) { $params =& SEFTools::getExtParams($option); $ignoredIds = trim($params->get('ignoreItemids', '')); if (empty($ignoredIds)) { return false; } $ids = array_map('trim', explode(',', $ignoredIds)); if (in_array($Itemid, $ids)) { return true; } return false; }
function _getActiveHandler($option) { $params =& SEFTools::getExtParams($option); $handler = $params->get('handling', '0'); $ret = new stdClass(); switch ($handler) { case '0': $compExt = JFile::exists(JPATH_ROOT . '/components/' . $option . '/router.php'); $ownExt = JFile::exists(JPATH_ROOT . '/components/com_sef/sef_ext/' . $option . '.php'); if ($compExt && !$ownExt) { $ret->text = JText::_('COM_SEF_COMPONENTS_ROUTER'); $ret->code = _COM_SEF_HANDLER_ROUTER; $ret->color = 'black'; } else { if ($ownExt) { $ret->text = JText::_('COM_SEF_JOOMSEF_EXTENSION'); $ret->code = _COM_SEF_HANDLER_EXTENSION; $ret->color = 'green'; } else { $ret->text = JText::_('COM_SEF_JOOMSEF_DEFAULT_HANDLER'); $ret->code = _COM_SEF_HANDLER_DEFAULT; $ret->color = 'green'; } } break; case '1': $ret->text = JText::_('COM_SEF_DEFAULT_JOOMLA_ROUTER'); $ret->code = _COM_SEF_HANDLER_JOOMLA; $ret->color = 'orange'; break; case '2': $ret->text = JText::_('COM_SEF_NOT_USING_SEF'); $ret->code = _COM_SEF_HANDLER_NONE; $ret->color = 'red'; break; case '3': $ret->text = JText::_('COM_SEF_JOOMSEF_BASIC_REWRITING'); $ret->code = _COM_SEF_HANDLER_BASIC; $ret->color = 'green'; break; } return $ret; }
function create(&$uri) { $this->metadesc = null; // Extract variables $vars = $uri->getQuery(true); extract($vars); $this->params = SEFTools::getExtParams('com_contact'); $title[] = JoomSEF::_getMenuTitleLang(@$option, $this->lang, @$Itemid); if (isset($view)) { switch ($view) { case 'categories': case 'featured': break; case 'category': $catInfo = $this->getCategoryInfo($id); if ($catInfo === false) { JoomSefLogger::Log("Category with ID {$id} could not be found.", $this, 'com_contact'); } if (is_array($catInfo->path)) { $title = array_merge($title, $catInfo->path); } break; case 'contact': $title = array_merge($title, $this->getContactName($id)); break; } } if (!empty($format)) { if ($format == 'feed' && !empty($type)) { $title[] = $type; } elseif ($format == 'vcf') { $title[] = 'vCard'; } } $newUri = $uri; if (count($title) > 0) { // Generate meta tags $this->metatags = $this->getMetaTags(); $priority = $this->getPriority($uri); $sitemap = $this->getSitemapParams($uri); if (isset($this->lang)) { $lang = $this->lang; } $newUri = JoomSEF::_sefGetLocation($uri, $title, null, null, null, @$lang, null, null, $this->metatags, $priority, false, null, $sitemap); } return $newUri; }
function _getPackageFromServer() { $extension = trim(JRequest::getString('extension')); // Make sure we have an extension selected if (empty($extension)) { JError::raiseWarning(100, JText::_('COM_SEF_NO_EXTENSION_SELECTED')); return false; } // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { JError::raiseWarning(100, JText::_('COM_SEF_WARNINSTALLZLIB')); return false; } // build the appropriate paths $sefConfig =& SEFConfig::getConfig(); $config =& JFactory::getConfig(); $tmp_dest = $config->get('tmp_path') . '/' . $extension . '.zip'; // Validate the upgrade on server $data = array(); $data['username'] = $sefConfig->artioUserName; $data['password'] = $sefConfig->artioPassword; $params =& SEFTools::getExtParams($extension); $data['download_id'] = $params->get('downloadId', ''); $data['file'] = 'ext_joomsef4_' . substr($extension, 4); $uri = parse_url(JURI::root()); $url = $uri['host'] . $uri['path']; $url = trim($url, '/'); $data['site'] = $url; $data['ip'] = $_SERVER['SERVER_ADDR']; $lang =& JFactory::getLanguage(); $data['lang'] = $lang->getTag(); $data['cat'] = 'joomsef4'; // Get the server response $response = SEFTools::PostRequest($sefConfig->serverAutoUpgrade, JURI::root(), $data); // Check the response if ($response === false || $response->code != 200) { JError::raiseWarning(100, JText::_('COM_SEF_ERROR_SERVER_CONNECTION')); return false; } // Response OK, check what we got if (strpos($response->header, 'Content-Type: application/zip') === false) { JError::raiseWarning(100, $response->content); return false; } // Seems we got the ZIP installation package, let's save it to disk if (!JFile::write($tmp_dest, $response->content)) { JError::raiseWarning(100, JText::_('COM_SEF_ERROR_TEMP_DIRECTORY')); return false; } // Unpack the downloaded package file $package = JInstallerHelper::unpack($tmp_dest); // Delete the package file JFile::delete($tmp_dest); return $package; }
function _getActiveHandler($option) { $params =& SEFTools::getExtParams($option); $handler = $params->get('handling', '0'); $ret = new stdClass(); switch ($handler) { case '0': $compExt = JFile::exists(JPATH_ROOT . DS . 'components' . DS . $option . DS . 'router.php'); $ownExt = JFile::exists(JPATH_ROOT . DS . 'components' . DS . 'com_sef' . DS . 'sef_ext' . DS . $option . '.php'); if ($compExt && !$ownExt) { $ret->text = JText::_('Component\'s router'); $ret->code = _COM_SEF_HANDLER_ROUTER; $ret->color = 'black'; } else { if ($ownExt) { $ret->text = JText::_('JoomSEF extension'); $ret->code = _COM_SEF_HANDLER_EXTENSION; $ret->color = 'green'; } else { $ret->text = JText::_('JoomSEF default handler'); $ret->code = _COM_SEF_HANDLER_DEFAULT; $ret->color = 'green'; } } break; case '1': $ret->text = JText::_('Default Joomla! router'); $ret->code = _COM_SEF_HANDLER_JOOMLA; $ret->color = 'orange'; break; case '2': $ret->text = JText::_('Not using SEF'); $ret->code = _COM_SEF_HANDLER_NONE; $ret->color = 'red'; break; case '3': $ret->text = JText::_('JoomSEF basic rewriting'); $ret->code = _COM_SEF_HANDLER_BASIC; $ret->color = 'green'; break; } return $ret; }
/** * Tries to find a SEF URL corresponding with given nonSEF URL * * @param string $nonsef * @param string $Itemid * @return string */ function getSefUrl($nonsef, $Itemid = null) { $sefConfig =& SEFConfig::getConfig(); // Load the cache if needed if (!$this->cacheLoaded) { $this->LoadCache(); } // Check if the cache was loaded successfully if (!$this->cacheLoaded) { return false; } // Check if non-sef url doesn't contain Itemid $vars = array(); parse_str(str_replace('index.php?', '', $nonsef), $vars); if (is_null($Itemid) && strpos($nonsef, 'Itemid=')) { if (isset($vars['Itemid'])) { $Itemid = $vars['Itemid']; } $nonsef = SEFTools::removeVariable($nonsef, 'Itemid'); } // Get the ignoreSource parameter if (isset($vars['option'])) { $params = SEFTools::getExtParams($vars['option']); $extIgnore = $params->get('ignoreSource', 2); } else { $extIgnore = 2; } $ignoreSource = $extIgnore == 2 ? $sefConfig->ignoreSource : $extIgnore; // If Itemid is set as ignored for the component, set ignoreSource to 1 if (!is_null($Itemid) && isset($vars['option'])) { if (SEFTools::isItemidIgnored($vars['option'], $Itemid)) { $ignoreSource = 1; } } // Get all sef urls matching non-sef url if (isset($this->cache[$nonsef]) && is_array($this->cache[$nonsef]) && count($this->cache[$nonsef]) > 0) { // Search with Itemid if set to and Itemid set if (!$ignoreSource && !is_null($Itemid)) { $nullId = null; for ($i = 0, $n = count($this->cache[$nonsef]); $i < $n; $i++) { $row = $this->cache[$nonsef][$i]; if (isset($row->Itemid) && $row->Itemid == $Itemid) { return $row; } if (empty($row->Itemid)) { $nullId = $i; } } // Not found with correct itemid, try to find without itemid if (!is_null($nullId)) { // Update Itemid in cache $this->cache[$nonsef][$i]->Itemid = $Itemid; $row = $this->cache[$nonsef][$i]; // Save the cache $this->saveCache(); // Return found row return $row; } } else { return $this->cache[$nonsef][0]; } } // URL does not exist in the cache return false; }
/** * Checks the found row * */ function _checkRow(&$row, $ignoreSource, $Itemid, $url, &$metadata, $temploc, $priority, $option, $check = false, $host, $sitemapParams = null) { $realloc = null; $db =& JFactory::getDBO(); $sefConfig =& SEFConfig::getConfig(); $numberDuplicates = $sefConfig->numberDuplicates; if (!empty($option)) { $params =& SEFTools::getExtParams($option); $extDuplicates = $params->get('numberDuplicates', '2'); if ($extDuplicates != '2') { $numberDuplicates = $extDuplicates; } } if ($row != false && !is_null($row)) { if ($ignoreSource || !$ignoreSource && (empty($Itemid) || $row->Itemid == $Itemid)) { // ... check that it matches original URL if ($row->origurl == $url) { // found the matching object // it probably should have been found sooner // but is checked again here just for CYA purposes // and to end the loop $realloc = $row->sefurl; } else { if ($sefConfig->langPlacement == _COM_SEF_LANG_DOMAIN) { // check if the urls differ only by lang variable if (SEFTools::removeVariable($row->origurl, 'lang') == SEFTools::removeVariable($url, 'lang')) { $db->setQuery("UPDATE `#__sefurls` SET `origurl` = '" . SEFTools::removeVariable($row->origurl, 'lang') . "' WHERE `id` = '" . $row->id . "' LIMIT 1"); // if error occured. if (!$db->query()) { JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_SEF_URL_UPDATE') . $db->getErrorMsg()); } $realloc = $row->sefurl; } } } } // The found URL is not the same if (!$numberDuplicates) { // But duplicates management is turned on // so we can save the same SEF URL for different non-SEF URL if (!$check) { JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, $host, $sitemapParams); } $realloc = $temploc; } } else { // first, try to search among 404s $query = "SELECT `id` FROM `#__sefurls` WHERE `sefurl` = '{$temploc}' AND `origurl` = ''"; $db->setQuery($query); $id = $db->loadResult(); // if 404 exists, rewrite it to the new URL if (!is_null($id)) { $sqlId = !empty($Itemid) ? ", `Itemid` = '{$Itemid}'" : ''; $query = "UPDATE `#__sefurls` SET `origurl` = " . $db->quote(html_entity_decode(urldecode($url))) . "{$sqlId}, `priority` = '{$priority}' WHERE `id` = '{$id}' LIMIT 1"; $db->setQuery($query); // if error occured if (!$db->query()) { JError::raiseError('JoomSEF Error', JText::_('COM_SEF_ERROR_SEF_URL_UPDATE') . $db->getErrorMsg()); } } else { if (!$check) { JoomSEF::_saveNewURL($Itemid, $metadata, $priority, $temploc, $url, $host, $sitemapParams); } } $realloc = $temploc; } return $realloc; }
function create(&$uri) { $vars = $uri->getQuery(true); extract($vars); $title = array(); // Don't SEF if no variables if (self::$is20 && is_null($uri->getVar('view'))) { return $uri; } // JF translate extension. $sefConfig =& SEFConfig::getConfig(); $database =& JFactory::getDBO(); $jfTranslate = $sefConfig->translateNames ? ', `id`' : ''; // load params $this->params = SEFTools::getExtParams('com_kunena'); $catRewrite = true; $msgRewrite = true; $usrRewrite = true; /*if (isset($view) && ($view == 'category')) { $msgRewrite = false; }*/ if ($msgRewrite || $catRewrite) { if ($catRewrite && !empty($catid)) { $categories = $this->GetCategories($catid); if (is_null($categories)) { // Error, don't SEF return $uri; } } if (isset($id)) { $msgID = $id; } elseif (isset($msg_id)) { $msgID = $msg_id; } elseif (isset($replyto)) { $msgID = $replyto; } elseif (isset($pid)) { $msgID = $pid; } else { $msgID = null; } if ($msgRewrite && !empty($msgID)) { if (isset($func) && $func == 'announcement') { $msgTitle = $this->GetAnnouncementTitle($msgID); } else { if (self::$is20) { $msgTitle = $this->GetTopicTitle($msgID); } else { $msgTitle = $this->GetMessageTitle($msgID); } } if (is_null($msgTitle)) { // Error, don't SEF return $uri; } } } // Set non-sef vars according to settings $this->_createNonSefVars($uri); // this needs to follow previous that use do if ($this->params->get('doExclude', true)) { unset($do); } // get user ID if ($usrRewrite && isset($userid)) { if ($this->params->get('userIdInsteadOfLogin', false)) { $usrTitle = 'user-' . $userid; } else { $query = "SELECT `username` FROM `#__users` WHERE `id` = {$userid}"; $database->setQuery($query); $usrTitle = $database->loadResult(); } } // use view if func not set if (!isset($func) && isset($view)) { $func = $view; unset($view); } // if task is not set, use do if (empty($task) && isset($func) && $func == 'post' && isset($do)) { $task = $do; unset($func); unset($do); } if (empty($task) && isset($func)) { $task = $func; unset($func); } // First subdir if (!empty($option) && !self::$is16) { $title[] = JoomSEF::_getMenuTitle($option, @$task, @$Itemid); } elseif (self::$is16) { $menuTitle = $this->getDefaultForumMenuTitle(); if (!is_null($menuTitle)) { $title[] = $menuTitle; } } // Category if (isset($categories) && !empty($categories)) { $addCat = $this->params->get('categories', '2'); if ($addCat == '2') { $title = array_merge($title, $categories); } else { if ($addCat == '1' || empty($msgID)) { $title[] = $categories[count($categories) - 1]; } } } // Announcement if (@$task == 'announcement') { $title[] = JText::_('Announcements'); } // Topic if (isset($msgTitle) && !empty($msgTitle) && isset($task) && $task != 'showcat') { //$title[] = (!isset($do) && !isset($func)) ? $msgTitle.$sefConfig->suffix : $msgTitle; $title[] = $msgTitle; } if (isset($task) && in_array($task, array('search', 'advsearch'))) { if ($task == 'advsearch') { $title[] = JText::_('Advanced Search'); } else { $title[] = JText::_($task); } if (isset($limitstart)) { unset($limitstart); } if (isset($limit)) { unset($limit); } unset($task); } if (isset($task) && $task == 'topics') { $title[] = $task; unset($task); } // Cleanout some views if (in_array(@$view, array('entrypage', 'category', 'topic', 'home'))) { unset($view); } // Cleanout some funcs if (in_array(@$func, array('showcat', 'view', 'announcement', 'entrypage', 'rules', 'category', 'topic', 'home'))) { unset($func); } // Cleanout some tasks if (in_array(@$task, array('showcat', 'view', 'announcement', 'entrypage', 'category', 'topic', 'home'))) { unset($task); } // View if (isset($view)) { $title[] = $view; } // JSON if (isset($task) && $task == 'json') { $title[] = $task; unset($task); } // Action if (isset($action)) { $title[] = $action; unset($action); } // User if (@$task == 'user') { if (empty($Itemid)) { $title[] = 'user'; } else { $app = JFactory::getApplication(); $menu = $app->getMenu('site'); $item = $menu->getItem($Itemid); if (!is_object($item) || !isset($item->query['view']) || $item->query['view'] != 'user') { $title[] = 'user'; } else { $title[] = 'profile'; } } $task = null; } if (isset($usrTitle) && !empty($usrTitle)) { if (@$task == 'fbprofile') { $title[] = 'users'; $task = null; } elseif (@$task == 'profile') { $title[] = 'profile'; $task = null; } elseif (@$task == 'showprf') { $task = null; } $title[] = $usrTitle; } // Misc if (@$task == 'misc' && !empty($Itemid)) { // Use correct menu title $title[] = JoomSEF::_getMenuTitle(null, null, $Itemid); $task = null; } // Layout if (isset($layout)) { switch ($layout) { case 'reply': if (isset($quote) && $quote) { $layout = 'quote'; } $title[] = $layout; break; case 'list': if ($uri->getVar('view') == 'category') { $layout = 'index'; $title[] = $layout; } else { if ($uri->getVar('view') == 'user') { $title[] = $layout; } } break; case 'default': // Don't add break; default: $title[] = $layout; break; } unset($layout); } // Gallery if (isset($gallery)) { $title[] = $gallery; } // Func and do if (isset($do) || isset($func)) { if (isset($func)) { if ($func == 'search') { $oper[] = 'do'; } $oper[] = $func; } if (isset($do)) { $oper[] = $do; } $title[] = join('-', $oper) . $sefConfig->suffix; } // Fix some task texts if (isset($task)) { $task = str_replace(array('listcat', 'userlist'), array('categories', 'users'), $task); } // Mode if (isset($mode) && $mode == 'noreplies') { $title[] = $mode; } // Feeds if (isset($format)) { switch ($format) { case 'feed': if (!isset($type)) { $type = 'rss'; } $title[] = $type; break; case 'raw': $title[] = $format; break; } } // Page number if (isset($limitstart)) { // Limit should be set due to beforeCreate function, but to be sure if (!isset($limit)) { if (in_array($uri->getVar('view'), array('category', 'topics')) && isset(self::$kunenaConfig->threads_per_page)) { $limit = self::$kunenaConfig->threads_per_page; } elseif ($uri->getVar('view') == 'user') { $limit = self::$kunenaConfig->userlist_rows; } else { $limit = self::$kunenaConfig->messages_per_page; } } $pageNum = intval($limitstart / $limit) + 1; $pagetext = strval($pageNum); if ($cnfPageText = $sefConfig->getPageText()) { $pagetext = str_replace('%s', $pageNum, $cnfPageText); } $title = array_merge($title, explode('/', $pagetext)); //$title[] = $pagetext; } // Selection if (!empty($sel)) { if (isset($task) && $task == 'latest') { $num = $sel >= 24 ? $sel / 24 : $sel; $title[] = $task . '-' . $num; unset($task); } else { $title[] = $sel; } } if (isset($page) && $page > 1) { $pagetext = strval($page); if ($cnfPageText = $sefConfig->getPageText()) { $pagetext = str_replace('%s', $page, $cnfPageText); } $title[] = $pagetext; } // Task if (isset($task)) { $title[] = $task; unset($task); } $newUri = $uri; if (count($title) > 0) { $newUri = JoomSEF::_sefGetLocation($uri, $title, null, @$limit, @$limitstart, @$lang, $this->nonSefVars, $this->ignoreVars, null, null, true); } return $newUri; }