ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPageLayoutGUI.php
Go to the documentation of this file.
1<?php
2
20
29{
30 protected ilTabsGUI $tabs;
32 protected ?ilPageLayout $layout_object = null;
33
34 public function __construct(
35 string $a_parent_type,
36 int $a_id = 0,
37 int $a_old_nr = 0,
38 bool $a_prevent_get_id = false,
39 string $a_lang = ""
40 ) {
41 global $DIC;
42
43 $this->tpl = $DIC["tpl"];
44 $this->ctrl = $DIC->ctrl();
45 $this->tabs = $DIC->tabs();
46 $this->lng = $DIC->language();
47 $this->settings = $DIC->settings();
48 $tpl = $DIC["tpl"];
49
50 parent::__construct($a_parent_type, $a_id, $a_old_nr, $a_prevent_get_id, $a_lang);
51
52 //associated object
53 $this->layout_object = new ilPageLayout($a_id);
54 $this->layout_object->readObject();
55
56 // content style
57 $tpl->setCurrentBlock("ContentStyle");
59 "LOCATION_CONTENT_STYLESHEET",
61 );
63
65
66 // $this->setStyleId($this->layout_object->getStyleId());
67 }
68
69 public function executeCommand(): string
70 {
71 $next_class = $this->ctrl->getNextClass($this);
72
73 switch ($next_class) {
74 case 'ilmdeditorgui':
75 return parent::executeCommand();
76
77 default:
78 $html = parent::executeCommand();
79 return $html;
80 }
81 }
82
83 public function create(): void
84 {
85 $this->properties("insert");
86 }
87
91 public function properties(
92 string $a_mode = "save",
93 ?ilPropertyFormGUI $a_form = null
94 ): void {
95 $ilTabs = $this->tabs;
96
97 $ilTabs->setTabActive('properties');
98
99 if (!$a_form) {
100 $a_form = $this->initForm($a_mode);
101 }
102 $this->tpl->setContent($a_form->getHTML());
103 }
104
105 public function initForm(string $a_mode): ilPropertyFormGUI
106 {
107 $ilCtrl = $this->ctrl;
109 $ilSetting = $this->settings;
110
111 $form_gui = new ilPropertyFormGUI();
112 $form_gui->setFormAction($ilCtrl->getFormAction($this));
113 $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
114
115 // title
116 $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
117 $title_input->setSize(50);
118 $title_input->setMaxLength(128);
119 $title_input->setValue($this->layout_object->title);
120 $title_input->setTitle($lng->txt("title"));
121 $title_input->setRequired(true);
122
123 // description
124 $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
125 $desc_input->setValue($this->layout_object->description);
126 $desc_input->setRows(3);
127 $desc_input->setCols(37);
128 $desc_input->setTitle($lng->txt("description"));
129 $desc_input->setRequired(false);
130
131 // modules
132 $mods = new ilCheckboxGroupInputGUI($this->lng->txt("copg_obj_types"), "module");
133 // $mods->setRequired(true);
134 $mods->setValue($this->layout_object->getModules());
135 foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
136 $mod = new ilCheckboxOption($mod_caption, $mod_id);
137 $mods->addOption($mod);
138 }
139
140 $form_gui->addItem($title_input);
141 $form_gui->addItem($desc_input);
142 $form_gui->addItem($mods);
143
144 $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
145
146 return $form_gui;
147 }
148
149 public function updateProperties(): void
150 {
152
153 $form = $this->initForm("save");
154 if (!$form->checkInput()) {
155 $form->setValuesByPost();
156 $this->properties("save", $form);
157 return;
158 }
159
160 $this->layout_object->setTitle($form->getInput('pgl_title'));
161 $this->layout_object->setDescription($form->getInput('pgl_desc'));
162 $this->layout_object->setModules($form->getInput('module'));
163 $this->layout_object->update();
164
165 $this->tpl->setOnScreenMessage('info', $lng->txt("saved_successfully"));
166 $this->properties();
167 }
168
172 public function setTabs(?ilTabsGUI $a_tabs = null): void
173 {
174 $ilTabs = $this->tabs;
175 $ilCtrl = $this->ctrl;
176 $tpl = $this->tpl;
177
178 $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->getId());
179 $ilTabs->addTab(
180 "properties",
181 $this->lng->txt("settings"),
182 $ilCtrl->getLinkTarget($this, "properties")
183 );
184 $tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_pg.svg"));
185 $tpl->setTitle($this->layout_object->getTitle());
186 $tpl->setDescription("");
187 }
188
192 public static function getTemplateSelection(string $module): ?Radio
193 {
194 global $DIC;
195 $ui = $DIC->ui();
196 $f = $ui->factory();
197 $lng = $DIC->language();
198 $arr_templates = ilPageLayout::activeLayouts($module);
199 if (count($arr_templates) == 0) {
200 return null;
201 }
202 $radio = $f->input()->field()->radio($lng->txt("cont_page_template"), "");
203 $first = 0;
205 foreach ($arr_templates as $templ) {
206 if ($first == 0) {
207 $first = $templ->getId();
208 }
209 $templ->readObject();
210 $radio = $radio->withOption($templ->getId(), $templ->getPreview(), $templ->getTitle());
211 }
212 $radio = $radio->withValue($first);
213 return $radio;
214 }
215
216 public function finishEditing(): void
217 {
218 $this->ctrl->redirectByClass("ilpagelayoutadministrationgui", "listLayouts");
219 }
220}
This class represents a property in a property form.
This class represents an option in a checkbox group.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
Class ilPageLayoutGUI GUI class.
executeCommand()
execute command
setTabs(?ilTabsGUI $a_tabs=null)
output tabs
properties(string $a_mode="save", ?ilPropertyFormGUI $a_form=null)
Edit page layout properties.
ilPageLayout $layout_object
__construct(string $a_parent_type, int $a_id=0, int $a_old_nr=0, bool $a_prevent_get_id=false, string $a_lang="")
initForm(string $a_mode)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static activeLayouts(int $a_module=0)
Get active layouts.
static getAvailableModules()
Class ilPageObjectGUI.
ilGlobalTemplateInterface $tpl
This class represents a property form user interface.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
This is what a radio-input looks like.
Definition: Radio.php:29
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $lng
Definition: privfeed.php:31
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26