From cae329a1f909bd15ba127a799d564dfe0ea66ff5 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 31 Mar 2015 06:24:14 -0700 Subject: [PATCH] Issue #937 e107::url() can now build non-sef URLs. ToDo: mod-rewrite check. --- e107_handlers/e107_class.php | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 75bdfdaac..4a1d959a8 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2617,8 +2617,36 @@ class e107 if(varset($tmp[$plugin][$key]['sef'])) { - $rawUrl = $tp->simpleParse($tmp[$plugin][$key]['sef'], $row); - return e_HTTP.$rawUrl; + $mode = 'sef'; //TODO Auto-detect when mod-rewrite is active. + + if($mode == 'sef') // Search-Engine-Friendly URL + { + $rawUrl = $tp->simpleParse($tmp[$plugin][$key]['sef'], $row); + return e_HTTP.$rawUrl; + } + else // Legacy URL. + { + preg_match('#({[a-z_]*})#', $tmp[$plugin][$key]['sef'],$matches); + + unset($matches[0]); + + $srch = array(); + $repl = array(); + + foreach($matches as $k=>$val) + { + $srch[] = '$'.$k; + $repl[] = $val; + } + + $urlTemplate = str_replace($srch,$repl,$tmp[$plugin][$key]['redirect']); + $urlTemplate = $tp->replaceConstants($urlTemplate,'abs'); + $legacyUrl = $tp->simpleParse($urlTemplate, $row); + + return $legacyUrl; + } + + } return false;