Mage_Weee_Block_Renderer_Weee_Tax Class Reference

Inheritance diagram for Mage_Weee_Block_Renderer_Weee_Tax:

Mage_Adminhtml_Block_Widget Varien_Data_Form_Element_Renderer_Interface Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()
 getProduct ()
 render (Varien_Data_Form_Element_Abstract $element)
 setElement (Varien_Data_Form_Element_Abstract $element)
 getElement ()
 getValues ()
 getWebsiteCount ()
 isMultiWebsites ()
 getCountries ()
 getWebsites ()
 getAddButtonHtml ()

Protected Member Functions

 _sortWeeeTaxes ($a, $b)
 _setAddButton ()

Protected Attributes

 $_element = null
 $_countries = null
 $_websites = null


Detailed Description

Definition at line 34 of file Tax.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Definition at line 41 of file Tax.php.

00042     {
00043         $this->setTemplate('weee/renderer/tax.phtml');
00044     }


Member Function Documentation

_setAddButton (  )  [protected]

Definition at line 146 of file Tax.php.

00147     {
00148         $this->setChild('add_button',
00149             $this->getLayout()->createBlock('adminhtml/widget_button')
00150                 ->setData(array(
00151                     'label'     => Mage::helper('catalog')->__('Add Tax'),
00152                     'onclick'   => "weeeTaxControl.addItem('".$this->getElement()->getHtmlId()."')",
00153                     'class' => 'add'
00154                 )));
00155     }

_sortWeeeTaxes ( a,
b 
) [protected]

Definition at line 81 of file Tax.php.

00082     {
00083         if ($a['website_id']!=$b['website_id']) {
00084             return $a['website_id']<$b['website_id'] ? -1 : 1;
00085         }
00086         if ($a['country']!=$b['country']) {
00087             return $a['country']<$b['country'] ? -1 : 1;
00088         }
00089         return 0;
00090     }

getAddButtonHtml (  ) 

Definition at line 157 of file Tax.php.

00158     {
00159         return $this->getChildHtml('add_button');
00160     }

getCountries (  ) 

Definition at line 102 of file Tax.php.

00103     {
00104         if (is_null($this->_countries)) {
00105             $this->_countries = Mage::getModel('adminhtml/system_config_source_country')
00106                 ->toOptionArray();
00107         }
00108 
00109         return $this->_countries;
00110     }

getElement (  ) 

Definition at line 64 of file Tax.php.

00065     {
00066         return $this->_element;
00067     }

getProduct (  ) 

Definition at line 46 of file Tax.php.

00047     {
00048         return Mage::registry('product');
00049     }

getValues (  ) 

Definition at line 69 of file Tax.php.

00070     {
00071         $values =array();
00072         $data = $this->getElement()->getValue();
00073 
00074         if (is_array($data) && count($data)) {
00075             usort($data, array($this, '_sortWeeeTaxes'));
00076             $values = $data;
00077         }
00078         return $values;
00079     }

getWebsiteCount (  ) 

Definition at line 92 of file Tax.php.

00093     {
00094         return count($this->getWebsites());
00095     }

getWebsites (  ) 

Definition at line 112 of file Tax.php.

00113     {
00114         if (!is_null($this->_websites)) {
00115             return $this->_websites;
00116         }
00117         $websites = array();
00118         $websites[0] = array(
00119             'name'      => $this->__('All Websites'),
00120             'currency'  => Mage::app()->getBaseCurrencyCode()
00121         );
00122 
00123         if (!Mage::app()->isSingleStoreMode() && !$this->getElement()->getEntityAttribute()->isScopeGlobal()) {
00124             if ($storeId = $this->getProduct()->getStoreId()) {
00125                 $website = Mage::app()->getStore($storeId)->getWebsite();
00126                 $websites[$website->getId()] = array(
00127                     'name'      => $website->getName(),
00128                     'currency'  => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00129                 );
00130             } else {
00131                 foreach (Mage::app()->getWebsites() as $website) {
00132                     if (!in_array($website->getId(), $this->getProduct()->getWebsiteIds())) {
00133                         continue;
00134                     }
00135                     $websites[$website->getId()] = array(
00136                         'name'      => $website->getName(),
00137                         'currency'  => $website->getConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
00138                     );
00139                 }
00140             }
00141         }
00142         $this->_websites = $websites;
00143         return $this->_websites;
00144     }

isMultiWebsites (  ) 

Definition at line 97 of file Tax.php.

00098     {
00099         return !Mage::app()->isSingleStoreMode();
00100     }

render ( Varien_Data_Form_Element_Abstract element  ) 

Implements Varien_Data_Form_Element_Renderer_Interface.

Definition at line 51 of file Tax.php.

00052     {
00053         $this->setElement($element);
00054         $this->_setAddButton();
00055         return $this->toHtml();
00056     }

setElement ( Varien_Data_Form_Element_Abstract element  ) 

Definition at line 58 of file Tax.php.

00059     {
00060         $this->_element = $element;
00061         return $this;
00062     }


Member Data Documentation

$_countries = null [protected]

Definition at line 38 of file Tax.php.

$_element = null [protected]

Definition at line 37 of file Tax.php.

$_websites = null [protected]

Definition at line 39 of file Tax.php.


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

Generated on Sat Jul 4 17:24:56 2009 for Magento by  doxygen 1.5.8