ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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($this->layout_object->getStyleId());
67 }
68
72 public function executeCommand()
73 {
75
76 $next_class = $this->ctrl->getNextClass($this);
77 $cmd = $this->ctrl->getCmd();
78
79 switch ($next_class) {
80 case 'ilmdeditorgui':
81 return parent::executeCommand();
82 break;
83
84 case "ilpageobjectgui":
85die("ilPageLayoutGUI forward to ilpageobjectgui error.");
86 return;
87
88 default:
89 $html = parent::executeCommand();
90 return $html;
91 }
92 }
93
94 public function create()
95 {
96 $this->properties("insert");
97 }
98
104 public function properties($a_mode = "save", $a_form = null)
105 {
106 $ilTabs = $this->tabs;
107
108 $ilTabs->setTabActive('properties');
109
110 if (!$a_form) {
111 $a_form = $this->initForm($a_mode);
112 }
113
114 $this->tpl->setContent($a_form->getHTML());
115 }
116
117 public function initForm($a_mode)
118 {
122
123 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
124 $form_gui = new ilPropertyFormGUI();
125 $form_gui->setFormAction($ilCtrl->getFormAction($this));
126 $form_gui->setTitle($lng->txt("cont_ed_pglprop"));
127
128 // title
129 $title_input = new ilTextInputGUI($lng->txt("title"), "pgl_title");
130 $title_input->setSize(50);
131 $title_input->setMaxLength(128);
132 $title_input->setValue($this->layout_object->title);
133 $title_input->setTitle($lng->txt("title"));
134 $title_input->setRequired(true);
135
136 // description
137 $desc_input = new ilTextAreaInputGUI($lng->txt("description"), "pgl_desc");
138 $desc_input->setValue($this->layout_object->description);
139 $desc_input->setRows(3);
140 $desc_input->setCols(37);
141 $desc_input->setTitle($lng->txt("description"));
142 $desc_input->setRequired(false);
143
144 // modules
145 $mods = new ilCheckboxGroupInputGUI($this->lng->txt("modules"), "module");
146 // $mods->setRequired(true);
147 $mods->setValue($this->layout_object->getModules());
148 foreach (ilPageLayout::getAvailableModules() as $mod_id => $mod_caption) {
149 $mod = new ilCheckboxOption($mod_caption, $mod_id);
150 $mods->addOption($mod);
151 }
152
153 $form_gui->addItem($title_input);
154 $form_gui->addItem($desc_input);
155 $form_gui->addItem($mods);
156
157 // style
158 $fixed_style = $ilSetting->get("fixed_content_style_id");
159 $style_id = $this->layout_object->getStyleId();
160
161 if ($fixed_style > 0) {
162 $st = new ilNonEditableValueGUI($lng->txt("cont_current_style"));
163 $st->setValue(ilObject::_lookupTitle($fixed_style) . " (" .
164 $this->lng->txt("global_fixed") . ")");
165 $form_gui->addItem($st);
166 } else {
167 include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
168 $st_styles = ilObjStyleSheet::_getStandardStyles(true, false);
169 $st_styles[0] = $this->lng->txt("default");
170 ksort($st_styles);
171 $style_sel = new ilSelectInputGUI($lng->txt("obj_sty"), "style_id");
172 $style_sel->setOptions($st_styles);
173 $style_sel->setValue($style_id);
174 $form_gui->addItem($style_sel);
175 }
176
177 $form_gui->addCommandButton("updateProperties", $lng->txt($a_mode));
178
179 return $form_gui;
180 }
181
185 public function updateProperties()
186 {
188
189 $form = $this->initForm("save");
190 if (!$form->checkInput()) {
191 $form->setValuesByPost();
192 return $this->properties("save", $form);
193 }
194
195 $this->layout_object->setTitle($form->getInput('pgl_title'));
196 $this->layout_object->setDescription($form->getInput('pgl_desc'));
197 $this->layout_object->setStyleId($form->getInput('style_id'));
198 $this->layout_object->setModules($form->getInput('module'));
199 $this->layout_object->update();
200
201 ilUtil::sendInfo($lng->txt("saved_successfully"));
202 $this->properties();
203 }
204
208 public function setTabs($a_tabs = "")
209 {
210 $ilTabs = $this->tabs;
214
215 $ilCtrl->setParameterByClass("ilpagelayoutgui", "obj_id", $this->obj->getId());
216 $ilTabs->addTarget(
217 "properties",
218 $ilCtrl->getLinkTarget($this, "properties"),
219 array("properties","", ""),
220 "",
221 ""
222 );
223 $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg.svg"));
224 $tpl->setTitle($this->layout_object->getTitle());
225 $tpl->setDescription("");
226 }
227
234 public static function getTemplateSelection(string $module)
235 {
236 global $DIC;
237 $ui = $DIC->ui();
238 $f = $ui->factory();
239 $lng = $DIC->language();
240 $arr_templates = ilPageLayout::activeLayouts(false, $module);
241 if (count($arr_templates) == 0) {
242 return null;
243 }
244 $radio = $f->input()->field()->radio($lng->txt("cont_page_template"), "");
245 $first = 0;
247 foreach ($arr_templates as $templ) {
248 if ($first == 0) {
249 $first = (int) $templ->getId();
250 }
251 $templ->readObject();
252 $radio = $radio->withOption($templ->getId(), $templ->getPreview(), $templ->getTitle());
253 }
254 $radio = $radio->withValue((int) $first);
255 return $radio;
256 }
257}
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 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 $ilCtrl
Definition: ilias.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
settings()
Definition: settings.php:2
$DIC
Definition: xapitoken.php:46