summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authoradmin <devnull@localhost>2006-09-21 19:01:27 +0200
committeradmin <devnull@localhost>2006-09-21 19:01:27 +0200
commitdaf454dabe983f621570bcef10d6d8babedfb8a8 (patch)
tree614b8581cc71d5d7d4cec5f89ee71e50cb2c62ba /system/libraries
parent2c676ef0c7a7df9de4331137b033d236f5f3708a (diff)
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/URI.php93
1 files changed, 91 insertions, 2 deletions
diff --git a/system/libraries/URI.php b/system/libraries/URI.php
index ba6279e88..11562eb29 100644
--- a/system/libraries/URI.php
+++ b/system/libraries/URI.php
@@ -66,6 +66,25 @@ class CI_URI {
// --------------------------------------------------------------------
/**
+ * Fetch a URI "routed" Segment
+ *
+ * This function returns the re-routed URI segment (assuming routing rules are used)
+ * based on the number provided. If there is no routing this function returns the
+ * same result as $this->segment()
+ *
+ * @access public
+ * @param integer
+ * @param bool
+ * @return string
+ */
+ function rsegment($n, $no_result = FALSE)
+ {
+ return ( ! isset($this->router->rsegments[$n])) ? $no_result : $this->router->rsegments[$n];
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
* Generate a key value pair from the URI string
*
* This function generates and associative array of URI data starting
@@ -168,7 +187,6 @@ class CI_URI {
return implode('/', $temp);
}
-
// --------------------------------------------------------------------
/**
@@ -180,6 +198,37 @@ class CI_URI {
* @return string
*/
function slash_segment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'segment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash
+ *
+ * @access public
+ * @param integer
+ * @param string
+ * @return string
+ */
+ function slash_rsegment($n, $where = 'trailing')
+ {
+ return $this->_slash_segment($n, $where, 'rsegment');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch a URI Segment and add a trailing slash - helper function
+ *
+ * @access private
+ * @param integer
+ * @param string
+ * @param string
+ * @return string
+ */
+ function _slash_segment($n, $where = 'trailing', $which = 'segment')
{
if ($where == 'trailing')
{
@@ -196,7 +245,7 @@ class CI_URI {
$leading = '/';
$trailing = '/';
}
- return ( ! isset($this->router->segments[$n])) ? '' : $leading.$this->router->segments[$n].$trailing;
+ return ( ! isset($this->router->$which[$n])) ? '' : $leading.$this->router->$which[$n].$trailing;
}
// --------------------------------------------------------------------
@@ -211,6 +260,19 @@ class CI_URI {
{
return $this->router->segments;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Routed Segment Array
+ *
+ * @access public
+ * @return array
+ */
+ function rsegment_array()
+ {
+ return $this->router->rsegments;
+ }
// --------------------------------------------------------------------
@@ -224,6 +286,19 @@ class CI_URI {
{
return count($this->router->segments);
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Total number of routed segments
+ *
+ * @access public
+ * @return integer
+ */
+ function total_rsegments()
+ {
+ return count($this->router->rsegments);
+ }
// --------------------------------------------------------------------
@@ -238,6 +313,20 @@ class CI_URI {
return $this->router->uri_string;
}
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Fetch the entire Re-routed URI string
+ *
+ * @access public
+ * @return string
+ */
+ function uri_rstring()
+ {
+ return '/'.implode('/', $this->rsegment_array()).'/';
+ }
+
}
// END URI Class
?> \ No newline at end of file