diff --git a/plugins/admin/systems/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/class_printerPPDSelectionDialog.inc
index b10357b9d056ca6fc703002375cfde08642b1a76..1c949fb99ddf5015a3671e3ec3c9758595d244be 100644 (file)
/* 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)
{
$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)){
- $tmp2 = split("\n",$ppd['ppd']);
- $this->currentPos = $tmp2[0];
- $this->currentSel = preg_replace("/^ -/","",$tmp2[1]);
- }
-
+ if(!isset($_SESSION['printerPPDSelectionDialog'])){
+ $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
+ }
+
/* Order the manufacturers index */
ksort($this->header);
}
function execute()
{
+ /* Call parent execute */
+ plugin::execute();
+
/* Fill templating stuff */
$smarty= get_smarty();
$display= "";
$s_action = "none";
- /* Links used to open/select an entry */
- $LINK_openDir = "<a href='?plug=".$_GET['plug']."&open=%s'>%s</a>";
- $LINK_useThis = "<a href='?plug=".$_GET['plug']."&use=%s'>%s</a>";
+ $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 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];
+
+ if(isset($_POST['regex'])){
+ $regex= $_POST['regex'];
}
-
- /* "Back" resets our selection
- */
- foreach($_POST as $post => $val){
- if(preg_match("/dep_back/",$post)){
- $s_action = "back";
- $this->currentPos = "";
- $this->currentSel = -1;
+
+ $regex = str_replace("**","*",$regex);
+ $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
+
+ /** 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;
+ }
}
}
+
+ if((isset($_GET['act']))&&($_GET['act']=="open")) {
+ $this->Vendor = $_GET['id'];
+ }
- /* The listhead is shown on top of the list.
- * It represents a menu that contains basic option for this dialog/list
- */
- $listhead = "<div style='background:#F0F0F9;padding:5px;'>".
- " <input type='image' align='middle' src='images/list_back.png' title='"._("Reset list")."' alt='"._("Up")."' name='dep_back'> ".
- " <img src='images/list_seperator.png' align='middle' alt='' height='16' width='1'> ".
- " <input type='image' align='middle' src='images/list_new_user.png' title='"._("Upload PPD")."' alt='"._("Uppload PPD")."' name='upload'> ".
- "</div>";
-
- /* 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 = "";
+ $div = new divSelectBox("printerPPDSelectionDialog");
+ $div ->SetHeight(450);
+ $div ->SetSummary(_("Printer ppd selection."));
+
+ $linkopen = "<a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
+ $uselink = "<a href='?plug=".$_GET['plug']."&act=use&id=%s'>%s</a>";
+
- /* 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));
+ if(empty($this->Vendor)){
+ foreach($this-> header as $key => $entry){
+ $div ->AddEntry (array(
+ array("string"=>sprintf($linkopen,$key,$key),"attach"=>"style='border-right:0px;'")
+ ));
}
-
- /* 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;'");
+ $div ->AddEntry (array(
+ array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
+ ));
+ foreach($list as $key => $ppd){
+ if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
+ $div ->AddEntry (array(
+ array("string"=>sprintf($uselink,$key,$ppd['ppd']),"attach"=>"style='border-right:0px;'")
+ ));
}
- $div->AddEntry(array($field1));
}
}
-
- /* print out template */
- $smarty->assign("listhead",$listhead);
- $smarty->assign("list",$div->DrawList());
+
+ $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'));
+ $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 */