<?
/**************************************************************************
Компонент для вывода курсов валют
***************************************************************************/
global $USER, $APPLICATION;
if (CModule::IncludeModule("currency")):
IncludeTemplateLangFile(__FILE__);
/*************************************************************************
Инициализируем начальные параметры компонента
*************************************************************************/
/*
$arrCURRENCY_FROM = $arParams["arrCURRENCY_FROM"]; // массив переводимых валют
$CURRENCY_BASE = $arParams["CURRENCY_BASE"]; // валюта, к которой приводятся все значения
$RATE_DAY = $arParams["RATE_DAY"]; // дата курсов в формате "Y-m-d"
$CACHE_TIME = $arParams["CACHE_TIME"]; // время кэширования (сек.)
*/
$CACHE_TIME = IntVal($CACHE_TIME);
$CACHE_ID = __FILE__.md5(serialize($arParams));
$obCache = new CPHPCache;
if($obCache->StartDataCache($CACHE_TIME, $CACHE_ID, "/")):
if (is_array($arrCURRENCY_FROM) && count($arrCURRENCY_FROM) > 0)
$strings = count($arrCURRENCY_FROM);
if (strlen($CURRENCY_BASE) <= 0):
if ($CURRENCY_BASE = COption::GetOptionString("sale", "default_currency"))
{
}
else
{
$rsCurrency = CCurrency::GetList(($by="SORT"), ($order="ASC"));
$arCurrency = $rsCurrency->Fetch();
$CURRENCY_BASE = $arCurrency["CURRENCY"];
}
endif;
if (strlen($RATE_DAY)<=0):
$RATE_DAY_SHOW = GetTime(time(), "SHORT", LANGUAGE_ID);
else:
$arRATE_DAY_PARSED = ParseDate($RATE_DAY, "ymd");
$RATE_DAY_SHOW = GetTime(mktime(0, 0, 0, $arRATE_DAY_PARSED[1], $arRATE_DAY_PARSED[0], $arRATE_DAY_PARSED[2]), "D.M.Y", LANGUAGE_ID);
endif;
if ($strings > 0):
// format "to" currency
$arCurFormatBase = CCurrencyLang::GetCurrencyFormat($CURRENCY_BASE);
if (!isset($arCurFormatBase["DECIMALS"]))
$arCurFormatBase["DECIMALS"] = 2;
$arCurFormatBase["DECIMALS"] = IntVal($arCurFormatBase["DECIMALS"]);
if (!isset($arCurFormatBase["DEC_POINT"]))
$arCurFormatBase["DEC_POINT"] = ".";
if (!isset($arCurFormatBase["THOUSANDS_SEP"]))
$arCurFormatBase["THOUSANDS_SEP"] = "\\"."xA0";
$tmpTHOUSANDS_SEP = $arCurFormatBase["THOUSANDS_SEP"];
eval("\$tmpTHOUSANDS_SEP = \"$tmpTHOUSANDS_SEP\";");
$arCurFormatBase["THOUSANDS_SEP"] = $tmpTHOUSANDS_SEP;
if (!isset($arCurFormatBase["FORMAT_STRING"]))
$arCurFormatBase["FORMAT_STRING"] = "#";
?>
<table cellspacing=1 cellpadding=2 border=0 align="center">
<?
for ($i=0; $i<$strings; $i++)
{
if ($arCurrencyFrom = CCurrency::GetByID($arrCURRENCY_FROM[$i])):
$arCurFormat = CCurrencyLang::GetCurrencyFormat($arCurrencyFrom["CURRENCY"]);
if (!isset($arCurFormat["DECIMALS"]))
$arCurFormat["DECIMALS"] = 2;
// $arCurFormat["DECIMALS"] = IntVal($arCurFormat["DECIMALS"]);
$arCurFormat["DECIMALS"] = 0;
if (!isset($arCurFormat["DEC_POINT"]))
$arCurFormat["DEC_POINT"] = ".";
if (!isset($arCurFormat["THOUSANDS_SEP"]))
$arCurFormat["THOUSANDS_SEP"] = &q |