/** * Smarty function * ------------------------------------------------------------- * Purpose: Output price string * add [{oxprice price="..." currency="..."}] where you want to display content * price - decimal number: 13; 12.45; 13.01; * currency - currency abbreviation: EUR, USD, LTL etc. * ------------------------------------------------------------- * * @param array $params params * @param Smarty &$smarty clever simulation of a method * * @return string */ function smarty_function_oxprice($params, &$smarty) { $sOutput = ''; $iDecimals = 2; $sDecimalsSeparator = ','; $sThousandSeparator = '.'; $sCurrencySign = ''; $sSide = ''; $mPrice = $params['price']; if (!is_null($mPrice)) { $oConfig = Registry::getConfig(); $sPrice = $mPrice instanceof \OxidEsales\EshopCommunity\Core\Price ? $mPrice->getPrice() : $mPrice; $oCurrency = isset($params['currency']) ? $params['currency'] : $oConfig->getActShopCurrencyObject(); if (!is_null($oCurrency)) { $sDecimalsSeparator = isset($oCurrency->dec) ? $oCurrency->dec : $sDecimalsSeparator; $sThousandSeparator = isset($oCurrency->thousand) ? $oCurrency->thousand : $sThousandSeparator; $sCurrencySign = isset($oCurrency->sign) ? $oCurrency->sign : $sCurrencySign; $sSide = isset($oCurrency->side) ? $oCurrency->side : $sSide; $iDecimals = isset($oCurrency->decimal) ? (int) $oCurrency->decimal : $iDecimals; } if (is_numeric($sPrice)) { if ((double) $sPrice > 0 || $sCurrencySign) { $sPrice = number_format($sPrice, $iDecimals, $sDecimalsSeparator, $sThousandSeparator); $sOutput = isset($sSide) && $sSide == 'Front' ? $sCurrencySign . $sPrice : $sPrice . ' ' . $sCurrencySign; } $sOutput = trim($sOutput); } } return $sOutput; }
/** * _getArticleItems create channel items from article list * * @param oxArticleList $oList article list * * @access protected * @return array */ protected function _getArticleItems(ArticleList $oList) { $myUtilsUrl = Registry::get("oxUtilsUrl"); $aItems = array(); $oLang = Registry::getLang(); $oStr = getStr(); foreach ($oList as $oArticle) { $oItem = new stdClass(); $oActCur = $this->getConfig()->getActShopCurrencyObject(); $sPrice = ''; if ($oPrice = $oArticle->getPrice()) { $sFrom = $oArticle->isRangePrice() ? Registry::getLang()->translateString('PRICE_FROM') . " " : ''; $sPrice .= ' ' . $sFrom . $oLang->formatCurrency($oPrice->getBruttoPrice(), $oActCur) . " " . $oActCur->sign; } $oItem->title = strip_tags($oArticle->oxarticles__oxtitle->value . $sPrice); $oItem->guid = $oItem->link = $myUtilsUrl->prepareUrlForNoSession($oArticle->getLink()); $oItem->isGuidPermalink = true; // $oItem->description = $oArticle->getLongDescription()->value; //oxarticles__oxshortdesc->value; //#4038: Smarty not parsed in RSS, although smarty parsing activated for longdescriptions if (Registry::getConfig()->getConfigParam('bl_perfParseLongDescinSmarty')) { $oItem->description = $oArticle->getLongDesc(); } else { $oItem->description = $oArticle->getLongDescription()->value; } if (trim(str_replace(' ', '', strip_tags($oItem->description))) == '') { $oItem->description = $oArticle->oxarticles__oxshortdesc->value; } $oItem->description = trim($oItem->description); if ($sThumb = $oArticle->getThumbnailUrl()) { $oItem->description = "<img src='{$sThumb}' border=0 align='left' hspace=5>" . $oItem->description; } $oItem->description = $oStr->htmlspecialchars($oItem->description); if ($oArticle->oxarticles__oxtimestamp->value) { list($date, $time) = explode(' ', $oArticle->oxarticles__oxtimestamp->value); $date = explode('-', $date); $time = explode(':', $time); $oItem->date = date('D, d M Y H:i:s O', mktime($time[0], $time[1], $time[2], $date[1], $date[2], $date[0])); } else { $oItem->date = date('D, d M Y H:i:s O', time()); } $aItems[] = $oItem; } return $aItems; }