brute-force changed access to $_GET['key'] to use get_array instead
[plewww.git] / planetlab / tags / tags.php
1 <?php
2
3 // Require login
4 require_once 'plc_login.php';
5
6 // Get session and API handles
7 require_once 'plc_session.php';
8 global $plc, $api;
9
10 // Print header
11 require_once 'plc_drupal.php';
12 include 'plc_header.php';
13
14 // Common functions
15 require_once 'plc_functions.php';
16 require_once 'linetabs.php';
17 require_once 'table.php';
18 require_once 'form.php';
19
20 // -------------------- 
21 // recognized URL arguments
22 $pattern=get_array($_GET, 'pattern');
23
24 // --- decoration
25 $title="Tag Types";
26 $tabs=array();
27 $tabs []= tab_tags();
28 $tabs []= tab_nodes_local();
29 $tabs []= tab_slices();
30
31 // -------------------- 
32 drupal_set_title($title);
33 plekit_linetabs($tabs);
34
35 $tag_type_columns = array( "tag_type_id", "tagname", "category", "description", "roles");
36
37 $tag_type_filter=NULL;
38 if ($pattern) 
39   $tag_type_filter['category']=$pattern;
40
41 // get types
42 $tag_types= $api->GetTagTypes($tag_type_filter, $tag_type_columns);
43   
44 $headers=array();
45 $notes=array();
46 // delete button
47 $headers['Name']="string";
48 $headers['Description']="string";
49 $headers['Category']="string";
50 $headers['Roles']="string";
51
52 // xxx ref count would be helpful but seem too expensive to compute at this stage 
53 // the individual tag page show those ref counts per type
54
55 $headers["Id"]="int";
56 if (plc_is_admin()) $headers[plc_delete_icon()]="none";
57
58 $form=new PlekitForm(l_actions(),NULL);
59 $form->start();
60
61 $table = new PlekitTable("tags",$headers,0,array('notes'=>$notes));
62 $table->start();
63
64 $description_width=40;
65
66 foreach( $tag_types as $tag_type ) {
67
68   $table->row_start();
69   $tag_type_id=$tag_type['tag_type_id'];
70   $table->cell(href(l_tag($tag_type_id),$tag_type['tagname']));
71   $table->cell(wordwrap($tag_type['description'],$description_width,"<br/>"));
72   $table->cell($tag_type['category']);
73   $table->cell(plc_vertical_table ($tag_type['roles']));
74   $table->cell($tag_type_id);
75   if (plc_is_admin()) 
76     $table->cell ($form->checkbox_html('tag_type_ids[]',$tag_type_id));
77   $table->row_end();
78 }
79
80 if (plc_is_admin()) {
81   $table->tfoot_start();
82
83   $table->row_start();
84   $table->cell($form->submit_html ("delete-tag-types","Remove tags"),
85                array('hfill'=>true,'align'=>'right'));
86   $table->row_end();
87
88   // an inline area to add a tag type
89   $table->row_start();
90   
91   $table->cell($form->text_html('tagname',''));
92   $table->cell($form->textarea_html('description','',$description_width,2));
93   $table->cell($form->text_html('category',''));
94   $table->cell("<span class='note_roles'>add roles later</span>");
95   $table->cell($form->submit_html("add-tag-type","Add"),2);
96   $table->row_end();
97  }
98
99 $table->end();
100 $form->end();
101
102 //plekit_linetabs ($tabs,"bottom");
103
104 // Print footer
105 include 'plc_footer.php';
106
107 ?>