1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
component_params_manager.php
См. документацию.
1<?
6
9{
10 private static
11 $fileDialogs = array();
12
13 public static function Init($config = array())
14 {
15 global $APPLICATION;
16
17 \Bitrix\Main\UI\Extension::load(['ui.design-tokens']);
18 $APPLICATION->AddHeadScript('/bitrix/js/fileman/comp_params_manager/component_params_manager.js');
19 $APPLICATION->SetAdditionalCss('/bitrix/js/fileman/comp_params_manager/component_params_manager.css');
20
21 if (!isset($config['requestUrl']))
22 {
23 $config['requestUrl'] = '/bitrix/admin/fileman_component_params.php';
24 }
25
26 if (!isset($config['id']))
27 {
28 $config['id'] = 'bx_comp_params_manager_'.mb_substr(uniqid(mt_rand(), true), 0, 4);
29 }
30
31 $mess_lang = self::GetLangMessages();
32 ?>
33 <script>
34 BX.message(<?=CUtil::PhpToJSObject($mess_lang, false);?>);
35 if (window.BXComponentParamsManager)
36 {
37 window.oBXComponentParamsManager = new BXComponentParamsManager(<?=CUtil::PhpToJSObject($config)?>);
38 }
39 else
40 {
41 window.oBXComponentParamsManager = new top.BXComponentParamsManager(<?=CUtil::PhpToJSObject($config)?>);
42 }
43 top.oBXComponentParamsManager = window.oBXComponentParamsManager;
44 </script>
45 <?
46
47 // For colorpicker
48 $APPLICATION->IncludeComponent(
49 "bitrix:main.colorpicker",
50 "",
51 Array("SHOW_BUTTON" => "N"),
52 false
53 );
54 }
55
56 public static function ProcessRequest()
57 {
58 if (isset($_REQUEST['component_params_manager']))
59 {
60 $reqId = intval($_REQUEST['component_params_manager']);
61 $requestData = [
62 'component_name' => $_REQUEST['component_name'] ?? null,
63 'component_template' => $_REQUEST['component_template'] ?? null,
64 'site_template' => $_REQUEST['site_template'] ?? null,
65 'current_values' => $_REQUEST['current_values'] ?? null,
66 ];
68 $requestData['component_name'],
69 $requestData['component_template'],
70 $requestData['site_template'],
71 $requestData['current_values']
72 );
73
74 $templateMatch = false;
75 for ($i = 0, $l = count($result['templates']); $i < $l; $i++)
76 {
77 if (
78 $result['templates'][$i]['NAME'] == $requestData['component_template']
79 || ($requestData['component_template'] == '' && $result['templates'][$i]['NAME'] == '.default')
80 )
81 {
82 $templateMatch = true;
83 break;
84 }
85 }
86 if (!$templateMatch && $l > 0)
87 {
89 $requestData['component_name'],
90 $result['templates'][0]['NAME'],
91 $requestData['site_template'],
92 $requestData['current_values']
93 );
94 }
95
96 $result['description'] = CComponentUtil::GetComponentDescr($requestData['component_name']);
97 ?>
98 <script>
99 window.__bxResult['<?= $reqId?>'] = <?=CUtil::PhpToJSObject($result)?>;
100 </script>
101 <?
103 }
104 }
105
106 public static function GetComponentProperties($name = '', $template = '', $siteTemplate = '', $currentValues = array())
107 {
108 $template = (!$template || $template == '.default') ? '' : $template;
109 $arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate);
110
111 $result = array(
112 'templates' => array()
113 );
114
115 $arSiteTemplates = array(".default" => GetMessage("PAR_MAN_DEFAULT"));
116 if(!empty($siteTemplate))
117 {
118 $dbst = CSiteTemplate::GetList(array(), array("ID" => $siteTemplate), array());
119 while($siteTempl = $dbst->Fetch())
120 $arSiteTemplates[$siteTempl['ID']] = $siteTempl['NAME'];
121 }
122
123 foreach($arTemplates as $k => $templ)
124 {
125 $showTemplateName = ($templ["TEMPLATE"] !== '' && $arSiteTemplates[$templ["TEMPLATE"]] <> '') ? $arSiteTemplates[$templ["TEMPLATE"]] : GetMessage("PAR_MAN_DEF_TEMPLATE");
126 $arTemplates[$k]['DISPLAY_NAME'] = $templ['NAME'].' ('.$showTemplateName.')';
127 }
128
129 $arTemplateProps = array();
130 if (is_array($arTemplates))
131 {
132 foreach ($arTemplates as $arTemplate)
133 {
134 $result['templates'][] = $arTemplate;
135 $tName = (!$arTemplate['NAME'] || $arTemplate['NAME'] == '.default') ? '' : $arTemplate['NAME'];
136
137 if ($tName == $template)
138 {
139 $arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $currentValues);
140 }
141 }
142 }
143
144 $result['parameters'] = array();
145 $arProps = CComponentUtil::GetComponentProps($name, $currentValues, $arTemplateProps);
146 $result['tooltips'] = self::FetchHelp($name);
147
148 if (!isset($arProps['GROUPS']) || !is_array($arProps['GROUPS']))
149 {
150 $arProps['GROUPS'] = array();
151 }
152 if (!isset($arProps['PARAMETERS']) || !is_array($arProps['PARAMETERS']))
153 {
154 $arProps['PARAMETERS'] = array();
155 }
156
157 $result['groups'] = array();
158 foreach ($arProps['GROUPS'] as $k => $arGroup)
159 {
160 $arGroup['ID'] = $k;
161 $result['groups'][] = $arGroup;
162 }
163
164 foreach ($arProps['PARAMETERS'] as $k => $arParam)
165 {
166 $arParam['ID'] = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $k);
167 if (!isset($arParam['PARENT']))
168 {
169 $arParam['PARENT'] = 'ADDITIONAL_SETTINGS';
170 }
171 $result['parameters'][] = $arParam;
172
173 if (($arParam['TYPE'] ?? null) == 'FILE')
174 {
175 self::$fileDialogs[] = array(
176 'NAME' => $arParam['ID'],
177 'TARGET' => isset($arParam['FD_TARGET']) ? $arParam['FD_TARGET'] : 'F',
178 'EXT' => isset($arParam['FD_EXT']) ? $arParam['FD_EXT'] : '',
179 'UPLOAD' => isset($arParam['FD_UPLOAD']) && $arParam['FD_UPLOAD'] && $arParam['FD_TARGET'] == 'F',
180 'USE_ML' => isset($arParam['FD_USE_MEDIALIB']) && $arParam['FD_USE_MEDIALIB'],
181 'ONLY_ML' => isset($arParam['FD_USE_ONLY_MEDIALIB']) && $arParam['FD_USE_ONLY_MEDIALIB'],
182 'ML_TYPES' => isset($arParam['FD_MEDIALIB_TYPES']) ? $arParam['FD_MEDIALIB_TYPES'] : false
183 );
184 }
185
186 // TOOLTIPS FROM .parameters langs
187 if (!isset($result['tooltips'][$arParam['ID'].'_TIP']))
188 {
189 $tip = GetMessage($arParam['ID'].'_TIP');
190 if ($tip)
191 {
192 $result['tooltips'][$arParam['ID'].'_TIP'] = $tip;
193 }
194 }
195 }
196
197 return $result;
198 }
199
200 public static function FetchHelp($componentName, $lang = false)
201 {
202 $cName = str_replace("..", "", $componentName);
203 $cName = str_replace(":", "/", $cName);
204 $lang = $lang ? preg_replace("/[^a-zA-Z0-9_]/is", "", $lang) : LANGUAGE_ID;
205 $filePath = "/bitrix/components/".$cName;
206 $fileName = "help/.tooltips.php";
207 $arTooltips = array();
208
209 $fname = $_SERVER["DOCUMENT_ROOT"].$filePath."/lang/".LangSubst($lang)."/".$fileName;
210 if ($lang != "en" && $lang != "ru" && file_exists($fname))
211 {
212 $arTooltips = __IncludeLang($fname, true, true);
213 }
214
215 $fname = $_SERVER["DOCUMENT_ROOT"].$filePath."/lang/".$lang."/".$fileName;
216 if (file_exists($fname))
217 {
218 $arTooltips = __IncludeLang($fname, true, true);
219 }
220
221 return $arTooltips;
222 }
223
224 public static function GetLangMessages()
225 {
227 'CompParManSelectOther' => GetMessage('PAR_MAN_SELECT_OTHER'),
228 'CompParManNoValue' => GetMessage('PAR_MAN_SELECT_NO_VALUE'),
229 'CompParManSearch' => GetMessage('PAR_MAN_SEARCH'),
230 'NoSearchResults' => GetMessage('PAR_MAN_NO_SEARCH_RESULTS'),
231 'TemplateGroup' => GetMessage('PAR_MAN_TEMPLATE_GROUP'),
232 'DefTemplate' => GetMessage('PAR_MAN_DEF_TEMPLATE')
233 );
234 return $messages;
235 }
236
237 public static function DisplayFileDialogsScripts()
238 {
239 for($i = 0, $l = count(self::$fileDialogs); $i < $l; $i++)
240 {
241 $fd = self::$fileDialogs[$i];
242 if ($fd['USE_ML'])
243 {
244 $MLRes = CMedialib::ShowBrowseButton(
245 array(
246 'mode' => $fd['ONLY_ML'] ? 'medialib' : 'select',
247 'value' => '...',
248 'event' => "BX_FD_".$fd['NAME'],
249 'id' => "bx_fd_input_".mb_strtolower($fd['NAME']),
250 'MedialibConfig' => array(
251 "event" => "bx_ml_event_".$fd['NAME'],
252 "arResultDest" => Array("FUNCTION_NAME" => "BX_FD_ONRESULT_".$fd['NAME']),
253 "types" => $fd['ML_TYPES']
254 ),
255 'bReturnResult' => true
256 )
257 );
258 ?><script>window._bxMlBrowseButton_<?= mb_strtolower($fd['NAME'])?> = '<?= CUtil::JSEscape($MLRes)?>';</script><?
259 }
260
262 (
263 "event" => "BX_FD_".$fd['NAME'],
264 "arResultDest" => Array("FUNCTION_NAME" => "BX_FD_ONRESULT_".$fd['NAME']),
265 "arPath" => Array(),
266 "select" => $fd['TARGET'], // F - file only, D - folder only, DF - files & dirs
267 "operation" => 'O',
268 "showUploadTab" => $fd['UPLOAD'],
269 "showAddToMenuTab" => false,
270 "fileFilter" => $fd['EXT'],
271 "allowAllFiles" => true,
272 "SaveConfig" => true
273 ));
274 }
275 }
276}
277?>
global $APPLICATION
Определения include.php:80
static load($extNames)
Определения extension.php:16
static ShowScript($arConfig)
Определения file_dialog.php:9
static DisplayFileDialogsScripts()
Определения component_params_manager.php:237
static Init($config=array())
Определения component_params_manager.php:13
static FetchHelp($componentName, $lang=false)
Определения component_params_manager.php:200
static ProcessRequest()
Определения component_params_manager.php:56
static GetComponentProperties($name='', $template='', $siteTemplate='', $currentValues=array())
Определения component_params_manager.php:106
static GetTemplateProps($componentName, $templateName, $siteTemplate="", $arCurrentValues=array())
Определения component_util.php:963
static GetComponentDescr($componentName)
Определения component_util.php:402
static GetTemplatesList($componentName, $currentTemplate=false)
Определения component_util.php:1024
static GetComponentProps($componentName, $arCurrentValues=array(), $templateProperties=array())
Определения component_util.php:461
static GetList($arOrder=array(), $arFilter=array(), $arSelect=false)
Определения site_template.php:13
$componentName
Определения component_props2.php:49
$arTemplate
Определения component_props.php:26
$template
Определения file_edit.php:49
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
bx_acc_lim_group_list limitGroupList[] multiple<?=$group[ 'ID']?> ID selected margin top
Определения file_new.php:657
$_REQUEST["admin_mnu_menu_id"]
Определения get_menu.php:8
$result
Определения get_property_values.php:14
if($request->isPost() && $currentAction !==null &&check_bitrix_sessid()) $currentValues
Определения options.php:198
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
if(!defined('SITE_ID')) $lang
Определения include.php:91
$l
Определения options.php:783
LangSubst($lang)
Определения tools.php:3854
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
__IncludeLang($path, $bReturnArray=false, $bFileChecked=false)
Определения tools.php:3477
$name
Определения menu_edit.php:35
$config
Определения quickway.php:69
$fileName
Определения quickway.php:305
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936
$messages
Определения template.php:8
$k
Определения template_pdf.php:567