2 # This CGI generates the HTML for choosing a module or list of modules
4 $trust_unknown_referers = 1;
5 require './web-lib.pl';
7 &ReadParse(undef, undef, 2);
8 %access = &get_module_acl();
11 # selecting multiple modules
12 if ($in{'frame'} == 0) {
16 @ul = split(/\s+/, $in{'module'});
18 print "sel = new Array($len);\n";
19 print "selr = new Array($len);\n";
20 for($i=0; $i<$len; $i++) {
21 %minfo = &get_module_info($ul[$i]);
23 print "sel[$i] = \"$ul[$i]\";\n";
24 print "selr[$i] = \"$minfo{'desc'}\";\n";
28 print "<title>$text{'modules_title1'}</title>\n";
29 print "<frameset cols='50%,50%'>\n";
30 print "<frame src=\"/module_chooser.cgi?frame=1&multi=1\">\n";
31 print "<frameset rows='*,50' frameborder=no>\n";
32 print " <frame src=\"/module_chooser.cgi?frame=2&multi=1\">\n";
33 print " <frame src=\"/module_chooser.cgi?frame=3&multi=1\" scrolling=no>\n";
34 print "</frameset>\n";
35 print "</frameset>\n";
37 elsif ($in{'frame'} == 1) {
38 # list of all modules to choose from
41 print "function addmodule(u, r)\n";
43 print "top.sel[top.sel.length] = u\n";
44 print "top.selr[top.selr.length] = r\n";
45 print "top.frames[1].location = top.frames[1].location\n";
46 print "return false;\n";
49 print "<font size=+1>$text{'modules_all'}</font>\n";
50 print "<table width=100%>\n";
51 foreach $m (&get_all_module_infos()) {
52 if ($in{'module'} eq $m->{'dir'}) { print "<tr $cb>\n"; }
53 else { print "<tr>\n"; }
54 print "<td width=20%><a href=\"\" onClick='return addmodule(\"$m->{'dir'}\", \"$m->{'desc'}\")'>$m->{'dir'}</a></td>\n";
55 print "<td>$m->{'desc'}</td> </tr>\n";
60 elsif ($in{'frame'} == 2) {
63 print "<font size=+1>$text{'modules_sel'}</font>\n";
69 sel2 = new Array(); selr2 = new Array();
70 for(k=0,l=0; k<top.sel.length; k++) {
73 selr2[l] = top.selr[k];
77 top.sel = sel2; top.selr = selr2;
78 top.frames[1].location = top.frames[1].location;
81 for(i=0; i<top.sel.length; i++) {
82 document.write("<tr>\n");
83 document.write("<td><a href=\"\" onClick='return sub("+i+")'>"+top.sel[i]+"</a></td>\n");
84 document.write("<td>"+top.selr[i]+"</td>\n");
91 elsif ($in{'frame'} == 3) {
92 # output OK and Cancel buttons
95 print "function qjoin(l)\n";
98 print "for(i=0; i<l.length; i++) {\n";
99 print " if (rv != '') rv += ' ';\n";
100 print " if (l[i].indexOf(' ') < 0) rv += l[i];\n";
101 print " else rv += '\"'+l[i]+'\"'\n";
103 print "return rv;\n";
107 print "<input type=button value=\"$text{'modules_ok'}\" ",
108 "onClick='top.opener.ifield.value = qjoin(top.sel); ",
110 print "<input type=button value=\"$text{'modules_cancel'}\" ",
111 "onClick='top.close()'>\n";
112 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";
118 # selecting just one module .. display a list of all modules to
120 &popup_header($text{'modules_title2'});
122 print "function select(f)\n";
124 print "top.opener.ifield.value = f;\n";
125 print "top.close();\n";
126 print "return false;\n";
129 print "<table width=100%>\n";
130 foreach $m (&get_all_module_infos()) {
131 if ($in{'user'} eq $m->{'dir'}) { print "<tr $cb>\n"; }
132 else { print "<tr>\n"; }
133 print "<td width=20%><a href=\"\" onClick='return select(\"$m->{'dir'}\")'>$m->{'dir'}</a></td>\n";
134 print "<td>$m->{'dir'}</td> </tr>\n";