# Copyright (C) 2006 Brock Wilcox # Copyright (C) 2006 Alex Schroeder # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA # This is heavily based off of search-list.pl by Alex # The idea is to drop into your SideBar $ModulesDescription .= '

ref-list.pl v1.0 2006-11-17

'; push(@MyRules, \&RefListRule); sub get_linked_pages { my ($pageName, $depth) = @_; my $search = "\\[\\[$pageName\\]\\]"; $search =~ s/_/ /g; my $original = 'SideBar'; # TODO use $sidebar pagename local ($OpenPageName, %Page); my %hash = (); foreach my $id (SearchTitleAndBody($search)) { $hash{$id} = 1 unless $id eq $original; # skip the page with the query } my @found = keys %hash; if (defined &PageSort) { @found = sort PageSort @found; } else { @found = sort(@found); } return @found; } sub RefListRule { if ($bol && /\G(<reflist>)/cgis) { # my ($oldpos, $old_) = (pos, $_); Clean(CloseHtmlEnvironments()); Dirty($1); my (@found) = get_linked_pages($OpenPageName); @found = map { $q->li(GetPageLink($_)), $q->li($q->ul( map { $q->li(GetPageLink($_)) } get_linked_pages($_))) } @found; if(!@found) { @found = ($q->li('... none found ...')); } print $q->start_div({-class=>'search list'}), $q->ul(@found), $q->end_div; Clean(AddHtmlEnvironment('p')); # if dirty block is looked at later, this will disappear ($_, pos) = ($old_, $oldpos); # restore \G (assignment order matters!) return ''; } return undef; }