Files
@ 51a566e6db62
Branch filter:
Location: hot67beta/libraries/joomla/application/router.php - annotation
51a566e6db62
7.9 KiB
text/x-php
header kill
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 | c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 c7d7e38b2269 | <?php
/**
* @version $Id:router.php 8876 2007-09-13 22:54:03Z jinx $
* @package Joomla.Framework
* @subpackage Application
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
/**
* Set the available masks for the routing mode
*/
define('JROUTER_MODE_RAW', 0);
define('JROUTER_MODE_SEF', 1);
/**
* Class to create and parse routes
*
* @abstract
* @package Joomla.Framework
* @subpackage Application
* @since 1.5
*/
class JRouter extends JObject
{
/**
* The rewrite mode
*
* @access protected
* @var integer
*/
var $_mode = null;
/**
* An array of variables
*
* @access protected
* @var array
*/
var $_vars = array();
/**
* An array of rules
*
* @access protected
* @var array
*/
var $_rules = array(
'build' => array(),
'parse' => array()
);
/**
* Class constructor
*
* @access public
*/
function __construct($options = array())
{
if(array_key_exists('mode', $options)) {
$this->_mode = $options['mode'];
} else {
$this->_mode = JROUTER_MODE_RAW;
}
}
/**
* Returns a reference to the global JRouter object, only creating it if it
* doesn't already exist.
*
* This method must be invoked as:
* <pre> $menu = &JRouter::getInstance();</pre>
*
* @access public
* @param string $client The name of the client
* @param array $options An associative array of options
* @return JRouter A router object.
*/
function &getInstance($client, $options = array())
{
static $instances;
if (!isset( $instances )) {
$instances = array();
}
if (empty($instances[$client]))
{
//Load the router object
$info =& JApplicationHelper::getClientInfo($client, true);
$path = $info->path.DS.'includes'.DS.'router.php';
if(file_exists($path))
{
require_once $path;
// Create a JRouter object
$classname = 'JRouter'.ucfirst($client);
$instance = new $classname($options);
}
else
{
$error = JError::raiseError( 500, 'Unable to load router: '.$client);
return $error;
}
$instances[$client] = & $instance;
}
return $instances[$client];
}
/**
* Function to convert a route to an internal URI
*
* @access public
*/
function parse(&$uri)
{
$vars = array();
// Process the parsed variables based on custom defined rules
$vars = $this->_processParseRules($uri);
// Parse RAW URL
if($this->_mode == JROUTER_MODE_RAW) {
$vars += $this->_parseRawRoute($uri);
}
// Parse SEF URL
if($this->_mode == JROUTER_MODE_SEF) {
$vars += $vars + $this->_parseSefRoute($uri);
}
return array_merge($this->getVars(), $vars);
}
/**
* Function to convert an internal URI to a route
*
* @param string $string The internal URL
* @return string The absolute search engine friendly URL
*/
function &build($url)
{
//Create the URI object
$uri =& $this->_createURI($url);
//Process the uri information based on custom defined rules
$this->_processBuildRules($uri);
// Build RAW URL
if($this->_mode == JROUTER_MODE_RAW) {
$this->_buildRawRoute($uri);
}
// Build SEF URL : mysite/route/index.php?var=x
if ($this->_mode == JROUTER_MODE_SEF) {
$this->_buildSefRoute($uri);
}
return $uri;
}
/**
* Get the router mode
*
* @access public
*/
function getMode() {
return $this->_mode;
}
/**
* Get the router mode
*
* @access public
*/
function setMode($mode) {
$this->_mode = $mode;
}
/**
* Set a router variable, creating it if it doesn't exist
*
* @access public
* @param string $key The name of the variable
* @param mixed $value The value of the variable
* @param boolean $create If True, the variable will be created if it doesn't exist yet
*/
function setVar($key, $value, $create = true) {
if(!$create && array_key_exists($key, $this->_vars)) {
$this->_vars[$key] = $value;
} else {
$this->_vars[$key] = $value;
}
}
/**
* Set the router variable array
*
* @access public
* @param array $vars An associative array with variables
* @param boolean $create If True, the array will be merged instead of overwritten
*/
function setVars($vars = array(), $merge = true) {
if($merge) {
$this->_vars = array_merge($this->_vars, $vars);
} else {
$this->_vars = $vars;
}
}
/**
* Get a router variable
*
* @access public
* @param string $key The name of the variable
* $return mixed Value of the variable
*/
function getVar($key)
{
$result = null;
if(isset($this->_vars[$key])) {
$result = $this->_vars[$key];
}
return $result;
}
/**
* Get the router variable array
*
* @access public
* @return array An associative array of router variables
*/
function getVars() {
return $this->_vars;
}
/**
* Attach a build rule
*
* @access public
* @param callback $callback The function to be called.
*/
function attachBuildRule($callback)
{
$this->_rules['build'][] = $callback;
}
/**
* Attach a parse rule
*
* @access public
* @param callback $callback The function to be called.
*/
function attachParseRule($callback)
{
$this->_rules['parse'][] = $callback;
}
/**
* Function to convert a raw route to an internal URI
*
* @abstract
* @access protected
*/
function _parseRawRoute(&$uri)
{
return false;
}
/**
* Function to convert a sef route to an internal URI
*
* @abstract
* @access protected
*/
function _parseSefRoute(&$uri)
{
return false;
}
/**
* Function to build a raw route
*
* @abstract
* @access protected
*/
function _buildRawRoute(&$uri)
{
}
/**
* Function to build a sef route
*
* @abstract
* @access protected
*/
function _buildSefRoute(&$uri)
{
}
/**
* Process the parsed router variables based on custom defined rules
*
* @abstract
* @access protected
*/
function _processParseRules(&$uri)
{
$vars = array();
foreach($this->_rules['parse'] as $rule) {
$vars = call_user_func_array($rule, array(&$this, &$uri));
}
return $vars;
}
/**
* Process the build uri query data based on custom defined rules
*
* @abstract
* @access protected
*/
function _processBuildRules(&$uri)
{
foreach($this->_rules['build'] as $rule) {
call_user_func_array($rule, array(&$this, &$uri));
}
}
/**
* Create a uri based on a full or partial url string
*
* @access protected
* @return JURI A JURI object
*/
function &_createURI($url)
{
// Create full URL if we are only appending variables to it
if(substr($url, 0, 1) == '&')
{
$vars = array();
if(strpos($url, '&') !== false)
{
$url = str_replace('&','&',$url);
}
parse_str($url, $vars);
$vars = array_merge($this->getVars(), $vars);
foreach($vars as $key => $var)
{
if($var == "") {
unset($vars[$key]);
}
}
$url = 'index.php?'.JURI::buildQuery($vars);
}
// Decompose link into url component parts
$uri = new JURI($url);
return $uri;
}
/**
* Encode route segments
*
* @access protected
* @param array An array of route segments
* @return array
*/
function _encodeSegments($segments)
{
$total = count($segments);
for($i=0; $i<$total; $i++) {
$segments[$i] = str_replace(':', '-', $segments[$i]);
}
return $segments;
}
/**
* Decode route segments
*
* @access protected
* @param array An array of route segments
* @return array
*/
function _decodeSegments($segments)
{
$total = count($segments);
for($i=0; $i<$total; $i++) {
$segments[$i] = preg_replace('/-/', ':', $segments[$i], 1);
}
return $segments;
}
}
|