Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
editor.php
1<?php
3
5
6class Editor
7{
8 protected static array $listCurrencyCache;
9
10 public static function getListCurrency(): array
11 {
12 if (!isset(static::$listCurrencyCache))
13 {
14 static::$listCurrencyCache = [];
15
16 $separators = \CCurrencyLang::GetSeparators();
17 $defaultFormat = \CCurrencyLang::GetDefaultValues();
18 $defaultFormat['SEPARATOR'] = $separators[$defaultFormat['THOUSANDS_VARIANT']];
19
20 $iterator = Currency\CurrencyTable::getList([
21 'select' => [
22 'CURRENCY',
23 'BASE',
24 'SORT',
25 ],
26 'order' => [
27 'SORT' => 'ASC',
28 'CURRENCY' => 'ASC',
29 ],
30 ]);
31 while ($row = $iterator->fetch())
32 {
33 unset($row['SORT']);
34 $row['NAME'] = $row['CURRENCY'];
35 static::$listCurrencyCache[$row['CURRENCY']] = array_merge($row, $defaultFormat);
36 }
37 if (!empty(static::$listCurrencyCache))
38 {
39 $iterator = Currency\CurrencyLangTable::getList([
40 'select' => [
41 'CURRENCY',
42 'FULL_NAME',
43 'FORMAT_STRING',
44 'DEC_POINT',
45 'THOUSANDS_VARIANT',
46 'DECIMALS',
47 'THOUSANDS_SEP',
48 'HIDE_ZERO',
49 ],
50 'filter' => [
51 '@CURRENCY' => array_keys(static::$listCurrencyCache),
52 '=LID' => LANGUAGE_ID,
53 ],
54 ]);
55 while ($row = $iterator->fetch())
56 {
57 $currencyId = $row['CURRENCY'];
58 $row['FULL_NAME'] = (string)$row['FULL_NAME'];
59 if ($row['FULL_NAME'] !== '')
60 {
61 static::$listCurrencyCache[$currencyId]['NAME'] = $row['FULL_NAME'];
62 }
63
64 unset($row['FULL_NAME'], $row['CURRENCY']);
65 static::$listCurrencyCache[$currencyId] = array_merge(
66 static::$listCurrencyCache[$currencyId],
67 $row
68 );
69
70 if ($row['THOUSANDS_VARIANT'] !== null && isset($separators[$row['THOUSANDS_VARIANT']]))
71 {
72 static::$listCurrencyCache[$currencyId]['SEPARATOR'] = $separators[$row['THOUSANDS_VARIANT']];
73 if ($row['THOUSANDS_VARIANT'] == Currency\CurrencyClassifier::SEPARATOR_NBSPACE)
74 {
75 static::$listCurrencyCache[$currencyId]['SEPARATOR'] = ' ';
76 }
77 }
78 else
79 {
80 static::$listCurrencyCache[$currencyId]['SEPARATOR'] = $row['THOUSANDS_SEP'];
81 }
82 }
83 }
84 unset($row, $iterator);
85 }
86
87 return static::$listCurrencyCache;
88 }
89}
static array $listCurrencyCache
Definition editor.php:8