From cf57eaac83bd003bb611176a86460cb9d7d1d375 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 7 Oct 2005 13:08:14 +0000 Subject: [PATCH] iReworked buffer management, list sorted git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1536 594d385d-05f5-0310-b6e9-bd551577e9d8 --- plugins/admin/fai/class_faiPackage.inc | 21 +++++- plugins/admin/fai/class_faiPackageEntry.inc | 83 +++++++++------------ 2 files changed, 56 insertions(+), 48 deletions(-) diff --git a/plugins/admin/fai/class_faiPackage.inc b/plugins/admin/fai/class_faiPackage.inc index ac0c81a44..c48e29ec3 100644 --- a/plugins/admin/fai/class_faiPackage.inc +++ b/plugins/admin/fai/class_faiPackage.inc @@ -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); diff --git a/plugins/admin/fai/class_faiPackageEntry.inc b/plugins/admin/fai/class_faiPackageEntry.inc index 5c02f58c7..c5c53d20d 100644 --- a/plugins/admin/fai/class_faiPackageEntry.inc +++ b/plugins/admin/fai/class_faiPackageEntry.inc @@ -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 = ""; $i = 0; foreach($this->categories as $cat => $selected){ @@ -83,17 +88,12 @@ class faiPackageEntry extends plugin } $CHKS .= "
"; - $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 = " - "; - $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 = " + "; + $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]; -- 2.30.2