]> git.andy128k.dev Git - ipf.git/commitdiff
context variables on 404
authorAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 13:14:22 +0000 (16:14 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Sat, 22 Jun 2013 13:14:22 +0000 (16:14 +0300)
ipf/admin/model.php
ipf/admin/views.php
ipf/http/response.php
ipf/http/response/notfound.php
ipf/router.php

index 43f60ad663b65ee3e5805d5ee6a2a7bf12aea4f6..e063a31b4902a1828c1f980e0b1690e514377db1 100644 (file)
@@ -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);
index 15f1f50b7ed44808419c51e89d4f8aa4b564229f..85a0e1aae2df641e9b89c4cc01450481820cec07 100644 (file)
@@ -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)
index 55d2a467e468cdb9121b69acd4cf9a73132583d1..cdb02ce52827bd8ef22de0d1cf53bf1ed1b6366d 100644 (file)
@@ -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();
index 1383cb6bfb5eeb3993f27215670502bdaa763aed..e4cb8c96e2903fc4f9d9501ed2e93d9b0ea5647a 100644 (file)
@@ -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;
     }
 }
index deb1210226e1ba371705e4d549a2d74b94345799..a41d9367e5b20e25d2644f57d1ecd9a58bef8edf 100644 (file)
@@ -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()