コード例 #1
0
ファイル: PageServiceSTL.cs プロジェクト: skotbenben/cms
        public string GetLoadingTemplates(int publishmentSystemId, string templateType)
        {
            var arraylist = new ArrayList();

            var eTemplateType = ETemplateTypeUtils.GetEnumType(templateType);

            var templateInfoList = DataProvider.TemplateDao.GetTemplateInfoListByType(publishmentSystemId, eTemplateType);

            foreach (var templateInfo in templateInfoList)
            {
                var templateAddUrl = PageTemplateAdd.GetRedirectUrl(publishmentSystemId, templateInfo.TemplateId, eTemplateType);
                arraylist.Add($@"
<tr treeitemlevel=""3"">
	<td align=""left"" nowrap="""">
		<img align=""absmiddle"" src=""../assets/icons/tree/empty.gif""><img align=""absmiddle"" src=""../assets/icons/tree/empty.gif""><img align=""absmiddle"" src=""../assets/icons/menu/template.gif"">&nbsp;<a href=""{templateAddUrl}"" onclick=""fontWeightLink(this)"" target=""management"">{templateInfo.TemplateName}</a>
	</td>
</tr>
");
            }

            var builder = new StringBuilder();

            foreach (string html in arraylist)
            {
                builder.Append(html);
            }
            return(builder.ToString());
        }
コード例 #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var templateLogId = TranslateUtils.ToInt(DdlLogId.SelectedValue);

            if (templateLogId == 0)
            {
                FailMessage("当前模板不存在历史版本,无法进行还原");
            }
            else
            {
                LayerUtils.CloseAndRedirect(Page, PageTemplateAdd.GetRedirectUrlToRestore(SiteId, _templateId, templateLogId));
            }
        }
コード例 #3
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();
        }
コード例 #4
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var templateId          = SqlUtils.EvalInt(e.Item.DataItem, nameof(TemplateInfo.Id));
            var templateType        = TemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateType)));
            var templateName        = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.TemplateName));
            var relatedFileName     = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.RelatedFileName));
            var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.CreatedFileFullName));
            var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, nameof(TemplateInfo.IsDefault)));

            var ltlTemplateName    = (Literal)e.Item.FindControl("ltlTemplateName");
            var ltlRelatedFileName = (Literal)e.Item.FindControl("ltlRelatedFileName");
            var ltlFileName        = (Literal)e.Item.FindControl("ltlFileName");
            var ltlUseCount        = (Literal)e.Item.FindControl("ltlUseCount");
            var ltlTemplateType    = (Literal)e.Item.FindControl("ltlTemplateType");
            var ltlDefaultUrl      = (Literal)e.Item.FindControl("ltlDefaultUrl");
            var ltlCopyUrl         = (Literal)e.Item.FindControl("ltlCopyUrl");
            var ltlLogUrl          = (Literal)e.Item.FindControl("ltlLogUrl");
            var ltlCreateUrl       = (Literal)e.Item.FindControl("ltlCreateUrl");
            var ltlDeleteUrl       = (Literal)e.Item.FindControl("ltlDeleteUrl");

            var templateAddUrl = PageTemplateAdd.GetRedirectUrl(SiteId, templateId, templateType);

            ltlTemplateName.Text    = $@"<a href=""{templateAddUrl}"">{templateName}</a>";
            ltlRelatedFileName.Text = relatedFileName;

            if (templateType == TemplateType.IndexPageTemplate || templateType == TemplateType.FileTemplate)
            {
                var url = PageUtility.ParseNavigationUrl(SiteInfo, createdFileFullName, false);
                ltlFileName.Text = $"<a href='{url}' target='_blank'>{createdFileFullName}</a>";
            }

            ltlUseCount.Text = DataProvider.ChannelDao.GetTemplateUseCount(SiteId, templateId, templateType, isDefault).ToString();

            ltlTemplateType.Text = TemplateTypeUtils.GetText(templateType);

            if (templateType != TemplateType.FileTemplate)
            {
                if (isDefault)
                {
                    ltlDefaultUrl.Text = @"<span class=""badge badge-primary"">默认模板</span>";
                }
                else
                {
                    var defaultUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageTemplate), new NameValueCollection
                    {
                        { "TemplateID", templateId.ToString() },
                        { "SetDefault", true.ToString() },
                        { "TemplateType", templateType.Value }
                    });
                    ltlDefaultUrl.Text =
                        $@"<a href=""{defaultUrl}"" onClick=""javascript:return confirm('此操作将把此模板设为默认,确认吗?');"">设为默认</a>";
                }
            }

            var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(SiteId, templateId);

            ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

            var logUrl = PageTemplateLog.GetRedirectUrl(SiteId, templateId);

            ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

            ltlCreateUrl.Text =
                $@"<a href=""javascript:;"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(
                    SiteId, templateId)}"">生成页面</a>";

            if (!isDefault)
            {
                var deleteUrl = PageUtils.GetCmsUrl(SiteId, nameof(PageTemplate), new NameValueCollection
                {
                    { "TemplateID", templateId.ToString() },
                    { "Delete", true.ToString() },
                    { "TemplateType", templateType.Value }
                });

                ltlDeleteUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{AlertUtils.ConfirmDelete("删除文件", $"此操作将删除模板“{templateName}”,确认吗?", deleteUrl)}"">删除</a>";
            }
        }
コード例 #5
0
ファイル: PageTemplate.cs プロジェクト: yankaics/cms-1
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

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

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, "模板管理", AppManager.Cms.Permission.WebSite.Template);

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

                TbKeywords.Text = _keywords;

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

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

                    try
                    {
                        var templateInfo = TemplateManager.GetTemplateInfo(PublishmentSystemId, templateId);
                        if (templateInfo != null)
                        {
                            DataProvider.TemplateDao.SetDefault(PublishmentSystemId, templateId);
                            Body.AddSiteLog(PublishmentSystemId,
                                            $"设置默认{ETemplateTypeUtils.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(PublishmentSystemId, 0, ETemplateType.IndexPageTemplate)}';"" value=""添加首页模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ChannelTemplate)}';"" value=""添加栏目模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.ContentTemplate)}';"" value=""添加内容模板"" />
<input type=""button"" class=""btn"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, ETemplateType.FileTemplate)}';"" value=""添加单页模板"" />
";
                }
                else
                {
                    var eTemplateType = ETemplateTypeUtils.GetEnumType(_templateType);
                    LtlCommands.Text = $@"
<input type=""button"" class=""btn btn-success"" onclick=""location.href='{PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, 0, eTemplateType)}';"" value=""添加{ETemplateTypeUtils.GetText(eTemplateType)}"" />
";
                }

                DgContents.DataSource     = DataProvider.TemplateDao.GetDataSource(PublishmentSystemId, _keywords, _templateType);
                DgContents.ItemDataBound += DgContents_ItemDataBound;
                DgContents.DataBind();
            }
        }
コード例 #6
0
ファイル: PageTemplate.cs プロジェクト: yankaics/cms-1
        private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var templateId          = SqlUtils.EvalInt(e.Item.DataItem, "TemplateID");
                var templateType        = ETemplateTypeUtils.GetEnumType(SqlUtils.EvalString(e.Item.DataItem, "TemplateType"));
                var templateName        = SqlUtils.EvalString(e.Item.DataItem, "TemplateName");
                var createdFileFullName = SqlUtils.EvalString(e.Item.DataItem, "CreatedFileFullName");
                var isDefault           = TranslateUtils.ToBool(SqlUtils.EvalString(e.Item.DataItem, "IsDefault"));

                var ltlTemplateName = (Literal)e.Item.FindControl("ltlTemplateName");
                var ltlFileName     = (Literal)e.Item.FindControl("ltlFileName");
                var ltlUseCount     = (Literal)e.Item.FindControl("ltlUseCount");
                var ltlTemplateType = (Literal)e.Item.FindControl("ltlTemplateType");
                var ltlDefaultUrl   = (Literal)e.Item.FindControl("ltlDefaultUrl");
                var ltlCopyUrl      = (Literal)e.Item.FindControl("ltlCopyUrl");
                var ltlLogUrl       = (Literal)e.Item.FindControl("ltlLogUrl");
                var ltlCreateUrl    = (Literal)e.Item.FindControl("ltlCreateUrl");
                var ltlDeleteUrl    = (Literal)e.Item.FindControl("ltlDeleteUrl");

                var templateAddUrl = PageTemplateAdd.GetRedirectUrl(PublishmentSystemId, templateId, templateType);
                ltlTemplateName.Text = $@"<a href=""{templateAddUrl}"">{templateName}</a>";

                if (templateType == ETemplateType.IndexPageTemplate || templateType == ETemplateType.FileTemplate)
                {
                    var url = PageUtility.ParseNavigationUrl(PublishmentSystemInfo, createdFileFullName);
                    ltlFileName.Text = $"<a href='{url}' target='_blank'>{createdFileFullName}</a>";
                }

                ltlUseCount.Text = DataProvider.TemplateDao.GetTemplateUseCount(PublishmentSystemId, templateId, templateType, isDefault).ToString();

                ltlTemplateType.Text = ETemplateTypeUtils.GetText(templateType);

                if (templateType != ETemplateType.FileTemplate)
                {
                    if (isDefault)
                    {
                        ltlDefaultUrl.Text = "默认模板";
                    }
                    else
                    {
                        var defaultUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                        {
                            { "PublishmentSystemID", PublishmentSystemId.ToString() },
                            { "TemplateID", templateId.ToString() },
                            { "SetDefault", true.ToString() }
                        });
                        ltlDefaultUrl.Text =
                            $@"<a href=""{defaultUrl}"" onClick=""javascript:return confirm('此操作将把此模板设为默认,确认吗?');"">设为默认</a>";
                    }
                }

                var copyUrl = PageTemplateAdd.GetRedirectUrlToCopy(PublishmentSystemId, templateId);
                ltlCopyUrl.Text = $@"<a href=""{copyUrl}"">快速复制</a>";

                var logUrl = PageTemplateLog.GetRedirectUrl(PublishmentSystemId, templateId);
                ltlLogUrl.Text = $@"<a href=""{logUrl}"">修订历史</a>";

                ltlCreateUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalProgressBar.GetOpenWindowStringWithCreateByTemplate(
                        PublishmentSystemId, templateId)}"">生成页面</a>";

                if (!isDefault)
                {
                    var deleteUrl = PageUtils.GetCmsUrl(nameof(PageTemplate), new NameValueCollection
                    {
                        { "PublishmentSystemID", PublishmentSystemId.ToString() },
                        { "TemplateID", templateId.ToString() },
                        { "Delete", true.ToString() }
                    });
                    ltlDeleteUrl.Text =
                        $@"<a href=""{deleteUrl}"" onClick=""javascript:return confirm('此操作将删除模板“{templateName}”,确认吗?');"">删除</a>";
                }
            }
        }