From: Andrey Kutejko Date: Sat, 22 Jun 2013 13:14:22 +0000 (+0300) Subject: context variables on 404 X-Git-Tag: 0.5~216 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=9e4f803eff1d1dac35fdcdf344d4037c9dfcc780;p=ipf.git context variables on 404 --- diff --git a/ipf/admin/model.php b/ipf/admin/model.php index 43f60ad..e063a31 100644 --- a/ipf/admin/model.php +++ b/ipf/admin/model.php @@ -528,7 +528,7 @@ class IPF_Admin_Model $perms = IPF_Admin_App::GetAdminModelPermissions($this, $request, $lapp, $lmodel); if ($perms === false || !in_array('view', $perms) || !in_array('add', $perms)) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); if ($request->method == 'POST') { @@ -577,7 +577,7 @@ class IPF_Admin_Model $perms = IPF_Admin_App::GetAdminModelPermissions($this, $request, $lapp, $lmodel); if ($perms === false || !in_array('view', $perms) || !in_array('delete', $perms)) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); if ($request->method == 'POST') { @@ -607,12 +607,12 @@ class IPF_Admin_Model $perms = IPF_Admin_App::GetAdminModelPermissions($this, $request, $lapp, $lmodel); if ($perms === false || !in_array('view', $perms)) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); if ($request->method == 'POST') { if (!in_array('change', $perms)) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); $this->_beforeEdit($o); $data = $request->POST+$request->FILES; @@ -676,7 +676,7 @@ class IPF_Admin_Model $perms = IPF_Admin_App::GetAdminModelPermissions($this, $request, $lapp, $lmodel); if ($perms === false || !in_array('view', $perms)) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); $this->ListItemsQuery(); $this->_GetFilters($request); diff --git a/ipf/admin/views.php b/ipf/admin/views.php index 15f1f50..85a0e1a 100644 --- a/ipf/admin/views.php +++ b/ipf/admin/views.php @@ -78,7 +78,7 @@ function IPF_Admin_Views_ListItems($request, $match) return $ma->ListItems($request, $lapp, $lmodel); } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); } function IPF_Admin_Views_AddItem($request, $match) @@ -102,7 +102,7 @@ function IPF_Admin_Views_AddItem($request, $match) return $ma->AddItem($request, $lapp, $lmodel); } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); } function IPF_Admin_Views_EditItem($request, $match) @@ -132,7 +132,7 @@ function IPF_Admin_Views_EditItem($request, $match) } } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); } function IPF_Admin_Views_DeleteItem($request, $match) @@ -162,7 +162,7 @@ function IPF_Admin_Views_DeleteItem($request, $match) } } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); } function IPF_Admin_Views_Reorder($request, $match) @@ -171,7 +171,7 @@ function IPF_Admin_Views_Reorder($request, $match) if ($ca!==true) return $ca; if ($request->method != 'POST' || !isset($request->POST['ids']) || !is_array($request->POST['ids'])) - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); $lapp = $match[1]; $lmodel = $match[2]; @@ -273,7 +273,7 @@ function IPF_Admin_Views_ChangePassword($request, $match) } } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($request); } function IPF_Admin_Views_Login($request, $match) diff --git a/ipf/http/response.php b/ipf/http/response.php index 55d2a46..cdb02ce 100644 --- a/ipf/http/response.php +++ b/ipf/http/response.php @@ -3,7 +3,7 @@ class IPF_HTTP_Response { public $short_session = false; - public $content = ''; + public $content = ''; public $headers = array(); public $status_code = 200; public $cookies = array(); diff --git a/ipf/http/response/notfound.php b/ipf/http/response/notfound.php index 1383cb6..e4cb8c9 100644 --- a/ipf/http/response/notfound.php +++ b/ipf/http/response/notfound.php @@ -2,22 +2,20 @@ class IPF_HTTP_Response_NotFound extends IPF_HTTP_Response { - function __construct($content='404 Not Found', $mimetype=null) + function __construct($request=null) { - try - { + try { $context = array( 'title' => '404 Not Found', 'query_string' => @$_SERVER['QUERY_STRING'], 'MEDIA_URL' => IPF::get('media_url'), 'ADMIN_MEDIA_URL' => IPF::get('admin_media_url'), ); - $content = IPF_Shortcuts::RenderToString('404.html', $context); + $content = IPF_Shortcuts::RenderToString('404.html', $context, $request); + } catch (IPF_Exception $e) { + $content = '404 Not Found'; } - catch (IPF_Exception $e) - { - } - parent::__construct($content, $mimetype); + parent::__construct($content); $this->status_code = 404; } } diff --git a/ipf/router.php b/ipf/router.php index deb1210..a41d936 100644 --- a/ipf/router.php +++ b/ipf/router.php @@ -68,14 +68,14 @@ class IPF_Router } return $r; } catch (IPF_HTTP_Error404 $e) { - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($req); } catch (IPF_Exception $e) { return IPF_Router::response500($e); } } } } - return new IPF_HTTP_Response_NotFound(); + return new IPF_HTTP_Response_NotFound($req); } public static function describe()