Index: build/manifests/jelix-lib.mn
===================================================================
--- build/manifests/jelix-lib.mn	(révision 1008)
+++ build/manifests/jelix-lib.mn	(copie de travail)
@@ -239,6 +239,7 @@
 * jJsonRpc.class.php
   jLog.class.php
   jMailer.class.php
+  jMessage.class.php
   jSmtp.class.php
   jTcpdf.class.php
 * jWiki.class.php
@@ -452,6 +453,7 @@
   block.swfjs.php
   function.link_to_remote.php
   function.breadcrumb.php
+  function.jmessage.php
 
 cd lib/jelix/plugins/tpl/ltx2pdf
   function.jlocale.php
Index: lib/jelix/plugins/tpl/html/function.jmessage.php
===================================================================
--- lib/jelix/plugins/tpl/html/function.jmessage.php	(révision 0)
+++ lib/jelix/plugins/tpl/html/function.jmessage.php	(révision 0)
@@ -0,0 +1,49 @@
+<?php
+/**
+* @package     Jelix
+* @subpackage  jtpl_plugin
+* @author      Loic Mathaud
+* @copyright   2008 Loic Mathaud
+* @link        http://www.jelix.org
+* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
+*/
+
+/**
+* function plugin :  Display messages from jMessage
+*/
+
+function jtpl_function_html_jmessage($tpl, $type = '') {
+    // Get messages
+    if ($type == '') {
+        $messages = jMessage::getAll();
+    } else {
+        $messages = jMessage::get($type);
+    }
+    // Not messages, quit
+    if (!$messages) {
+        return;
+    }
+
+    // Display messages
+    if ($type == '') {
+        echo '<ul class="jelix-msg">';
+        foreach ($messages as $types) {
+            foreach ($types as $type => $msg) {
+                echo '<li class="jelix-msg-item-'.$type.'">'.htmlspecialchars($msg).'</li>';
+            }
+        }
+    } else {
+        echo '<ul class="jelix-msg-'. $type .'">';
+        foreach ($messages as $msg) {
+            echo '<li class="jelix-msg-item-'.$type.'">'.htmlspecialchars($msg).'</li>';
+        }
+    }
+    echo '</ul>';
+
+    if ($type == '') {
+        jMessage::clearAll();;
+    } else {
+        jMessage::clear($type);
+    }
+    
+}
Index: lib/jelix/utils/jMessage.class.php
===================================================================
--- lib/jelix/utils/jMessage.class.php	(révision 0)
+++ lib/jelix/utils/jMessage.class.php	(révision 0)
@@ -0,0 +1,81 @@
+<?php
+/**
+* @package    jelix
+* @subpackage utils
+* @author     Loic Mathaud
+* @copyright  2008 Loic Mathaud
+* @link       http://www.jelix.org
+* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
+*/
+
+/**
+* Utility class to log some message in session in order to be displayed in a template
+* @package    jelix
+* @subpackage utils
+* @static
+*/
+class jMessage {
+
+    protected static $session_name = 'JELIX_MESSAGE';
+    
+    
+    /**
+    * Add a message
+    * @param string $message the message
+    * @param string $type the message type ('default' by default)
+    */
+    public static function add($message, $type = 'default') {
+        if (!isset($_SESSION[self::$session_name])) {
+            $_SESSION[self::$session_name] = array();
+        }
+        if (!isset($_SESSION[self::$session_name][$type])) {
+            $_SESSION[self::$session_name][$type] = array();
+        }
+        
+        // Add message
+        $_SESSION[self::$session_name][$type][] = $message;
+    }
+    
+    /**
+    * Clear messages for the given type
+    * @param string $type the message type ('default' by default)
+    */
+    public static function clear($type = 'default') {
+        if (isset($_SESSION[self::$session_name][$type])) {
+            $_SESSION[self::$session_name][$type] = array();
+        }
+    }
+    
+    /**
+    * Clear all messages
+    */
+    public static function clearAll() {
+        if (isset($_SESSION[self::$session_name])) {
+            $_SESSION[self::$session_name] = array();
+        }
+    }
+    
+    /**
+    * Get messages for the given type
+    * @param string $type the message type ('default' by default)
+    * @return mixed array/null
+    */
+    public static function get($type = 'default') {
+        if (isset($_SESSION[self::$session_name][$type])) {
+            return $_SESSION[self::$session_name][$type];
+        }
+        
+        return null;
+    }
+    
+    /**
+    * Get all messages
+    */
+    public static function getAll() {
+        if (isset($_SESSION[self::$session_name])) {
+            return $_SESSION[self::$session_name];
+        }
+        
+        return null;
+    }
+}
