/// <summary> /// Sets the breadcrumbs trail, if appropriate. /// </summary> private void SetupBreadcrumbsTrail() { if (Settings.GetDisableBreadcrumbsTrail(currentWiki) || discussMode || viewCodeMode) { lblBreadcrumbsTrail.Visible = false; return; } StringBuilder sb = new StringBuilder(1000); sb.Append(@"<div id=""BreadcrumbsDiv"">"); string[] pageTrailTemp = SessionFacade.Breadcrumbs(currentWiki).GetAllPages(); List <PageContent> pageTrail = new List <PageContent>(pageTrailTemp.Length); // Build a list of pages the are currently available foreach (string pageFullName in pageTrailTemp) { PageContent p = Pages.FindPage(currentWiki, pageFullName); if (p != null) { pageTrail.Add(p); } } int min = 3; if (pageTrail.Count < 3) { min = pageTrail.Count; } sb.Append(@"<div id=""BreadcrumbsDivMin"">"); if (pageTrail.Count > 3) { // Write hyperLink sb.Append(@"<a href=""#"" onclick=""javascript:return __ShowAllTrail();"" title="""); sb.Append(Properties.Messages.ViewBreadcrumbsTrail); sb.Append(@""">("); sb.Append(pageTrail.Count.ToString()); sb.Append(")</a> "); } for (int i = pageTrail.Count - min; i < pageTrail.Count; i++) { AppendBreadcrumb(sb, pageTrail[i], "s"); } sb.Append("</div>"); sb.Append(@"<div id=""BreadcrumbsDivAll"" style=""display: none;"">"); // Write hyperLink sb.Append(@"<a href=""#"" onclick=""javascript:return __HideTrail();"" title="""); sb.Append(Properties.Messages.HideBreadcrumbsTrail); sb.Append(@""">[X]</a> "); for (int i = 0; i < pageTrail.Count; i++) { AppendBreadcrumb(sb, pageTrail[i], "f"); } sb.Append("</div>"); sb.Append("</div>"); lblBreadcrumbsTrail.Text = sb.ToString(); }
protected void Page_Load(object sender, EventArgs e) { currentWiki = DetectWiki(); discussMode = Request["Discuss"] != null; viewCodeMode = Request["Code"] != null && !discussMode; if (!Settings.GetEnableViewPageCodeFeature(currentWiki)) { viewCodeMode = false; } currentPage = Pages.FindPage(currentWiki, DetectPage(true)); VerifyAndPerformRedirects(); // The following actions are verified: // - View content (redirect to AccessDenied) // - Edit or Edit with Approval (for button display) // - Any Administrative activity (Rollback/Admin/Perms) (for button display) // - Download attachments (for button display - download permissions are also checked in GetFile) // - View discussion (for button display in content mode) // - Post discussion (for button display in discuss mode) string currentUsername = SessionFacade.GetCurrentUsername(); string[] currentGroups = SessionFacade.GetCurrentGroupNames(currentWiki); AuthChecker authChecker = new AuthChecker(Collectors.CollectorsBox.GetSettingsProvider(currentWiki)); bool canView = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ReadPage, currentUsername, currentGroups); bool canEdit = false; bool canEditWithApproval = false; Pages.CanEditPage(currentWiki, currentPage.FullName, currentUsername, currentGroups, out canEdit, out canEditWithApproval); if (canEditWithApproval && canEdit) { canEditWithApproval = false; } bool canDownloadAttachments = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.DownloadAttachments, currentUsername, currentGroups); bool canSetPerms = authChecker.CheckActionForGlobals(Actions.ForGlobals.ManagePermissions, currentUsername, currentGroups); bool canAdmin = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ManagePage, currentUsername, currentGroups); bool canViewDiscussion = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ReadDiscussion, currentUsername, currentGroups); bool canPostDiscussion = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.PostDiscussion, currentUsername, currentGroups); bool canManageDiscussion = authChecker.CheckActionForPage(currentPage.FullName, Actions.ForPages.ManageDiscussion, currentUsername, currentGroups); if (!canView) { if (SessionFacade.LoginKey == null) { UrlTools.Redirect("Login.aspx?Redirect=" + Tools.UrlEncode(Tools.GetCurrentUrlFixed())); } else { UrlTools.Redirect(UrlTools.BuildUrl(currentWiki, "AccessDenied.aspx")); } } attachmentViewer.Visible = canDownloadAttachments; attachmentViewer.PageFullName = currentPage.FullName; pnlPageInfo.Visible = Settings.GetEnablePageInfoDiv(currentWiki); SetupTitles(); SetupToolbarLinks(canEdit || canEditWithApproval, canViewDiscussion, canPostDiscussion, canDownloadAttachments, canAdmin, canAdmin, canSetPerms); SetupLabels(); SetupPrintAndRssLinks(); SetupMetaInformation(); VerifyAndPerformPageRedirection(); SetupRedirectionSource(); SetupNavigationPaths(); SetupAdjacentPages(); SessionFacade.Breadcrumbs(currentWiki).AddPage(currentPage.FullName); SetupBreadcrumbsTrail(); SetupDoubleClickHandler(); SetupEmailNotification(); SetupPageContent(canPostDiscussion, canManageDiscussion); if (currentPage != null) { Literal canonical = new Literal(); canonical.Text = Tools.GetCanonicalUrlTag(Request.Url.ToString(), currentPage.FullName, Pages.FindNamespace(currentWiki, NameTools.GetNamespace(currentPage.FullName))); Page.Header.Controls.Add(canonical); } }