wanted.pl 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License, or
  6. # (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. use strict;
  16. use v5.10;
  17. our ($WantedPageName, $WantedPageNameFilter, $WantedPageReferrerFilter);
  18. AddModuleDescription('wanted.pl', 'Wanted Pages Extension');
  19. our ($q, %Action, %IndexHash, @MyAdminCode);
  20. push(@MyAdminCode, \&WantedAction);
  21. sub WantedAction {
  22. my ($id, $menuref, $restref) = @_;
  23. push(@$menuref, ScriptLink('action=wanted', Ts('Wanted Pages'), 'wanted'));
  24. }
  25. sub PrintWantedData {
  26. my %links = %{(GetFullLinkList(1,0,0,1))};
  27. my %wanted;
  28. foreach my $page (sort keys %links) {
  29. next if defined $WantedPageReferrerFilter and ($page =~ m/$WantedPageReferrerFilter/);
  30. foreach my $link (@{$links{$page}}) {
  31. next if defined $WantedPageNameFilter and ($link =~ m/$WantedPageNameFilter/);
  32. push @{$wanted{$link}}, $page if not $IndexHash{$link};
  33. }
  34. }
  35. print $q->p(Ts('%s pages', scalar keys %wanted));
  36. foreach my $page (sort keys %wanted) {
  37. my @references = map {GetPageLink($_)} (sort @{$wanted{$page}});
  38. my $pageLink = sprintf( T('%s, referenced from:'), GetEditLink($page,$page) );
  39. print $q->ul( $q->li($pageLink, $q->ul($q->li(\@references))));
  40. }
  41. }
  42. $Action{'wanted'} = \&DoWantedPages;
  43. sub DoWantedPages {
  44. my $title = defined $WantedPageName ? $WantedPageName : T('Wanted Pages');
  45. print GetHeader('', $title, '', 1), $q->start_div({-class=>'content wanted'});
  46. PrintWantedData();
  47. print $q->end_div();
  48. PrintFooter();
  49. }