Exemplo n.º 1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            if (IsPostBack)
            {
                return;
            }
            VerifySitePermissions(ConfigManager.WebSitePermissions.Template);

            TemplateTypeUtils.AddListItems(DdlTemplateType);
            ChannelManager.AddListItems(DdlChannelId.Items, SiteInfo, false, true, AuthRequest.AdminPermissionsImpl);
            if (AuthRequest.IsQueryExists("fromCache"))
            {
                TbTemplate.Text = TranslateUtils.DecryptStringBySecretKey(CacheUtils.Get <string>("SiteServer.BackgroundPages.Cms.PageTemplatePreview"));
            }

            if (AuthRequest.IsQueryExists("returnUrl"))
            {
                BtnReturn.Visible = true;
            }
        }
Exemplo n.º 2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            _templateType = AuthRequest.GetQueryString("templateType");
            _keywords     = AuthRequest.GetQueryString("keywords");

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.SitePermissions.Templates);

            DdlTemplateType.Items.Add(new ListItem("<所有类型>", string.Empty));
            TemplateTypeUtils.AddListItems(DdlTemplateType);
            ControlUtils.SelectSingleItem(DdlTemplateType, _templateType);

            TbKeywords.Text = _keywords;

            if (AuthRequest.IsQueryExists("Delete"))
            {
                var templateId = AuthRequest.GetQueryInt("TemplateID");

                try
                {
                    var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId);
                    if (templateInfo != null)
                    {
                        DataProvider.TemplateDao.Delete(SiteId, templateId);
                        AuthRequest.AddSiteLog(SiteId,
                                               $"删除{TemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                               $"模板名称:{templateInfo.TemplateName}");
                    }
                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }
            else if (AuthRequest.IsQueryExists("SetDefault"))
            {
                var templateId = AuthRequest.GetQueryInt("TemplateID");

                try
                {
                    var templateInfo = TemplateManager.GetTemplateInfo(SiteId, templateId);
                    if (templateInfo != null)
                    {
                        DataProvider.TemplateDao.SetDefault(SiteId, templateId);
                        AuthRequest.AddSiteLog(SiteId,
                                               $"设置默认{TemplateTypeUtils.GetText(templateInfo.TemplateType)}",
                                               $"模板名称:{templateInfo.TemplateName}");
                    }
                    SuccessMessage();
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败");
                }
            }

            if (string.IsNullOrEmpty(_templateType))
            {
                LtlCommands.Text = $@"
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.ContentTemplate)}';"" value=""添加内容模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, TemplateType.FileTemplate)}';"" value=""添加单页模板"" />
";
            }
            else
            {
                var templateType = TemplateTypeUtils.GetEnumType(_templateType);
                LtlCommands.Text = $@"
<input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(SiteId, 0, templateType)}';"" value=""添加{TemplateTypeUtils.GetText(templateType)}"" />
";
            }

            RptContents.DataSource     = DataProvider.TemplateDao.GetDataSource(SiteId, _keywords, _templateType);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();
        }