From b7e7d697d736cadae9135d094672c947b35b539f Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 2 Sep 2005 06:18:28 +0000 Subject: [PATCH] Added midding Dialogs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1295 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_printerPPDDialog.inc | 149 ++++++++++++++++++ .../class_printerPPDSelectionDialog.inc | 145 +++++++++++++++++ plugins/admin/systems/printerPPDDialog.tpl | 23 +++ .../systems/printerPPDSelectionDialog.tpl | 19 +++ 4 files changed, 336 insertions(+) create mode 100644 plugins/admin/systems/class_printerPPDDialog.inc create mode 100644 plugins/admin/systems/class_printerPPDSelectionDialog.inc create mode 100644 plugins/admin/systems/printerPPDDialog.tpl create mode 100644 plugins/admin/systems/printerPPDSelectionDialog.tpl diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc new file mode 100644 index 000000000..083e04077 --- /dev/null +++ b/plugins/admin/systems/class_printerPPDDialog.inc @@ -0,0 +1,149 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array(); + var $objectclasses = array("whatever"); + + var $ppdList = array(); + var $ppdListHeader = array(); + + var $dialog = NULL; + var $selectedPPD = false; + + var $ppdManager = false; + function printerPPDDialog ($config, $dn= NULL,$ppdfile=NULL ) + { + plugin::plugin ($config, $dn); + $this->depselect = $this->config->current['BASE']; + + /* Load all available PPD files and sort them into an array + */ + require_once ("class_ppdManager.inc"); + $this->ppdManager= new ppdManager('/var/spool/ppd/'); + $tmp = $this->ppdManager->getPrinterList(); + + /* Sort all available files, and create header (Vendor index) */ + foreach($tmp as $file=>$ppd){ + $tmp2 = split("\n",$ppd); + if(!isset($this->ppdListHeader[$tmp2[0]])){ + $this->ppdListHeader[$tmp2[0]]=0; + } + $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]); + $tmp3['link'] =$file; + $tmp3['ppd'] =$ppd; + + $this->ppdListHeader[$tmp2[0]]++; + + $this->ppdList[$tmp2[0]][preg_replace("/^ -/","",$tmp2[1])]=$tmp3; + } + + /* The user has already a valid PPD assigned + * Get some informations about this PPD + */ + if(($ppdfile!= NULL)&&(strlen($ppdfile)>0)){ + $tmp2= split("\n", $this->ppdManager->loadDescription($ppdfile)); + $tmp3['name'] =preg_replace("/^ -/","",$tmp2[1]); + $tmp3['link'] =$ppdfile; + $tmp3['ppd'] =$this->ppdManager->loadDescription($ppdfile); + $this->selectedPPD = $tmp3; + } + + + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + + /* Open a dialog that allow us to select different PPDs + */ + if(isset($_POST['SelectPPD'])){ + $this->dialog= new printerPPDSelectionDialog($this->config,$this->dn,$this->ppdList,$this->ppdListHeader,$this->selectedPPD); + } + + /* The selection dialog fpr PPDs is canceled + */ + if(isset($_POST['ClosePPDSelection'])){ + unset($this->dialog); + $this->dialog=NULL; + } + + /* A new PPDs was selected in the PPDs selection Dialog + * 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); + } + }else{ + $this->selectedPPD = $this->dialog->save(); + unset($this->dialog); + $this->dialog=NULL; + } + } + + /* if a dialog is open, print the dialog instead of this class + */ + if($this->dialog!=NULL){ + $display = $this->dialog->execute(); + return($display); + } + + /* Give smarty the information it needs */ + $smarty->assign("ppdString" ,$this->getPPDInformation()); + $smarty->assign("properties",$this->generateProperties()); + + /* Print out template */ + $display.= $smarty->fetch(get_template_path('printerPPDDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function check(){ + /* Check the given data + */ + $message=array(); + return $message; + } + + /* Save to LDAP */ + function save() + { + /* return the selected PPD, and in future the selected options too */ + return($this->selectedPPD['link']); + } + + function getPPDInformation() + { + /* Get Information for a single PPD entry + * This will be shown on top of template + */ + $str = "none"; + if(!empty($this->selectedPPD)){ + $str = $this->selectedPPD['link']; + $str = $this->ppdManager->loadDescription($this->selectedPPD['link']); + } + return($str) ; + } + + function generateProperties() + { + /* In future there will be a schema parser that provide us all settings that can be made in the selected PPD file. + * This function will generate a userfriendly post based form with this informations + */ + return("
adfasdf
"); + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_printerPPDSelectionDialog.inc b/plugins/admin/systems/class_printerPPDSelectionDialog.inc new file mode 100644 index 000000000..b10357b9d --- /dev/null +++ b/plugins/admin/systems/class_printerPPDSelectionDialog.inc @@ -0,0 +1,145 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = FALSE; + var $attributes = array("currentPos","currentSel"); + var $objectclasses = array("whatever"); + + var $list =array(); + var $header =array(); + + var $currentPos = ""; + var $currentSel = -1; + var $selectedPPD = ""; + + function printerPPDSelectionDialog ($config, $dn= NULL,$list=false,$headers=false,$ppd=false) + { + plugin::plugin ($config, $dn); + $this->list = $list; + $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]); + } + + /* Order the manufacturers index */ + ksort($this->header); + } + + function execute() + { + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + $s_action = "none"; + + /* Links used to open/select an entry */ + $LINK_openDir = "%s"; + $LINK_useThis = "%s"; + + /* Open manufacturer */ + if(isset($_GET['open'])){ + $this->currentPos=base64_decode($_GET['open']); + } + + /* 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]; + } + + /* "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;'"); + } + $div->AddEntry(array($field1)); + } + } + + /* print out template */ + $smarty->assign("listhead",$listhead); + $smarty->assign("list",$div->DrawList()); + $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + function check(){ + $message=array(); + if(empty($this->selectedPPD)){ + $message[] = _("Please select a PPD or press cancel"); + } + return $message; + } + + /* Save to LDAP */ + function save() + { + return $this->selectedPPD; + } +} +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/printerPPDDialog.tpl b/plugins/admin/systems/printerPPDDialog.tpl new file mode 100644 index 000000000..32ecb48b0 --- /dev/null +++ b/plugins/admin/systems/printerPPDDialog.tpl @@ -0,0 +1,23 @@ + +

{t}Printer driver information file setup{/t}

+ + + + + + + +
+ {t}Current used information setup : {/t} + + {$ppdString} + + +
+

 

+
+{$properties} +

 

+
+ + diff --git a/plugins/admin/systems/printerPPDSelectionDialog.tpl b/plugins/admin/systems/printerPPDSelectionDialog.tpl new file mode 100644 index 000000000..6a4f3934a --- /dev/null +++ b/plugins/admin/systems/printerPPDSelectionDialog.tpl @@ -0,0 +1,19 @@ + + + + +
+
+

+ +

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