-
Notifications
You must be signed in to change notification settings - Fork 0
CI_URI
URI Class
Parses URIs and determines routing
- Class name: CI_URI
- Namespace:
public array $keyval = array()
List of cached URI segments
- Visibility: public
public string $uri_string = ''
Current URI string
- Visibility: public
public array $segments = array()
List of URI segments
Starts at 1 instead of 0.
- Visibility: public
public array $rsegments = array()
List of routed URI segments
Starts at 1 instead of 0.
- Visibility: public
protected string $_permitted_uri_chars
Permitted URI chars
PCRE character group allowed in URI segments
- Visibility: protected
void CI_URI::__construct()
Class constructor
- Visibility: public
void CI_URI::_set_uri_string(string $str)
Set URI String
- Visibility: protected
- $str string
string CI_URI::_parse_request_uri()
Parse REQUEST_URI
Will parse REQUEST_URI and automatically detect the URI from it, while fixing the query string if necessary.
- Visibility: protected
string CI_URI::_parse_query_string()
Parse QUERY_STRING
Will parse QUERY_STRING and automatically detect the URI from it.
- Visibility: protected
string CI_URI::_parse_argv()
Parse CLI arguments
Take each command line argument and assume it is a URI segment.
- Visibility: protected
string CI_URI::_remove_relative_directory($uri)
Remove relative directory (.
./) and multi slashes (///)
Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
- Visibility: protected
- $uri mixed
void CI_URI::filter_uri(string $str)
Filter URI
Filters segments for malicious characters.
- Visibility: public
- $str string
mixed CI_URI::segment(integer $n, mixed $no_result)
Fetch URI Segment
- Visibility: public
- $n integer - <p>Index</p>
- $no_result mixed - <p>What to return if the segment index is not found</p>
mixed CI_URI::rsegment(integer $n, mixed $no_result)
Fetch URI "routed" Segment
Returns the re-routed URI segment (assuming routing rules are used) based on the index provided. If there is no routing, will return the same result as CI_URI::segment().
- Visibility: public
- $n integer - <p>Index</p>
- $no_result mixed - <p>What to return if the segment index is not found</p>
array CI_URI::uri_to_assoc(integer $n, array $default)
URI to assoc
Generates an associative array of URI data starting at the supplied segment index. For example, if this is your URI:
example.com/user/search/name/joe/location/UK/gender/male
You can use this method to generate an array with this prototype:
array ( name => joe location => UK gender => male )
- Visibility: public
- $n integer - <p>Index (default: 3)</p>
- $default array - <p>Default values</p>
array CI_URI::ruri_to_assoc(integer $n, array $default)
Routed URI to assoc
Identical to CI_URI::uri_to_assoc(), only it uses the re-routed segment array.
- Visibility: public
- $n integer - <p>Index (default: 3)</p>
- $default array - <p>Default values</p>
array CI_URI::_uri_to_assoc(integer $n, array $default, string $which)
Internal URI-to-assoc
Generates a key/value pair from the URI string or re-routed URI string.
- Visibility: protected
- $n integer - <p>Index (default: 3)</p>
- $default array - <p>Default values</p>
- $which string - <p>Array name ('segment' or 'rsegment')</p>
string CI_URI::assoc_to_uri(array $array)
Assoc to URI
Generates a URI string from an associative array.
- Visibility: public
- $array array - <p>Input array of key/value pairs</p>
string CI_URI::slash_segment(integer $n, string $where)
Slash segment
Fetches an URI segment with a slash.
- Visibility: public
- $n integer - <p>Index</p>
- $where string - <p>Where to add the slash ('trailing' or 'leading')</p>
string CI_URI::slash_rsegment(integer $n, string $where)
Slash routed segment
Fetches an URI routed segment with a slash.
- Visibility: public
- $n integer - <p>Index</p>
- $where string - <p>Where to add the slash ('trailing' or 'leading')</p>
string CI_URI::_slash_segment(integer $n, string $where, string $which)
Internal Slash segment
Fetches an URI Segment and adds a slash to it.
- Visibility: protected
- $n integer - <p>Index</p>
- $where string - <p>Where to add the slash ('trailing' or 'leading')</p>
- $which string - <p>Array name ('segment' or 'rsegment')</p>
array CI_URI::segment_array()
Segment Array
- Visibility: public
array CI_URI::rsegment_array()
Routed Segment Array
- Visibility: public
integer CI_URI::total_segments()
Total number of segments
- Visibility: public
integer CI_URI::total_rsegments()
Total number of routed segments
- Visibility: public
string CI_URI::uri_string()
Fetch URI string
- Visibility: public
string CI_URI::ruri_string()
Fetch Re-routed URI string
- Visibility: public