Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
currency.php
1<?php
2
4
8
10{
16 public static function getDefaultValue()
17 {
18 return in_array($current = self::getDefaultCurrency(),static::getCurrencyList())? $current : 'USD';
19 }
20
21 private static function getDefaultCurrency()
22 {
23 if (Loader::includeModule('bitrix24') && is_array($currencies = \CBitrix24::GetAvBillingCurrencies()))
24 {
25 $currentCurrency = current($currencies);
26 return $currentCurrency !== 'RUR'? $currentCurrency : 'RUB';
27 }
28
29 if (Loader::includeModule('currency'))
30 {
31 return CurrencyManager::getBaseCurrency();
32 }
33 return false;
34 }
35
45 public static function checkValue($value): bool
46 {
47 if(is_string($value))
48 {
49 return in_array($value,static::getAvailableValues());
50 }
51 return false;
52 }
53
60 public static function getAvailableValues(): array
61 {
62 return static::getCurrencyList();
63 }
64
68 public static function available(): bool
69 {
70 return true;
71
72 }
73
77 public static function required(): bool
78 {
79 return true;
80 }
81
82 public static function getCurrencyList() : array
83 {
84 return [
85 'DZD', 'ARS', 'AUD', 'BDT', 'BOB', 'BRL', 'GBP', 'CAD', 'CLP', 'CNY', 'COP', 'CRC', 'CZK', 'DKK', 'EGP', 'EUR',
86 'GTQ', 'HNL', 'HKD', 'HUF', 'ISK', 'INR', 'IDR', 'ILS', 'JPY', 'KES', 'KRW', 'MOP', 'MYR', 'MXN', 'NZD', 'NIO',
87 'NGN', 'NOK', 'PKR', 'PYG', 'PEN', 'PHP', 'PLN', 'QAR', 'RON', 'RUB', 'SAR', 'SGD', 'ZAR', 'SEK', 'CHF', 'TWD',
88 'THB', 'TRY', 'AED', 'USD', 'UYU', 'VEF', 'VND'
89 ];
90 }
91}