1 <?php
3 class divListMimeTypes extends MultiSelectWindow
4 {
5 /* Current base */
6 var $selectedBase = "";
7 var $departments = array();
8 var $parent ;
9 var $ui ;
11 /* Regex */
12 var $Regex = "*";
14 /* Subsearch checkbox */
15 var $SubSearch;
17 function divListMimeTypes (&$config, &$parent)
18 {
19 /* Create divlist and setup */
20 MultiSelectWindow::MultiSelectWindow($config, "Mimetypes", "mimetypes");
22 /* initialize required attributes */
23 $this->parent = &$parent;
24 $this->ui = get_userinfo();
26 /* Set list strings */
27 $this->SetTitle (_("List of defined mime types"));
28 $this->SetSummary (_("List of defined mime types"));
30 /* Result page will look like a headpage */
31 $this->SetHeadpageMode();
32 $this->EnableAplhabet(true);
34 /* Disable buttonsm */
35 $this->EnableCloseButton(false);
36 $this->EnableSaveButton (false);
38 /* set Page header */
39 $action_col_size = 80;
40 if($this->parent->snapshotEnabled()){
41 $action_col_size += 38;
42 }
44 /* Toggle all selected / deselected */
45 $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
46 onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
48 /* set Page header */
49 $this->AddHeader(array("string"=> $chk, "attach"=>"style='width:20px;'"));
50 $this->AddHeader(array("string" => " ", "attach" => "style='text-align:center;width:20px;'"));
51 $this->AddHeader(array("string" => _("Mime type")." / "._("Department"), "attach" => "style=''"));
52 $this->AddHeader(array("string" => _("Actions"), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
54 /* Add SubSearch checkbox */
55 $this->AddCheckBox("SubSearch", msgPool::selectToView("","subsearch"), msgPool::selectToView("","subsearch_small"), false);
57 /* Name ,Text ,Default , Connect with alphabet */
58 $this->AddRegex ("Regex", _("Display mime types matching"),"*" , true);
59 }
62 function AddUserBoxToFilter($position)
63 {
64 $str = "";
65 if(($position == 2) && ($this->parent->IsReleaseManagementActivated($this->config))){
66 $smarty = get_smarty();
67 $releases = $this->parent->getReleases();
68 $smarty->assign("mime_release" , $releases[$this->parent->mime_release]);
69 $smarty->assign("mime_base" , $releases[$this->parent->mime_base]);
70 $smarty->assign("branchimage","plugins/goto/images/branch.png");
71 $smarty->assign("mime_releases", $releases);
72 $str = $smarty->fetch(get_template_path('release_select.tpl', TRUE));
73 }
74 return($str);
75 }
78 /* Create list header, with create / copy & paste etc*/
79 function GenHeader()
80 {
81 /* Add default header */
82 $listhead = MultiSelectWindow::get_default_header(false);
83 if(!$this->parent->IsReleaseManagementActivated()){
85 /* Get all departments within this subtree */
86 $ui= get_userinfo();
87 $first = "";
88 $found = FALSE;
89 $base = $this->config->current['BASE'];
90 $options = $this->create_department_list($this->module);
92 /* And at least add a department selection box */
93 $listhead .= _("Base")." <select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
94 " <input class='center' type='image' src='images/lists/submit.png' align='middle'
95 title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'> ";
97 }
99 /* Get acls */
100 $ui = get_userinfo();
101 $acl = $ui->get_permissions($this->parent->mime_base,"mimetypes/mimetype");
102 $acl_all = $ui->has_complete_category_acls($this->parent->mime_base,"mimetypes") ;
105 /* If this is true we add an additional seperator. Just look a few lines below */
106 $add_sep = false;
108 /* Create Layers menu */
109 $s = ".|"._("Actions")."|\n";
111 /* Append create options */
112 if(preg_match("/c/",$acl)) {
113 $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
114 " "._("Create")."|\n";
115 $s.= "...|<input class='center' type='image' src='plugins/goto/images/list_new_mime.png' alt=''>".
116 " "._("Mime type")."|mime_new|\n";
117 $s.= "..|---|\n";
118 }
120 /* Multiple options */
121 $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
122 " "._("Remove")."|"."remove_multiple|\n";
124 /* Add Copy & Paste header */
125 $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
127 /* Add snapshot icons */
128 $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);
130 $this->SetDropDownHeaderMenu($s);
131 $this->SetListHeader($listhead);
132 }
135 /* Some basic settings */
136 function execute()
137 {
138 $this->ClearElementsList();
139 $this->GenHeader();
140 }
143 function setEntries($list)
144 {
145 /********************
146 Variable init
147 ********************/
149 /* Create links */
150 $editlink = "<a href='?plug=".$_GET['plug']."&id=%s&act=edit_entry'>%s</a>";
151 $userimg = "<img class='center' src='plugins/groups/images/groups.png' alt='User' title='%s'>";
152 $mimeimg = "<img class='center' src='plugins/goto/images/select_mimetype.png' alt='A' title='"._("Mime type")."'>";
153 $empty = "<img class='center' src='images/empty.png' style='width:16px;height:16px;' alt=''>";
155 /* set Page header */
156 $action_col_size = 80;
157 if($this->parent->snapshotEnabled()){
158 $action_col_size += 38;
159 }
161 /********************
162 Attach objects
163 ********************/
165 foreach($list as $key => $val){
167 /* Check FAI state
168 */
169 $FAIstate = $val['FAIstate'][0];
171 $ui = get_userinfo();
172 $acl = $ui->get_permissions($val['dn'],"mimetypes/mimetype");
173 $acl_all = $ui->has_complete_category_acls($val['dn'],"mimetypes") ;
175 $action = "";
177 /* Add copy & cut functionality */
178 if(!preg_match("/freeze/i",$FAIstate)){
179 $action.= $this->parent->get_copypaste_action($val['dn'],"mimetypes","mimetype");
180 }else{
181 $action.= "<img src='images/empty.png' class='center' alt=''> ";
182 $action.= "<img src='images/empty.png' class='center' alt=''> ";
183 }
185 $action.= "<input class='center' type='image'
186 src='images/lists/edit.png' alt='"._("edit")."' name='mime_edit_%KEY%' title='"._("Edit this entry")."'>";
188 /* Add snapshot icon */
189 if(!preg_match("/freeze/i",$FAIstate)){
190 $action.= $this->parent->get_snapshot_action($val['dn'],$this->module);
191 }else{
192 $action.= "<img src='images/empty.png' class='center' alt=''> ";
193 $action.= "<img src='images/empty.png' class='center' alt=''> ";
194 }
196 /* Add delete button */
197 if(preg_match("/freeze/i",$FAIstate)){
198 $action .= "<img src='plugins/goto/images/freeze.png' class='center' alt='!' title='"._("Freezed")."'>";
199 }elseif(preg_match("/d/",$acl)){
200 $action.= "<input class='center' type='image'
201 src='images/lists/trash.png' alt='"._("delete")."' name='mime_del_%KEY%' title='"._("Delete this entry")."'>";
202 }else{
203 $action.= "<img src='images/empty.png' alt=' ' class='center'>";
204 }
206 $title = "title='".preg_replace('/ /', ' ', @LDAP::fix($val['dn']))."'";
208 if(!isset($val['description'][0])){
209 $desc = "";
210 }else{
211 $desc = " - [ ".$val['description'][0]." ]";
212 }
214 /* Cutted objects should be displayed in light grey */
215 $display = $val['cn'][0].$desc;
216 if($this->parent->CopyPasteHandler){
217 foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
218 if($queue_data['dn'] == $val['dn']) {
219 $display = "<font color='#999999'>".$display."</font>";
220 break;
221 }
222 }
223 }
226 /* Create each field */
227 $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
228 "attach" => "style='width:20px;'");
229 $field1 = array("string" => sprintf($mimeimg,$val['dn']), "attach" => "style='text-align:center;width:20px;'");
230 $field2 = array("string" => sprintf($editlink,$key,$display), "attach" => "style='' ".$title);
231 $field3 = array("string" => preg_replace("/%KEY%/", $key, $action), "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
232 $this->AddElement(array($field0,$field1,$field2,$field3));
233 }
236 /* Create summary string for list footer */
237 $num_deps=0;
238 if(!$this->SubSearch){
239 $num_deps = count($this->Added_Departments);
240 }
241 $num_objs = count($list);
243 $num_obj_str = _("Number of listed mimetypes");
244 $num_dep_str = _("Number of listed departments");
246 $str = "<img class='center' src='plugins/goto/images/select_mimetype.png'
247 title='".$num_obj_str."' alt='".$num_obj_str."'> ".$num_objs." ";
248 $str.= "<img class='center' src='images/lists/folder.png'
249 title='".$num_dep_str."' alt='".$num_dep_str."'> ".$num_deps." ";
251 $this->set_List_Bottom_Info($str);
252 }
254 function Save()
255 {
256 MultiSelectWindow::Save();
257 }
259 function save_object()
260 {
261 /* Save automatic created POSTs like regex, checkboxes */
262 MultiSelectWindow::save_object();
263 }
265 }
266 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
267 ?>