From 46e912ba6a09643b50bf79f10e30080b838495e3 Mon Sep 17 00:00:00 2001 From: hickert Date: Wed, 26 Oct 2005 07:16:44 +0000 Subject: [PATCH] reworked printer ppd selection git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1690 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_printerPPDDialog.inc | 22 ++-- .../class_printerPPDSelectionDialog.inc | 103 ++++++------------ .../systems/printerPPDSelectionDialog.tpl | 77 ++++++++++--- 3 files changed, 105 insertions(+), 97 deletions(-) diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc index 1b4c5a396..d036a0128 100644 --- a/plugins/admin/systems/class_printerPPDDialog.inc +++ b/plugins/admin/systems/class_printerPPDDialog.inc @@ -83,18 +83,16 @@ class printerPPDDialog extends plugin * Perform a Check. If everything is fine, use the new PPD. */ if(isset($_POST['SavePPDSelection'])){ - if(count($this->dialog->check())>0){ - foreach($this->dialog->check() as $msg){ - print_red($msg); - } + if(!isset($_POST['PPDselection'])){ + print_red(_("Please select a valid PPD.")); }else{ - $this->selectedPPD = $this->dialog->save(); - $this->ppdConfig = false; + $this->selectedPPD['link'] = $_POST['PPDselection']; + $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){ @@ -121,10 +119,12 @@ class printerPPDDialog extends plugin function save_object() { if(isset($_POST['PPDDisSubmitted'])){ - foreach($this->ppdConfig as $cat => $obj){ - foreach($obj as $attr => $attributes){ - if(isset($_POST[base64_encode($attributes['_name'])])){ - $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; + if(is_array($this->ppdConfig)){ + foreach($this->ppdConfig as $cat => $obj){ + foreach($obj as $attr => $attributes){ + if(isset($_POST[base64_encode($attributes['_name'])])){ + $this->ppdConfig[$cat][$attr]['_default'] = $_POST[base64_encode($attributes['_name'])]; + } } } } diff --git a/plugins/admin/systems/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/class_printerPPDSelectionDialog.inc index 78935b9d1..39f38da54 100644 --- a/plugins/admin/systems/class_printerPPDSelectionDialog.inc +++ b/plugins/admin/systems/class_printerPPDSelectionDialog.inc @@ -36,6 +36,10 @@ class printerPPDSelectionDialog extends plugin } } + if(!isset($_SESSION['printerPPDSelectionDialog'])){ + $_SESSION['printerPPDSelectionDialog']['regex'] = "*"; + } + /* Order the manufacturers index */ ksort($this->header); } @@ -47,19 +51,19 @@ class printerPPDSelectionDialog extends plugin $display= ""; $s_action = "none"; - /* Links used to open/select an entry */ - $LINK_openDir = "%s"; - $LINK_useThis = "%s"; + $regex = $_SESSION['printerPPDSelectionDialog']['regex']; - /* Open manufacturer */ - if(isset($_GET['open'])){ - $this->currentPos=base64_decode($_GET['open']); + if(isset($_GET['search'])){ + $regex = $_GET['search']."*"; } - - /* Select ppd */ - if(isset($_GET['use'])){ - $this->currentSel=base64_decode($_GET['use']); + + if(isset($_POST['regex'])){ + $regex= $_POST['regex']; } + + $regex = str_replace("**","*",$regex); + $_SESSION['printerPPDSelectionDialog']['regex'] = $regex; + /* if manufacturer is selected and a ppd file * Set this selected file to our return value. @@ -68,73 +72,34 @@ class printerPPDSelectionDialog extends plugin $this->selectedPPD = $this->list[$this->currentPos][$this->currentSel]; } - /* "Back" resets our selection - */ - foreach($_POST as $post => $val){ - if(preg_match("/dep_back/",$post)){ - $s_action = "back"; - $this->currentPos = ""; - $this->currentSel = -1; - } - } - - /* The listhead is shown on top of the list. - * It represents a menu that contains basic option for this dialog/list - */ - $listhead = "
". - "  ". - "  ". - "  ". - "
"; - - /* Create new list*/ - $div = new divlist("PPD"); - $div -> SetSummary(_("List with all available ppd files.")); - $div -> SetEntriesPerPage(18); - - /* If nothing is selected open manufacturers list */ - if($this->currentPos==""){ - $div -> SetHeader (array( - array("string"=>_("Name")), - array("string"=>_("Entries"),"attach"=>"style='border-right:none;width:100px;'"))); - $options = ""; - - /* Append elements */ - foreach($this->header as $header => $nums){ - $field1 = array("string" => sprintf($LINK_openDir,base64_encode($header),$header),"attach"=>"style='border-right:none;height:26px;'"); - $field2 = array("string" => $nums,"attach"=>"style='border-right:none;height:26px;'"); - $div->AddEntry(array($field1,$field2)); - } - - /* Display all ppds for the given manufacturer */ - }else{ - $div -> SetHeader (array( - array("string"=>_("Name")." - ".$this->currentPos ,"attach"=>"style='border-right:none;'"))); - - /* Append elements */ - foreach($this->list[$this->currentPos] as $pos => $ppd){ - if($pos == $this->currentSel){ - $field1 = array("string" => sprintf($LINK_useThis,base64_encode($pos),$ppd['name'])." - "._("selected"),"attach"=>"style='border-right:none;background:#99CCBB;height:25px;'"); - }else{ - $field1 = array("string" => sprintf($LINK_useThis,base64_encode($pos),$ppd['name']),"attach"=>"style='border-right:none;height:25px;'"); + /** 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']; } - $div->AddEntry(array($field1)); } } - - /* print out template */ - $smarty->assign("listhead",$listhead); - $smarty->assign("list",$div->DrawList()); + + $smarty->assign("objects", $list); + $smarty->assign("objectKeys", array_flip($list)); + $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')); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("apply", apply_filter()); + $smarty->assign("regex", $regex); + $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__))); return($display); } + function save_object() + { + } + function check(){ - $message=array(); - if(empty($this->selectedPPD)){ - $message[] = _("Please select a PPD or press cancel"); - } - return $message; } /* Save to LDAP */ diff --git a/plugins/admin/systems/printerPPDSelectionDialog.tpl b/plugins/admin/systems/printerPPDSelectionDialog.tpl index 6a4f3934a..7dfcc61d9 100644 --- a/plugins/admin/systems/printerPPDSelectionDialog.tpl +++ b/plugins/admin/systems/printerPPDSelectionDialog.tpl @@ -1,19 +1,62 @@ - - -
-
-

- -

-
-
- {$listhead} -
-
- {$list} -
+ + + - + +
+
+

+ {t}Select objects to add{/t} +

+
+
+

+ + +

+
+
+

+ [F] + {t}Filters{/t} +

+
+
+ + {$alphabet} +
+ + + + +
+ +  {t}Display objects of department{/t} +
+ + + + + +
+ +  {t}Display objects matching{/t} + + +
+ {$apply} +
+
- - + +

+ +   + +

+ -- 2.30.2