ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, and $lng.

22  {
23  global $DIC;
24 
25  $lng = $DIC['lng'];
26 
27  $this->parent_object = $a_parent_obj;
28  $this->lng = $lng;
29  $this->lng->loadLanguageModule('didactic');
30  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ appendToolbarSwitch()

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

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

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

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

References $DIC, and $ilCtrl.

182  {
183  global $DIC;
184 
185  $ilCtrl = $DIC['ilCtrl'];
186 
187  $ilCtrl->returnToParent($this);
188  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ confirmTemplateSwitch()

ilDidacticTemplateGUI::confirmTemplateSwitch ( )
protected

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

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

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

◆ executeCommand()

ilDidacticTemplateGUI::executeCommand ( )

Execute command.

Returns
<type>

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

References $DIC, and $ilCtrl.

42  {
43  global $DIC;
44 
45  $ilCtrl = $DIC['ilCtrl'];
46 
47  $next_class = $ilCtrl->getNextClass($this);
48  $cmd = $ilCtrl->getCmd();
49 
50  switch ($next_class) {
51  default:
52  if (!$cmd) {
53  $cmd = 'overview';
54  }
55  $this->$cmd();
56 
57  break;
58  }
59  return true;
60  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18

◆ getParentObject()

ilDidacticTemplateGUI::getParentObject ( )

Definition at line 32 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 193 of file class.ilDidacticTemplateGUI.php.

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

194  {
195  global $DIC;
196 
197  $ilCtrl = $DIC['ilCtrl'];
198 
199  $new_tpl_id = (int) $_REQUEST['tplid'];
200 
201  include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateUtils.php';
202  ilDidacticTemplateUtils::switchTemplate($this->getParentObject()->object->getRefId(), $new_tpl_id);
203 
204  ilUtil::sendSuccess($this->lng->txt('didactic_template_applied'), true);
205  $ilCtrl->returnToParent($this);
206  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
static switchTemplate($a_ref_id, $a_new_tpl_id)
+ 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: