Code

iReworked buffer management, list sorted
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Oct 2005 13:08:14 +0000 (13:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 7 Oct 2005 13:08:14 +0000 (13:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1536 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/fai/class_faiPackage.inc
plugins/admin/fai/class_faiPackageEntry.inc

index ac0c81a4487abc46e4b30b6e3a04c71b67e40bdb..c48e29ec3435a1655615f021fd2a0e48c124427d 100644 (file)
@@ -42,9 +42,13 @@ class faiPackage extends plugin
   var $releases         = array();  // All possible releases 
   var $sections         = array();  // All section types
 
+  var $list             = array();
+
   var $mirrors          = array();  // The combination of server/release/section
   var $confDir          = "";
   var $usedPackages     = array();
+  
+  var $strID            ="";
 
   function faiPackage ($config, $dn= NULL)
   {
@@ -146,8 +150,17 @@ class faiPackage extends plugin
       $smarty->assign("SectionACL"," disabled ");
     } 
 
+    $this->strID = $this->confDir.$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$this->FAIdebianSection;
+    if(!$disableOptions){
+      if(!isset($this->list[$this->strID])){
+        $tmp = new faiPackageEntry($this->config, $this->dn,$this->strID,$this->usedPackages);
+        $this->list[$this->strID]=$tmp->genPkgs();
+      }
+    }
+
     if(isset($_POST['Addpkg'])){
-      $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->confDir.$this->FAIdebianMirror."/".$this->FAIdebianRelease."/".$this->FAIdebianSection,$this->usedPackages);
+      $this->dialog = new faiPackageEntry($this->config, $this->dn,$this->strID,$this->usedPackages);
+      $this->dialog->buffer[$this->strID]= $this->list[$this->strID];
       $this->is_dialog =true;
     }
  
@@ -307,7 +320,11 @@ class faiPackage extends plugin
     $a_ret=array(); 
     if(is_array($this->usedPackages)) {
       foreach($this->usedPackages as $usedName){
-        $a_ret[$usedName] = $usedName;
+        if(isset($this->list[$this->strID][$usedName][1])){
+          $a_ret[$usedName] = $usedName." [".$this->list[$this->strID][$usedName][1]."]";
+        }else{
+          $a_ret[$usedName] = $usedName;
+        }
       }
     }
     return($a_ret);
index 5c02f58c794ad13393b7321b4e242b6965ee0e41..c5c53d20d1f44dcf68ab943bccf8e19d5ea32acc 100644 (file)
@@ -52,21 +52,26 @@ class faiPackageEntry extends plugin
     }
 
     $pkgs = $this->genPkgs();
-    foreach($pkgs as $cat => $entries){
-      if(!isset($this->categories[$cat])){  
-        $this->categories[$cat] = true;
-      }
-      if(isset($_POST['chkchange'])){
-        $this->searchStrPKG = $_POST['searchStrPKG'];
-        if(isset($_POST['CAT'.$cat])){
-          $this->categories[$cat]=true;
-        }else{
-          $this->categories[$cat]=false;
+    unset($this->categories);
+    foreach($pkgs as $name => $entry){
+      $cat = $entry[2];
+      if(!empty($cat)){
+        if(!isset($this->categories[$cat])){  
+          $this->categories[$cat] = true;
+        }
+        if(isset($_POST['chkchange'])){
+          $this->searchStrPKG = $_POST['searchStrPKG'];
+          if(isset($_POST['CAT'.$cat])){
+            $this->categories[$cat]=true;
+          }else{
+            $this->categories[$cat]=false;
+          }
         }
       } 
-  
     }
 
+    ksort($this->categories);
+
     $CHKS = "<table><tr><input type='hidden' value='chkchange' name='chkchange'>";
     $i = 0; 
     foreach($this->categories as $cat => $selected){
@@ -83,17 +88,12 @@ class faiPackageEntry extends plugin
     }
     $CHKS .= "</td></tr></table>";
 
-    $packages = array();
-    foreach($this->categories as $cat => $use){
-      if($use){
-        $packages = array_merge($packages,$pkgs[$cat]);
-      }
-    }
 
     foreach($_POST as $name => $value){
       if(preg_match("/^wasonpage_/i",$name)){
         $name = preg_replace("/^wasonpage_/","",$name);
         $n =base64_decode($name);
+
         if(isset($_POST['use_'.$name])){
           $this->selected[$n] = $n; 
         }else{
@@ -105,21 +105,24 @@ class faiPackageEntry extends plugin
       }
     }
 
-    foreach($packages as $pkg){
+    foreach($pkgs as $pkg){
       if(preg_match("/^".str_replace("*",".*",$this->searchStrPKG)."/i",$pkg[0])){
-      if(in_array($pkg[0],$this->selected)){
-        $check = " checked ";
-      }else{
-        $check = "";
-      }
-      $chkbox = "<input type='checkbox' value='1' name='use_".base64_encode($pkg[0])."' ".$check." onclick='document.mainform.submit()'>
-                 <input type='hidden' value='1' name='wasonpage_".base64_encode($pkg[0])."'>";
-      $divlist->AddEntry(array(array("string"=>$chkbox),
-                               array("string"=>$pkg[0]),
+        if($this->categories[$pkg[2]]){
+          if(in_array($pkg[0],$this->selected)){
+            $check = " checked ";
+          }else{
+            $check = "";
+          }
+          $chkbox = "<input type='checkbox' value='1' name='use_".base64_encode($pkg[0])."' ".$check." onclick='document.mainform.submit()'>
+                   <input type='hidden' value='1' name='wasonpage_".base64_encode($pkg[0])."'>";
+          $divlist->AddEntry(array(array("string"=>$chkbox),
+                                 array("string"=>$pkg[0]),
                                array("string"=>$pkg[1]),
                                array("string"=>$pkg[3],"attach"=>"style='border-right:0px'")));
+        }
       }
     }
+
     $_SESSION['searchStrPKG']       = $this->searchStrPKG;
     $smarty->assign("CHKS"          , $CHKS);
     $smarty->assign("searchStrPKG"  , $this->searchStrPKG);
@@ -164,22 +167,7 @@ class faiPackageEntry extends plugin
 
   function save()
   {
-/*
-    $a_ret= array();
-    $pkgs = $this->genPkgs();
-    foreach($this->selected as $pkg){
-      foreach($pkgs as $cat => $obj){
-        foreach($obj as $package){
-          if($package[0] == $pkg){
-            $a_ret[$package[0]]=$package;
-          }
-        }
-      }
-    }
-    return($a_ret);
-*/
-
-  return($this->selected);
+    return($this->selected);
   }
 
     /* Generate listbox friendly SubObject list
@@ -192,6 +180,7 @@ class faiPackageEntry extends plugin
     /* Open the packelist */
     $fp = fopen($strID,"r");  
     $a_ret = array();
+    $this->buffer = array();
     /* Only read this file if it wasn't read before */
     if(!isset($this->buffer[$strID])){
       $str = "";
@@ -200,12 +189,14 @@ class faiPackageEntry extends plugin
         $str= fgets($fp,512);
         $stra= split("\|",$str);
         if(count($stra)==4){
-          $a_ret[$stra[2]][] = $stra;
-          } 
+          $a_ret[$stra[0]] = $stra;
+          }
         }
-        
         /* Save our Data, to avoid reading it again */
       $this->buffer[$strID]=$a_ret;
+
+      ksort($a_ret);
+
       return($a_ret);
     }else{
       return $this->buffer[$strID];