From da5652ed436911f81ac08120f3c0eb42fdfebc06 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 4 Feb 2009 12:34:30 +0000 Subject: [PATCH] class PlcTable replaces functions plc_table_* --- modules/planetlab.module | 2 +- planetlab/events/index.php | 35 ++-- planetlab/includes/plc_tables.php | 263 +++++++++++++++++------------- planetlab/nodes/node.php | 57 ++++--- planetlab/nodes/nodes.php | 27 +-- planetlab/peers/peers.php | 19 ++- planetlab/persons/person.php | 58 ++++--- planetlab/persons/persons.php | 25 +-- planetlab/sites/sites.php | 25 +-- planetlab/tags/nodegroup.php | 11 +- planetlab/tags/nodegroups.php | 12 +- planetlab/tags/tags.php | 23 +-- 12 files changed, 307 insertions(+), 250 deletions(-) diff --git a/modules/planetlab.module b/modules/planetlab.module index 45e2db4..ae5497b 100644 --- a/modules/planetlab.module +++ b/modules/planetlab.module @@ -270,7 +270,7 @@ function planetlab_login_submit($form_id, $form_values) { if ($url[0] != "/") { $url = "/$url"; } - Header("Location: $url"); + header("Location: $url"); exit(); } } diff --git a/planetlab/events/index.php b/planetlab/events/index.php index 88a4046..f5c66c0 100644 --- a/planetlab/events/index.php +++ b/planetlab/events/index.php @@ -357,11 +357,9 @@ if ( ! plc_is_admin()) { "D"=>"none", ); - $table_options=array('notes'=>array("The R column shows the call result value, a.k.a. fault_code", - "Click the button in the D(etails) column to get more details", - ), - 'max_pages'=>20); - plc_table_start("events",$headers,"0r",$table_options); + $table = new PlcTable ("events",$headers,"0r"); + $table->set_options (array ('max_pages'=>20)); + $table->start (); foreach ($events as $event) { // the call button @@ -378,19 +376,22 @@ if ( ! plc_is_admin()) { // $message=sprintf('%s',$message,$message); $message=truncate($event['message'],40); - plc_table_row_start(); - plc_table_cell(e_event($event['event_id'])); - plc_table_cell(date('M/d/Y H:i', $event['time'])); - plc_table_cell($event['call_name']); - plc_table_cell($message); - plc_table_cell(e_subjects($event)); - plc_table_cell(e_issuer($event)); - plc_table_cell(e_auth($event)); - plc_table_cell(e_fault($event)); - plc_table_cell($details); - plc_table_row_end(); + $table->row_start(); + $table->cell(e_event($event['event_id'])); + $table->cell(date('M/d/Y H:i', $event['time'])); + $table->cell($event['call_name']); + $table->cell($message); + $table->cell(e_subjects($event)); + $table->cell(e_issuer($event)); + $table->cell(e_auth($event)); + $table->cell(e_fault($event)); + $table->cell($details); + $table->row_end(); } - plc_table_end("events"); + $table->set_options(array('notes'=>array("The R column shows the call result value, a.k.a. fault_code", + "Click the button in the D(etails) column to get more details"))); + $table->end(); + } diff --git a/planetlab/includes/plc_tables.php b/planetlab/includes/plc_tables.php index 5f9be14..d565ee8 100644 --- a/planetlab/includes/plc_tables.php +++ b/planetlab/includes/plc_tables.php @@ -8,23 +8,11 @@ drupal_set_html_head(' '); - -//// hash to retrieve the headers and options as passed at table-creation time -// this means that table_id's need to be different across the page, -// which is required anyway for the search and pagesize areas to work properly -$plc_table_hash=array(); - -//////////////////////////////////////// -function plc_table_cell($cell) { - // printf (' %s ',$cell); - printf ('%s',$cell); -} - //////////////////////////////////////// // table_id: 's id tag - WARNING : do not use '-' in table ids as it's used for generating javascript code // headers: an associative array "label"=>"type" // column_sort: the column to sort on at load-time -// options : an associative array to override options (should be passed to both _stsart and _end) +// options : an associative array to override options // - search_area : boolean (default true) // - pagesize_area : boolean (default true) // - notes_area : boolean (default true) @@ -34,37 +22,80 @@ function plc_table_cell($cell) { // - pagesize_def: the page size when one clicks the pagesize reset button // - max_pages: the max number of pages to display in the paginator // - footers: an array of table rows ( will be added) for building the table's tfoot area -function plc_table_start ($table_id, $headers, $column_sort, $options=NULL) { - if ( ! $options ) $options = array(); - global $plc_table_hash; - $plc_table_hash[$table_id]=array($headers,$options); - $search_area = array_key_exists('search_area',$options) ? $options['search_area'] : true; - $pagesize_area = array_key_exists('pagesize_area',$options) ? $options['pagesize_area'] : true; - $max_pages = array_key_exists('max_pages',$options) ? $options['max_pages'] : 10; - $pagesize = array_key_exists('pagesize',$options) ? $options['pagesize'] : 25; - $pagesize_def = array_key_exists('pagesize_def',$options) ? $options['pagesize_def'] : 999; - $search_width = array_key_exists('search_width',$options) ? $options['search_width'] : 40; - - $paginator=$table_id."_paginator"; - $classname="paginationcallback-".$paginator; - $classname.=" max-pages-" . $max_pages; - $classname.=" paginate-" . $pagesize; + +class PlcTable { + // mandatory + var $table_id; + var $headers; + var $column_sort; + // options + var $search_area; // boolean (default true) + var $pagesize_area; // boolean (default true) + var $notes_area; // boolean (default true) + var $search_width; // size in chars of the search text dialog + var $pagesize; // the initial pagination size + var $pagesize_def; // the page size when one clicks the pagesize reset button + var $max_pages; // the max number of pages to display in the paginator + var $notes; // an array of additional notes + var $footers; // an array of table rows ( will be added) for building the table's tfoot area + + function PlcTable ($table_id,$headers,$column_sort,$options=NULL) { + $this->table_id = $table_id; + $this->headers = $headers; + $this->column_sort = $column_sort; + + $this->search_area = true; + $this->pagesize_area = true; + $this->notes_area = true; + $this->search_width = 40; + $this->pagesize = 25; + $this->pagesize_def = 999; + $this->max_pages = 10; + $this->notes = array(); + $this->footers = array(); + + $this->set_options ($options); + } + + function set_options ($options) { + if ( ! $options) + return; + if (array_key_exists('search_area',$options)) $this->search_area=$options['search_area']; + if (array_key_exists('pagesize_area',$options)) $this->pagesize_area=$options['pagesize_area']; + if (array_key_exists('notes_area',$options)) $this->notes_area=$options['notes_area']; + if (array_key_exists('search_width',$options)) $this->search_width=$options['search_width']; + if (array_key_exists('pagesize',$options)) $this->pagesize=$options['pagesize']; + if (array_key_exists('pagesize_def',$options)) $this->pagesize_def=$options['pagesize_def']; + if (array_key_exists('max_pages',$options)) $this->max_pages=$options['max_pages']; + + if (array_key_exists('notes',$options)) $this->notes=array_merge($this->notes,$options['notes']); + if (array_key_exists('footers',$options)) $this->footers=array_merge($this->footers,$options['footers']); + } + + //////////////////// + public function start () { + $paginator=$this->table_id."_paginator"; + $classname="paginationcallback-".$paginator; + $classname.=" max-pages-" . $max_pages; + $classname.=" paginate-" . $pagesize; // instantiate paginator callback - print <<< EOF + print <<< EOF
-
+
EOF; - if ($pagesize_area) plc_table_pagesize_area ($table_id,$headers,$pagesize, $pagesize_def); - if ($search_area) plc_table_search_area ($table_id, $headers, $search_width); + if ($this->pagesize_area) + print $this->pagesize_area_text (); + if ($this->search_area) + print $this->search_area_text (); print ""; - foreach ($headers as $label => $type) { + foreach ($this->headers as $label => $type) { if ($type == "none" ) { $class=""; } else { @@ -84,106 +115,118 @@ EOF; EOF; } -//////////////////// -function plc_table_pagesize_area ($table_id,$headers,$pagesize,$pagesize_def) { - $width=count($headers); - $pagesize_text_id = $table_id . "_pagesize"; - print <<< EOF + //////////////////// + // for convenience, the options that apply to the footer can be passed here + // typically footers or notes will add up to the ones provided so far + // makes code more readable, as preparing the footer before the table is displayed is confusing + function end ($options=NULL) { + $this->set_options($options); + print $this->foot_text(); + if ($this->notes_area) + print $this->notes_area_text(); + } + + //////////////////// + function pagesize_area_text () { + $width=count($this->headers); + $pagesize_text_id = $this->table_id . "_pagesize"; + $result= <<< EOF EOF; + return $result; } -//////////////////// -function plc_table_search_area ($table_id,$headers,$search_width) { - $width=count($headers); - $search_text_id = $table_id . "_search"; - $search_reset_id = $table_id . "_search_reset"; - $search_and_id = $table_id . "_search_and"; - print <<< EOF + //////////////////// + function search_area_text () { + $width=count($this->headers); + $search_text_id = $this->table_id . "_search"; + $search_reset_id = $this->table_id . "_search_reset"; + $search_and_id = $this->table_id . "_search_and"; + $result = <<< EOF EOF; -} + return $result; + } -//////////////////////////////////////// -// for convenience, the options that apply to the footer only can be passed in plc_table_end() -// they add up to the ones provided to the begin clause -// makes code more readable, as preparing the footer before the table is displayed is confusing -function plc_table_end ($table_id,$options_end=NULL) { - global $plc_table_hash; - list($headers,$options) = $plc_table_hash[$table_id]; - if ($options_end) - $options=array_merge($options,$options_end); - - plc_table_foot($options); - $notes_area = array_key_exists('notes_area',$options) ? $options['notes_area'] : true; - if ($notes_area) - plc_table_notes($options); -} - -//////////////////////////////////////// -function plc_table_foot ($options) { - print "\n"; - if ($options['footers']) - foreach ($options['footers'] as $footer) - print " $footer \n"; - print "
- pagesize + onkeyup='plc_pagesize_set("$this->table_id","$this->pagesize_text_id", $this->pagesize);' size=3 maxlength=3 /> + onmousedown='plc_pagesize_reset("$this->table_id","$pagesize_text_id",$this->pagesize_def);' />
\n"; -} + //////////////////////////////////////// + function foot_text () { + $result=""; + $result .= "\n"; + if ($this->footers) + foreach ($this->footers as $footer) + $result .="$footer\n"; + $result .= "\n"; + return $result; + } -//////////////////////////////////////// -function plc_table_notes ($options) { - $plc_table_default_notes = array( + //////////////////////////////////////// + function notes_area_text () { + $default_notes = array( "Enter & or | in the search area to alternate between AND and OR search modes", "Hold down the shift key to select multiple columns to sort"); - if (array_key_exists('notes',$options)) - $notes=$options['notes']; - else - $notes=array(); - $notes=array_merge($notes,$plc_table_default_notes); - print "

Notes\n"; - foreach ($notes as $note) - print "
$note\n"; - print "

"; -} + if ($this->notes) + $notes=$this->notes; + else + $notes=array(); + $notes=array_merge($notes,$default_notes); + if (! $notes) + return ""; + $result = ""; + $result .= "

Notes\n"; + foreach ($notes as $note) + $result .= "
$note\n"; + $result .= "

"; + return $result; + } -//////////////////////////////////////// -function plc_table_row_start ($id=NULL,$class=NULL) { - print "\n"; -} + //////////////////////////////////////// + function row_start ($id=NULL,$class=NULL) { + print "\n"; + } -function plc_table_row_end () { - print "\n"; -} + function row_end () { + print "\n"; + } + + //////////////////// + public function cell_text ($cell) { + return "$cell"; + } + public function cell ($cell) { + print $this->cell_text($cell); + } + + public static function td_text ($text,$colspan=0,$align=NULL) { + $result=""; + $result .= " - diff --git a/planetlab/nodes/node.php b/planetlab/nodes/node.php index a3cf5e8..22b156b 100644 --- a/planetlab/nodes/node.php +++ b/planetlab/nodes/node.php @@ -222,18 +222,19 @@ if ( $local_peer ) { "Nodegroup"=>"string"); $table_options=array("notes_area"=>false,"pagesize_area"=>false,"search_width"=>10); - plc_table_start("node_tags",$headers,0,$table_options); + $table=new PlcTable("node_tags",$headers,0,$table_options); + $table->start(); if ($tags) foreach ($tags as $tag) { // does this match a nodegroup ? $nodegroup_name="n/a"; $nodegroup_key=$tag['tagname'] . "=" . $tag['value']; $nodegroup=$nodegroups_hash[$nodegroup_key]; if ($nodegroup) $nodegroup_name=l_nodegroup_t($nodegroup['nodegroup_id'],$nodegroup['groupname']); - plc_table_row_start(); - plc_table_cell($tag['tagname']); - plc_table_cell($tag['value']); - plc_table_cell($nodegroup_name); - plc_table_row_end(); + $table->row_start(); + $table->cell($tag['tagname']); + $table->cell($tag['value']); + $table->cell($nodegroup_name); + $table->row_end(); } $footers=array(); @@ -249,11 +250,11 @@ if ( $local_peer ) { $add_tag_value=plc_form_text_text("value","",8); $add_tag_submit=plc_form_submit_text("set-tag-on-node","Set Tag"); - $add_tag_footer=plc_table_td_text($add_tag_name).plc_table_td_text($add_tag_value).plc_table_td_text($add_tag_submit); + $add_tag_footer=PlcTable::td_text($add_tag_name).PlcTable::td_text($add_tag_value).PlcTable::td_text($add_tag_submit); $footers[]= $add_tag_footer; } - plc_table_end("node_tags",array('footers'=>$footers)); + $table->end(array('footers'=>$footers)); } //////////////////////////////////////////////////////////// slices @@ -273,16 +274,17 @@ if ( ! $slices ) { $table_options['search_area']=false; $table_options['pagesize_area']=false; } - plc_table_start ("node_slices",$headers,1,$table_options); + $table=new PlcTable("node_slices",$headers,1,$table_options); + $table->start(); foreach ($slices as $slice) { - plc_table_row_start(); - plc_table_cell ($peers->shortname($peer_id)); - plc_table_cell (l_slice_t ($slice['slice_id'],$slice['name'])); - plc_table_cell (l_sliver_t ($node_id,$slice['slice_id'],'view')); - plc_table_row_end(); + $table->row_start(); + $table->cell ($peers->shortname($peer_id)); + $table->cell (l_slice_t ($slice['slice_id'],$slice['name'])); + $table->cell (l_sliver_t ($node_id,$slice['slice_id'],'view')); + $table->row_end(); } - plc_table_end("node_slices"); + $table->end(); } //////////////////////////////////////////////////////////// interfaces @@ -308,7 +310,8 @@ if ( $local_peer ) { $headers["bw limit"]="FileSize"; $table_options=array('search_area'=>false,"pagesize_area"=>false,'notes_area'=>false); - plc_table_start("node_interfaces",$headers,2,$table_options); + $table=new PlcTable("node_interfaces",$headers,2,$table_options); + $table->start(); foreach ( $interfaces as $interface ) { $interface_id= $interface['interface_id']; @@ -326,28 +329,28 @@ if ( $local_peer ) { $interface_type= $interface['type']; $interface_method= $interface['method']; - plc_table_row_start(); + $table->row_start(); if ( $privileges ) { if (!$interface_primary) { // xxx - plc_table_cell (plc_delete_link_button ('interfaces.php?id=' . $interface_id . '&delete=1&submitted=1', + $table->cell (plc_delete_link_button ('interfaces.php?id=' . $interface_id . '&delete=1&submitted=1', '\\nInterface ' . $interface_ip)); } else { - plc_table_cell('p'); + $table->cell('p'); } } - plc_table_cell(l_interface_t($interface_id,$interface_ip)); - plc_table_cell($interface_method); - plc_table_cell($interface_type); - plc_table_cell($interface_mac); - plc_table_cell($interface_bwlimit); - plc_table_row_end(); + $table->cell(l_interface_t($interface_id,$interface_ip)); + $table->cell($interface_method); + $table->cell($interface_type); + $table->cell($interface_mac); + $table->cell($interface_bwlimit); + $table->row_end(); } if ($privileges) { $button=plc_form_simple_button(l_interface_add($node_id),"Add interface","GET"); - $footers=array(plc_table_td_text($button,6,"right")); + $footers=array(PlcTable::td_text($button,6,"right")); } - plc_table_end("node_interfaces",array("footers"=>$footers)); + $table->end(array("footers"=>$footers)); } } diff --git a/planetlab/nodes/nodes.php b/planetlab/nodes/nodes.php index c60d16a..b1daeff 100644 --- a/planetlab/nodes/nodes.php +++ b/planetlab/nodes/nodes.php @@ -137,7 +137,8 @@ $headers = array ("Peer"=>"string", ); # initial sort on hostnames -plc_table_start("nodes",$headers,4); +$table=new PlcTable ("nodes",$headers,4); +$table->start(); $peers = new Peers ($api); // write rows @@ -154,21 +155,21 @@ foreach ($nodes as $node) { $shortname = $peers->shortname($peer_id); $node_type = $node['node_type']; - plc_table_row_start(); - plc_table_cell ($peers->link($peer_id,$shortname)); - plc_table_cell (topdomain($hostname)); - plc_table_cell (l_site_t($site_id,$login_base)); - plc_table_cell ($node['boot_state']); - plc_table_cell (l_node_t($node_id,$hostname)); - plc_table_cell (l_interface_t($interface_id,$ip)); - plc_table_cell ($node_type); - plc_table_cell ($node['arch']); - plc_table_cell (node_status($node)); - plc_table_row_end(); + $table->row_start(); + $table->cell ($peers->link($peer_id,$shortname)); + $table->cell (topdomain($hostname)); + $table->cell (l_site_t($site_id,$login_base)); + $table->cell ($node['boot_state']); + $table->cell (l_node_t($node_id,$hostname)); + $table->cell (l_interface_t($interface_id,$ip)); + $table->cell ($node_type); + $table->cell ($node['arch']); + $table->cell (node_status($node)); + $table->row_end(); } -plc_table_end("nodes"); +$table->end(); // Print footer include 'plc_footer.php'; diff --git a/planetlab/peers/peers.php b/planetlab/peers/peers.php index 11cd42f..b22673c 100644 --- a/planetlab/peers/peers.php +++ b/planetlab/peers/peers.php @@ -38,18 +38,19 @@ if ( empty($peers)) { 'Comon'=>'string'); $table_options=array('search_area'=>false, 'notes_area'=>false); - plc_table_start ("peers",$headers,1,$table_options); + $table = new PlcTable ("peers",$headers,1,$table_options); + $table->start(); foreach ($peers as $peer) { - plc_table_row_start(); - plc_table_cell (href(l_peer($peer['peer_id']),$peer['peername'])); - plc_table_cell ($peer['shortname']); + $table->row_start(); + $table->cell (href(l_peer($peer['peer_id']),$peer['peername'])); + $table->cell ($peer['shortname']); // xxx no HRN yet - plc_table_cell ('?'); - plc_table_cell ($peer['peer_url']); - plc_table_cell (href(l_comon("peer_id",$peer['peer_id']),'Comon')); - plc_table_row_end(); + $table->cell ('?'); + $table->cell ($peer['peer_url']); + $table->cell (href(l_comon("peer_id",$peer['peer_id']),'Comon')); + $table->row_end(); } - plc_table_end("peers"); + $table->end(); } // Print footer diff --git a/planetlab/persons/person.php b/planetlab/persons/person.php index 832a540..9e5db98 100644 --- a/planetlab/persons/person.php +++ b/planetlab/persons/person.php @@ -159,16 +159,17 @@ if( ! $slices) { $table_options['search_area']=false; $table_options['pagesize_area']=false; } - plc_table_start("person_slices",$headers,1,$table_options); + $table=new PlcTable ("person_slices",$headers,1,$table_options); + $table->start(); foreach( $slices as $slice ) { $slice_name= $slice['name']; $slice_id= $slice['slice_id']; - plc_table_row_start(); - plc_table_cell(l_slice_t($slice_id,$slice_name)); - plc_table_row_end(); + $table->row_start(); + $table->cell(l_slice_t($slice_id,$slice_name)); + $table->row_end(); } - plc_table_end("person_slices"); + $table->end(); } // we don't set 'action', but use the submit button name instead @@ -188,16 +189,17 @@ $headers=array("Type"=>"string", if ($can_manage_keys) $headers['Remove']="none"; // table overall options $table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false); -plc_table_start("person_keys",$headers,"1",$table_options); +$table=new PlcTable("person_keys",$headers,"1",$table_options); +$table->start(); if ($keys) foreach ($keys as $key) { $key_id=$key['key_id']; - plc_table_row_start(); - plc_table_cell ($key['key_type']); - plc_table_cell(wordwrap( $key['key'], 60, "
\n", 1 )); + $table->row_start(); + $table->cell ($key['key_type']); + $table->cell(wordwrap( $key['key'], 60, "
\n", 1 )); if ($can_manage_keys) - plc_table_cell (plc_form_checkbox_text('key_ids[]',$key_id)); - plc_table_row_end(); + $table->cell (plc_form_checkbox_text('key_ids[]',$key_id)); + $table->row_end(); } // the footer area is used for displaying key-management buttons $footers=array(); @@ -214,7 +216,7 @@ if ($can_manage_keys) { " $upload_key_right_area "; } -plc_table_end("person_keys",array("footers"=>$footers)); +$table->end(array("footers"=>$footers)); //////////////////// sites plc_section('Sites'); @@ -230,17 +232,18 @@ $headers['Name']="string"; if ($can_manage_sites) $headers['Remove']="string"; $table_options = array('notes_area'=>false,'search_area'=>false, 'pagesize_area'=>false); -plc_table_start ("person_sites",$headers,0,$table_options); +$table=new PlcTable ("person_sites",$headers,0,$table_options); +$table->start(); foreach( $sites as $site ) { $site_name= $site['name']; $site_id= $site['site_id']; $login_base=$site['login_base']; - plc_table_row_start(); - plc_table_cell ($login_base); - plc_table_cell (l_site_t($site_id,$site_name)); + $table->row_start(); + $table->cell ($login_base); + $table->cell (l_site_t($site_id,$site_name)); if ($can_manage_sites) - plc_table_cell (plc_form_checkbox_text('site_ids[]',$site_id)); - plc_table_row_end (); + $table->cell (plc_form_checkbox_text('site_ids[]',$site_id)); + $table->row_end (); } // footers : the remove and add buttons $footers=array(); @@ -262,11 +265,11 @@ if ($can_manage_sites) { $add_site_left_area=plc_form_select_text("site_id",$selector,"Choose a site to add"); $add_site_area = $add_site_left_area . $add_site_right_area; if ($sites) - $footers[]=plc_table_td_text ($remove_sites_area,3,"right"); + $footers[]=PlcTable::td_text ($remove_sites_area,3,"right"); // add a new site - $footers []= plc_table_td_text ($add_site_right_area,3,"right"); + $footers []= PlcTable::td_text ($add_site_area,3,"right"); } -plc_table_end("person_sites",array("footers"=>$footers)); +$table->end(array("footers"=>$footers)); //////////////////// roles plc_section("Roles"); @@ -279,7 +282,8 @@ $headers=array("Role"=>"none"); if ($can_manage_roles) $headers ["Remove"]="none"; $table_options=array('search_area'=>false,'pagesize_area'=>false,'notes_area'=>false); -plc_table_start("person_roles",$headers,0,$table_options); +$table=new PlcTable("person_roles",$headers,0,$table_options); +$table->start(); // construct array of role objs $role_objs=array(); @@ -288,10 +292,10 @@ for ($n=0; $nrow_start(); + $table->cell($role_obj['name']); + if ($can_manage_roles) $table->cell (plc_form_checkbox_text('role_ids[]',$role_obj['role_id'])); + $table->row_end(); } // footers : the remove and add buttons @@ -316,7 +320,7 @@ if ($can_manage_roles) { // add a new role $footers[]=" $add_role_area "; } -plc_table_end("person_roles",array("footers"=>$footers)); +$table->end(array("footers"=>$footers)); ////////////////////////////// plc_form_end(); diff --git a/planetlab/persons/persons.php b/planetlab/persons/persons.php index e4f5a39..6645afd 100644 --- a/planetlab/persons/persons.php +++ b/planetlab/persons/persons.php @@ -145,7 +145,8 @@ $headers = array ("Peer"=>"string", ); // initial sort on email -plc_table_start("persons",$headers,4); +$table=new PlcTable("persons",$headers,4); +$table->start(); $peers=new Peers ($api); // write rows @@ -159,21 +160,21 @@ foreach ($persons as $person) { $login_base = $site['login_base']; $roles = plc_vertical_table ($person['roles']); - plc_table_row_start(); + $table->row_start(); - plc_table_cell($shortname); - plc_table_cell($roles); - plc_table_cell ($person['first_name']); - plc_table_cell ($person['last_name']); - plc_table_cell(l_person_t($person_id,$email)); - plc_table_cell($login_base); - plc_table_cell(count($person['slice_ids'])); - plc_table_cell(person_status($person)); - plc_table_row_end(); + $table->cell($shortname); + $table->cell($roles); + $table->cell ($person['first_name']); + $table->cell ($person['last_name']); + $table->cell(l_person_t($person_id,$email)); + $table->cell($login_base); + $table->cell(count($person['slice_ids'])); + $table->cell(person_status($person)); + $table->row_end(); } $notes=array("The S column shows the number of slices for the given user"); -plc_table_end("persons",array('notes'=>$notes)); +$table->end(array('notes'=>$notes)); // Print footer include 'plc_footer.php'; diff --git a/planetlab/sites/sites.php b/planetlab/sites/sites.php index c705c57..9760fde 100644 --- a/planetlab/sites/sites.php +++ b/planetlab/sites/sites.php @@ -118,26 +118,27 @@ if (plc_is_admin()) { $headers['?']="string"; } -plc_table_start("sites",$headers,2); +$table=new PlcTable("sites",$headers,2); +$table->start(); if ($sites) foreach ($sites as $site) { $shortname = $peers->shortname($site['peer_id']); - plc_table_row_start(); - plc_table_cell($shortname); - plc_table_cell (l_site_t($site['site_id'],htmlentities($site['name']))); - plc_table_cell ($site['login_base']); - plc_table_cell (htmlentities($site['abbreviated_name'])); + $table->row_start(); + $table->cell($shortname); + $table->cell (l_site_t($site['site_id'],htmlentities($site['name']))); + $table->cell ($site['login_base']); + $table->cell (htmlentities($site['abbreviated_name'])); if (plc_is_admin()) { - plc_table_cell(count($site['node_ids'])); - plc_table_cell(count($site['person_ids'])); - plc_table_cell(count($site['slice_ids'])); - plc_table_cell(site_status($site)); + $table->cell(count($site['node_ids'])); + $table->cell(count($site['person_ids'])); + $table->cell(count($site['slice_ids'])); + $table->cell(site_status($site)); } - plc_table_row_end(); + $table->row_end(); } $notes=array("N = number of sites / U = number of users / S = number of slices"); -plc_table_end("sites",array('notes'=>$notes)); +$table->end(array('notes'=>$notes)); // Print footer include 'plc_footer.php'; diff --git a/planetlab/tags/nodegroup.php b/planetlab/tags/nodegroup.php index 7cb1aab..892cfc8 100644 --- a/planetlab/tags/nodegroup.php +++ b/planetlab/tags/nodegroup.php @@ -66,14 +66,15 @@ plc_section("Nodes"); $headers["Hostname"]="string"; -plc_table_start("nodegroup_nodes",$headers,0,array('search_width'=>15)); +$table = new PlcTable("nodegroup_nodes",$headers,0,array('search_width'=>15)); +$table->start(); if ($nodes) foreach ($nodes as $node) { - plc_table_row_start (); - plc_table_cell ( href (l_node ($node['node_id']),$node['hostname'])); - plc_table_row_end (); + $table->row_start (); + $table->cell ( href (l_node ($node['node_id']),$node['hostname'])); + $table->row_end (); } -plc_table_end ("nodegroup_nodes"); +$table->end (); // Print footer include 'plc_footer.php'; diff --git a/planetlab/tags/nodegroups.php b/planetlab/tags/nodegroups.php index 17778b1..2ae9093 100644 --- a/planetlab/tags/nodegroups.php +++ b/planetlab/tags/nodegroups.php @@ -65,12 +65,12 @@ $headers = array ( "Name"=>"string", plc_table_start("nodegroups",$headers,0); foreach ($nodegroups as $nodegroup) { - plc_table_row_start(); - plc_table_cell (href(l_nodegroup($nodegroup['nodegroup_id']),$nodegroup['groupname'])); - plc_table_cell ($nodegroup['tagname']); - plc_table_cell ($nodegroup['value']); - plc_table_cell (count($nodegroup['node_ids'])); - plc_table_row_end(); + $table->row_start(); + $table->cell (href(l_nodegroup($nodegroup['nodegroup_id']),$nodegroup['groupname'])); + $table->cell ($nodegroup['tagname']); + $table->cell ($nodegroup['value']); + $table->cell (count($nodegroup['node_ids'])); + $table->row_end(); } plc_table_end("nodegroups"); diff --git a/planetlab/tags/tags.php b/planetlab/tags/tags.php index 298accb..502f8b2 100644 --- a/planetlab/tags/tags.php +++ b/planetlab/tags/tags.php @@ -54,31 +54,32 @@ $headers['Description']="string"; $headers['Min role']="string"; $headers['Category']="string"; -plc_table_start("tags",$headers,1); +$table = new PlcTable("tags",$headers,1); +$table->start(); $roles_hash=plc_role_global_hash($api); foreach( $tag_types as $tag_type ) { $role_name=$roles_hash[$tag_type['min_role_id']]; - plc_table_row_start(); + $table->row_start(); $id=$tag_type['tag_type_id']; if (plc_is_admin()) // xxx this is deprecated - plc_table_cell(plc_delete_link_button ('tag_action.php?del_type='. $id, + $table->cell(plc_delete_link_button ('tag_action.php?del_type='. $id, $tag_type['tagname'])); - plc_table_cell($id); - plc_table_cell(href(l_tag_update($id),$tag_type['tagname'])); - plc_table_cell(wordwrap($tag_type['description'],40,"
")); - plc_table_cell($role_name); - plc_table_cell($tag_type['category']); - plc_table_row_end(); + $table->cell($id); + $table->cell(href(l_tag_update($id),$tag_type['tagname'])); + $table->cell(wordwrap($tag_type['description'],40,"
")); + $table->cell($role_name); + $table->cell($tag_type['category']); + $table->row_end(); } $footers=array(); if (plc_is_admin()) - $footers[]=plc_table_td_text(plc_form_simple_button(l_tag_add(),"Add a Tag Type","GET"),6,"right"); + $footers[]=PlcTable::td_text(plc_form_simple_button(l_tag_add(),"Add a Tag Type","GET"),6,"right"); -plc_table_end("tags",array('footers'=>$footers)); +$table->end(array('footers'=>$footers)); // Print footer include 'plc_footer.php'; -- 2.43.0