Gives nicer display to the MySQL errors gathering page.
authorStéphane Jacob <jacou@melix.net>
Tue, 20 Jan 2009 20:13:23 +0000 (21:13 +0100)
committerStéphane Jacob <jacou@melix.net>
Tue, 20 Jan 2009 20:36:17 +0000 (21:36 +0100)
modules/core.php
templates/sql_errors.tpl [new file with mode: 0644]

index 5aec747..7d537c5 100644 (file)
@@ -176,19 +176,18 @@ class CoreModule extends PLModule
         exit;
     }
 
-    function handler_sqlerror(&$page, $clear = null) {
+    function handler_sqlerror(&$page) {
         global $globals;
+        $page->coreTpl('sql_errors.tpl');
         $file = @fopen($globals->spoolroot . '/spool/tmp/query_errors', 'r');
         if ($file !== false) {
-            echo '<html><body>';
-            fpassthru($file);
+            $page->assign('errors', fpassthru($file));
             fclose($file);
-            echo '</html></body>';
         }
-        if ($clear == 'clear') {
+        if (Post::has('clear')) {
             @unlink($globals->spoolroot . '/spool/tmp/query_errors');
+            $page->trigSuccess("Erreurs MySQL effacées.");
         }
-        exit;
     }
 }
 
diff --git a/templates/sql_errors.tpl b/templates/sql_errors.tpl
new file mode 100644 (file)
index 0000000..d7eb9de
--- /dev/null
@@ -0,0 +1,38 @@
+{**************************************************************************}\r
+{*                                                                        *}\r
+{*  Copyright (C) 2003-2009 Polytechnique.org                             *}\r
+{*  http://opensource.polytechnique.org/                                  *}\r
+{*                                                                        *}\r
+{*  This program is free software; you can redistribute it and/or modify  *}\r
+{*  it under the terms of the GNU General Public License as published by  *}\r
+{*  the Free Software Foundation; either version 2 of the License, or     *}\r
+{*  (at your option) any later version.                                   *}\r
+{*                                                                        *}\r
+{*  This program is distributed in the hope that it will be useful,       *}\r
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}\r
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}\r
+{*  GNU General Public License for more details.                          *}\r
+{*                                                                        *}\r
+{*  You should have received a copy of the GNU General Public License     *}\r
+{*  along with this program; if not, write to the Free Software           *}\r
+{*  Foundation, Inc.,                                                     *}\r
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}\r
+{*                                                                        *}\r
+{**************************************************************************}\r
+\r
+<h1>Erreurs MySQL</h2>\r
+<p>\r
+  {if $errors}\r
+    {$errors}\r
+  {else}\r
+    Il n'y pas d'erreurs actuellement recencées.\r
+  {/if}\r
+</p>\r
+<form action="sql_errors" method="post">\r
+  <div>\r
+    <input type="submit" name="clear" value="Effacer les erreurs" />\r
+  </div>\r
+</form>\r
+\r
+\r
+{* vim:set et sws=2 sts=2 sw=2 enc=utf-8: *}\r