| 1 | # PurpleWiki::StructuralNode.pm | ||||||||||
| 2 | # | ||||||||||
| 3 | # $Id: StructuralNode.pm 352 2004-05-08 22:00:33Z cdent $ | ||||||||||
| 4 | # | ||||||||||
| 5 | # Copyright (c) Blue Oxen Associates 2002-2003. All rights reserved. | ||||||||||
| 6 | # | ||||||||||
| 7 | # This file is part of PurpleWiki. PurpleWiki is derived from: | ||||||||||
| 8 | # | ||||||||||
| 9 | # UseModWiki v0.92 (c) Clifford A. Adams 2000-2001 | ||||||||||
| 10 | # AtisWiki v0.3 (c) Markus Denker 1998 | ||||||||||
| 11 | # CVWiki CVS-patches (c) Peter Merel 1997 | ||||||||||
| 12 | # The Original WikiWikiWeb (c) Ward Cunningham | ||||||||||
| 13 | # | ||||||||||
| 14 | # PurpleWiki is free software; you can redistribute it and/or modify | ||||||||||
| 15 | # it under the terms of the GNU General Public License as published by | ||||||||||
| 16 | # the Free Software Foundation; either version 2 of the License, or | ||||||||||
| 17 | # (at your option) any later version. | ||||||||||
| 18 | # | ||||||||||
| 19 | # This program is distributed in the hope that it will be useful, | ||||||||||
| 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||
| 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||
| 22 | # GNU General Public License for more details. | ||||||||||
| 23 | # | ||||||||||
| 24 | # You should have received a copy of the GNU General Public License | ||||||||||
| 25 | # along with this program; if not, write to the | ||||||||||
| 26 | # Free Software Foundation, Inc. | ||||||||||
| 27 | # 59 Temple Place, Suite 330 | ||||||||||
| 28 | # Boston, MA 02111-1307 USA | ||||||||||
| 29 | |||||||||||
| 30 | package PurpleWiki::StructuralNode; | ||||||||||
| 31 | |||||||||||
| 32 | 18 | ▶ | use 5.005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | 18 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 18 | ▶ | use PurpleWiki::InlineNode; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 18 | our $VERSION; | |||||||||
| 37 | 18 | $VERSION = sprintf("%d", q$Id: StructuralNode.pm 352 2004-05-08 22:00:33Z cdent $ =~ /\s(\d+)\s/); | |||||||||
| 38 | |||||||||||
| 39 | ### constructor | ||||||||||
| 40 | |||||||||||
| 41 | 8 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||
| 42 | 8 | my $this = shift; | |||||||||
| 43 | 8 | my (%options) = @_; | |||||||||
| 44 | 8 | my $self = {}; | |||||||||
| 45 | |||||||||||
| 46 | # TODO: Type checking. | ||||||||||
| 47 | 8 | ▶ | $self->{type} = $options{type} ? $options{type} : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | 8 | ▶ | $self->{id} = $options{id} ? $options{id} : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | 8 | ▶ | $self->{content} = $options{content} ? $options{content} : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | 8 | bless $self, $this; | |||||||||
| 51 | 8 | return $self; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | ### methods | ||||||||||
| 55 | |||||||||||
| 56 | 3 | ▶ | sub insertChild { | ||||||||
|
Subroutine
insertChild: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 57 | 3 | my $this = shift; | |||||||||
| 58 | 3 | my (%options) = @_; | |||||||||
| 59 | |||||||||||
| 60 | 3 | my $newNode = PurpleWiki::StructuralNode->new(%options); | |||||||||
| 61 | 3 | $newNode->{parent} = $this; | |||||||||
| 62 | 3 | push(@{$this->{children}}, $newNode); | |||||||||
| 63 | 3 | return $newNode; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 2 | ▶ | sub parent { | ||||||||
|
Subroutine
parent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 67 | 2 | my $this = shift; | |||||||||
| 68 | 2 | return $this->{parent}; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 10 | ▶ | sub children { | ||||||||
|
Subroutine
children: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 72 | 10 | my $this = shift; | |||||||||
| 73 | |||||||||||
| 74 | 10 | return $this->{children}; | |||||||||
| 75 | } | ||||||||||
| 76 | |||||||||||
| 77 | ### accessors/mutators | ||||||||||
| 78 | |||||||||||
| 79 | 8 | ▶ | sub type { | ||||||||
|
Subroutine
type: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 80 | 8 | my $this = shift; | |||||||||
| 81 | |||||||||||
| 82 | 8 | ▶ | $this->{type} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 83 | 8 | return $this->{type}; | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | sub id { | ||||||||
|
Subroutine
id: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 87 | 0 | my $this = shift; | |||||||||
| 88 | |||||||||||
| 89 | 0 | ▶ | $this->{id} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 90 | 0 | return $this->{id}; | |||||||||
| 91 | } | ||||||||||
| 92 | |||||||||||
| 93 | 9 | ▶ | sub content { | ||||||||
|
Subroutine
content: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||
| 94 | 9 | my $this = shift; | |||||||||
| 95 | |||||||||||
| 96 | 9 | ▶ | $this->{content} = shift if @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 97 | 9 | return $this->{content}; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | 18 | 1; | |||||||||
| 101 | __END__ | ||||||||||