ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPageLayoutGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5include_once("./Modules/Scorm2004/classes/class.ilSCORM2004Page.php");
6
18{
22 protected $tabs;
23
27 protected $settings;
28
29 protected $layout_object = null;
30
31
35 public function __construct($a_parent_type, $a_id = 0, $a_old_nr = 0, $a_prevent_get_id = false, $a_lang = "")
36 {
37 global $DIC;
38
39 $this->tpl = $DIC["tpl"];
40 $this->ctrl = $DIC->ctrl();
41 $this->tabs = $DIC->tabs();
42 $this->lng = $DIC->language();
43 $this->settings = $DIC->settings();
44 $tpl = $DIC["tpl"];
45
46 parent::__construct($a_parent_type, $a_id, $a_old_nr, $a_prevent_get_id, $a_lang);
47
48 //associated object
49 include_once("./Services/COPage/Layout/classes/class.ilPageLayout.php");
50
51 $this->layout_object = new ilPageLayout($a_id);
52 $this->layout_object->readObject();
53
54 // content style
55 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
56 $tpl->setCurrentBlock("ContentStyle");
57 $tpl->setVariable(
58 "LOCATION_CONTENT_STYLESHEET",
59 ilObjStyleSheet::getContentStylePath($this->layout_object->getStyleId())
60 );
61 $tpl->parseCurrentBlock();
62
65
66 $this->setStyleId(
68 $this->layout_object->getStyleId()
69 )
70 );
71 }
72
76 public function executeCommand()
77 {
78 $ilCtrl = $this->ctrl;
79
80 $next_class = $this->ctrl->getNextClass($this);
81 $cmd = $this->ctrl->getCmd();
82
83 switch ($next_class) {
84 case 'ilmdeditorgui':
85 return parent::executeCommand();
86 break;
87
88 case "ilpageobjectgui":
89die("ilPageLayoutGUI forward to ilpageobjectgui error.");
90 return;
91
92 default:
93 $html = parent::executeCommand();
94 return $html;
95 }
96 }
97
98 public function create()
99 {
100 $this->properties("insert");
101 }
102
108 public function properties($a_mode = "save", $a_form = null)
109 {
110 $ilTabs = $this->tabs;
111
112 $ilTabs->setTabActive('properties');
113
114 if (!$a_form) {
115 $a_form = $this->initForm($a_mode);
116 }
117
118 $this->tpl->setContent($a_form->getHTML());
119 }
120
121 public function initForm($a_mode)
122 {
123 $ilCtrl = $this->ctrl;
126
127 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
128 $form_gui = new ilPropertyFormGUI();
129 $form_gui->setFormAction($ilCtrl->getFormAction($this));
130 $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
131
132 // title
133 $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
134 $title_input->setSize(50);
135 $title_input->setMaxLength(128);
136 $title_input->setValue($this->layout_object->title);
137 $title_input->setTitle($lng->txt("title"));
138 $title_input->setRequired(true);
139
140 // description
141 $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
142 $desc_input->setValue($this->layout_object->description);
143 $desc_input->setRows(3);
144 $desc_input->setCols(37);
145 $desc_input->setTitle($lng->txt("description"));
146 $desc_input->setRequired(false);
147
148 // modules
149 $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
150 // $mods->setRequired(true);
151 $mods->setValue($this->layout_object->getModules());
152 foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
153 $mod = new ilCheckboxOption($mod_caption, $mod_id);
154 $mods->addOption($mod);
155 }
156
157 $form_gui->addItem($title_input);
158 $form_gui->addItem($desc_input);
159 $form_gui->addItem($mods);
160
161 // style
162 $fixed_style = $ilSetting->get("fixed_content_style_id");
163 $style_id = $this->layout_object->getStyleId();
164
165 if ($fixed_style > 0) {
166 $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
167 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
168 $this->lng->txt("global_fixed") . ")");
169 $form_gui->addItem($st);
170 } else {
171 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
172 $st_styles = ilObjStyleSheet::_getStandardStyles(true, false);
173 $st_styles[0] = $this->lng->txt("default");
174 ksort($st_styles);
175 $style_sel = new ilSelectInputGUI($lng->txt("obj_sty"), "style_id");
176 $style_sel->setOptions($st_styles);
177 $style_sel->setValue($style_id);
178 $form_gui->addItem($style_sel);
179 }
180
181 $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
182
183 return $form_gui;
184 }
185
189 public function updateProperties()
190 {
192
193 $form = $this->initForm("save");
194 if (!$form->checkInput()) {
195 $form->setValuesByPost();
196 return $this->properties("save", $form);
197 }
198
199 $this->layout_object->setTitle($form->getInput('pgl_title'));
200 $this->layout_object->setDescription($form->getInput('pgl_desc'));
201 $this->layout_object->setStyleId($form->getInput('style_id'));
202 $this->layout_object->setModules($form->getInput('module'));
203 $this->layout_object->update();
204
205 ilUtil::sendInfo($lng->txt("saved_successfully"));
206 $this->properties();
207 }
208
212 public function setTabs($a_tabs = "")
213 {
214 $ilTabs = $this->tabs;
215 $ilCtrl = $this->ctrl;
218
219 $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->getId());
220 $ilTabs->addTarget(
221 "properties",
222 $ilCtrl->getLinkTarget($this, "properties"),
223 array("properties","", ""),
224 "",
225 ""
226 );
227 $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
228 $tpl->setTitle($this->layout_object->getTitle());
229 $tpl->setDescription("");
230 }
231
238 public static function getTemplateSelection(string $module)
239 {
240 global $DIC;
241 $ui = $DIC->ui();
242 $f = $ui->factory();
243 $lng = $DIC->language();
244 $arr_templates = ilPageLayout::activeLayouts(false, $module);
245 if (count($arr_templates) == 0) {
246 return null;
247 }
248 $radio = $f->input()->field()->radio($lng->txt("cont_page_template"), "");
249 $first = 0;
251 foreach ($arr_templates as $templ) {
252 if ($first == 0) {
253 $first = (int) $templ->getId();
254 }
255 $templ->readObject();
256 $radio = $radio->withOption($templ->getId(), $templ->getPreview(), $templ->getTitle());
257 }
258 $radio = $radio->withValue((int) $first);
259 return $radio;
260 }
261}
An exception for terminatinating execution or to throw for unit testing.
This class represents a property in a property form.
This class represents an option in a checkbox group.
This class represents a non editable value in a property form.
static getSyntaxStylePath()
get syntax style path
static _getStandardStyles( $a_exclude_default_style=false, $a_include_deactivated=false, $a_scope=0)
Get standard styles.
static getEffectiveContentStyleId($a_style_id, $a_type="")
Get effective Style Id.
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static getPlaceHolderStylePath()
get placeholder style path (for Page Layouts)
static _lookupTitle($a_id)
lookup object title
Class ilPageLayoutGUI GUI class.
executeCommand()
execute command
__construct($a_parent_type, $a_id=0, $a_old_nr=0, $a_prevent_get_id=false, $a_lang="")
Constructor.
properties($a_mode="save", $a_form=null)
Edit page layout properties.
setTabs($a_tabs="")
output tabs
updateProperties()
Update properties.
Class ilPageLayout.
static activeLayouts($a_special_page=false, $a_module=null)
Get active layouts.
static getAvailableModules()
Class ilPageObjectGUI.
setStyleId($a_styleid)
Set Style Id.
This class represents a property form user interface.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
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)
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2