minitabs reimplemented with forms, now support POSTing
[plewww.git] / planetlab / includes / plc_minitabs.php
1 <?php
2   // $Id$
3
4 drupal_set_html_head('
5 <script type="text/javascript" src="/planetlab/minitabs/minitabs.js"></script>
6 <link href="/planetlab/minitabs/minitabs.css" rel="stylesheet" type="text/css" />
7 ');
8
9
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
13 // todo can be either
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 //     (*) 'active': if set, this entry is the default one on startup
20 //                   (not supported yet)
21
22
23 function plc_tabs($array) {
24   print '<div id="minitabs_container">';
25   print '<ul id="miniflex">';
26   print "\n";
27   foreach ($array as $label=>$todo) {
28     print '<li class="minitabs">';
29     // in case we have a string, rewrite it as an array
30     if (is_string ($todo)) $todo=array('method'=>'GET','url'=>$todo);
31     // set default method
32     if ( ! $todo['method'] ) $todo['method']='GET';
33     // create form
34     printf ('<form name="%s" action="%s" method="%s">',$label,$todo['url'],$todo['method']);
35     // set values
36     if ( $todo['values'] ) {
37       foreach ($todo['values'] as $key=>$value) {
38         printf('<input class="minitabs" type=hidden name="%s" value="%s" />',$key,$value);
39       }
40     }
41     $class_value="minitabs";
42     if ($todo['active']) $class_value += ' active';
43     // onmouseover="over()" onmouseout="out()"
44     printf('<input class="%s" value="%s" type=submit />',$class_value,$label);
45     printf("</form></li>\n");
46   }
47   print '</ul>';
48   print '</div>';
49   print "\n";
50   print "<br/>\n";
51 }
52
53 ?>