ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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
4include_once "./Services/Object/classes/class.ilObjectGUI.php";
5include_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 = "editSystemStyles";
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, $ilias, $tpl, $ilToolbar, $ilCtrl, $lng;
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 may not be cool, if styles are organised as (independent) Service
125 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
126 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
127
128 $from_styles = $to_styles = $data = array();
129 $styles = $this->object->getStyles();
130 foreach($styles as $style)
131 {
134 $data[$style["title"].":".$style["id"]]
135 = $style;
136 if ($style["lm_nr"] > 0)
137 {
138 $from_styles[$style["id"]] = $style["title"];
139 }
140 if ($style["active"] > 0)
141 {
142 $to_styles[$style["id"]] = $style["title"];
143 }
144 }
145
146 // number of individual styles
147 if ($fixed_style <= 0)
148 {
149 $data[-1] =
150 array("title" => $this->lng->txt("sty_individual_styles"),
151 "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsIndividualStyles());
152 $from_styles[-1] = $this->lng->txt("sty_individual_styles");
153 }
154
155 // number of default style (fallback default style)
156 if ($default_style <= 0 && $fixed_style <= 0)
157 {
158 $data[0] =
159 array("title" => $this->lng->txt("sty_default_style"),
160 "id" => 0, "lm_nr" => ilObjContentObject::_getNrLMsNoStyle());
161 $from_styles[0] = $this->lng->txt("sty_default_style");
162 $to_styles[0] = $this->lng->txt("sty_default_style");
163 }
164
165 if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
166 {
167 $ilToolbar->addButton($lng->txt("sty_add_content_style"),
168 $ilCtrl->getLinkTarget($this, "createStyle"));
169 $ilToolbar->addSeparator();
170 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
171
172 // from styles selector
173 $si = new ilSelectInputGUI($lng->txt("sty_move_lm_styles").": ".$lng->txt("sty_from"), "from_style");
174 $si->setOptions($from_styles);
175 $ilToolbar->addInputItem($si, true);
176
177 // from styles selector
178 $si = new ilSelectInputGUI($lng->txt("sty_to"), "to_style");
179 $si->setOptions($to_styles);
180 $ilToolbar->addInputItem($si, true);
181 $ilToolbar->addFormButton($lng->txt("sty_move_style"), "moveLMStyles");
182
183 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
184 }
185
186 include_once("./Services/Style/classes/class.ilContentStylesTableGUI.php");
187 $table = new ilContentStylesTableGUI($this, "editContentStyles", $data, $this->object);
188 $tpl->setContent($table->getHTML());
189
190 }
191
196 {
197 if ($_POST["from_style"] == -1)
198 {
200 return;
201 }
202
203 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
204 ilObjContentObject::_moveLMStyles($_POST["from_style"], $_POST["to_style"]);
205 $this->ctrl->redirect($this, "editContentStyles");
206 }
207
208
213 {
214 include_once("./Modules/LearningModule/classes/class.ilObjContentObject.php");
216 $this->ctrl->redirect($this, "editContentStyles");
217 }
218
223 {
224 global $ilCtrl, $tpl, $lng;
225
226 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
227
228 $ilCtrl->setParameter($this, "to_style", $_POST["to_style"]);
229
230 $cgui = new ilConfirmationGUI();
231 $cgui->setFormAction($ilCtrl->getFormAction($this));
232 $cgui->setHeaderText($lng->txt("sty_confirm_del_ind_styles").": ".
233 sprintf($this->lng->txt("sty_confirm_del_ind_styles_desc"),
234 ilObject::_lookupTitle($_POST["to_style"])));
235 $cgui->setCancel($lng->txt("cancel"), "editContentStyles");
236 $cgui->setConfirm($lng->txt("ok"), "moveIndividualStyles");
237 $tpl->setContent($cgui->getHTML());
238 }
239
244 {
245 global $rbacsystem, $ilias, $styleDefinition, $ilToolbar, $ilCtrl, $lng, $tpl;
246
247 if (!$rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
248 {
249 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
250 }
251
252 // toolbar
253
254 // default skin/style
255 if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
256 {
257 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
258
259 $options = array();
260 foreach (ilStyleDefinition::getAllSkinStyles() as $st)
261 {
262 $options[$st["id"]] = $st["title"];
263 }
264
265 // from styles selector
266 $si = new ilSelectInputGUI($lng->txt("sty_move_user_styles").": ".$lng->txt("sty_from"), "from_style");
267 $si->setOptions($options + array("other" => $lng->txt("other")));
268 $ilToolbar->addInputItem($si, true);
269
270 // from styles selector
271 $si = new ilSelectInputGUI($lng->txt("sty_to"), "to_style");
272 $si->setOptions($options);
273 $ilToolbar->addInputItem($si, true);
274 $ilToolbar->addFormButton($lng->txt("sty_move_style"), "moveUserStyles");
275
276 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
277 }
278
279 include_once("./Services/Style/classes/class.ilSystemStylesTableGUI.php");
280 $tab = new ilSystemStylesTableGUI($this, "editSystemStyles");
281 $tpl->setContent($tab->getHTML());
282
283 }
284
285
290 {
291 global $styleDefinition, $ilCtrl;
292
293 // check if one style is activated
294 if (count($_POST["st_act"]) < 1)
295 {
296 $this->ilias->raiseError($this->lng->txt("at_least_one_style"), $this->ilias->error_obj->MESSAGE);
297 }
298
299 //set default skin and style
300 if ($_POST["default_skin_style"] != "")
301 {
302 $sknst = explode(":", $_POST["default_skin_style"]);
303
304 if ($this->ilias->ini->readVariable("layout","style") != $sknst[1] ||
305 $this->ilias->ini->readVariable("layout","skin") != $sknst[0])
306 {
307 $this->ilias->ini->setVariable("layout","skin", $sknst[0]);
308 $this->ilias->ini->setVariable("layout","style",$sknst[1]);
309 }
310 $this->ilias->ini->write();
311 }
312
313 // check if a style should be deactivated, that still has
314 // a user assigned to
316 foreach ($all_styles as $st)
317 {
318 if (!isset($_POST["st_act"][$st["id"]]))
319 {
320 if (ilObjUser::_getNumberOfUsersForStyle($st["template_id"], $st["style_id"]) > 1)
321 {
322 $this->ilias->raiseError($this->lng->txt("cant_deactivate_if_users_assigned"), $this->ilias->error_obj->MESSAGE);
323 }
324 else
325 {
326 ilObjStyleSettings::_deactivateStyle($st["template_id"], $st["style_id"]);
327 }
328 }
329 else
330 {
331 ilObjStyleSettings::_activateStyle($st["template_id"], $st["style_id"]);
332 }
333 }
334
335 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
336 $ilCtrl->redirect($this , "editSystemStyles");
337 }
338
346 {
347 global $ilCtrl, $lng;
348
349 $to = explode(":", $_POST["to_style"]);
350
351 if ($_POST["from_style"] != "other")
352 {
353 $from = explode(":", $_POST["from_style"]);
354 ilObjUser::_moveUsersToStyle($from[0],$from[1],$to[0],$to[1]);
355 }
356 else
357 {
358 // get all user assigned styles
359 $all_user_styles = ilObjUser::_getAllUserAssignedStyles();
360
361 // move users that are not assigned to
362 // currently existing style
363 foreach($all_user_styles as $style)
364 {
365 if (!in_array($style, $all_styles))
366 {
367 $style_arr = explode(":", $style);
368 ilObjUser::_moveUsersToStyle($style_arr[0],$style_arr[1],$to[0],$to[1]);
369 }
370 }
371 }
372
373 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
374 $ilCtrl->redirect($this , "editSystemStyles");
375 }
376
377
378
384 function deleteStyleObject($a_error = false)
385 {
386 if (!isset($_POST["id"]))
387 {
388 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
389 }
390
391 // display confirmation message
392 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
393 $cgui = new ilConfirmationGUI();
394 $cgui->setFormAction($this->ctrl->getFormAction($this));
395 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
396 $cgui->setCancel($this->lng->txt("cancel"), "cancelDelete");
397 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDelete");
398
399 foreach ($_POST["id"] as $id)
400 {
401 $caption = ilUtil::getImageTagByType("sty", $this->tpl->tplPath).
402 " ".ilObject::_lookupTitle($id);
403
404 $cgui->addItem("id[]", $id, $caption);
405 }
406
407 $this->tpl->setContent($cgui->getHTML());
408 }
409
410
415 {
416 global $ilias;
417
418 foreach($_POST["id"] as $id)
419 {
420 $this->object->removeStyle($id);
421 $style_obj =& $ilias->obj_factory->getInstanceByObjId($id);
422 $style_obj->delete();
423 }
424 $this->object->update();
425
426 ilUtil::redirect($this->getReturnLocation("delete",
427 $this->ctrl->getLinkTarget($this,"editContentStyles","",false,false)));
428 }
429
430
435 {
436 global $ilSetting, $lng;
437
438 if ($_GET["id"] > 0)
439 {
440 $ilSetting->delete("fixed_content_style_id");
441 $def_style = $ilSetting->get("default_content_style_id");
442
443 if ($def_style != $_GET["id"])
444 {
445 $ilSetting->set("default_content_style_id", (int) $_GET["id"]);
446 }
447 else
448 {
449 $ilSetting->delete("default_content_style_id");
450 }
451 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
452 }
453 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
454 }
455
460 {
461 global $ilSetting, $lng;
462
463 if ($_GET["id"] > 0)
464 {
465 $ilSetting->delete("default_content_style_id");
466 $fixed_style = $ilSetting->get("fixed_content_style_id");
467 if ($fixed_style == (int) $_GET["id"])
468 {
469 $ilSetting->delete("fixed_content_style_id");
470 }
471 else
472 {
473 $ilSetting->set("fixed_content_style_id", (int) $_GET["id"]);
474 }
475 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
476 }
477 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
478 }
479
480
485 {
486 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
487 $styles = $this->object->getStyles();
488 foreach($styles as $style)
489 {
490 if ($_POST["std_".$style["id"]] == 1)
491 {
493 }
494 else
495 {
497 }
498 }
499 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
500 }
501
508 function showActions($with_subobjects = false)
509 {
510
511 // delete
512 $this->tpl->setCurrentBlock("tbl_action_btn");
513 $this->tpl->setVariable("BTN_NAME", "deleteStyle");
514 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
515 $this->tpl->parseCurrentBlock();
516
517 // set global default
518 $this->tpl->setCurrentBlock("tbl_action_btn");
519 $this->tpl->setVariable("BTN_NAME", "toggleGlobalDefault");
520 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalDefault"));
521 $this->tpl->parseCurrentBlock();
522
523 // set global default
524 $this->tpl->setCurrentBlock("tbl_action_btn");
525 $this->tpl->setVariable("BTN_NAME", "toggleGlobalFixed");
526 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("toggleGlobalFixed"));
527 $this->tpl->parseCurrentBlock();
528
529 // set global default
530 $this->tpl->setCurrentBlock("tbl_action_btn");
531 $this->tpl->setVariable("BTN_NAME", "setScope");
532 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_set_scope"));
533 $this->tpl->parseCurrentBlock();
534
535 // save active styles
536 $this->tpl->setCurrentBlock("tbl_action_btn");
537 $this->tpl->setVariable("BTN_NAME", "saveActiveStyles");
538 $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("sty_save_active_styles"));
539 $this->tpl->parseCurrentBlock();
540
541 if ($with_subobjects === true)
542 {
543 $this->showPossibleSubObjects();
544 }
545
546 $this->tpl->setCurrentBlock("tbl_action_row");
547 $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
548 $this->tpl->parseCurrentBlock();
549 }
550
557 {
558 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
559 $this->ctrl->redirect($this, "editContentStyles");
560
561 }
562
569 function setScopeObject()
570 {
571 global $tpl, $ilCtrl;
572
573 $ilCtrl->saveParameter($this, "id");
574 include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
575 $exp = new ilRepositorySelectorExplorerGUI($this, "setScope",
576 $this, "saveScope", "cat");
577 $exp->setTypeWhiteList(array("root", "cat"));
578 if (!$exp->handleCommand())
579 {
580 $tpl->setContent($exp->getHTML());
581 }
582 }
583
588 {
589 global $tree;
590
591 include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
592 if ($_GET["cat"] == $tree->readRootId())
593 {
594 $_GET["cat"] = "";
595 }
597
598 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
599
600 ilUtil::redirect($this->ctrl->getLinkTarget($this, "editContentStyles", "", false, false));
601 }
602
603
608 {
609 global $tpl, $lng, $ilCtrl, $ilTabs, $ilToolbar, $rbacsystem;
610
611 $ilTabs->setTabActive('page_layouts');
612
613 // show toolbar, if write permission is given
614 if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
615 {
616 $ilToolbar->addButton($lng->txt("sty_add_pgl"),
617 $ilCtrl->getLinkTarget($this, "addPageLayout"));
618 $ilToolbar->addButton($lng->txt("sty_import_page_layout"),
619 $ilCtrl->getLinkTarget($this, "importPageLayoutForm"));
620 }
621
622 $oa_tpl = new ilTemplate("tpl.stys_pglayout.html", true, true, "Services/Style");
623
624 include_once("./Services/Style/classes/class.ilPageLayoutTableGUI.php");
625 $pglayout_table = new ilPageLayoutTableGUI($this, "viewPageLayouts");
626 $oa_tpl->setVariable("PGLAYOUT_TABLE", $pglayout_table->getHTML());
627 $tpl->setContent($oa_tpl->get());
628
629 }
630
631
632 function activateObject($a_activate=true){
633 if (!isset($_POST["pglayout"]))
634 {
635 ilUtil::sendInfo($this->lng->txt("no_checkbox"),true);
636 } else {
637 ilUtil::sendSuccess($this->lng->txt("sty_opt_saved"),true);
638 foreach ($_POST["pglayout"] as $item)
639 {
640 $pg_layout = new ilPageLayout($item);
641 $pg_layout->activate($a_activate);
642 }
643 }
644 $this->ctrl->redirect($this, "viewPageLayouts");
645 }
646
648 $this->activateObject(false);
649 }
650
651
652
657 {
658 global $ilTabs;
659
660 if(!isset($_POST["pglayout"]))
661 {
662 $this->ilias->raiseError($this->lng->txt("no_checkbox"),$this->ilias->error_obj->MESSAGE);
663 }
664
665 $ilTabs->setTabActive('page_layouts');
666 unset($this->data);
667
668 // display confirmation message
669 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
670 $cgui = new ilConfirmationGUI();
671 $cgui->setFormAction($this->ctrl->getFormAction($this));
672 $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
673 $cgui->setCancel($this->lng->txt("cancel"), "cancelDeletePg");
674 $cgui->setConfirm($this->lng->txt("confirm"), "confirmedDeletePg");
675
676 foreach($_POST["pglayout"] as $id)
677 {
678 $pg_obj = new ilPageLayout($id);
679 $pg_obj->readObject();
680
681 $caption = ilUtil::getImageTagByType("stys", $this->tpl->tplPath).
682 " ".$pg_obj->getTitle();
683
684 $cgui->addItem("pglayout[]", $id, $caption);
685 }
686
687 $this->tpl->setContent($cgui->getHTML());
688 }
689
694 {
695 ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
696 $this->ctrl->redirect($this, "viewPageLayouts");
697 }
698
703 {
704 foreach ($_POST["pglayout"] as $id)
705 {
706 $pg_obj = new ilPageLayout($id);
707 $pg_obj->delete();
708 }
709
710 $this->ctrl->redirect($this, "viewPageLayouts");
711 }
712
713 function addPageLayoutObject($a_form = null)
714 {
715 global $ilTabs;
716
717 $ilTabs->setTabActive('page_layouts');
718
719 if(!$a_form)
720 {
721 $a_form = $this->initAddPageLayoutForm();
722 }
723
724 $this->tpl->setContent($a_form->getHTML());
725 }
726
728 {
729 global $lng, $ilCtrl;
730
731 $lng->loadLanguageModule("content");
732
733 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
734 $form_gui = new ilPropertyFormGUI();
735 $form_gui->setFormAction($ilCtrl->getFormAction($this));
736 $form_gui->setTitle($lng->txt("sty_create_pgl"));
737
738 $title_input = new ilTextInputGUI($lng->txt("title"),"pgl_title");
739 $title_input->setSize(50);
740 $title_input->setMaxLength(128);
741 $title_input->setValue($this->layout_object->title);
742 $title_input->setTitle($lng->txt("title"));
743 $title_input->setRequired(true);
744
745 $desc_input = new ilTextAreaInputGUI($lng->txt("description"),"pgl_desc");
746 $desc_input->setValue($this->layout_object->description);
747 $desc_input->setRows(3);
748 $desc_input->setCols(37);
749
750 // special page?
751 $options = array(
752 "0" => $lng->txt("cont_layout_template"),
753 "1" => $lng->txt("cont_special_page"),
754 );
755 $si = new ilSelectInputGUI($this->lng->txt("type"), "special_page");
756 $si->setOptions($options);
757
758 // modules
759 $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
760 // $mods->setRequired(true);
761 foreach(ilPageLayout::getAvailableModules() as $mod_id => $mod_caption)
762 {
763 $mod = new ilCheckboxOption($mod_caption, $mod_id);
764 $mods->addOption($mod);
765 }
766
767 $ttype_input = new ilSelectInputGUI($lng->txt("sty_based_on"), "pgl_template");
768
769 $arr_templates = ilPageLayout::getLayouts();
770 $arr_templates1 = ilPageLayout::getLayouts(false, true);
771 foreach ($arr_templates1 as $v)
772 {
773 $arr_templates[] = $v;
774 }
775
776 $options = array();
777 $options['-1'] = $lng->txt("none");
778
779 foreach ($arr_templates as $templ) {
780 $templ->readObject();
781 $key = $templ->getId();
782 $value = $templ->getTitle();
783 $options[$key] = $value;
784 }
785
786 $ttype_input->setOptions($options);
787 $ttype_input->setValue(-1);
788 $ttype_input->setRequired(true);
789
790 $desc_input->setTitle($lng->txt("description"));
791 $desc_input->setRequired(false);
792
793 $form_gui->addItem($title_input);
794 $form_gui->addItem($desc_input);
795 $form_gui->addItem($si);
796 $form_gui->addItem($mods);
797 $form_gui->addItem($ttype_input);
798
799
800 $form_gui->addCommandButton("createPg", $lng->txt("save"));
801 $form_gui->addCommandButton("cancelCreate", $lng->txt("cancel"));
802
803 return $form_gui;
804 }
805
806
807 function createPgObject()
808 {
809 global $ilCtrl;
810
811 $form_gui = $this->initAddPageLayoutForm();
812 if(!$form_gui->checkInput())
813 {
814 $form_gui->setValuesByPost();
815 return $this->addPageLayoutObject($form_gui);
816 }
817
818 //create Page-Layout-Object first
819 $pg_object = new ilPageLayout();
820 $pg_object->setTitle($form_gui->getInput('pgl_title'));
821 $pg_object->setDescription($form_gui->getInput('pgl_desc'));
822 $pg_object->setSpecialPage($form_gui->getInput('special_page'));
823 $pg_object->setModules($form_gui->getInput('module'));
824 $pg_object->update();
825
826 include_once("./Services/Style/classes/class.ilPageLayoutPage.php");
827
828 //create Page
829 if(!is_object($pg_content))
830 {
831 $this->pg_content = new ilPageLayoutPage();
832 }
833
834 $this->pg_content->setId($pg_object->getId());
835
836 $tmpl = $form_gui->getInput('pgl_template');
837 if ($tmpl != "-1")
838 {
839 $layout_obj = new ilPageLayout($tmpl);
840 $this->pg_content->setXMLContent($layout_obj->getXMLContent());
841 $this->pg_content->create(false);
842 }
843 else
844 {
845 $this->pg_content->create(false);
846 }
847
848 $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $pg_object->getId());
849 $ilCtrl->redirectByClass("ilpagelayoutgui", "edit");
850 }
851
853 $this->viewPageLayoutsObject();
854 }
855
856 function editPgObject()
857 {
858 global $ilCtrl, $rbacsystem;
859
860 if (!$rbacsystem->checkAccess("write",$this->object->getRefId()))
861 {
862 $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
863 }
864
865 $ilCtrl->setCmdClass("ilpagelayoutgui");
866 $ilCtrl->setCmd("edit");
867 $this->executeCommand();
868 }
869
870
871 function setTabs()
872 {
873 echo "settings_setTabs";
874 }
875
876 function getAdminTabs(&$tabs_gui)
877 {
878 $this->getTabs($tabs_gui);
879 }
880
886 function getTabs(&$tabs_gui)
887 {
888 global $rbacsystem, $lng, $ilTabs;
889
890 if ($this->peditor_active) {
891 $tabs_gui->setBackTarget($this->lng->txt("page_layouts"),
892 $this->ctrl->getLinkTarget($this, "viewPageLayouts"));
893 }
894
895 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()) && !$this->peditor_active)
896 {
897 $tabs_gui->addTarget("system_styles",
898 $this->ctrl->getLinkTarget($this, "editSystemStyles"), array("editSystemStyles", "", "view"), "", "");
899
900 $tabs_gui->addTarget("content_styles",
901 $this->ctrl->getLinkTarget($this, "editContentStyles"), "editContentStyles", "", "");
902
903 $tabs_gui->addTarget("page_layouts",
904 $this->ctrl->getLinkTarget($this, "viewPageLayouts"), "viewPageLayouts", "", "");
905
906 }
907
908
909 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()) && !$this->peditor_active)
910 {
911 $tabs_gui->addTarget("perm_settings",
912 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
913 }
914 }
915
920 {
921 global $ilCtrl;
922
923 $ilCtrl->setParameter($this, "new_type", "sty");
924 $ilCtrl->redirect($this, "create");
925 }
926
931 {
932 global $lng, $ilCtrl;
933
934 include_once("./Services/Style/classes/class.ilPageLayout.php");
935
936 if (is_array($_POST["type"]))
937 {
938 foreach($_POST["type"] as $id => $t)
939 {
940 if ($id > 0)
941 {
942 $l = new ilPageLayout($id);
943 $l->readObject();
944 $l->setSpecialPage($t);
945 if(is_array($_POST["module"][$id]))
946 {
947 $l->setModules(array_keys($_POST["module"][$id]));
948 }
949 else
950 {
951 $l->setModules();
952 }
953 $l->update();
954 }
955 }
956
957 ilUtil::sendSuccess($lng->txt("msg_obj_modified"));
958 }
959
960 $ilCtrl->redirect($this, "viewPageLayouts");
961 }
962
963
968 {
969 include_once("./Services/Export/classes/class.ilExport.php");
970 $exp = new ilExport();
971
972 $tmpdir = ilUtil::ilTempnam();
973 ilUtil::makeDir($tmpdir);
974
975 $succ = $exp->exportEntity("pgtp", (int) $_GET["layout_id"], "4.2.0",
976 "Services/COPage", "Title", $tmpdir);
977
978 if ($succ["success"])
979 {
980 ilUtil::deliverFile($succ["directory"]."/".$succ["file"], $succ["file"],
981 "", false, false, false);
982 }
983 if (is_file($succ["directory"]."/".$succ["file"]))
984 {
985 unlink($succ["directory"]."/".$succ["file"]);
986 }
987 if (is_dir($succ["directory"]))
988 {
989 unlink($succ["directory"]);
990 }
991 }
992
997 {
998 global $tpl, $ilTabs;
999
1000 $ilTabs->setTabActive('page_layouts');
1001 $form = $this->initPageLayoutImportForm();
1002 $tpl->setContent($form->getHTML());
1003 }
1004
1009 {
1010 global $lng, $ilCtrl;
1011
1012 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1013 $form = new ilPropertyFormGUI();
1014
1015 // template file
1016 $fi = new ilFileInputGUI($lng->txt("file"), "file");
1017 $fi->setSuffixes(array("zip"));
1018 $fi->setRequired(true);
1019 $form->addItem($fi);
1020
1021 $form->addCommandButton("importPageLayout", $lng->txt("import"));
1022 $form->addCommandButton("viewPageLayouts", $lng->txt("cancel"));
1023
1024 $form->setTitle($lng->txt("sty_import_page_layout"));
1025 $form->setFormAction($ilCtrl->getFormAction($this));
1026
1027 return $form;
1028 }
1029
1033 public function importPageLayoutObject()
1034 {
1035 global $tpl, $lng, $ilCtrl, $ilTabs;
1036
1037 $form = $this->initPageLayoutImportForm();
1038 if ($form->checkInput())
1039 {
1040 include_once("./Services/Style/classes/class.ilPageLayout.php");
1041 $pg = ilPageLayout::import($_FILES["file"]["name"], $_FILES["file"]["tmp_name"]);
1042 if ($pg > 0)
1043 {
1044 ilUtil::sendSuccess($lng->txt("sty_imported_layout"), true);
1045 }
1046 $ilCtrl->redirect($this, "viewPageLayouts");
1047 }
1048 else
1049 {
1050 $ilTabs->setTabActive('page_layouts');
1051 $form->setValuesByPost();
1052 $tpl->setContent($form->getHtml());
1053 }
1054 }
1055
1063 {
1064 global $ilToolbar, $ilCtrl, $tpl, $lng, $rbacsystem;
1065
1066 $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1067
1068 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1069 {
1070 return;
1071 }
1072
1074 $sel_style = $all_styles[$_GET["style_id"]];
1075
1076 $options = array();
1077 if (is_array($sel_style["substyle"]))
1078 {
1079 foreach ($sel_style["substyle"] as $subst)
1080 {
1081 $options[$subst["id"]] = $subst["name"];
1082 }
1083 }
1084
1085 // substyle
1086 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1087 $si = new ilSelectInputGUI($this->lng->txt("sty_substyle"), "substyle");
1088 $si->setOptions($options);
1089 $ilToolbar->addInputItem($si, true);
1090
1091 $ilToolbar->addFormButton($lng->txt("sty_add_assignment"), "addStyleCatAssignment");
1092 $ilToolbar->setFormAction($ilCtrl->getFormAction($this));
1093
1094 include_once("./Services/Style/classes/class.ilSysStyleCatAssignmentTableGUI.php");
1095 $tab = new ilSysStyleCatAssignmentTableGUI($this, "assignStylesToCats");
1096
1097 $tpl->setContent($tab->getHTML());
1098 }
1099
1100
1108 {
1109 global $ilCtrl, $ilTabs, $lng, $tree, $tpl, $rbacsystem;
1110
1111 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1112 {
1113 return;
1114 }
1115
1116 $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1117 $ilCtrl->setParameter($this, "substyle", urlencode($_REQUEST["substyle"]));
1118
1119 include_once 'Services/Search/classes/class.ilSearchRootSelector.php';
1120 $exp = new ilSearchRootSelector(
1121 $ilCtrl->getLinkTarget($this,'addStyleCatAssignment'));
1122 $exp->setExpand($_GET["search_root_expand"] ? $_GET["search_root_expand"] : $tree->readRootId());
1123 $exp->setExpandTarget($ilCtrl->getLinkTarget($this,'addStyleCatAssignment'));
1124 $exp->setTargetClass(get_class($this));
1125 $exp->setCmd('saveStyleCatAssignment');
1126 $exp->setClickableTypes(array("cat"));
1127
1128 // build html-output
1129 $exp->setOutput(0);
1130 $tpl->setContent($exp->getOutput());
1131 }
1132
1133
1141 {
1142 global $lng, $ilCtrl, $rbacsystem;
1143
1144 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1145 {
1146 return;
1147 }
1148
1149 $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1150
1151 $style_arr = explode(":", $_GET["style_id"]);
1152 ilStyleDefinition::writeSystemStyleCategoryAssignment($style_arr[0], $style_arr[1],
1153 $_GET["substyle"], $_GET["root_id"]);
1154 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1155
1156 $ilCtrl->redirect($this, "assignStylesToCats");
1157 }
1158
1163 {
1164 global $ilCtrl, $lng, $rbacsystem;
1165
1166 if (!$rbacsystem->checkAccess("write", $this->object->getRefId()))
1167 {
1168 return;
1169 }
1170
1171 $ilCtrl->setParameter($this, "style_id", urlencode($_GET["style_id"]));
1172 $style_arr = explode(":", $_GET["style_id"]);
1173 if (is_array($_POST["id"]))
1174 {
1175 foreach ($_POST["id"] as $id)
1176 {
1177 $id_arr = explode(":", $id);
1178 ilStyleDefinition::deleteSystemStyleCategoryAssignment($style_arr[0], $style_arr[1],
1179 $id_arr[0], $id_arr[1]);
1180 }
1181 ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
1182 }
1183
1184 $ilCtrl->redirect($this, "assignStylesToCats");
1185 }
1186
1187}
1188?>
global $l
Definition: afr.php:30
$_GET["client_id"]
This class represents a property in a property form.
This class represents an option in a checkbox group.
Confirmation screen class.
This class represents a file property in a property form.
_moveLMStyles($a_from_style, $a_to_style)
move learning modules from one style to another
_getNrOfAssignedLMs($a_style_id)
gets the number of learning modules assigned to a content style
_getNrLMsNoStyle()
get number of learning modules assigned no style
_getNrLMsIndividualStyles()
get number of learning modules with individual styles
Style settings GUI class.
cancelDeletePgObject()
cancel deletion of Page Layout
confirmedDeletePgObject()
conform deletion of Page Layout
viewPageLayoutsObject()
view list of page layouts
deleteSysStyleCatAssignmentsObject()
Delete system style to category assignments.
assignStylesToCatsObject()
Assign styles to cats.
setTabs()
set admin tabs @access public
toggleGlobalFixedObject()
Toggle global fixed style.
getAdminTabs(&$tabs_gui)
administration tabs show only permissions and trash folder
importPageLayoutFormObject()
Import page layout.
importPageLayoutObject()
Import page layout.
cancelDeleteObject()
cancel deletion of object
addStyleCatAssignmentObject()
Add style category assignment.
initPageLayoutImportForm()
Init page layout import form.
showActions($with_subobjects=false)
show possible action (form buttons)
moveIndividualStylesObject()
move all learning modules with individual styles to new style
toggleGlobalDefaultObject()
Toggle global default style.
saveScopeObject()
Save scope for style.
savePageLayoutTypesObject()
Save page layout types.
moveLMStylesObject()
move learning modules from one style to another
deleteStyleObject($a_error=false)
display deletion confirmation screen
deletePglObject()
display deletion confirmation screen
editSystemStylesObject()
edit system styles
ilObjStyleSettingsGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output=true)
Constructor.
editContentStylesObject()
view list of styles
exportLayoutObject()
Export page layout template object.
saveActiveStylesObject()
Save active styles.
saveStyleCatAssignmentObject()
Save style category assignment.
getTabs(&$tabs_gui)
get tabs @access public
saveStyleSettingsObject()
save skin and style settings
confirmedDeleteObject()
delete selected style objects
_deactivateStyle($a_skin, $a_style)
deactivate style
_activateStyle($a_skin, $a_style)
activate style
_writeActive($a_id, $a_active)
Write active flag.
_writeScope($a_id, $a_scope)
Write scope.
_lookupActive($a_id)
Lookup active flag.
_moveUsersToStyle($a_from_skin, $a_from_style, $a_to_skin, $a_to_style)
skins and styles
_getAllUserAssignedStyles()
skins and styles
_getNumberOfUsersForStyle($a_skin, $a_style)
skins and styles
Class ilObjectGUI Basic methods of all Output classes.
ilObjectGUI($a_data, $a_id=0, $a_call_by_reference=true, $a_prepare_output=true)
Constructor @access public.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
prepareOutput()
prepare output
showPossibleSubObjects()
show possible subobjects (pulldown menu)
static _lookupTitle($a_id)
lookup object title
Class ilPageLayoutGUI GUI class.
Page layout page object.
TableGUI class for page layouts.
Class ilPageLayout.
static getAvailableModules()
static import($a_filename, $a_filepath)
Import page layout.
static getLayouts($a_active=false, $a_special_page=false, $a_module=null)
Get layouts.
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
Explorer for selecting repository items.
This class represents a selection list property in a property form.
deleteSystemStyleCategoryAssignment($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
Delete category style assignment.
static getAllSkinStyles()
Get all skins/styles.
writeSystemStyleCategoryAssignment($a_skin_id, $a_style_id, $a_substyle, $a_ref_id)
Write category assignment.
TableGUI class for system style to category assignments.
TableGUI class for system styles.
special template class to simplify handling of ITX/PEAR
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImageTagByType($a_type, $a_path, $a_big=false)
Builds an html image tag TODO: function still in use, but in future use getImagePath and move HTML-Co...
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static redirect($a_script)
http redirect to other script
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
$_POST['username']
Definition: cron.php:12
$style
Definition: example_012.php:70
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)
global $ilSetting
Definition: privfeed.php:40
$cmd
Definition: sahs_server.php:35
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
if(!is_array($argv)) $options