/** * 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; }
/** * 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; }