| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package WebEditor::OldFeatures::MakeMenu; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1168
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
33
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
78
|
|
|
5
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.5 $ =~ /(\d+)\.(\d+)/); |
|
6
|
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use CGI qw(param); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# XXX |
|
10
|
|
|
|
|
|
|
# This module is untested for a long time. Probably the |
|
11
|
|
|
|
|
|
|
# get_released_children calls should be rooted in $objdb instead of $root |
|
12
|
|
|
|
|
|
|
# now. Also there's too much project specific stuff hardcoded to be |
|
13
|
|
|
|
|
|
|
# useable as a general purpose module. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
###################################################################### |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# create the menu |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
sub makemenu { |
|
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
|
my $root = $self->Root; |
|
23
|
0
|
|
|
|
|
|
my $objdb = $root->ObjDB; |
|
24
|
0
|
|
|
|
|
|
my $c = $self->C; |
|
25
|
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
require Template; |
|
27
|
|
|
|
|
|
|
# create a dummy-menu: |
|
28
|
0
|
|
|
|
|
|
my @lines; |
|
29
|
0
|
|
|
|
|
|
my %menucolors = ("aussen","green", |
|
30
|
|
|
|
|
|
|
"innen","red", |
|
31
|
|
|
|
|
|
|
"company","blue"); |
|
32
|
0
|
|
|
|
|
|
my $t = Template->new($self->Templateconf); |
|
33
|
0
|
|
|
|
|
|
my $templatevars = $self->Templatevars; |
|
34
|
0
|
|
|
|
|
|
foreach my $mnu (keys %menucolors) { |
|
35
|
0
|
|
|
|
|
|
foreach my $lng (@{ $c->project->sitelanguages }) { |
|
|
0
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my @lines=(); |
|
37
|
|
|
|
|
|
|
#traversemenu(0,\@lines,$lng); |
|
38
|
0
|
|
|
|
|
|
my $outf = $c->paths->pubhtmldir."script/menuconfig_".$mnu."_".$lng.".js"; |
|
39
|
0
|
|
|
|
|
|
$templatevars->{'bgcolor'} = $menucolors{$mnu}; |
|
40
|
|
|
|
|
|
|
#### now the real work |
|
41
|
0
|
|
|
|
|
|
my $fldr_id = $objdb->name_to_objid($mnu); |
|
42
|
0
|
|
|
|
|
|
my @children = $root->get_released_children($fldr_id); |
|
43
|
0
|
|
|
|
|
|
my $mcounter = 0; |
|
44
|
0
|
|
|
|
|
|
foreach my $child (@children) { |
|
45
|
0
|
0
|
|
|
|
|
next if (!$child->is_folder); |
|
46
|
0
|
|
|
|
|
|
my $mtarget = ""; |
|
47
|
0
|
0
|
|
|
|
|
if (defined $child->IndexDoc) { $mtarget = $child->IndexDoc }; |
|
|
0
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $mtitle = $child->Title->get($lng); |
|
49
|
0
|
|
|
|
|
|
push(@lines,"menu1.list.add('".$mtarget."',' > ".$mtitle."')\n"); |
|
50
|
0
|
|
|
|
|
|
my @products = $root->get_released_children($child->Id); |
|
51
|
|
|
|
|
|
|
#warn $products[0]; |
|
52
|
0
|
0
|
|
|
|
|
if (@products > 0) {push(@lines," tmp = new MenuList(menu1,$mcounter,widchld)\n")} |
|
|
0
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
foreach my $product (@products) { |
|
54
|
0
|
0
|
|
|
|
|
next if (!$product->is_folder); |
|
55
|
0
|
|
|
|
|
|
my $mtarget = ""; |
|
56
|
0
|
0
|
|
|
|
|
if (defined $product->IndexDoc) { $mtarget = $product->IndexDoc }; |
|
|
0
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
my $mtitle = $product->Title->get($lng); |
|
58
|
0
|
|
|
|
|
|
push(@lines," tmp.list.add('".$mtarget."',' ".$mtitle."')\n"); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
0
|
|
|
|
|
|
$mcounter++; |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
### |
|
63
|
0
|
|
|
|
|
|
$templatevars->{'lines'} = \@lines; |
|
64
|
0
|
0
|
|
|
|
|
open (MENU, ">$outf") or error("cant writeopen $outf"); |
|
65
|
0
|
0
|
|
|
|
|
$t->process($c->paths->we_site_templatebase."menuconfig_tpl.js", $self->Templatevars, \*MENU ) or error("Template process failed: ", $t->error, "\n"); |
|
66
|
0
|
|
|
|
|
|
close MENU; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
0
|
|
|
|
|
|
my $outf = $c->paths->pubhtmldir."script/lookup.js"; |
|
70
|
0
|
0
|
|
|
|
|
open (LOOKUP, ">$outf") or error("cant writeopen $outf"); |
|
71
|
0
|
|
|
|
|
|
print LOOKUP 'var lookup = {'; |
|
72
|
0
|
|
|
|
|
|
$self->traverselookup($objdb->root_object->Id); |
|
73
|
0
|
|
|
|
|
|
print LOOKUP " aussen:[\"12\",\"aussen\"], innen:[\"18\",\"innen\"]}"; |
|
74
|
0
|
|
|
|
|
|
close LOOKUP; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
#XXX delete: $self->updatekeydb(); |
|
77
|
|
|
|
|
|
|
####### |
|
78
|
|
|
|
|
|
|
# for the real menu: |
|
79
|
|
|
|
|
|
|
# check each objects "VisibleToMenu", |
|
80
|
|
|
|
|
|
|
# if an object appears in the menu at all |
|
81
|
|
|
|
|
|
|
# |
|
82
|
|
|
|
|
|
|
# check "IndexDoc" of each folder, |
|
83
|
|
|
|
|
|
|
# which page will be the index.Page of this folder |
|
84
|
|
|
|
|
|
|
# |
|
85
|
|
|
|
|
|
|
# then yo'll probably have to create the JS-file |
|
86
|
|
|
|
|
|
|
# "/html/nav_js/menuitems.js" |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub traverselookup { |
|
90
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $root = $self->Root; |
|
93
|
0
|
|
|
|
|
|
my $objdb = $self->ObjDB; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $realid; |
|
96
|
|
|
|
|
|
|
my $targetid; |
|
97
|
0
|
|
|
|
|
|
my ($objid) = @_; |
|
98
|
0
|
|
|
|
|
|
my @children = $objdb->children($objid); |
|
99
|
|
|
|
|
|
|
#my @children = $root->get_released_children($objid); |
|
100
|
0
|
|
|
|
|
|
foreach my $child (@children) { |
|
101
|
0
|
0
|
|
|
|
|
if ($child->is_folder) { |
|
102
|
0
|
0
|
|
|
|
|
if (defined $child->IndexDoc) { |
|
|
|
0
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$targetid = $child->IndexDoc; |
|
104
|
|
|
|
|
|
|
} elsif ($root->get_released_children($child->Id)) { |
|
105
|
0
|
|
|
|
|
|
my @cs = $root->get_released_children($child->Id); |
|
106
|
0
|
0
|
|
|
|
|
if ($cs[0]) { |
|
107
|
0
|
|
0
|
|
|
|
$targetid = $cs[0]->Version_Parent || "x"; |
|
108
|
|
|
|
|
|
|
} else { |
|
109
|
0
|
|
|
|
|
|
$targetid="x"; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
} else { |
|
112
|
0
|
|
|
|
|
|
$targetid="x"; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
0
|
|
|
|
|
|
$realid = $child->Id; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
0
|
|
|
|
|
|
my $chobj = $root->get_released_object($child->Id); |
|
117
|
0
|
0
|
|
|
|
|
if ($chobj) { |
|
118
|
0
|
|
|
|
|
|
$realid = $chobj->Version_Parent; |
|
119
|
|
|
|
|
|
|
#my $realid = $child->Id; |
|
120
|
0
|
|
|
|
|
|
$targetid = $realid; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
|
123
|
0
|
|
|
|
|
|
print LOOKUP $realid.':["'.$targetid.'.html"'; |
|
124
|
0
|
0
|
|
|
|
|
if ($root->can("get_section")) { |
|
125
|
0
|
|
|
|
|
|
print LOOKUP ',"' . $root->get_section($child->Id) . '"'; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
|
|
|
|
|
print LOOKUP '],'."\n"; |
|
128
|
0
|
0
|
|
|
|
|
if ($child->is_folder) { |
|
129
|
0
|
|
|
|
|
|
$self->traverselookup($child->Id); |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub traversemenu { |
|
135
|
0
|
|
|
0
|
0
|
|
my ($self,$objid,$lines,$lang) = @_; |
|
136
|
0
|
|
|
|
|
|
my $root = $self->Root; |
|
137
|
0
|
|
|
|
|
|
my @children = $root->get_released_children($objid); |
|
138
|
0
|
|
|
|
|
|
foreach my $child (@children) { |
|
139
|
0
|
0
|
|
|
|
|
if ($child->is_folder) { |
|
140
|
0
|
|
|
|
|
|
$self->traversemenu($child->Id,$lines,$lang); |
|
141
|
|
|
|
|
|
|
} else { |
|
142
|
0
|
|
|
|
|
|
push(@$lines,"".$child->Id." ") |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |