コード例 #1
0
ファイル: PageTemplateCssAdd.cs プロジェクト: zhongqi013/cms
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("siteId");

            if (Body.IsQueryExists("FileName"))
            {
                _fileName = Body.GetQueryString("FileName");
                _fileName = PathUtils.RemoveParentPath(_fileName);
            }
            _directoryPath = PathUtility.MapPath(SiteInfo, "@/css");

            if (IsPostBack)
            {
                return;
            }

            VerifySitePermissions(ConfigManager.Permissions.WebSite.Template);

            LtlPageTitle.Text = string.IsNullOrEmpty(_fileName) ? "添加样式文件" : "编辑样式文件";

            var isCodeMirror = SiteInfo.Additional.ConfigTemplateIsCodeMirror;

            BtnEditorType.Text   = isCodeMirror ? "采用纯文本编辑模式" : "采用代码编辑模式";
            PhCodeMirror.Visible = isCodeMirror;

            ECharsetUtils.AddListItems(DdlCharset);

            if (_fileName != null)
            {
                if (!EFileSystemTypeUtils.IsCss(PathUtils.GetExtension(_fileName)))
                {
                    PageUtils.RedirectToErrorPage("对不起,此文件无法编辑!");
                }
                else
                {
                    TbRelatedFileName.Text = PathUtils.RemoveExtension(_fileName);
                    var fileCharset = FileUtils.GetFileCharset(PathUtils.Combine(_directoryPath, _fileName));
                    ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, ECharsetUtils.GetValue(fileCharset));
                    TbContent.Text = FileUtils.ReadText(PathUtils.Combine(_directoryPath, _fileName), fileCharset);
                }
            }
            else
            {
                ControlUtils.SelectSingleItemIgnoreCase(DdlCharset, SiteInfo.Additional.Charset);
            }
        }
コード例 #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemID");

            if (Body.IsQueryExists("FileName"))
            {
                fileName = Body.GetQueryString("FileName");
                fileName = PathUtils.RemoveParentPath(fileName);
            }
            directoryPath = PathUtility.MapPath(PublishmentSystemInfo, "@/css");

            if (!IsPostBack)
            {
                var pageTitle = string.IsNullOrEmpty(fileName) ? "添加样式文件" : "编辑样式文件";
                BreadCrumb(AppManager.Cms.LeftMenu.IdTemplate, pageTitle, AppManager.Cms.Permission.WebSite.Template);

                ltlPageTitle.Text = pageTitle;

                ECharsetUtils.AddListItems(Charset);

                if (fileName != null)
                {
                    if (!EFileSystemTypeUtils.IsCss(PathUtils.GetExtension(fileName)))
                    {
                        PageUtils.RedirectToErrorPage("对不起,此文件无法编辑!");
                    }
                    else
                    {
                        RelatedFileName.Text       = PathUtils.RemoveExtension(fileName);
                        ltlCreatedFileExtName.Text = PathUtils.GetExtension(fileName);
                        var fileCharset = FileUtils.GetFileCharset(PathUtils.Combine(directoryPath, fileName));
                        ControlUtils.SelectListItemsIgnoreCase(Charset, ECharsetUtils.GetValue(fileCharset));
                        Content.Text = FileUtils.ReadText(PathUtils.Combine(directoryPath, fileName), fileCharset);
                    }
                }
                else
                {
                    ltlCreatedFileExtName.Text = ".css";
                    ControlUtils.SelectListItemsIgnoreCase(Charset, PublishmentSystemInfo.Additional.Charset);
                }
            }
        }