wiki.pl: Port some fixes from upstream
[Orgmuse.git] / modules / wanted.pl
blob0512566184e4d2bb7310267f5b5fcdb0efd8c473
1 # Copyright (C) 2006 Alex Schroeder <alex@emacswiki.org>
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 2 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the
15 # Free Software Foundation, Inc.
16 # 59 Temple Place, Suite 330
17 # Boston, MA 02111-1307 USA
19 package OddMuse;
21 use vars qw($WantedPageName $WantedPageNameFilter $WantedPageReferrerFilter);
23 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/wanted.pl">wanted.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Wanted_Pages_Extension">Wanted Pages Extension</a></p>';
26 push(@MyAdminCode, \&WantedAction);
28 sub WantedAction
30 my ($id, $menuref, $restref) = @_;
31 push(@$menuref, ScriptLink('action=wanted', Ts('Wanted Pages'), 'wanted'));
34 sub PrintWantedData
36 my %links = %{(GetFullLinkList(1,0,0,1))};
37 my %wanted;
38 foreach my $page (sort keys %links) {
39 next if defined $WantedPageReferrerFilter and ($page =~ m/$WantedPageReferrerFilter/);
40 foreach my $link (@{$links{$page}}) {
41 next if defined $WantedPageNameFilter and ($link =~ m/$WantedPageNameFilter/);
42 push @{$wanted{$link}}, $page if not $IndexHash{$link};
45 print $q->p(Ts('%s pages', scalar keys %wanted));
46 foreach my $page (sort keys %wanted) {
47 my @references = map {GetPageLink($_)} (sort @{$wanted{$page}});
48 my $pageLink = sprintf( T('%s, referenced from:'), GetEditLink($page,$page) );
49 print $q->ul( $q->li($pageLink, $q->ul($q->li(\@references))));
53 $Action{'wanted'} = \&DoWantedPages;
55 sub DoWantedPages {
56 my $title = defined $WantedPageName ? $WantedPageName : T('Wanted Pages');
57 print GetHeader('', $title, '', 1), $q->start_div({-class=>'content wanted'});
58 PrintWantedData();
59 print $q->end_div();
60 PrintFooter();