Initial commit
This commit is contained in:
73
archive/version_01/admin/includes/classes/message_stack.php
Executable file
73
archive/version_01/admin/includes/classes/message_stack.php
Executable file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/**
|
||||
* @package admin
|
||||
* @copyright Copyright 2003-2006 Zen Cart Development Team
|
||||
* @copyright Portions Copyright 2003 osCommerce
|
||||
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
|
||||
* @version $Id: message_stack.php 3001 2006-02-09 21:45:06Z wilt $
|
||||
*/
|
||||
if (!defined('IS_ADMIN_FLAG')) {
|
||||
die('Illegal Access');
|
||||
}
|
||||
|
||||
/*
|
||||
Example usage:
|
||||
|
||||
$messageStack = new messageStack();
|
||||
$messageStack->add('Error: Error 1', 'error');
|
||||
$messageStack->add('Error: Error 2', 'warning');
|
||||
if ($messageStack->size > 0) echo $messageStack->output();
|
||||
*/
|
||||
|
||||
class messageStack extends tableBlock {
|
||||
var $size = 0;
|
||||
|
||||
function messageStack() {
|
||||
|
||||
$this->errors = array();
|
||||
|
||||
if ($_SESSION['messageToStack']) {
|
||||
for ($i = 0, $n = sizeof($_SESSION['messageToStack']); $i < $n; $i++) {
|
||||
$this->add($_SESSION['messageToStack'][$i]['text'], $_SESSION['messageToStack'][$i]['type']);
|
||||
}
|
||||
$_SESSION['messageToStack'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
function add($message, $type = 'error') {
|
||||
if ($type == 'error') {
|
||||
$this->errors[] = array('params' => 'class="messageStackError"', 'text' => zen_image(DIR_WS_ICONS . 'error.gif', ICON_ERROR) . ' ' . $message);
|
||||
} elseif ($type == 'warning') {
|
||||
$this->errors[] = array('params' => 'class="messageStackWarning"', 'text' => zen_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message);
|
||||
} elseif ($type == 'success') {
|
||||
$this->errors[] = array('params' => 'class="messageStackSuccess"', 'text' => zen_image(DIR_WS_ICONS . 'success.gif', ICON_SUCCESS) . ' ' . $message);
|
||||
} elseif ($type == 'caution') {
|
||||
$this->errors[] = array('params' => 'class="messageStackCaution"', 'text' => zen_image(DIR_WS_ICONS . 'warning.gif', ICON_WARNING) . ' ' . $message);
|
||||
} else {
|
||||
$this->errors[] = array('params' => 'class="messageStackError"', 'text' => $message);
|
||||
}
|
||||
|
||||
|
||||
$this->size++;
|
||||
}
|
||||
|
||||
function add_session($message, $type = 'error') {
|
||||
|
||||
if (!$_SESSION['messageToStack']) {
|
||||
$_SESSION['messageToStack'] = array();
|
||||
}
|
||||
|
||||
$_SESSION['messageToStack'][] = array('text' => $message, 'type' => $type);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
$this->errors = array();
|
||||
$this->size = 0;
|
||||
}
|
||||
|
||||
function output() {
|
||||
$this->table_data_parameters = 'class="messageBox"';
|
||||
return $this->tableBlock($this->errors);
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user