ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDidacticTemplateGUI Class Reference

GUI class for didactic template settings inside repository objects. More...

+ Collaboration diagram for ilDidacticTemplateGUI:

Public Member Functions

 __construct (object $a_parent_obj, int $requested_template_id=0)
 
 getParentObject ()
 
 executeCommand ()
 
 appendToolbarSwitch (ilToolbarGUI $toolbar, string $a_obj_type, int $a_ref_id)
 

Protected Member Functions

 initTemplateIdFromPost ()
 
 confirmTemplateSwitch ()
 Show didactic template switch confirmation screen. More...
 
 cancel ()
 Return to parent gui. More...
 
 switchTemplate ()
 

Private Attributes

object $parent_object
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
int $requested_template_id
 
ILIAS HTTP GlobalHttpState $http
 
ILIAS Refinery Factory $refinery
 
ilLogger $logger
 

Detailed Description

GUI class for didactic template settings inside repository objects.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

@ilCtrl_IsCalledBy ilDidacticTemplateGUI: ilPermissionGUI

Definition at line 27 of file class.ilDidacticTemplateGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateGUI::__construct ( object  $a_parent_obj,
int  $requested_template_id = 0 
)

Definition at line 39 of file class.ilDidacticTemplateGUI.php.

40 {
41 global $DIC;
42
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();
49 $this->refinery = $DIC->refinery();
50 $this->logger = $DIC->logger()->otpl();
51
52 $this->parent_object = $a_parent_obj;
53 if ($requested_template_id === 0) {
55 } else {
56 $this->requested_template_id = $requested_template_id;
57 }
58 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, $requested_template_id, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), initTemplateIdFromPost(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ILIAS\Repository\refinery(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

Member Function Documentation

◆ appendToolbarSwitch()

ilDidacticTemplateGUI::appendToolbarSwitch ( ilToolbarGUI  $toolbar,
string  $a_obj_type,
int  $a_ref_id 
)

Definition at line 92 of file class.ilDidacticTemplateGUI.php.

92 : bool
93 {
94 $tpls = ilDidacticTemplateSettings::getInstanceByObjectType($a_obj_type)->getTemplates();
95 $value = ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->getObject()->getRefId());
96
97 if (0 === $value && 0 === count($tpls)) {
98 return false;
99 }
100
101 // Add template switch
102 $toolbar->addText($this->lng->txt('didactic_selected_tpl_option'));
103
104 // Show template options
105 $options = array(0 => $this->lng->txt('didactic_default_type'));
106 $excl_tpl = false;
107
108 foreach ($tpls as $tpl) {
109 //just add if template is effective except template is already applied to this object
110 if ($tpl->isEffective($a_ref_id)) {
111 $options[$tpl->getId()] = $tpl->getPresentationTitle();
112
113 if ($tpl->isExclusive()) {
114 $excl_tpl = true;
115 }
116 }
117 }
118
119 if ($excl_tpl && $value !== 0) {
120 //remove default entry if an exclusive template exists but only if the actual entry isn't the default
121 unset($options[0]);
122 }
123
124 if (($excl_tpl && $value === 0) || !array_key_exists($value, $options)) {
125 $options[$value] = $this->lng->txt('not_available');
126 }
127
128 if (count($options) < 2) {
129 return false;
130 }
131
132 $tpl_selection = new ilSelectInputGUI(
133 $this->lng->txt('didactic_selected_tpl_option'),
134 'tplid'
135 );
136 $tpl_selection->setOptions($options);
137 $tpl_selection->setValue((string) $value);
138 $toolbar->addInputItem($tpl_selection);
139
140 // Apply templates switch
141 $toolbar->addFormButton($this->lng->txt('change'), 'confirmTemplateSwitch');
142 return true;
143 }
ilGlobalTemplateInterface $tpl
static getInstanceByObjectType(string $a_obj_type)
This class represents a selection list property in a property form.
addInputItem(ilToolbarItem $a_item, bool $a_output_label=false)
addFormButton(string $a_txt, string $a_cmd, ?int $a_acc_key=null, bool $a_primary=false, ?string $a_class=null)
addText(string $a_text)

References $tpl, ilToolbarGUI\addFormButton(), ilToolbarGUI\addInputItem(), ilToolbarGUI\addText(), ilDidacticTemplateSettings\getInstanceByObjectType(), getParentObject(), ILIAS\Repository\lng(), and ilDidacticTemplateObjSettings\lookupTemplateId().

+ Here is the call graph for this function:

◆ cancel()

ilDidacticTemplateGUI::cancel ( )
protected

Return to parent gui.

Definition at line 197 of file class.ilDidacticTemplateGUI.php.

197 : void
198 {
199 $this->ctrl->returnToParent($this);
200 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ confirmTemplateSwitch()

ilDidacticTemplateGUI::confirmTemplateSwitch ( )
protected

Show didactic template switch confirmation screen.

Definition at line 148 of file class.ilDidacticTemplateGUI.php.

148 : void
149 {
150 // Check if template is changed
151 $new_tpl_id = $this->requested_template_id;
152 if ($new_tpl_id === ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->getObject()->getRefId())) {
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);
156 }
157
158 $this->tabs->clearTargets();
159 $this->tabs->clearSubTabs();
160
161 $confirm = new ilConfirmationGUI();
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');
166
167 if ($new_tpl_id) {
168 $dtpl = new ilDidacticTemplateSetting($new_tpl_id);
169
170 $confirm->addItem(
171 'tplid',
172 (string) $new_tpl_id,
173 $dtpl->getPresentationTitle() .
174 '<div class="il_Description">' .
175 $dtpl->getPresentationDescription() . ' ' .
176 '</div>'
177 );
178 } else {
179 $confirm->addItem(
180 'tplid',
181 (string) $new_tpl_id,
182 $this->lng->txt('default') . ' ' .
183 '<div class="il_Description">' .
184 sprintf(
185 $this->lng->txt('didactic_default_type_info'),
186 $this->lng->txt('objs_' . $this->getParentObject()->getObject()->getType())
187 ) .
188 '</div>'
189 );
190 }
191 $this->tpl->setContent($confirm->getHTML());
192 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $requested_template_id, ILIAS\Repository\ctrl(), getParentObject(), ILIAS\Repository\lng(), ILIAS\Repository\logger(), ilDidacticTemplateObjSettings\lookupTemplateId(), and ILIAS\Repository\tabs().

+ Here is the call graph for this function:

◆ executeCommand()

ilDidacticTemplateGUI::executeCommand ( )

Definition at line 76 of file class.ilDidacticTemplateGUI.php.

76 : void
77 {
78 $next_class = $this->ctrl->getNextClass($this);
79 $cmd = $this->ctrl->getCmd();
80
81 switch ($next_class) {
82 default:
83 if (!$cmd) {
84 $cmd = 'overview';
85 }
86 $this->$cmd();
87
88 break;
89 }
90 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getParentObject()

ilDidacticTemplateGUI::getParentObject ( )

Definition at line 71 of file class.ilDidacticTemplateGUI.php.

71 : object
72 {
74 }

References $parent_object.

Referenced by appendToolbarSwitch(), confirmTemplateSwitch(), and switchTemplate().

+ Here is the caller graph for this function:

◆ initTemplateIdFromPost()

ilDidacticTemplateGUI::initTemplateIdFromPost ( )
protected

Definition at line 60 of file class.ilDidacticTemplateGUI.php.

61 {
62 $this->requested_template_id = 0;
63 if ($this->http->wrapper()->post()->has('tplid')) {
64 $this->requested_template_id = $this->http->wrapper()->post()->retrieve(
65 'tplid',
66 $this->refinery->kindlyTo()->int()
67 );
68 }
69 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ switchTemplate()

ilDidacticTemplateGUI::switchTemplate ( )
protected

Definition at line 202 of file class.ilDidacticTemplateGUI.php.

202 : void
203 {
204 $new_tpl_id = $this->requested_template_id;
205 ilDidacticTemplateUtils::switchTemplate($this->getParentObject()->getObject()->getRefId(), $new_tpl_id);
206 $this->tpl->setOnScreenMessage('success', $this->lng->txt('didactic_template_applied'), true);
207 $this->ctrl->returnToParent($this);
208 }
static switchTemplate(int $a_ref_id, int $a_new_tpl_id)

References $requested_template_id, ILIAS\Repository\ctrl(), getParentObject(), ILIAS\Repository\lng(), and ilDidacticTemplateUtils\switchTemplate().

+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilDidacticTemplateGUI::$ctrl
private

Definition at line 31 of file class.ilDidacticTemplateGUI.php.

◆ $http

ILIAS HTTP GlobalHttpState ilDidacticTemplateGUI::$http
private

Definition at line 35 of file class.ilDidacticTemplateGUI.php.

◆ $lng

ilLanguage ilDidacticTemplateGUI::$lng
private

Definition at line 30 of file class.ilDidacticTemplateGUI.php.

◆ $logger

ilLogger ilDidacticTemplateGUI::$logger
private

Definition at line 37 of file class.ilDidacticTemplateGUI.php.

◆ $parent_object

object ilDidacticTemplateGUI::$parent_object
private

Definition at line 29 of file class.ilDidacticTemplateGUI.php.

Referenced by getParentObject().

◆ $refinery

ILIAS Refinery Factory ilDidacticTemplateGUI::$refinery
private

Definition at line 36 of file class.ilDidacticTemplateGUI.php.

◆ $requested_template_id

int ilDidacticTemplateGUI::$requested_template_id
private

◆ $tabs

ilTabsGUI ilDidacticTemplateGUI::$tabs
private

Definition at line 32 of file class.ilDidacticTemplateGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilDidacticTemplateGUI::$tpl
private

Definition at line 33 of file class.ilDidacticTemplateGUI.php.

Referenced by appendToolbarSwitch().


The documentation for this class was generated from the following file: