Esempio n. 1
0
        protected override void Initialize()
        {
            string file = FileTextBox.Text = Request["file"];

            We7Helper.Assert(file != null, " 非法的参数。");

            Template tp = new Template();

            if (EnableSiteSkins)
            {
                tp.FromFile(Server.MapPath(String.Format("\\{0}\\{1}", Constants.TemplateBasePath, FileFolder)), file + ".xml");
                FileName = TemplateHelper.GetTemplatePath(String.Format("{0}/{1}", FileFolder, tp.FileName));
            }
            else
            {
                tp.FromFile(Server.MapPath(Constants.TemplateBasePath), file + ".xml");
                FileName = TemplateHelper.GetTemplatePath(tp.FileName);
            }

            NameLabel.Text    = "编辑模板";
            SummaryLabel.Text = String.Format("正在编辑" + InfoKey + "文件 {0}。", tp.FileName);

            string fn = Server.MapPath(FileName);

            if (File.Exists(fn))
            {
                LoadTemplateFromFile(fn);
            }
            else
            {
                SummaryLabel.Text = String.Format("新建的" + InfoKey + "文件,将被保存到文件 {0}", FileName);
            }
            TemplatePathTextBox.Text = Constants.TemplateUrlPath;
            string path = string.Format("/{0}/{1}", Constants.TemplateBasePath, FileFolder);
        }
Esempio n. 2
0
        /// <summary>
        /// 页面初始化
        /// </summary>
        protected override void Initialize()
        {
            string currentTemplateGroupName = TemplateHelper.GetCurrentExistTemplateGroup();

            if (string.IsNullOrEmpty(currentTemplateGroupName))
            {
                TemplateHelper.CreateDefaultTemplateGroup();
            }

            try
            {
                We7Helper.Assert(CurrentTemplate.FileName != null, " 非法的参数。");
                if (!CurrentTemplate.IsNew)
                {
                    CurrentTemplate.FromFile(Server.MapPath(String.Format("\\{0}\\{1}", Constants.TemplateBasePath, CurrentTemplate.SkinFolder)), CurrentTemplate.FileName + ".xml");
                }
                CurrentTemplate.FilePath = TemplateHelper.GetTemplatePath(String.Format("{0}/{1}", CurrentTemplate.SkinFolder, CurrentTemplate.FileName));
                FilenameTextBox.Text     = CurrentTemplate.FileName;
                if (CurrentTemplate.IsNew)
                {
                    ActionLiteral.Text = "新建";
                }
                else
                {
                    ActionLiteral.Text = "编辑";
                }
                ActionLiteral.Text += CurrentTemplate.TemplateTypeText;

                NameTextbox.Text = CurrentTemplate.Name;

                this.Page.Title = ActionLiteral.Text + NameLabel.Text;
                if (CurrentTemplate.IsNew)
                {
                    FilenameTextBox.Text    = String.Format("{0}", CurrentTemplate.FileName);
                    FilenameTextBox.Visible = true;
                }
                else
                {
                    SummaryLabel.Text       = String.Format("{0}", CurrentTemplate.FileName);
                    FilenameTextBox.Visible = false;
                }

                string fn = Server.MapPath(CurrentTemplate.FilePath);
                if (CDHelper.Config.SiteBuildState == "run") //处于运行状态,启用副本
                {
                    PublishSpan.Visible = true;
                    CurrentTemplate.EditFileFullPath = TemplateCopies.GetThisTemplateCopy(CurrentTemplate, FilenameTextBox.Text);
                    if (File.Exists(fn) || File.Exists(CurrentTemplate.EditFileFullPath))
                    {
                        LoadTemplateCopy(CurrentTemplate);
                    }

                    InitCopyControls(CurrentTemplate.EditFileFullPath);
                    SummaryLabel.Text += "编辑后的内容将保存到副本中,发布后才会正式启用。";
                }
                else
                {
                    PublishSpan.Visible = false;
                    if (File.Exists(fn))
                    {
                        LoadTemplateFromFile(fn);
                    }
                    else
                    {
                        //SummaryLabel.Text = String.Format("文件将保存到{0},", CurrentTemplate.FileName);
                        TemplateContentTextBox.Value = @"<html>
    <head>
        <title></title>
   </head>
    <body>
    </body>
</html>";
                    }
                    InitCopyControls(fn);
                }

                TemplatePathTextBox.Text = Constants.TemplateUrlPath;
                string path = string.Format("/{0}/{1}", Constants.TemplateBasePath, CurrentTemplate.SkinFolder);

                PrevewDropDownList.Visible = !CurrentTemplate.IsMasterPage;
            }
            catch (Exception ex)
            {
                Messages.ShowError(ex.Message);
            }
        }