ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSheetFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2005 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 //
35 //
36 // THIS CLASS IS CURRENTLY NOT IN USE
37 //
38 //
39 include_once "./classes/class.ilObjectGUI.php";
40 
42 {
47  function ilObjStyleSheetFolderGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
48  {
49  $this->type = "styf";
50  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
51  }
52 
57  function saveObject()
58  {
59  global $rbacadmin;
60 
61  // create and insert forum in objecttree
62  $newObj = parent::saveObject();
63 
64  // setup rolefolder & default local roles
65  //$roles = $newObj->initDefaultRoles();
66 
67  // ...finally assign role to creator of object
68  //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "y");
69 
70  // put here object specific stuff
71 
72  // always send a message
73  ilUtil::sendInfo($this->lng->txt("object_added"),true);
74 
75  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"")));
76  }
77 
81  function viewObject()
82  {
83  global $rbacsystem, $ilias;
84 
85  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
86  {
87  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
88  }
89 
90  include_once "./Services/Table/classes/class.ilTableGUI.php";
91 
92  // load template for table
93  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
94 
95  // load template for table content data
96  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
97 
98  $num = 0;
99 
100 // $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
101 
102  // create table
103  $tbl = new ilTableGUI();
104 
105  // title & header columns
106  $tbl->setTitle($this->object->getTitle(),"icon_styf.gif",
107  $this->lng->txt("obj_".$this->object->getType()));
108 
109  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
110 
111  // title
112  $header_names = array("", $this->lng->txt("title"),
113  $this->lng->txt("purpose"));
114  $tbl->setHeaderNames($header_names);
115 
116  $header_params = array("ref_id" => $this->ref_id);
117  $tbl->setHeaderVars(array("", "title", "purpose"), $header_params);
118  $tbl->setColumnWidth(array("0%", "80%", "20%"));
119 
120  // control
121  $tbl->setOrderColumn($_GET["sort_by"]);
122  $tbl->setOrderDirection($_GET["sort_order"]);
123  $tbl->setLimit($_GET["limit"]);
124  $tbl->setOffset($_GET["offset"]);
125 
126  // get style ids
127  $style_entries = array();
128  $styles = $this->object->getStyles();
129  foreach($styles as $style)
130  {
131  $style_entries[$style["title"].":".$style["id"]]
132  = $style;
133  }
134  ksort($style_entries);
135 
136  // todo
137  $tbl->setMaxCount(count($style_entries));
138 
139  $this->tpl->setVariable("COLUMN_COUNTS", 3);
140 
141  // footer
142  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
143 
144  $this->showActions(true);
145 
146  include_once ("./Services/Style/classes/class.ilObjStyleSheet.php");
147 
148  $fixed_style = $ilias->getSetting("fixed_content_style_id");
149  $default_style = $ilias->getSetting("default_content_style_id");
150 
151  foreach ($style_entries as $style)
152  {
153  $this->tpl->setCurrentBlock("style_row");
154 
155  // color changing
156  $css_row = ($css_row == "tblrow2")
157  ? "tblrow1"
158  : "tblrow2";
159 
160  $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
161  $this->tpl->setVariable("TXT_TITLE", $style["title"]);
162  $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
163 // $this->tpl->setVariable("LINK_STYLE",
164 // "adm_object.php?ref_id=".$_GET["ref_id"].
165 // "&obj_id=".$style["id"]);
166  $this->tpl->setVariable("ROWCOL", $css_row);
167  if ($style["id"] == $fixed_style)
168  {
169  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
170  }
171  if ($style["id"] == $default_style)
172  {
173  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
174  }
175  $this->tpl->parseCurrentBlock();
176 
177  $this->tpl->setCurrentBlock("tbl_content");
178  $this->tpl->parseCurrentBlock();
179 
180  } //if is_array
181 
182  if (count($style_entries) == 0)
183  {
184  $tbl->disable("header");
185  $tbl->disable("footer");
186 
187  $this->tpl->setCurrentBlock("text");
188  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
189  $this->tpl->parseCurrentBlock();
190 
191  $this->tpl->setCurrentBlock("tbl_content");
192  $this->tpl->parseCurrentBlock();
193  }
194 
195 
196 
197  // render table
198  $tbl->render();
199  }
200 
206  function deleteStyleObject($a_error = false)
207  {
208  if (!isset($_POST["id"]))
209  {
210  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
211  }
212 
213  // SAVE POST VALUES
214  $_SESSION["saved_post"] = $_POST["id"];
215 
216  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
217 
218  if(!$a_error)
219  {
220  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
221  }
222 
223 // $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
224 // "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway"));
225 
226  // BEGIN TABLE HEADER
227  $this->tpl->setCurrentBlock("table_header");
228  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
229  $this->tpl->parseCurrentBlock();
230 
231  // END TABLE HEADER
232 
233  // BEGIN TABLE DATA
234  $counter = 0;
235 
236  foreach ($_POST["id"] as $id)
237  {
238  $this->tpl->setCurrentBlock("table_row");
239  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
240  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
241  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
242  $this->tpl->parseCurrentBlock();
243  }
244 
245  // END TABLE DATA
246 
247  // BEGIN OPERATION_BTN
248  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
249  "cancelDelete" => $this->lng->txt("cancel"));
250  foreach ($buttons as $name => $value)
251  {
252  $this->tpl->setCurrentBlock("operation_btn");
253  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
254  $this->tpl->setVariable("BTN_NAME",$name);
255  $this->tpl->setVariable("BTN_VALUE",$value);
256  $this->tpl->parseCurrentBlock();
257  }
258  }
259 
260 
265  {
266  global $ilias;
267 
268  foreach($_SESSION["saved_post"] as $id)
269  {
270  $this->object->removeStyle($id);
271  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
272  $style_obj->delete();
273  }
274  $this->object->update();
275 
276  ilUtil::redirect($this->getReturnLocation("delete",$this->ctrl->getLinkTarget($this,"")));
277  }
278 
279 
286  {
287  global $ilias;
288 
289  if (!isset($_POST["id"]))
290  {
291  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
292  }
293  if(count($_POST["id"]) > 1)
294  {
295  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
296  }
297 
298  $ilias->deleteSetting("fixed_content_style_id");
299  $def_style = $ilias->getSetting("default_content_style_id");
300 
301  if ($def_style != $_POST["id"][0])
302  {
303  $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
304  }
305  else
306  {
307  $ilias->deleteSetting("default_content_style_id");
308  }
309 
310  ilUtil::redirect($this->ctrl->getLinkTarget($this,"view"));
311  }
312 
319  {
320  global $ilias;
321 
322  if (!isset($_POST["id"]))
323  {
324  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
325  }
326  if(count($_POST["id"]) > 1)
327  {
328  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
329  }
330 
331  $ilias->deleteSetting("default_content_style_id");
332  $fixed_style = $ilias->getSetting("fixed_content_style_id");
333  if ($fixed_style == $_POST["id"][0])
334  {
335  $ilias->deleteSetting("fixed_content_style_id");
336  }
337  else
338  {
339  $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
340  }
341  ilUtil::redirect($this->ctrl->getLinkTarget($this,"view"));
342  }
343 
344 
351  function showActions($with_subobjects = false)
352  {
353 
354  // delete
355  $this->tpl->setCurrentBlock("tbl_action_btn");
356  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
357  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
358  $this->tpl->parseCurrentBlock();
359 
360  // set global default
361  $this->tpl->setCurrentBlock("tbl_action_btn");
362  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
363  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
364  $this->tpl->parseCurrentBlock();
365 
366  // set global default
367  $this->tpl->setCurrentBlock("tbl_action_btn");
368  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
369  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
370  $this->tpl->parseCurrentBlock();
371 
372  if ($with_subobjects === true)
373  {
374  $this->showPossibleSubObjects();
375  }
376 
377  $this->tpl->setCurrentBlock("tbl_action_row");
378  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
379  $this->tpl->parseCurrentBlock();
380  }
381 
382 
388  function getTabs(&$tabs_gui)
389  {
390  // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
391  // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
392  }
393 } // END class.ilObjStyleSheetFolder
394 ?>