WE_Frontend/Plugin/Navigation/Object.pm

filter: Statementstmt 28.0% 16 / 57 Branchbran 16.6% 2 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 11.1% 2 / 18 Podpod 50.0% 8 / 16 totaltotal 25.9% 28 / 108 CC 6 SCAR 15.2
CC
6
Cov
25%
content
12.0
dump
12.0
Navigation
6.0
CRAP 4.6
« WE_Frontend/Plugin/KeywordIndex.pm ↑ Summary WE_Content/YAML.pm »
1 # -*- perl -*-
2  
3 #
4 # $Id: Object.pm,v 1.10 2004/10/04 17:05:47 eserte Exp $
5 # Author: Slaven Rezic
6 #
7 # Copyright (C) 2002 Online Office Berlin. All rights reserved.
8 # Copyright (C) 2002 Slaven Rezic.
9 # This is free software; you can redistribute it and/or modify it under the
10 # terms of the GNU General Public License, see the file COPYING.
11  
12 #
13 # Mail: slaven@rezic.de
14 # WWW: http://we-framework.sourceforge.net
15 #
16  
17 package WE_Frontend::Plugin::Navigation::Object;
18  
19 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use vars qw($VERSION $Navigation);
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 $VERSION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/);
22  
23 =head1 NAME
24  
25 WE_Frontend::Plugin::Navigation::Object - object for Navigation plugin
26  
27 =head1 SYNOPSIS
28  
29 Not instantiated manually
30  
31 =head1 DESCRIPTION
32  
33 The C<WE_Frontend::Plugin::Navigation::Object> objects correspond to
34 C<WE::Obj> objects.
35  
36 =head2 METHODS
37  
38 =over
39  
40 =cut
41  
42 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
43 0 my($pkg, $o, $navigation) = @_;
44 0 my $self = {O => $o};
45 0 bless $self, $pkg;
46 0 $self->Navigation($navigation);
47 0 $self;
48 }
49  
50 =item Navigation
51  
52 Return the L<WE_Frontend::Plugin::Navigation> object of the current
53 object.
54  
55 Implementation note: This is solved by using a global object because
56 of self-referencing issues with Perl. This means this will not work if
57 you have multiple navigation objects in your template (not likely
58 anyway). However with modern Perl, we could use weaken() instead.
59  
60 =cut
61  
62 0 ▶sub Navigation {
Subroutine Navigation: not called CC=2 SCAR=17.9
Pod documented
63 0 shift;
64 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
65 0 $Navigation = $_[0];
66 }
67 0 $Navigation;
68 }
69  
70 =item o
71  
72 Return a reference to the L<WE::Obj> object.
73  
74 =cut
75  
76 0 ▶sub o {
Subroutine o: not called CC=1 SCAR=6.9
Pod documented
77 0 $_[0]->{O};
78 }
79  
80 =item get(member)
81  
82 Return the value of the named member of the L<WE::Obj> object.
83  
84 =cut
85  
86 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod documented
87 0 $_[0]->o->{$_[1]}; # XXX evtl. try first method, then member!
88 }
89  
90 =item is_doc, is_folder
91  
92 Return true if the L<WE::Obj> object is a document resp. folder.
93  
94 =item is_sequence
95  
96 Return true if the L<WE::Obj> object is a sequence. Remember that a
97 sequence is always a C<FolderObj>, so a call to C<is_folder> would
98 also be true.
99  
100 =cut
101  
102 1 foreach my $sub (qw(is_doc is_folder is_sequence
103 )) {
104 3 my $code = 'sub '.$sub.' { $_[0]->o->' . $sub.' }';
105 #warn "$code\n";
106 0 ▶ eval $code; die $@ if $@;
Subroutine is_doc: not called CC=1 SCAR=1.7
Subroutine is_folder: not called CC=1 SCAR=1.7
Subroutine is_sequence: not called CC=1 SCAR=1.7
Pod documented
Pod documented
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
107 }
108  
109 # NYI:
110 1 foreach my $sub (qw(lang_title lang_short_title
111 relurl halfabsurl absurl target
112 )) {
113 6 my $code = 'sub '.$sub.' { die "'.$sub.' is NYI" }';
114 #warn "$code\n";
115 0 ▶ eval $code; die $@ if $@;
Subroutine absurl: not called CC=1 SCAR=2.9
Subroutine halfabsurl: not called CC=1 SCAR=2.9
Subroutine lang_short_title: not called CC=1 SCAR=2.9
Subroutine lang_title: not called CC=1 SCAR=2.9
Subroutine relurl: not called CC=1 SCAR=2.9
Subroutine target: not called CC=1 SCAR=2.9
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 6 6
116 }
117  
118 =item content([lang=lang])
119  
120 Return the language-specific language content of the current object.
121 If lang is not specified, then the "de" content is used instead XXX
122 This will probably change, so don't rely on it! See also L</data>.
123  
124 This corresponds to things=data.${data.language}.ct as seen in the
125 sample webeditor templates.
126  
127 =cut
128  
129 0 ▶sub content {
Subroutine content: not called CC=3 SCAR=24.8
Pod documented
130 0 my($self, $params) = @_;
131 0 ▶ if (!$params || !$params->{lang}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($params and $params->{"lang"}) 0 0 0
Condition0%0/3
$params and $params->{"lang"}
!ll&&!rl&&r
000
MC/DC0%0/2
$params and $params->{"lang"}
$params $params->{"lang"}
Truth table0%0/3
A and B
A= $paramsB= $params->{"lang"}
ABresult
0X0
100
111
132 0 $params->{lang} = "de"; # XXX how to get default language???
133 }
134 0 $self->data->{$params->{lang}}->{ct};
135 }
136  
137 =item data
138  
139 Return the data content of the current object. See also L</content>.
140  
141 =cut
142  
143 0 ▶sub data {
Subroutine data: not called CC=1 SCAR=6.9
Pod documented
144 0 my($self) = @_;
145 0 my $content;
146 0 require WE_Content::Base;
147 0 my $content_file = $self->Navigation->{RootDB}->ContentDB->filename($self->o->Id);
148 0 my $perldd = WE_Content::Base->new(-file => $content_file);
149 0 $content = $perldd->{Object}->{'data'};
150 0 $content;
151 }
152  
153 0 ▶sub dump {
Subroutine dump: not called CC=3 SCAR=24.8
Pod undocumented
154 0 my($self, $extra) = @_;
155 0 my $out = "Dump $self:\n";
156 0 require WE::Util::LangString;
157 0 ▶ while(my($k,$v) = each %{ $self->o }) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->o;}) 0 0 0
158 0 $out .= "$k => " . WE::Util::LangString::langstring($v) . "\n";
159 }
160 0 ▶ $out .= "\n$extra" if defined $extra;
Branch: 1 branch
BranchTrueFalseTotal
if defined $extra 0 0 0
161 0 $out .= "\n";
162 0 warn $out;
163 0 "";
164 }
165  
166 1 1;
167  
168 __END__
« WE_Frontend/Plugin/KeywordIndex.pm ↑ Summary WE_Content/YAML.pm »