No more relative urls by default, #16
git-svn-id: svn+ssh://code.netmonsters.ru/svn/majestic/branches/evo@129 4cb57b5f-5bbd-dd11-951b-001d605cbbc5
This commit is contained in:
@ -41,16 +41,10 @@ abstract class Action
|
|||||||
* Redirect
|
* Redirect
|
||||||
*
|
*
|
||||||
* @param mixed $url
|
* @param mixed $url
|
||||||
* @param mixed $relative Default to true
|
|
||||||
*/
|
*/
|
||||||
protected function redirect($url = null, $relative = true)
|
protected function redirect($url = null)
|
||||||
{
|
{
|
||||||
$url = ($url) ? $url : Env::getRequestUri();
|
header('Location: ' . (($url) ? $url : Env::getRequestUri()));
|
||||||
|
|
||||||
if ($relative) {
|
|
||||||
$url = FrontController::getInstance()->getBaseUrl() . $url;
|
|
||||||
}
|
|
||||||
header('Location: ' . $url);
|
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +100,7 @@ class FrontController
|
|||||||
public function execute()
|
public function execute()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$request = Env::getRequestUri();
|
$request = Env::getRequestUri(true);
|
||||||
$route = $this->getRouter()->route($request);
|
$route = $this->getRouter()->route($request);
|
||||||
if (!$route) {
|
if (!$route) {
|
||||||
throw new Error404Exception('Route for "' . $request . '" not found');
|
throw new Error404Exception('Route for "' . $request . '" not found');
|
||||||
|
@ -14,22 +14,24 @@
|
|||||||
class Env
|
class Env
|
||||||
{
|
{
|
||||||
|
|
||||||
static protected $request = null;
|
static protected $request = array();
|
||||||
|
|
||||||
static protected $params = array();
|
static protected $params = array();
|
||||||
|
|
||||||
static public function getRequestUri()
|
static public function getRequestUri($trim_base = false)
|
||||||
{
|
{
|
||||||
if (self::$request === null) {
|
if (!isset(self::$request[$trim_base])) {
|
||||||
// removes get params
|
// removes get params
|
||||||
list(self::$request, ) = explode('?', Env::Server('REQUEST_URI'));
|
list(self::$request[$trim_base], ) = explode('?', Env::Server('REQUEST_URI'));
|
||||||
// removes base url
|
if ($trim_base) {
|
||||||
$base = FrontController::getInstance()->getBaseUrl();
|
// removes base url
|
||||||
if (($length = strlen($base)) > 0 && strpos(self::$request, $base) === 0) {
|
$base = FrontController::getInstance()->getBaseUrl();
|
||||||
self::$request = (string) substr(self::$request, $length);
|
if (($length = strlen($base)) > 0 && strpos(self::$request[$trim_base], $base) === 0) {
|
||||||
|
self::$request[$trim_base] = (string) substr(self::$request[$trim_base], $length);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self::$request;
|
return self::$request[$trim_base];
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function Get($key = null, $default = null)
|
static public function Get($key = null, $default = null)
|
||||||
|
Reference in New Issue
Block a user