| 1 | # PurpleWiki::Search::Result.pm | ||
| 2 | # vi:ai:sm:et:sw=4:ts=4 | ||
| 3 | # | ||
| 4 | # $Id: Result.pm 366 2004-05-19 19:22:17Z eekim $ | ||
| 5 | # | ||
| 6 | # Copyright (c) Blue Oxen Associates 2002-2004. All rights reserved. | ||
| 7 | # | ||
| 8 | # This file is part of PurpleWiki. PurpleWiki is derived from: | ||
| 9 | # | ||
| 10 | # UseModWiki v0.92 (c) Clifford A. Adams 2000-2001 | ||
| 11 | # AtisWiki v0.3 (c) Markus Denker 1998 | ||
| 12 | # CVWiki CVS-patches (c) Peter Merel 1997 | ||
| 13 | # The Original WikiWikiWeb (c) Ward Cunningham | ||
| 14 | # | ||
| 15 | # PurpleWiki is free software; you can redistribute it and/or modify | ||
| 16 | # it under the terms of the GNU General Public License as published by | ||
| 17 | # the Free Software Foundation; either version 2 of the License, or | ||
| 18 | # (at your option) any later version. | ||
| 19 | # | ||
| 20 | # This program is distributed in the hope that it will be useful, | ||
| 21 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 22 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 23 | # GNU General Public License for more details. | ||
| 24 | # | ||
| 25 | # You should have received a copy of the GNU General Public License | ||
| 26 | # along with this program; if not, write to the | ||
| 27 | # Free Software Foundation, Inc. | ||
| 28 | # 59 Temple Place, Suite 330 | ||
| 29 | # Boston, MA 02111-1307 USA | ||
| 30 | |||
| 31 | package PurpleWiki::Search::Result; | ||
| 32 | |||
| 33 | use strict; | ||
| 34 | use PurpleWiki::Config; | ||
| 35 | |||
| 36 | our $VERSION; | ||
| 37 | $VERSION = sprintf("%d", q$Id: Result.pm 366 2004-05-19 19:22:17Z eekim $ =~ /\s(\d+)\s/); | ||
| 38 | |||
| 39 | sub new { | ||
| 40 | my $class = shift; | ||
| 41 | my $self = {}; | ||
| 42 | |||
| 43 | my %params = @_; | ||
| 44 | |||
| 45 | $self->{config} = PurpleWiki::Config->instance(); | ||
| 46 | |||
| 47 | bless ($self, $class); | ||
| 48 | |||
| 49 | return $self; | ||
| 50 | } | ||
| 51 | |||
| 52 | sub title { | ||
| 53 | my $self = shift; | ||
| 54 | |||
| 55 | $self->{title} = shift if @_; | ||
| 56 | return $self->{title}; | ||
| 57 | } | ||
| 58 | |||
| 59 | sub url { | ||
| 60 | my $self = shift; | ||
| 61 | |||
| 62 | $self->{URL} = shift if @_; | ||
| 63 | return $self->{URL}; | ||
| 64 | } | ||
| 65 | |||
| 66 | sub summary { | ||
| 67 | my $self = shift; | ||
| 68 | |||
| 69 | $self->{summary} = shift if @_; | ||
| 70 | return $self->{summary}; | ||
| 71 | } | ||
| 72 | |||
| 73 | sub modifiedTime { | ||
| 74 | my $self = shift; | ||
| 75 | |||
| 76 | $self->{mtime} = shift if @_; | ||
| 77 | return $self->{mtime}; | ||
| 78 | } | ||
| 79 | |||
| 80 | sub lastModified { # return a date/time string | ||
| 81 | return &_date(shift->{mtime}); | ||
| 82 | } | ||
| 83 | |||
| 84 | ### private | ||
| 85 | |||
| 86 | sub _date { | ||
| 87 | my $ts = shift; | ||
| 88 | my @datetime = localtime($ts); | ||
| 89 | my %monthNames = ( | ||
| 90 | 0 => 'Jan', | ||
| 91 | 1 => 'Feb', | ||
| 92 | 2 => 'Mar', | ||
| 93 | 3 => 'Apr', | ||
| 94 | 4 => 'May', | ||
| 95 | 5 => 'Jun', | ||
| 96 | 6 => 'Jul', | ||
| 97 | 7 => 'Aug', | ||
| 98 | 8 => 'Sep', | ||
| 99 | 9 => 'Oct', | ||
| 100 | 10 => 'Nov', | ||
| 101 | 11 => 'Dec'); | ||
| 102 | my $year = 1900 + $datetime[5]; | ||
| 103 | my $month = $monthNames{$datetime[4]}; | ||
| 104 | my $day = $datetime[3]; | ||
| 105 | |||
| 106 | return "$month $day, $year"; | ||
| 107 | } | ||
| 108 | |||
| 109 | 1; | ||
| 110 | __END__ |