ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
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

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.

References $lng.

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

Member Function Documentation

◆ appendToolbarSwitch()

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

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

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

61  {
62  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettings.php';
63  $tpls = ilDidacticTemplateSettings::getInstanceByObjectType($a_obj_type)->getTemplates();
64 
65  if(!count($tpls))
66  {
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  foreach($tpls as $tpl)
76  {
77  $options[$tpl->getId()] = $tpl->getTitle();
78  }
79 
80  include_once './Services/Form/classes/class.ilSelectInputGUI.php';
81  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
82  $tpl_selection = new ilSelectInputGUI(
83  '',
84  'tplid'
85  );
86  $tpl_selection->setOptions($options);
87  $tpl_selection->setValue(ilDidacticTemplateObjSettings::lookupTemplateId(
88  $this->getParentObject()->object->getRefId()
89  ));
90  $toolbar->addInputItem($tpl_selection);
91 
92  // Apply templates switch
93  $toolbar->addFormButton($this->lng->txt('change'),'confirmTemplateSwitch');
94  return true;
95  }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
This class represents a selection list property in a property form.
addText($a_text)
Add text.
global $tpl
Definition: ilias.php:8
addInputItem(ilToolbarItem $a_item, $a_output_label=false)
Add input item.
if(!is_array($argv)) $options
addFormButton($a_txt, $a_cmd, $a_acc_key="", $a_primary=false, $a_class=false)
Add form button to toolbar.
static getInstanceByObjectType($a_obj_type)
Get instance by obj type.
+ Here is the call graph for this function:

◆ cancel()

ilDidacticTemplateGUI::cancel ( )
protected

Return to parent gui.

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

References $ilCtrl.

161  {
162  global $ilCtrl;
163 
164  $ilCtrl->returnToParent($this);
165  }
global $ilCtrl
Definition: ilias.php:18

◆ confirmTemplateSwitch()

ilDidacticTemplateGUI::confirmTemplateSwitch ( )
protected

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

References $_REQUEST, $GLOBALS, $ilCtrl, $tpl, getParentObject(), ilDidacticTemplateObjSettings\lookupTemplateId(), and ilUtil\sendInfo().

101  {
102  global $ilCtrl, $ilTabs, $tpl;
103 
104  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
105 
106  // Check if template is changed
107  $new_tpl_id = (int) $_REQUEST['tplid'];
108  if($new_tpl_id == ilDidacticTemplateObjSettings::lookupTemplateId($this->getParentObject()->object->getRefId()))
109  {
110  $GLOBALS['ilLog']->write(__METHOD__.': Template id: '.$new_tpl_id);
111  ilUtil::sendInfo($this->lng->txt('didactic_not_changed'),true);
112  $ilCtrl->returnToParent($this);
113  }
114 
115  $ilTabs->clearTargets();
116  $ilTabs->clearSubTabs();
117 
118  include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
119  $confirm = new ilConfirmationGUI();
120  $confirm->setFormAction($ilCtrl->getFormAction($this));
121  $confirm->setHeaderText($this->lng->txt('didactic_confirm_apply_new_template'));
122  $confirm->setConfirm($this->lng->txt('apply'), 'switchTemplate');
123  $confirm->setCancel($this->lng->txt('cancel'), 'cancel');
124 
125  if($new_tpl_id)
126  {
127  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSetting.php';
128  $dtpl = new ilDidacticTemplateSetting($new_tpl_id);
129 
130  $confirm->addItem(
131  'tplid',
132  $new_tpl_id,
133  $dtpl->getTitle().
134  '<div class="il_Description">'.
135  $dtpl->getDescription().' '.
136  '</div>'
137  );
138  }
139  else
140  {
141  $confirm->addItem(
142  'tplid',
143  $new_tpl_id,
144  $this->lng->txt('default').' '.
145  '<div class="il_Description">'.
146  sprintf(
147  $this->lng->txt('didactic_default_type_info'),
148  $this->lng->txt('objs_'.$this->getParentObject()->object->getType())
149  ).
150  '</div>'
151  );
152 
153  }
154  $tpl->setContent($confirm->getHTML());
155  }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$GLOBALS['ct_recipient']
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
Confirmation screen class.
+ Here is the call graph for this function:

◆ executeCommand()

ilDidacticTemplateGUI::executeCommand ( )

Execute command.

Returns
<type>

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

References $cmd, and $ilCtrl.

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
global $ilCtrl
Definition: ilias.php:18

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

References $_REQUEST, $ilCtrl, ilDidacticTemplateObjSettings\assignTemplate(), ilDidacticTemplateActionFactory\getActionsByTemplateId(), getParentObject(), ilDidacticTemplateObjSettings\lookupTemplateId(), and ilUtil\sendSuccess().

171  {
172  global $ilCtrl;
173 
174  $new_tpl_id = (int) $_REQUEST['tplid'];
175 
176  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateObjSettings.php';
178  $this->getParentObject()->object->getRefId()
179  );
180 
181  // Revert current template
182  if($current_tpl_id)
183  {
184  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
185  foreach(ilDidacticTemplateActionFactory::getActionsByTemplateId($current_tpl_id) as $action)
186  {
187  $action->setRefId($this->getParentObject()->object->getRefId());
188  $action->revert();
189  }
190  }
191  if($new_tpl_id)
192  {
193  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateActionFactory.php';
194  foreach(ilDidacticTemplateActionFactory::getActionsByTemplateId($new_tpl_id) as $action)
195  {
196  $action->setRefId($this->getParentObject()->object->getRefId());
197  $action->apply();
198  }
199  }
200 
201  // Assign template id to object
203  $this->getParentObject()->object->getRefId(),
204  $this->getParentObject()->object->getId(),
205  $new_tpl_id
206  );
207 
208  ilUtil::sendSuccess($this->lng->txt('didactic_template_applied'),true);
209  $ilCtrl->returnToParent($this);
210  }
static lookupTemplateId($a_ref_id)
Lookup template id ilDB $ilDB.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
global $ilCtrl
Definition: ilias.php:18
static assignTemplate($a_ref_id, $a_obj_id, $a_tpl_id)
Assign template to object ilDB $ilDB.
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7
static getActionsByTemplateId($a_tpl_id)
Get actions of one template.
+ 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: