tabs can do POST, nodes.php uses it
[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
20
21 function plc_tabs($array) {
22   print '<div id="minitabs_container">';
23   print '<ul id="miniflex">';
24   print "\n";
25   foreach ($array as $label=>$todo) {
26     print '<li class="minitabs">';
27     // in case we have a string, rewrite it as an array
28     if (is_string ($todo)) $todo=array('method'=>'GET','url'=>$todo);
29     // set default method
30     if ( ! $todo['method'] ) $todo['method']='GET';
31     // create form
32     printf ('<form name="%s" action="%s" method="%s">',$label,$todo['url'],$todo['method']);
33     // set values
34     if ( $todo['values'] ) {
35       foreach ($todo['values'] as $key=>$value) {
36         printf('<input class="minitabs-hidden" type=hidden name="%s" value="%s" />',$key,$value);
37       }
38     }
39     $class_value="minitabs-submit";
40     printf('<input class="%s" value="%s" type=submit />',$class_value,$label);
41     printf("</form></li>\n");
42   }
43   print '</ul>';
44   print '</div>';
45   print "\n";
46   print "<br/>\n";
47 }
48
49 ?>