ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 60 of file class.ilDidacticTemplateGUI.php.

61 {
62 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
63 $tpls = ilDidacticTemplateSettings::getInstanceByObjectType($a_obj_type)->getTemplates();
64
65 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
66 $value = ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId());
67
68 if(!count($tpls) && !$value)
69 {
70 return false;
71 }
72
73 // Add template switch
74 $toolbar->addText($this->lng->txt('didactic_selected_tpl_option'));
75
76 // Show template options
77 $options = array(0 => $this->lng->txt('didactic_default_type'));
78 $excl_tpl = false;
79
80 foreach($tpls as $tpl)
81 {
82 //just add if template is effective except template is already applied to this object
83 if($tpl->isEffective($_GET['ref_id']))
84 {
85 $options[$tpl->getId()] = $tpl->getPresentationTitle();
86
87 if($tpl->isExclusive())
88 {
89 $excl_tpl = true;
90 }
91 }
92 }
93
94 if($excl_tpl && $value != 0)
95 {
96 //remove default entry if an exclusive template exists but only if the actual entry isn't the default
97 unset($options[0]);
98 }
99
100 if(!in_array($value, array_keys($options)) || ($excl_tpl && $value == 0))
101 {
102 $options[$value] = $this->lng->txt('not_available');
103 }
104
105 if(count($options) < 2)
106 {
107 return false;
108 }
109
110 include_once './Services/Form/classes/class.ilSelectInputGUI.php';
111 $tpl_selection = new ilSelectInputGUI(
112 '',
113 'tplid'
114 );
115 $tpl_selection->setOptions($options);
116 $tpl_selection->setValue($value);
117 $toolbar->addInputItem($tpl_selection);
118
119 // Apply templates switch
120 $toolbar->addFormButton($this->lng->txt('change'),'confirmTemplateSwitch');
121 return true;
122 }
global $tpl
Definition: ilias.php:8
$_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.
if(!is_array($argv)) $options

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

188 {
189 global $ilCtrl;
190
191 $ilCtrl->returnToParent($this);
192 }
global $ilCtrl
Definition: ilias.php:18

References $ilCtrl.

◆ confirmTemplateSwitch()

ilDidacticTemplateGUI::confirmTemplateSwitch ( )
protected

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

128 {
129 global $ilCtrl, $ilTabs, $tpl;
130
131 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
132
133 // Check if template is changed
134 $new_tpl_id = (int) $_REQUEST['tplid'];
135 if($new_tpl_id == ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId()))
136 {
137 ilLoggerFactory::getLogger('otpl')->debug('Template id: '.$new_tpl_id);
138 ilUtil::sendInfo($this->lng->txt('didactic_not_changed'),true);
139 $ilCtrl->returnToParent($this);
140 }
141
142 $ilTabs->clearTargets();
143 $ilTabs->clearSubTabs();
144
145 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
146 $confirm = new ilConfirmationGUI();
147 $confirm->setFormAction($ilCtrl->getFormAction($this));
148 $confirm->setHeaderText($this->lng->txt('didactic_confirm_apply_new_template'));
149 $confirm->setConfirm($this->lng->txt('apply'), 'switchTemplate');
150 $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
151
152 if($new_tpl_id)
153 {
154 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
155 $dtpl = new ilDidacticTemplateSetting($new_tpl_id);
156
157 $confirm->addItem(
158 'tplid',
159 $new_tpl_id,
160 $dtpl->getPresentationTitle().
161 '<div class="il_Description">'.
162 $dtpl->getPresentationDescription().' '.
163 '</div>'
164 );
165 }
166 else
167 {
168 $confirm->addItem(
169 'tplid',
170 $new_tpl_id,
171 $this->lng->txt('default').' '.
172 '<div class="il_Description">'.
173 sprintf(
174 $this->lng->txt('didactic_default_type_info'),
175 $this->lng->txt('objs_'.$this->getParentObject()->object->getType())
176 ).
177 '</div>'
178 );
179
180 }
181 $tpl->setContent($confirm->getHTML());
182 }
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 {
48 default:
49 if(!$cmd)
50 {
51 $cmd = 'overview';
52 }
53 $this->$cmd();
54
55 break;
56 }
57 return true;
58 }
$cmd
Definition: sahs_server.php:35

References $cmd, and $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 197 of file class.ilDidacticTemplateGUI.php.

198 {
199 global $ilCtrl;
200
201 $new_tpl_id = (int) $_REQUEST['tplid'];
202
203 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateUtils.php';
204 ilDidacticTemplateUtils::switchTemplate($this->getParentObject()->object->getRefId(), $new_tpl_id);
205
206 ilUtil::sendSuccess($this->lng->txt('didactic_template_applied'),true);
207 $ilCtrl->returnToParent($this);
208 }
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: