ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjStyleSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once "./Services/Object/classes/class.ilObjectGUI.php";
5 include_once("./Services/Style/classes/class.ilPageLayout.php");
6 
18 {
19  //page_layout editing
20  var $peditor_active = false;
21  var $pg_id = null;
22 
26  function ilObjStyleSettingsGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output = true)
27  {
28  global $lng,$ilCtrl;
29 
30  $this->type = "stys";
31 
32  $cmd = $ilCtrl->getCmd();
33 
34  if ($cmd == "editPg") {
35  $this->peditor_active = true;
36  }
37 
38  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,$a_prepare_output);
39 
40  $lng->loadLanguageModule("style");
41  }
42 
46  function &executeCommand()
47  {
48  $next_class = $this->ctrl->getNextClass($this);
49  $cmd = $this->ctrl->getCmd();
50 
51  if ($next_class == "ilpagelayoutgui" || $cmd =="createPg") {
52  $this->peditor_active =true;
53  }
54 
55  $this->prepareOutput();
56 
57  switch($next_class)
58  {
59  case 'ilpermissiongui':
60  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
61  $perm_gui =& new ilPermissionGUI($this);
62  $ret =& $this->ctrl->forwardCommand($perm_gui);
63  break;
64 
65  case 'ilpagelayoutgui':
66  include_once("./Services/Style/classes/class.ilPageLayoutGUI.php");
67  $this->tpl->getStandardTemplate();
68  $this->ctrl->setReturn($this, "edit");
69  if ($this->pg_id!=null) {
70  $layout_gui =& new ilPageLayoutGUI($this->type,$this->pg_id);
71  } else {
72  $layout_gui =& new ilPageLayoutGUI($this->type,$_GET["obj_id"]);
73  }
74  $layout_gui->setTabs();
75  $layout_gui->setEditPreview(true);
76  $this->ctrl->saveParameter($this, "obj_id");
77  $ret =& $this->ctrl->forwardCommand($layout_gui);
78  $this->tpl->setContent($ret);
79  break;
80 
81  default:
82  if ($cmd == "" || $cmd == "view")
83  {
84  $cmd = "editBasicSettings";
85  }
86  $cmd .= "Object";
87  $this->$cmd();
88 
89  break;
90  }
91  return true;
92  }
93 
97  function saveObject()
98  {
99  global $rbacadmin;
100 
101  // create and insert forum in objecttree
102  $newObj = parent::saveObject();
103 
104  // put here object specific stuff
105 
106  // always send a message
107  ilUtil::sendInfo($this->lng->txt("object_added"),true);
108 
109  ilUtil::redirect($this->getReturnLocation("save",$this->ctrl->getLinkTarget($this,"","",false,false)));
110  }
111 
116  {
117  global $rbacsystem;
118 
119  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
120  {
121  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
122  }
123 
124  $this->tpl->addBlockfile("ADM_CONTENT", "style_basic_settings", "tpl.stys_basic_settings.html", "Services/Style");
125  //$this->tpl->setCurrentBlock("style_settings");
126 
127  $settings = $this->ilias->getAllSettings();
128 
129  if ($rbacsystem->checkAccess("write", $this->object->getRefId()))
130  {
131  $this->tpl->setCurrentBlock("save_but");
132  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
133  $this->tpl->parseCurrentBlock();
134  }
135 
136  $this->tpl->setVariable("FORMACTION_STYLESETTINGS", $this->ctrl->getFormAction($this));
137 
138  $this->tpl->setVariable("TXT_TREE_FRAME", $this->lng->txt("tree_frame"));
139  $this->tpl->setVariable("TXT_TREE_FRAME_INFO", $this->lng->txt("tree_frame_info"));
140  $this->tpl->setVariable("TXT_FRAME_LEFT", $this->lng->txt("tree_left"));
141  $this->tpl->setVariable("TXT_FRAME_RIGHT", $this->lng->txt("tree_right"));
142 
143  $this->tpl->setVariable("TXT_STYLE_SETTINGS", $this->lng->txt("settings"));
144  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS", $this->lng->txt("icons_in_typed_lists"));
145  $this->tpl->setVariable("TXT_ICONS_IN_HEADER", $this->lng->txt("icons_in_header"));
146  $this->tpl->setVariable("TXT_ICONS_IN_ITEM_ROWS", $this->lng->txt("icons_in_item_rows"));
147  $this->tpl->setVariable("TXT_ICONS_IN_TYPED_LISTS_INFO", $this->lng->txt("icons_in_typed_lists_info"));
148 
149  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS", $this->lng->txt("enable_custom_icons"));
150  $this->tpl->setVariable("TXT_ENABLE_CUSTOM_ICONS_INFO", $this->lng->txt("enable_custom_icons_info"));
151  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_BIG", $this->lng->txt("custom_icon_size_big"));
152  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_SMALL", $this->lng->txt("custom_icon_size_standard"));
153  $this->tpl->setVariable("TXT_CUSTOM_ICON_SIZE_TINY", $this->lng->txt("custom_icon_size_tiny"));
154  $this->tpl->setVariable("TXT_WIDTH_X_HEIGHT", $this->lng->txt("width_x_height"));
155 
156  // set current values
157  if ($settings["tree_frame"] == "right")
158  {
159  $this->tpl->setVariable("SEL_FRAME_RIGHT","selected=\"selected\"");
160  }
161  else
162  {
163  $this->tpl->setVariable("SEL_FRAME_LEFT","selected=\"selected\"");
164  }
165 
166  if ($settings["custom_icons"])
167  {
168  $this->tpl->setVariable("CHK_CUSTOM_ICONS","checked=\"checked\"");
169  }
170 /* if ($settings["icon_position_in_lists"] == "item_rows")
171  {
172  $this->tpl->setVariable("SEL_ICON_POS_ITEM_ROWS","selected=\"selected\"");
173  }
174  else
175  {
176  $this->tpl->setVariable("SEL_ICON_POS_HEADER","selected=\"selected\"");
177  }*/
178  $this->tpl->setVariable("CUST_ICON_BIG_WIDTH", $settings["custom_icon_big_width"]);
179  $this->tpl->setVariable("CUST_ICON_BIG_HEIGHT", $settings["custom_icon_big_height"]);
180  $this->tpl->setVariable("CUST_ICON_SMALL_WIDTH", $settings["custom_icon_small_width"]);
181  $this->tpl->setVariable("CUST_ICON_SMALL_HEIGHT", $settings["custom_icon_small_height"]);
182  $this->tpl->setVariable("CUST_ICON_TINY_WIDTH", $settings["custom_icon_tiny_width"]);
183  $this->tpl->setVariable("CUST_ICON_TINY_HEIGHT", $settings["custom_icon_tiny_height"]);
184 
185 // $this->tpl->parseCurrentBlock();
186  }
187 
192  {
193  $this->ilias->setSetting("tree_frame", $_POST["tree_frame"]);
194 // $this->ilias->setSetting("icon_position_in_lists", $_POST["icon_position_in_lists"]);
195  $this->ilias->setSetting("custom_icons", $_POST["custom_icons"]);
196  $this->ilias->setSetting("custom_icon_big_width", (int) $_POST["custom_icon_big_width"]);
197  $this->ilias->setSetting("custom_icon_big_height", (int) $_POST["custom_icon_big_height"]);
198  $this->ilias->setSetting("custom_icon_small_width", (int) $_POST["custom_icon_small_width"]);
199  $this->ilias->setSetting("custom_icon_small_height", (int) $_POST["custom_icon_small_height"]);
200  $this->ilias->setSetting("custom_icon_tiny_width", (int) $_POST["custom_icon_tiny_width"]);
201  $this->ilias->setSetting("custom_icon_tiny_height", (int) $_POST["custom_icon_tiny_height"]);
202  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
203  ilUtil::redirect($this->ctrl->getLinkTarget($this,"editBasicSettings","",false,false));
204  }
205 
210  {
211  global $rbacsystem, $ilias, $tpl, $ilToolbar, $ilCtrl, $lng;
212 
213  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
214  {
215  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
216  }
217 
218  // this may not be cool, if styles are organised as (independent) Service
219  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
220  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
221 
222  $from_styles = $to_styles = $data = array();
223  $styles = $this->object->getStyles();
224 
225  foreach($styles as $style)
226  {
227  $style["active"] = ilObjStyleSheet::_lookupActive($style["id"]);
228  $style["lm_nr"] = ilObjContentObject::_getNrOfAssignedLMs($style["id"]);
229  $data[$style["title"].":".$style["id"]]
230  = $style;
231  if ($style["lm_nr"] > 0)
232  {
233  $from_styles[$style["id"]] = $style["title"];
234  }
235  if ($style["active"] > 0)
236  {
237  $to_styles[$style["id"]] = $style["title"];
238  }
239  }
240 
241  // number of individual styles
242  if ($fixed_style <= 0)
243  {
244  $data[-1] =
245  array("title" => $this->lng->txt("sty_individual_styles"),
246  "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsIndividualStyles());
247  $from_styles[-1] = $this->lng->txt("sty_individual_styles");
248  }
249 
250  // number of default style (fallback default style)
251  if ($default_style <= 0 && $fixed_style <= 0)
252  {
253  $data[0] =
254  array("title" => $this->lng->txt("sty_default_style"),
255  "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsNoStyle());
256  $from_styles[0] = $this->lng->txt("sty_default_style");
257  $to_styles[0] = $this->lng->txt("sty_default_style");
258  }
259 
260  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
261  {
262  $ilToolbar->addButton($lng->txt("sty_add_content_style"),
263  $ilCtrl->getLinkTarget($this, "createStyle"));
264  $ilToolbar->addSeparator();
265  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
266 
267  // from styles selector
268  $si = new ilSelectInputGUI($lng->txt("sty_move_lm_styles").": ".$lng->txt("sty_from"), "from_style");
269  $si->setOptions($from_styles);
270  $ilToolbar->addInputItem($si, true);
271 
272  // from styles selector
273  $si = new ilSelectInputGUI($lng->txt("sty_to"), "to_style");
274  $si->setOptions($to_styles);
275  $ilToolbar->addInputItem($si, true);
276  $ilToolbar->addFormButton($lng->txt("sty_move_style"), "moveLMStyles");
277 
278  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
279  }
280 
281  include_once("./Services/Style/classes/class.ilContentStylesTableGUI.php");
282  $table = new ilContentStylesTableGUI($this, "editContentStyles", $data, $this->object);
283  $tpl->setContent($table->getHTML());
284 
285  }
286 
291  {
292  if ($_POST["from_style"] == -1)
293  {
295  return;
296  }
297 
298  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
299  ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
300  $this->ctrl->redirect($this, "editContentStyles");
301  }
302 
303 
308  {
309  include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
310  ilObjContentObject::_moveLMStyles(-1, $_GET["to_style"]);
311  $this->ctrl->redirect($this, "editContentStyles");
312  }
313 
318  {
319  global $ilCtrl, $tpl, $lng;
320 
321  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
322 
323  $ilCtrl->setParameter($this, "to_style", $_POST["to_style"]);
324 
325  $cgui = new ilConfirmationGUI();
326  $cgui->setFormAction($ilCtrl->getFormAction($this));
327  $cgui->setHeaderText($lng->txt("sty_confirm_del_ind_styles").": ".
328  sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
329  ilObject::_lookupTitle($_POST["to_style"])));
330  $cgui->setCancel($lng->txt("cancel"), "editContentStyles");
331  $cgui->setConfirm($lng->txt("ok"), "moveIndividualStyles");
332  $tpl->setContent($cgui->getHTML());
333  }
334 
339  {
340  global $rbacsystem, $ilias, $styleDefinition, $ilToolbar, $ilCtrl, $lng, $tpl;
341 
342  if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
343  {
344  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
345  }
346 
347  // toolbar
348 
349  // default skin/style
350  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
351  {
352  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
353 
354  $options = array();
355  foreach (ilStyleDefinition::getAllSkinStyles() as $st)
356  {
357  $options[$st["id"]] = $st["title"];
358  }
359 
360  // from styles selector
361  $si = new ilSelectInputGUI($lng->txt("sty_move_user_styles").": ".$lng->txt("sty_from"), "from_style");
362  $si->setOptions($options + array("other" => $lng->txt("other")));
363  $ilToolbar->addInputItem($si, true);
364 
365  // from styles selector
366  $si = new ilSelectInputGUI($lng->txt("sty_to"), "to_style");
367  $si->setOptions($options);
368  $ilToolbar->addInputItem($si, true);
369  $ilToolbar->addFormButton($lng->txt("sty_move_style"), "moveUserStyles");
370 
371  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
372  }
373 
374  include_once("./Services/Style/classes/class.ilSystemStylesTableGUI.php");
375  $tab = new ilSystemStylesTableGUI($this, "editSystemStyles");
376  $tpl->setContent($tab->getHTML());
377 
378  }
379 
380 
385  {
386  global $styleDefinition, $ilCtrl;
387 
388  // check if one style is activated
389  if (count($_POST["st_act"]) < 1)
390  {
391  $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
392  }
393 
394  //set default skin and style
395  if ($_POST["default_skin_style"] != "")
396  {
397  $sknst = explode(":", $_POST["default_skin_style"]);
398 
399  if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
400  $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
401  {
402  $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
403  $this->ilias->ini->setVariable("layout","style",$sknst[1]);
404  }
405  $this->ilias->ini->write();
406  }
407 
408  // check if a style should be deactivated, that still has
409  // a user assigned to
410  $all_styles = ilStyleDefinition::getAllSkinStyles();
411  foreach ($all_styles as $st)
412  {
413  if (!isset($_POST["st_act"][$st["id"]]))
414  {
415  if (ilObjUser::_getNumberOfUsersForStyle($st["template_id"], $st["style_id"]) > 1)
416  {
417  $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
418  }
419  else
420  {
421  ilObjStyleSettings::_deactivateStyle($st["template_id"], $st["style_id"]);
422  }
423  }
424  else
425  {
426  ilObjStyleSettings::_activateStyle($st["template_id"], $st["style_id"]);
427  }
428  }
429 
430  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
431  $ilCtrl->redirect($this , "editSystemStyles");
432  }
433 
441  {
442  global $ilCtrl, $lng;
443 
444  $to = explode(":", $_POST["to_style"]);
445 
446  if ($_POST["from_style"] != "other")
447  {
448  $from = explode(":", $_POST["from_style"]);
449  ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
450  }
451  else
452  {
453  // get all user assigned styles
454  $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
455 
456  // move users that are not assigned to
457  // currently existing style
458  foreach($all_user_styles as $style)
459  {
460  if (!in_array($style, $all_styles))
461  {
462  $style_arr = explode(":", $style);
463  ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
464  }
465  }
466  }
467 
468  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
469  $ilCtrl->redirect($this , "editSystemStyles");
470  }
471 
472 
473 
479  function deleteStyleObject($a_error = false)
480  {
481  if (!isset($_POST["id"]))
482  {
483  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
484  }
485 
486  // display confirmation message
487  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
488  $cgui = new ilConfirmationGUI();
489  $cgui->setFormAction($this->ctrl->getFormAction($this));
490  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
491  $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
492  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
493 
494  foreach ($_POST["id"] as $id)
495  {
496  $caption = ilUtil::getImageTagByType("sty", $this->tpl->tplPath).
497  " ".ilObject::_lookupTitle($id);
498 
499  $cgui->addItem("id[]", $id, $caption);
500  }
501 
502  $this->tpl->setContent($cgui->getHTML());
503  }
504 
505 
510  {
511  global $ilias;
512 
513  foreach($_POST["id"] as $id)
514  {
515  $this->object->removeStyle($id);
516  $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
517  $style_obj->delete();
518  }
519  $this->object->update();
520 
521  ilUtil::redirect($this->getReturnLocation("delete",
522  $this->ctrl->getLinkTarget($this,"editContentStyles","",false,false)));
523  }
524 
525 
530  {
531  global $ilSetting, $lng;
532 
533  if ($_GET["id"] > 0)
534  {
535  $ilSetting->delete("fixed_content_style_id");
536  $def_style = $ilSetting->get("default_content_style_id");
537 
538  if ($def_style != $_GET["id"])
539  {
540  $ilSetting->set("default_content_style_id", (int) $_GET["id"]);
541  }
542  else
543  {
544  $ilSetting->delete("default_content_style_id");
545  }
546  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
547  }
548  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
549  }
550 
555  {
556  global $ilSetting, $lng;
557 
558  if ($_GET["id"] > 0)
559  {
560  $ilSetting->delete("default_content_style_id");
561  $fixed_style = $ilSetting->get("fixed_content_style_id");
562  if ($fixed_style == (int) $_GET["id"])
563  {
564  $ilSetting->delete("fixed_content_style_id");
565  }
566  else
567  {
568  $ilSetting->set("fixed_content_style_id", (int) $_GET["id"]);
569  }
570  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
571  }
572  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
573  }
574 
575 
580  {
581  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
582  $styles = $this->object->getStyles();
583  foreach($styles as $style)
584  {
585  if ($_POST["std_".$style["id"]] == 1)
586  {
587  ilObjStyleSheet::_writeActive((int) $style["id"], 1);
588  }
589  else
590  {
591  ilObjStyleSheet::_writeActive((int) $style["id"], 0);
592  }
593  }
594  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
595  }
596 
603  function showActions($with_subobjects = false)
604  {
605 
606  // delete
607  $this->tpl->setCurrentBlock("tbl_action_btn");
608  $this->tpl->setVariable("BTN_NAME", "deleteStyle");
609  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
610  $this->tpl->parseCurrentBlock();
611 
612  // set global default
613  $this->tpl->setCurrentBlock("tbl_action_btn");
614  $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
615  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
616  $this->tpl->parseCurrentBlock();
617 
618  // set global default
619  $this->tpl->setCurrentBlock("tbl_action_btn");
620  $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
621  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
622  $this->tpl->parseCurrentBlock();
623 
624  // set global default
625  $this->tpl->setCurrentBlock("tbl_action_btn");
626  $this->tpl->setVariable("BTN_NAME", "setScope");
627  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
628  $this->tpl->parseCurrentBlock();
629 
630  // save active styles
631  $this->tpl->setCurrentBlock("tbl_action_btn");
632  $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
633  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
634  $this->tpl->parseCurrentBlock();
635 
636  if ($with_subobjects === true)
637  {
638  $this->showPossibleSubObjects();
639  }
640 
641  $this->tpl->setCurrentBlock("tbl_action_row");
642  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.png"));
643  $this->tpl->parseCurrentBlock();
644  }
645 
652  {
653  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
654  $this->ctrl->redirect($this, "editContentStyles");
655 
656  }
657 
658  function setScopeObject()
659  {
660  if ($_GET["id"] > 0)
661  {
662  include_once ("./Services/Style/classes/class.ilStyleScopeExplorer.php");
663  $exp = new ilStyleScopeExplorer("ilias.php?baseClass=ilRepositoryGUI&amp;cmd=goto");
664  $exp->setExpandTarget("ilias.php?baseClass=ilRepositoryGUI&amp;cmd=showTree");
665  $exp->setTargetGet("ref_id");
666  $exp->setFilterMode(IL_FM_POSITIVE);
667  $exp->forceExpandAll(true, false);
668  $exp->addFilter("root");
669  $exp->addFilter("cat");
670 
671  if ($_GET["expand"] == "")
672  {
673  $expanded = $this->tree->readRootId();
674  }
675  else
676  {
677  $expanded = $_GET["expand"];
678  }
679 
680  $exp->setExpand($expanded);
681 
682  // build html-output
683  $exp->setOutput(0);
684  $output = $exp->getOutput();
685  }
686 
687  $this->tpl->setVariable("ADM_CONTENT", $output);
688  }
689 
693  function saveScopeObject()
694  {
695  global $ilias;
696 
697  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
698  if ($_GET["cat"] == 0)
699  {
700  $_GET["cat"] == "";
701  }
702  ilObjStyleSheet::_writeScope($_GET["style_id"], $_GET["cat"]);
703 
704  ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
705  }
706 
707 
712  {
713  global $tpl, $lng, $ilCtrl, $ilTabs, $ilToolbar, $rbacsystem;
714 
715  $ilTabs->setTabActive('page_layouts');
716 
717  // show toolbar, if write permission is given
718  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
719  {
720  $ilToolbar->addButton($lng->txt("sty_add_pgl"),
721  $ilCtrl->getLinkTarget($this, "addPageLayout"));
722  $ilToolbar->addButton($lng->txt("sty_import_page_layout"),
723  $ilCtrl->getLinkTarget($this, "importPageLayoutForm"));
724  }
725 
726  $oa_tpl = new ilTemplate("tpl.stys_pglayout.html", true, true, "Services/Style");
727 
728  include_once("./Services/Style/classes/class.ilPageLayoutTableGUI.php");
729  $pglayout_table = new ilPageLayoutTableGUI($this, "viewPageLayouts");
730  $oa_tpl->setVariable("PGLAYOUT_TABLE", $pglayout_table->getHTML());
731  $tpl->setContent($oa_tpl->get());
732 
733  }
734 
735 
736  function activateObject($a_activate=true){
737  if (!isset($_POST["pglayout"]))
738  {
739  ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
740  } else {
741  ilUtil::sendSuccess($this->lng->txt("sty_opt_saved"),true);
742  foreach ($_POST["pglayout"] as $item)
743  {
744  $pg_layout = new ilPageLayout($item);
745  $pg_layout->activate($a_activate);
746  }
747  }
748  $this->ctrl->redirect($this, "viewPageLayouts");
749  }
750 
751  function deactivateObject(){
752  $this->activateObject(false);
753  }
754 
755 
756 
760  function deletePglObject()
761  {
762  global $ilTabs;
763 
764  if(!isset($_POST["pglayout"]))
765  {
766  $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
767  }
768 
769  $ilTabs->setTabActive('page_layouts');
770  unset($this->data);
771 
772  // display confirmation message
773  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
774  $cgui = new ilConfirmationGUI();
775  $cgui->setFormAction($this->ctrl->getFormAction($this));
776  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
777  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeletePg");
778  $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeletePg");
779 
780  foreach($_POST["pglayout"] as $id)
781  {
782  $pg_obj = new ilPageLayout($id);
783  $pg_obj->readObject();
784 
785  $caption = ilUtil::getImageTagByType("stys", $this->tpl->tplPath).
786  " ".$pg_obj->getTitle();
787 
788  $cgui->addItem("pglayout[]", $id, $caption);
789  }
790 
791  $this->tpl->setContent($cgui->getHTML());
792  }
793 
798  {
799  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
800  $this->ctrl->redirect($this, "viewPageLayouts");
801  }
802 
807  {
808  foreach ($_POST["pglayout"] as $id)
809  {
810  $pg_obj = new ilPageLayout($id);
811  $pg_obj->delete();
812  }
813 
814  $this->ctrl->redirect($this, "viewPageLayouts");
815  }
816 
817  function addPageLayoutObject($a_form = null)
818  {
819  global $ilTabs;
820 
821  $ilTabs->setTabActive('page_layouts');
822 
823  if(!$a_form)
824  {
825  $a_form = $this->initAddPageLayoutForm();
826  }
827 
828  $this->tpl->setContent($a_form->getHTML());
829  }
830 
832  {
833  global $lng, $ilCtrl;
834 
835  $lng->loadLanguageModule("content");
836 
837  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
838  $form_gui = new ilPropertyFormGUI();
839  $form_gui->setFormAction($ilCtrl->getFormAction($this));
840  $form_gui->setTitle($lng->txt("sty_create_pgl"));
841 
842  include_once("Services/Form/classes/class.ilRadioMatrixInputGUI.php");
843 
844 
845  $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
846  $title_input->setSize(50);
847  $title_input->setMaxLength(128);
848  $title_input->setValue($this->layout_object->title);
849  $title_input->setTitle($lng->txt("title"));
850  $title_input->setRequired(true);
851 
852  $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
853  $desc_input->setValue($this->layout_object->description);
854  $desc_input->setRows(3);
855  $desc_input->setCols(37);
856 
857  // special page?
858  $options = array(
859  "0" => $lng->txt("cont_layout_template"),
860  "1" => $lng->txt("cont_special_page"),
861  );
862  $si = new ilSelectInputGUI($this->lng->txt("type"), "special_page");
863  $si->setOptions($options);
864 
865  // modules
866  $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
867  // $mods->setRequired(true);
868  foreach(ilPageLayout::getAvailableModules() as $mod_id => $mod_caption)
869  {
870  $mod = new ilCheckboxOption($mod_caption, $mod_id);
871  $mods->addOption($mod);
872  }
873 
874  $ttype_input = new ilSelectInputGUI($lng->txt("sty_based_on"), "pgl_template");
875 
876  $arr_templates = ilPageLayout::getLayouts();
877  $arr_templates1 = ilPageLayout::getLayouts(false, true);
878  foreach ($arr_templates1 as $v)
879  {
880  $arr_templates[] = $v;
881  }
882 
883  $options = array();
884  $options['-1'] = $lng->txt("none");
885 
886  foreach ($arr_templates as $templ) {
887  $templ->readObject();
888  $key = $templ->getId();
889  $value = $templ->getTitle();
890  $options[$key] = $value;
891  }
892 
893  $ttype_input->setOptions($options);
894  $ttype_input->setValue(-1);
895  $ttype_input->setRequired(true);
896 
897  $desc_input->setTitle($lng->txt("description"));
898  $desc_input->setRequired(false);
899 
900  $form_gui->addItem($title_input);
901  $form_gui->addItem($desc_input);
902  $form_gui->addItem($si);
903  $form_gui->addItem($mods);
904  $form_gui->addItem($ttype_input);
905 
906 
907  $form_gui->addCommandButton("createPg", $lng->txt("save"));
908  $form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
909 
910  return $form_gui;
911  }
912 
913 
914  function createPgObject()
915  {
916  global $ilCtrl;
917 
918  $form_gui = $this->initAddPageLayoutForm();
919  if(!$form_gui->checkInput())
920  {
921  $form_gui->setValuesByPost();
922  return $this->addPageLayoutObject($form_gui);
923  }
924 
925  //create Page-Layout-Object first
926  $pg_object = new ilPageLayout();
927  $pg_object->setTitle($form_gui->getInput('pgl_title'));
928  $pg_object->setDescription($form_gui->getInput('pgl_desc'));
929  $pg_object->setSpecialPage($form_gui->getInput('special_page'));
930  $pg_object->setModules($form_gui->getInput('module'));
931  $pg_object->update();
932 
933  include_once("./Services/COPage/classes/class.ilPageObject.php");
934 
935  //create Page
936  if(!is_object($pg_content))
937  {
938  $this->pg_content =& new ilPageObject($this->type);
939  }
940 
941  $this->pg_content->setId($pg_object->getId());
942 
943  $tmpl = $form_gui->getInput('pgl_template');
944  if ($tmpl != "-1")
945  {
946  $layout_obj = new ilPageLayout($tmpl);
947  $this->pg_content->setXMLContent($layout_obj->getXMLContent());
948  $this->pg_content->create(false);
949  }
950  else
951  {
952  $this->pg_content->create(false);
953  }
954 
955  $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $pg_object->getId());
956  $ilCtrl->redirectByClass("ilpagelayoutgui", "edit");
957  }
958 
959  function cancelCreateObject() {
960  $this->viewPageLayoutsObject();
961  }
962 
963  function editPgObject()
964  {
965  global $ilCtrl, $rbacsystem;
966 
967  if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
968  {
969  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
970  }
971 
972  $ilCtrl->setCmdClass("ilpagelayoutgui");
973  $ilCtrl->setCmd("edit");
974  $this->executeCommand();
975  }
976 
977 
978  function setTabs()
979  {
980  echo "settings_setTabs";
981  }
982 
983  function getAdminTabs(&$tabs_gui)
984  {
985  $this->getTabs($tabs_gui);
986  }
987 
993  function getTabs(&$tabs_gui)
994  {
995  global $rbacsystem, $lng, $ilTabs;
996 
997  if ($this->peditor_active) {
998  $tabs_gui->setBackTarget($this->lng->txt("page_layouts"),
999  $this->ctrl->getLinkTarget($this, "viewPageLayouts"));
1000  }
1001 
1002  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()) && !$this->peditor_active)
1003  {
1004  $tabs_gui->addTarget("settings",
1005  $this->ctrl->getLinkTarget($this, "editBasicSettings"), array("editBasicSettings","", "view"), "", "");
1006 
1007  $tabs_gui->addTarget("system_styles",
1008  $this->ctrl->getLinkTarget($this, "editSystemStyles"), "editSystemStyles", "", "");
1009 
1010  $tabs_gui->addTarget("content_styles",
1011  $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
1012 
1013  $tabs_gui->addTarget("page_layouts",
1014  $this->ctrl->getLinkTarget($this, "viewPageLayouts"), "viewPageLayouts", "", "");
1015 
1016  }
1017 
1018 
1019  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()) && !$this->peditor_active)
1020  {
1021  $tabs_gui->addTarget("perm_settings",
1022  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
1023  }
1024  }
1025 
1030  {
1031  global $ilCtrl;
1032 
1033  $ilCtrl->setParameter($this, "new_type", "sty");
1034  $ilCtrl->redirect($this, "create");
1035  }
1036 
1041  {
1042  global $lng, $ilCtrl;
1043 
1044  include_once("./Services/Style/classes/class.ilPageLayout.php");
1045 
1046  if (is_array($_POST["type"]))
1047  {
1048  foreach($_POST["type"] as $id => $t)
1049  {
1050  if ($id > 0)
1051  {
1052  $l = new ilPageLayout($id);
1053  $l->readObject();
1054  $l->setSpecialPage($t);
1055  if(is_array($_POST["module"][$id]))
1056  {
1057  $l->setModules(array_keys($_POST["module"][$id]));
1058  }
1059  else
1060  {
1061  $l->setModules();
1062  }
1063  $l->update();
1064  }
1065  }
1066 
1067  ilUtil::sendSuccess($lng->txt("msg_obj_modified"));
1068  }
1069 
1070  $ilCtrl->redirect($this, "viewPageLayouts");
1071  }
1072 
1073 
1078  {
1079  include_once("./Services/Export/classes/class.ilExport.php");
1080  $exp = new ilExport();
1081 
1082  $tmpdir = ilUtil::ilTempnam();
1083  ilUtil::makeDir($tmpdir);
1084 
1085  $succ = $exp->exportEntity("pgtp", (int) $_GET["layout_id"], "4.2.0",
1086  "Services/COPage", "Title", $tmpdir);
1087 
1088  if ($succ["success"])
1089  {
1090  ilUtil::deliverFile($succ["directory"]."/".$succ["file"], $succ["file"],
1091  "", false, false, false);
1092  }
1093  if (is_file($succ["directory"]."/".$succ["file"]))
1094  {
1095  unlink($succ["directory"]."/".$succ["file"]);
1096  }
1097  if (is_dir($succ["directory"]))
1098  {
1099  unlink($succ["directory"]);
1100  }
1101  }
1102 
1107  {
1108  global $tpl, $ilTabs;
1109 
1110  $ilTabs->setTabActive('page_layouts');
1111  $form = $this->initPageLayoutImportForm();
1112  $tpl->setContent($form->getHTML());
1113  }
1114 
1118  public function initPageLayoutImportForm()
1119  {
1120  global $lng, $ilCtrl;
1121 
1122  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1123  $form = new ilPropertyFormGUI();
1124 
1125  // template file
1126  $fi = new ilFileInputGUI($lng->txt("file"), "file");
1127  $fi->setSuffixes(array("zip"));
1128  $fi->setRequired(true);
1129  $form->addItem($fi);
1130 
1131  $form->addCommandButton("importPageLayout", $lng->txt("import"));
1132  $form->addCommandButton("viewPageLayouts", $lng->txt("cancel"));
1133 
1134  $form->setTitle($lng->txt("sty_import_page_layout"));
1135  $form->setFormAction($ilCtrl->getFormAction($this));
1136 
1137  return $form;
1138  }
1139 
1143  public function importPageLayoutObject()
1144  {
1145  global $tpl, $lng, $ilCtrl, $ilTabs;
1146 
1147  $form = $this->initPageLayoutImportForm();
1148  if ($form->checkInput())
1149  {
1150  include_once("./Services/Style/classes/class.ilPageLayout.php");
1151  $pg = ilPageLayout::import($_FILES["file"]["name"], $_FILES["file"]["tmp_name"]);
1152  if ($pg > 0)
1153  {
1154  ilUtil::sendSuccess($lng->txt("sty_imported_layout"), true);
1155  }
1156  $ilCtrl->redirect($this, "viewPageLayouts");
1157  }
1158  else
1159  {
1160  $ilTabs->setTabActive('page_layouts');
1161  $form->setValuesByPost();
1162  $tpl->setContent($form->getHtml());
1163  }
1164  }
1165 
1173  {
1174  global $ilToolbar, $ilCtrl, $tpl, $lng, $rbacsystem;
1175 
1176  $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1177 
1178  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1179  {
1180  return;
1181  }
1182 
1183  $all_styles = ilStyleDefinition::getAllSkinStyles();
1184  $sel_style = $all_styles[$_GET["style_id"]];
1185 
1186  $options = array();
1187  if (is_array($sel_style["substyle"]))
1188  {
1189  foreach ($sel_style["substyle"] as $subst)
1190  {
1191  $options[$subst["id"]] = $subst["name"];
1192  }
1193  }
1194 
1195  // substyle
1196  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1197  $si = new ilSelectInputGUI($this->lng->txt("sty_substyle"), "substyle");
1198  $si->setOptions($options);
1199  $ilToolbar->addInputItem($si, true);
1200 
1201  $ilToolbar->addFormButton($lng->txt("sty_add_assignment"), "addStyleCatAssignment");
1202  $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1203 
1204  include_once("./Services/Style/classes/class.ilSysStyleCatAssignmentTableGUI.php");
1205  $tab = new ilSysStyleCatAssignmentTableGUI($this, "assignStylesToCats");
1206 
1207  $tpl->setContent($tab->getHTML());
1208  }
1209 
1210 
1218  {
1219  global $ilCtrl, $ilTabs, $lng, $tree, $tpl, $rbacsystem;
1220 
1221  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1222  {
1223  return;
1224  }
1225 
1226  $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1227  $ilCtrl->setParameter($this, "substyle", urlencode($_REQUEST["substyle"]));
1228 
1229  include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
1230  $exp = new ilSearchRootSelector(
1231  $ilCtrl->getLinkTarget($this,'addStyleCatAssignment'));
1232  $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
1233  $exp->setExpandTarget($ilCtrl->getLinkTarget($this,'addStyleCatAssignment'));
1234  $exp->setTargetClass(get_class($this));
1235  $exp->setCmd('saveStyleCatAssignment');
1236  $exp->setClickableTypes(array("cat"));
1237 
1238  // build html-output
1239  $exp->setOutput(0);
1240  $tpl->setContent($exp->getOutput());
1241  }
1242 
1243 
1251  {
1252  global $lng, $ilCtrl, $rbacsystem;
1253 
1254  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1255  {
1256  return;
1257  }
1258 
1259  $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1260 
1261  $style_arr = explode(":", $_GET["style_id"]);
1262  ilStyleDefinition::writeSystemStyleCategoryAssignment($style_arr[0], $style_arr[1],
1263  $_GET["substyle"], $_GET["root_id"]);
1264  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1265 
1266  $ilCtrl->redirect($this, "assignStylesToCats");
1267  }
1268 
1273  {
1274  global $ilCtrl, $lng, $rbacsystem;
1275 
1276  if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1277  {
1278  return;
1279  }
1280 
1281  $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1282  $style_arr = explode(":", $_GET["style_id"]);
1283  if (is_array($_POST["id"]))
1284  {
1285  foreach ($_POST["id"] as $id)
1286  {
1287  $id_arr = explode(":", $id);
1288  ilStyleDefinition::deleteSystemStyleCategoryAssignment($style_arr[0], $style_arr[1],
1289  $id_arr[0], $id_arr[1]);
1290  }
1291  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1292  }
1293 
1294  $ilCtrl->redirect($this, "assignStylesToCats");
1295  }
1296 
1297 }
1298 ?>