tables layout
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 08:59:57 +0000 (08:59 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 30 Jan 2009 08:59:57 +0000 (08:59 +0000)
planetlab/css/plc_details.css [new file with mode: 0644]
planetlab/css/plc_style.css
planetlab/css/plc_tables.css
planetlab/includes/plc_details.php
planetlab/includes/plc_forms.php
planetlab/includes/plc_functions.php
planetlab/includes/plc_tables.php
planetlab/nodes/comon.php
planetlab/nodes/node.php
planetlab/persons/person.php
planetlab/tags/tag_form.php

diff --git a/planetlab/css/plc_details.css b/planetlab/css/plc_details.css
new file mode 100644 (file)
index 0000000..416cdfa
--- /dev/null
@@ -0,0 +1,7 @@
+/* $Id: plc_tables.css 11750 2009-01-29 10:11:53Z thierry $ */
+table.plc_details {
+    width:auto;
+    padding: 0;
+    margin: 0 auto 1.5em auto;
+    border-collapse:collapse;
+}
index 310c0dc..2d2a0e0 100644 (file)
@@ -283,19 +283,23 @@ html>body #clearmenu{ /* non IE browsers
  * $Id$
  */
 
-/* Thierry : class used for showing foreign items */
+h2.plc { 
+    text-align: center;
+}
+
+
 .plc-foreign {
   background:  #d0d0d0;
 }
 
-/* Thierry : class used for showing various warnings */
 .plc-warning {
   background:  orange;
 }
+.plc-error {
+    background: red;
+}
+
 *.plc-warning a:link { text-decoration: none; color:white }
 *.plc-warning a:visited { text-decoration: none; color:white }
 *.plc-warning a:hover { text-decoration: none; color:black }
 
-.plc-error {
-    background: red;
-}
index 1fce227..6d425b6 100644 (file)
@@ -8,6 +8,10 @@ table.plc_table {
 table.plc_table thead tr, table.plc_table tbody tr {
     border-left: 1px solid #C1DAD7; 
 }    
+/* remove border for search/pagesize area */
+table.plc_table thead tr.pagesize_area, table.plc_table thead tr.search_area {
+    border-left: 0px;
+}    
 
 th.plc_table {
     font: bold 10px/22px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
@@ -85,18 +89,23 @@ table.plc_table>tbody>tr>td:first-child {
     font-weight:bold;
 }
 
-td.table_flushleft {
+/*td.table_flushleft {
     text-align:left;
     padding-left: 30px;
 }
-td.table_flushright {
-    text-align:right;
-    padding-right: 30px;
-}
 table.table_dialogs {
     width:100%;
     border:1px;
 }
+*/
+td.search_area {
+    text-align:right;
+    padding-right: 30px;
+}
+td.pagesize_area {
+    text-align:right;
+    padding-right: 30px;
+}
 .pagesize_label, .pagesize_input {
     font-style: oblique;
     font-size: .5em;
index d28d1c7..10af0af 100644 (file)
@@ -4,11 +4,15 @@
 
 require_once 'plc_functions.php';
 
+drupal_set_html_head('
+<link href="/planetlab/css/plc_details.css" rel="stylesheet" type="text/css" />
+');
+
 // rough implem, no class for now
 
 // start the details area, with an optional caption
 function plc_details_start ($title="") {
-  print "<table><thead>";
+  print "<table class=plc_details><thead>";
   if ($caption) {
     printf ("<caption>%s</caption>\n",$caption);
   }
index 92de1e1..19052e9 100644 (file)
@@ -18,7 +18,7 @@ function plc_form_start ($full_url, $values, $options=array()) {
   if ( $url_values ) $values=array_merge($values,$url_values);
   $method = array_key_exists('method',$options) ? $options['method'] : 'POST';
   print "<form method=$method action='$url' enctype='multipart/form-data'>";
-  plc_debug('values',$values);
+  //  plc_debug('values',$values);
   if ($values) foreach ($values as $key=>$value) {
     print plc_form_hidden_text($key,$value);
   }
index ddfd68e..c703b14 100644 (file)
@@ -343,6 +343,11 @@ function plc_vertical_table ($messages, $class="") {
 function get_site_id ($site) { return $site['site_id'];}
 
 ////////////////////////////////////////////////////////////
+function plc_section ($text,$line=true) {
+  if ($line) { print "<hr/>";}
+  print "<h2 class=plc> $text </h2>\n";
+}
+
 function plc_error ($text) {
   // should use the same channel as the php errors..
   print "<div class='plc-error'> Error " . $text . "</div>";
index ee3a5d2..ef31cd5 100644 (file)
@@ -25,6 +25,7 @@ function plc_table_cell($cell) {
 // 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)
 //  - search_area : boolean (default true)
+//  - pagesize_area : boolean (default true)
 //  - notes_area : boolean (default true)
 //  - notes : an array of additional notes
 //  - pagesize: the initial pagination size
@@ -36,69 +37,11 @@ function plc_table_start ($table_id, $headers, $column_sort, $options=NULL) {
   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;
 
-  if ($search_area) 
-    plc_table_search_area($table_id,$pagesize,$pagesize_def);
-  plc_table_head($table_id,$headers,$column_sort,$max_pages,$pagesize);
-}
-
-// 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_search_area ($table_id,$pagesize,$pagesize_def) {
-  $pagesize_text_id = $table_id . "_pagesize";
-  $search_text_id = $table_id . "_search";
-  $search_reset_id = $table_id . "_search_reset";
-  $search_and_id = $table_id . "_search_and";
-  print <<< EOF
-<table class='table_dialogs'> <tr>
-<td class='table_flushleft'>
-<form class='pagesize'>
-   <input class='pagesize_input' type='text' id="$pagesize_text_id" value=$pagesize 
-      onkeyup='plc_pagesize_set("$table_id","$pagesize_text_id", $pagesize);' 
-      size=3 maxlength=3 /> 
-  <label class='pagesize_label'> items/page </label>   
-  <img class='table_reset' src="/planetlab/icons/clear.png" 
-      onmousedown='plc_pagesize_reset("$table_id","$pagesize_text_id",$pagesize_def);'>
-</form>
-</td>
-
-<td class='table_flushright'> 
-<form class='table_search'>
-   <label class='table_search_label'> Search </label> 
-   <input class='table_search_input' type='text' id='$search_text_id'
-      onkeyup='plc_table_filter("$table_id","$search_text_id","$search_and_id");'
-      size=40 maxlength=256 />
-   <label>and</label>
-   <input id='$search_and_id' class='table_search_and' 
-      type='checkbox' checked='checked' 
-      onchange='plc_table_filter("$table_id","$search_text_id","$search_and_id");' />
-   <img class='table_reset' src="/planetlab/icons/clear.png" 
-      onmousedown='plc_table_filter_reset("$table_id","$search_text_id","$search_and_id");'>
-</form>
-</td>
-</tr></table>
-EOF;
-}
-
-////////////////////////////////////////
-function plc_table_head ($table_id,$headers,$column_sort,$max_pages,$pagesize) {
   $paginator=$table_id."_paginator";
   $classname="paginationcallback-".$paginator;
   $classname.=" max-pages-" . $max_pages;
@@ -112,9 +55,12 @@ function $paginator (opts) { plc_table_paginator (opts,"$table_id"); }
 <table id="$table_id" cellpadding="0" cellspacing="0" border="0" 
 class="plc_table sortable-onload-$column_sort rowstyle-alt colstyle-alt no-arrow $classname">
 <thead>
-<tr>
 EOF;
 
+  if ($pagesize_area) plc_table_pagesize_area ($table_id,$headers,$pagesize, $pagesize_def);
+  if ($search_area) plc_table_search_area ($table_id, $headers);
+
+  print "<tr>";
   foreach ($headers as $label => $type) {
     if ($type == "none" ) {
       $class="";
@@ -135,6 +81,60 @@ EOF;
 EOF;
 }
 
+////////////////////
+function plc_table_pagesize_area ($table_id,$headers,$pagesize,$pagesize_def) {
+  $width=count($headers);
+  $pagesize_text_id = $table_id . "_pagesize";
+  print <<< EOF
+<tr class=pagesize_area><td class=pagesize_area colspan=$width><form class='pagesize'>
+   <input class='pagesize_input' type='text' id="$pagesize_text_id" value=$pagesize 
+      onkeyup='plc_pagesize_set("$table_id","$pagesize_text_id", $pagesize);' 
+      size=3 maxlength=3 /> 
+  <label class='pagesize_label'> items/page </label>   
+  <img class='table_reset' src="/planetlab/icons/clear.png" 
+      onmousedown='plc_pagesize_reset("$table_id","$pagesize_text_id",$pagesize_def);' />
+</form></td></tr>
+EOF;
+}
+
+////////////////////
+function plc_table_search_area ($table_id,$headers) {
+  $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
+<tr class=search_area><td class=search_area colspan=$width><form class='table_search'>
+   <label class='table_search_label'> Search </label> 
+   <input class='table_search_input' type='text' id='$search_text_id'
+      onkeyup='plc_table_filter("$table_id","$search_text_id","$search_and_id");'
+      size=40 maxlength=256 />
+   <label>and</label>
+   <input id='$search_and_id' class='table_search_and' 
+      type='checkbox' checked='checked' 
+      onchange='plc_table_filter("$table_id","$search_text_id","$search_and_id");' />
+   <img class='table_reset' src="/planetlab/icons/clear.png" 
+      onmousedown='plc_table_filter_reset("$table_id","$search_text_id","$search_and_id");'>
+</form></td></tr>
+EOF;
+}
+
+////////////////////////////////////////
+// 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 "</tbody><tfoot>";
@@ -161,10 +161,6 @@ EOF;
 }
 
 ////////////////////////////////////////
-function plc_table_title ($text) {
-  print "<h2> $text </h2>\n";
-}
-
 function plc_table_row_start ($id="") {
   if ( $id) {
     printf ('<tr id="%s">',$id);
index 18b2623..3524eb9 100644 (file)
@@ -93,7 +93,7 @@ foreach ($nns as $nn) {
   $local_ips[] = $nn['ip'];
 }
 
-plc_debug('locals',$local_ips);
+//plc_debug('locals',$local_ips);
 
 // for foreign hosts we're left with dns resolving them
 $remote_ips=array();
@@ -106,7 +106,7 @@ foreach ($hostnames as $hostname) {
   }
 }
 
-plc_debug('remote ips',$remote_ips);
+//plc_debug('remote ips',$remote_ips);
 
 
 // add both lists
@@ -114,7 +114,7 @@ $all_ips=$local_ips+$remote_ips;
 // compute comon URL
 $url = plc_comon_url_from_ips("http://comon.cs.princeton.edu",$all_ips);
 
-plc_debug('url',$url);
+//plc_debug('url',$url);
 
 // redirect to comon
 header("Location: " . $url);
index ef87039..7ecc909 100644 (file)
@@ -130,8 +130,6 @@ $tabs["All nodes"]=l_nodes();
 
 plc_tabs($tabs);
 
-echo "<hr />";
-  
 plc_details_start ();
 plc_details_line("Hostname",$hostname);
 plc_details_line("Type",$node_type);
@@ -200,8 +198,7 @@ plc_details_end ();
 //////////////////////////////////////////////////////////// slices
 // display slices
 
-print "<hr/>\n";
-plc_table_title ("Slices");
+plc_section ("Slices");
 if ( ! $slices  ) {
   echo "<p><span class='plc-warning'>This node is not associated to any slice.</span></p>\n";
  } else {
@@ -241,8 +238,7 @@ if ( ! $peer_id ) {
     $headers["MAC"]="string";
     $headers["bw limit"]="FileSize";
 
-    print "<hr/>\n";
-    plc_table_title('Interfaces');
+    plc_section('Interfaces');
     $table_options=array('search_area'=>false);
     plc_table_start("interfaces",$headers,2,$table_options);
        
@@ -290,8 +286,7 @@ if ( ! $peer_id ) {
 
 //////////////////////////////////////////////////////////// nodegroups
 // display node group info
-print "<hr/>\n";
-plc_table_title("Nodegroups");
+plc_section("Nodegroups");
 if ( ! $nodegroups ) {
   echo "<p><span class='plc-warning'>This node is not in any nodegroup.</span></p>\n";
  } 
index 31a18d6..41b39c6 100644 (file)
@@ -144,8 +144,7 @@ plc_details_line("Bio",wordwrap($bio,50,"<br/>"));
 plc_details_end();
 
 //////////////////// slices
-echo "<hr />\n";
-plc_table_title('Slices');
+plc_section('Slices');
 
 if( ! $slices) {
   plc_warning ("User has no slice");
@@ -173,8 +172,7 @@ plc_form_start(l_actions(),
                     ));
 
 //////////////////// keys
-echo "<hr />\n";
-plc_table_title ("Keys");
+plc_section ("Keys");
                
 $can_manage_keys = ( $local_peer && ( plc_is_admin() || $is_my_account) );
 if ( empty( $key_ids ) ) {
@@ -216,8 +214,7 @@ if ($can_manage_keys) {
 plc_table_end("person_keys",array("footers"=>$footers));
 
 //////////////////// sites
-echo "<hr />\n";
-plc_table_title('Sites');
+plc_section('Sites');
   
 // sites
 if (empty( $sites ) ) {
@@ -268,8 +265,7 @@ if ($can_manage_sites) {
 plc_table_end("person_sites",array("footers"=>$footers));
 
 //////////////////// roles
-echo "<hr />\n";
-plc_table_title("Roles");
+plc_section("Roles");
 if (! $roles) plc_warning ("This user has no role !");
 
 $can_manage_roles= ($local_peer && plc_is_admin());
index 2851e82..12f1b08 100644 (file)
@@ -50,7 +50,7 @@ if ($update_mode) {
  }  
 
 // display form for tag types
-plc_table_title($label);
+plc_section($label,false);
 
 plc_form_start (l_actions(),array());
 plc_details_start();