Esempio n. 1
0
        /// <summary>
        /// Sorts the items.
        /// </summary>
        /// <param name="pages">The full page list</param>
        /// <param name="parentId">The current parent id</param>
        /// <param name="level">The level in structure</param>
        /// <returns>The sitemap</returns>
        private Models.Sitemap Sort(IEnumerable <Page> pages, Guid?parentId = null, int level = 0)
        {
            var result = new Models.Sitemap();

            foreach (var page in pages.Where(p => p.ParentId == parentId).OrderBy(p => p.SortOrder))
            {
                var item = Module.Mapper.Map <Page, Models.SitemapItem>(page);

                if (!string.IsNullOrEmpty(page.RedirectUrl))
                {
                    item.Permalink = page.RedirectUrl;
                }

                item.Level        = level;
                item.PageTypeName = App.PageTypes.First(t => t.Id == page.PageTypeId).Title;
                item.Items        = Sort(pages, page.Id, level + 1);

                //use for multilanguage - anhpt
                Guid   siteId   = _db.Pages.SingleOrDefault(x => x.Id == item.Id).SiteId;
                string hostName = _db.Sites.SingleOrDefault(x => x.Id == siteId).Hostnames;
                string urlName  = hostName.Substring(hostName.Length - 3, 3);
                item.Permalink = urlName + item.Permalink;

                result.Add(item);
            }
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Sorts the items.
        /// </summary>
        /// <param name="pages">The full page list</param>
        /// <param name="parentId">The current parent id</param>
        /// <returns>The sitemap</returns>
        private Models.Sitemap Sort(IEnumerable <Page> pages, Guid?parentId = null, int level = 0)
        {
            var result = new Models.Sitemap();

            foreach (var page in pages.Where(p => p.ParentId == parentId).OrderBy(p => p.SortOrder))
            {
                var item = App.Mapper.Map <Page, Models.SitemapItem>(page);

                item.Level = level;
                item.Items = Sort(pages, page.Id, level + 1);

                result.Add(item);
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Sorts the items.
        /// </summary>
        /// <param name="pages">The full page list</param>
        /// <param name="parentId">The current parent id</param>
        /// <returns>The sitemap</returns>
        private Models.Sitemap Sort(IEnumerable <Page> pages, IEnumerable <Models.PageType> pageTypes, Guid?parentId = null, int level = 0)
        {
            var result = new Models.Sitemap();

            foreach (var page in pages.Where(p => p.ParentId == parentId).OrderBy(p => p.SortOrder))
            {
                var item = App.Mapper.Map <Page, Models.SitemapItem>(page);

                if (!string.IsNullOrEmpty(page.RedirectUrl))
                {
                    item.Permalink = page.RedirectUrl;
                }

                item.Level        = level;
                item.PageTypeName = pageTypes.First(t => t.Id == page.PageTypeId).Title;
                item.Items        = Sort(pages, pageTypes, page.Id, level + 1);

                result.Add(item);
            }
            return(result);
        }