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
00028
00029
00030
00031
00032
00033
00034 class Mage_Downloadable_Block_Catalog_Product_Links extends Mage_Catalog_Block_Product_Abstract
00035 {
00036
00037
00038
00039
00040
00041 public function getLinksPurchasedSeparately()
00042 {
00043 return $this->getProduct()->getLinksPurchasedSeparately();
00044 }
00045
00046
00047
00048
00049
00050
00051 public function getLinkSelectionRequired()
00052 {
00053 return $this->getProduct()->getTypeInstance(true)
00054 ->getLinkSelectionRequired($this->getProduct());
00055 }
00056
00057
00058
00059
00060
00061
00062 public function hasLinks()
00063 {
00064 return $this->getProduct()->getTypeInstance(true)
00065 ->hasLinks($this->getProduct());
00066 }
00067
00068
00069
00070
00071
00072
00073 public function getLinks()
00074 {
00075 return $this->getProduct()->getTypeInstance(true)
00076 ->getLinks($this->getProduct());
00077 }
00078
00079
00080
00081
00082
00083
00084
00085 public function getFormattedLinkPrice($link)
00086 {
00087 $price = $link->getPrice();
00088
00089 if (0 == $price) {
00090 return '';
00091 }
00092
00093 $_priceInclTax = Mage::helper('tax')->getPrice($link->getProduct(), $price, true);
00094 $_priceExclTax = Mage::helper('tax')->getPrice($link->getProduct(), $price);
00095
00096 $priceStr = '<span class="price-notice">+';
00097 if (Mage::helper('tax')->displayPriceIncludingTax()) {
00098 $priceStr .= $this->helper('core')->currency($_priceInclTax, true, true);
00099 } elseif (Mage::helper('tax')->displayPriceExcludingTax()) {
00100 $priceStr .= $this->helper('core')->currency($_priceExclTax, true, true);
00101 } elseif (Mage::helper('tax')->displayBothPrices()) {
00102 $priceStr .= $this->helper('core')->currency($_priceExclTax, true, true);
00103 if ($_priceInclTax != $_priceExclTax) {
00104 $priceStr .= ' (+'.$this->helper('core')
00105 ->currency($_priceInclTax, true, true).' '.$this->__('Incl. Tax').')';
00106 }
00107 }
00108 $priceStr .= '</span>';
00109
00110 return $priceStr;
00111 }
00112
00113
00114
00115
00116
00117
00118 public function getJsonConfig()
00119 {
00120 $config = array();
00121
00122 foreach ($this->getLinks() as $link) {
00123 $config[$link->getId()] = Mage::helper('core')->currency($link->getPrice(), false, false);
00124 }
00125
00126 return Zend_Json::encode($config);
00127 }
00128
00129 public function getLinkSamlpeUrl($link)
00130 {
00131 return $this->getUrl('downloadable/download/linkSample', array('link_id' => $link->getId()));
00132 }
00133
00134
00135
00136
00137
00138
00139 public function getLinksTitle()
00140 {
00141 if ($this->getProduct()->getLinksTitle()) {
00142 return $this->getProduct()->getLinksTitle();
00143 }
00144 return Mage::getStoreConfig(Mage_Downloadable_Model_Link::XML_PATH_LINKS_TITLE);
00145 }
00146
00147
00148
00149
00150
00151
00152 public function getIsOpenInNewWindow()
00153 {
00154 return Mage::getStoreConfigFlag(Mage_Downloadable_Model_Link::XML_PATH_TARGET_NEW_WINDOW);
00155 }
00156
00157 }