messages = array(); if (isset($_SESSION['messageToStack']) && $_SESSION['messageToStack']) { $messageToStack = $_SESSION['messageToStack']; for ($i=0, $n=sizeof($messageToStack); $i<$n; $i++) { $this->add($messageToStack[$i]['class'], $messageToStack[$i]['text'], $messageToStack[$i]['type']); } $_SESSION['messageToStack']= ''; } } // class methods function add($class, $message, $type = 'error') { global $template, $current_page_base; $message = trim($message); if (strlen($message) > 0) { if ($type == 'error') { $this->messages[] = array('params' => 'class="messageStackError larger"', 'class' => $class, 'text' => $message); } elseif ($type == 'warning') { $this->messages[] = array('params' => 'class="messageStackWarning larger"', 'class' => $class, 'text' => $message); } elseif ($type == 'success') { $this->messages[] = array('params' => 'class="messageStackSuccess larger"', 'class' => $class, 'text' => $message); } elseif ($type == 'caution') { $this->messages[] = array('params' => 'class="messageStackCaution larger"', 'class' => $class, 'text' => $message); } else { $this->messages[] = array('params' => 'class="messageStackError larger"', 'class' => $class, 'text' => $message); } } } function add_session($class, $message, $type = 'error') { if (!$_SESSION['messageToStack']) { $messageToStack = array(); } else { $messageToStack = $_SESSION['messageToStack']; } $messageToStack[] = array('class' => $class, 'text' => $message, 'type' => $type); $_SESSION['messageToStack'] = $messageToStack; $this->add($class, $message, $type); } function reset() { $this->messages = array(); } function output($class) { global $template, $current_page_base; $output = array(); for ($i=0, $n=sizeof($this->messages); $i<$n; $i++) { if ($this->messages[$i]['class'] == $class) { $output[] = $this->messages[$i]; } } // remove duplicates before displaying // $output = array_values(array_unique($output)); for ($i=0, $n=sizeof($output); $i<$n; $i++) { echo '