line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Orze::Sources::Menu; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1671
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
56
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
146
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1914
|
use Data::Dump qw(dump); |
|
1
|
|
|
|
|
11008
|
|
|
1
|
|
|
|
|
206
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
13
|
use base "Orze::Sources"; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
766
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Orze::Sources::Menu - Build a page tree, suitable for a menu |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 DESCRIPTION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
If there is a base attribute, use the value as the root of the tree (it |
17
|
|
|
|
|
|
|
expects the name of a page). |
18
|
|
|
|
|
|
|
Otherwise, use the current page (you can also set C if you |
19
|
|
|
|
|
|
|
want). |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
If C, use the root of the website as the root of the tree. |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
All pages without a title variable or with the C attribute |
24
|
|
|
|
|
|
|
set to 1 will be ignored. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
The output is a list of hash pointer of the form: |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
{ |
29
|
|
|
|
|
|
|
name => 'name_of_the_page', |
30
|
|
|
|
|
|
|
title => 'Title of the page', |
31
|
|
|
|
|
|
|
extension => 'extension_of_the_page', |
32
|
|
|
|
|
|
|
path => 'path/to/name_of_the_page', |
33
|
|
|
|
|
|
|
submenu => pointer to a list of the same form, |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHOD |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 evaluate |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub evaluate { |
43
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $page = $self->{page}; |
46
|
0
|
|
|
|
|
|
my $var = $self->{var}; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $basename; |
49
|
0
|
0
|
|
|
|
|
if (defined($var->att('base'))) { |
50
|
0
|
|
|
|
|
|
$basename = $var->att('base'); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
else { |
53
|
0
|
|
|
|
|
|
$basename = "."; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $notinmenu; |
57
|
0
|
0
|
|
|
|
|
if (defined($page->att('notinmenu'))) { |
58
|
0
|
|
|
|
|
|
$notinmenu = $page->att('notinmenu'); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
0
|
|
|
|
|
|
$notinmenu = 0; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $base; |
65
|
0
|
0
|
|
|
|
|
if ($basename eq "/") { |
66
|
0
|
|
|
|
|
|
$base = $page->root; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
else { |
69
|
0
|
0
|
|
|
|
|
if ($basename eq ".") { |
70
|
0
|
|
|
|
|
|
$base = $page; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
else { |
73
|
0
|
|
|
|
|
|
$base = $page->root->first_child('page[@name="' . $basename . '"]'); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my @pages = $base->children('page'); |
78
|
0
|
|
|
|
|
|
my @menu = (); |
79
|
0
|
|
|
|
|
|
foreach (@pages) { |
80
|
0
|
|
|
|
|
|
my $notinmenu; |
81
|
0
|
0
|
|
|
|
|
if (defined($_->att('notinmenu'))) { |
82
|
0
|
|
|
|
|
|
$notinmenu = $_->att('notinmenu'); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
else { |
85
|
0
|
|
|
|
|
|
$notinmenu = 0; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my $title = $_->field('var[@name="title"]'); |
89
|
|
|
|
|
|
|
# print STDERR $title, "\n"; # ça devient de l'iso ici !!! |
90
|
0
|
0
|
0
|
|
|
|
if ($title && not $notinmenu) { |
91
|
0
|
|
|
|
|
|
my $name = $_->att('name'); |
92
|
0
|
|
|
|
|
|
my $extension = $_->att('extension'); |
93
|
0
|
|
|
|
|
|
my $path = $_->att('path'); |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my @subpages = $_->children('page'); |
96
|
0
|
|
|
|
|
|
my @submenu = (); |
97
|
0
|
|
|
|
|
|
foreach my $p (@subpages) { |
98
|
0
|
|
|
|
|
|
my $title = $p->field('var[@name="title"]'); |
99
|
0
|
0
|
|
|
|
|
if ($title) { |
100
|
0
|
|
|
|
|
|
my $name = $p->att('name'); |
101
|
0
|
|
|
|
|
|
my $extension = $p->att('extension'); |
102
|
0
|
|
|
|
|
|
my $path = $p->att('path'); |
103
|
0
|
|
|
|
|
|
push @submenu, { |
104
|
|
|
|
|
|
|
name => $name, |
105
|
|
|
|
|
|
|
title => $title, |
106
|
|
|
|
|
|
|
extension => $extension, |
107
|
|
|
|
|
|
|
path => $path, |
108
|
|
|
|
|
|
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
push @menu, { |
113
|
|
|
|
|
|
|
name => $name, |
114
|
|
|
|
|
|
|
title => $title, |
115
|
|
|
|
|
|
|
extension => $extension, |
116
|
|
|
|
|
|
|
path => $path, |
117
|
|
|
|
|
|
|
submenu => \@submenu, |
118
|
|
|
|
|
|
|
}; |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if ($var->att('debug')) { |
123
|
0
|
|
|
|
|
|
print STDERR dump(\@menu); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
return \@menu; |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
1; |