fix adminsearch
[plewww.git] / planetlab / common / adminsearch.php
index 37fbe56..354b179 100644 (file)
@@ -33,7 +33,11 @@ if ( ! plc_is_admin()) {
 $pattern="";
 if (isset($_GET['pattern'])) { $pattern=$_GET['pattern']; }
 if (isset($_POST['pattern'])) { $pattern=$_POST['pattern']; }
-$tokens=split(" ",$pattern);
+
+$tokens=explode(" ",$pattern);
+function token_filter ($t) { $t = trim($t); if (empty($t)) return false; return true; }
+$tokens=array_filter($tokens, "token_filter");
+
 
 ////////////////////
 // from a single search form, extract all tokens entered 
@@ -81,10 +85,15 @@ function generic_search ($type,$field,$tokens) {
   global $api;
   $results=array();
   $methodname='Get'.$type;
+  /*
+    This was broken after 598e1e840b55262fd40c6d1700148e4f0b508065 change in plcapi.
+    We no longer generate a list of methods but let the api (php) object pass them through.
+
   if ( ! method_exists($api,$methodname)) {
     plc_error("generic_search failed with methodname=$methodname");
     return $results;
   }
+  */
   foreach ($tokens as $token) {
     $filter=array($field=>token_pattern($token));
     $new_results = $api->$methodname($filter);