19declare(strict_types=1);
35 private \ILIAS\HTTP\GlobalHttpState
$http;
43 $this->
ctrl = $DIC->ctrl();
44 $this->
tabs = $DIC->tabs();
45 $this->
lng = $DIC->language();
46 $this->
lng->loadLanguageModule(
'didactic');
47 $this->tpl =
$DIC->ui()->mainTemplate();
48 $this->
http = $DIC->http();
50 $this->
logger = $DIC->logger()->otpl();
52 $this->parent_object = $a_parent_obj;
62 $this->requested_template_id = 0;
63 if ($this->
http->wrapper()->post()->has(
'tplid')) {
64 $this->requested_template_id = $this->
http->wrapper()->post()->retrieve(
78 $next_class = $this->
ctrl->getNextClass($this);
79 $cmd = $this->
ctrl->getCmd();
81 switch ($next_class) {
97 if (0 === $value && 0 === count($tpls)) {
102 $toolbar->
addText($this->
lng->txt(
'didactic_selected_tpl_option'));
105 $options = array(0 => $this->
lng->txt(
'didactic_default_type'));
108 foreach ($tpls as
$tpl) {
110 if (
$tpl->isEffective($a_ref_id)) {
111 $options[
$tpl->getId()] =
$tpl->getPresentationTitle();
113 if (
$tpl->isExclusive()) {
119 if ($excl_tpl && $value !== 0) {
124 if (($excl_tpl && $value === 0) || !array_key_exists($value, $options)) {
125 $options[$value] = $this->
lng->txt(
'not_available');
128 if (count($options) < 2) {
133 $this->
lng->txt(
'didactic_selected_tpl_option'),
136 $tpl_selection->setOptions($options);
137 $tpl_selection->setValue((
string) $value);
141 $toolbar->
addFormButton($this->
lng->txt(
'change'),
'confirmTemplateSwitch');
153 $this->
logger->debug(
'Template id: ' . $new_tpl_id);
154 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'didactic_not_changed'),
true);
155 $this->
ctrl->returnToParent($this);
158 $this->
tabs->clearTargets();
159 $this->
tabs->clearSubTabs();
162 $confirm->setFormAction($this->
ctrl->getFormAction($this));
163 $confirm->setHeaderText($this->
lng->txt(
'didactic_confirm_apply_new_template'));
164 $confirm->setConfirm($this->
lng->txt(
'apply'),
'switchTemplate');
165 $confirm->setCancel($this->
lng->txt(
'cancel'),
'cancel');
172 (
string) $new_tpl_id,
173 $dtpl->getPresentationTitle() .
174 '<div class="il_Description">' .
175 $dtpl->getPresentationDescription() .
' ' .
181 (
string) $new_tpl_id,
182 $this->
lng->txt(
'default') .
' ' .
183 '<div class="il_Description">' .
185 $this->
lng->txt(
'didactic_default_type_info'),
186 $this->lng->txt(
'objs_' . $this->getParentObject()->getObject()->getType())
191 $this->tpl->setContent($confirm->getHTML());
199 $this->
ctrl->returnToParent($this);
206 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'didactic_template_applied'),
true);
207 $this->
ctrl->returnToParent($this);
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
GUI class for didactic template settings inside repository objects.
ILIAS HTTP GlobalHttpState $http
__construct(object $a_parent_obj, int $requested_template_id=0)
confirmTemplateSwitch()
Show didactic template switch confirmation screen.
ilGlobalTemplateInterface $tpl
cancel()
Return to parent gui.
ILIAS Refinery Factory $refinery
int $requested_template_id
appendToolbarSwitch(ilToolbarGUI $toolbar, string $a_obj_type, int $a_ref_id)
static lookupTemplateId(int $a_ref_id)
static getInstanceByObjectType(string $a_obj_type)
static switchTemplate(int $a_ref_id, int $a_new_tpl_id)
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static http()
Fetches the global http state from ILIAS.