Mage_Adminhtml_Block_Sales_Order_View_Giftmessage Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Sales_Order_View_Giftmessage:

Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getSaveButtonHtml ()
 setEntity (Varien_Object $entity)
 getEntity ()
 getDefaultSender ()
 getDefaultRecipient ()
 getFieldName ($name)
 getFieldId ($id)
 getFieldIdPrefix ()
 getMessage ()
 getSaveUrl ()
 getHtmlId ()
 canDisplayGiftmessage ()

Protected Member Functions

 _beforeToHtml ()
 _prepareLayout ()
 _initMessage ()

Protected Attributes

 $_entity
 $_giftMessage


Detailed Description

Definition at line 34 of file Giftmessage.php.


Member Function Documentation

_beforeToHtml (  )  [protected]

Before rendering html, but after trying to load cache

Returns:
Mage_Core_Block_Abstract

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 50 of file Giftmessage.php.

00051     {
00052         if ($this->getParentBlock() && ($order = $this->getParentBlock()->getOrder())) {
00053             $this->setEntity($order);
00054         }
00055         parent::_beforeToHtml();
00056     }

_initMessage (  )  [protected]

Initialize gift message for entity

Returns:
Mage_Adminhtml_Block_Sales_Order_View_Giftmessage

Definition at line 199 of file Giftmessage.php.

00200     {
00201         $this->_giftMessage = $this->helper('giftmessage/message')->getGiftMessage(
00202                                    $this->getEntity()->getGiftMessageId()
00203                               );
00204 
00205         // init default values for giftmessage form
00206         if(!$this->getMessage()->getSender()) {
00207             $this->getMessage()->setSender($this->getDefaultSender());
00208         }
00209         if(!$this->getMessage()->getRecipient()) {
00210             $this->getMessage()->setRecipient($this->getDefaultRecipient());
00211         }
00212 
00213         return $this;
00214     }

_prepareLayout (  )  [protected]

Prepares layout of block

Returns:
Mage_Adminhtml_Block_Sales_Order_View_Giftmessage

Reimplemented from Mage_Core_Block_Abstract.

Definition at line 63 of file Giftmessage.php.

00064     {
00065         $this->setChild('save_button',
00066             $this->getLayout()->createBlock('adminhtml/widget_button')
00067                 ->setData(array(
00068                     'label'   => Mage::helper('giftmessage')->__('Save Gift Message'),
00069                     'class'   => 'save'
00070                 ))
00071         );
00072 
00073         return $this;
00074     }

canDisplayGiftmessage (  ) 

Indicates that block can display giftmessages form

Returns:
boolean

Definition at line 256 of file Giftmessage.php.

00257     {
00258         return $this->helper('giftmessage/message')->getIsMessagesAvailable(
00259             'order', $this->getEntity(), $this->getEntity()->getStoreId()
00260         );
00261     }

getDefaultRecipient (  ) 

Retrive default value for giftmessage recipient

Returns:
string

Definition at line 139 of file Giftmessage.php.

00140     {
00141         if(!$this->getEntity()) {
00142             return '';
00143         }
00144 
00145         if($this->getEntity()->getOrder()) {
00146             if ($this->getEntity()->getOrder()->getShippingAddress()) {
00147                 return $this->getEntity()->getOrder()->getShippingAddress()->getName();
00148             } else if ($this->getEntity()->getOrder()->getBillingAddress()) {
00149                 return $this->getEntity()->getOrder()->getBillingAddress()->getName();
00150             }
00151         }
00152 
00153         if ($this->getEntity()->getShippingAddress()) {
00154             return $this->getEntity()->getShippingAddress()->getName();
00155         } else if ($this->getEntity()->getBillingAddress()) {
00156             return $this->getEntity()->getBillingAddress()->getName();
00157         }
00158 
00159         return '';
00160     }

getDefaultSender (  ) 

Retrive default value for giftmessage sender

Returns:
string

Definition at line 121 of file Giftmessage.php.

00122     {
00123         if(!$this->getEntity()) {
00124             return '';
00125         }
00126 
00127         if($this->getEntity()->getOrder()) {
00128             return $this->getEntity()->getOrder()->getCustomerName();
00129         }
00130 
00131         return $this->getEntity()->getCustomerName();
00132     }

getEntity (  ) 

Retrive entity for form

Returns:
Varien_Object

Definition at line 107 of file Giftmessage.php.

00108     {
00109         if(is_null($this->_entity)) {
00110             $this->setEntity(Mage::getModel('giftmessage/message')->getEntityModelByType('order'));
00111             $this->getEntity()->load($this->getRequest()->getParam('entity'));
00112         }
00113         return $this->_entity;
00114     }

getFieldId ( id  ) 

Retrive real html id for field

Parameters:
string $name
Returns:
string

Definition at line 179 of file Giftmessage.php.

00180     {
00181         return $this->getFieldIdPrefix() . $id;
00182     }

getFieldIdPrefix (  ) 

Retrive field html id prefix

Returns:
string

Definition at line 189 of file Giftmessage.php.

00190     {
00191         return 'giftmessage_order_' . $this->getEntity()->getId() . '_';
00192     }

getFieldName ( name  ) 

Retrive real name for field

Parameters:
string $name
Returns:
string

Definition at line 168 of file Giftmessage.php.

00169     {
00170         return 'giftmessage[' . $this->getEntity()->getId() . '][' . $name . ']';
00171     }

getHtmlId (  ) 

Retrive block html id

Returns:
string

Reimplemented from Mage_Adminhtml_Block_Widget.

Definition at line 246 of file Giftmessage.php.

00247     {
00248         return substr($this->getFieldIdPrefix(), 0, -1);
00249     }

getMessage (  ) 

Retrive gift message for entity

Returns:
Mage_GiftMessage_Model_Message

Definition at line 221 of file Giftmessage.php.

00222     {
00223         if(is_null($this->_giftMessage)) {
00224             $this->_initMessage();
00225         }
00226 
00227         return $this->_giftMessage;
00228     }

getSaveButtonHtml (  ) 

Retrive save button html

Returns:
string

Definition at line 81 of file Giftmessage.php.

00082     {
00083         $this->getChild('save_button')->setOnclick(
00084             'giftMessagesController.saveGiftMessage(\''. $this->getHtmlId() .'\')'
00085         );
00086 
00087         return $this->getChildHtml('save_button');
00088     }

getSaveUrl (  ) 

Definition at line 230 of file Giftmessage.php.

00231     {
00232         return $this->getUrl('*/sales_order_view_giftmessage/save',
00233             array(
00234                 'entity'=>$this->getEntity()->getId(),
00235                 'type'  =>'order',
00236                 'reload' => 1
00237             )
00238         );
00239     }

setEntity ( Varien_Object entity  ) 

Set entity for form

Parameters:
Varien_Object $entity
Returns:
Mage_Adminhtml_Block_Sales_Order_View_Giftmessage

Definition at line 96 of file Giftmessage.php.

00097     {
00098         $this->_entity  = $entity;
00099         return $this;
00100     }


Member Data Documentation

$_entity [protected]

Definition at line 41 of file Giftmessage.php.

$_giftMessage [protected]

Definition at line 48 of file Giftmessage.php.


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

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