00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 class Mage_Checkout_Block_Cart_Totals extends Mage_Checkout_Block_Cart_Abstract
00028 {
00029 protected $_totalRenderers;
00030 protected $_defaultRenderer = 'checkout/total_default';
00031
00032 protected $_totals = null;
00033
00034 public function getTotals()
00035 {
00036 if (is_null($this->_totals)) {
00037 return parent::getTotals();
00038 }
00039 return $this->_totals;
00040 }
00041
00042 public function setTotals($value)
00043 {
00044 $this->_totals = $value;
00045 return $this;
00046 }
00047
00048 protected function _getTotalRenderer($code)
00049 {
00050 if (!isset($this->_totalRenderers[$code])) {
00051 $this->_totalRenderers[$code] = $this->_defaultRenderer;
00052 $config = Mage::getConfig()->getNode("global/sales/quote/totals/{$code}/renderer");
00053 if ($config)
00054 $this->_totalRenderers[$code] = (string) $config;
00055
00056 $this->_totalRenderers[$code] = $this->getLayout()->createBlock($this->_totalRenderers[$code], "{$code}_total_renderer");
00057 }
00058
00059 return $this->_totalRenderers[$code];
00060 }
00061
00062 public function renderTotal($total, $area = null, $colspan = 1)
00063 {
00064 $code = $total->getCode();
00065 if ($total->getAs()) {
00066 $code = $total->getAs();
00067 }
00068 return $this->_getTotalRenderer($code)
00069 ->setTotal($total)
00070 ->setColspan($colspan)
00071 ->setRenderingArea(is_null($area) ? -1 : $area)
00072 ->toHtml();
00073 }
00074
00075 public function renderTotals($area = null, $colspan = 1)
00076 {
00077 $html = '';
00078
00079 foreach($this->getTotals() as $total) {
00080 if ($total->getArea() != $area && $area != -1) {
00081 continue;
00082 }
00083
00084 $html .= $this->renderTotal($total, $area, $colspan);
00085 }
00086
00087 return $html;
00088 }
00089 }