Mage_Core_Block_Messages Class Reference

Inheritance diagram for Mage_Core_Block_Messages:

Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Messages Mage_Adminhtml_Block_Sales_Order_Create_Messages Mage_Adminhtml_Block_Sales_Order_View_Messages

List of all members.

Public Member Functions

 _prepareLayout ()
 setMessages (Mage_Core_Model_Message_Collection $messages)
 addMessages (Mage_Core_Model_Message_Collection $messages)
 getMessageCollection ()
 addMessage (Mage_Core_Model_Message_Abstract $message)
 addError ($message)
 addWarning ($message)
 addNotice ($message)
 addSuccess ($message)
 getMessages ($type=null)
 getHtml ($type=null)
 getGroupedHtml ()

Protected Member Functions

 _toHtml ()

Protected Attributes

 $_messages


Detailed Description

Definition at line 34 of file Messages.php.


Member Function Documentation

_prepareLayout (  ) 

Preparing global layout

You can redefine this method in child classes for changin layout

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Reimplemented in Mage_Adminhtml_Block_Sales_Order_Create_Messages, and Mage_Adminhtml_Block_Sales_Order_View_Messages.

Definition at line 43 of file Messages.php.

00044     {
00045         $this->addMessages(Mage::getSingleton('core/session')->getMessages(true));
00046 
00047         parent::_prepareLayout();
00048     }

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 208 of file Messages.php.

00209     {
00210         return $this->getGroupedHtml();
00211     }

addError ( message  ) 

Adding new error message

Parameters:
string $message
Returns:
Mage_Core_Block_Messages

Definition at line 101 of file Messages.php.

00102     {
00103         $this->addMessage(Mage::getSingleton('core/message')->error($message));
00104         return $this;
00105     }

addMessage ( Mage_Core_Model_Message_Abstract message  ) 

Adding new message to message collection

Parameters:
Mage_Core_Model_Message_Abstract $message
Returns:
Mage_Core_Block_Messages

Definition at line 89 of file Messages.php.

00090     {
00091         $this->getMessageCollection()->add($message);
00092         return $this;
00093     }

addMessages ( Mage_Core_Model_Message_Collection messages  ) 

Definition at line 62 of file Messages.php.

00063     {
00064         foreach ($messages->getItems() as $message) {
00065             $this->getMessageCollection()->add($message);
00066         }
00067         return $this;
00068     }

addNotice ( message  ) 

Adding new nitice message

Parameters:
string $message
Returns:
Mage_Core_Block_Messages

Definition at line 125 of file Messages.php.

00126     {
00127         $this->addMessage(Mage::getSingleton('core/message')->notice($message));
00128         return $this;
00129     }

addSuccess ( message  ) 

Adding new success message

Parameters:
string $message
Returns:
Mage_Core_Block_Messages

Definition at line 137 of file Messages.php.

00138     {
00139         $this->addMessage(Mage::getSingleton('core/message')->success($message));
00140         return $this;
00141     }

addWarning ( message  ) 

Adding new warning message

Parameters:
string $message
Returns:
Mage_Core_Block_Messages

Definition at line 113 of file Messages.php.

00114     {
00115         $this->addMessage(Mage::getSingleton('core/message')->warning($message));
00116         return $this;
00117     }

getGroupedHtml (  ) 

Retrieve messages in HTML format grouped by type

Parameters:
string $type
Returns:
string

Definition at line 176 of file Messages.php.

00177     {
00178         $types = array(
00179             Mage_Core_Model_Message::ERROR,
00180             Mage_Core_Model_Message::WARNING,
00181             Mage_Core_Model_Message::NOTICE,
00182             Mage_Core_Model_Message::SUCCESS
00183         );
00184         $html = '';
00185         foreach ($types as $type) {
00186             if ( $messages = $this->getMessages($type) ) {
00187                 if ( !$html ) {
00188                     $html .= '<ul class="messages">';
00189                 }
00190                 $html .= '<li class="' . $type . '-msg">';
00191                 $html .= '<ul>';
00192 
00193                 foreach ( $messages as $message ) {
00194                     $html.= '<li>';
00195                     $html.= $message->getText();
00196                     $html.= '</li>';
00197                 }
00198                 $html .= '</ul>';
00199                 $html .= '</li>';
00200             }
00201         }
00202         if ( $html) {
00203             $html .= '</ul>';
00204         }
00205         return $html;
00206     }

getHtml ( type = null  ) 

Retrieve messages in HTML format

Parameters:
string $type
Returns:
string

Definition at line 160 of file Messages.php.

00161     {
00162         $html = '<ul id="admin_messages">';
00163         foreach ($this->getMessages($type) as $message) {
00164             $html.= '<li class="'.$message->getType().'-msg">'.$message->getText().'</li>';
00165         }
00166         $html .= '</ul>';
00167         return $html;
00168     }

getMessageCollection (  ) 

Retrieve messages collection

Returns:
Mage_Core_Model_Message_Collection

Definition at line 75 of file Messages.php.

00076     {
00077         if (!($this->_messages instanceof Mage_Core_Model_Message_Collection)) {
00078             $this->_messages = Mage::getModel('core/message_collection');
00079         }
00080         return $this->_messages;
00081     }

getMessages ( type = null  ) 

Retrieve messages array by message type

Parameters:
string $type
Returns:
array

Definition at line 149 of file Messages.php.

00150     {
00151         return $this->getMessageCollection()->getItems($type);
00152     }

setMessages ( Mage_Core_Model_Message_Collection messages  ) 

Set messages collection

Parameters:
Mage_Core_Model_Message_Collection $messages
Returns:
Mage_Core_Block_Messages

Definition at line 56 of file Messages.php.

00057     {
00058         $this->_messages = $messages;
00059         return $this;
00060     }


Member Data Documentation

$_messages [protected]

Definition at line 41 of file Messages.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:53 2009 for Magento by  doxygen 1.5.8