コード例 #1
0
ファイル: Compose.aspx.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        /// 装载模板副本内容
        /// </summary>
        /// <param name="tp"></param>
        void LoadTemplateCopy(Template tp)
        {
            string   copyFile = TemplateCopies.GetThisTemplateCopy(tp, FilenameTextBox.Text);
            FileInfo cfi      = new FileInfo(copyFile);
            FileInfo fi       = new FileInfo(tp.FileName);

            if (fi.Exists && (!cfi.Exists || cfi.LastWriteTime < fi.LastWriteTime))
            {
                TemplateCopies.MergeToTemplateCopy(tp.FileName, tp);
            }
            LoadTemplateFromFile(copyFile);
        }
コード例 #2
0
ファイル: Compose.aspx.cs プロジェクト: jiaping/JPCMS
        /// <summary>
        /// 将本副本发布到正本
        /// </summary>
        /// <returns></returns>
        bool PublishTemplateCopy()
        {
            string fn = Server.MapPath(CurrentTemplate.FilePath);

            try
            {
                TemplateCopies.PublistCopy(CurrentTemplate, FilenameTextBox.Text, TemplateContentTextBox.Value);
                TemplateProcessor.PublicTemplate(CurrentTemplate.EditFileFullPath, fn);
                //File.Copy(EditFileName, fn, true);
                Messages.ShowMessage("副本已成功发布!");
                return(true);
            }
            catch (Exception ex)
            {
                Messages.ShowError("发布模板副本出错。错误:" + ex.Message);
                return(false);
            }
        }
コード例 #3
0
ファイル: Compose.aspx.cs プロジェクト: jiaping/JPCMS
        /// <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);
            }
        }