Example #1
0
        public static List <SelectListItem> GetLanguages(this HtmlHelper html)
        {
            List <SelectListItem> selectList = new List <SelectListItem>();

            Durados.Web.Mvc.Database           database  = Maps.Instance.GetMap().Database;
            Durados.Web.Localization.Localizer localizer = (Durados.Web.Localization.Localizer)database.Localizer;

            if (localizer.Languages != null)
            {
                foreach (Durados.Localization.Model.Language language in localizer.Languages.Where(l => l.Active || database.Localization.DefaultLanguage == l.Code))
                {
                    SelectListItem item = new SelectListItem();
                    item.Value    = language.Code;
                    item.Text     = language.NativeName;
                    item.Selected = localizer.Language.UserLanguageCode == language.Code;

                    selectList.Add(item);
                }
            }
            return(selectList);
        }
Example #2
0
        public List <MenuList> GetMenu()
        {
            List <MenuList> list = new List <MenuList>();

            foreach (Durados.Menu menu in Map.Database.Menus.Values.OrderBy(m => m.Ordinal))
            {
                if (menu.Root)
                {
                    AddSubMenu(list, menu, "");
                }
                else if (menu.HasVisibleViews())
                {
                    string prefix = Map.Database.Localizer.Translate(menu.Name);
                    AddSubMenu(list, menu, prefix);
                }
                if (Map.Database.HasViewsWithNoMenu)
                {
                    AddSubMenu(list, Map.Database.ViewsWithNoMenu, "");
                }
            }

            Durados.Web.Mvc.Database configDatabase = Map.GetConfigDatabase();
            if (!SecurityHelper.IsDenied("", configDatabase.AllowConfigConfigRoles) && configDatabase.HasViewsWithNoMenu)
            {
                string prefix = Map.Database.Localizer.Translate("Admin");
                AddSubMenu(list, configDatabase.ViewsWithNoMenu, prefix);
            }


            //foreach (Durados.Web.Mvc.View view in Map.Database.GetVisibleViews())
            //{
            //    string href = HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + General.GetRootPath() + view.Controller + seperator + view.IndexAction + seperator + view.Name;
            //    list.Add(new MenuList { Name = view.DisplayName, Url = href });
            //}

            return(list);
        }