PHP Class CI_URI, TastyIgniter

Parses URIs and determines routing
Author: EllisLab Dev Team
Mostra file Open project: tastyigniter/tastyigniter Class Usage Examples

Public Properties

Property Type Description
$keyval array List of cached URI segments
$rsegments array Starts at 1 instead of 0.
$segments array Starts at 1 instead of 0.
$uri_string string Current URI string

Protected Properties

Property Type Description
$_permitted_uri_chars string PCRE character group allowed in URI segments

Public Methods

Method Description
__construct ( ) : void Class constructor
assoc_to_uri ( array $array ) : string Assoc to URI
filter_uri ( string &$str ) : void Filter URI
rsegment ( integer $n, mixed $no_result = NULL ) : mixed Fetch URI "routed" Segment
rsegment_array ( ) : array Routed Segment Array
ruri_string ( ) : string Fetch Re-routed URI string
ruri_to_assoc ( integer $n = 3, array $default = [] ) : array Routed URI to assoc
segment ( integer $n, mixed $no_result = NULL ) : mixed Fetch URI Segment
segment_array ( ) : array Segment Array
slash_rsegment ( integer $n, string $where = 'trailing' ) : string Slash routed segment
slash_segment ( integer $n, string $where = 'trailing' ) : string Slash segment
total_rsegments ( ) : integer Total number of routed segments
total_segments ( ) : integer Total number of segments
uri_string ( ) : string Fetch URI string
uri_to_assoc ( integer $n = 3, array $default = [] ) : array URI to assoc

Protected Methods

Method Description
_parse_argv ( ) : string Parse CLI arguments
_parse_query_string ( ) : string Parse QUERY_STRING
_parse_request_uri ( ) : string Parse REQUEST_URI
_remove_relative_directory ( string $uri ) : string Remove relative directory (.
_set_uri_string ( string $str ) : void Set URI String
_slash_segment ( integer $n, string $where = 'trailing', string $which = 'segment' ) : string Internal Slash segment
_uri_to_assoc ( integer $n = 3, array $default = [], string $which = 'segment' ) : array Internal URI-to-assoc

Method Details

__construct() public method

Class constructor
public __construct ( ) : void
return void

_parse_argv() protected method

Take each command line argument and assume it is a URI segment.
protected _parse_argv ( ) : string
return string

_parse_query_string() protected method

Will parse QUERY_STRING and automatically detect the URI from it.
protected _parse_query_string ( ) : string
return string

_parse_request_uri() protected method

Will parse REQUEST_URI and automatically detect the URI from it, while fixing the query string if necessary.
protected _parse_request_uri ( ) : string
return string

_remove_relative_directory() protected method

./) and multi slashes (///) Do some final cleaning of the URI and return it, currently only used in self::_parse_request_uri()
protected _remove_relative_directory ( string $uri ) : string
$uri string
return string

_set_uri_string() protected method

Set URI String
protected _set_uri_string ( string $str ) : void
$str string
return void

_slash_segment() protected method

Fetches an URI Segment and adds a slash to it.
protected _slash_segment ( integer $n, string $where = 'trailing', string $which = 'segment' ) : string
$n integer Index
$where string Where to add the slash ('trailing' or 'leading')
$which string Array name ('segment' or 'rsegment')
return string

_uri_to_assoc() protected method

Generates a key/value pair from the URI string or re-routed URI string.
protected _uri_to_assoc ( integer $n = 3, array $default = [], string $which = 'segment' ) : array
$n integer Index (default: 3)
$default array Default values
$which string Array name ('segment' or 'rsegment')
return array

assoc_to_uri() public method

Generates a URI string from an associative array.
public assoc_to_uri ( array $array ) : string
$array array Input array of key/value pairs
return string URI string

filter_uri() public method

Filters segments for malicious characters.
public filter_uri ( string &$str ) : void
$str string
return void

rsegment() public method

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().
See also: CI_URI::$rsegments
See also: CI_URI::segment()
public rsegment ( integer $n, mixed $no_result = NULL ) : mixed
$n integer Index
$no_result mixed What to return if the segment index is not found
return mixed

rsegment_array() public method

Routed Segment Array
public rsegment_array ( ) : array
return array CI_URI::$rsegments

ruri_string() public method

Fetch Re-routed URI string
public ruri_string ( ) : string
return string

ruri_to_assoc() public method

Identical to CI_URI::uri_to_assoc(), only it uses the re-routed segment array.
See also: CI_URI::uri_to_assoc()
public ruri_to_assoc ( integer $n = 3, array $default = [] ) : array
$n integer Index (default: 3)
$default array Default values
return array

segment() public method

Fetch URI Segment
See also: CI_URI::$segments
public segment ( integer $n, mixed $no_result = NULL ) : mixed
$n integer Index
$no_result mixed What to return if the segment index is not found
return mixed

segment_array() public method

Segment Array
public segment_array ( ) : array
return array CI_URI::$segments

slash_rsegment() public method

Fetches an URI routed segment with a slash.
public slash_rsegment ( integer $n, string $where = 'trailing' ) : string
$n integer Index
$where string Where to add the slash ('trailing' or 'leading')
return string

slash_segment() public method

Fetches an URI segment with a slash.
public slash_segment ( integer $n, string $where = 'trailing' ) : string
$n integer Index
$where string Where to add the slash ('trailing' or 'leading')
return string

total_rsegments() public method

Total number of routed segments
public total_rsegments ( ) : integer
return integer

total_segments() public method

Total number of segments
public total_segments ( ) : integer
return integer

uri_string() public method

Fetch URI string
public uri_string ( ) : string
return string CI_URI::$uri_string

uri_to_assoc() public method

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 )
public uri_to_assoc ( integer $n = 3, array $default = [] ) : array
$n integer Index (default: 3)
$default array Default values
return array

Property Details

$_permitted_uri_chars protected_oe property

PCRE character group allowed in URI segments
protected string $_permitted_uri_chars
return string

$keyval public_oe property

List of cached URI segments
public array $keyval
return array

$rsegments public_oe property

Starts at 1 instead of 0.
public array $rsegments
return array

$segments public_oe property

Starts at 1 instead of 0.
public array $segments
return array

$uri_string public_oe property

Current URI string
public string $uri_string
return string