/**
* Bitrix Framework
* @package bitrix
* @subpackage main
* @copyright 2001-2013 Bitrix
*/
/**
* Bitrix vars
* @global CUser $USER
* @global CMain $APPLICATION
*/
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_js.php");
$io = CBXVirtualIo::GetInstance();
$src_path = $io->CombinePath("/", $_GET["src_path"]);
$src_line = intval($_GET["src_line"]);
$template_site_template = $_GET["template_site_template"];
if(!$USER->CanDoOperation('edit_php') && !$USER->CanDoFileOperation('fm_lpa', array($_GET["src_site"], $src_path)))
die(GetMessage("ACCESS_DENIED"));
IncludeModuleLangFile(__FILE__);
CUtil::JSPostUnescape();
$obJSPopup = new CJSPopup('',
array(
'TITLE' => GetMessage("template_copy_title"),
'ARGS' => 'component_name='.urlencode($_GET["component_name"]).
'&component_template='.urlencode($_GET["component_template"]).
'&template_id='.urlencode($_GET["template_id"]).
'&lang='.urlencode(LANGUAGE_ID).
'&template_site_template='.urlencode($template_site_template).
'&src_path='.urlencode($_GET["src_path"]).
'&src_line='.intval($_GET["src_line"]).
'&src_site='.intval($_GET["src_site"]).
'&edit_file='.urlencode($_GET["edit_file"]).
'&back_path='.urlencode($_GET["back_path"]).
'&action=save'
)
);
$strWarning = "";
$arTemplate = false;
$aComponent = false;
$filesrc = "";
$abs_path = "";
// try to read parameters from script file
/* Try to open script containing the component call */
if(!$src_path || $src_line <= 0)
{
$strWarning .= GetMessage("comp_prop_err_param")."
";
}
else
{
$abs_path = $io->RelativeToAbsolutePath($src_path);
$f = $io->GetFile($abs_path);
$filesrc = $f->GetContents();
if(!$filesrc || $filesrc == "")
$strWarning .= GetMessage("comp_prop_err_open")."
";
}
$arComponent = false;
if($strWarning == "")
{
/* parse source file for PHP code */
$arComponents = PHPParser::ParseScript($filesrc);
/* identify the component by line number */
for ($i = 0, $cnt = count($arComponents); $i < $cnt; $i++)
{
$nLineFrom = substr_count(mb_substr($filesrc, 0, $arComponents[$i]["START"]), "\n") + 1;
$nLineTo = substr_count(mb_substr($filesrc, 0, $arComponents[$i]["END"]), "\n") + 1;
if ($nLineFrom <= $src_line && $nLineTo >= $src_line)
{
if ($arComponents[$i]["DATA"]["COMPONENT_NAME"] == $_GET["component_name"])
{
$arComponent = $arComponents[$i];
break;
}
}
if ($nLineTo > $src_line)
break;
}
}
if ($arComponent === false)
$strWarning .= GetMessage("comp_prop_err_comp")."
";
$arComponentDescription = array();
$arTemplatesList = array();
$templateSiteTemplate = "";
if($strWarning == "")
{
$arComponentDescription = CComponentUtil::GetComponentDescr($_GET["component_name"]);
$arComponentParameters = CComponentUtil::GetComponentProps($_GET["component_name"], $arComponent["DATA"]["PARAMS"]);
$arTemplateParameters = CComponentUtil::GetTemplateProps($_GET["component_name"], $_GET["component_template"], $_GET["template_id"], $arComponent["DATA"]["PARAMS"]);
$arParameterGroups = array();
if (isset($arComponentParameters["GROUPS"]) && is_array($arComponentParameters["GROUPS"]))
$arParameterGroups = $arParameterGroups + $arComponentParameters["GROUPS"];
if (isset($arTemplateParameters) && is_array($arTemplateParameters))
$arParameterGroups = $arParameterGroups + array("TEMPLATE" => array("NAME" => GetMessage("comp_templ_template")));
$arParameters = array();
if (isset($arComponentParameters["PARAMETERS"]) && is_array($arComponentParameters["PARAMETERS"]))
$arParameters = $arParameters + $arComponentParameters["PARAMETERS"];
if (isset($arTemplateParameters) && is_array($arTemplateParameters))
$arParameters = $arParameters + $arTemplateParameters;
$arTemplatesList = CComponentUtil::GetTemplatesList($_GET["component_name"], $_GET["template_id"]);
for ($i = 0, $cnt = count($arTemplatesList); $i < $cnt; $i++)
{
if($arComponent["DATA"]["TEMPLATE_NAME"]<>"" && $arTemplatesList[$i]["NAME"] == $arComponent["DATA"]["TEMPLATE_NAME"]
|| $arComponent["DATA"]["TEMPLATE_NAME"]=="" && $arTemplatesList[$i]["NAME"] == ".default")
{
$templateSiteTemplate = $arTemplatesList[$i]["TEMPLATE"];
break;
}
}
/* save parameters to file */
if($_SERVER["REQUEST_METHOD"] == "POST" && $_REQUEST["action"] == "save" && $arComponent !== false && $arComponentDescription !== false && check_bitrix_sessid())
{
//check template name
$sTemplateName = trim($_POST["TEMPLATE_NAME"]);
if($sTemplateName == '' || !CBitrixComponentTemplate::CheckName($sTemplateName))
$sTemplateName = '.default';
if ($_POST["SITE_TEMPLATE"] != $_GET["template_id"] && $_POST["SITE_TEMPLATE"] != ".default")
$_POST["USE_TEMPLATE"] = "N";
if (CComponentUtil::CopyTemplate($arComponent["DATA"]["COMPONENT_NAME"], $arComponent["DATA"]["TEMPLATE_NAME"], (($templateSiteTemplate <> '') ? $templateSiteTemplate : false), $_POST["SITE_TEMPLATE"], $sTemplateName, false))
{
if (isset($_POST["USE_TEMPLATE"]) && $_POST["USE_TEMPLATE"] == "Y")
{
$code = ($arComponent["DATA"]["VARIABLE"]?$arComponent["DATA"]["VARIABLE"]."=":"").
"\$APPLICATION->IncludeComponent(\"".$arComponent["DATA"]["COMPONENT_NAME"]."\", ".
"\"".$sTemplateName."\", ".
"Array(\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"], $arParameters)."\n\t)".
",\n\t".($arComponent["DATA"]["PARENT_COMP"] <> ''? $arComponent["DATA"]["PARENT_COMP"] : "false").
(!empty($arComponent["DATA"]["FUNCTION_PARAMS"])? ",\n\t"."array(\n\t".PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"])."\n\t)" : "").
"\n);";
$filesrc_for_save = mb_substr($filesrc, 0, $arComponent["START"]).$code.mb_substr($filesrc, $arComponent["END"]);
if(!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save))
$strWarning .= GetMessage("comp_prop_err_save")."
";
}
if($strWarning == "")
{
$strJSText = 'window.location = window.location.href;';
if (isset($_POST["EDIT_TEMPLATE"]) && $_POST["EDIT_TEMPLATE"] == "Y")
{
$component = new CBitrixComponent();
if ($component->InitComponent($arComponent["DATA"]["COMPONENT_NAME"], $_POST["TEMPLATE_NAME"]))
{
if ($component->InitComponentTemplate($_REQUEST["edit_file"], $_POST["SITE_TEMPLATE"]))
{
$template = & $component->GetTemplate();
if (!is_null($template))
{
$strJSText = $APPLICATION->GetPopupLink(
array(
'URL' => '/bitrix/admin/public_file_edit_src.php?lang='.LANGUAGE_ID.'&site='.SITE_ID.'&back_url='.urlencode($_REQUEST["back_path"]).'&path='.urlencode($template->GetFile()),
"PARAMS" => Array("width" => 770, "height" => 570,"resize" => true,"dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400),
)
);
}
}
}
}
?>
die();
}
}
else
{
if ($ex = $APPLICATION->GetException())
$strWarning .= $ex->GetString()."
";
else
$strWarning .= GetMessage("comp_templ_error_copy")."
";
}
}
}
$componentPath = CComponentEngine::MakeComponentPath($_GET["component_name"]);
$arComponentDescription["ICON"] = ltrim($arComponentDescription["ICON"], "/");
$localPath = getLocalPath("components".$componentPath);
if($localPath !== false && $arComponentDescription["ICON"] <> "" && $io->FileExists($io->RelativeToAbsolutePath($localPath."/".$arComponentDescription["ICON"])))
$sIcon = $localPath."/".$arComponentDescription["ICON"];
else
$sIcon = "/bitrix/images/fileman/htmledit2/component.gif";
$sCurrentTemplateName = ($arComponent["DATA"]["TEMPLATE_NAME"] <> ""? htmlspecialcharsbx($arComponent["DATA"]["TEMPLATE_NAME"]) : ".default");
$obJSPopup->ShowTitlebar();
$obJSPopup->StartDescription($sIcon);
?>
""):?>
">
""):?>">
if (isset($_GET['system_template']) && $_GET['system_template'] == 'Y') ShowNote(GetMessage("copy_comp_sys_templ")); if($strWarning <> "") { //ShowError($strWarning); $obJSPopup->ShowValidationError($strWarning); echo ''; } ?> $obJSPopup->StartContent(); ?>Fatal error: Uncaught Error: Call to undefined function GetMessage() in D:\ktt\ttepla.com\public_html\bitrix\modules\main\public\template_copy.php:255 Stack trace: #0 {main} thrown in D:\ktt\ttepla.com\public_html\bitrix\modules\main\public\template_copy.php on line 255 |