| 1 | # E2::Node | ||||||||||||||||||||||||||||
| 2 | # Jose M. Weeks <jose@joseweeks.com> | ||||||||||||||||||||||||||||
| 3 | # 11 July 2003 | ||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||
| 5 | # See bottom for pod documentation. | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | package E2::Node; | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 6 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 6 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 6 | ▶ | use E2::Interface; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | our @ISA = "E2::Interface"; | |||||||||||||||||||||||||||
| 17 | 6 | our $VERSION = "0.33"; | |||||||||||||||||||||||||||
| 18 | 6 | our $DEBUG; *DEBUG = *E2::Interface::DEBUG; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # Prototypes | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | sub new; | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | sub clear; | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | sub title; | ||||||||||||||||||||||||||||
| 27 | sub node_id; | ||||||||||||||||||||||||||||
| 28 | sub author; | ||||||||||||||||||||||||||||
| 29 | sub author_id; | ||||||||||||||||||||||||||||
| 30 | sub createtime; | ||||||||||||||||||||||||||||
| 31 | sub type; | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub bookmark; | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | sub load; | ||||||||||||||||||||||||||||
| 36 | sub load_by_id; | ||||||||||||||||||||||||||||
| 37 | sub load_from_xml; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # Object Methods | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 5 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||
| 42 | 5 | my $arg = shift; | |||||||||||||||||||||||||||
| 43 | 5 | ▶ | my $class = ref( $arg ) || $arg; | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $arg || $arg
MC/DC0%0/2
ref $arg || $arg
ref $arg
$arg
Truth table33%1/3
A || B
A= ref $argB= $arg
| |||||||||||||||||||||||||||||
| 44 | 5 | my $self = $class->SUPER::new(); | |||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 5 | $self->clear; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 5 | return $self; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 15 | ▶ | sub clear { | ||||||||||||||||||||||||||
|
Subroutine
clear: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 15 | ▶ | my $self = shift or croak "Usage: clear E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 15 | ▶ | warn "E2::Node::clear\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 15 | $self->{title} = undef; # Title of the node | |||||||||||||||||||||||||||
| 57 | 15 | $self->{node_id} = undef; # node_id | |||||||||||||||||||||||||||
| 58 | 15 | $self->{author} = undef; # Author (node creator) | |||||||||||||||||||||||||||
| 59 | 15 | $self->{author_id} = undef; # user_id of author | |||||||||||||||||||||||||||
| 60 | 15 | $self->{time} = undef; # Creation time | |||||||||||||||||||||||||||
| 61 | 15 | $self->{type} = undef; # Writeup type | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 15 | return 1; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub type_as_string { | ||||||||||||||||||||||||||
|
Subroutine
type_as_string: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | 0 | return undef; | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub autodetect { | ||||||||||||||||||||||||||
|
Subroutine
autodetect: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | ▶ | my $self = shift or croak "Usage: autodetect E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | ▶ | warn "E2::Node::autodetect\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | bless $self; | |||||||||||||||||||||||||||
| 76 | 0 | return 1; | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub load { | ||||||||||||||||||||||||||
|
Subroutine
load: not called CC=12 SCAR=50.5
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $self = shift or croak "Usage: load E2NODE, TITLE [, TYPE] [, SOFTLINK ]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | my $title = shift or croak "Usage: load E2NODE, TITLE [, TYPE] [, SOFTLINK ]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $type = shift || $self->type_as_string; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->type_as_string
MC/DC0%0/2
shift() || $self->type_as_string
shift()
$self->type_as_string
Truth table0%0/3
A || B
A= shift()B= $self->type_as_string
| |||||||||||||||||||||||||||||
| 83 | 0 | ▶ | my $softlink = shift||0; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | warn "E2::Node::load\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 0 | ▶ | warn "Loading node $title" if $DEBUG > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | $softlink = $self->node_id if $softlink == -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 0 | ▶ | warn "[softlinking $softlink]" if $DEBUG > 2 && $softlink; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$E2::Node::DEBUG > 2 and $softlink
MC/DC0%0/2
$E2::Node::DEBUG > 2 and $softlink
$E2::Node::DEBUG > 2
$softlink
Truth table0%0/3
A and B
A= $E2::Node::DEBUG > 2B= $softlink
| |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | 0 | my %opt; | |||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | $opt{node} = $title; | |||||||||||||||||||||||||||
| 96 | 0 | $opt{displaytype} = 'xmltrue'; | |||||||||||||||||||||||||||
| 97 | 0 | ▶ | $opt{type} = $type if $type; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $opt{lastnode_id} = $softlink if $softlink; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | return $self->thread_then( | ||||||||||||||||||||||||||||
| 101 | [ \&E2::Interface::process_request, $self, %opt ], | ||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 103 | 0 | my $r = shift; | |||||||||||||||||||||||||||
| 104 | 0 | return $self->load_from_xml( $r ); | |||||||||||||||||||||||||||
| 105 | 0 | }); | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | ▶ | sub load_by_id { | ||||||||||||||||||||||||||
|
Subroutine
load_by_id: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $self = shift or croak "Usage: load_by_id E2NODE, NODE_ID [, SOFTLINK ]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my $id = shift or croak "Usage: load_by_id E2NODE, NODE_ID [, SOFTLINK ]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | my $softlink = shift||0; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | warn "E2::Node::load_by_id\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 0 | ▶ | warn "Loading node_id $id" if $DEBUG > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $softlink = $self->node_id if $softlink == -1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | my %opt; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | $opt{node_id} = $id; | |||||||||||||||||||||||||||
| 122 | 0 | $opt{displaytype} = 'xmltrue'; | |||||||||||||||||||||||||||
| 123 | 0 | ▶ | $opt{lastnode_id} = $softlink if $softlink; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | return $self->thread_then( [ \&E2::Interface::process_request, $self, %opt ], | ||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 127 | 0 | my $r = shift; | |||||||||||||||||||||||||||
| 128 | 0 | return $self->load_from_xml( $r ); | |||||||||||||||||||||||||||
| 129 | 0 | }); | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 5 | ▶ | sub load_from_xml { | ||||||||||||||||||||||||||
|
Subroutine
load_from_xml: called CC=13 SCAR=39.7
Pod
documented
| |||||||||||||||||||||||||||||
| 134 | 5 | ▶ | my $self = shift or croak "Usage: load_from_xml E2NODE, XML_STRING"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | 5 | ▶ | my $xml = shift or croak "Usage: load_from_xml E2NODE, XML_STRING"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 5 | ▶ | warn "E2::Node::load_from_xml\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 5 | my %type_to_class = ( | |||||||||||||||||||||||||||
| 140 | e2node => 'E2::E2Node', | ||||||||||||||||||||||||||||
| 141 | writeup => 'E2::E2Node', | ||||||||||||||||||||||||||||
| 142 | user => 'E2::User', | ||||||||||||||||||||||||||||
| 143 | usergroup => 'E2::Usergroup', | ||||||||||||||||||||||||||||
| 144 | room => 'E2::Room', | ||||||||||||||||||||||||||||
| 145 | superdoc => 'E2::Superdoc', | ||||||||||||||||||||||||||||
| 146 | superdocnolinks => 'E2::Superdoc' | ||||||||||||||||||||||||||||
| 147 | ); | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | # Determine what type the XML says it is. | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 5 | $xml =~ /<type>(.*?)<\/type>/s; | |||||||||||||||||||||||||||
| 152 | 5 | my $verified_type = $1; | |||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 5 | ▶ | if( !$verified_type ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 155 | 0 | croak "Invalid document"; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | # If we hit a search page then the node doesn't exist | ||||||||||||||||||||||||||||
| 159 | # FIXME: search page | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 5 | ▶ | if( ! ($xml =~ /<node [^>]*node_id="(.*?)"/s) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | croak "Invalid document"; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 5 | ▶ | if( $1 == 1140332 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 166 | #&& # Search node_id | ||||||||||||||||||||||||||||
| 167 | # (!$type || lc($type) ne 'superdoc') ) { | ||||||||||||||||||||||||||||
| 168 | 0 | ▶ | warn "Hit search superdoc" if $DEBUG; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | $self->clear; | |||||||||||||||||||||||||||
| 170 | 0 | return undef; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | #if( $type && lc($type) ne lc($verified_type) ) { | ||||||||||||||||||||||||||||
| 174 | # return undef; | ||||||||||||||||||||||||||||
| 175 | #} | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # Now, if we are an E2::Node, figure out what type of node | ||||||||||||||||||||||||||||
| 178 | # the XML is describing and bless $self into that class. | ||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 5 | ▶ | if( ref($self) eq "E2::Node" ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | $self->clear; | |||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | my $class = $type_to_class{$verified_type}; | |||||||||||||||||||||||||||
| 185 | 0 | ▶ | if( !$class ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 186 | 0 | croak "Invalid document"; | |||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # Convert class name to module name and | ||||||||||||||||||||||||||||
| 190 | # re-bless $self to that class. | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 0 | my $c = $class; | |||||||||||||||||||||||||||
| 193 | 0 | $c =~ s/::/\//g; | |||||||||||||||||||||||||||
| 194 | 0 | $c .= ".pm"; | |||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | 0 | require $c; | |||||||||||||||||||||||||||
| 197 | 0 | bless $self, $class; | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | ▶ | warn "Autodetected type $class" if $DEBUG > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | # Otherwise, make sure the node is of the type | ||||||||||||||||||||||||||||
| 202 | # we expect. | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | } else { | ||||||||||||||||||||||||||||
| 205 | 5 | ▶ | if( lc($self->type_as_string) ne lc($verified_type) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | 0 | croak "Wrong node type"; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | # These are the default handlers. Descendants can add handlers by | ||||||||||||||||||||||||||||
| 211 | # returning a hash (of 'tag' => sub { ... } pairs) in the method | ||||||||||||||||||||||||||||
| 212 | # twig_handlers | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | my %handlers = ( | ||||||||||||||||||||||||||||
| 215 | 0 | ▶ | 'node' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 216 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||
| 217 | 0 | $self->{node_id} = $b->{att}->{node_id}; | |||||||||||||||||||||||||||
| 218 | 0 | $self->{createtime} = $b->{att}->{createtime}; | |||||||||||||||||||||||||||
| 219 | }, | ||||||||||||||||||||||||||||
| 220 | 0 | ▶ | 'node/type' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 221 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||
| 222 | 0 | $self->{type} = $b->text; | |||||||||||||||||||||||||||
| 223 | }, | ||||||||||||||||||||||||||||
| 224 | 0 | ▶ | 'node/title' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 225 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||
| 226 | 0 | $self->{title} = $b->text; | |||||||||||||||||||||||||||
| 227 | }, | ||||||||||||||||||||||||||||
| 228 | 0 | ▶ | 'node/author' => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 229 | 0 | (my $a, my $b) = @_; | |||||||||||||||||||||||||||
| 230 | 0 | $self->{author} = $b->text; | |||||||||||||||||||||||||||
| 231 | 0 | $self->{author_id} = $b->{att}->{user_id}; | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | 5 | ); | |||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 5 | my %h2 = $self->twig_handlers; | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 5 | ▶ | if( %h2 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 5 | %handlers = ( %handlers, %h2 ); # Append twig_handlers | |||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | 5 | $self->clear; | |||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | 5 | $self->parse_twig( $xml, \%handlers ); | |||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 0 | return 1; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | 0 | ▶ | sub bookmark { | ||||||||||||||||||||||||||
|
Subroutine
bookmark: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my $self = shift or croak "Usage: bookmark E2NODE [, NODE_ID ]"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | my $node_id = shift || $self->node_id; | ||||||||||||||||||||||||||
|
Condition0%0/3
shift() || $self->node_id
MC/DC0%0/2
shift() || $self->node_id
shift()
$self->node_id
Truth table0%0/3
A || B
A= shift()B= $self->node_id
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | ▶ | warn "E2::Node::bookmark\n" if $DEBUG > 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | ▶ | if( !$self->logged_in ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 0 | croak "Not logged in"; | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if( !$node_id ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | croak "No node specified"; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | return $self->thread_then( [ \&E2::Interface::process_request, | ||||||||||||||||||||||||||||
| 263 | $self, | ||||||||||||||||||||||||||||
| 264 | node_id => $node_id, | ||||||||||||||||||||||||||||
| 265 | op => "bookmark", | ||||||||||||||||||||||||||||
| 266 | displaytype => "xmltrue" | ||||||||||||||||||||||||||||
| 267 | ], | ||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 269 | 0 | return 1; | |||||||||||||||||||||||||||
| 270 | 0 | }); | |||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | #--------------- | ||||||||||||||||||||||||||||
| 274 | # Access methods | ||||||||||||||||||||||||||||
| 275 | #--------------- | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub exists { | ||||||||||||||||||||||||||
|
Subroutine
exists: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $self = shift or croak "Usage: exists E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if( !$self->node_id ) { return 0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 0 | else { return 1; } | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | ▶ | sub author { | ||||||||||||||||||||||||||
|
Subroutine
author: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 285 | 0 | ▶ | my $self = shift or croak "Usage: author E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | return $self->{author}; | |||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 0 | ▶ | sub author_id { | ||||||||||||||||||||||||||
|
Subroutine
author_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 291 | 0 | ▶ | my $self = shift or croak "Usage: author_id E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 0 | return $self->{author_id}; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 0 | ▶ | sub node_id { | ||||||||||||||||||||||||||
|
Subroutine
node_id: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 297 | 0 | ▶ | my $self = shift or croak "Usage: node_id E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 0 | return $self->{node_id}; | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 0 | ▶ | sub title { | ||||||||||||||||||||||||||
|
Subroutine
title: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 303 | 0 | ▶ | my $self = shift or croak "Usage: title E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | return $self->{title} | ||||||||||||||||||||||||||||
| 306 | 0 | } | |||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | 0 | ▶ | sub createtime { | ||||||||||||||||||||||||||
|
Subroutine
createtime: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 309 | 0 | ▶ | my $self = shift or croak "Usage: createtime E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | 0 | return $self->{createtime}; | |||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | 0 | ▶ | sub type { | ||||||||||||||||||||||||||
|
Subroutine
type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 315 | 0 | ▶ | my $self = shift or croak "Usage: type E2NODE"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | 0 | return $self->{type}; | |||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | 6 | 1; | |||||||||||||||||||||||||||
| 321 | __END__ | ||||||||||||||||||||||||||||