[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * @package admin 4 * @copyright Copyright 2003-2006 Zen Cart Development Team 5 * @copyright Portions Copyright 2003 osCommerce 6 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 7 * @version $Id: message_stack.php 3001 2006-02-09 21:45:06Z wilt $ 8 */ 9 if (!defined('IS_ADMIN_FLAG')) { 10 die('Illegal Access'); 11 } 12 13 /* 14 Example usage: 15 16 $messageStack = new messageStack(); 17 $messageStack->add('Error: Error 1', 'error'); 18 $messageStack->add('Error: Error 2', 'warning'); 19 if ($messageStack->size > 0) echo $messageStack->output(); 20 */ 21 22 class messageStack extends tableBlock { 23 var $size = 0; 24 25 function messageStack() { 26 27 $this->errors = array(); 28 29 if ($_SESSION['messageToStack']) { 30 for ($i = 0, $n = sizeof($_SESSION['messageToStack']); $i < $n; $i++) { 31 $this->add($_SESSION['messageToStack'][$i]['text'], $_SESSION['messageToStack'][$i]['type']); 32 } 33 $_SESSION['messageToStack'] = ''; 34 } 35 } 36 37 function add($message, $type = 'error') { 38 if ($type == 'error') { 39 $this->errors[] = array('params' => 'class="messageStackError"', 'text' => zen_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . ' ' . $message); 40 } elseif ($type == 'warning') { 41 $this->errors[] = array('params' => 'class="messageStackWarning"', 'text' => zen_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message); 42 } elseif ($type == 'success') { 43 $this->errors[] = array('params' => 'class="messageStackSuccess"', 'text' => zen_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . ' ' . $message); 44 } elseif ($type == 'caution') { 45 $this->errors[] = array('params' => 'class="messageStackCaution"', 'text' => zen_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message); 46 } else { 47 $this->errors[] = array('params' => 'class="messageStackError"', 'text' => $message); 48 } 49 50 51 $this->size++; 52 } 53 54 function add_session($message, $type = 'error') { 55 56 if (!$_SESSION['messageToStack']) { 57 $_SESSION['messageToStack'] = array(); 58 } 59 60 $_SESSION['messageToStack'][] = array('text' => $message, 'type' => $type); 61 } 62 63 function reset() { 64 $this->errors = array(); 65 $this->size = 0; 66 } 67 68 function output() { 69 $this->table_data_parameters = 'class="messageBox"'; 70 return $this->tableBlock($this->errors); 71 } 72 } 73 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |