Update url.class.php
This commit is contained in:
parent
bcd9f024f8
commit
e96cfebb20
|
@ -42,28 +42,51 @@ class Url
|
||||||
unset($filters['admin']);
|
unset($filters['admin']);
|
||||||
uasort($filters, array($this, 'sortByLength'));
|
uasort($filters, array($this, 'sortByLength'));
|
||||||
$this->filters = $adminFilter + $filters;
|
$this->filters = $adminFilter + $filters;
|
||||||
|
$this->filters = $filters;
|
||||||
|
|
||||||
foreach ($this->filters as $filterName=>$filterURI) {
|
foreach ($this->filters as $filterName=>$filterURI) {
|
||||||
// $filterName = 'category'
|
// $filterName = 'category'
|
||||||
// $filterURI = '/category/'
|
// $filterURI = '/category/'
|
||||||
|
// $filterURIwoSlash = '/category'
|
||||||
|
$filterURIwoSlash = rtrim($filterURI, '/');
|
||||||
|
|
||||||
|
// $filterFull = '/base_url/category/'
|
||||||
$filterFull = ltrim($filterURI, '/');
|
$filterFull = ltrim($filterURI, '/');
|
||||||
$filterFull = HTML_PATH_ROOT.$filterFull;
|
$filterFull = HTML_PATH_ROOT.$filterFull;
|
||||||
$filterLenght = mb_strlen($filterFull, CHARSET);
|
$filterFullLenght = mb_strlen($filterFull, CHARSET);
|
||||||
|
|
||||||
if (mb_substr($this->uri, 0, $filterLenght, CHARSET)==$filterURI) {
|
// $filterFullwoSlash = '/base_url/category'
|
||||||
$this->slug = mb_substr($this->uri, $filterLenght+1);
|
$filterFullwoSlash = ltrim($filterURIwoSlash, '/');
|
||||||
|
$filterFullwoSlash = HTML_PATH_ROOT.$filterURIwoSlash;
|
||||||
|
|
||||||
|
$subString = mb_substr($this->uri, 0, $filterFullLenght, CHARSET);
|
||||||
|
|
||||||
|
// Check coincidence without the last slash at the end, this case is notfound
|
||||||
|
if ($subString==$filterURIwoSlash) {
|
||||||
|
$this->setNotFound();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check coincidence with complete filterURI
|
||||||
|
if ($subString==$filterURI) {
|
||||||
|
$this->slug = mb_substr($this->uri, $filterFullLenght+1);
|
||||||
$this->whereAmI = $filterName;
|
$this->whereAmI = $filterName;
|
||||||
$this->activeFilter = $filterURI;
|
$this->activeFilter = $filterURI;
|
||||||
|
|
||||||
if (empty($this->slug) && (($filterName=='blog') || ($filterURI=='/')) ) {
|
if (empty($this->slug) && (($filterName=='blog') || ($filterURI=='/')) ) {
|
||||||
$this->whereAmI = 'home';
|
$this->whereAmI = 'home';
|
||||||
|
} elseif (!empty($this->slug) && ($filterURI=='/')) {
|
||||||
|
$this->whereAmI = 'page';
|
||||||
|
} elseif (!empty($this->slug) && ($filterName=='blog')) {
|
||||||
|
$this->setNotFound();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
$this->setNotFound();
|
$this->setNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,4 +185,4 @@ class Url
|
||||||
return strlen($b)-strlen($a);
|
return strlen($b)-strlen($a);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue