ILIAS  Release_4_1_x_branch Revision 61804
 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  // put here object specific stuff
65 
66  // always send a message
67  ilUtil::sendInfo($this->lng->txt("object_added"),true);
68 
69  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"","",false,false)));
70  }
71 
75  function viewObject()
76  {
77  global $rbacsystem, $ilias;
78 
79  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
80  {
81  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
82  }
83 
84  include_once "./Services/Table/classes/class.ilTableGUI.php";
85 
86  // load template for table
87  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
88 
89  // load template for table content data
90  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.styf_row.html");
91 
92  $num = 0;
93 
94 // $this->tpl->setVariable("FORMACTION", "adm_object.php?ref_id=".$this->ref_id."$obj_str&cmd=gateway");
95 
96  // create table
97  $tbl = new ilTableGUI();
98 
99  // title & header columns
100  $tbl->setTitle($this->object->getTitle(),"icon_styf.gif",
101  $this->lng->txt("obj_".$this->object->getType()));
102 
103  //$tbl->setHelp("tbl_help.php","icon_help.gif",$this->lng->txt("help"));
104 
105  // title
106  $header_names = array("", $this->lng->txt("title"),
107  $this->lng->txt("purpose"));
108  $tbl->setHeaderNames($header_names);
109 
110  $header_params = array("ref_id" => $this->ref_id);
111  $tbl->setHeaderVars(array("", "title", "purpose"), $header_params);
112  $tbl->setColumnWidth(array("0%", "80%", "20%"));
113 
114  // control
115  $tbl->setOrderColumn($_GET["sort_by"]);
116  $tbl->setOrderDirection($_GET["sort_order"]);
117  $tbl->setLimit($_GET["limit"]);
118  $tbl->setOffset($_GET["offset"]);
119 
120  // get style ids
121  $style_entries = array();
122  $styles = $this->object->getStyles();
123  foreach($styles as $style)
124  {
125  $style_entries[$style["title"].":".$style["id"]]
126  = $style;
127  }
128  ksort($style_entries);
129 
130  // todo
131  $tbl->setMaxCount(count($style_entries));
132 
133  $this->tpl->setVariable("COLUMN_COUNTS", 3);
134 
135  // footer
136  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
137 
138  $this->showActions(true);
139 
140  include_once ("./Services/Style/classes/class.ilObjStyleSheet.php");
141 
142  $fixed_style = $ilias->getSetting("fixed_content_style_id");
143  $default_style = $ilias->getSetting("default_content_style_id");
144 
145  foreach ($style_entries as $style)
146  {
147  $this->tpl->setCurrentBlock("style_row");
148 
149  // color changing
150  $css_row = ($css_row == "tblrow2")
151  ? "tblrow1"
152  : "tblrow2";
153 
154  $this->tpl->setVariable("CHECKBOX_ID", $style["id"]);
155  $this->tpl->setVariable("TXT_TITLE", $style["title"]);
156  $this->tpl->setVariable("TXT_DESC", ilObject::_lookupDescription($style["id"]));
157 // $this->tpl->setVariable("LINK_STYLE",
158 // "adm_object.php?ref_id=".$_GET["ref_id"].
159 // "&obj_id=".$style["id"]);
160  $this->tpl->setVariable("ROWCOL", $css_row);
161  if ($style["id"] == $fixed_style)
162  {
163  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_fixed"));
164  }
165  if ($style["id"] == $default_style)
166  {
167  $this->tpl->setVariable("TXT_PURPOSE", $this->lng->txt("global_default"));
168  }
169  $this->tpl->parseCurrentBlock();
170 
171  $this->tpl->setCurrentBlock("tbl_content");
172  $this->tpl->parseCurrentBlock();
173 
174  } //if is_array
175 
176  if (count($style_entries) == 0)
177  {
178  $tbl->disable("header");
179  $tbl->disable("footer");
180 
181  $this->tpl->setCurrentBlock("text");
182  $this->tpl->setVariable("TXT_CONTENT", $this->lng->txt("obj_not_found"));
183  $this->tpl->parseCurrentBlock();
184 
185  $this->tpl->setCurrentBlock("tbl_content");
186  $this->tpl->parseCurrentBlock();
187  }
188 
189 
190 
191  // render table
192  $tbl->render();
193  }
194 
200  function deleteStyleObject($a_error = false)
201  {
202  if (!isset($_POST["id"]))
203  {
204  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
205  }
206 
207  // SAVE POST VALUES
208  $_SESSION["saved_post"] = $_POST["id"];
209 
210  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html");
211 
212  if(!$a_error)
213  {
214  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
215  }
216 
217 // $this->tpl->setVariable("FORMACTION", $this->getFormAction("delete",
218 // "adm_object.php?ref_id=".$_GET["ref_id"]."&cmd=gateway"));
219 
220  // BEGIN TABLE HEADER
221  $this->tpl->setCurrentBlock("table_header");
222  $this->tpl->setVariable("TEXT", $this->lng->txt("objects"));
223  $this->tpl->parseCurrentBlock();
224 
225  // END TABLE HEADER
226 
227  // BEGIN TABLE DATA
228  $counter = 0;
229 
230  foreach ($_POST["id"] as $id)
231  {
232  $this->tpl->setCurrentBlock("table_row");
233  $this->tpl->setVariable("IMG_OBJ",ilUtil::getImagePath("icon_styf.gif"));
234  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
235  $this->tpl->setVariable("TEXT_CONTENT",ilObject::_lookupTitle($id));
236  $this->tpl->parseCurrentBlock();
237  }
238 
239  // END TABLE DATA
240 
241  // BEGIN OPERATION_BTN
242  $buttons = array("confirmedDelete" => $this->lng->txt("confirm"),
243  "cancelDelete" => $this->lng->txt("cancel"));
244  foreach ($buttons as $name => $value)
245  {
246  $this->tpl->setCurrentBlock("operation_btn");
247  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
248  $this->tpl->setVariable("BTN_NAME",$name);
249  $this->tpl->setVariable("BTN_VALUE",$value);
250  $this->tpl->parseCurrentBlock();
251  }
252  }
253 
254 
259  {
260  global $ilias;
261 
262  foreach($_SESSION["saved_post"] as $id)
263  {
264  $this->object->removeStyle($id);
265  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
266  $style_obj->delete();
267  }
268  $this->object->update();
269 
270  ilUtil::redirect($this->getReturnLocation("delete",$this->ctrl->getLinkTarget($this,"","",false,false)));
271  }
272 
273 
280  {
281  global $ilias;
282 
283  if (!isset($_POST["id"]))
284  {
285  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
286  }
287  if(count($_POST["id"]) > 1)
288  {
289  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
290  }
291 
292  $ilias->deleteSetting("fixed_content_style_id");
293  $def_style = $ilias->getSetting("default_content_style_id");
294 
295  if ($def_style != $_POST["id"][0])
296  {
297  $ilias->setSetting("default_content_style_id", $_POST["id"][0]);
298  }
299  else
300  {
301  $ilias->deleteSetting("default_content_style_id");
302  }
303 
304  ilUtil::redirect($this->ctrl->getLinkTarget($this,"view","",false,false));
305  }
306 
313  {
314  global $ilias;
315 
316  if (!isset($_POST["id"]))
317  {
318  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
319  }
320  if(count($_POST["id"]) > 1)
321  {
322  $this->ilias->raiseError($this->lng->txt("cont_select_max_one_item"),$this->ilias->error_obj->MESSAGE);
323  }
324 
325  $ilias->deleteSetting("default_content_style_id");
326  $fixed_style = $ilias->getSetting("fixed_content_style_id");
327  if ($fixed_style == $_POST["id"][0])
328  {
329  $ilias->deleteSetting("fixed_content_style_id");
330  }
331  else
332  {
333  $ilias->setSetting("fixed_content_style_id", $_POST["id"][0]);
334  }
335  ilUtil::redirect($this->ctrl->getLinkTarget($this,"view","",false,false));
336  }
337 
338 
345  function showActions($with_subobjects = false)
346  {
347 
348  // delete
349  $this->tpl->setCurrentBlock("tbl_action_btn");
350  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
351  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
352  $this->tpl->parseCurrentBlock();
353 
354  // set global default
355  $this->tpl->setCurrentBlock("tbl_action_btn");
356  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
357  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
358  $this->tpl->parseCurrentBlock();
359 
360  // set global default
361  $this->tpl->setCurrentBlock("tbl_action_btn");
362  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
363  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
364  $this->tpl->parseCurrentBlock();
365 
366  if ($with_subobjects === true)
367  {
368  $this->showPossibleSubObjects();
369  }
370 
371  $this->tpl->setCurrentBlock("tbl_action_row");
372  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
373  $this->tpl->parseCurrentBlock();
374  }
375 
376 
382  function getTabs(&$tabs_gui)
383  {
384  // tabs are defined manually here. The autogeneration via objects.xml will be deprecated in future
385  // for usage examples see ilObjGroupGUI or ilObjSystemFolderGUI
386  }
387 } // END class.ilObjStyleSheetFolder
388 ?>