message_stack.php
来自「全新且完善的强大网上商店系统」· PHP 代码 · 共 76 行
PHP
76 行
<?php
class messageStack{
// class constructor
function messageStack() {
global $messageToStack;
$this->messages = array();
if (tep_session_is_registered('messageToStack')) {
for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) {
$this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']);
}
tep_session_unregister('messageToStack');
}
}
// class methods
function add($class, $message, $type = 'error') {
if ($type == 'error') {
$this->messages[] = array('class' => $class, 'text' => '<img src="images/icons/error.gif" border="0" alt="'.ICON_ERROR.'"> ' . $message);
} elseif ($type == 'warning') {
$this->messages[] = array('class' => $class, 'text' => '<img src="images/icons/warning.gif" border="0" alt="'.ICON_WARNING.'"> ' . $message);
} elseif ($type == 'success') {
$this->messages[] = array('class' => $class, 'text' => '<img src="images/icons/success.gif" border="0" alt="'.ICON_SUCCESS.'"> ' . $message);
} else {
$this->messages[] = array('class' => $class, 'text' => $message);
}
}
function add_session($class, $message, $type = 'error') {
global $messageToStack;
if (!tep_session_is_registered('messageToStack')) {
tep_session_register('messageToStack');
$messageToStack = array();
}
$messageToStack[] = array('class' => $class, 'text' => $message, 'type' => $type);
}
function reset() {
$this->messages = array();
}
function output($class) {
$this->table_data_parameters = 'class="messageBox"';
$output = array();
for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) {
if ($this->messages[$i]['class'] == $class) {
$output[] = $this->messages[$i];
}
}
return $output;
}
function size($class) {
$count = 0;
for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) {
if ($this->messages[$i]['class'] == $class) {
$count++;
}
}
return $count;
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?