2 # This CGI generates the HTML for choosing a module or list of modules
4 BEGIN { push(@INC, ".."); };
7 $trust_unknown_referers = 1;
9 &ReadParse(undef, undef, 2);
10 %access = &get_module_acl();
13 # selecting multiple modules
14 if ($in{'frame'} == 0) {
18 @ul = split(/\s+/, $in{'module'});
20 print "sel = new Array($len);\n";
21 print "selr = new Array($len);\n";
22 for($i=0; $i<$len; $i++) {
23 %minfo = &get_module_info($ul[$i]);
25 print "sel[$i] = \"$ul[$i]\";\n";
26 print "selr[$i] = \"$minfo{'desc'}\";\n";
30 print "<title>$text{'modules_title1'}</title>\n";
31 print "<frameset cols='50%,50%'>\n";
32 print "<frame src=\"/module_chooser.cgi?frame=1&multi=1\">\n";
33 print "<frameset rows='*,50' frameborder=no>\n";
34 print " <frame src=\"/module_chooser.cgi?frame=2&multi=1\">\n";
35 print " <frame src=\"/module_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
36 print "</frameset>\n";
37 print "</frameset>\n";
39 elsif ($in{'frame'} == 1) {
40 # list of all modules to choose from
43 print "function addmodule(u, r)\n";
45 print "top.sel[top.sel.length] = u\n";
46 print "top.selr[top.selr.length] = r\n";
47 print "top.frames[1].location = top.frames[1].location\n";
48 print "return false;\n";
51 print "<font size=+1>$text{'modules_all'}</font>\n";
52 print "<table width=100%>\n";
53 foreach $m (&get_all_module_infos()) {
54 if ($in{'module'} eq $m->{'dir'}) { print "<tr $cb>\n"; }
55 else { print "<tr>\n"; }
56 print "<td width=20%><a href=\"\" onClick='return addmodule(\"$m->{'dir'}\", \"$m->{'desc'}\")'>$m->{'dir'}</a></td>\n";
57 print "<td>$m->{'desc'}</td> </tr>\n";
62 elsif ($in{'frame'} == 2) {
65 print "<font size=+1>$text{'modules_sel'}</font>\n";
71 sel2 = new Array(); selr2 = new Array();
72 for(k=0,l=0; k<top.sel.length; k++) {
75 selr2[l] = top.selr[k];
79 top.sel = sel2; top.selr = selr2;
80 top.frames[1].location = top.frames[1].location;
83 for(i=0; i<top.sel.length; i++) {
84 document.write("<tr>\n");
85 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
86 document.write("<td>"+top.selr[i]+"</td>\n");
93 elsif ($in{'frame'} == 3) {
94 # output OK and Cancel buttons
97 print "function qjoin(l)\n";
100 print "for(i=0; i<l.length; i++) {\n";
101 print " if (rv != '') rv += ' ';\n";
102 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
103 print " else rv += '\"'+l[i]+'\"'\n";
105 print "return rv;\n";
109 print "<input type=button value=\"$text{'modules_ok'}\" ",
110 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
112 print "<input type=button value=\"$text{'modules_cancel'}\" ",
113 "onClick='top.close()'>\n";
114 print " <input type=button value=\"$text{'modules_clear'}\" onClick='top.sel = new Array(); top.selr = new Array(); top.frames[1].location = top.frames[1].location'>\n";
120 # selecting just one module .. display a list of all modules to
122 &popup_header($text{'modules_title2'});
124 print "function select(f)\n";
126 print "top.opener.ifield.value = f;\n";
127 print "top.close();\n";
128 print "return false;\n";
131 print "<table width=100%>\n";
132 foreach $m (&get_all_module_infos()) {
133 if ($in{'user'} eq $m->{'dir'}) { print "<tr $cb>\n"; }
134 else { print "<tr>\n"; }
135 print "<td width=20%><a href=\"\" onClick='return select(\"$m->{'dir'}\")'>$m->{'dir'}</a></td>\n";
136 print "<td>$m->{'dir'}</td> </tr>\n";