lambdas and create_function
[plewww.git] / planetlab / events / events.php
index 07edd3a..5156d2b 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-// $Id: index.php 11949 2009-02-09 17:57:16Z thierry $
+// $Id$
 
 // Require login
 require_once 'plc_login.php';
@@ -14,9 +14,9 @@ include 'plc_header.php';
 
 // Common functions
 require_once 'plc_functions.php';
-require_once 'plc_tables.php';
-require_once 'plc_minitabs.php';
-require_once 'plc_datepicker.php';
+require_once 'table.php';
+require_once 'linetabs.php';
+require_once 'datepicker.php';
   
 // needs much memory
 ini_set("memory_limit","256M");
@@ -53,7 +53,7 @@ function parse_date ($user_date,$until_if_true=false,$DAY,$EPOCH) {
   
   } else {
     // user-provided string
-    list ($year,$month,$day) = split ('[/.-]',$user_date);
+    list ($year,$month,$day) = preg_split ('/[\/\.\-]/',$user_date);
     $date=sprintf("%s %s %s",$day,$month,$year);
     $time=strtotime($date);
     //if the flag is set, we add 23h59'59'', so the 'until' date is inclusive
@@ -88,7 +88,8 @@ function e_subject ($type,$id) {
   case 'Site': return l_site_t ($id,$mess);
   case 'Person': return l_person_t ($id,$mess);
   case 'Slice': return l_slice_t ($id,$mess);
-  case 'Role': case 'Key': case 'PCU': case 'Interface': case 'NodeGroup': case "Address":
+  case 'Interface': return l_interface_t ($id, $mess);
+  case 'Role': case 'Key': case 'PCU': case 'NodeGroup': case "Address":
     return "$mess";
   default: return "Unknown $type" . "-" . $id;
   }
@@ -126,7 +127,7 @@ function e_fault ($event) {
 
 $tabs=array();
 $tabs['Clear events']=l_events();
-plc_tabs($tabs);
+plekit_linetabs($tabs);
 
 list($from_string,$from_time) = parse_date ($from_date,false,$DAY,$EPOCH);
 list($until_string,$until_time) = parse_date ($until_date,true,$DAY,$EPOCH);
@@ -197,7 +198,7 @@ if ($type == 'Event') {
   $title="Events [ $from_string - $until_string]";
   $title .= " type=$object_type";
   $title .= " id(s)=";
-  foreach ( split(",",$user_input) as $user_desc) {
+  foreach ( explode(",",$user_input) as $user_desc) {
 # numeric 
     if (my_is_int($user_desc)) {
       $obj_check = call_user_func(array($api,$method),array(intval($user_desc)),array($primary_key));
@@ -223,8 +224,8 @@ if ($type == 'Event') {
 
   $event_objs = $api->GetEventObjects(array('object_id'=>$object_ids,'object_type'=>$object_type),array('event_id'));
   // get set of event_ids
-  $event_ids = array_map ( create_function ('$eo','return $eo["event_id"];') , $event_objs);
-    
+  $event_ids = array_map (function ($eo) {return $eo["event_id"];} , $event_objs);
+
   $events = $api->GetEvents (array('event_id'=>$event_ids));
 
   // see actual display of $title and $events below
@@ -248,7 +249,7 @@ $headers=array("Id"=>"int",
               "D"=>"none",
               );
 
-$table = new PlcTable ("events",$headers,"0r");
+$table = new PlekitTable ("events",$headers,"0r");
 $table->set_options (array ('max_pages'=>20));
 $table->start ();
 foreach ($events as $event) {
@@ -263,7 +264,7 @@ foreach ($events as $event) {
   // the message button
   $trunc_mess=htmlentities(truncate($event['message'],40),ENT_QUOTES);
   $message="<input type=button name='message' value='" . $trunc_mess ."' onclick='alert(\"" . $text . "\")'";
-  $details="<input type=button name='message' value='X' onclick='alert(\"" . $text . "\")'";
+  $details="<input type=button name='message' value='+' onclick='alert(\"" . $text . "\")'";
   //    $message=sprintf('<span title="%s">%s</span>',$message,$message);
   
   $message=truncate($event['message'],40);
@@ -283,7 +284,7 @@ $table->set_options(array('notes'=>array("The R column shows the call result val
                                         "Click the button in the D(etails) column to get more details")));
 $table->end();
   
-plc_tabs ($tabs,"bottom");
+//plekit_linetabs ($tabs,"bottom");
 
 // Print footer
 include 'plc_footer.php';