Exemple #1
0
 private void AddPage(List <PageBarInfo.PanelEntry> list, PageDefinition pageDef, bool popup)
 {
     if (pageDef != null && pageDef.IsAuthorized_View())
     {
         // If a page is authorized for anonymous but not users, we suppress it if we're Editor, Admin, Superuser, etc. to avoid cases where we
         // have 2 of the same pages, one for anonymous users, the other for logged on users.
         if (Manager.HaveUser && pageDef.IsAuthorized_View_Anonymous() && !pageDef.IsAuthorized_View_AnyUser())
         {
             return;
         }
         list.Add(new PageBarInfo.PanelEntry {
             Url      = pageDef.EvaluatedCanonicalUrl,
             Caption  = pageDef.Title,
             ToolTip  = pageDef.Description,
             ImageUrl = GetImage(pageDef),
             Popup    = popup
         });
     }
 }
Exemple #2
0
        public async Task <ActionResult> PageBar()
        {
            Model model;

            if (Manager.EditMode)
            {
                model = new Model {
                    PagePattern       = Module.PagePattern,
                    PageList          = Module.PageList,
                    Style             = Module.Style,
                    ContentPane       = Module.ContentPane,
                    UseSkinFormatting = Module.UseSkinFormatting,
                    DefaultImage      = Module.DefaultImage,
                    DefaultImage_Data = Module.DefaultImage_Data
                };
            }
            else
            {
                model = new Model {
                    PanelInfo = new Models.PageBarInfo()
                    {
                        Style             = Module.Style,
                        ContentPane       = Module.ContentPane,
                        UseSkinFormatting = Module.UseSkinFormatting,
                        Panels            = await GetPanelsAsync()
                    }
                };

                // Check whether current page contents are accessible and get pane contents
                Uri    contentUri = null;
                string contentUrl;
                Manager.TryGetUrlArg <string>("!ContentUrl", out contentUrl);
                if (!string.IsNullOrWhiteSpace(contentUrl))
                {
                    if (contentUrl.StartsWith("/"))
                    {
                        contentUrl = Manager.CurrentSite.MakeUrl(contentUrl);
                    }
                    contentUri = new Uri(contentUrl);
                }
                else
                {
                    if (model.PanelInfo.Panels.Count > 0)
                    {
                        contentUri = new Uri(model.PanelInfo.Panels[0].Url);
                    }
                }
                if (contentUri != null)
                {
                    PageDefinition page = await PageDefinition.LoadFromUrlAsync(contentUri.AbsolutePath);

                    if (page != null)
                    {
                        if (page.IsAuthorized_View())
                        {
                            model.PanelInfo.ContentUri  = contentUri;
                            model.PanelInfo.ContentPage = page;
                        }
                        else
                        {
                            if (!Manager.HaveUser)
                            {
                                return(RedirectToUrl(Manager.CurrentSite.LoginUrl));
                            }
                        }
                    }
                }
            }
            return(View(model));
        }