1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
component_props2.php
См. документацию.
1<?php
2
4
9
10if (!array_key_exists("component_name", $_GET))
11{
12 require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/public/component_props.php");
13 die();
14}
15
16require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
17require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
18
19$APPLICATION->ShowAjaxHead();
20
21function PageParams($bUrlEncode = true)
22{
23 $amp = $bUrlEncode ? '&amp;' : '&';
24 return
25 'component_name='.urlencode(CUtil::addslashes($_GET["component_name"])).
26 $amp.'component_template='.urlencode(CUtil::addslashes($_GET["component_template"])).
27 $amp.'template_id='.urlencode(CUtil::addslashes($_GET["template_id"])).
28 $amp.'lang='.urlencode(CUtil::addslashes(LANGUAGE_ID)).
29 $amp.'src_path='.urlencode(CUtil::addslashes($_GET["src_path"])).
30 $amp.'src_line='.intval($_GET["src_line"]).
31 $amp.'src_page='.urlencode(CUtil::addslashes($_GET["src_page"])).
32 $amp.'src_site='.urlencode(CUtil::addslashes($_GET["src_site"]));
33}
34
36
37$src_path = $io->CombinePath("/", $_GET["src_path"]);
38$src_line = intval($_GET["src_line"]);
39
40if(!$USER->CanDoOperation('edit_php') && !$USER->CanDoFileOperation('fm_lpa', array($_GET["src_site"], $src_path)))
41{
42 die(GetMessage("ACCESS_DENIED"));
43}
44
45$bLimitPhpAccess = !$USER->CanDoOperation('edit_php');
46
47CModule::IncludeModule("fileman");
48
49$componentName = $_GET["component_name"];
50$componentTemplate = $_GET["component_template"];
51$templateId = $_GET["template_id"];
52$relPath = $io->ExtractPathFromPath($src_path);
53
55 'requestUrl' => '/bitrix/admin/fileman_component_params.php',
56 'relPath' => $relPath
57));
58
59IncludeModuleLangFile(__FILE__);
60
62 array(
63 'TITLE' => GetMessage("comp_prop_title")
64 )
65);
66
67$obJSPopup->ShowTitlebar();
68
78
79if(!CComponentEngine::CheckComponentName($componentName))
80 $strWarning .= GetMessage("comp_prop_error_name")."<br>";
81
82if($strWarning == "")
83{
84 // try to read parameters from script file
85 /* Try to open script containing the component call */
86 if(!$src_path || $src_line <= 0)
87 {
88 $strWarning .= GetMessage("comp_prop_err_param")."<br>";
89 }
90 else
91 {
92 $abs_path = $io->RelativeToAbsolutePath($src_path);
93 $f = $io->GetFile($abs_path);
94 $filesrc = $f->GetContents();
95 if(!$filesrc || $filesrc == "")
96 $strWarning .= GetMessage("comp_prop_err_open")."<br>";
97 }
98
99 if($strWarning == "")
100 {
101 $arComponent = PHPParser::FindComponent($componentName, $filesrc, $src_line);
102 if ($arComponent === false)
103 $strWarning .= GetMessage("comp_prop_err_comp")."<br>";
104 else
105 $arValues = $arComponent["DATA"]["PARAMS"];
106 }
107}
108
109if($strWarning == "")
110{
111 if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh")
112 {
113 // parameters were changed by "ok" button
114 // we need to refresh the component description with new values
115 $arValues = array_merge($arValues, $_POST);
116 }
117
118 $curTemplate = (isset($_POST["COMPONENT_TEMPLATE"])) ? $_POST["COMPONENT_TEMPLATE"] : $componentTemplate;
119
125 );
127
128 /* save parameters to file */
129 if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $arComponent !== false)
130 {
131 if (!check_bitrix_sessid())
132 {
133 $strWarning .= GetMessage("comp_prop_err_save")."<br>";
134 }
135 else
136 {
137 $aPostValues = array_merge($arValues, $_POST);
138 unset($aPostValues["sessid"]);
139 unset($aPostValues["bxpiheight"]);
140 unset($aPostValues["bxpiwidth"]);
141
143 foreach ($aPostValues as $name => $value)
144 {
145 if (is_array($value))
146 {
147 if (count($value) == 1 && isset($value[0]) && $value[0] == "")
148 {
149 $aPostValues[$name] = [];
150 }
151 }
152 elseif ($bLimitPhpAccess && str_starts_with($value, '={') && str_ends_with($value, '}'))
153 {
154 $aPostValues[$name] = $arValues[$name];
155 }
156 }
157
158 //check template name
159 $sTemplateName = "";
161 foreach($arComponentTemplates as $templ)
162 {
163 if($templ["NAME"] == $_POST["COMPONENT_TEMPLATE"])
164 {
165 $sTemplateName = $templ["NAME"];
166 break;
167 }
168 }
169
170 $code = PHPParser::buildComponentCode($arComponent, $sTemplateName, $aPostValues);
171
172 $filesrc_for_save = mb_substr($filesrc, 0, $arComponent["START"]).$code.mb_substr($filesrc, $arComponent["END"]);
173
174 $f = $io->GetFile($abs_path);
175 $arUndoParams = array(
176 'module' => 'fileman',
177 'undoType' => 'edit_component_props',
178 'undoHandler' => 'CFileman::UndoEditFile',
179 'arContent' => array(
180 'absPath' => $abs_path,
181 'content' => $f->GetContents()
182 )
183 );
184
185 if($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
186 {
187 CUndo::ShowUndoMessage(CUndo::Add($arUndoParams));
188 $obJSPopup->Close();
189 }
190 else
191 {
192 $strWarning .= GetMessage("comp_prop_err_save")."<br>";
193 }
194 }
195 }
196}
197$componentPath = CComponentEngine::MakeComponentPath($componentName);
198
199if($strWarning !== "")
200{
201 $obJSPopup->ShowValidationError($strWarning);
202 ?>
203 <script>
204 (function()
205 {
206 if (BX && BX.WindowManager)
207 {
208 var oPopup = BX.WindowManager.Get();
209 if (oPopup && oPopup.PARTS && oPopup.PARTS.CONTENT_DATA)
210 {
211 oPopup.PARTS.CONTENT_DATA.style.display = 'none';
212 }
213 }
214 })();
215 </script>
216 <?
217}
218
219$obJSPopup->StartContent();?>
220
221<?if($strWarning === ""):?>
222<script>
223(function()
224{
225 function CompDialogManager(params)
226 {
227 this.Init(params);
228 }
229
230 CompDialogManager.prototype =
231 {
232 Init: function(params)
233 {
234 this.pDiv = BX('bx-comp-params-wrap');
235 var oPopup = BX.WindowManager.Get();
236 oPopup.PARTS.CONTENT_DATA.className = 'bxcompprop-adm-dialog-content';
237
238 BX.addClass(oPopup.PARTS.CONTENT, 'bxcompprop-adm-dialog');
239
240 BX.addCustomEvent(oPopup, 'onWindowResize', function()
241 {
242 BX.onCustomEvent(oBXComponentParamsManager, 'OnComponentParamsResize', [
243 parseInt(oPopup.PARTS.CONTENT_DATA.style.width),
244 parseInt(oPopup.PARTS.CONTENT_DATA.style.height)
245 ]);
246 });
247
248 oBXComponentParamsManager.params = {
249 name: params.name,
250 parent: params.parent,
251 template: params.template,
252 exParams: params.exParams,
253 currentValues: params.currentValues || {},
254 container: this.pDiv,
255 siteTemplate: params.siteTemplate
256 };
257
258 BX.addCustomEvent(oBXComponentParamsManager, 'onComponentParamsBuilt', function()
259 {
260 BX.onCustomEvent(oBXComponentParamsManager, 'OnComponentParamsResize', [
261 parseInt(oPopup.PARTS.CONTENT_DATA.style.width),
262 parseInt(oPopup.PARTS.CONTENT_DATA.style.height)
263 ]);
264 });
265
266 oBXComponentParamsManager.BuildComponentParams(params.data, oBXComponentParamsManager.params);
267
268 BX.addCustomEvent(oBXComponentParamsManager, 'onComponentParamsBeforeRefresh', BX.proxy(this.DisableSaveButton, this));
269 BX.addCustomEvent(oBXComponentParamsManager, 'onComponentParamsBuilt', BX.proxy(this.EnableSaveButton, this));
270 },
271
272 EnableSaveButton: function()
273 {
274 BX('bx-comp-params-save-button').disabled = null;
275 },
276 DisableSaveButton: function()
277 {
278 BX('bx-comp-params-save-button').disabled = 'disabled';
279 }
280 };
281
282 window.publicComponentDialogManager = new CompDialogManager(<?= Json::encode(array(
283 'name' => $componentName,
284 'template' => $curTemplate,
285 'siteTemplate' => $templateId,
286 'currentValues' => $arValues,
287 'data' => $data
288 ))?>);
289
290})();
291</script>
292<div id="bx-comp-params-wrap" class="bxcompprop-wrap-public"></div>
294<?endif; /*($strWarning === "") */?>
295
296<?$obJSPopup->StartButtons();?>
297 <input type="button" id="bx-comp-params-save-button" value="<?= GetMessage("comp_prop_save")?>" onclick="<?=$obJSPopup->jsPopup?>.PostParameters('<?= PageParams().'&amp;action=save'?>');" title="<?= GetMessage("comp_prop_save_title")?>" name="save" class="adm-btn-save" />
298 <input type="button" value="<?= GetMessage("comp_prop_cancel")?>" onclick="<?=$obJSPopup->jsPopup?>.CloseDialog()" title="<?= GetMessage("comp_prop_cancel_title")?>" />
299<?$obJSPopup->EndButtons();?>
300
301<?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");?>
global $APPLICATION
Определения include.php:80
if($canUseYandexMarket) $strWarning
Определения options.php:74
Определения json.php:9
static GetInstance()
Определения virtual_io.php:60
static DisplayFileDialogsScripts()
Определения component_params_manager.php:237
static Init($config=array())
Определения component_params_manager.php:13
static GetComponentProperties($name='', $template='', $siteTemplate='', $currentValues=array())
Определения component_params_manager.php:106
static GetComponentDescr($componentName)
Определения component_util.php:402
static GetTemplatesList($componentName, $currentTemplate=false)
Определения component_util.php:1024
static PrepareVariables(&$arData)
Определения component_util.php:37
Определения jspopup.php:10
static ShowUndoMessage($ID)
Определения undo.php:187
static Add($params=array())
Определения undo.php:9
$componentTemplate
Определения component_props2.php:50
if( $strWarning=="") if($strWarning=="") $componentPath
Определения component_props2.php:197
if(! $USER->CanDoOperation('edit_php') &&! $USER->CanDoFileOperation('fm_lpa', array($_GET["src_site"], $src_path))) $bLimitPhpAccess
Определения component_props2.php:45
$abs_path
Определения component_props2.php:76
$templateId
Определения component_props2.php:51
$componentName
Определения component_props2.php:49
$arParameterGroups
Определения component_props2.php:74
$curTemplate
Определения component_props2.php:77
$src_path
Определения component_props2.php:37
$arComponentDescription
Определения component_props2.php:73
$arComponent
Определения component_props2.php:72
PageParams($bUrlEncode=true)
Определения component_props2.php:21
$relPath
Определения component_props2.php:52
$arTemplate
Определения component_props.php:26
$f
Определения component_props.php:52
$arValues
Определения component_props.php:25
$src_line
Определения component_props.php:43
$filesrc
Определения component_props.php:53
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $USER
Определения csv_new_run.php:40
$io
Определения csv_new_run.php:98
endif
Определения csv_new_setup.php:990
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
check_bitrix_sessid($varname='sessid')
Определения tools.php:4686
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
$name
Определения menu_edit.php:35
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
die
Определения quickway.php:367
</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
$obJSPopup
Определения settings_admin_form.php:102