Code

Added DivSelect to
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 Nov 2005 06:54:04 +0000 (06:54 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 15 Nov 2005 06:54:04 +0000 (06:54 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1946 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/admin/systems/class_printerPPDDialog.inc
plugins/admin/systems/class_printerPPDSelectionDialog.inc
plugins/admin/systems/printerPPDSelectionDialog.tpl

index ab1b175258e6315454fa753bd165a1708bb059ee..516f95ad0ca8a086ab093dca5d996d459426a1bb 100644 (file)
@@ -195,6 +195,22 @@ class printerPPDDialog extends plugin
         }
       }
 
+      /* Div Selection */ 
+      if((isset($_GET['act']))&&($_GET['act']=="use")){
+        $hit = false;
+        foreach($this->ppdList as $vendor => $ppds ){
+          foreach($ppds as $name => $ppd){
+            if($ppd['link']==$_GET['id']){
+              $hit = true;
+            }
+          }
+        } 
+        $this->selectedPPD['link'] = $_GET['id'];
+        $this->ppdConfig   = false;
+        unset($this->dialog);
+        $this->dialog=NULL;
+      }
+
       /* if a dialog is open, print the dialog instead of this class
        */
       if($this->dialog!=NULL){
index a03209ca45c29aebb0e50ace06da3c78d82ce39b..76987219d0dc681fb70b700a2f8d2b94099c800b 100644 (file)
@@ -9,15 +9,13 @@ class printerPPDSelectionDialog extends plugin
 
   /* attribute list for save action */
   var $ignore_account       = FALSE;
-  var $attributes           = array("currentPos","currentSel");
+  var $attributes           = array();
   var $objectclasses        = array("whatever");
 
   var $list                 =array();
   var $header               =array();
 
-  var $currentPos           = "";
-  var $currentSel           = -1;
-  var $selectedPPD          = "";
+  var $Vendor               = "";
 
   function printerPPDSelectionDialog ($config, $dn= NULL,$list=false,$headers=false,$ppd=false)
   {
@@ -26,18 +24,6 @@ class printerPPDSelectionDialog extends plugin
     $this->header     = $headers;
     $this->depselect  = $this->config->current['BASE'];
     
-    /* If there is already a ppd file selected, use this as preselected object in our ppds list
-     * /
-    if(isset($ppd)){
-      print_a( $ppd);
-      $tmp2 = split("\n",$ppd['ppd']);
-      if(count($tmp2)==2){
-        $this->currentPos = $tmp2[0];
-        $this->currentSel = preg_replace("/^ -/","",$tmp2[1]);
-      }
-    }
-  
-     */
     if(!isset($_SESSION['printerPPDSelectionDialog'])){
       $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
     }  
@@ -69,26 +55,48 @@ class printerPPDSelectionDialog extends plugin
     $regex = str_replace("**","*",$regex);
     $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
   
-
-    /* if manufacturer is selected and a ppd file 
-     * Set this selected file to our return value.
-     */ 
-    if(isset($this->list[$this->currentPos][$this->currentSel])){
-      $this->selectedPPD = $this->list[$this->currentPos][$this->currentSel];
-    }
-
     /** Added **/
     $list = array();
     foreach($this->list as $cat => $ppds){
       foreach($ppds as $ppd){
         if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
-          $list[$ppd['link']] = $ppd['ppd'];
+          $list[$ppd['link']] = $ppd;
+        }
+      }
+    }
+  
+    if((isset($_GET['act']))&&($_GET['act']=="open"))  {
+      $this->Vendor = $_GET['id'];
+    }
+
+    $div = new divSelectBox("printerPPDSelectionDialog");
+    $div ->SetHeight(400);
+    $div ->SetSummary(_("Printer ppd selection."));
+    
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
+    $uselink  = "<a href='?plug=".$_GET['plug']."&amp;act=use&amp;id=%s'>%s</a>";
+    
+
+    if(empty($this->Vendor)){
+      foreach($this-> header as $key => $entry){
+        $div ->AddEntry (array(
+              array("string"=>sprintf($linkopen,$key,$key))
+              ));
+      }
+    }else{
+      $div ->AddEntry (array(
+            array("string"=>sprintf($linkopen,"",".. ["._("back")."]"))
+            ));
+      foreach($list as $key => $ppd){
+        if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
+          $div ->AddEntry (array(
+                array("string"=>sprintf($uselink,$key,$ppd['ppd']))
+                ));
         }
       }
     }
 
-    $smarty->assign("objects",      $list);
-    $smarty->assign("objectKeys",   array_flip($list));
+    $smarty->assign("List",         $div -> DrawList());
     $smarty->assign("search_image", get_template_path('images/search.png'));
     $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
     $smarty->assign("tree_image",   get_template_path('images/tree.png'));
index 5c628e11d97f873775b7a1ece2bb7f73484b4ef7..e6b6fc881701a14794fe0e83612f4a19b5f0da0a 100644 (file)
@@ -8,9 +8,7 @@
                        </div>
                        <div class="contentboxb">
                                <p class="contentboxb" style="border-top:1px solid #B0B0B0;background-color:#F8F8F8">
-                                       <select style="width:100%; height:450px; margin-top:4px;" name="PPDselection" size="15">
-            {html_options values=$objectKeys options=$objects}
-                                       </select>
+          {$List}
                                        <input type=hidden name="edit_helper">
                                </p>    
                        </div>