[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/includes/classes/ -> message_stack.php (source)

   1  <?php
   2  /*

   3  $Id: message_stack.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  

  12    Example usage:

  13  

  14    $messageStack = new messageStack();

  15    $messageStack->add('Error: Error 1', 'error');

  16    $messageStack->add('Error: Error 2', 'warning');

  17    if ($messageStack->size > 0) echo $messageStack->output();

  18  */
  19  
  20    class messageStack extends tableBlock {
  21      var $size = 0;
  22  
  23      function messageStack() {
  24        global $messageToStack;
  25  
  26        $this->errors = array();
  27  
  28        if (tep_session_is_registered('messageToStack')) {
  29          for ($i = 0, $n = sizeof($messageToStack); $i < $n; $i++) {
  30            $this->add($messageToStack[$i]['text'], $messageToStack[$i]['type']);
  31          }
  32          tep_session_unregister('messageToStack');
  33        }
  34      }
  35  
  36      function add($message, $type = 'error') {
  37        if ($type == 'error') {
  38          $this->errors[] = array('params' => 'class="messageStackError"', 'text' => tep_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . '&nbsp;' . $message);
  39        } elseif ($type == 'warning') {
  40          $this->errors[] = array('params' => 'class="messageStackWarning"', 'text' => tep_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . '&nbsp;' . $message);
  41        } elseif ($type == 'success') {
  42          $this->errors[] = array('params' => 'class="messageStackSuccess"', 'text' => tep_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . '&nbsp;' . $message);
  43        } else {
  44          $this->errors[] = array('params' => 'class="messageStackError"', 'text' => $message);
  45        }
  46  
  47        $this->size++;
  48      }
  49  
  50      function add_session($message, $type = 'error') {
  51        global $messageToStack;
  52  
  53        if (!tep_session_is_registered('messageToStack')) {
  54          tep_session_register('messageToStack');
  55          $messageToStack = array();
  56        }
  57  
  58        $messageToStack[] = array('text' => $message, 'type' => $type);
  59      }
  60  
  61      function reset() {
  62        $this->errors = array();
  63        $this->size = 0;
  64      }
  65  
  66      function output() {
  67        $this->table_data_parameters = 'class="messageBox"';
  68        return $this->tableBlock($this->errors);
  69      }
  70    }
  71  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7