示例#1
0
        public static List <CustomMenuItem> GetSiteMap()
        {
            Settings s = GetCurrentSettings();
            List <CustomMenuItem> pages = GetMenuAllIncludeNoneAdminMenu(s.ID, SF.GetLangCodeThreading());

            return(pages);
        }
        public ActionResult Index(string lang, string group)
        {
            ViewBag.MessageRed    = TempData["MessageRed"];
            ViewBag.MessageYellow = TempData["MessageYellow"];
            ViewBag.MessageGreen  = TempData["MessageGreen"];

            if (string.IsNullOrEmpty(lang))
            {
                lang = SF.GetLangCodeThreading();
            }
            ViewBag.Lang = lang;

            if (string.IsNullOrEmpty(group))
            {
                group = SF.GetFirstMenuGroup();
            }
            ViewBag.Group = group;

            var menuItems = _db.Menus.Where(x => x.Group == group && x.LangCode == lang).OrderBy(x => x.DisplayOrder).AsNoTracking().ToList();
            var model     = menuItems.Where(x => x.ParentID == 0).ToList();

            model.ForEach(x =>
            {
                x.Childrens = GetChildrens(x.ID, menuItems);//.Where(m => m.ParentID == x.ID).ToList();
            });
            return(View(model));
        }
示例#3
0
        public static string GetSiteMapFormated()
        {
            Settings s = GetCurrentSettings();
            List <CustomMenuItem> pages = GetMenuAllIncludeNoneAdminMenu(s.ID, SF.GetLangCodeThreading());

            return(WriteChildMenu(pages.Where(r => r.Visible == true && r.ShowInSitemap == true).ToList(), null, 10, 1));
        }
示例#4
0
        public ActionResult Index(string lang)
        {
            if (string.IsNullOrEmpty(lang))
            {
                ViewBag.Lang = SF.GetLangCodeThreading();
            }
            else
            {
                ViewBag.Lang = lang;
            }

            return(View());
        }
示例#5
0
        public static string GetMenuFormated(int MaxLevel, int CurrentPageID, string UlID, string UlClass)
        {
            List <CustomMenuItem> pages = GetDisplayMenuRepository();

            if (SF.GetLangCodeThreading() == SF.GetLangCodeWebconfig())
            {
                return(WriteChildMenu(pages.Where(r => r.Visible == true && r.LangCode == SF.GetLangCodeThreading() && r.ShowInMenu == true && r.Level <= MaxLevel).ToList(), null, MaxLevel, 1, CurrentPageID, UlID, UlClass));
            }
            else
            {
                MaxLevel = MaxLevel + 1;
                return(WriteChildMenu(pages.Where(r => r.Visible == true && r.LangCode == SF.GetLangCodeThreading() && r.ShowInMenu == true && r.Level <= MaxLevel).ToList(), null, MaxLevel, 2, CurrentPageID, UlID, UlClass));
            }
        }
示例#6
0
        public ActionResult Index(string lang)
        {
            if (string.IsNullOrEmpty(lang))
            {
                ViewBag.Lang = SF.GetLangCodeThreading();
            }
            else
            {
                ViewBag.Lang = lang;
            }

            ViewBag.ContentUnitMeasures = RP.GetContentUnitMeasures();
            return(View());
        }
示例#7
0
        public override string GetVaryByCustomString(HttpContext context, string arg)
        {
            if (arg == "LangCode")
            {
                return(SF.GetLangCodeThreading());
            }
            else if (arg == "CleanCacheGuid")
            {
                string Token = "CleanCacheGuid";
                object o     = context.Application[Token];
                if (o == null)
                {
                    o = Guid.NewGuid();
                    context.Application[Token] = o;
                }
                return(o.ToString());
            }
            else if (arg == "LangCodeAndCleanCacheGuid")
            {
                string CurrentCulture = SF.GetLangCodeThreading();
                string Token          = string.Format("CleanCacheGuid_{0}", CurrentCulture);

                object o = context.Application[Token];
                if (o == null)
                {
                    o = CurrentCulture + Guid.NewGuid();
                    context.Application[Token] = o;
                }
                return(o.ToString());
            }
            else if (arg == "LangCodeDomainAndCleanCacheGuid")
            {
                string Domain         = SF.GetCurrentDomain();
                string CurrentCulture = SF.GetLangCodeThreading();
                string Token          = string.Format("LangCodeDomainAndCleanCacheGuid_{0}_{1}", CurrentCulture, Domain);

                object o = context.Application[Token];
                if (o == null)
                {
                    o = Guid.NewGuid();
                    context.Application[Token] = o;
                }
                return(o.ToString());
            }

            return(base.GetVaryByCustomString(context, arg));
        }
示例#8
0
        public ActionResult Index(string lang, bool untranslated = false)
        {
            ViewBag.MessageRed    = TempData["MessageRed"];
            ViewBag.MessageYellow = TempData["MessageYellow"];
            ViewBag.MessageGreen  = TempData["MessageGreen"];

            if (string.IsNullOrEmpty(lang))
            {
                ViewBag.Lang = SF.GetLangCodeThreading();
            }
            else
            {
                ViewBag.Lang = lang;
            }
            ViewBag.Untranslated = untranslated;
            return(View());
        }
        public ActionResult _AjaxInsert([DataSourceRequest] DataSourceRequest request, NavigationData item)
        {
            if (ModelState.IsValid)
            {
                item.Segment  = Request["Segment"];
                item.DomainID = RP.GetAdminCurrentSettingsRepository().ID;
                if (string.IsNullOrEmpty(item.LangCode))
                {
                    item.LangCode = SF.GetLangCodeThreading();
                }

                _db.NavigationDatas.Add(item);
                _db.SaveChanges();

                RP.CleanNavigationDataRepository(AdminCurrentSettingsRepository.ID);
            }
            return(Json(new[] { item }.ToDataSourceResult(request, ModelState)));
        }
示例#10
0
        public static List <Translation> GetTranslationsReprository()
        {
            return(LS.Get <Translation>());

            string LanguageCode = SF.GetLangCodeThreading();//RP.GetCurrentSettings().LanguageCode; //<- bug
            string Token        = "Translation_" + LanguageCode;

            if (LS.Cache[Token] == null)
            {
                List <Translation> l = new List <Translation>();
                l = _db.Translations.Where(r => r.LangCode == LanguageCode).ToList();

                LS.Cache[Token] = l;
                return(l);
            }
            else
            {
                return(LS.Cache[Token] as List <Translation>);
            }
        }
        public static List <Banner> GetBannersReprository(string BannerGroup)
        {
            string lang = SF.GetLangCodeThreading();
            string key  = string.Format("BannersReprository_{0}_{1}_{2}", lang, BannerGroup, RP.GetCurrentSettings().ID.ToString());

            if (LS.Cache[key] == null)
            {
                using (Db _db = new Db())
                {
                    int           did = RP.GetAdminCurrentSettingsRepository().ID;
                    List <Banner> l   = _db.Banners.Where(r => r.BannerGroup == BannerGroup && r.DomainID == did &&
                                                          r.LangCode == lang &&
                                                          r.ShowDateMax > DateTime.Now).ToList();


                    //Output
                    foreach (Banner item in l)
                    {
                        if (item.BannerTypeName == Banner.BannerType.Text)
                        {
                            item.Output = "<div class='banner'>" + item.Text + "</div>";
                        }
                        else if (item.BannerTypeName == Banner.BannerType.Html)
                        {
                            item.Output = "<div class='banner'>" + item.Html + "</div>";
                        }
                        else if (item.BannerTypeName == Banner.BannerType.Image)
                        {
                            if (!string.IsNullOrEmpty(item.Link))
                            {
                                item.Output = "<div class='banner'>" + "<a target='_blank' href='" + item.Link + "'><img alt='" + item.Title + "' src='" + item.MainFile + "'></a>" + "</div>";
                            }
                            else if (string.IsNullOrEmpty(item.Link))
                            {
                                item.Output = "<div class='banner'>" + "<img alt='" + item.Title + "' src='" + item.MainFile + "'>" + "</div>";
                            }
                        }
                        else if (item.BannerTypeName == Banner.BannerType.Flash)
                        {
                            item.Output =
                                "<div class='banner banner_holder' style='width:" + item.Width + "px;height:" + item.Height + "px;position:relative;'>"
                                + "<div class='banner_bottom' style='width:" + item.Width + "px;height:" + item.Height + "px;left:0;position:absolute;top:0;z-index:100;'>"
                                + "<object height=\"" + item.Height + "\" width=\"" + item.Width + "\" codebase=\"http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">"
                                + "<param name=\"movie\" value=\"" + item.MainFile + "\" />"
                                + "<param name=\"play\" value=\"true\" />"
                                + "<param name=\"loop\" value=\"true\" />"
                                + "<param name=\"wmode\" value=\"transparent\" />"
                                + "<param name=\"quality\" value=\"high\" />"
                                + "<embed height=\"" + item.Height + "\" width=\"" + item.Width + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" quality=\"high\" wmode=\"transparent\" loop=\"true\" play=\"true\" src=\"" + item.MainFile + "\">"
                                + "</object>"
                                + "</div>"
                                + (string.IsNullOrEmpty(item.Link) ? "" : ("<a target='_blank' href='" + item.Link + "' class='banner_top' style='width:" + item.Width + "px;height:" + item.Height + "px;display:block;left:0;position:absolute;top:0;z-index: 1000;'></a>"))
                                + "</div>";
                        }
                        else if (item.BannerTypeName == Banner.BannerType.FlashAndBackground)
                        {
                            item.Output =
                                "<div class='banner banner_holder' style='width:" + item.Width + "px;height:" + item.Height + "px;position:relative;'>"
                                + "<div syle='width:" + item.Width + "px;height:" + item.Height + "px;display:block;left:0;position:absolute;top:0;z-index: 0;'><img alt='" + item.Title + "' src='" + item.OtherFile + "' style='border-width: 0px; width:" + item.Width + "px; height:" + item.Height + "px;'></div>"
                                + "<div class='banner_bottom' style='width:" + item.Width + "px;height:" + item.Height + "px;left:0;position:absolute;top:0;z-index:100;'>"
                                + "<object height=\"" + item.Height + "\" width=\"" + item.Width + "\" codebase=\"http://active.macromedia.com/flash5/cabs/swflash.cab#version=5,0,0,0' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\">"
                                + "<param name=\"movie\" value=\"" + item.MainFile + "\" />"
                                + "<param name=\"play\" value=\"true\" />"
                                + "<param name=\"loop\" value=\"true\" />"
                                + "<param name=\"wmode\" value=\"transparent\" />"
                                + "<param name=\"quality\" value=\"high\" />"
                                + "<embed height=\"" + item.Height + "\" width=\"" + item.Width + "\" pluginspage=\"http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash\" quality=\"high\" wmode=\"transparent\" loop=\"true\" play=\"true\" src=\"" + item.MainFile + "\">"
                                + "</object>"
                                + "</div>"
                                + (string.IsNullOrEmpty(item.Link) ? "" : ("<a target='_blank' href='" + item.Link + "' class='banner_top' style='width:" + item.Width + "px;height:" + item.Height + "px;display:block;left:0;position:absolute;top:0;z-index: 1000;'></a>"))
                                + "</div>";
                        }
                    }
                    LS.Cache[key] = l;
                    return(l);
                }
            }
            else
            {
                return(LS.Cache[key] as List <Banner>);
            }
        }
        public static Uco.Models.Settings GetCurrentSettings()
        {
            if (LS.CurrentEntityContext == null)
            {
                return
                    new Settings()
                    {
                        AdminEmail   = "*****@*****.**",
                        Domain       = "localhost",
                        LanguageCode = "en-US",
                        Roles        = "",
                    }
            }
            ;

            if (SF.UseMultiDomain() == false)
            {
                string Token = "CurrentSettings_" + SF.GetLangCodeThreading();

                if (LS.Cache[Token] == null)
                {
                    lock (s_lock)
                    {
                        Settings s = GetSettingsRepositoryList().FirstOrDefault();
                        if (s == null)
                        {
                            return(null);
                        }

                        string LangCodeThreading = SF.GetLangCodeThreading();
                        if (SF.GetLangCodeWebconfig() != LangCodeThreading)
                        {
                            LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading);
                            if (l != null)
                            {
                                s.LanguageCode = l.LanguageCode;
                                //s.LanguageRTL = l.ShowOnMainPage;
                                s.HeaderHtml = l.Text2;
                                s.FotterHtml = l.Text3;
                            }
                        }

                        LS.Cache[Token] = s;
                    }
                }
                return((Uco.Models.Settings)LS.Cache[Token]);
            }
            else
            {
                string Domain = SF.GetCurrentDomain();

                if (LS.CurrentHttpContext.Request.IsLocal)
                {
                    string TokenAdmin = "AdminCurrentSettingsRepository";
                    if (LS.CurrentHttpContext.Session[TokenAdmin] != null)
                    {
                        return((Uco.Models.Settings)LS.CurrentHttpContext.Session[TokenAdmin]);
                    }
                    else
                    {
                        string Token = string.Format("CurrentSettingsMultiDomain_{0}_{1}", Domain, SF.GetLangCodeThreading());
                        if (LS.Cache[Token] == null)
                        {
                            lock (s_lock)
                            {
                                Settings s = GetSettingsRepositoryList().FirstOrDefault();
                                if (s == null)
                                {
                                    return(null);
                                }

                                string LangCodeThreading = SF.GetLangCodeThreading();
                                if (SF.GetLangCodeWebconfig() != LangCodeThreading)
                                {
                                    LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading);
                                    if (l != null)
                                    {
                                        s.LanguageCode = l.LanguageCode;
                                        //s.LanguageRTL = l.ShowOnMainPage;
                                        s.HeaderHtml = l.Text2;
                                        s.FotterHtml = l.Text3;
                                    }
                                }

                                LS.Cache[Token] = s;
                            }
                        }
                        return((Uco.Models.Settings)LS.Cache[Token]);
                    }
                }
                else
                {
                    string Token = string.Format("CurrentSettingsMultiDomain_{0}_{1}", Domain, SF.GetLangCodeThreading());
                    if (LS.Cache[Token] == null)
                    {
                        lock (s_lock)
                        {
                            Settings s = GetSettingsRepositoryList().FirstOrDefault(r => r.Domain == Domain);
                            if (s == null)
                            {
                                return(null);
                            }

                            string LangCodeThreading = SF.GetLangCodeThreading();
                            if (SF.GetLangCodeWebconfig() != LangCodeThreading)
                            {
                                LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading);
                                if (l != null)
                                {
                                    s.LanguageCode = l.LanguageCode;
                                    //s.LanguageRTL = l.ShowOnMainPage;
                                    s.HeaderHtml = l.Text2;
                                    s.FotterHtml = l.Text3;
                                }
                            }

                            LS.Cache[Token] = s;
                        }
                    }
                    return((Uco.Models.Settings)LS.Cache[Token]);
                }
            }
        }
 public static void CleanSettingsRepository()
 {
     LS.Cache.Remove("SettingsAll");
     foreach (Settings item in RP.GetSettingsRepositoryList())
     {
         LS.Cache.Remove("CurrentSettingsMultiDomain_" + item.Domain + "_" + item.LanguageCode);
         LS.Cache.Remove("CurrentSettings_" + item.LanguageCode);
     }
     LS.Cache.Remove("CurrentSettingsMultiDomain_" + SF.GetCurrentDomain() + "_" + SF.GetLangCodeThreading());
     LS.CurrentHttpContext.Session["AdminCurrentSettingsRepository"] = null;
 }
示例#14
0
        public static string GetSiteMapFormatedXML(int skip = 0, int take = 20000)
        {
            Settings s = GetCurrentSettings();
            List <CustomMenuItem> pages = new List <CustomMenuItem>();

            if (skip == 0)
            {
                pages = GetMenuAllIncludeNoneAdminMenu(s.ID, SF.GetLangCodeThreading());
            }
            pages = pages.Where(r => r.Visible == true && r.ShowInSitemap == true).ToList();
            var      categoriesFormat = "/{0}#!/category/{1}/{2}";
            var      productsFormat   = "/{0}#!/{1}/{2}";
            var      shopFormat       = "/{0}";
            DateTime now               = DateTime.Now;
            var      today             = new DateTime(now.Year, now.Month, now.Day);
            var      allShops          = _db.Shops.ToList();
            var      allShopCategories = _db.ShopCategories.ToList();
            var      allCategories     = _db.Categories.ToList();

            if (skip == 0)
            {
                foreach (Shop shop in allShops)
                {
                    var menuItem = new CustomMenuItem
                    {
                        RedirectTo    = string.Format(shopFormat, shop.SeoUrl),
                        ChangeTime    = today,
                        Visible       = true,
                        ShowInSitemap = true
                    };
                    pages.Add(menuItem);
                }
                foreach (Shop shop in allShops)
                {
                    var shopCategories = allShopCategories.Where(_ => _.ShopID == shop.ID).ToList();

                    foreach (ShopCategory shopCategory in shopCategories)
                    {
                        var categories = allCategories.Where(_ => _.ID == shopCategory.CategoryID).ToList();
                        foreach (Category category in categories)
                        {
                            var menuItem = new CustomMenuItem
                            {
                                RedirectTo    = string.Format(categoriesFormat, shop.SeoUrl, shop.ID, category.ID),
                                ChangeTime    = today,
                                Visible       = true,
                                ShowInSitemap = true
                            };
                            pages.Add(menuItem);
                        }
                    }
                }
            }
            var usedCount    = pages.Count;
            var canTakeCount = take - usedCount;

            if (canTakeCount < 0)
            {
                canTakeCount = 0;
            }
            var allProductShops = (from ps in _db.ProductShopMap
                                   join p in _db.Products
                                   on ps.ProductID equals p.ID
                                   select new { ps.ID, p.SKU, ProductID = p.ID, ps.ShopID }
                                   ).Distinct().OrderBy(x => x.ID).Skip(skip).Take(canTakeCount).ToList();

            foreach (Shop shop in allShops)
            {
                var productShops = allProductShops.Where(_ => _.ShopID == shop.ID);
                foreach (var productShop in productShops)
                {
                    var menuItem = new CustomMenuItem
                    {
                        RedirectTo    = string.Format(productsFormat, shop.SeoUrl, productShop.SKU, productShop.ID),
                        ChangeTime    = today,
                        Visible       = true,
                        ShowInSitemap = true
                    };
                    pages.Add(menuItem);
                }
            }


            return(WriteChildMenuXML(pages));
        }
示例#15
0
 public Translation()
 {
     this.LangCode = SF.GetLangCodeThreading();
 }