1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
component_props.php
См. документацию.
1<?
2require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
3require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
4
5if(!$USER->CanDoOperation('edit_php'))
6 die(GetMessage("ACCESS_DENIED"));
7
9
11 array(
12 'TITLE' => GetMessage("comp_prop_title"),
13 'ARGS' => 'path='.urlencode(CUtil::addslashes($_GET["path"])).
14 '&amp;template_id='.urlencode(CUtil::addslashes($_GET["template_id"])).
15 '&amp;lang='.LANGUAGE_ID.
16 '&amp;src_path='.urlencode(CUtil::addslashes($_GET["src_path"])).
17 '&amp;src_line='.intval($_GET["src_line"]).
18 '&amp;action=save'
19 )
20);
21
22$obJSPopup->ShowTitlebar();
23
28
30
31if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh")
32{
33 // parameters were changed by "ok" button
34 // we need to refresh the component description with new values
35 $arValues = $_POST;
36}
37else
38{
39 // try to read parameters from script file
40
41 /* Try to open script containing the component call */
42 $src_path = $_GET["src_path"];
43 $src_line = intval($_GET["src_line"]);
44
45 if(!$src_path || $src_line <= 0)
46 {
47 $strWarning .= GetMessage("comp_prop_err_param")."<br>";
48 }
49 else
50 {
52 $f = $io->GetFile($abs_path);
53 $filesrc = $f->GetContents();
54
55 if(!$filesrc || $filesrc == "")
56 $strWarning .= GetMessage("comp_prop_err_open")."<br>";
57 }
58
59 if($strWarning == "")
60 {
61 /* parse source file for PHP code */
62 $arScripts = PHPParser::ParseFile($filesrc);
63
64 /* identify the component by line number */
66 foreach($arScripts as $script)
67 {
68 $nLineFrom = substr_count(mb_substr($filesrc, 0, $script[0]), "\n")+1;
69 $nLineTo = substr_count(mb_substr($filesrc, 0, $script[1]), "\n")+1;
70 if($nLineFrom <= $src_line && $nLineTo >= $src_line)
71 $aComponents[] = $script;
72 if($nLineTo > $src_line)
73 break;
74 }
75
76 foreach($aComponents as $component)
77 {
78 $arRes = PHPParser::CheckForComponent($component[2]);
79
80 if($arRes && $arRes["SCRIPT_NAME"] == $_GET["path"])
81 {
82 $arValues = $arRes["PARAMS"];
83 $aComponent = $component;
84 break;
85 }
86 }
87 }
88 if($aComponent === false)
89 $strWarning .= GetMessage("comp_prop_err_comp")."<br>";
90} //$_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh"
91
92
93if($strWarning == "")
94{
95 $arTemplate = CTemplates::GetByID($_GET["path"], $arValues, $_GET["template_id"]);
96
97 /* save parameters to file */
98 if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $aComponent !== false && $arTemplate !== false)
99 {
100 if (!check_bitrix_sessid())
101 {
102 $strWarning .= GetMessage("comp_prop_err_save")."<br>";
103 }
104 else
105 {
106 $params = PHPParser::ReturnPHPStr($_POST, $arTemplate["PARAMS"]);
107
108 if($params <> "")
109 $code = "<"."?".($arRes["VARIABLE"]?$arRes["VARIABLE"]."=":"")."\$APPLICATION->IncludeFile(\"".$_GET["path"]."\", Array(\r\n\t".$params."\r\n\t)\r\n);?".">";
110 else
111 $code = "<"."?".($arRes["VARIABLE"]?$arRes["VARIABLE"]."=":"")."\$APPLICATION->IncludeFile(\"".$_GET["path"]."\");?".">";
112
113 $filesrc_for_save = mb_substr($filesrc, 0, $aComponent[0]).$code.mb_substr($filesrc, $aComponent[1]);
114
115 if($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
116 {
117 $obJSPopup->Close();
118 }
119 else
120 $strWarning .= GetMessage("comp_prop_err_save")."<br />";
121 }
122 }
123}
124
125if($arTemplate["ICON"] == "" || !is_file($_SERVER["DOCUMENT_ROOT"].$arTemplate["ICON"]))
126 $arTemplate["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif";
127
128$obJSPopup->StartDescription($arTemplate['ICON']);
129?>
130<?if($arTemplate["NAME"] <> ""):?>
131<p title="<?echo GetMessage("comp_prop_name")?>"><b><?echo htmlspecialcharsbx($arTemplate["NAME"])?></b></p>
132<?endif;?>
133<?if($arTemplate["DESCRIPTION"] <> ""):?>
134<p title="<?echo GetMessage("comp_prop_desc")?>"><?echo htmlspecialcharsbx($arTemplate["DESCRIPTION"])?></p>
135<?endif;?>
136<p class="note" title="<?echo GetMessage("comp_prop_path")?>"><?echo htmlspecialcharsbx($arTemplate["REAL_PATH"]<>""? $arTemplate["REAL_PATH"]:$_GET["path"])?></p>
137<?
138if($strWarning <> "")
139 //ShowError($strWarning);
140 $obJSPopup->ShowValidationError($strWarning);
141?>
142<?
143$obJSPopup->StartContent();
144if(!empty($arTemplate["PARAMS"])):
145?>
146<table cellspacing="0" class="bx-width100">
147<?
148foreach($arTemplate["PARAMS"] as $ID=>$prop):
149?>
150 <tr>
151 <td><?echo htmlspecialcharsbx($prop["NAME"]).":"?></td>
152 <td>
153<?
154if(!array_key_exists($ID, $arValues) && isset($prop["DEFAULT"]))
155 $arValues[$ID] = $prop["DEFAULT"];
156
157if($prop["MULTIPLE"]=='Y' && !is_array($arValues[$ID]))
158{
159 if(isset($arValues[$ID]))
160 $val = Array($arValues[$ID]);
161 else
162 $val = Array();
163}
164elseif($prop["TYPE"]=="LIST" && !is_array($arValues[$ID]))
165 $val = Array($arValues[$ID]);
166else
167 $val = $arValues[$ID];
168
169$res = "";
170if($prop["COLS"]<1)
171 $prop["COLS"] = '30';
172
173if($prop["MULTIPLE"]=='Y')
174{
175 $prop["CNT"] = intval($prop["CNT"]);
176 if($prop["CNT"]<1)
177 $prop["CNT"] = 1;
178}
179
180switch(mb_strtoupper($prop["TYPE"]))
181{
182 case "LIST":
183 $prop["SIZE"] = ($prop["MULTIPLE"] == 'Y' && intval($prop["SIZE"]) <= 1? '3' : $prop["SIZE"]);
184 if(intval($prop["SIZE"]) <= 0)
185 {
186 $prop["SIZE"] = 1;
187 }
188
189 $res .= '<select name="'.$ID.($prop["MULTIPLE"] == "Y"? '[]' : '').'"'.
190 ($prop["MULTIPLE"] == "Y"?
191 ' multiple ' :
192 ($prop['ADDITIONAL_VALUES'] !== 'N'?
193 ' onChange="this.form.elements[\''.$ID.'_alt\'].disabled = (this.selectedIndex!=0);" '
194 : '')
195 ).
196 ' size="'.$prop["SIZE"].'">';
197
198 if(!is_array($prop["VALUES"]))
199 {
200 $prop["VALUES"] = Array();
201 }
202
203 $tmp = '';
204 $bFound = false;
205 foreach ($prop["VALUES"] as $v_id => $v_name)
206 {
207 $key = array_search($v_id, $val);
208 if ($key === false)
209 {
210 $tmp .= '<option value="'.htmlspecialcharsbx($v_id).'">'.htmlspecialcharsbx($v_name).'</option>';
211 }
212 else
213 {
214 unset($val[$key]);
215 $bFound = true;
216 $tmp .= '<option value="'.htmlspecialcharsbx($v_id).'" selected>'.htmlspecialcharsbx($v_name).'</option>';
217 }
218 }
219 if($prop['ADDITIONAL_VALUES'] !== 'N')
220 {
221 $res .= '<option value=""'.(!$bFound? ' selected' : '').'>'.($prop["MULTIPLE"] == "Y"? GetMessage("comp_prop_not_sel") : GetMessage("comp_prop_other").' -&gt;').'</option>';
222 }
224 $res .= '</select>';
225 if($prop['ADDITIONAL_VALUES'] !== 'N')
226 {
227 if($prop["MULTIPLE"] == 'Y')
228 {
229 reset($val);
230 foreach($val as $v)
231 {
232 $res .= '<br>';
233 if($prop['ROWS'] > 1)
234 {
235 $res .= '<textarea name="'.$ID.'[]" cols='.$prop["COLS"].'>'.htmlspecialcharsbx($v).'</textarea>';
236 }
237 else
238 {
239 $res .= '<input type="text" name="'.$ID.'[]" size='.$prop["COLS"].' value="'.htmlspecialcharsbx($v).'">';
240 }
241 }
242
243 for($i = 0; $i < $prop["CNT"]; $i++)
244 {
245 $res .= '<br>';
246 if($prop['ROWS'] > 1)
247 {
248 $res .= '<textarea name="'.$ID.'[]" cols='.$prop["COLS"].'></textarea>';
249 }
250 else
251 {
252 $res .= '<input type="text" name="'.$ID.'[]" size='.$prop["COLS"].' value="">';
253 }
254 }
255 $res .= '<input type="button" value="+" onClick="var span = document.createElement(\'SPAN\'); this.parentNode.insertBefore(span, this); span.innerHTML=\''.
256 '<br>';
257 if($prop['ROWS'] > 1)
258 {
259 $res .= '<textarea name=\\\''.$ID.'[]\\\' cols=\\\''.$prop["COLS"].'\\\'></textarea>';
260 }
261 else
262 {
263 $res .= '<input type=\\\'text\\\' name=\\\''.$ID.'[]\\\' size=\\\''.$prop["COLS"].'\\\'>';
264 }
265
266 $res .= '\'">';
267 }
268 else
269 {
270 $res .= '<br>';
271 if($prop['ROWS'] > 1)
272 {
273 $res .= '<textarea name="'.$ID.'_alt" '.($bFound? ' disabled ' : '').' cols='.$prop["COLS"].'>'.htmlspecialcharsbx(!empty($val)? $val[0] : '').'</textarea>';
274 }
275 else
276 {
277 $res .= '<input type="text" name="'.$ID.'_alt" '.($bFound? ' disabled ' : '').'size='.$prop["COLS"].' value="'.htmlspecialcharsbx(!empty($val)? $val[0] : '').'">';
278 }
279 }
280 }
281 break;
282 default:
283 if($prop["MULTIPLE"] == 'Y')
284 {
285 $bBr = false;
286 foreach($val as $v)
287 {
288 if($bBr)
289 {
290 $res .= '<br>';
291 }
292 else
293 {
294 $bBr = true;
295 }
296 if($prop['ROWS'] > 1)
297 {
298 $res .= '<textarea name="'.$ID.'[]" cols='.$prop["COLS"].'>'.htmlspecialcharsbx($v).'</textarea>';
299 }
300 else
301 {
302 $res .= '<input type="text" name="'.$ID.'[]" size='.$prop["COLS"].' value="'.htmlspecialcharsbx($v).'">';
303 }
304 }
305
306 for($i = 0; $i < $prop["CNT"]; $i++)
307 {
308 if($bBr)
309 {
310 $res .= '<br>';
311 }
312 else
313 {
314 $bBr = true;
315 }
316 if($prop['ROWS'] > 1)
317 {
318 $res .= '<textarea name="'.$ID.'[]" cols='.$prop["COLS"].'></textarea>';
319 }
320 else
321 {
322 $res .= '<input type="text" name="'.$ID.'[]" size='.$prop["COLS"].' value="">';
323 }
324 }
325
326 $res .= '<input type="button" value="+" onClick="var span = document.createElement(\'SPAN\'); this.parentNode.insertBefore(span, this); span.innerHTML=\''.
327 '<br>';
328 if($prop['ROWS'] > 1)
329 {
330 $res .= '<textarea name=\\\''.$ID.'[]\\\' cols=\\\''.$prop["COLS"].'\\\'></textarea>';
331 }
332 else
333 {
334 $res .= '<input type=\\\'text\\\' name=\\\''.$ID.'[]\\\' size=\\\''.$prop["COLS"].'\\\'>';
335 }
336
337 $res .= '\'">';
338 }
339 else
340 {
341 if($prop['ROWS'] > 1)
342 {
343 $res .= '<textarea name="'.$ID.'" cols='.$prop["COLS"].'>'.htmlspecialcharsbx($val).'</textarea>';
344 }
345 else
346 {
347 $res .= '<input name="'.$ID.'" size='.$prop["COLS"].' value="'.htmlspecialcharsbx($val).'" type="text">';
348 }
349 }
350 break;
351}
352if($prop["REFRESH"]=="Y")
353 $res .= '<input type="button" value="OK" onclick="'.$obJSPopup->jsPopup.'.PostParameters(\''.
354 'path='.urlencode(CUtil::addslashes($_GET["path"])).
355 '&amp;template_id='.urlencode(CUtil::addslashes($_GET["template_id"])).
356 '&amp;lang='.LANGUAGE_ID.
357 '&amp;src_path='.urlencode(CUtil::addslashes($_GET["src_path"])).
358 '&amp;src_line='.intval($_GET["src_line"]).
359 '&amp;action=refresh\');">';
360
361echo $res;
362?>
363 </td>
364 </tr>
365<?endforeach?>
366</table>
367<?
368 $obJSPopup->StartButtons();
369 echo '<input id="btn_popup_save" name="btn_popup_save" type="button" value="'.GetMessage("JSPOPUP_SAVE_CAPTION").'" onclick="'.$obJSPopup->jsPopup.'.PostParameters(\'action=save\');" title="'.GetMessage("JSPOPUP_SAVE_CAPTION").'" />'."\r\n";
370 $obJSPopup->ShowStandardButtons(array('close'));
371else:
372 $obJSPopup->ShowStandardButtons(array('close'));
374
375require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php");
376?>
global $APPLICATION
Определения include.php:80
if($canUseYandexMarket) $strWarning
Определения options.php:74
static GetInstance()
Определения virtual_io.php:60
Определения jspopup.php:10
static GetByID($id, $arCurrentValues=array(), $templateID=array())
Определения templates.php:107
static CheckForComponent($str)
Определения php_parser.php:141
static ReturnPHPStr($arVals, $arParams)
Определения php_parser.php:766
static ParseFile($filesrc, $limit=false)
Определения php_parser.php:651
$aComponents
Определения clear_component_cache.php:19
$abs_path
Определения component_props2.php:76
$src_path
Определения component_props2.php:37
$arTemplate
Определения component_props.php:26
$f
Определения component_props.php:52
$arValues
Определения component_props.php:25
if(!is_array($prop["VALUES"])) $tmp
Определения component_props.php:203
$strWarning
Определения component_props.php:24
$src_line
Определения component_props.php:43
$filesrc
Определения component_props.php:53
$aComponent
Определения component_props.php:27
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$bFound
Определения get_search.php:40
if($ajaxMode) $ID
Определения get_user.php:27
$_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
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения tools.php:3778
GetMessage($name, $aReplace=null)
Определения tools.php:3397
global_menu_<?echo $menu["menu_id"]?> adm main menu item icon adm main menu item text text adm main menu hover adm submenu menucontainer menu_id menu_id items_id items_id desktop menu_id block none adm global submenu<?=($subMenuDisplay=="block" ? " adm-global-submenu-active" :"")?> global_submenu_<?echo $menu["menu_id"]?> text MAIN_PR_ADMIN_FAV items adm submenu items wrap adm submenu items stretch wrap BX adminMenu itemsStretchScroll()"> <table class if (!empty( $menu["items"])) elseif ( $menu[ 'menu_id']=='desktop') if ( $menu[ 'menu_id']=='desktop') endforeach
Определения prolog_main_admin.php:255
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
<? endif;?> window document title
Определения prolog_main_admin.php:76
if(empty($signedUserToken)) $key
Определения quickway.php:257
die
Определения quickway.php:367
$i
Определения factura.php:643
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$val
Определения options.php:1793
$obJSPopup
Определения settings_admin_form.php:102
$arRes
Определения options.php:104