ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDidacticTemplateGUI Class Reference

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

+ Collaboration diagram for ilDidacticTemplateGUI:

Public Member Functions

 __construct ($a_parent_obj)
 Constructor. More...
 
 getParentObject ()
 
 executeCommand ()
 Execute command. More...
 
 appendToolbarSwitch (ilToolbarGUI $toolbar, $a_obj_type, $a_ref_id)
 

Protected Member Functions

 confirmTemplateSwitch ()
 
 cancel ()
 Return to parent gui. More...
 
 switchTemplate ()
 Switch Template. More...
 

Private Attributes

 $parent_object
 
 $lng
 

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 13 of file class.ilDidacticTemplateGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateGUI::__construct (   $a_parent_obj)

Constructor.

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

22 {
23 global $lng;
24
25 $this->parent_object = $a_parent_obj;
26 $this->lng = $lng;
27 $this->lng->loadLanguageModule('didactic');
28 }

References $lng.

Member Function Documentation

◆ appendToolbarSwitch()

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

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

59 {
60 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
61 $tpls = ilDidacticTemplateSettings::getInstanceByObjectType($a_obj_type)->getTemplates();
62
63 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
64 $value = ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId());
65
66 if (!count($tpls) && !$value) {
67 return false;
68 }
69
70 // Add template switch
71 $toolbar->addText($this->lng->txt('didactic_selected_tpl_option'));
72
73 // Show template options
74 $options = array(0 => $this->lng->txt('didactic_default_type'));
75 $excl_tpl = false;
76
77 foreach ($tpls as $tpl) {
78 //just add if template is effective except template is already applied to this object
79 if ($tpl->isEffective($_GET['ref_id'])) {
80 $options[$tpl->getId()] = $tpl->getPresentationTitle();
81
82 if ($tpl->isExclusive()) {
83 $excl_tpl = true;
84 }
85 }
86 }
87
88 if ($excl_tpl && $value != 0) {
89 //remove default entry if an exclusive template exists but only if the actual entry isn't the default
90 unset($options[0]);
91 }
92
93 if (!in_array($value, array_keys($options)) || ($excl_tpl && $value == 0)) {
94 $options[$value] = $this->lng->txt('not_available');
95 }
96
97 if (count($options) < 2) {
98 return false;
99 }
100
101 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
102 $tpl_selection = new ilSelectInputGUI(
103 '',
104 'tplid'
105 );
106 $tpl_selection->setOptions($options);
107 $tpl_selection->setValue($value);
108 $toolbar->addInputItem($tpl_selection);
109
110 // Apply templates switch
111 $toolbar->addFormButton($this->lng->txt('change'), 'confirmTemplateSwitch');
112 return true;
113 }
$tpl
Definition: ilias.php:10
if(!isset( $_REQUEST[ 'ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
$_GET["client_id"]
static lookupTemplateId($a_ref_id)
Lookup template id @global ilDB $ilDB.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
This class represents a selection list property in a property form.
addInputItem(ilToolbarItem $a_item, $a_output_label=false)
Add input item.
addFormButton($a_txt, $a_cmd, $a_acc_key="", $a_primary=false, $a_class=false)
Add form button to toolbar.
addText($a_text)
Add text.

References $_GET, $options, $tpl, ilToolbarGUI\addFormButton(), ilToolbarGUI\addInputItem(), ilToolbarGUI\addText(), ilDidacticTemplateSettings\getInstanceByObjectType(), getParentObject(), and ilDidacticTemplateObjSettings\lookupTemplateId().

+ Here is the call graph for this function:

◆ cancel()

ilDidacticTemplateGUI::cancel ( )
protected

Return to parent gui.

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

174 {
175 global $ilCtrl;
176
177 $ilCtrl->returnToParent($this);
178 }
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl.

◆ confirmTemplateSwitch()

ilDidacticTemplateGUI::confirmTemplateSwitch ( )
protected

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

119 {
120 global $ilCtrl, $ilTabs, $tpl;
121
122 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
123
124 // Check if template is changed
125 $new_tpl_id = (int) $_REQUEST['tplid'];
126 if ($new_tpl_id == ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId())) {
127 ilLoggerFactory::getLogger('otpl')->debug('Template id: ' . $new_tpl_id);
128 ilUtil::sendInfo($this->lng->txt('didactic_not_changed'), true);
129 $ilCtrl->returnToParent($this);
130 }
131
132 $ilTabs->clearTargets();
133 $ilTabs->clearSubTabs();
134
135 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
136 $confirm = new ilConfirmationGUI();
137 $confirm->setFormAction($ilCtrl->getFormAction($this));
138 $confirm->setHeaderText($this->lng->txt('didactic_confirm_apply_new_template'));
139 $confirm->setConfirm($this->lng->txt('apply'), 'switchTemplate');
140 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
141
142 if ($new_tpl_id) {
143 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
144 $dtpl = new ilDidacticTemplateSetting($new_tpl_id);
145
146 $confirm->addItem(
147 'tplid',
148 $new_tpl_id,
149 $dtpl->getPresentationTitle() .
150 '<div class="il_Description">' .
151 $dtpl->getPresentationDescription() . ' ' .
152 '</div>'
153 );
154 } else {
155 $confirm->addItem(
156 'tplid',
157 $new_tpl_id,
158 $this->lng->txt('default') . ' ' .
159 '<div class="il_Description">' .
160 sprintf(
161 $this->lng->txt('didactic_default_type_info'),
162 $this->lng->txt('objs_' . $this->getParentObject()->object->getType())
163 ) .
164 '</div>'
165 );
166 }
167 $tpl->setContent($confirm->getHTML());
168 }
sprintf('%.4f', $callTime)
Confirmation screen class.
static getLogger($a_component_id)
Get component logger.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References $ilCtrl, $tpl, ilLoggerFactory\getLogger(), getParentObject(), ilDidacticTemplateObjSettings\lookupTemplateId(), ilUtil\sendInfo(), and sprintf.

+ Here is the call graph for this function:

◆ executeCommand()

ilDidacticTemplateGUI::executeCommand ( )

Execute command.

Returns
<type>

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

40 {
41 global $ilCtrl;
42
43 $next_class = $ilCtrl->getNextClass($this);
44 $cmd = $ilCtrl->getCmd();
45
46 switch ($next_class) {
47 default:
48 if (!$cmd) {
49 $cmd = 'overview';
50 }
51 $this->$cmd();
52
53 break;
54 }
55 return true;
56 }

References $ilCtrl.

◆ getParentObject()

ilDidacticTemplateGUI::getParentObject ( )

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

References $parent_object.

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

+ Here is the caller graph for this function:

◆ switchTemplate()

ilDidacticTemplateGUI::switchTemplate ( )
protected

Switch Template.

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

184 {
185 global $ilCtrl;
186
187 $new_tpl_id = (int) $_REQUEST['tplid'];
188
189 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateUtils.php';
190 ilDidacticTemplateUtils::switchTemplate($this->getParentObject()->object->getRefId(), $new_tpl_id);
191
192 ilUtil::sendSuccess($this->lng->txt('didactic_template_applied'), true);
193 $ilCtrl->returnToParent($this);
194 }
static switchTemplate($a_ref_id, $a_new_tpl_id)
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $ilCtrl, getParentObject(), ilUtil\sendSuccess(), and ilDidacticTemplateUtils\switchTemplate().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilDidacticTemplateGUI::$lng
private

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

Referenced by __construct().

◆ $parent_object

ilDidacticTemplateGUI::$parent_object
private

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

Referenced by getParentObject().


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