PlFilterOrder is an abstract class, put a default implementation for
[platal.git] / classes / platal.php
index 90f2df3..e5187e4 100644 (file)
@@ -23,6 +23,7 @@ define('PL_DO_AUTH',   300);
 define('PL_FORBIDDEN', 403);
 define('PL_NOT_FOUND', 404);
 define('PL_WIKI',      500);
+define('PL_JSON',      501);
 
 abstract class PlHook
 {
@@ -219,7 +220,6 @@ class PlHookTree
     }
 }
 
-
 abstract class Platal
 {
     private $mods;
@@ -362,7 +362,8 @@ abstract class Platal
 
         try {
             $page->assign('platal', $this);
-            switch ($this->call_hook($page)) {
+            $res = $this->call_hook($page);
+            switch ($res) {
               case PL_FORBIDDEN:
                 $this->mods['core']->handler_403($page);
                 break;
@@ -376,13 +377,7 @@ abstract class Platal
             }
         } catch (Exception $e) {
             header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error');
-
-            $file = fopen(self::globals()->spoolroot . '/spool/tmp/site_errors', 'a');
-            fwrite($file, '<pre>' . date('Y-m-d G:i:s') . '</pre>'
-                        . '<pre>' . pl_entities("" . $e) . '</pre>'
-                        . '------------------------------------------------------------------' . "\n");
-            fclose($file);
-
+            PlErrorReport::report($e);
             if (self::globals()->debug) {
                 $page->kill(pl_entities($e->getMessage())
                             . '<pre>' . pl_entities("" . $e) . '</pre>');
@@ -392,7 +387,11 @@ abstract class Platal
         }
 
         $page->assign('platal', $this);
-        $page->run();
+        if ($res == PL_JSON) {
+            $page->runJSon();
+        } else {
+            $page->run();
+        }
     }
 
     public function error403()