mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding comments for Router
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5193 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
6dd42ab406
commit
61a3d09dbc
1 changed files with 84 additions and 37 deletions
|
@ -46,30 +46,35 @@ class Router extends Object {
|
||||||
* Array of routes
|
* Array of routes
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $routes = array();
|
var $routes = array();
|
||||||
/**
|
/**
|
||||||
* CAKE_ADMIN route
|
* CAKE_ADMIN route
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__admin = null;
|
var $__admin = null;
|
||||||
/**
|
/**
|
||||||
* Directive for Router to parse out file extensions for mapping to Content-types.
|
* Directive for Router to parse out file extensions for mapping to Content-types.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var boolean
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__parseExtensions = false;
|
var $__parseExtensions = false;
|
||||||
/**
|
/**
|
||||||
* List of valid extensions to parse from a URL. If null, any extension is allowed.
|
* List of valid extensions to parse from a URL. If null, any extension is allowed.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__validExtensions = null;
|
var $__validExtensions = null;
|
||||||
/**
|
/**
|
||||||
* 'Constant' regular expression definitions for named route elements
|
* 'Constant' regular expression definitions for named route elements
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__named = array(
|
var $__named = array(
|
||||||
'Action' => 'index|show|list|add|create|edit|update|remove|del|delete|new|view|item',
|
'Action' => 'index|show|list|add|create|edit|update|remove|del|delete|new|view|item',
|
||||||
|
@ -82,18 +87,21 @@ class Router extends Object {
|
||||||
* The route matching the URL of the current request
|
* The route matching the URL of the current request
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__currentRoute = array();
|
var $__currentRoute = array();
|
||||||
/**
|
/**
|
||||||
* Maintains the parameter stack for the current request
|
* Maintains the parameter stack for the current request
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__params = array();
|
var $__params = array();
|
||||||
/**
|
/**
|
||||||
* Maintains the path stack for the current request
|
* Maintains the path stack for the current request
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__paths = array();
|
var $__paths = array();
|
||||||
|
|
||||||
|
@ -101,6 +109,7 @@ class Router extends Object {
|
||||||
* Maintains the mapped elements for array based urls
|
* Maintains the mapped elements for array based urls
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__mapped = array();
|
var $__mapped = array();
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +131,9 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Gets a reference to the Router object instance
|
* Gets a reference to the Router object instance
|
||||||
*
|
*
|
||||||
* @return object
|
* @return object Object instance
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function &getInstance() {
|
function &getInstance() {
|
||||||
static $instance = array();
|
static $instance = array();
|
||||||
|
@ -135,7 +146,9 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Gets the named route elements for use in app/config/routes.php
|
* Gets the named route elements for use in app/config/routes.php
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array Named route elements
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function getNamedExpressions() {
|
function getNamedExpressions() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -149,6 +162,8 @@ class Router extends Object {
|
||||||
* @param array $params An array matching the named elements in the route to regular expressions which that element should match.
|
* @param array $params An array matching the named elements in the route to regular expressions which that element should match.
|
||||||
* @see routes
|
* @see routes
|
||||||
* @return array Array of routes
|
* @return array Array of routes
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function connect($route, $default = array(), $params = array()) {
|
function connect($route, $default = array(), $params = array()) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -178,12 +193,13 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Builds a route regular expression
|
* Builds a route regular expression
|
||||||
*
|
*
|
||||||
* @access public
|
|
||||||
* @param string $route An empty string, or a route string "/"
|
* @param string $route An empty string, or a route string "/"
|
||||||
* @param array $default NULL or an array describing the default route
|
* @param array $default NULL or an array describing the default route
|
||||||
* @param array $params An array matching the named elements in the route to regular expressions which that element should match.
|
* @param array $params An array matching the named elements in the route to regular expressions which that element should match.
|
||||||
* @return string
|
* @return string
|
||||||
* @see routes
|
* @see routes
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function writeRoute($route, $default, $params) {
|
function writeRoute($route, $default, $params) {
|
||||||
if (empty($route) || ($route == '/')) {
|
if (empty($route) || ($route == '/')) {
|
||||||
|
@ -223,7 +239,9 @@ class Router extends Object {
|
||||||
* taken from that URL.
|
* taken from that URL.
|
||||||
*
|
*
|
||||||
* @param string $url URL to be parsed
|
* @param string $url URL to be parsed
|
||||||
* @return array
|
* @return array Parsed elements from URL
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function parse($url) {
|
function parse($url) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -289,6 +307,7 @@ class Router extends Object {
|
||||||
*
|
*
|
||||||
* @param string $url
|
* @param string $url
|
||||||
* @return array Returns an array containing the altered URL and the parsed extension.
|
* @return array Returns an array containing the altered URL and the parsed extension.
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __parseExtension($url) {
|
function __parseExtension($url) {
|
||||||
$ext = null;
|
$ext = null;
|
||||||
|
@ -316,7 +335,7 @@ class Router extends Object {
|
||||||
* Connects the default, built-in routes, including admin routes, and (deprecated) web services
|
* Connects the default, built-in routes, including admin routes, and (deprecated) web services
|
||||||
* routes.
|
* routes.
|
||||||
*
|
*
|
||||||
* @return void
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __connectDefaultRoutes() {
|
function __connectDefaultRoutes() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -346,8 +365,9 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Takes parameter and path information back from the Dispatcher
|
* Takes parameter and path information back from the Dispatcher
|
||||||
*
|
*
|
||||||
* @param array
|
* @param array $params Parameters and path information
|
||||||
* @return void
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function setRequestInfo($params) {
|
function setRequestInfo($params) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -359,8 +379,10 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Gets parameter information
|
* Gets parameter information
|
||||||
*
|
*
|
||||||
* @param boolean $current
|
* @param boolean $current Get current parameter (true)
|
||||||
* @return array
|
* @return array Parameter information
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function getParams($current = false) {
|
function getParams($current = false) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -372,9 +394,11 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Gets URL parameter by name
|
* Gets URL parameter by name
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name Parameter name
|
||||||
* @param boolean $current
|
* @param boolean $current Current parameter
|
||||||
* @return string
|
* @return string Parameter value
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function getParam($name = 'controller', $current = false) {
|
function getParam($name = 'controller', $current = false) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -387,8 +411,10 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Gets path information
|
* Gets path information
|
||||||
*
|
*
|
||||||
* @param boolean $current
|
* @param boolean $current Current parameter
|
||||||
* @return array
|
* @return array
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function getPaths($current = false) {
|
function getPaths($current = false) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -400,7 +426,8 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Reloads default Router settings
|
* Reloads default Router settings
|
||||||
*
|
*
|
||||||
* @return void
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function reload() {
|
function reload() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -423,6 +450,8 @@ class Router extends Object {
|
||||||
* and standard URL arguments (indexed array elements)
|
* and standard URL arguments (indexed array elements)
|
||||||
* @param boolean $full If true, the full base URL will be prepended to the result
|
* @param boolean $full If true, the full base URL will be prepended to the result
|
||||||
* @return string Full translated URL with base path.
|
* @return string Full translated URL with base path.
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function url($url = null, $full = false) {
|
function url($url = null, $full = false) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -573,9 +602,11 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Maps a URL array onto a route and returns the string result, or false if no match
|
* Maps a URL array onto a route and returns the string result, or false if no match
|
||||||
*
|
*
|
||||||
* @param array Route
|
* @param array $route Route Route
|
||||||
* @param array URL
|
* @param array $url URL URL to map
|
||||||
* @return mixed
|
* @return mixed Result (as string) or false if no match
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function mapRouteElements($route, $url) {
|
function mapRouteElements($route, $url) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -646,9 +677,10 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Merges URL parameters into a route string
|
* Merges URL parameters into a route string
|
||||||
*
|
*
|
||||||
* @param array Route
|
* @param array $route Route
|
||||||
* @param array $params
|
* @param array $params Parameters
|
||||||
* @return string
|
* @return string Merged URL with parameters
|
||||||
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __mapRoute($route, $params = array()) {
|
function __mapRoute($route, $params = array()) {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -675,9 +707,11 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Generates a well-formed querystring from $q
|
* Generates a well-formed querystring from $q
|
||||||
*
|
*
|
||||||
* @param mixed Querystring
|
* @param mixed $q Query string
|
||||||
* @param array Extra querystring parameters
|
* @param array $extra Extra querystring parameters
|
||||||
* @return array
|
* @return array
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function queryString($q, $extra = array()) {
|
function queryString($q, $extra = array()) {
|
||||||
if (empty($q) && empty($extra)) {
|
if (empty($q) && empty($extra)) {
|
||||||
|
@ -700,7 +734,9 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns the route matching the current request URL.
|
* Returns the route matching the current request URL.
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array Matching route
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function requestRoute() {
|
function requestRoute() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -709,7 +745,9 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Returns the route matching the current request (useful for requestAction traces)
|
* Returns the route matching the current request (useful for requestAction traces)
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array Matching route
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function currentRoute() {
|
function currentRoute() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -718,9 +756,11 @@ class Router extends Object {
|
||||||
/**
|
/**
|
||||||
* Removes the plugin name from the base URL.
|
* Removes the plugin name from the base URL.
|
||||||
*
|
*
|
||||||
* @param string $base
|
* @param string $base Base URL
|
||||||
* @param string $plugin
|
* @param string $plugin Plugin name
|
||||||
* @return base url with plugin name removed if present
|
* @return base url with plugin name removed if present
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
*/
|
*/
|
||||||
function stripPlugin($base, $plugin) {
|
function stripPlugin($base, $plugin) {
|
||||||
if ($plugin != null) {
|
if ($plugin != null) {
|
||||||
|
@ -735,6 +775,15 @@ class Router extends Object {
|
||||||
}
|
}
|
||||||
return $base;
|
return $base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip escape characters from parameter values.
|
||||||
|
*
|
||||||
|
* @param mixed $param Either an array, or a string
|
||||||
|
* @return mixed Array or string escaped
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
function stripEscape($param) {
|
function stripEscape($param) {
|
||||||
if(!is_array($param) || empty($param)) {
|
if(!is_array($param) || empty($param)) {
|
||||||
if(is_bool($param)) {
|
if(is_bool($param)) {
|
||||||
|
@ -767,11 +816,8 @@ class Router extends Object {
|
||||||
* If no parameters are given, anything after the first . (dot) after the last / in the URL will be
|
* If no parameters are given, anything after the first . (dot) after the last / in the URL will be
|
||||||
* parsed, excluding querystring parameters (i.e. ?q=...).
|
* parsed, excluding querystring parameters (i.e. ?q=...).
|
||||||
*
|
*
|
||||||
* @param string $ext
|
* @access public
|
||||||
* @param string $ext
|
* @static
|
||||||
* @param string $ext
|
|
||||||
* @param string ...
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
function parseExtensions() {
|
function parseExtensions() {
|
||||||
$_this =& Router::getInstance();
|
$_this =& Router::getInstance();
|
||||||
|
@ -781,17 +827,18 @@ class Router extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!function_exists('http_build_query')) {
|
||||||
/**
|
/**
|
||||||
* Implements http_build_query for PHP4.
|
* Implements http_build_query for PHP4.
|
||||||
*
|
*
|
||||||
* @param string $data
|
* @param string $data Data to set in query string
|
||||||
* @param string $prefix
|
* @param string $prefix If numeric indices, prepend this to index for elements in base array.
|
||||||
* @param string $argSep
|
* @param string $argSep String used to separate arguments
|
||||||
* @param string $baseKey
|
* @param string $baseKey Base key
|
||||||
* @return string
|
* @return string URL encoded query string
|
||||||
* @see http://php.net/http_build_query
|
* @see http://php.net/http_build_query
|
||||||
*/
|
*/
|
||||||
if(!function_exists('http_build_query')) {
|
|
||||||
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
|
function http_build_query($data, $prefix = null, $argSep = null, $baseKey = null) {
|
||||||
if(empty($argSep)) {
|
if(empty($argSep)) {
|
||||||
$argSep = ini_get('arg_separator.output');
|
$argSep = ini_get('arg_separator.output');
|
||||||
|
|
Loading…
Reference in a new issue