Code

default is now visible as _("inherited")
[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       
70       if((!empty($_GET['id'])) && (!isset( $this->header[base64_decode($_GET['id'])]))){
71         print_red(sprintf(_("Selected vendor '%s' does not exists in our list of ppds."),base64_decode($_GET['id'])));      
72         $this->Vendor = ""; 
73       }else{
74         $this->Vendor = base64_decode($_GET['id']);
75       }
76     }
78     $div = new divSelectBox("printerPPDSelectionDialog");
79     $div ->SetHeight(450);
80     $div ->SetSummary(_("Printer ppd selection."));
81     
82     $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=open&amp;id=%s'>%s</a>";
83     $uselink  = "<a href='?plug=".$_GET['plug']."&amp;act=use&amp;id=%s'>%s</a>";
84     
86     if(empty($this->Vendor)){
87       foreach($this-> header as $key => $entry){
88         $div ->AddEntry (array(
89               array("string"=>sprintf($linkopen,base64_encode($key),$key),"attach"=>"style='border-right:0px;'")
90               ));
91       }
92     }else{
93       $div ->AddEntry (array(
94             array("string"=>sprintf($linkopen,"",".. ["._("back")."]"),"attach"=>"style='border-right:0px;'")
95             ));
96       foreach($list as $key => $ppd){
97         if(preg_match("/^".$this->Vendor."/",$ppd['ppd'])){
98           $div ->AddEntry (array(
99                 array("string"=>sprintf($uselink,base64_encode($key),$ppd['ppd']),"attach"=>"style='border-right:0px;'")
100                 ));
101         }
102       }
103     }
105     $smarty->assign("List",         $div -> DrawList());
106     $smarty->assign("search_image", get_template_path('images/search.png'));
107     $smarty->assign("launchimage",  get_template_path('images/small_filter.png'));
108     $smarty->assign("tree_image",   get_template_path('images/tree.png'));
109     $smarty->assign("alphabet",     generate_alphabet());
110     $smarty->assign("apply",        apply_filter());
111     $smarty->assign("regex",        $regex);
112   
113     $display.= $smarty->fetch(get_template_path('printerPPDSelectionDialog.tpl', TRUE,dirname(__FILE__)));
114     return($display);
115   }
117   function save_object()
118   {
119   } 
121   function check(){
122   }
124   /* Save to LDAP */
125   function save()
126   {
127     return $this->selectedPPD;
128   }
130 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
131 ?>