Exemple #1
0
        public virtual ActionResult Index()
        {
            var menuItems = new List <MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest {
                        SitemapId = sitemapId.Value
                    };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    if (response.Data.Count > 0)
                    {
                        menuItems = response.Data.Select(mi => new MenuItemViewModel {
                            Caption = mi.Title, Url = mi.Url
                        }).ToList();
                    }
                }
            }

            return(View(menuItems));
        }
Exemple #2
0
        public ActionResult SitemapMenu(string languageCode)
        {
            var menuItems = new List <MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var languageId = GetLanguageId(api, languageCode);
                var sitemapId  = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest {
                        SitemapId = sitemapId.Value
                    };
                    request.Data.LanguageId = languageId;
                    var response = api.Pages.Sitemap.Tree.Get(request);
                    if (response.Data.Count > 0)
                    {
                        menuItems = response.Data.Select(mi => new MenuItemViewModel {
                            Caption = mi.Title, Url = mi.Url, IsPublished = mi.PageIsPublished
                        }).ToList();
                    }
                }
            }

            return(View("~/Views/SitemapMenu/Index.cshtml", menuItems));
        }
        public GetSitemapTreeResponse Get(GetSitemapTreeRequest request)
        {
            var pagesToFuture = SitemapHelper.GetPagesToFuture(cmsConfiguration.EnableMultilanguage, repository);
            var translationsToFuture = cmsConfiguration.EnableMultilanguage && request.Data.LanguageId.HasValue
                                           ? repository.AsQueryable<Module.Pages.Models.SitemapNodeTranslation>()
                                                       .Where(t => t.Node.Sitemap.Id == request.SitemapId && t.Language.Id == request.Data.LanguageId.Value && !t.IsDeleted && !t.Node.IsDeleted)
                                                       .Select(t => new SitemapTreeNodeTranslationModel
                                                           {
                                                               Id = t.Id,
                                                               Version = t.Version,
                                                               CreatedBy = t.CreatedByUser,
                                                               CreatedOn = t.CreatedOn,
                                                               LastModifiedBy = t.ModifiedByUser,
                                                               LastModifiedOn = t.ModifiedOn,

                                                               NodeId = t.Node.Id,
                                                               LanguageId = t.Language.Id,
                                                               Title = t.Title,
                                                               Url = t.Url,
                                                               UsePageTitleAsNodeTitle = t.UsePageTitleAsNodeTitle,
                                                               Macro = t.Macro
                                                           })
                                                       .ToFuture()
                                           : null;
            
            var allNodes = repository
                .AsQueryable<Module.Pages.Models.SitemapNode>()
                .Where(node => node.Sitemap.Id == request.SitemapId && !node.IsDeleted)
                .OrderBy(node => node.DisplayOrder)
                .Select(node => new SitemapTreeNodeModel
                    {
                        Id = node.Id,
                        Version = node.Version,
                        CreatedBy = node.CreatedByUser,
                        CreatedOn = node.CreatedOn,
                        LastModifiedBy = node.ModifiedByUser,
                        LastModifiedOn = node.ModifiedOn,

                        ParentId = node.ParentNode != null && !node.ParentNode.IsDeleted ? node.ParentNode.Id : (Guid?)null,
                        Title = node.Page != null && node.UsePageTitleAsNodeTitle ? node.Page.Title : node.Title,
                        Url = node.Page != null ? node.Page.PageUrl : node.Url,
                        PageId = node.Page != null ? node.Page.Id : (Guid?)null,
                        PageIsPublished = node.Page != null && !node.Page.IsDeleted && node.Page.Status == PageStatus.Published,
                        UsePageTitleAsNodeTitle = node.UsePageTitleAsNodeTitle,
                        DisplayOrder = node.DisplayOrder,
                        Macro = node.Macro
                    })
                .ToFuture()
                .ToList();

            var nodes = GetChildren(allNodes, request.Data.NodeId);

            if (pagesToFuture != null && translationsToFuture != null)
            {
                Translate(nodes, request.Data.LanguageId, translationsToFuture.ToList(), pagesToFuture.ToList());
            }

            return new GetSitemapTreeResponse { Data = nodes };
        }
Exemple #4
0
        public virtual ActionResult SubMenu(string parentUrl)
        {
            var menuItems = new List <MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var pageRequest = new PageExistsRequest {
                    PageUrl = parentUrl
                };
                var pageResponse = api.Pages.Page.Exists(pageRequest);

                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var parentRequest = new GetSitemapNodesRequest();
                    parentRequest.SitemapId = sitemapId.Value;
                    parentRequest.Data.Take = 1;
                    parentRequest.Data.Filter.Add("ParentId", null);

                    var filter = new DataFilter(FilterConnector.Or);
                    parentRequest.Data.Filter.Inner.Add(filter);
                    filter.Add("Url", parentUrl);
                    if (pageResponse.Data.Exists)
                    {
                        filter.Add("PageId", pageResponse.Data.PageId.Value);
                    }
                    parentRequest.Data.Order.Add("DisplayOrder");

                    var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest);
                    if (parentResponse.Data.Items.Count == 1)
                    {
                        var request = new GetSitemapTreeRequest {
                            SitemapId = sitemapId.Value
                        };
                        request.Data.NodeId = parentResponse.Data.Items[0].Id;
                        var response = api.Pages.Sitemap.Tree.Get(request);
                        if (response.Data.Count > 0)
                        {
                            menuItems = response.Data.Select(mi => new MenuItemViewModel {
                                Caption = mi.Title, Url = mi.Url
                            }).ToList();
                            menuItems.Insert(0, new MenuItemViewModel {
                                Caption = "Main", Url = parentUrl
                            });
                        }
                    }
                }
            }

            return(View(menuItems));
        }
Exemple #5
0
        public ActionResult FooterMenu()
        {
            var menuItems = new List <MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest {
                        SitemapId = sitemapId.Value, Data = new GetSitemapTreeModel {
                            LanguageId = LanguageHelper.CurrentLanguageId
                        }
                    };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    if (response.Data.Count > 0)
                    {
                        foreach (var item in response.Data)
                        {
                            if (item.ChildrenNodes.Count > 0)
                            {
                                sb.Append("<div class=\"col\">");
                                sb.Append("<h2>" + item.Title + "</h2>");
                                sb.Append("<ul>");
                                foreach (var item1 in item.ChildrenNodes)
                                {
                                    sb.Append("<li><a href=\"" + item1.Url + "\">" + item1.Title + "</a></li>");
                                }

                                sb.Append("<ul>");
                                sb.Append("</div>");
                            }
                        }
                        menuItems = response.Data.Select(mi => new MenuItemViewModel {
                            Caption = mi.Title, Url = mi.Url
                        }).ToList();
                    }
                    ViewBag.MenuString = sb.ToString();
                }
            }

            return(View());
        }
        public virtual ActionResult SubMenu(string parentUrl)
        {
            var menuItems = new List<MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var pageRequest = new PageExistsRequest { PageUrl = parentUrl };
                var pageResponse = api.Pages.Page.Exists(pageRequest);

                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var parentRequest = new GetSitemapNodesRequest();
                    parentRequest.SitemapId = sitemapId.Value;
                    parentRequest.Data.Take = 1;
                    parentRequest.Data.Filter.Add("ParentId", null);

                    var filter = new DataFilter(FilterConnector.Or);
                    parentRequest.Data.Filter.Inner.Add(filter);
                    filter.Add("Url", parentUrl);
                    if (pageResponse.Data.Exists)
                    {
                        filter.Add("PageId", pageResponse.Data.PageId.Value);
                    }
                    parentRequest.Data.Order.Add("DisplayOrder");

                    var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest);
                    if (parentResponse.Data.Items.Count == 1)
                    {
                        var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value };
                        request.Data.NodeId = parentResponse.Data.Items[0].Id;
                        var response = api.Pages.Sitemap.Tree.Get(request);
                        if (response.Data.Count > 0)
                        {
                            menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
                            menuItems.Insert(0, new MenuItemViewModel { Caption = "Main", Url = parentUrl });
                        }
                    }
                }
            }

            return View(menuItems);
        }
        public virtual ActionResult Index()
        {
            var menuItems = new List<MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    if (response.Data.Count > 0)
                    {
                        menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
                    }
                }
            }

            return View(menuItems);
        }
Exemple #8
0
        public ActionResult FooterMenu()
        {
            var menuItems = new List<MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value, Data = new GetSitemapTreeModel { LanguageId = LanguageHelper.CurrentLanguageId } };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    if (response.Data.Count > 0)
                    {
                        foreach (var item in response.Data)
                        {
                            if (item.ChildrenNodes.Count > 0)
                            {
                                sb.Append("<div class=\"col\">");
                                sb.Append("<h2>" + item.Title + "</h2>");
                                sb.Append("<ul>");
                                foreach (var item1 in item.ChildrenNodes)
                                {
                                    sb.Append("<li><a href=\"" + item1.Url + "\">" + item1.Title + "</a></li>");
                                }

                                sb.Append("<ul>");
                                sb.Append("</div>");

                            }
                        }
                        menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
                    }
                    ViewBag.MenuString = sb.ToString();
                }
            }

            return View();
        }
        public GetSitemapTreeResponse Get(GetSitemapTreeRequest request)
        {
            var allNodes = repository
                .AsQueryable<Module.Pages.Models.SitemapNode>()
                .OrderBy(node => node.Title)
                .Select(node => new SitemapTreeNodeModel
                    {
                        Id = node.Id,
                        Version = node.Version,
                        CreatedBy = node.CreatedByUser,
                        CreatedOn = node.CreatedOn,
                        LastModifiedBy = node.ModifiedByUser,
                        LastModifiedOn = node.ModifiedOn,

                        ParentId = node.ParentNode != null && !node.ParentNode.IsDeleted ? node.ParentNode.Id : (System.Guid?)null,
                        Title = node.Title,
                        Url = node.Url,
                        DisplayOrder = node.DisplayOrder
                    })
                .ToList();

            return new GetSitemapTreeResponse { Data = GetChildren(allNodes, request.Data.NodeId) };
        }
Exemple #10
0
        public virtual ActionResult SubMenu(string parentUrl)
        {
            //var menuItems = new List<MenuItemViewModel>();

            //using (var api = ApiFactory.Create())
            //{
            //    var pageRequest = new PageExistsRequest { PageUrl = parentUrl };
            //    var pageResponse = api.Pages.Page.Exists(pageRequest);

            //    var sitemapId = GetSitemapId(api);
            //    if (sitemapId.HasValue)
            //    {
            //        var parentRequest = new GetSitemapNodesRequest();
            //        parentRequest.SitemapId = sitemapId.Value;
            //        parentRequest.Data.Take = 1;
            //        parentRequest.Data.Filter.Add("ParentId", null);

            //        var filter = new DataFilter(FilterConnector.Or);
            //        parentRequest.Data.Filter.Inner.Add(filter);
            //        filter.Add("Url", parentUrl);
            //        if (pageResponse.Data.Exists)
            //        {
            //            filter.Add("PageId", pageResponse.Data.PageId.Value);
            //        }
            //        parentRequest.Data.Order.Add("DisplayOrder");

            //        var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest);
            //        if (parentResponse.Data.Items.Count == 1)
            //        {
            //            var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value };
            //            request.Data.NodeId = parentResponse.Data.Items[0].Id;
            //            var response = api.Pages.Sitemap.Tree.Get(request);
            //            if (response.Data.Count > 0)
            //            {
            //                menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
            //                //menuItems.Insert(0, new MenuItemViewModel { Caption = "Main", Url = parentUrl });
            //            }
            //        }
            //    }
            //}

            //return View(menuItems);
            var menuItems = new List<MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value, Data = new GetSitemapTreeModel { LanguageId = LanguageHelper.CurrentLanguageId } };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    if (response.Data.Count > 0)
                    {
                        foreach (var item in response.Data)
                        {
                            if (item.ChildrenNodes.Count > 0)
                            {
                                if (item.Url == parentUrl)
                                {
                                    sb.Append("<div id=\"VMENU709487940\" class=\"VMENU\">");
                                    sb.Append("    <ul class=\"VMENU_0 VMENU_0_709487940 reset\">");
                                    foreach (var item1 in item.ChildrenNodes)
                                    {
                                        sb.Append("       <li>");
                                        sb.Append("       <a href=\""+item1.Url+"\" class=\"" + (System.Web.HttpContext.Current.Request.Path == item1.Url ? "a_s" : null) + "\"><span class=\"" + (System.Web.HttpContext.Current.Request.Path == item1.Url ? "s" : null) + "\">" + item1.Title + "</span></a>");
                                        sb.Append("       </li>");
                                        sb.Append("         <li class=\"d\"></li>");
                                    }
                                    sb.Append("    </ul>");
                                    sb.Append("</div>");

                                }

                            }
                        }
                        menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
                    }
                    ViewBag.MenuString2 = sb.ToString();
                }
            }

            return View();
        }
Exemple #11
0
        public virtual ActionResult SubMenu(string parentUrl)
        {
            //var menuItems = new List<MenuItemViewModel>();

            //using (var api = ApiFactory.Create())
            //{
            //    var pageRequest = new PageExistsRequest { PageUrl = parentUrl };
            //    var pageResponse = api.Pages.Page.Exists(pageRequest);

            //    var sitemapId = GetSitemapId(api);
            //    if (sitemapId.HasValue)
            //    {
            //        var parentRequest = new GetSitemapNodesRequest();
            //        parentRequest.SitemapId = sitemapId.Value;
            //        parentRequest.Data.Take = 1;
            //        parentRequest.Data.Filter.Add("ParentId", null);

            //        var filter = new DataFilter(FilterConnector.Or);
            //        parentRequest.Data.Filter.Inner.Add(filter);
            //        filter.Add("Url", parentUrl);
            //        if (pageResponse.Data.Exists)
            //        {
            //            filter.Add("PageId", pageResponse.Data.PageId.Value);
            //        }
            //        parentRequest.Data.Order.Add("DisplayOrder");

            //        var parentResponse = api.Pages.Sitemap.Nodes.Get(parentRequest);
            //        if (parentResponse.Data.Items.Count == 1)
            //        {
            //            var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value };
            //            request.Data.NodeId = parentResponse.Data.Items[0].Id;
            //            var response = api.Pages.Sitemap.Tree.Get(request);
            //            if (response.Data.Count > 0)
            //            {
            //                menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url }).ToList();
            //                //menuItems.Insert(0, new MenuItemViewModel { Caption = "Main", Url = parentUrl });
            //            }
            //        }
            //    }
            //}

            //return View(menuItems);
            var menuItems = new List <MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest {
                        SitemapId = sitemapId.Value, Data = new GetSitemapTreeModel {
                            LanguageId = LanguageHelper.CurrentLanguageId
                        }
                    };

                    var response = api.Pages.Sitemap.Tree.Get(request);
                    System.Text.StringBuilder sb = new System.Text.StringBuilder();
                    if (response.Data.Count > 0)
                    {
                        foreach (var item in response.Data)
                        {
                            if (item.ChildrenNodes.Count > 0)
                            {
                                if (item.Url == parentUrl)
                                {
                                    sb.Append("<div id=\"VMENU709487940\" class=\"VMENU\">");
                                    sb.Append("    <ul class=\"VMENU_0 VMENU_0_709487940 reset\">");
                                    foreach (var item1 in item.ChildrenNodes)
                                    {
                                        sb.Append("       <li>");
                                        sb.Append("       <a href=\"" + item1.Url + "\" class=\"" + (System.Web.HttpContext.Current.Request.Path == item1.Url ? "a_s" : null) + "\"><span class=\"" + (System.Web.HttpContext.Current.Request.Path == item1.Url ? "s" : null) + "\">" + item1.Title + "</span></a>");
                                        sb.Append("       </li>");
                                        sb.Append("         <li class=\"d\"></li>");
                                    }
                                    sb.Append("    </ul>");
                                    sb.Append("</div>");
                                }
                            }
                        }
                        menuItems = response.Data.Select(mi => new MenuItemViewModel {
                            Caption = mi.Title, Url = mi.Url
                        }).ToList();
                    }
                    ViewBag.MenuString2 = sb.ToString();
                }
            }

            return(View());
        }
Exemple #12
0
        public ActionResult SitemapMenu(string languageCode)
        {
            var menuItems = new List<MenuItemViewModel>();

            using (var api = ApiFactory.Create())
            {
                var languageId = GetLanguageId(api, languageCode);
                var sitemapId = GetSitemapId(api);
                if (sitemapId.HasValue)
                {
                    var request = new GetSitemapTreeRequest { SitemapId = sitemapId.Value };
                    request.Data.LanguageId = languageId;
                    var response = api.Pages.Sitemap.Tree.Get(request);
                    if (response.Data.Count > 0)
                    {
                        menuItems = response.Data.Select(mi => new MenuItemViewModel { Caption = mi.Title, Url = mi.Url, IsPublished = mi.PageIsPublished}).ToList();
                    }
                }
            }

            return View("~/Views/SitemapMenu/Index.cshtml", menuItems);
        }