From 2e1eb1813dd22283cbc3cc30ecdaef3ec87d2021 Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Fri, 22 Apr 2011 17:53:17 +0200 Subject: [PATCH] [completed: 586] Resolved paging bug in AdminPages.aspx. --- AssemblyVersion.cs | 4 ++-- Core/Pages.cs | 29 +++++++++++++++++++++++++---- WebApplication/AdminHome.aspx.cs | 2 +- WebApplication/AdminPages.aspx.cs | 14 ++++++++------ WebApplication/AdminUsers.aspx.cs | 2 ++ 5 files changed, 38 insertions(+), 13 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index 14e2b02..aa76643 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.4.566")] -[assembly: AssemblyFileVersion("3.0.4.566")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.4.567")] +[assembly: AssemblyFileVersion("3.0.4.567")] \ No newline at end of file diff --git a/Core/Pages.cs b/Core/Pages.cs index 0789254..5e95486 100644 --- a/Core/Pages.cs +++ b/Core/Pages.cs @@ -956,14 +956,17 @@ namespace ScrewTurn.Wiki { public static string[] GetPageIncomingLinks(PageInfo page) { if(page == null) return null; - IDictionary allLinks = Settings.Provider.GetAllOutgoingLinks(); - string[] knownPages = new string[allLinks.Count]; - allLinks.Keys.CopyTo(knownPages, 0); + return GetPageIncomingLinks(page, Settings.Provider.GetAllOutgoingLinks()); + } + + private static string[] GetPageIncomingLinks(PageInfo page, IDictionary allOutgoingLinks) { + string[] knownPages = new string[allOutgoingLinks.Count]; + allOutgoingLinks.Keys.CopyTo(knownPages, 0); List result = new List(20); foreach(string key in knownPages) { - if(Contains(allLinks[key], page.FullName)) { + if(Contains(allOutgoingLinks[key], page.FullName)) { // result is likely to be very small, so a linear search is fine if(!result.Contains(key)) result.Add(key); } @@ -972,6 +975,24 @@ namespace ScrewTurn.Wiki { return result.ToArray(); } + /// + /// Gets all the orphan pages. + /// + /// The pages to analyze. + /// The orphan pages. + public static List GetOrphanedPages(IList pages) { + IDictionary allLinks = Settings.Provider.GetAllOutgoingLinks(); + + List orphans = new List(); + foreach(var p in pages) { + if(GetPageIncomingLinks(p, allLinks).Length == 0) { + orphans.Add(p.FullName); + } + } + + return orphans; + } + /// /// Gets the outgoing links of a page. /// diff --git a/WebApplication/AdminHome.aspx.cs b/WebApplication/AdminHome.aspx.cs index 92843d2..53aa304 100644 --- a/WebApplication/AdminHome.aspx.cs +++ b/WebApplication/AdminHome.aspx.cs @@ -43,7 +43,7 @@ namespace ScrewTurn.Wiki { /// Displays the orphan pages count. /// private void DisplayOrphansCount() { - int orphans = Pages.GetOrphanedPages(null).Length; + int orphans = Pages.GetOrphanedPages(null as NamespaceInfo).Length; foreach(NamespaceInfo nspace in Pages.GetNamespaces()) { orphans += Pages.GetOrphanedPages(nspace).Length; } diff --git a/WebApplication/AdminPages.aspx.cs b/WebApplication/AdminPages.aspx.cs index 2ef4fa9..254fc1c 100644 --- a/WebApplication/AdminPages.aspx.cs +++ b/WebApplication/AdminPages.aspx.cs @@ -66,6 +66,7 @@ namespace ScrewTurn.Wiki { private IList GetPages() { NamespaceInfo nspace = Pages.FindNamespace(lstNamespace.SelectedValue); List pages = Pages.GetPages(nspace); + var orphanPages = Pages.GetOrphanedPages(pages); List result = new List(pages.Count); @@ -73,10 +74,13 @@ namespace ScrewTurn.Wiki { foreach(PageInfo page in pages) { if(NameTools.GetLocalName(page.FullName).ToLower(System.Globalization.CultureInfo.CurrentCulture).Contains(filter)) { - result.Add(page); + if(chkOrphansOnly.Checked && !orphanPages.Contains(page.FullName)) continue; + else result.Add(page); } } + result.Sort(new PageNameComparer()); + return result; } @@ -190,6 +194,8 @@ namespace ScrewTurn.Wiki { bool canSetPermissions = AdminMaster.CanManagePermissions(currentUser, currentGroups); bool canDeletePages = AuthChecker.CheckActionForNamespace(nspace, Actions.ForNamespaces.DeletePages, currentUser, currentGroups); + var orphanPages = Pages.GetOrphanedPages(currentPages); + for(int i = rangeBegin; i <= rangeEnd; i++) { PageInfo page = currentPages[i]; @@ -204,17 +210,13 @@ namespace ScrewTurn.Wiki { if(!canDeletePages && !canManagePage) canManageDiscussion = AuthChecker.CheckActionForPage(page, Actions.ForPages.ManageDiscussion, currentUser, currentGroups); bool canSelect = canManagePage | canDeletePages | canManageDiscussion; - int incomingLinks = Pages.GetPageIncomingLinks(page).Length; - - if(chkOrphansOnly.Checked && incomingLinks > 0) continue; - PageContent firstContent = null; List baks = Pages.GetBackups(page); if(baks.Count == 0) firstContent = currentContent; else firstContent = Pages.GetBackupContent(page, baks[0]); result.Add(new PageRow(page, currentContent, firstContent, - Pages.GetMessageCount(page), baks.Count, incomingLinks == 0, + Pages.GetMessageCount(page), baks.Count, orphanPages.Contains(page.FullName), canEdit, canSelect, canSetPermissions, txtCurrentPage.Value == page.FullName)); } diff --git a/WebApplication/AdminUsers.aspx.cs b/WebApplication/AdminUsers.aspx.cs index 6e6defb..073cce7 100644 --- a/WebApplication/AdminUsers.aspx.cs +++ b/WebApplication/AdminUsers.aspx.cs @@ -103,6 +103,8 @@ namespace ScrewTurn.Wiki { } } + result.Sort(new UsernameComparer()); + return result; }