예제 #1
0
        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);
        }
예제 #2
0
        public static string SaveByPostForm(NameValueCollection form)
        {
            String             file = Cms.PyhicPath + CmsVariables.SITE_LOCALE_PATH;
            IList <LangKvPair> list = new List <LangKvPair>();
            int            row      = 0;
            int            lang     = 0;
            LangKvPair     p;
            IList <String> k1 = new List <string>();
            IList <String> v1 = new List <string>();

            foreach (String pk in form.Keys)
            {
                if (pk.StartsWith("k_"))
                {
                    k1.Add(pk);
                }
                else if (pk.StartsWith("f_"))
                {
                    v1.Add(pk);
                }
            }

            foreach (String k in k1)
            {
                if (int.TryParse(k.Substring(2), out row)) //获取行号
                {
                    p       = new LangKvPair();
                    p.key   = form.Get(k);
                    p.value = new Dictionary <int, string>();
                    String fPre = "f_" + row.ToString() + "_";
                    for (int 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[v1[j]];
                            }
                            //v1.Remove(v1[j]);
                        }
                    }
                    list.Add(p);
                }
            }

            if (list.Count > 0)
            {
                var arr = SortLocaleList(list);
                return(FlushToFile(file, arr));
            }
            return(null);
        }