~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Contrib/MailerContrib/UpData.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
2
#
 
3
# Copyright (C) 2004 Wind River Systems Inc.
 
4
# Copyright (C) 1999-2006 Foswiki Contributors.
 
5
# All Rights Reserved. Foswiki Contributors
 
6
# are listed in the AUTHORS file in the root of this distribution.
 
7
# NOTE: Please extend that file, not this notice.
 
8
#
 
9
# This program is free software; you can redistribute it and/or
 
10
# modify it under the terms of the GNU General Public License
 
11
# as published by the Free Software Foundation; either version 2
 
12
# of the License, or (at your option) any later version. For
 
13
# more details read LICENSE in the root of this distribution.
 
14
#
 
15
# This program is distributed in the hope that it will be useful,
 
16
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
18
#
 
19
# As per the GPL, removal of this notice is prohibited.
 
20
 
 
21
use strict;
 
22
 
 
23
=pod
 
24
 
 
25
---+ package Foswiki::Contrib::MailerContrib::UpData
 
26
Object that lazy-scans topics to extract
 
27
parent relationships.
 
28
 
 
29
=cut
 
30
 
 
31
package Foswiki::Contrib::MailerContrib::UpData;
 
32
 
 
33
=pod
 
34
 
 
35
---++ new($web)
 
36
   * =$web= - Web we are building parent relationships for
 
37
Constructor for a web; initially empty, will lazy-load as topics
 
38
are referenced.
 
39
 
 
40
=cut
 
41
 
 
42
sub new {
 
43
    my ( $class, $session, $web ) = @_;
 
44
    my $this = bless( {}, $class );
 
45
    $this->{web} = $web;
 
46
    $this->{session} = $session;
 
47
    return $this;
 
48
}
 
49
 
 
50
=pod
 
51
 
 
52
---++ getParent($topic) -> string
 
53
Get the name of the parent topic of the given topic
 
54
 
 
55
=cut
 
56
 
 
57
sub getParent {
 
58
    my ( $this, $topic ) = @_;
 
59
 
 
60
    if ( ! defined( $this->{parent}{$topic} )) {
 
61
        my( $meta, $text ) =
 
62
          Foswiki::Func::readTopic( $this->{web}, $topic );
 
63
        my $parent = $meta->get('TOPICPARENT');
 
64
        $this->{parent}{$topic} = $parent->{name} if $parent;
 
65
        $this->{parent}{$topic} ||= '';
 
66
    }
 
67
 
 
68
    return $this->{parent}{$topic};
 
69
}
 
70
 
 
71
1;