From: Thierry Parmentelat Date: Tue, 19 May 2009 17:02:01 +0000 (+0000) Subject: sortable tables now have options X-Git-Tag: PLEWWW-4.3-14~4 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=e8fb477e36771b75dcbeeb79c8eefdfb4e28d084;p=plewww.git sortable tables now have options 'bullets1' : display decorative (now transparent) bullets in column 1 'stripes' : to do the odd/even stripes adminsearch page shows objects peer --- diff --git a/planetlab/common/adminsearch.php b/planetlab/common/adminsearch.php index c72fbbd..b47d6f3 100644 --- a/planetlab/common/adminsearch.php +++ b/planetlab/common/adminsearch.php @@ -18,6 +18,7 @@ include 'plc_header.php'; // Common functions require_once 'plc_functions.php'; require_once 'plc_objects.php'; +require_once 'plc_peers.php'; require_once 'table.php'; require_once 'form.php'; require_once 'toggle.php'; @@ -51,9 +52,12 @@ function display_form ($pattern) { $toggle->start(); print <<< EOF

-This form searches for any entry in the database matching a name fragment, or token.
-Specifically it searches for persons, slices, sites and nodes.
-You can specify a space-separated list of tokens, all entries matching any token would then get listed. +This form searches for any entry in the database +(among persons, slices, +sites and nodes) +matching a name fragment, or token.
+You can specify a space-separated list of tokens, all entries matching +any token would then get listed.

EOF; print "
"; @@ -123,6 +127,9 @@ function plc_node_link ($node_id) {global $nodes_hash; return l_node_obj($nodes_ global $table_options; $table_options = array('notes_area'=>false); +global $peers; +$peers = new Peers ($api); + function display_persons ($persons,$visible) { if ( ! $persons) return; @@ -130,16 +137,19 @@ function display_persons ($persons,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'email'=>'string', 'sites'=>'string', 'slices'=>'string', 'roles'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('persons',$headers,1,$table_options); $table->start(); foreach ($persons as $person) { $table->row_start(); $table->cell($person['person_id']); + $peers->cell($table,$person['peer_id']); $table->cell(l_person_obj($person)); $table->cell(plc_vertical_table(array_map("plc_site_link",$person['site_ids']))); $table->cell(plc_vertical_table(array_map("plc_slice_link",$person['slice_ids']))); @@ -157,16 +167,19 @@ function display_slices ($slices,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'name'=>'string', 'site'=>'string', 'persons'=>'string', 'N'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('slices',$headers,1,$table_options); $table->start(); foreach ($slices as $slice) { $table->row_start(); $table->cell($slice['slice_id']); + $peers->cell($table,$slice['peer_id']); $table->cell(l_slice_obj($slice)); global $sites_hash; $site=$sites_hash[$slice['site_id']]; @@ -188,17 +201,20 @@ function display_sites ($sites,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'name'=>'string', 'url'=>'string', 'persons'=>'string', 'slices'=>'string', 'nodes'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('sites',$headers,1,$table_options); $table->start(); foreach ($sites as $site) { $table->row_start(); $table->cell($site['site_id']); + $peers->cell($table,$site['peer_id']); $table->cell(l_site_obj($site)); $table->cell(href($site['url'],$site['url'])); $table->cell(plc_vertical_table(array_map("plc_person_link",$site['person_ids']))); @@ -217,15 +233,18 @@ function display_nodes ($nodes,$visible) { $toggle->start(); $headers=array('id'=>'int', + 'P'=>'string', 'hostname'=>'string', 'site'=>'string', 'slices'=>'string'); global $table_options; + global $peers; $table=new PlekitTable('nodes',$headers,1,$table_options); $table->start(); foreach ($nodes as $node) { $table->row_start(); $table->cell($node['node_id']); + $peers->cell($table,$node['peer_id']); $table->cell(l_node_obj($node)); global $sites_hash; $site=$sites_hash[$node['site_id']]; diff --git a/plekit/icons/tablesort-bullet1.gif b/plekit/icons/tablesort-bullet1.gif index ae352c2..d804b8a 100644 Binary files a/plekit/icons/tablesort-bullet1.gif and b/plekit/icons/tablesort-bullet1.gif differ diff --git a/plekit/php/table.php b/plekit/php/table.php index 3a629b1..c22b867 100644 --- a/plekit/php/table.php +++ b/plekit/php/table.php @@ -17,6 +17,9 @@ drupal_set_html_head(' // headers: an associative array "label"=>"type" // sort_column: the column to sort on at load-time // options : an associative array to override options +// - bullets1 : set to true if you want decorative bullets in column 1 (need white background) +// - stripes : use diferent colors for odd and even rows +// - caption : a caption for the table -- never used I'm afraid // - search_area : boolean (default true) // - pagesize_area : boolean (default true) // - notes_area : boolean (default true) @@ -32,6 +35,8 @@ class PlekitTable { var $headers; var $sort_column; // options + var $bullets1; // boolean - default false - display decorative bullets in column 1 + var $stripes; // boolean - default true - use different colors for odd and even rows var $caption; var $search_area; // boolean (default true) var $pagesize_area; // boolean (default true) @@ -47,6 +52,8 @@ class PlekitTable { $this->table_id = $table_id; $this->headers = $headers; $this->sort_column = $sort_column; + $this->bullets1 = true; + $this->stripes=true; $this->has_tfoot=false; @@ -65,6 +72,8 @@ class PlekitTable { function set_options ($options) { if ( ! $options) return; + if (array_key_exists('bullets1',$options)) $this->bullets1=$options['bullets1']; + if (array_key_exists('stripes',$options)) $this->stripes=$options['stripes']; if (array_key_exists('caption',$options)) $this->caption=$options['caption']; 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']; @@ -87,6 +96,8 @@ class PlekitTable { $classname="paginationcallback-".$paginator; $classname.=" max-pages-" . $this->max_pages; $classname.=" paginate-" . $this->pagesize; + if ($this->bullets1) { $classname .= " bullets1"; } + if ($this->stripes) { $classname .= " rowstyle-alt"; } // instantiate paginator callback print <<< EOF
+class="plekit_table sortable-onload-$this->sort_column colstyle-alt no-arrow $classname"> EOF; diff --git a/plekit/table/table.css b/plekit/table/table.css index 89a509e..26116cf 100644 --- a/plekit/table/table.css +++ b/plekit/table/table.css @@ -90,12 +90,12 @@ table.plekit_table>tbody>tr>td [class~="alt"] { background: #edf3f3 url(/plekit/icons/tablesort-col-alt.jpg) no-repeat !important; } /* Poor old Internet Explorer won't see the next two rules either as it doesn't get :first-child */ -table.plekit_table>tbody>tr.alt>td:first-child { +table.bullets1>tbody>tr.alt>td:first-child { background-color: #F5FAFA; background-image: url(/plekit/icons/tablesort-bullet2.gif); background-repeat: no-repeat; } -table.plekit_table>tbody>tr>td:first-child { +table.bullets1>tbody>tr>td:first-child { background-image: url(/plekit/icons/tablesort-bullet1.gif); background-repeat: no-repeat; }