CanDoOperation('edit_php')) die(GetMessage("ACCESS_DENIED")); IncludeModuleLangFile(__FILE__); CUtil::JSPostUnescape(); $obJSPopup = new CJSPopup('', array( 'TITLE' => GetMessage("comp_prop_title"), 'ARGS' => 'path='.urlencode(CUtil::addslashes($_GET["path"])). '&template_id='.urlencode(CUtil::addslashes($_GET["template_id"])). '&lang='.LANGUAGE_ID. '&src_path='.urlencode(CUtil::addslashes($_GET["src_path"])). '&src_line='.intval($_GET["src_line"]). '&action=save' ) ); $obJSPopup->ShowTitlebar(); $strWarning = ""; $arValues = array(); $arTemplate = false; $aComponent = false; $io = CBXVirtualIo::GetInstance(); if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh") { // parameters were changed by "ok" button // we need to refresh the component description with new values $arValues = $_POST; } else { // try to read parameters from script file /* Try to open script containing the component call */ $src_path = $_GET["src_path"]; $src_line = intval($_GET["src_line"]); if(!$src_path || $src_line <= 0) { $strWarning .= GetMessage("comp_prop_err_param")."
"; } else { $abs_path = $src_path; $f = $io->GetFile($abs_path); $filesrc = $f->GetContents(); if(!$filesrc || $filesrc == "") $strWarning .= GetMessage("comp_prop_err_open")."
"; } if($strWarning == "") { /* parse source file for PHP code */ $arScripts = PHPParser::ParseFile($filesrc); /* identify the component by line number */ $aComponents = array(); foreach($arScripts as $script) { $nLineFrom = substr_count(mb_substr($filesrc, 0, $script[0]), "\n")+1; $nLineTo = substr_count(mb_substr($filesrc, 0, $script[1]), "\n")+1; if($nLineFrom <= $src_line && $nLineTo >= $src_line) $aComponents[] = $script; if($nLineTo > $src_line) break; } foreach($aComponents as $component) { $arRes = PHPParser::CheckForComponent($component[2]); if($arRes && $arRes["SCRIPT_NAME"] == $_GET["path"]) { $arValues = $arRes["PARAMS"]; $aComponent = $component; break; } } } if($aComponent === false) $strWarning .= GetMessage("comp_prop_err_comp")."
"; } //$_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh" if($strWarning == "") { $arTemplate = CTemplates::GetByID($_GET["path"], $arValues, $_GET["template_id"]); /* save parameters to file */ if($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $aComponent !== false && $arTemplate !== false) { if (!check_bitrix_sessid()) { $strWarning .= GetMessage("comp_prop_err_save")."
"; } else { $params = PHPParser::ReturnPHPStr($_POST, $arTemplate["PARAMS"]); if($params <> "") $code = "<"."?".($arRes["VARIABLE"]?$arRes["VARIABLE"]."=":"")."\$APPLICATION->IncludeFile(\"".$_GET["path"]."\", Array(\r\n\t".$params."\r\n\t)\r\n);?".">"; else $code = "<"."?".($arRes["VARIABLE"]?$arRes["VARIABLE"]."=":"")."\$APPLICATION->IncludeFile(\"".$_GET["path"]."\");?".">"; $filesrc_for_save = mb_substr($filesrc, 0, $aComponent[0]).$code.mb_substr($filesrc, $aComponent[1]); if($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) { $obJSPopup->Close(); } else $strWarning .= GetMessage("comp_prop_err_save")."
"; } } } if($arTemplate["ICON"] == "" || !is_file($_SERVER["DOCUMENT_ROOT"].$arTemplate["ICON"])) $arTemplate["ICON"] = "/bitrix/images/fileman/htmledit2/component.gif"; $obJSPopup->StartDescription($arTemplate['ICON']); ?> ""):?>

">

""):?>

">

">""? $arTemplate["REAL_PATH"]:$_GET["path"])?>

"") //ShowError($strWarning); $obJSPopup->ShowValidationError($strWarning); ?> StartContent(); if(!empty($arTemplate["PARAMS"])): ?> $prop): ?>
'; if(!is_array($prop["VALUES"])) { $prop["VALUES"] = Array(); } $tmp = ''; $bFound = false; foreach ($prop["VALUES"] as $v_id => $v_name) { $key = array_search($v_id, $val); if ($key === false) { $tmp .= ''; } else { unset($val[$key]); $bFound = true; $tmp .= ''; } } if($prop['ADDITIONAL_VALUES'] !== 'N') { $res .= ''; } $res .= $tmp; $res .= ''; if($prop['ADDITIONAL_VALUES'] !== 'N') { if($prop["MULTIPLE"] == 'Y') { reset($val); foreach($val as $v) { $res .= '
'; if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } for($i = 0; $i < $prop["CNT"]; $i++) { $res .= '
'; if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } $res .= ''; } else { $res .= ''; } $res .= '\'">'; } else { $res .= '
'; if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } } break; default: if($prop["MULTIPLE"] == 'Y') { $bBr = false; foreach($val as $v) { if($bBr) { $res .= '
'; } else { $bBr = true; } if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } for($i = 0; $i < $prop["CNT"]; $i++) { if($bBr) { $res .= '
'; } else { $bBr = true; } if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } $res .= ''; } else { $res .= ''; } $res .= '\'">'; } else { if($prop['ROWS'] > 1) { $res .= ''; } else { $res .= ''; } } break; } if($prop["REFRESH"]=="Y") $res .= ''; echo $res; ?>
StartButtons(); echo ''."\r\n"; $obJSPopup->ShowStandardButtons(array('close')); else: //!empty($arTemplate["PARAMS"]) $obJSPopup->ShowStandardButtons(array('close')); endif; //!empty($arTemplate["PARAMS"]) require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_admin_js.php"); ?>