From b6e760ce6d34be6705a3bc890febae6452396f78 Mon Sep 17 00:00:00 2001 From: "Ivan.Zolotarev" Date: Thu, 8 Jan 2026 17:27:14 +0600 Subject: [PATCH] hw5 Add component otus currency rate --- .../otus/currency.rate/.description.php | 21 ++++++++++ .../otus/currency.rate/.parameters.php | 36 ++++++++++++++++ local/components/otus/currency.rate/class.php | 41 +++++++++++++++++++ .../currency.rate/lang/ru/.description.php | 3 ++ .../currency.rate/lang/ru/.parameters.php | 2 + .../otus/currency.rate/lang/ru/class.php | 2 + .../templates/.default/lang/ru/template.php | 2 + .../templates/.default/template.php | 23 +++++++++++ otus/currencies.php | 20 +++++++++ 9 files changed, 150 insertions(+) create mode 100644 local/components/otus/currency.rate/.description.php create mode 100644 local/components/otus/currency.rate/.parameters.php create mode 100644 local/components/otus/currency.rate/class.php create mode 100644 local/components/otus/currency.rate/lang/ru/.description.php create mode 100644 local/components/otus/currency.rate/lang/ru/.parameters.php create mode 100644 local/components/otus/currency.rate/lang/ru/class.php create mode 100644 local/components/otus/currency.rate/templates/.default/lang/ru/template.php create mode 100644 local/components/otus/currency.rate/templates/.default/template.php create mode 100644 otus/currencies.php diff --git a/local/components/otus/currency.rate/.description.php b/local/components/otus/currency.rate/.description.php new file mode 100644 index 0000000..832aa63 --- /dev/null +++ b/local/components/otus/currency.rate/.description.php @@ -0,0 +1,21 @@ + Loc::getMessage("OTUS_CURRENCY_RATE_COMPONENT_NAME"), + 'DESCRIPTION' => Loc::getMessage("OTUS_CURRENCY_RATE_COMPONENT_DESCRIPTION"), + "SORT" => 20, + 'PATH' => [ + 'ID' => 'otus', + 'NAME' => 'otus', + 'CHILD' => [ + 'ID' => 'otus.currency.rate', + 'NAME' => Loc::getMessage("OTUS_CURRENCY_RATE_COMPONENT_NAME"), + ], + ], +]; \ No newline at end of file diff --git a/local/components/otus/currency.rate/.parameters.php b/local/components/otus/currency.rate/.parameters.php new file mode 100644 index 0000000..42ac20f --- /dev/null +++ b/local/components/otus/currency.rate/.parameters.php @@ -0,0 +1,36 @@ + ['CURRENCY'], + 'order' => ['SORT' => 'ASC'] +]); + +$listCurrencies = []; + +while ($currency = $result->fetch()) { + + $listCurrencies[$currency['CURRENCY']] = $currency['CURRENCY']; + +} + + +$arComponentParameters = array( + + "PARAMETERS" => array( + "CURRENCY_CODE" => array( + "PARENT" => "BASE", + "NAME"=> Loc::getMessage("OTUS_CURRENCY_RATE_LIST"), + "TYPE" => "LIST", + "VALUES" => $listCurrencies, + ), + ) +); diff --git a/local/components/otus/currency.rate/class.php b/local/components/otus/currency.rate/class.php new file mode 100644 index 0000000..73f7687 --- /dev/null +++ b/local/components/otus/currency.rate/class.php @@ -0,0 +1,41 @@ +arParams['CURRENCY_CODE']){ + $this->arResult['CURRENCY'] = CurrencyTable::getById($this->arParams['CURRENCY_CODE'])->fetch(); + } + else { + $this->arResult['CURRENCY'] = false; + } + + + $this->includeComponentTemplate(); + } +} \ No newline at end of file diff --git a/local/components/otus/currency.rate/lang/ru/.description.php b/local/components/otus/currency.rate/lang/ru/.description.php new file mode 100644 index 0000000..f2dbeba --- /dev/null +++ b/local/components/otus/currency.rate/lang/ru/.description.php @@ -0,0 +1,3 @@ +setFrameMode(true); + + +if($arResult['CURRENCY']){?> +
+ - +
+SetTitle("Валюты"); +?>IncludeComponent( + "otus:currency.rate", + ".default", + [ + "CACHE_TIME" => "3600", + "CACHE_TYPE" => "A", + "CURRENCY_CODE" => "EUR", + "COMPONENT_TEMPLATE" => ".default" + ], + false +);?> + +