[completed: 586] Resolved paging bug in AdminPages.aspx.
This commit is contained in:
parent
f16f67cff2
commit
2e1eb1813d
5 changed files with 38 additions and 13 deletions
|
@ -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")]
|
||||
[assembly: AssemblyVersion("3.0.4.567")]
|
||||
[assembly: AssemblyFileVersion("3.0.4.567")]
|
|
@ -956,14 +956,17 @@ namespace ScrewTurn.Wiki {
|
|||
public static string[] GetPageIncomingLinks(PageInfo page) {
|
||||
if(page == null) return null;
|
||||
|
||||
IDictionary<string, string[]> 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<string, string[]> allOutgoingLinks) {
|
||||
string[] knownPages = new string[allOutgoingLinks.Count];
|
||||
allOutgoingLinks.Keys.CopyTo(knownPages, 0);
|
||||
|
||||
List<string> result = new List<string>(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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the orphan pages.
|
||||
/// </summary>
|
||||
/// <param name="pages">The pages to analyze.</param>
|
||||
/// <returns>The orphan pages.</returns>
|
||||
public static List<string> GetOrphanedPages(IList<PageInfo> pages) {
|
||||
IDictionary<string, string[]> allLinks = Settings.Provider.GetAllOutgoingLinks();
|
||||
|
||||
List<string> orphans = new List<string>();
|
||||
foreach(var p in pages) {
|
||||
if(GetPageIncomingLinks(p, allLinks).Length == 0) {
|
||||
orphans.Add(p.FullName);
|
||||
}
|
||||
}
|
||||
|
||||
return orphans;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the outgoing links of a page.
|
||||
/// </summary>
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace ScrewTurn.Wiki {
|
|||
/// Displays the orphan pages count.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace ScrewTurn.Wiki {
|
|||
private IList<PageInfo> GetPages() {
|
||||
NamespaceInfo nspace = Pages.FindNamespace(lstNamespace.SelectedValue);
|
||||
List<PageInfo> pages = Pages.GetPages(nspace);
|
||||
var orphanPages = Pages.GetOrphanedPages(pages);
|
||||
|
||||
List<PageInfo> result = new List<PageInfo>(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<int> 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -103,6 +103,8 @@ namespace ScrewTurn.Wiki {
|
|||
}
|
||||
}
|
||||
|
||||
result.Sort(new UsernameComparer());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue