summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 740c76b)
raw | patch | inline | side by side (parent: 740c76b)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Sep 2005 06:18:28 +0000 (06:18 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Sep 2005 06:18:28 +0000 (06:18 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1295 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/systems/class_printerPPDDialog.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/class_printerPPDSelectionDialog.inc | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/printerPPDDialog.tpl | [new file with mode: 0644] | patch | blob |
plugins/admin/systems/printerPPDSelectionDialog.tpl | [new file with mode: 0644] | patch | blob |
diff --git a/plugins/admin/systems/class_printerPPDDialog.inc b/plugins/admin/systems/class_printerPPDDialog.inc
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+
+class printerPPDDialog extends plugin
+{
+ /* CLI vars */
+ var $cli_summary = "Manage server basic objects";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "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("<table><tr><td>adfasdf</td></tr></table/table>");
+ }
+}
+// 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
--- /dev/null
@@ -0,0 +1,145 @@
+<?php
+
+class printerPPDSelectionDialog extends plugin
+{
+ /* CLI vars */
+ var $cli_summary = "Manage server basic objects";
+ var $cli_description = "Some longer text\nfor help";
+ var $cli_parameters = array("eins" => "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 = "<a href='?plug=".$_GET['plug']."&open=%s'>%s</a>";
+ $LINK_useThis = "<a href='?plug=".$_GET['plug']."&use=%s'>%s</a>";
+
+ /* 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 = "<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 = "";
+
+ /* 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
--- /dev/null
@@ -0,0 +1,23 @@
+
+<h2>{t}Printer driver information file setup{/t}</h2>
+
+<table summary="" width="50%">
+ <tr>
+ <td>
+ {t}Current used information setup : {/t}
+ </td>
+ <td>
+ {$ppdString}
+ </td>
+ <td>
+ <input type="submit" name="SelectPPD" value="{t}Select{/t}">
+ </td>
+ </tr>
+</table>
+<p class="seperator"> </p>
+<br>
+{$properties}
+<p class="seperator"> </p>
+<br>
+<input type="submit" name="SavePPD" value="{t}Save{/t}">
+<input type="submit" name="ClosePPD" value="{t}Close{/t}">
diff --git a/plugins/admin/systems/printerPPDSelectionDialog.tpl b/plugins/admin/systems/printerPPDSelectionDialog.tpl
--- /dev/null
@@ -0,0 +1,19 @@
+<table summary="" style="width:50%; vertical-align:top; text-align:left;" cellpadding=4>
+<tr>
+ <td style="vertical-align:top;width:50%;">
+ <div class="contentboxh">
+ <p class="contentboxh">
+ <LABEL for="userlist">{t}List of PPDs{/t}</LABEL>
+ </p>
+ </div>
+ <div class="contentboxb">
+ {$listhead}
+ </div>
+ <div class="contentboxb">
+ {$list}
+</div>
+ </td>
+ </tr>
+</table>
+<input type="submit" name="SavePPDSelection" value="{t}Save{/t}">
+<input type="submit" name="ClosePPDSelection" value="{t}Close{/t}">