Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
tools.php
1<?php
2
4
10
17class Tools
18{
24 public static function getPriceTypeLinkList(): array
25 {
26 global $adminPage, $adminSidePanelHelper;
27
28 $selfFolderUrl = $adminPage->getSelfFolderUrl();
29
30 if (!(
31 AccessController::getCurrent()->check(ActionDictionary::ACTION_CATALOG_READ)
32 || AccessController::getCurrent()->check(ActionDictionary::ACTION_PRICE_GROUP_EDIT)
33 ))
34 {
35 return [];
36 }
37
38 $priceTypeLinkTitle = Main\Text\HtmlFilter::encode(
39 AccessController::getCurrent()->check(ActionDictionary::ACTION_PRICE_GROUP_EDIT)
40 ? Loc::getMessage('CATALOG_HELPERS_ADMIN_TOOLS_MESS_PRICE_TYPE_EDIT_TITLE')
41 : Loc::getMessage('CATALOG_HELPERS_ADMIN_TOOLS_MESS_PRICE_TYPE_VIEW_TITLE')
42 );
43
44 $priceTypeList = Catalog\GroupTable::getTypeList();
45 if (empty($priceTypeList))
46 {
47 return [];
48 }
49 $result = [];
50 foreach ($priceTypeList as $priceType)
51 {
52 $id = $priceType['ID'];
53 $title = $priceType['NAME_LANG'];
54 $fullTitle = '['. $id .'] [' . $priceType['NAME'] . ']' . ($title !== null ? ' ' . $title : '');
55 $editUrl = $selfFolderUrl . 'cat_group_edit.php?ID=' . $id . '&lang=' . LANGUAGE_ID;
56 $editUrl = $adminSidePanelHelper->editUrlToPublicPage($editUrl);
57 $result[$id] =
58 '<a href="' . $editUrl . '"'
59 . ' title="' . Main\Text\HtmlFilter::encode($priceTypeLinkTitle) . '">'
60 . Main\Text\HtmlFilter::encode($fullTitle)
61 . '</a>'
62 ;
63
64 unset($fullTitle, $title, $id);
65 }
66 unset($priceType, $priceTypeList, $priceTypeLinkTitle);
67
68 return $result;
69 }
70
77 public static function getPriceTypeList(bool $codeIndex = false): array
78 {
79 $result = [];
80 $codeIndex = ($codeIndex === true);
81
82 foreach (Catalog\GroupTable::getTypeList() as $priceType)
83 {
84 $id = $priceType['ID'];
85 $title = $priceType['NAME_LANG'];
86 $index = ($codeIndex ? $priceType['NAME'] : $id);
87 $result[$index] = '['. $id .'] [' . $priceType['NAME'] . ']' . ($title !== null ? ' ' . $title : '');
88 unset($index, $title, $id);
89 }
90 unset($priceType);
91
92 return $result;
93 }
94}
static getPriceTypeList(bool $codeIndex=false)
Definition tools.php:77
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29