3 # Outputs HTML for a frame-based svc chooser
5 require './smf-lib.pl';
10 # type specifies svc, inst or both
12 if (defined($in{'type'})) {
15 if ((defined($in{'add'})) && ($in{'add'})) {
16 # Only use last fmri by default
17 $in{'fmri'} =~ s/\s+$//;
18 if ($in{'fmri'} =~ /\n(.*)$/) {
23 if ($fmri =~ /^svc\:\/([^\:]*)\:*(.*)$/) {
24 # fmri entered is valid
33 $add = int($in{'add'});
35 $frame = $in{'frame'};
40 if ($in{'frame'} == 0) {
43 if ($in{'type'} eq "svc")
44 { print "<title>$text{'svc_chooser_titlesvc'}</title>\n"; }
45 elsif ($in{'type'} eq "inst")
46 { print "<title>$text{'svc_chooser_titleinst'}</title>\n";}
48 { print "<title>$text{'svc_chooser_titleboth'}</title>\n";}
50 print "<frameset rows='*,50'>\n";
51 print "<frame marginwidth=10 marginheight=10 name=topframe ",
52 "src=\"svc_chooser.cgi?frame=1&fmri=$fmri&add=$add&type=$type\">\n";
53 print "<frame marginwidth=10 marginheight=10 name=bottomframe ",
54 "src=\"svc_chooser.cgi?frame=2&add=$add&fmri=$fmri&type=$type\" ",
56 print "</frameset>\n";
58 elsif ($in{'frame'} == 1) {
63 function svcclick(fmri, inst, expand, isvalid)
65 if ((inst == "") || (inst == ":")) {
69 selected_fmri = fmri+inst;
71 curr = top.bottomframe.document.forms[0].fmri.value;
73 top.bottomframe.document.forms[0].fmri.value = selected_fmri;
76 location ="svc_chooser.cgi?frame=1&add=$add&type=$type&fmri="+fmri+inst;
82 print "<b>", &text('svc_chooser_fmri', $fmri),"</b>\n";
84 # filter fmris via fmri var
85 @list = &svcs_listing("$fmri", "-sFMRI");
86 foreach $f_hash (@list) {
87 $full_fmri = $f_hash->{"FMRI"};
88 if ($full_fmri =~ /^$fmri([^\/:]+[\/\:]*).*$/) {
90 # check if its an instance, if so add colon
91 if ($fmri =~ /.*\:$/) {
97 @fmris = &unique(@flist);
99 if ($uplevel =~ /^svc\:\/.+$/) {
100 $uplevel =~ /^svc\:\/(([^\/\:]+[\:\/])*)[^\/\:]+[\/]*[\:]*$/;
101 $uplevel = "svc:/$1";
102 unshift(@fmris, $uplevel);
104 foreach $f (@fmris) {
107 if ($f eq $uplevel) {
108 $img = "images/uplevel.gif";
110 "<a href='javascript:svcclick(\"$uplevel\",\"\",1,0)'>";
111 } elsif ($f =~ /^.*\/$/) {
112 $img = "images/nextlevel.gif";
114 "<a href='javascript:svcclick(\"$fmri$f\",\"\",1,0)'>";
115 } elsif ($f =~ /^\:.*/) {
116 # at instance level...
118 $f =~ s/^\:(\S+)$/$1/;
119 $img = "images/instance.gif";
121 "<a href='javascript:svcclick(\"$fmri\",\"$f\",0,1)'>";
124 $img = "images/service.gif";
125 # remove final ":" if present
126 $f =~ s/^([^\:]+)\:$/$1/;
128 if ($type eq "svc") {
129 # cannot click to instance level!
130 # remove final ":" if present
133 } elsif ($type eq "inst") {
134 # cannnot select svc...
143 "<a href='javascript:svcclick(\"$fmri$f\",\"$inst\",$expand,$isvalid)'>";
146 "<td>$link<img border=0 width=30 height=30 src=$img></a></td>\n";
147 print "<td>$link$f</a></td>\n";
150 print "</table></td></tr></table>\n";
153 elsif ($in{'frame'} == 2) {
154 # Current fmri and OK/cancel buttons
158 function fmrichosen()
161 top.opener.ifield.value = document.forms[0].fmri.value;
164 if (top.opener.ifield.value != "") {
165 top.opener.ifield.value += " ";
167 top.opener.ifield.value += document.forms[0].fmri.value;
173 print "<table width=100%><tr><td>\n";
174 print "<form onSubmit='fmrichosen(); return false'>\n";
176 "<input name=fmri size=45 value=\"\">\n";
178 "<input type=\"submit\" value=\"$text{'svc_chooser_ok'}\">\n";
183 "<input type=\"button\" onClick='top.close()' value=\"$text{'svc_chooser_cancel'}\">";
185 print "</td></tr></table></form>\n";