Пример #1
0
        private IExtendField GetCloneNewExtendField(int toSiteId, IExtendField extendField)
        {
            IExtendField toField = this.GetExtendFieldByName(toSiteId, extendField.Name, extendField.Type);

            if (toField == null)
            {
                int id = this.SaveExtendField(toSiteId, new ExtendFieldDto
                {
                    DefaultValue = extendField.DefaultValue,
                    Message      = extendField.Message,
                    Regex        = extendField.Regex,
                    Name         = extendField.Name,
                    Type         = extendField.Type,
                });
                toField = new ExtendField(id, extendField.Name);
            }
            return(toField);
        }
Пример #2
0
        private IExtendField GetCloneNewExtendField(int toSiteId, IExtendField extendField)
        {
            var toField = GetExtendFieldByName(toSiteId, extendField.Name, extendField.Type);

            if (toField == null)
            {
                var r = SaveExtendField(toSiteId, new ExtendFieldDto
                {
                    DefaultValue = extendField.DefaultValue,
                    Message      = extendField.Message,
                    Regex        = extendField.Regex,
                    Name         = extendField.Name,
                    Type         = extendField.Type,
                });
                if (r.ErrCode <= 0)
                {
                    toField = new ExtendField(0, extendField.Name);
                }
            }

            return(toField);
        }
Пример #3
0
        private ArchiveDto GetFormCopyedArchive(int siteId, ICompatibleRequest form, ArchiveDto archive, string alias)
        {
            string content = form.Form("Content");

            //自动替换Tags
            if (form.Form("auto_tag") == "on")
            {
                //todo: tags 顺序调换了下

                /*
                 * HttpTags _tags = this.GetTags(siteId);
                 * content = _tags.Tags.RemoveAutoTags(content);
                 * content = _tags.Tags.ReplaceSingleTag(content);
                 */
            }

            archive.Flag = 0;
            if (form.Form("IsVisible") == "on")
            {
                archive.Flag |= (int)BuiltInArchiveFlags.Visible;
            }
            if (form.Form("AsPage") == "on")
            {
                archive.Flag |= (int)BuiltInArchiveFlags.AsPage;
            }
            if (form.Form("IsSpecial") == "on")
            {
                archive.Flag |= (int)BuiltInArchiveFlags.IsSpecial;
            }
            if (form.Form("IsSystem") == "on")
            {
                archive.Flag |= (int)BuiltInArchiveFlags.IsSystem;
            }
            archive.UpdateTime = DateTime.Now;
            archive.Title      = form.Form("Title").ToString().Trim();
            archive.SmallTitle = form.Form("SmallTitle").ToString().Trim();
            archive.Location   = form.Form("location").ToString().Trim();
            archive.Source     = form.Form("Source");
            archive.Outline    = form.Form("Outline");
            archive.Alias      = alias;
            archive.Tags       = form.Form("Tags").ToString().Replace(",", ",");
            archive.Content    = content;
            archive.Thumbnail  = form.Form("Thumbnail");

            //分类
            var categoryId = int.Parse(form.Form("categoryid"));

            archive.Category = new CategoryDto {
                ID = categoryId
            };

            //检测图片是否为默认图片
            if (archive.Thumbnail == CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto)
            {
                archive.Thumbnail = string.Empty;
            }

            archive.ExtendValues = new List <IExtendValue>();

            //=============== 更新扩展字段 ===================

            IExtendField field;
            string       extendValue;

            foreach (var key in form.FormKeys())
            {
                if (key.StartsWith("extend_"))
                {
                    extendValue = form.Form(key);
                    field       = new ExtendField(int.Parse(key.Substring(7)), null);
                    archive.ExtendValues.Add(new ExtendValue(-1, field, extendValue));
                }
            }

            //更新模板设置
            archive.TemplatePath = form.Form("TemplatePath");
            if (archive.TemplatePath != string.Empty)
            {
                archive.IsSelfTemplate = true;
            }
            return(archive);
        }
Пример #4
0
        private ArchiveDto GetFormCopyedArchive(int siteId, NameValueCollection form, ArchiveDto archive, string alias)
        {
            string flag = ArchiveFlag.GetFlagString(
                form["IsSystem"] == "on",     //系统
                form["IsSpecial"] == "on",    //特殊
                form["IsNotVisible"] != "on", //隐藏
                form["AsPage"] == "on",       //作为单页
                null);

            string content = form["Content"];

            //自动替换Tags
            if (form["autotag"] == "on")
            {
                //todo:顺序调换了下
                HttpTags _tags = this.GetTags(siteId);
                content = _tags.Tags.RemoveAutoTags(content);
                content = _tags.Tags.ReplaceSingleTag(content);
            }

            archive.LastModifyDate = DateTime.Now;
            archive.Title          = form["Title"];
            archive.Source         = form["Source"];
            archive.Outline        = form["Outline"];
            archive.Alias          = alias;
            archive.Flags          = flag;
            archive.Tags           = form["Tags"].Replace(",", ",");
            archive.Content        = content;
            archive.Thumbnail      = form["Thumbnail"];

            //分类
            int categoryID = int.Parse(form["categoryid"]);

            archive.Category = new CategoryDto {
                ID = categoryID
            };

            //检测图片是否为默认图片
            if (archive.Thumbnail == CmsVariables.FRAMEWORK_ARCHIVE_NoPhoto)
            {
                archive.Thumbnail = String.Empty;
            }

            archive.ExtendValues = new List <IExtendValue>();

            //=============== 更新扩展字段 ===================

            IExtendField field;
            string       extendValue;

            foreach (string key in form.Keys)
            {
                if (key.StartsWith("extend_"))
                {
                    extendValue = form[key];
                    field       = new ExtendField(int.Parse(key.Substring(7)), null);
                    archive.ExtendValues.Add(new ExtendValue(-1, field, extendValue));
                }
            }

            //更新模板设置
            archive.TemplatePath = form["TemplatePath"];
            if (archive.TemplatePath != String.Empty)
            {
                archive.IsSelfTemplate = true;
            }
            return(archive);
        }