本文整理汇总了PHP中SEFTools::removeVariable方法的典型用法代码示例。如果您正苦于以下问题:PHP SEFTools::removeVariable方法的具体用法?PHP SEFTools::removeVariable怎么用?PHP SEFTools::removeVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SEFTools
的用法示例。
在下文中一共展示了SEFTools::removeVariable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _checkRow
/**
* 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;
}
示例2: _checkRow
/**
* 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;
}
示例3: getSefUrl
/**
* 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;
}
示例4: extractVariable
function extractVariable(&$url, $var)
{
$value = SEFTools::getVariable($url, $var);
$url = SEFTools::removeVariable($url, $var);
return $value;
}