summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorJonatas Miguel <jonatas.df.miguel@gmail.com>2012-07-20 12:23:43 +0200
committerJonatas Miguel <jonatas.df.miguel@gmail.com>2012-07-20 12:23:43 +0200
commita101c93b93b43ac98370bb0a1378a82ff44e4e1a (patch)
tree30350d446bbc4a46db32d07c4c863a199d3dfcff /system
parentfa4af2c268eb920e8eb772b793962000c10ac79c (diff)
allow for routes that can be processed with php, ex: $route['([^/]+)/([^/]+)(/:any)?'] = 'php:"$1" . "/do" . ucfirst("$2") . "$3"';
Diffstat (limited to 'system')
-rw-r--r--system/core/Router.php15
1 files changed, 14 insertions, 1 deletions
diff --git a/system/core/Router.php b/system/core/Router.php
index 5bc053045..cb7df5320 100644
--- a/system/core/Router.php
+++ b/system/core/Router.php
@@ -86,6 +86,13 @@ class CI_Router {
* @var string
*/
public $default_controller;
+
+ /**
+ * Prepend used in php processed routes
+ *
+ * @var string
+ */
+ public $route_prepend = 'php:';
/**
* Constructor
@@ -373,10 +380,16 @@ class CI_Router {
// Does the RegEx match?
if (preg_match('#^'.$key.'$#', $uri))
{
+ // Are we using php functions to process matches?
+ $modifier = strpos($val, $this->route_prepend) === 0? 'e': '';
+
+ // If we have the 'e' modifier, remove the prepend from the route value.
+ $val = $modifier === 'e'? substr($val, strlen($this->route_prepend)): $val;
+
// Do we have a back-reference?
if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE)
{
- $val = preg_replace('#^'.$key.'$#', $val, $uri);
+ $val = preg_replace('#^'.$key.'$#'.$modifier, $val, $uri);
}
return $this->_set_request(explode('/', $val));