41 $oCache = $this->oDb->getDbCacheObject();
42 $this->aLinks =
$oCache->getData($this->oDb->genDbCacheKey(
'sys_permalinks'));
43 if (
null === $this->aLinks) {
44 if (!$this->
cache()) {
45 $this->aLinks = array();
52 if (!isset(
$GLOBALS[
'chWsbClasses'][
'ChWsbPermalinks'])) {
56 return $GLOBALS[
'chWsbClasses'][
'ChWsbPermalinks'];
61 $aLinks = $this->oDb->getAll(
"SELECT * FROM `sys_permalinks`");
65 $aResult[$aLink[
'standard']] = array(
66 'permalink' => $aLink[
'permalink'],
67 'check' => $aLink[
'check'],
68 'enabled' => $this->oDb->getParam($aLink[
'check']) ==
'on'
72 $oCache = $this->oDb->getDbCacheObject();
73 if (
$oCache->setData($this->oDb->genDbCacheKey(
'sys_permalinks'),
$aResult)) {
84 if (strpos($sLink,
'modules/?r=') ===
false && strpos($sLink,
'modules/index.php?r=') ===
false) {
87 return $this->aLinks[$sLink][
'permalink'];
92 preg_match(
'/([\d]+)$/', $sLink, $aMatch);
93 if (!isset($aMatch[1])) {
94 preg_match(
'/(\{[a-zA-Z0-9_]+\})$/', $sLink, $aMatch);
96 if (!isset($aMatch[1])) {
101 $sLink = substr($sLink, 0, -strlen($aMatch[1]));
103 return $this->
_isEnabled($sLink) ? $this->aLinks[$sLink][
'permalink'] . $aMatch[1] : $sLink . $aMatch[1];
109 preg_match(
'/^.*(modules\/(index.php)?\?r=[A-Za-z0-9_-]+\/).*$/', $sLink, $aMatch);
111 if (!isset($aMatch[1])) {
112 return $this->
_isEnabled($sLink) ? $this->aLinks[$sLink][
'permalink'] : $sLink;
117 return str_replace($sBase, $this->aLinks[$sBase][
'permalink'], $sLink);
120 $sBaseShort = str_replace(
'index.php',
'', $sBase);
122 return $this->
_isEnabled($sBaseShort) ? str_replace($sBase, $this->aLinks[$sBaseShort][
'permalink'],
128 return array_key_exists($sLink, $this->aLinks) && $this->aLinks[$sLink][
'enabled'];
139 if (!preg_match(
'/modules\/index.php\?r=(\w+)(.*)/', $sCurrentUrl, $m)) {
143 $sStandardLink =
'modules/?r=' . $m[1] .
'/';
144 $sPermalink = $this->
permalink($sStandardLink);
146 if (
false !== strpos($sCurrentUrl, $sPermalink)) {
150 header(
"HTTP/1.1 301 Moved Permanently");
151 header(
'Location:' . CH_WSB_URL_ROOT . $sPermalink . rtrim(trim(urldecode($m[2]),
'/'),
'&'));