public static string SaveByPostForm(ICompatibleRequest form) { var file = Cms.PhysicPath + CmsVariables.SITE_LOCALE_PATH; IList <LangKvPair> list = new List <LangKvPair>(); var row = 0; var lang = 0; LangKvPair p; IList <string> k1 = new List <string>(); IList <string> v1 = new List <string>(); foreach (var pk in form.FormKeys()) { if (pk.StartsWith("k_")) { k1.Add(pk); } else if (pk.StartsWith("f_")) { v1.Add(pk); } } foreach (var k in k1) { if (int.TryParse(k.Substring(2), out row)) //获取行号 { p = new LangKvPair(); p.key = form.Form(k); p.value = new Dictionary <int, string>(); var fPre = "f_" + row.ToString() + "_"; for (var j = 0; j < v1.Count; j++) { if (v1[j].StartsWith(fPre)) //获取对英语言的值,并移除 { if (int.TryParse(v1[j].Substring(fPre.Length), out lang)) { p.value[lang] = form.Form(v1[j]); } } } //v1.Remove(v1[j]); list.Add(p); } } if (list.Count > 0) { var arr = SortLocaleList(list); return(FlushToFile(file, arr)); } return(null); }
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); }