class PlcTable replaces functions plc_table_*
[plewww.git] / planetlab / tags / nodegroups.php
1 <?php
2
3 // $Id$
4
5 // Require login
6 require_once 'plc_login.php';
7
8 // Get session and API handles
9 require_once 'plc_session.php';
10 global $plc, $api;
11
12 // Print header
13 require_once 'plc_drupal.php';
14 include 'plc_header.php';
15
16 // Common functions
17 require_once 'plc_functions.php';
18 require_once 'plc_minitabs.php';
19 require_once 'plc_tables.php';
20
21 // -------------------- 
22 // recognized URL arguments
23 $pattern=$_GET['pattern'];
24
25 // --- decoration
26 $title="Nodegroups";
27 $tabs=array();
28 $tabs['Tags'] = array('url'=>l_tags(),
29                       'bubble'=>'Lists all known tag types');
30 // -------------------- 
31 $node_filter=array();
32
33
34 // fetch objs
35 $nodegroup_columns=array("nodegroup_id","groupname","tagname","value","node_ids");
36
37 // server-side filtering - set pattern in $_GET for filtering on hostname
38 if ($pattern) {
39   $nodegroup_filter['groupname']=$pattern;
40   $title .= " matching " . $pattern;
41  } else {
42   $nodegroup_filter['groupname']="*";
43  }
44
45 // go
46 $nodegroups=$api->GetNodeGroups($nodegroup_filter,$nodegroup_columns);
47
48 // --------------------
49 drupal_set_title($title);
50
51 plc_tabs($tabs);
52
53 if ( ! $nodegroups ) {
54   drupal_set_message ('No node group found');
55   return;
56  }
57   
58
59 $headers = array ( "Name"=>"string",
60                    "Tag"=>"string",
61                    "Value"=>"string",
62                    "Nodes"=>"int");
63
64 # initial sort on groupname
65 plc_table_start("nodegroups",$headers,0);
66
67 foreach ($nodegroups as $nodegroup) {
68   $table->row_start();
69   $table->cell (href(l_nodegroup($nodegroup['nodegroup_id']),$nodegroup['groupname']));
70   $table->cell ($nodegroup['tagname']);
71   $table->cell ($nodegroup['value']);
72   $table->cell (count($nodegroup['node_ids']));
73   $table->row_end();
74 }
75
76 plc_table_end("nodegroups");
77
78 // Print footer
79 include 'plc_footer.php';
80
81 ?>