NOTE: this has not been tested with subpages.
NOTE: seems to work with SubPages --TomScanlan
sub GetOrphanList? { my @found;
my %seen = (); my @pglist = &AllPagesList(); foreach my $name (@pglist) { $seen{$name} = 0; } # pages linked from menu bar aren't orphans $seen{$HomePage} = 1; $seen{$RCName} = 1; foreach my $name (@pglist) { my @links = &GetPageLinks($name, 1, 0, 0); foreach my $link (@links) { #don't include self links unless ($link eq $name) { $seen{$link}++ if exists $seen{$link}; } } } foreach my $name (sort keys %seen) { push(@found, $name) if $seen{$name} < 1; } return @found; }
For display, use something like this within a pre tag:
&PrintLinkList(&GetOrphanList?());
Here is a unified diff for adding an orphans link to the goto bar in version 1.0
-- TomScanlan
--- wiki.pl.orig 2004-09-11 08:21:02.000000000 -0400 +++ wiki.pl 2004-06-10 22:03:14.734384880 -0400 @@ -485,6 +485,9 @@ } elsif ($action eq 'random') { &DoRandom(); return 1; + } elsif ($action eq 'orphans') { + &DoOrphanList(); + return 1; } elsif ($action eq 'history') { &DoHistory($id) if &ValidIdOrDie($id); return 1; @@ -973,6 +976,43 @@ &DoRc(0); } +sub GetOrphanList { + my @found; + + my %seen = (); + my @pglist = &AllPagesList(); + + foreach my $name (@pglist) { + $seen{$name} = 0; + } + + # pages linked from menu bar aren't orphans + $seen{$HomePage} = 1; + $seen{$RCName} = 1; + foreach my $name (@pglist) { + my @links = &GetPageLinks($name, 1, 0, 0); + foreach my $link (@links) { + #don't include self links + unless ($link eq $name) { + $seen{$link}++ if exists $seen{$link}; + } + } + } + + foreach my $name (sort keys %seen) { + push(@found, $name) if $seen{$name} < 1; + } + return @found; +} + +sub DoOrphanList { + print &GetHeader('', &QuoteHtml(T('Full Orphan List')), ''); + print "<hr>\n\n\n\n\n"; # Extra lines to get below the logo + &PrintPageList(&GetOrphanList()); + print "\n"; + print &GetCommonFooter(); +} + sub DoRandom { my ($id, @pageList); @@ -1219,6 +1256,11 @@ return &ScriptLink("action=random", T('Random Page')); } +sub GetOrphanLink { + return &ScriptLink("action=orphans", T('Orphans')); +} + + sub ScriptLinkDiff { my ($diff, $id, $text, $rev) = @_; @@ -1487,6 +1529,7 @@ if (&GetParam("linkrandom", 0)) { $bartext .= " | " . &GetRandomLink(); } + $bartext .= " | " . &GetOrphanLink(); if ($UserGotoBar ne '') { $bartext .= " | " . $UserGotoBar; }
apologies over not being in a real diff format
@ somewhere in the sub GetGotoBar if (&GetParam("linkrandom", 0)) { $bartext .= " | " . &GetRandomLink(); } + if (&GetParam("linkorphan", 0)) { + $bartext .= " | " . &GetOrphanLink(); + } if ($UserGotoBar ne '') { @ somewhere in sub DoEditPrefs T('Add "Random Page" link to link bar')); + print '<br>', &GetFormCheck('linkorphan', 0, + T('Add "Ophans" link to link bar')); print '<br>' . T('StyleSheet URL:') . ' ', &GetFormText('stylesheet', "", 30, 150); @ somewhere in sub DoUpdatePrefs &UpdatePrefCheckbox("linkrandom"); + &UpdatePrefCheckbox("linkorphan"); print &GetHeader('',T('Saving Preferences'), '');
From
foreach my $link (@links) { #don't include self linksTo
foreach my $link (@links) { if ( $link =~ /^\// ) { $link = (split('/',$name))[0].$link; } #don't include self links-- JamesHodge?
foreach my $link (@links) { if ( $link =~ /^\// ) { $link = (split('/',$name))[0].$link; } #don't forget anchors $link =~ s/#.*$//; #don't include self links
I repaired the patch-file above (there was a wrong number in one @@ ... @@ command) and changed it to display the results as a list of pages instead of links.