5 <script type="text/javascript" src="/planetlab/minitabs/minitabs.js"></script>
6 <link href="/planetlab/minitabs/minitabs.css" rel="stylesheet" type="text/css" />
10 // the expected argument is an (ordered) associative array
11 // ( label => todo , ...)
12 // label is expected to be the string to display in the menu
14 // (*) a string : it is then taken to be a URL to move to
15 // (*) or an associative array with the following keys
16 // (*) 'method': 'POST' or 'GET' -- default is 'GET'
17 // (*) 'url': where to go
18 // (*) 'values': an associative array of (key,value) pairs to send to the URL; values are strings
19 // (*) 'confirm': a question to display before actually triggering
20 // (*) 'bubble': a longer message displayed when the mouse stays quite for a while on the label
21 // (*) 'image' : the url of an image used instead of the full title
22 // (*) 'height' : used for the image
24 ////////// Notes: limited support for images
25 // (*) for some reason, confirmation does not work with image tabs
26 // (the form gets submitted whatever the confirmation....)
27 // (*) you need to tune the image size, which is wrong, as the image should rather be bottom-aligned
30 function plc_tabs ($array) {
31 print '<div id="minitabs-container">';
32 print '<ul id="minitabs-list">';
34 foreach ($array as $label=>$todo) {
35 $tracer="class=minitabs";
37 $tracer .= " id=".$todo['id'];
38 printf ("<li %s>\n",$tracer);
39 // in case we have a string, rewrite it as an array
40 if (is_string ($todo)) $todo=array('method'=>'GET','url'=>$todo);
42 if ( ! $todo['method'] ) $todo['method']='GET';
43 // extract var=value settings from url if any
44 $full_url=$todo['url'];
45 $split=split_url($full_url);
47 $url_values=$split['values'];
50 printf ('<form name="%s" action="%s" method="%s">',$label,$url,$todo['method']);
52 $values=$todo['values'];
53 if ( ! $values) $values = array();
54 if ($url_values) $values = array_merge($values,$url_values);
55 if ( $values ) foreach ($values as $key=>$value) {
56 printf('<input class="minitabs-hidden" type=hidden name="%s" value="%s" />',$key,$value);
58 $tracer="class=minitabs-submit";
59 // image and its companions 'height'
61 $type='type=image src="' . $todo['image'] . '"';
62 if ($todo['height']) $type.= ' height=' . $todo['height'];
64 $type='type=button value="' . $label . '"';
66 printf('<span title="%s">',$todo['bubble']);
68 if ($todo['confirm']) $message=$todo['confirm'] . " ?";
69 printf('<input %s %s onclick=\'miniTab.submit("%s");\' />',$tracer,$type,$message);
70 printf('</span>',$todo['bubble']);
71 printf("</form></li>\n");
75 print "<p class='plc-minittabs'></p>\n";