public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("siteId"); TemplateInfo templateInfo = null; if (AuthRequest.GetQueryInt("TemplateID") > 0) { var templateId = AuthRequest.GetQueryInt("TemplateID"); _isCopy = AuthRequest.GetQueryBool("IsCopy"); templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId); if (templateInfo != null) { _templateType = templateInfo.TemplateType; } } else { _templateType = TemplateTypeUtils.GetEnumType(Request.QueryString["TemplateType"]); } if (_templateType == TemplateType.IndexPageTemplate || _templateType == TemplateType.FileTemplate) { PhCreatedFileFullName.Visible = true; } else { PhCreatedFileFullName.Visible = false; } if (IsPostBack) { return; } VerifySitePermissions(ConfigManager.SitePermissions.Templates); LtlTemplateType.Text = TemplateTypeUtils.GetText(_templateType); LtlPageTitle.Text = AuthRequest.GetQueryInt("TemplateID") > 0 ? "编辑模板" : "添加模板"; var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror; BtnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式"; PhCodeMirror.Visible = isCodeMirror; EFileSystemTypeUtils.AddWebPageListItems(DdlCreatedFileExtName); ECharsetUtils.AddListItems(DdlCharset); if (AuthRequest.GetQueryInt("TemplateID") > 0) { if (templateInfo == null) { return; } TbContent.Text = TemplateManager.GetTemplateContent(SiteInfo, templateInfo); if (_isCopy) { TbTemplateName.Text = templateInfo.TemplateName + "_复件"; TbRelatedFileName.Text = PathUtils.RemoveExtension(templateInfo.RelatedFileName) + "_复件"; TbCreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName) + "_复件"; } else { TbTemplateName.Text = templateInfo.TemplateName; TbRelatedFileName.Text = PathUtils.RemoveExtension(templateInfo.RelatedFileName); TbCreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName); LtlCommands.Text += $@" <button class=""btn"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(SiteId, templateInfo.Id)}"">生成页面</button> <button class=""btn"" onclick=""{ModalTemplateRestore.GetOpenWindowString(SiteId, templateInfo.Id, string.Empty)}"">还原历史版本</button>"; if (AuthRequest.GetQueryInt("TemplateLogID") > 0) { var templateLogId = AuthRequest.GetQueryInt("TemplateLogID"); if (templateLogId > 0) { TbContent.Text = DataProvider.TemplateLogDao.GetTemplateContent(templateLogId); SuccessMessage("已导入历史版本的模板内容,点击确定保存模板"); } } } ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(templateInfo.Charset)); ControlUtils.SelectSingleItem(DdlCreatedFileExtName, GetTemplateFileExtension(templateInfo)); HihTemplateType.Value = templateInfo.TemplateType.Value; } else { TbRelatedFileName.Text = "T_"; TbCreatedFileFullName.Text = _templateType == TemplateType.ChannelTemplate ? "index" : "@/"; ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset); ControlUtils.SelectSingleItem(DdlCreatedFileExtName, EFileSystemTypeUtils.GetValue(EFileSystemType.Html)); HihTemplateType.Value = AuthRequest.GetQueryString("TemplateType"); } }
public void Page_Load(object sender, EventArgs e) { if (IsForbidden) { return; } PageUtils.CheckRequestParameter("PublishmentSystemID"); TemplateInfo templateInfo = null; if (Body.GetQueryInt("TemplateID") > 0) { var templateId = Body.GetQueryInt("TemplateID"); _isCopy = Body.GetQueryBool("IsCopy"); templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId); if (templateInfo != null) { _theTemplateType = templateInfo.TemplateType; } } else { _theTemplateType = ETemplateTypeUtils.GetEnumType(Request.QueryString["TemplateType"]); } TemplateTypeString = ETemplateTypeUtils.GetText(_theTemplateType); if (_theTemplateType == ETemplateType.IndexPageTemplate || _theTemplateType == ETemplateType.FileTemplate) { CreatedFileFullNameRow.Visible = true; } else { CreatedFileFullNameRow.Visible = false; } if (!IsPostBack) { var pageTitle = Body.GetQueryInt("TemplateID") > 0 ? "编辑模板" : "添加模板"; BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, pageTitle, AppManager.Cms.Permission.WebSite.Template); ltlPageTitle.Text = pageTitle; var isCodeMirror = PublishmentSystemInfo.Additional.ConfigTemplateIsCodeMirror; btnEditorType.Text = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式"; phCodeMirror.Visible = isCodeMirror; EFileSystemTypeUtils.AddWebPageListItems(CreatedFileExtNameDropDownList); ECharsetUtils.AddListItems(Charset); if (Body.GetQueryInt("TemplateID") > 0) { if (templateInfo != null) { Content.Text = StlCacheManager.FileContent.GetTemplateContent(PublishmentSystemInfo, templateInfo); if (_isCopy) { TemplateName.Text = templateInfo.TemplateName + "_复件"; RelatedFileName.Text = PathUtils.RemoveExtension(templateInfo.RelatedFileName) + "_复件"; CreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName) + "_复件"; } else { TemplateName.Text = templateInfo.TemplateName; RelatedFileName.Text = PathUtils.RemoveExtension(templateInfo.RelatedFileName); CreatedFileFullName.Text = PathUtils.RemoveExtension(templateInfo.CreatedFileFullName); LtlCommands.Text += $@"<a href=""javascript:;"" class=""btn btn-info"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(PublishmentSystemId, templateInfo.TemplateId)}"">生成页面</a><a href=""javascript:;"" class=""btn btn-info"" onclick=""{ModalTemplateRestore.GetOpenLayerString(PublishmentSystemId, templateInfo.TemplateId, string.Empty)}"">还原历史版本</a>"; if (Body.GetQueryInt("TemplateLogID") > 0) { var templateLogId = Body.GetQueryInt("TemplateLogID"); if (templateLogId > 0) { Content.Text = DataProvider.TemplateLogDao.GetTemplateContent(templateLogId); SuccessMessage("已导入历史版本的模板内容,点击确定保存模板"); } } } ControlUtils.SelectListItemsIgnoreCase(Charset, ECharsetUtils.GetValue(templateInfo.Charset)); ControlUtils.SelectListItems(CreatedFileExtNameDropDownList, GetTemplateFileExtension(templateInfo)); TemplateType.Value = ETemplateTypeUtils.GetValue(templateInfo.TemplateType); } } else { RelatedFileName.Text = "T_"; if (_theTemplateType == ETemplateType.ChannelTemplate) { CreatedFileFullName.Text = "index"; } else { CreatedFileFullName.Text = "@/"; } ControlUtils.SelectListItemsIgnoreCase(Charset, PublishmentSystemInfo.Additional.Charset); ControlUtils.SelectListItems(CreatedFileExtNameDropDownList, EFileSystemTypeUtils.GetValue(EFileSystemType.Html)); TemplateType.Value = Body.GetQueryString("TemplateType"); } } }