Cleaner display for 'trig'.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 8 Jun 2008 14:46:20 +0000 (16:46 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 8 Jun 2008 14:46:20 +0000 (16:46 +0200)
This add two kinds of triggers:
 $page->trigError()
 $page->trigSuccess()

The old $page->trig() takes 2 arguments:
 - the message to display
 - the kind of message ('errors' or 'success'), default is errors in order
   to preserve backward compatibility

Plan is to remove all ->trig() calls and switch the trig() method to protected
access rights.

Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
classes/platalpage.php
htdocs/css/default.css
htdocs/css/keynote.css
htdocs/css/openweb.css
templates/core/plwizard.tpl
templates/payment/index.tpl
templates/search/index.tpl
templates/skin/common.content.tpl
templates/skin/common.triggers.tpl [new file with mode: 0644]

index 4072a0a..bfb588e 100644 (file)
@@ -48,13 +48,13 @@ abstract class PlatalPage extends Smarty
         $this->compile_check = !empty($globals->debug);
 
         $this->changeTpl($tpl, $type);
-        $this->_errors    = array();
+        $this->_errors    = array('errors' => array());
         $this->_jsonVars  = array();
         $this->_failure   = false;
 
         if ($globals->mode != 'rw') {
-            $this->_errors[] = "En raison d'une maintenance, une partie des fonctionnalités du site sont actuellement"
-                             . " désactivée, en particuliers aucune donnée ne sera sauvegardée";
+            $this->trig("En raison d'une maintenance, une partie des fonctionnalités du site sont"
+                      . " actuellement désactivée, en particuliers aucune donnée ne sera sauvegardée");
         }
         $this->register_prefilter('at_to_globals');
         $this->addJsLink('xorg.js');
@@ -94,7 +94,8 @@ abstract class PlatalPage extends Smarty
         $this->register_prefilter('form_force_encodings');
         $this->register_prefilter('wiki_include');
         $this->register_prefilter('if_has_perms');
-        $this->assign('xorg_errors', $this->_errors);
+        $this->assign('xorg_triggers', $this->_errors);
+        $this->assign('xorg_errors', $this->nb_errs());
         $this->assign('xorg_failure', $this->_failure);
         $this->assign('globals', $globals);
 
@@ -187,15 +188,28 @@ abstract class PlatalPage extends Smarty
 
     public function nb_errs()
     {
-        return count($this->_errors);
+        return count($this->_errors['errors']);
     }
 
     // }}}
     // {{{ function trig()
 
-    public function trig($msg)
+    public function trig($msg, $type = 'errors')
     {
-        $this->_errors[] = $msg;
+        if (!isset($this->_errors[$type])) {
+            $this->_errors[$type] = array();
+        }
+        $this->_errors[$type][] = $msg;
+    }
+
+    public function trigError($msg)
+    {
+        $this->trig($msg, 'errors');
+    }
+
+    public function trigSuccess($msg)
+    {
+        $this->trig($msg, 'success');
     }
 
     // }}}
index 3fa4eae..04e69ce 100644 (file)
@@ -73,6 +73,20 @@ p {
     text-align: justify;
 }
 
+.errors {
+    margin-top: 10px;
+    border: 1px solid #f00;
+    background-color: #fcc;
+    width: 98%;
+}
+
+.success {
+    margin-top: 10px;
+    border: 1px solid #0d2;
+    background-color: #cfd;
+    width: 98%;
+}
+
 .erreur {
     font-weight: bold;
     color: #ff0000;
index 482df1b..4f4c040 100644 (file)
@@ -88,6 +88,20 @@ p.smaller {
     text-indent: 0;
 }
 
+.errors {
+    width: 98%;
+    border: 1px solid #f00;
+    margin-top: 10px;
+    background-color: #200;
+}
+
+.success {
+    width: 98%;
+    border: 1px solid #0d3;
+    margin-top: 10px;
+    background-color: #021;
+}
+
 .erreur {
     font-weight: bold;
     color: #d00;
index 0dc7744..d45611e 100644 (file)
@@ -76,6 +76,20 @@ p {
     text-align: justify;
 }
 
+.errors {
+    margin-top: 10px;
+    border: 1px solid #f00;
+    background-color: #fcc;
+    width: 98%;
+}
+
+.success {
+    margin-top: 10px;
+    border: 1px solid #0d2;
+    background-color: #cfd;
+    width: 98%;
+}
+
 .erreur {
     font-weight: bold;
     color: #ff0000;
index ace9510..df409dd 100644 (file)
@@ -90,9 +90,7 @@
     <div style="clear: both"></div>
   </div>
   <div class="wiz_content" style="clear: both">
-    {foreach from=$xorg_errors item=err}
-    <div class="erreur">{$err|smarty:nodefaults}</div>
-    {/foreach}
+    {include file="skin/common.triggers.tpl"}
     {include file=$wiz_page}
   </div>
 </div>
index 834c768..156a1eb 100644 (file)
@@ -23,7 +23,7 @@
 
 <h1>Télépaiements</h1>
 
-{if $smarty.request.op eq "submit" and !$xorg_errors|count}
+{if $smarty.request.op eq "submit" and !$xorg_errors}
 
 <table class="bicol">
   <tr>
index 93d1855..0f6d2c9 100644 (file)
@@ -21,7 +21,7 @@
 {**************************************************************************}
 
 
-{if $formulaire eq 0 and !$xorg_errors|count}
+{if $formulaire eq 0 and !$xorg_errors}
   {if !$simple}
     {if !$advanced}
     {include file=search/quick.form.tpl show_js=1}
index d9d1907..fdd8ddb 100644 (file)
@@ -38,9 +38,7 @@ Nous conseillons très vivement d'utiliser des navigateurs récents, tels
 {/if}
 
 {if !$xorg_no_errors || $xorg_failure}
-{foreach from=$xorg_errors item=err}
-<div class="erreur">{$err|smarty:nodefaults}</div>
-{/foreach}
+{include file="skin/common.triggers.tpl"}
 {/if}
 
 {if !$xorg_failure && $xorg_tpl}{include file=$xorg_tpl}{/if}
diff --git a/templates/skin/common.triggers.tpl b/templates/skin/common.triggers.tpl
new file mode 100644 (file)
index 0000000..5a310a3
--- /dev/null
@@ -0,0 +1,35 @@
+{**************************************************************************}
+{*                                                                        *}
+{*  Copyright (C) 2003-2008 Polytechnique.org                             *}
+{*  http://opensource.polytechnique.org/                                  *}
+{*                                                                        *}
+{*  This program is free software; you can redistribute it and/or modify  *}
+{*  it under the terms of the GNU General Public License as published by  *}
+{*  the Free Software Foundation; either version 2 of the License, or     *}
+{*  (at your option) any later version.                                   *}
+{*                                                                        *}
+{*  This program is distributed in the hope that it will be useful,       *}
+{*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *}
+{*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *}
+{*  GNU General Public License for more details.                          *}
+{*                                                                        *}
+{*  You should have received a copy of the GNU General Public License     *}
+{*  along with this program; if not, write to the Free Software           *}
+{*  Foundation, Inc.,                                                     *}
+{*  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA               *}
+{*                                                                        *}
+{**************************************************************************}
+
+{foreach from=$xorg_triggers key=type item=triggers}
+{if $triggers|@count}
+<div class="{$type}">
+  <ul>
+    {foreach from=$triggers item=err}
+    <li>{$err|smarty:nodefaults}</li>
+    {/foreach}
+  </ul>
+</div>
+{/if}
+{/foreach}
+
+{* vim:set et sw=2 sts=2 sws=2 enc=utf-8: *}