_data =& $_SESSION['messageToStack']; } /** * Add a message to the stack * * @param string $group The group the message belongs to * @param string $message The message information text * @param string $type The type of message: error, warning, success * @access public */ public function add($group, $message, $type = 'error') { $this->_data[$group][] = array('text' => $message, 'type' => $type); } /** * Reset the message stack * * @access public */ public function reset() { $this->_data = array(); } /** * Checks to see if a group in the stack contains messages * * @param string $group The name of the group to check * @access public */ public function exists($group) { return ( isset($this->_data[$group]) && !empty($this->_data[$group]) ); } /** * Checks to see if the message stack contains messages * * @access public */ public function hasContent() { return !empty($this->_data); } /** * Get the messages belonging to a group. The messages are placed into an * unsorted list wrapped in a DIV element with the "messageStack" style sheet * class. * * @param string $group The name of the group to get the messages from * @access public */ public function get($group) { $result = false; if ( $this->exists($group) ) { $result = '
'; unset($this->_data[$group]); } return $result; } /** * Get the messages belonging to a group. The messages are separated by a new * line character. * * @param string $group The name of the group to get the messages from * @access public */ public function getRaw($group) { $result = false; if ( $this->exists($group) ) { $result = ''; foreach ( $this->_data[$group] as $message ) { $result .= osc_output_string($message['text']) . "\n"; } unset($this->_data[$group]); } return $result; } /** * Get the message stack array data set * * @access public */ public function getAll() { return $this->_data; } /** * Get the number of messages belonging to a group * * @param string $group The name of the group to check * @access public */ public function size($group) { $size = 0; if ( $this->exists($group) ) { $size = sizeof($this->_data[$group]); } return $size; } } ?>