57e96f97dafe4cd072eabaf6649f7fd560d30ae4
1 <?php
3 class faiPackageEntry 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= TRUE;
12 var $attributes = array();
13 var $objectclasses= array();
14 var $pkgs = array();
16 var $buffer = array();
17 var $categories = array();
18 var $searchStrPKG = "";
19 var $selected = array();
21 /* Array with available class names */
22 var $FAIAllclasses = array();
24 function faiPackageEntry ($config, $dn= NULL,$pkgs,$selected=array())
25 {
26 plugin::plugin ($config, $dn);
28 $this->pkgs=$pkgs;
30 if(isset($_SESSION['searchStrPKG'])){
31 $this->searchStrPKG=$_SESSION['searchStrPKG'];
32 }
33 $this->selected=$selected;
35 $this->searchStrPKG= _("Please enter your search string here");
36 }
38 function execute()
39 {
40 /* Call parent execute */
41 plugin::execute();
43 /* Fill templating stuff */
44 $smarty = get_smarty();
45 $display = "";
47 $divlist = new divlist("PackageEntry");
48 $divlist->SetSummary(_("This list displays all assigned package names for this repository settings."));
49 $divlist->SetEntriesPerPage(20);
50 $divlist->SetHeight("650px;");
51 $divlist->SetHeader(array(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"),
52 array("string" => "Name", "attach" => "style='width:180px;'"),
53 array("string" => "Version", "attach" ),
54 array("string" => "Description", "attach" => "style='width:240px;border-right:0px;text-align:left;'")));
56 if(isset($_GET['search'])){
57 $this->searchStrPKG= $_GET['search']."*";
58 }
60 $pkgs= $this->pkgs;
62 unset($this->categories);
63 foreach($pkgs as $name => $entry){
64 $cat = $entry[2];
65 if(!empty($cat)){
66 if(!isset($this->categories[$cat])){
67 $this->categories[$cat] = true;
68 }
69 if(isset($_POST['chkchange'])){
70 $this->searchStrPKG = $_POST['searchStrPKG'];
71 if(isset($_POST['CAT'.$cat])){
72 $this->categories[$cat]=true;
73 }else{
74 $this->categories[$cat]=false;
75 }
76 }
77 }
78 }
80 ksort($this->categories);
82 $CHKS = "<table><tr><input type='hidden' value='chkchange' name='chkchange'>";
83 $i = 0;
84 foreach($this->categories as $cat => $selected){
85 if($i == 3){
86 $CHKS .="</tr><tr>";
87 $i = 0;
88 }
89 $i ++ ;
90 if($selected){
91 $CHKS .="<td><input type='checkbox' value='1' name='CAT".$cat."' checked onclick='document.mainform.submit()'> ".$cat." </td>";
92 }else{
93 $CHKS .="<td><input type='checkbox' value='1' name='CAT".$cat."' onclick='document.mainform.submit()'> ".$cat." </td>";
94 }
95 }
96 $CHKS .= "</td></tr></table>";
99 foreach($_POST as $name => $value){
100 if(preg_match("/^wasonpage_/i",$name)){
101 $name = preg_replace("/^wasonpage_/","",$name);
102 $n =base64_decode($name);
104 if(isset($_POST['use_'.$name])){
105 $this->selected[$n] = $n;
106 }else{
107 if(isset($this->selected[$n])){
108 unset($this->selected[$n]);
109 }
110 }
112 }
113 }
115 $cnt = 0;
116 foreach($pkgs as $pkg){
117 if((preg_match("/^".str_replace("*",".*",$this->searchStrPKG)."/i",$pkg[0]))||
118 (preg_match("/^".str_replace("*",".*",$this->searchStrPKG)."/i",$pkg[3]))){
119 if($this->categories[$pkg[2]]){
120 if(in_array($pkg[0],$this->selected)){
121 $check = " checked ";
122 }else{
123 $check = "";
124 }
125 $cnt ++ ;
126 $chkbox = "<input type='checkbox' value='1' name='use_".base64_encode($pkg[0])."' ".$check." onclick='document.mainform.submit()'>
127 <input type='hidden' value='1' name='wasonpage_".base64_encode($pkg[0])."'>";
128 $divlist->AddEntry(array(array("string"=>$chkbox, "attach" => "style='text-align:center;width:20px;'"),
129 array("string"=>$pkg[0], "attach" => "style='width:180px;'"),
130 array("string"=>$pkg[1]),
131 array("string"=>$pkg[3], "attach" => "style='width:221px;border-right:0px;text-align:left;'")));
132 }
133 }
134 }
136 $_SESSION['searchStrPKG'] = $this->searchStrPKG;
137 $smarty->assign("CHKS" , $CHKS);
138 $smarty->assign("searchStrPKG" , $this->searchStrPKG);
139 $smarty->assign("faihead" , "");
140 $smarty->assign("failist" , $divlist->DrawList());
141 $smarty->assign("infoimage" , get_template_path('images/info.png'));
142 $smarty->assign("launchimage" , get_template_path('images/launch.png'));
143 $smarty->assign("alphabet" , generate_alphabet());
144 $smarty->assign("apply" , apply_filter(TRUE));
145 $smarty->assign("search_image" , get_template_path('images/search.png'));
147 $display.= $smarty->fetch(get_template_path('faiPackageEntry.tpl', TRUE));
148 return($display);
149 }
151 /* Save data to object */
152 function save_object()
153 {
154 foreach($_POST as $name => $value){
155 if(preg_match("/^wasonpage_/i",$name)){
156 $name = preg_replace("/^wasonpage_/","",$name);
157 $n =base64_decode($name);
158 if(isset($_POST['use_'.$name])){
159 $this->selected[$n] = $n;
160 }else{
161 if(isset($this->selected[$n])){
162 unset($this->selected[$n]);
163 }
164 }
166 }
167 }
169 }
171 /* Check supplied data */
172 function check()
173 {
174 $message= array();
175 return ($message);
176 }
178 function save()
179 {
180 return($this->selected);
181 }
182 }
183 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
184 ?>