<?php
/*
Copyright (C) 2008 by oscim   Project lossim  [ 15.09.2009, 09:17:59] @oscim
// kate: replace-trailing-space-save true; space-indent on; indent-width 2; mixedindent off; indent-mode cstyle; word-wrap-marker-color #41C2A4
ENCODE UTF-8
*/
/**
  Gestion de l'affichage des artciles et de leurs options

  @package lossim <web http://www.lossim.org>
  @author oscim <mail dom@oscim.fr > <web http://www.oscim.fr>
  @class nav_posts

  NOTE:
*/

class message_stack extends table_block {

    /**
      count entrée messageStack
    */
    var $size;

    var $messageToStack;

    function message_stack() {
      global $cstr;

      $this->size = 0;
// 	  $this->table_row_parameters = 'class="messageStack"';
      if (is_register_session('messageToStack')) {
        $messageToStack=value_in_session('messageToStack');
        if (is_array($messageToStack) )
        for ($i = 0, $n = sizeof($messageToStack); $i < $n; $i++) {
          $this->add((string)$messageToStack[$i]['text'], (string)$messageToStack[$i]['type']);
        }
       del_in_session('messageToStack');
      }
    }

    /**
      Report type message
    */
    /*private*/ function type_mess($type){
      if ($type == 'error'|| $type == 'erreur') return 'error';
      elseif ($type == 'warning')return 'warning';
      elseif ($type == 'success' || $type == 'ok') return 'ok';
      elseif ($type == 'info') return 'info';
    }


    /**
      add message
    */
    /*public*/ function add($message, $type = 'error') {
      $this->messageToStack[] = array('type' => $this->type_mess($type), 'text' => $message);
      $this->size++;
    }

    /**
      Add session affichage au 2 chargement
    */
    /*public*/ function add_session($message, $type = 'error') {
      global $cstr;
      $messageToStack[] = array('text' => $message, 'type' => $this->type_mess($type));
      add_in_session('messageToStack',  $messageToStack);
    }

    function reset() {
      $this->messageToStack = array();
      $this->size = 0;
    }

    /**
      sortie
    */
    /*public*/ function output() {
      global $cstr;
//       if(count($this->size) >0)
        return $cstr->_call('table_block','table_block',$this->messageToStack);
    }
  }
?>