Ejemplo n.º 1
0
        public IEnumerable <SelectListItem> GetValidParents(Webpage webpage)
        {
            List <DocumentMetadata> validParentTypes = DocumentMetadataHelper.GetValidParentTypes(webpage);

            List <string> validParentTypeNames =
                validParentTypes.Select(documentMetadata => documentMetadata.Type.FullName).ToList();
            IList <Webpage> potentialParents =
                _session.QueryOver <Webpage>()
                .Where(page => page.DocumentType.IsIn(validParentTypeNames))
                .Cacheable().List <Webpage>();

            List <SelectListItem> result = potentialParents.Distinct()
                                           .Where(page => !page.ActivePages.Contains(webpage))
                                           .OrderBy(x => x.Name)
                                           .BuildSelectItemList(page => string.Format("{0} ({1})", page.Name, page.GetMetadata().Name),
                                                                page => page.Id.ToString(),
                                                                webpage1 => webpage.Parent != null && webpage.ParentId == webpage1.Id, emptyItem: null);

            if (!webpage.GetMetadata().RequiresParent)
            {
                result.Insert(0, SelectListItemHelper.EmptyItem("Root"));
            }

            return(result);
        }
Ejemplo n.º 2
0
        public List <SelectListItem> GetLanguageOptions(string key, Site site)
        {
            List <CultureInfo>   cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures).ToList();
            IEnumerable <string> languages    = _provider.GetOverriddenLanguages(key, site);

            cultureInfos.RemoveAll(info => languages.Contains(info.Name));
            return(cultureInfos.OrderBy(info => info.DisplayName)
                   .BuildSelectItemList(info => info.DisplayName, info => info.Name,
                                        info => info.Name == _siteSettings.UICulture,
                                        SelectListItemHelper.EmptyItem("Select a culture...")));
        }
Ejemplo n.º 3
0
        public IEnumerable <SelectListItem> GetValidParents(Webpage webpage)
        {
            var webpages = GetValidParentWebpages(webpage);
            List <SelectListItem> result = webpages
                                           .BuildSelectItemList(page => string.Format("{0} ({1})", page.Name, page.GetMetadata().Name),
                                                                page => page.Id.ToString(),
                                                                webpage1 => webpage.Parent != null && webpage.ParentId == webpage1.Id, emptyItem: null);

            if (IsRootAllowed(webpage))
            {
                result.Insert(0, SelectListItemHelper.EmptyItem("Root"));
            }

            return(result);
        }
Ejemplo n.º 4
0
        public override void AssignViewData(Widgets.MobileFriendlyNavigation widget, ViewDataDictionary viewData)
        {
            var webpages =
                _session.QueryOver <Webpage>()
                .Where(webpage => webpage.Parent == null)
                .OrderBy(webpage => webpage.DisplayOrder)
                .Asc.List();

            viewData["root-webpage-options"] = webpages.BuildSelectItemList(webpage => webpage.Name, webpage => webpage.Id.ToString(),
                                                                            emptyItem: SelectListItemHelper.EmptyItem("Site Root", "0"));
        }