Added @geoffoliver attributes.

Geoff likes to exploit the URI and inject key/value pairs into it. It's not something I do, but I was intrigued enough to implement it. Basic usage is /path/to/page/id:123/spam:eggs. The variables are removed from the request variable as to not bork module loading and are made available via Browser::get('variable');
This commit is contained in:
Josh Sherman 2013-02-04 23:34:09 -05:00
parent 2a31127152
commit cbb75e7064
3 changed files with 173 additions and 5 deletions

View file

@ -9,7 +9,7 @@
* Redistribution of these files must retain the above copyright notice.
*
* @author Josh Sherman <pickles@joshtronic.com>
* @copyright Copyright 2007-2012, Josh Sherman
* @copyright Copyright 2007-2013, Josh Sherman
* @license http://www.opensource.org/licenses/mit-license.html
* @package PICKLES
* @link https://github.com/joshtronic/pickles
@ -55,6 +55,26 @@ class Controller extends Object
Error::fatal($_SERVER['SERVER_NAME'] . ' is currently<br />down for maintenance');
}
// Checks for attributes passed in the URI
if (strstr($_REQUEST['request'], ':'))
{
$parts = explode('/', $_REQUEST['request']);
$_REQUEST['request'] = '';
foreach ($parts as $part)
{
if (strstr($part, ':'))
{
list($variable, $value) = explode(':', $part);
Browser::set($variable, $value);
}
else
{
$_REQUEST['request'] .= ($_REQUEST['request'] ? '/' : '') . $part;
}
}
}
$_REQUEST['request'] = trim($_REQUEST['request']);
// Checks the passed request for validity