Public Member Functions | |
__construct () | |
Protected Member Functions | |
_prepareLayout () | |
getRatesFormAction () | |
_prepareRates ($array) |
Definition at line 34 of file Matrix.php.
__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 36 of file Matrix.php.
_prepareLayout | ( | ) | [protected] |
Preparing global layout
You can redefine this method in child classes for changin layout
Reimplemented from Mage_Core_Block_Abstract.
Definition at line 41 of file Matrix.php.
00042 { 00043 $newRates = Mage::getSingleton('adminhtml/session')->getRates(); 00044 Mage::getSingleton('adminhtml/session')->unsetData('rates'); 00045 00046 $currencyModel = Mage::getModel('directory/currency'); 00047 $currencies = $currencyModel->getConfigAllowCurrencies(); 00048 $defaultCurrencies = $currencyModel->getConfigBaseCurrencies(); 00049 $oldCurrencies = $this->_prepareRates($currencyModel->getCurrencyRates($defaultCurrencies, $currencies)); 00050 00051 foreach( $currencies as $currency ) { 00052 foreach( $oldCurrencies as $key => $value ) { 00053 if( !array_key_exists($currency, $oldCurrencies[$key]) ) { 00054 $oldCurrencies[$key][$currency] = ''; 00055 } 00056 } 00057 } 00058 00059 foreach( $oldCurrencies as $key => $value ) { 00060 ksort($oldCurrencies[$key]); 00061 } 00062 00063 sort($currencies); 00064 00065 $this->setAllowedCurrencies($currencies) 00066 ->setDefaultCurrencies($defaultCurrencies) 00067 ->setOldRates($oldCurrencies) 00068 ->setNewRates($this->_prepareRates($newRates)); 00069 00070 return parent::_prepareLayout(); 00071 }
_prepareRates | ( | $ | array | ) | [protected] |
Definition at line 78 of file Matrix.php.
00079 { 00080 if( !is_array($array) ) { 00081 return $array; 00082 } 00083 00084 foreach ($array as $key => $rate) { 00085 foreach ($rate as $code => $value) { 00086 $parts = explode('.', $value); 00087 if( sizeof($parts) == 2 ) { 00088 $parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT); 00089 $array[$key][$code] = join('.', $parts); 00090 } elseif( $value > 0 ) { 00091 $array[$key][$code] = number_format($value, 4); 00092 } else { 00093 $array[$key][$code] = null; 00094 } 00095 } 00096 } 00097 return $array; 00098 }
getRatesFormAction | ( | ) | [protected] |
Definition at line 73 of file Matrix.php.
00074 { 00075 return $this->getUrl('*/*/saveRates'); 00076 }