1 # Copyright (C) 2010 Alex Schroeder <alex@gnu.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 3 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, see <http://www.gnu.org/licenses/>.
16 $ModulesDescription .= '<p><a href="http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/dates.pl">dates.pl</a>, see <a href="http://www.oddmuse.org/cgi-bin/oddmuse/Dates_Extension">Dates Extension</a></p>';
18 push(@MyAdminCode, \
&DatesMenu
);
21 my ($id, $menuref, $restref) = @_;
23 ScriptLink
('action=dates',
24 T
('Extract all dates from the database'),
28 $Action{dates
} = \
&DoDates
;
30 my $regex = '([0-9][0-9][0-9][0-9]-([0-9][0-9])-([0-9][0-9]))';
33 print GetHeader
('', T
('Dates')), $q->start_div({-class=>'content dates'});
34 print $q->p(T
("No dates found.")) unless $q->p(SearchTitleAndBody
($regex, \
&DateCollector
));
42 *OldDatesSearchString
= *SearchString
;
43 *SearchString
= *NewDatesSearchString
;
45 sub NewDatesSearchString
{
46 $date_page = $_[1]; # save the page text!
47 return OldDatesSearchString
(@_);
52 my $text = $date_page; # use the page text saved above!
53 my ($ignore, $qtext) = split(/\n/, $text, 2);
54 $qtext = QuoteHtml
($qtext);
55 while ($text =~ m/$regex/g) {
58 my $context = SearchHighlight
(SearchExtract
($qtext, $date), $date);
59 push(@
{$date_collection{$key}}, [$id, $context]);
64 for my $key (sort keys %date_collection) {
67 for my $item (@
{$date_collection{$key}}) {
70 my $context = $item[1];
71 print $q->li(GetPageLink
($id) . ': ' . $context);