Пример #1
0
        public NBrightInfo GetSinglePageData(string GuidKey, string typeCode, string lang)
        {
            DataCache.ClearCache(); // clear ALL cache.
            var info = GetByGuidKey(PortalSettings.Current.PortalId, -1, typeCode, GuidKey);

            if (info == null)
            {
                // create record if not in DB
                info          = new NBrightInfo(true);
                info.GUIDKey  = GuidKey;
                info.TypeCode = typeCode;
                info.ModuleId = -1;
                info.PortalId = PortalSettings.Current.PortalId;
                info.ItemID   = Update(info);
            }
            var nbilang = GetDataLang(info.ItemID, lang);

            if (nbilang == null)
            {
                // create lang records if not in DB
                foreach (var lg in DnnUtils.GetCultureCodeList(PortalSettings.Current.PortalId))
                {
                    nbilang = GetDataLang(info.ItemID, lg);
                    if (nbilang == null)
                    {
                        nbilang              = new NBrightInfo(true);
                        nbilang.GUIDKey      = "";
                        nbilang.TypeCode     = typeCode + "LANG";
                        nbilang.ParentItemId = info.ItemID;
                        nbilang.Lang         = lg;
                        nbilang.ModuleId     = -1;
                        nbilang.PortalId     = PortalSettings.Current.PortalId;
                        nbilang.ItemID       = Update(nbilang);
                    }
                }
            }

            // do edit field data if a itemid has been selected
            var nbi = Get(info.ItemID, lang);

            return(nbi);
        }
Пример #2
0
 public override List <string> GetCultureCodeList()
 {
     return(DnnUtils.GetCultureCodeList());
 }
Пример #3
0
        public void FillEmptyLanguageFields(int baseParentItemId, String baseLang)
        {
            var baseInfo = GetDataLang(baseParentItemId, baseLang, true); // do NOT take cache

            if (baseInfo != null)
            {
                foreach (var toLang in DnnUtils.GetCultureCodeList(baseInfo.PortalId))
                {
                    if (toLang != baseInfo.Lang)
                    {
                        var updatedata = false;
                        var dlang      = GetDataLang(baseParentItemId, toLang, true); // do NOT take cache
                        if (dlang != null)
                        {
                            var nodList = baseInfo.XMLDoc.SelectNodes("genxml/textbox/*");
                            if (nodList != null)
                            {
                                foreach (XmlNode nod in nodList)
                                {
                                    if (nod.InnerText.Trim() != "")
                                    {
                                        if (dlang.GetXmlProperty("genxml/textbox/" + nod.Name) == "")
                                        {
                                            dlang.SetXmlProperty("genxml/textbox/" + nod.Name, nod.InnerText);
                                            updatedata = true;
                                        }
                                    }
                                }
                            }

                            var nodList2i = baseInfo.XMLDoc.SelectNodes("genxml/imgs/genxml");
                            if (nodList2i != null)
                            {
                                for (int i = 1; i <= nodList2i.Count; i++)
                                {
                                    var nodList2 = baseInfo.XMLDoc.SelectNodes("genxml/imgs/genxml[" + i + "]/textbox/*");
                                    if (nodList2 != null)
                                    {
                                        foreach (XmlNode nod in nodList2)
                                        {
                                            if (nod.InnerText.Trim() != "")
                                            {
                                                if (dlang.GetXmlProperty("genxml/imgs/genxml[" + i + "]/textbox/" + nod.Name) == "")
                                                {
                                                    if (dlang.XMLDoc.SelectSingleNode("genxml/imgs/genxml[" + i + "]") == null)
                                                    {
                                                        var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/imgs/genxml[" + i + "]");
                                                        if (baseXml != null)
                                                        {
                                                            if (dlang.XMLDoc.SelectSingleNode("genxml/imgs") == null)
                                                            {
                                                                dlang.AddSingleNode("imgs", "", "genxml");
                                                            }
                                                            dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/imgs");
                                                        }
                                                    }
                                                    dlang.SetXmlProperty("genxml/imgs/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText);
                                                    updatedata = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }


                            var nodList3i = baseInfo.XMLDoc.SelectNodes("genxml/docs/genxml");
                            if (nodList3i != null)
                            {
                                for (int i = 1; i <= nodList3i.Count; i++)
                                {
                                    var nodList3 = baseInfo.XMLDoc.SelectNodes("genxml/docs/genxml[" + i + "]/textbox/*");
                                    if (nodList3 != null)
                                    {
                                        foreach (XmlNode nod in nodList3)
                                        {
                                            if (nod.InnerText.Trim() != "")
                                            {
                                                if (dlang.GetXmlProperty("genxml/docs/genxml[" + i + "]/textbox/" + nod.Name) == "")
                                                {
                                                    if (dlang.XMLDoc.SelectSingleNode("genxml/docs/genxml[" + i + "]") == null)
                                                    {
                                                        var baseXml = baseInfo.XMLDoc.SelectSingleNode("genxml/docs/genxml[" + i + "]");
                                                        if (baseXml != null)
                                                        {
                                                            if (dlang.XMLDoc.SelectSingleNode("genxml/docs") == null)
                                                            {
                                                                dlang.AddSingleNode("docs", "", "genxml");
                                                            }
                                                            dlang.AddXmlNode(baseXml.OuterXml, "genxml", "genxml/docs");
                                                        }
                                                    }
                                                    dlang.SetXmlProperty("genxml/docs/genxml[" + i + "]/textbox/" + nod.Name, nod.InnerText);
                                                    updatedata = true;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        if (updatedata)
                        {
                            Update(dlang);
                        }
                    }
                }
            }
        }