Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
helper.php
1<?php
2
4
10
11Loc::loadMessages(__FILE__);
12
17class Helper
18{
26 public static function getCurrenciesList()
27 {
28 static $currencies = null;
29
30 if($currencies === null)
31 {
32 $currencies = array();
33
34 if (!\Bitrix\Main\Loader::includeModule('currency'))
35 throw new SystemException("Can't include module \"Currency\"!");
36
37 $currencies = Currency\CurrencyManager::getCurrencyList();
38 }
39
40 return $currencies;
41 }
42
49 protected static function createTreeFromGroups($flatGroups)
50 {
51 $result = array();
52
53 foreach($flatGroups as $groupId => $groupParams)
54 {
55 if(intval($groupParams["PARENT_ID"]) <= 0)
56 {
57 $groupParams["LEVEL"] = 1;
58 $groupParams["NAME"] = " . ".$groupParams["NAME"];
59 $result[$groupId] = $groupParams;
60 }
61 else
62 {
63 $groupParams["LEVEL"] = $result[$groupParams["PARENT_ID"]]["LEVEL"]+1;
64 $groupParams["NAME"] = str_repeat(" . ", $groupParams["LEVEL"]+1).$groupParams["NAME"];
65 $result[$groupId] = $groupParams;
66 }
67 }
68 return $result;
69 }
70
80 public static function getGroupChooseControl($selectedGroupId, $name, $addParams = "", $anyGroup = false)
81 {
82 $groups = array();
83
84 $dbRes = \Bitrix\Sale\Delivery\Services\Table::getList(array(
85 "filter" => array(
86 "=CLASS_NAME" => '\Bitrix\Sale\Delivery\Services\Group'
87 ),
88 "select" => array(
89 "ID", "NAME", "PARENT_ID"
90 ),
91 "order" => array(
92 "PARENT_ID" => "ASC",
93 "NAME" => "ASC"
94 )
95 ));
96
97 while($group = $dbRes->fetch())
98 $groups[$group["ID"]] = $group;
99
100 //$groups = self::createTreeFromGroups($groups);
101 $result = '<select name='.$name.' id="sale_delivery_group_choose"'.$addParams.'>';
102
103 if($anyGroup)
104 $result .= '<option value="-1"'.($selectedGroupId == "-1" ? ' selected' : '').'>'.Loc::getMessage('SALE_DELIVERY_HELPER_ANY_LEVEL').'</option>';
105
106 $result .= '<option value="0"'.($selectedGroupId == 0 ? ' selected' : '').'>'.Loc::getMessage('SALE_DELIVERY_HELPER_UPPER_LEVELL').'</option>';
107
108 foreach($groups as $groupId => $group)
109 $result .= '<option value="'.$groupId.'"'.($selectedGroupId == $groupId ? ' selected' : '').'>'.htmlspecialcharsbx($group["NAME"]).'</option>';
110
111 $result .= '</select>';
112
113 return $result;
114 }
115
122 public static function getDefaultSiteId()
123 {
124 static $result = null;
125
126 if($result === null)
127 {
128 $res = \Bitrix\Main\SiteTable::getList(array(
129 'filter' => array('DEF' => 'Y'),
130 'select' => array('LID')
131 ));
132
133 if($item = $res->fetch())
134 $result = $item['LID'];
135 }
136
137 return $result;
138 }
139
143 public static function additionalHandlerCacheClean()
144 {
145 require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/sale/handlers/delivery/additional/cache.php");
146 \Sale\Handlers\Delivery\Additional\CacheManager::cleanAll();
147 }
148
155 public static function getPortalZone(): string
156 {
157 static $result = null;
158
159 if ($result === null)
160 {
161 $result = '';
162
164 && Loader::includeModule('bitrix24')
165 )
166 {
167 $result = \CBitrix24::getLicensePrefix();
168 }
169 elseif (ModuleManager::isModuleInstalled('intranet')
170 && Loader::includeModule('intranet')
171 )
172 {
173 $result = \CIntranetUtils::getPortalZone();
174 }
175 }
176
177 return (string)$result;
178 }
179}
static includeModule($moduleName)
Definition loader.php:69
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static isModuleInstalled($moduleName)
static createTreeFromGroups($flatGroups)
Definition helper.php:49
static getGroupChooseControl($selectedGroupId, $name, $addParams="", $anyGroup=false)
Definition helper.php:80
static additionalHandlerCacheClean()
Definition helper.php:143