ILIAS  release_8 Revision v8.24
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
66
67// $this->setStyleId($this->layout_object->getStyleId());
68 }
69
70 public function executeCommand(): string
71 {
72 $next_class = $this->ctrl->getNextClass($this);
73
74 switch ($next_class) {
75 case 'ilmdeditorgui':
76 return parent::executeCommand();
77
78 default:
79 $html = parent::executeCommand();
80 return $html;
81 }
82 }
83
84 public function create(): void
85 {
86 $this->properties("insert");
87 }
88
92 public function properties(
93 string $a_mode = "save",
94 ilPropertyFormGUI $a_form = null
95 ): void {
96 $ilTabs = $this->tabs;
97
98 $ilTabs->setTabActive('properties');
99
100 if (!$a_form) {
101 $a_form = $this->initForm($a_mode);
102 }
103 $this->tpl->setContent($a_form->getHTML());
104 }
105
106 public function initForm(string $a_mode): ilPropertyFormGUI
107 {
108 $ilCtrl = $this->ctrl;
111
112 $form_gui = new ilPropertyFormGUI();
113 $form_gui->setFormAction($ilCtrl->getFormAction($this));
114 $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
115
116 // title
117 $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
118 $title_input->setSize(50);
119 $title_input->setMaxLength(128);
120 $title_input->setValue($this->layout_object->title);
121 $title_input->setTitle($lng->txt("title"));
122 $title_input->setRequired(true);
123
124 // description
125 $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
126 $desc_input->setValue($this->layout_object->description);
127 $desc_input->setRows(3);
128 $desc_input->setCols(37);
129 $desc_input->setTitle($lng->txt("description"));
130 $desc_input->setRequired(false);
131
132 // modules
133 $mods = new ilCheckboxGroupInputGUI($this->lng->txt("copg_obj_types"), "module");
134 // $mods->setRequired(true);
135 $mods->setValue($this->layout_object->getModules());
136 foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
137 $mod = new ilCheckboxOption($mod_caption, $mod_id);
138 $mods->addOption($mod);
139 }
140
141 $form_gui->addItem($title_input);
142 $form_gui->addItem($desc_input);
143 $form_gui->addItem($mods);
144
145 $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
146
147 return $form_gui;
148 }
149
150 public function updateProperties(): void
151 {
153
154 $form = $this->initForm("save");
155 if (!$form->checkInput()) {
156 $form->setValuesByPost();
157 $this->properties("save", $form);
158 return;
159 }
160
161 $this->layout_object->setTitle($form->getInput('pgl_title'));
162 $this->layout_object->setDescription($form->getInput('pgl_desc'));
163 $this->layout_object->setModules($form->getInput('module'));
164 $this->layout_object->update();
165
166 $this->tpl->setOnScreenMessage('info', $lng->txt("saved_successfully"));
167 $this->properties();
168 }
169
173 public function setTabs(ilTabsGUI $a_tabs = null): void
174 {
175 $ilTabs = $this->tabs;
176 $ilCtrl = $this->ctrl;
178
179 $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->getId());
180 $ilTabs->addTab(
181 "properties",
182 $this->lng->txt("settings"),
183 $ilCtrl->getLinkTarget($this, "properties")
184 );
185 $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
186 $tpl->setTitle($this->layout_object->getTitle());
187 $tpl->setDescription("");
188 }
189
193 public static function getTemplateSelection(string $module): ?Radio
194 {
195 global $DIC;
196 $ui = $DIC->ui();
197 $f = $ui->factory();
198 $lng = $DIC->language();
199 $arr_templates = ilPageLayout::activeLayouts($module);
200 if (count($arr_templates) == 0) {
201 return null;
202 }
203 $radio = $f->input()->field()->radio($lng->txt("cont_page_template"), "");
204 $first = 0;
206 foreach ($arr_templates as $templ) {
207 if ($first == 0) {
208 $first = $templ->getId();
209 }
210 $templ->readObject();
211 $radio = $radio->withOption($templ->getId(), $templ->getPreview(), $templ->getTitle());
212 }
213 $radio = $radio->withValue($first);
214 return $radio;
215 }
216
217 public function finishEditing(): void
218 {
219 $this->ctrl->redirectByClass("ilpagelayoutadministrationgui", "listLayouts");
220 }
221}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
properties(string $a_mode="save", ilPropertyFormGUI $a_form=null)
Edit page layout properties.
ilPageLayout $layout_object
setTabs(ilTabsGUI $a_tabs=null)
output tabs
__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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
This is what a radio-input looks like.
Definition: Radio.php:29
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
global $ilSetting
Definition: privfeed.php:17
$lng