| [ Index ] |
|
Code source de osCommerce 2.2ms2-060817 |
1 <?php 2 /* 3 $Id: message_stack.php,v 1.1 2003/05/19 19:45:42 hpdl Exp $ 4 5 osCommerce, Open Source E-Commerce Solutions 6 http://www.oscommerce.com 7 8 Copyright (c) 2002 osCommerce 9 10 Released under the GNU General Public License 11 12 Example usage: 13 14 $messageStack = new messageStack(); 15 $messageStack->add('general', 'Error: Error 1', 'error'); 16 $messageStack->add('general', 'Error: Error 2', 'warning'); 17 if ($messageStack->size('general') > 0) echo $messageStack->output('general'); 18 */ 19 20 class messageStack extends tableBox { 21 22 // class constructor 23 function messageStack() { 24 global $messageToStack; 25 26 $this->messages = array(); 27 28 if (tep_session_is_registered('messageToStack')) { 29 for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) { 30 $this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']); 31 } 32 tep_session_unregister('messageToStack'); 33 } 34 } 35 36 // class methods 37 function add($class, $message, $type = 'error') { 38 if ($type == 'error') { 39 $this->messages[] = array('params' => 'class="messageStackError"', 'class' => $class, 'text' => tep_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . ' ' . $message); 40 } elseif ($type == 'warning') { 41 $this->messages[] = array('params' => 'class="messageStackWarning"', 'class' => $class, 'text' => tep_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message); 42 } elseif ($type == 'success') { 43 $this->messages[] = array('params' => 'class="messageStackSuccess"', 'class' => $class, 'text' => tep_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . ' ' . $message); 44 } else { 45 $this->messages[] = array('params' => 'class="messageStackError"', 'class' => $class, 'text' => $message); 46 } 47 } 48 49 function add_session($class, $message, $type = 'error') { 50 global $messageToStack; 51 52 if (!tep_session_is_registered('messageToStack')) { 53 tep_session_register('messageToStack'); 54 $messageToStack = array(); 55 } 56 57 $messageToStack[] = array('class' => $class, 'text' => $message, 'type' => $type); 58 } 59 60 function reset() { 61 $this->messages = array(); 62 } 63 64 function output($class) { 65 $this->table_data_parameters = 'class="messageBox"'; 66 67 $output = array(); 68 for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) { 69 if ($this->messages[$i]['class'] == $class) { 70 $output[] = $this->messages[$i]; 71 } 72 } 73 74 return $this->tableBox($output); 75 } 76 77 function size($class) { 78 $count = 0; 79 80 for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) { 81 if ($this->messages[$i]['class'] == $class) { 82 $count++; 83 } 84 } 85 86 return $count; 87 } 88 } 89 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Mon Nov 26 19:48:25 2007 | par Balluche grâce à PHPXref 0.7 |
|