public function add($type, $message, $data = FALSE, $title = FALSE)
  {
	  $messages = $this->_session_get();
	  
	  if (!is_array($messages)) {
		
		$messages = array();
	  }
	  
	  if (is_a($message, 'Exception')) {
		  	
		  $title = 'Exception Thrown!';
		  
		  $message = $message->getMessage();
		  
		  $type = 'error';
	  }

      $msg = array('type'=>$type,'title'=>$title);      
  	  
	  $msg['text'] = is_array($data) ? vsprintf($message, $data) : sprintf($message, $data);
   
	  $messages[] = (object)$msg;

      $this->_session_set($messages);	  
	   	
      return $this;
  }
public function add($type, $message, $data = FALSE, $title = FALSE)
  {
	  $messages = $this->_session_get();
	  
	  if (!is_array($messages)) {
		
		$messages = array();
	  }
	  
	  if (is_a($message, 'Exception')) {
		  	
		  $title = 'Exception Thrown!';
		  
		  $message = $message->getMessage();
		  
		  $type = 'error';
	  }

      $msg = array('type'=>$type,'title'=>$title);      
  	  
	  $msg['text'] = is_array($data) ? vsprintf($message, $data) : sprintf($message, $data);
   
	  $messages[] = (object)$msg;

      $this->_session_set($messages);	  
	   	
      return $this;
  }
public function add ( $ type , $ message , $ data = FALSE , $ title = FALSE ) { $ messages = $ this -> _session_get ( ) ; if ( ! is_array ( $ messages ) ) { $ messages = array ( ) ; } if ( is_a ( $ message , 'Exception' ) ) { $ title = 'Exception Thrown!' ; $ message = $ message -> getMessage ( ) ; $ type = 'error' ; } $ msg = array ( 'type' => $ type , 'title' => $ title ) ; $ msg [ 'text' ] = is_array ( $ data ) ? vsprintf ( $ message , $ data ) : sprintf ( $ message , $ data ) ; $ messages [ ] = ( object ) $ msg ; $ this -> _session_set ( $ messages ) ; return $ this ; }
Adds a message to the a list.

The optional parameter $data may be a primitive value or an array.
If the $data parameter is present, $message must be a
{@link http://www.php.net/manual/en/function.sprintf.php printf()}-style
template string that includes formatting for the value(s) in $data.
The $message formatting string is applied to the $data value(s) and
the resulting message string is added to the list.

Eg. $this->messages->add('success', '%d files uploaded (%.2f kB)', array($num_files, $uploaded_size));

@param string $message message to be displayed
@param string $type one of the message types specified in the constructor params
@param mixed $data optional data to be included in the message
@return $this
Adds a message to the a list .