Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
catalogsectiontab.php
1<?
2
4
5use \Bitrix\Main\SystemException;
7
8Loc::loadMessages(__FILE__);
9
16{
17 protected static $tabHandlers = array();
18
19 public static function OnInit($args)
20 {
21 $result = array();
22
23 $res = \Bitrix\Sale\TradingPlatformTable::getList(array(
24 'select' => array("ID", "CODE", "CATALOG_SECTION_TAB_CLASS_NAME"),
25 'filter' => array('=ACTIVE' => 'Y'),
26 ));
27
28 while($arRes = $res->fetch())
29 {
30 if($arRes["CATALOG_SECTION_TAB_CLASS_NAME"] <> '' && class_exists($arRes["CATALOG_SECTION_TAB_CLASS_NAME"]))
31 {
32 $tabHandler = new $arRes["CATALOG_SECTION_TAB_CLASS_NAME"];
33
34 if(!($tabHandler instanceof TabHandler))
35 throw new SystemException("TabHandler (".$arRes["CODE"].") has wrong instance. (".__CLASS__."::".__METHOD__.")");
36
37 self::$tabHandlers[$arRes["CODE"]] = $tabHandler;
38 }
39 }
40
41 if(!empty(self::$tabHandlers))
42 {
43 //todo: iblock filter
44 $result = array(
45 "TABSET" => "SALE_TRADING_PLATFORM",
46 "GetTabs" => array("\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab", "GetTabs"),
47 "ShowTab" => array("\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab", "ShowTab"),
48 "Action" => array("\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab", "Action"),
49 "Check" => array("\\Bitrix\\Sale\\TradingPlatform\\CatalogSectionTab", "Check"),
50 );
51 }
52
53 return $result;
54 }
55
56 public static function Action($arArgs)
57 {
59 global $APPLICATION;
60 $result = true;
61
62 foreach(self::$tabHandlers as $handler)
63 {
65 try
66 {
67 $result = $handler->action($arArgs);
68 }
69 catch(SystemException $e)
70 {
71 $APPLICATION->ThrowException($e->getMessage());
72 $result = false;
73 break;
74 }
75 }
76
77 return $result;
78 }
79
80 public static function Check($arArgs)
81 {
83 global $APPLICATION;
84 $result = true;
85
86 foreach(self::$tabHandlers as $handler)
87 {
89 try
90 {
91 $result = $handler->check($arArgs);
92 }
93 catch(SystemException $e)
94 {
95 $APPLICATION->ThrowException($e->getMessage());
96 $result = false;
97 break;
98 }
99 }
100
101 return $result;
102 }
103
104 public static function GetTabs($arArgs)
105 {
106 $arTabs = array(
107 array(
108 "DIV" => "edit_trading_platforms",
109 "TAB" => Loc::getMessage('SALE_TRADING_PLATFORMS_TAB'),
110 "ICON" => "sale",
111 "TITLE" => Loc::getMessage('SALE_TRADING_PLATFORMS_TAB_TITLE'),
112 ),
113 );
114 return $arTabs;
115 }
116
117 // arArgs = array("ID" => $ID, "IBLOCK"=>$arIBlock, "IBLOCK_TYPE"=>$arIBTYPE)
118 public static function ShowTab($divName, $arArgs, $bVarsFromForm)
119 {
120 if ($divName == "edit_trading_platforms")
121 {
122 $result = "";
123
124 foreach(self::$tabHandlers as $tradingPlatformCode => $handler)
125 {
127 $header = '<tr class="heading" id="tr_'.$tradingPlatformCode.'"><td colspan="2">'.$handler->name.'</td></tr>';
128 $body = $handler->showTabSection($divName, $arArgs, $bVarsFromForm);
129
130 if($body == '')
131 $body = '<tr><td colspan="2">'.Loc::getMessage('SALE_TRADING_PLATFORMS_NOT_ACTIVE').' ('.$siteId = $arArgs["IBLOCK"]["LID"].')</td></tr>';
132
133 $result .= $header.$body;
134 }
135
136 echo $result;
137 }
138 }
139}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29