checkpoint
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 16 Jan 2009 09:38:48 +0000 (09:38 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 16 Jan 2009 09:38:48 +0000 (09:38 +0000)
planetlab/includes/plc_functions.php
planetlab/includes/plc_minitabs.php
planetlab/includes/plc_sorts.php
planetlab/includes/plc_tables.php
planetlab/nodes/newindex.php

index 60a8dc7..671dca2 100644 (file)
@@ -422,5 +422,10 @@ function plc_peer_info ($api,$peerscope) {
   return array ($peer_filter,$peer_label);
 }
     
+function topdomain ($hostname) {
+  $exploded=array_reverse(explode(".",$hostname));
+  return $exploded[0];
+}
+
 
 ?>
index 7e6620d..c1dc3cf 100644 (file)
@@ -1,6 +1,12 @@
 <?php
   // $Id$
 
+drupal_set_html_head('
+<script type="text/javascript" src="/planetlab/minitabs/minitabs.js"></script>
+<link href="/planetlab/minitabs/minitabs.css" rel="stylesheet" type="text/css" />
+');
+
+
 function plc_show_options($array) {
   print '<div id="minitabs_container">';
   print '<ul id="miniflex">';
index 4b5b1d4..37fdeb5 100644 (file)
@@ -13,11 +13,6 @@ function sort_persons(&$persons) {
   return usort($persons, "__cmp_persons");
 }
 
-function topdomain ($hostname) {
-  $exploded=array_reverse(explode(".",$hostname));
-  return $exploded[0];
-}
-
 function __cmp_nodes($a, $b) {
  $as = array_reverse(explode(".", $a['hostname']));
  $bs = array_reverse(explode(".", $b['hostname']));
index a5f92f3..2134769 100644 (file)
@@ -1,10 +1,36 @@
 <?php
 
+drupal_set_html_head('
+<script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
+<script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
+<script type="text/javascript" src="/planetlab/tablesort/paginate.js"></script>
+<script type="text/javascript" src="/planetlab/js/plc_tables.js"></script>
+<link href="/planetlab/css/plc_tables.css" rel="stylesheet" type="text/css" />
+');
+
+
 ////////////////////////////////////////
 // table_id: <table>'s id tag
-// pagesize_init: the initial pagination size
-// pagesize_def: the page size when one clisks the pagesize reset button
-function plc_table_search_area ($table_id,$pagesize_init,$pagesize_def) {
+// headers: an associative array "label"=>"type" 
+// column_sort: the column to sort on at load-time
+// search_area : boolean
+// pagesize: the initial pagination size
+// pagesize_def: the page size when one clicks the pagesize reset button
+// max_pages: the max number of pages to display in the paginator
+function plc_table_start ($table_id, $headers, $column_sort,
+                         $search_area=true,$max_pages="10",$pagesize="25",$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);
+}
+
+function plc_table_end () {
+  plc_table_foot();
+}
+                   
+////////////////////
+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";
@@ -13,8 +39,8 @@ function plc_table_search_area ($table_id,$pagesize_init,$pagesize_def) {
 <table class='table_dialogs'> <tr>
 <td class='table_flushleft'>
 <form class='pagesize'>
-   <input class='pagesize_input' type='text' id="$pagesize_text_id" value=$pagesize_init 
-      onkeyup='plc_pagesize_set("$table_id","$pagesize_text_id", $pagesize_init);' 
+   <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" 
@@ -41,12 +67,7 @@ EOF;
 }
 
 ////////////////////////////////////////
-// table_id: <table>'s id tag
-// headers: an associative array "label"=>"type" 
-// pagesize: the initial page
-// column_init_sort: the column to sort on at load-time
-// max_pages: the max number of pages to display in the paginator
-function plc_table_head ($table_id,$headers,$pagesize,$column_init_sort,$max_pages) {
+function plc_table_head ($table_id,$headers,$column_sort,$max_pages,$pagesize) {
   $paginator=$table_id."_paginator";
   $classname="paginationcallback-".$paginator;
   $classname.=" max-pages-" . $max_pages;
@@ -58,7 +79,7 @@ function $paginator (opts) { plc_table_paginator (opts,"$table_id"); }
 </script>
 <br/>
 <table id="$table_id" cellpadding="0" cellspacing="0" border="0" 
-class="plc_table sortable-onload-$column_init_sort rowstyle-alt colstyle-alt no-arrow $classname">
+class="plc_table sortable-onload-$column_sort rowstyle-alt colstyle-alt no-arrow $classname">
 <thead>
 <tr>
 EOF;
index 8660e05..a00bdac 100644 (file)
@@ -15,37 +15,19 @@ include 'plc_header.php';
 
 // Common functions
 require_once 'plc_functions.php';
-require_once 'plc_sorts.php';
+require_once 'plc_minitabs.php';
 require_once 'plc_tables.php';
 
 // find person roles
 $_person= $plc->person;
 $_roles= $_person['role_ids'];
 
-$header_js='
-<script type="text/javascript" src="/planetlab/tablesort/tablesort.js"></script>
-<script type="text/javascript" src="/planetlab/tablesort/customsort.js"></script>
-<script type="text/javascript" src="/planetlab/tablesort/paginate.js"></script>
-<script type="text/javascript" src="/planetlab/minitabs/minitabs.js"></script>
-<script type="text/javascript" src="/planetlab/js/plc_tables.js"></script>
-';
-
-$header_css='
-<link href="/planetlab/minitabs/minitabs.css" rel="stylesheet" type="text/css" />
-<link href="/planetlab/css/plc_style.css" rel="stylesheet" type="text/css" />
-<link href="/planetlab/css/plc_tables.css" rel="stylesheet" type="text/css" />
-';
-
-drupal_set_html_head($header_js);
-drupal_set_html_head($header_css);
-
 // -------------------- 
 $pattern=$_GET['pattern'];
 $peerscope=$_GET['peerscope'];
 
 drupal_set_title('Nodes');
 
-require_once 'plc_minitabs.php';
 $minitabs=array("Old page"=>"/db/nodes/index.php",
               "About"=>"/db/about.php",
               "Logout"=>"/planetlab/logout.php",
@@ -109,8 +91,8 @@ foreach ($peers as $peer) {
     $peer_hash[$peer['peer_id']]=$peer;
 }
 
-$pagesize=25;
-plc_table_search_area("nodes",$pagesize,999);
+
+
 $columns = array ("Peer"=>"string",
                  "Region"=>"string",
                  "Site"=>"string",
@@ -120,7 +102,8 @@ $columns = array ("Peer"=>"string",
                  "Load"=>"int",
                  "Avg Load"=>"float");
 
-plc_table_head("nodes",$columns,$pagesize,"4",15);
+# initial sort on hostnames
+plc_table_start("nodes",$columns,4);
 
 // write rows
 $fake1=1; $fake2=3.14; $fake_i=0;
@@ -154,7 +137,7 @@ foreach ($nodes as $node) {
     $fake_i += 1;
 }
 
-plc_table_foot();
+plc_table_end();
 
 plc_table_notes();
 ?>