Code

Fixed headpage
[gosa.git] / plugins / admin / systems / class_printerPPDSelectionDialog.inc
1 <?php
3 class printerPPDSelectionDialog extends plugin
4 {
5   /* CLI vars */
6   var $cli_summary          = "Manage server basic objects";
7   var $cli_description      = "Some longer text\nfor help";
8   var $cli_parameters       = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
10   /* attribute list for save action */
11   var $ignore_account       = FALSE;
12   var $attributes           = array();
13   var $objectclasses        = array("whatever");
15   var $list                 =array();
16   var $header               =array();
18   var $Vendor               = "";
20   function printerPPDSelectionDialog ($config, $dn= NULL,$list=false,$headers=false,$ppd=false)
21   {
22     plugin::plugin ($config, $dn);
23     $this->list       = $list;
24     $this->header     = $headers;
25     $this->depselect  = $this->config->current['BASE'];
26     
27     if(!isset($_SESSION['printerPPDSelectionDialog'])){
28       $_SESSION['printerPPDSelectionDialog']['regex'] = "*";
29     }  
31     /* Order the manufacturers index */
32     ksort($this->header);
33   }
35   function execute()
36   {
37         /* Call parent execute */
38         plugin::execute();
40     /* Fill templating stuff */
41     $smarty= get_smarty();
42     $display= "";
43     $s_action = "none";
44   
45     $regex = $_SESSION['printerPPDSelectionDialog']['regex'];
47     if(isset($_GET['search'])){
48       $regex = $_GET['search']."*";
49     }
50   
51     if(isset($_POST['regex'])){
52       $regex= $_POST['regex'];
53     }
54     
55     $regex = str_replace("**","*",$regex);
56     $_SESSION['printerPPDSelectionDialog']['regex'] = $regex;
57   
58     /** Added **/
59     $list = array();
60     foreach($this->list as $cat => $ppds){
61       foreach($ppds as $ppd){
62         if(preg_match("/^".str_replace("*",".*",$regex)."/i",$ppd['ppd'])){
63           $list[$ppd['link']] = $ppd;
64         }
65       }
66     }
67   
68     if((isset($_GET['act']))&&($_GET['act']=="open"))  {
69       $this->Vendor = $_GET['id'];
70     }
72     $div = new divSelectBox("printerPPDSelectionDialog");
73     $div ->SetHeight(450);
74     $div ->SetSummary(_("Printer ppd selection."));
75     
76     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
77     $uselink  = "<a href='?plug=".$_GET['plug']."&amp;act=use&amp;id=%s'>%s</a>";
78     
80     if(empty($this->Vendor)){
81       foreach($this-> header as $key => $entry){
82         $div ->AddEntry (array(
83               array("string"=>sprintf($linkopen,$key,$key),"attach"=>"style='border-right:0px;'")
84               ));
85       }
86     }else{
87       $div ->AddEntry (array(
88             array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
89             ));
90       foreach($list as $key => $ppd){
91         if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
92           $div ->AddEntry (array(
93                 array("string"=>sprintf($uselink,$key,$ppd['ppd']),"attach"=>"style='border-right:0px;'")
94                 ));
95         }
96       }
97     }
99     $smarty->assign("List",         $div -> DrawList());
100     $smarty->assign("search_image", get_template_path('images/search.png'));
101     $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
102     $smarty->assign("tree_image",   get_template_path('images/tree.png'));
103     $smarty->assign("alphabet",     generate_alphabet());
104     $smarty->assign("apply",        apply_filter());
105     $smarty->assign("regex",        $regex);
106   
107     $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
108     return($display);
109   }
111   function save_object()
112   {
113   } 
115   function check(){
116   }
118   /* Save to LDAP */
119   function save()
120   {
121     return $this->selectedPPD;
122   }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>