line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
20
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION $Navigation); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
629
|
|
21
|
|
|
|
|
|
|
$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 objects correspond to |
34
|
|
|
|
|
|
|
C objects. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { |
43
|
0
|
|
|
0
|
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 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
|
|
|
|
|
|
|
sub Navigation { |
63
|
0
|
|
|
0
|
1
|
|
shift; |
64
|
0
|
0
|
|
|
|
|
if (@_) { |
65
|
0
|
|
|
|
|
|
$Navigation = $_[0]; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
$Navigation; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item o |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Return a reference to the L object. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub o { |
77
|
0
|
|
|
0
|
1
|
|
$_[0]->{O}; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item get(member) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Return the value of the named member of the L object. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get { |
87
|
0
|
|
|
0
|
1
|
|
$_[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 object is a document resp. folder. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item is_sequence |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Return true if the L object is a sequence. Remember that a |
97
|
|
|
|
|
|
|
sequence is always a C, so a call to C would |
98
|
|
|
|
|
|
|
also be true. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
foreach my $sub (qw(is_doc is_folder is_sequence |
103
|
|
|
|
|
|
|
)) { |
104
|
|
|
|
|
|
|
my $code = 'sub '.$sub.' { $_[0]->o->' . $sub.' }'; |
105
|
|
|
|
|
|
|
#warn "$code\n"; |
106
|
0
|
|
|
0
|
1
|
|
eval $code; die $@ if $@; |
|
0
|
|
|
0
|
1
|
|
|
|
0
|
|
|
0
|
1
|
|
|
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# NYI: |
110
|
|
|
|
|
|
|
foreach my $sub (qw(lang_title lang_short_title |
111
|
|
|
|
|
|
|
relurl halfabsurl absurl target |
112
|
|
|
|
|
|
|
)) { |
113
|
|
|
|
|
|
|
my $code = 'sub '.$sub.' { die "'.$sub.' is NYI" }'; |
114
|
|
|
|
|
|
|
#warn "$code\n"; |
115
|
0
|
|
|
0
|
0
|
|
eval $code; die $@ if $@; |
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
|
0
|
|
|
0
|
0
|
|
|
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. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This corresponds to things=data.${data.language}.ct as seen in the |
125
|
|
|
|
|
|
|
sample webeditor templates. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub content { |
130
|
0
|
|
|
0
|
1
|
|
my($self, $params) = @_; |
131
|
0
|
0
|
0
|
|
|
|
if (!$params || !$params->{lang}) { |
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. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub data { |
144
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub dump { |
154
|
0
|
|
|
0
|
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 }) { |
|
0
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$out .= "$k => " . WE::Util::LangString::langstring($v) . "\n"; |
159
|
|
|
|
|
|
|
} |
160
|
0
|
0
|
|
|
|
|
$out .= "\n$extra" if defined $extra; |
161
|
0
|
|
|
|
|
|
$out .= "\n"; |
162
|
0
|
|
|
|
|
|
warn $out; |
163
|
0
|
|
|
|
|
|
""; |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
1; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
__END__ |