ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDidacticTemplateSettingsGUI Class Reference

Settings for a single didactic template. More...

+ Collaboration diagram for ilDidacticTemplateSettingsGUI:

Public Member Functions

 __construct ($a_parent_obj)
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 

Protected Member Functions

 overview ()
 Show didactic template administration. More...
 
 showImportForm (ilPropertyFormGUI $form=NULL)
 Show template import form. More...
 
 createImportForm ()
 Create template import form. More...
 
 importTemplate ()
 Import template. More...
 
 editTemplate (ilPropertyFormGUI $form=null)
 Edit template. More...
 
 updateTemplate ()
 Update template. More...
 
 initEditTemplate (ilDidacticTemplateSetting $set)
 Init edit template form. More...
 
 copyTemplate ()
 Copy on template. More...
 
 exportTemplate ()
 Export one template. More...
 
 confirmDelete ()
 Show delete confirmation screen. More...
 
 deleteTemplates ()
 Delete chosen didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl. More...
 
 activateTemplates ()
 Activate didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl. More...
 
 deactivateTemplates ()
 Activate didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl. More...
 

Private Attributes

 $parent_object
 
 $lng
 

Detailed Description

Settings for a single didactic template.

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

@ilCtrl_IsCalledBy ilDidacticTemplateSettingsGUI: ilObjRoleFolderGUI

Definition at line 13 of file class.ilDidacticTemplateSettingsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilDidacticTemplateSettingsGUI::__construct (   $a_parent_obj)

Constructor.

Definition at line 22 of file class.ilDidacticTemplateSettingsGUI.php.

23 {
24 global $lng;
25
26 $this->parent_object = $a_parent_obj;
27 $this->lng = $lng;
28 }

References $lng.

Member Function Documentation

◆ activateTemplates()

ilDidacticTemplateSettingsGUI::activateTemplates ( )
protected

Activate didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl.

Returns
void

Definition at line 414 of file class.ilDidacticTemplateSettingsGUI.php.

415 {
416 global $ilErr, $ilCtrl, $ilAccess;
417
418 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
419 {
420 $this->ctrl->redirect($this, "overview");
421 }
422 if(!$_REQUEST['tpls'])
423 {
424 ilUtil::sendFailure($this->lng->txt('select_one'));
425 return $ilCtrl->redirect($this,'overview');
426 }
427
428 foreach($_REQUEST['tpls'] as $tplid)
429 {
430 $tpl = new ilDidacticTemplateSetting($tplid);
431 $tpl->enable(true);
432 $tpl->update();
433 }
434
435 ilUtil::sendSuccess($this->lng->txt('didactic_activated_msg'),true);
436 $ilCtrl->redirect($this,'overview');
437 }
global $tpl
Definition: ilias.php:8
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
global $ilCtrl
Definition: ilias.php:18
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, $ilCtrl, $ilErr, $tpl, ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ confirmDelete()

ilDidacticTemplateSettingsGUI::confirmDelete ( )
protected

Show delete confirmation screen.

Definition at line 350 of file class.ilDidacticTemplateSettingsGUI.php.

351 {
352 global $ilErr, $ilCtrl;
353
354 if(!$_REQUEST['tpls'])
355 {
356 ilUtil::sendFailure($this->lng->txt('select_one'));
357 return $ilCtrl->redirect($this,'overview');
358 }
359
360 include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
361
362 $confirm = new ilConfirmationGUI();
363 $confirm->setFormAction($ilCtrl->getFormAction($this));
364 $confirm->setConfirm($this->lng->txt('delete'), 'deleteTemplates');
365 $confirm->setCancel($this->lng->txt('cancel'), 'overview');
366
367 foreach((array) $_REQUEST['tpls'] as $tplid)
368 {
369 $tpl = new ilDidacticTemplateSetting($tplid);
370 $confirm->addItem('tpls[]', $tpl->getId(), $tpl->getTitle());
371 }
372
373 ilUtil::sendQuestion($this->lng->txt('didactic_confirm_delete_msg'));
374 $GLOBALS['tpl']->setContent($confirm->getHTML());
375 }
Confirmation screen class.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276

References $_REQUEST, $GLOBALS, $ilCtrl, $ilErr, $tpl, ilUtil\sendFailure(), and ilUtil\sendQuestion().

+ Here is the call graph for this function:

◆ copyTemplate()

ilDidacticTemplateSettingsGUI::copyTemplate ( )
protected

Copy on template.

Definition at line 299 of file class.ilDidacticTemplateSettingsGUI.php.

300 {
301 global $ilErr, $ilCtrl, $ilAccess;
302
303 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
304 {
305 $this->ctrl->redirect($this, "overview");
306 }
307
308 if(!$_REQUEST['tplid'])
309 {
310 ilUtil::sendFailure($this->lng->txt('select_one'));
311 return $ilCtrl->redirect($this,'overview');
312 }
313
314 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateCopier.php';
315
316 $copier = new ilDidacticTemplateCopier((int) $_REQUEST['tplid']);
317 $copier->start();
318
319 ilUtil::sendSuccess($this->lng->txt('didactic_copy_suc_message'), true);
320 $ilCtrl->redirect($this,'overview');
321 }
Copy a didactic template and all subitems.

References $_REQUEST, $ilCtrl, $ilErr, ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ createImportForm()

ilDidacticTemplateSettingsGUI::createImportForm ( )
protected

Create template import form.

Returns
ilPropertyFormGUI $form

Definition at line 107 of file class.ilDidacticTemplateSettingsGUI.php.

108 {
109 global $ilCtrl;
110
111 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
112 $form = new ilPropertyFormGUI();
113 $form->setShowTopButtons(false);
114 $form->setFormAction($ilCtrl->getFormAction($this));
115 $form->setTitle($this->lng->txt('didactic_import_table_title'));
116 $form->addCommandButton('importTemplate', $this->lng->txt('import'));
117 $form->addCommandButton('overview', $this->lng->txt('cancel'));
118
119 $file = new ilFileInputGUI($this->lng->txt('import_file'), 'file');
120 $file->setSuffixes(array('xml'));
121 $file->setRequired(TRUE);
122 $form->addItem($file);
123
124 $created = true;
125
126 return $form;
127 }
print $file
This class represents a file property in a property form.
This class represents a property form user interface.

References $file, and $ilCtrl.

Referenced by importTemplate(), and showImportForm().

+ Here is the caller graph for this function:

◆ deactivateTemplates()

ilDidacticTemplateSettingsGUI::deactivateTemplates ( )
protected

Activate didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl.

Returns
void

Definition at line 445 of file class.ilDidacticTemplateSettingsGUI.php.

446 {
447 global $ilErr, $ilCtrl, $ilAccess;
448
449 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
450 {
451 $this->ctrl->redirect($this, "overview");
452 }
453
454 if(!$_REQUEST['tpls'])
455 {
456 ilUtil::sendFailure($this->lng->txt('select_one'));
457 return $ilCtrl->redirect($this,'overview');
458 }
459
460 foreach($_REQUEST['tpls'] as $tplid)
461 {
462 $tpl = new ilDidacticTemplateSetting($tplid);
463 $tpl->enable(false);
464 $tpl->update();
465 }
466
467 ilUtil::sendSuccess($this->lng->txt('didactic_deactivated_msg'),true);
468 $ilCtrl->redirect($this,'overview');
469 }

References $_REQUEST, $ilCtrl, $ilErr, $tpl, ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ deleteTemplates()

ilDidacticTemplateSettingsGUI::deleteTemplates ( )
protected

Delete chosen didactic templates @global ilErrorHandling $ilErr @global ilCtrl $ilCtrl.

Returns
void

Definition at line 383 of file class.ilDidacticTemplateSettingsGUI.php.

384 {
385 global $ilErr, $ilCtrl, $ilAccess;
386
387 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
388 {
389 $this->ctrl->redirect($this, "overview");
390 }
391
392 if(!$_REQUEST['tpls'])
393 {
394 ilUtil::sendFailure($this->lng->txt('select_one'));
395 return $ilCtrl->redirect($this,'overview');
396 }
397
398 foreach((array) $_REQUEST['tpls'] as $tplid)
399 {
400 $tpl = new ilDidacticTemplateSetting($tplid);
401 $tpl->delete();
402 }
403
404 ilUtil::sendSuccess($this->lng->txt('didactic_delete_msg'),true);
405 $ilCtrl->redirect($this,'overview');
406 }

References $_REQUEST, $ilCtrl, $ilErr, $tpl, ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

◆ editTemplate()

ilDidacticTemplateSettingsGUI::editTemplate ( ilPropertyFormGUI  $form = null)
protected

Edit template.

Returns
void

Definition at line 182 of file class.ilDidacticTemplateSettingsGUI.php.

183 {
184 global $ilCtrl,$ilTabs;
185
186 if(!$_REQUEST['tplid'])
187 {
188 ilUtil::sendFailure($this->lng->txt('select_one'));
189 return $ilCtrl->redirect($this,'overview');
190 }
191
192 $ilTabs->clearTargets();
193 $ilTabs->setBackTarget(
194 $this->lng->txt('didactic_back_to_overview'),
195 $ilCtrl->getLinkTarget($this,'overview')
196 );
197
198
199 $ilCtrl->saveParameter($this,'tplid');
200
201 if(!$form instanceof ilPropertyFormGUI)
202 {
203 $settings = new ilDidacticTemplateSetting((int) $_REQUEST['tplid']);
204 $form = $this->initEditTemplate($settings);
205 }
206 $GLOBALS['tpl']->setContent($form->getHTML());
207 }
initEditTemplate(ilDidacticTemplateSetting $set)
Init edit template form.

References $_REQUEST, $GLOBALS, $ilCtrl, initEditTemplate(), and ilUtil\sendFailure().

Referenced by updateTemplate().

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

◆ executeCommand()

ilDidacticTemplateSettingsGUI::executeCommand ( )

Execute command.

Returns
<type>

Definition at line 34 of file class.ilDidacticTemplateSettingsGUI.php.

35 {
36 global $ilCtrl;
37
38 $next_class = $ilCtrl->getNextClass($this);
39 $cmd = $ilCtrl->getCmd();
40
41 switch($next_class)
42 {
43 default:
44 if(!$cmd)
45 {
46 $cmd = 'overview';
47 }
48 $this->$cmd();
49
50 break;
51 }
52 return true;
53 }
$cmd
Definition: sahs_server.php:35

References $cmd, and $ilCtrl.

◆ exportTemplate()

ilDidacticTemplateSettingsGUI::exportTemplate ( )
protected

Export one template.

Definition at line 326 of file class.ilDidacticTemplateSettingsGUI.php.

327 {
328 global $ilErr, $ilCtrl;
329
330 if(!$_REQUEST['tplid'])
331 {
332 ilUtil::sendFailure($this->lng->txt('select_one'));
333 return $ilCtrl->redirect($this,'overview');
334 }
335
336 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateXmlWriter.php';
337 $writer = new ilDidacticTemplateXmlWriter((int) $_REQUEST['tplid']);
338 $writer->write();
339
341 $writer->xmlDumpMem(TRUE),
342 $writer->getSetting()->getTitle().'.xml',
343 'application/xml'
344 );
345 }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.

References $_REQUEST, $ilCtrl, $ilErr, ilUtil\deliverData(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ importTemplate()

ilDidacticTemplateSettingsGUI::importTemplate ( )
protected

Import template.

Definition at line 132 of file class.ilDidacticTemplateSettingsGUI.php.

133 {
134 global $ilCtrl, $ilAccess;
135
136 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
137 {
138 $this->ctrl->redirect($this, "overview");
139 }
140
141 $form = $this->createImportForm();
142 if(!$form->checkInput())
143 {
144 ilUtil::sendFailure($this->lng->txt('err_check_input'));
145 $form->setValuesByPost();
146 return $this->showImportForm($form);
147 }
148
149 // Do import
150 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateImport.php';
151
153
154 $file = $form->getInput('file');
155 $tmp = ilUtil::ilTempnam();
156
157 // move uploaded file
159 $file['tmp_name'],
160 $file['name'],
161 $tmp
162 );
163 $import->setInputFile($tmp);
164
165 try {
166 $import->import();
167 }
169 {
170 ilLoggerFactory::getLogger('otpl')->error('Import failed with message: ' . $e->getMessage());
171 ilUtil::sendFailure($this->lng->txt('didactic_import_failed').': '.$e->getMessage());
172 }
173
174 ilUtil::sendSuccess($this->lng->txt('didactic_import_success'),TRUE);
175 $ilCtrl->redirect($this,'overview');
176 }
Description of ilDidacticTemplateImportException.
Description of ilDidacticTemplateImport.
showImportForm(ilPropertyFormGUI $form=NULL)
Show template import form.
static getLogger($a_component_id)
Get component logger.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.

References $_REQUEST, $file, $ilCtrl, createImportForm(), ilLoggerFactory\getLogger(), ilUtil\ilTempnam(), ilDidacticTemplateImport\IMPORT_FILE, ilUtil\moveUploadedFile(), ilUtil\sendFailure(), ilUtil\sendSuccess(), and showImportForm().

+ Here is the call graph for this function:

◆ initEditTemplate()

ilDidacticTemplateSettingsGUI::initEditTemplate ( ilDidacticTemplateSetting  $set)
protected

Init edit template form.

Definition at line 244 of file class.ilDidacticTemplateSettingsGUI.php.

245 {
246 global $ilCtrl,$objDefinition;
247
248 include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
249 $form = new ilPropertyFormGUI();
250 $form->setShowTopButtons(false);
251 $form->setFormAction($ilCtrl->getFormAction($this,'updateTemplate'));
252 $form->setTitle($this->lng->txt('didactic_edit_tpl'));
253 $form->addCommandButton('updateTemplate', $this->lng->txt('save'));
254 $form->addCommandButton('overview', $this->lng->txt('cancel'));
255
256 // title
257 $title = new ilTextInputGUI($this->lng->txt('title'), 'title');
258 $title->setValue($set->getTitle());
259 $title->setSize(40);
260 $title->setMaxLength(64);
261 $title->setRequired(true);
262 $form->addItem($title);
263
264 // desc
265 $desc = new ilTextAreaInputGUI($this->lng->txt('description'), 'description');
266 $desc->setValue($set->getDescription());
267 $desc->setRows(3);
268 $form->addItem($desc);
269
270 // info
271 $info = new ilTextAreaInputGUI($this->lng->txt('didactic_install_info'), 'info');
272 $info->setValue($set->getInfo());
273 $info->setRows(6);
274 $form->addItem($info);
275
276 // object type
277 $type = new ilSelectInputGUI($this->lng->txt('obj_type'),'type');
278 $type->setRequired(true);
279 $assigned = $set->getAssignments();
280 $type->setValue(isset($assigned[0]) ? $assigned[0] : '');
281 $subs = $objDefinition->getCreatableSubobjects('root', false);
282 $options = array();
283 foreach(array_merge($subs,array('fold' => 1)) as $obj => $null)
284 {
285 if($objDefinition->isAllowedInRepository($obj))
286 {
287 $options[$obj] = $this->lng->txt('obj_'.$obj);
288 }
289 }
290 $type->setOptions($options);
291 $form->addItem($type);
292
293 return $form;
294 }
getInfo()
Get installation info text.
This class represents a selection list property in a property form.
This class represents a text area property in a property form.
This class represents a text property in a property form.
$info
Definition: example_052.php:80
if(!is_array($argv)) $options

References $ilCtrl, $info, $options, ilDidacticTemplateSetting\getAssignments(), ilDidacticTemplateSetting\getDescription(), ilDidacticTemplateSetting\getInfo(), and ilDidacticTemplateSetting\getTitle().

Referenced by editTemplate(), and updateTemplate().

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

◆ overview()

ilDidacticTemplateSettingsGUI::overview ( )
protected

Show didactic template administration.

@global ilToolbarGUI $ilToolbar

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

61 {
62 global $ilToolbar,$lng, $ilCtrl, $ilAccess;
63
64 if($ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
65 {
66 $ilToolbar->addButton(
67 $lng->txt('didactic_import_btn'),
68 $ilCtrl->getLinkTarget($this,'showImportForm')
69 );
70 }
71
72
73 include_once './Services/DidacticTemplate/classes/class.ilDidacticTemplateSettingsTableGUI.php';
74 $table = new ilDidacticTemplateSettingsTableGUI($this,'overview');
75 $table->init();
76 $table->parse();
77
78 $GLOBALS['tpl']->setContent($table->getHTML());
79 }
Description of ilDidacticTemplateSettingsTableGUI.

References $_REQUEST, $GLOBALS, $ilCtrl, and $lng.

◆ showImportForm()

ilDidacticTemplateSettingsGUI::showImportForm ( ilPropertyFormGUI  $form = NULL)
protected

Show template import form.

@global ilTabsGUI $ilTabs

Definition at line 86 of file class.ilDidacticTemplateSettingsGUI.php.

87 {
88 global $ilTabs, $ilCtrl;
89
90 $ilTabs->clearTargets();
91 $ilTabs->setBackTarget(
92 $this->lng->txt('didactic_back_to_overview'),
93 $ilCtrl->getLinkTarget($this,'overview')
94 );
95
96 if(!$form instanceof ilPropertyFormGUI)
97 {
98 $form = $this->createImportForm();
99 }
100 $GLOBALS['tpl']->setContent($form->getHTML());
101 }

References $GLOBALS, $ilCtrl, and createImportForm().

Referenced by importTemplate().

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

◆ updateTemplate()

ilDidacticTemplateSettingsGUI::updateTemplate ( )
protected

Update template.

Definition at line 212 of file class.ilDidacticTemplateSettingsGUI.php.

213 {
214 global $ilCtrl, $ilAccess;
215
216 if(!$ilAccess->checkAccess('write','',$_REQUEST["ref_id"]))
217 {
218 $this->ctrl->redirect($this, "overview");
219 }
220
221 $temp = new ilDidacticTemplateSetting((int) $_REQUEST['tplid']);
222 $form = $this->initEditTemplate($temp);
223
224 if($form->checkInput())
225 {
226 $temp->setTitle($form->getInput('title'));
227 $temp->setDescription($form->getInput('description'));
228 $temp->setInfo($form->getInput('info'));
229 $temp->setAssignments(array($form->getInput('type')));
230 $temp->update();
231
232 ilUtil::sendSuccess($this->lng->txt('save_settings'));
233 $ilCtrl->redirect($this,'overview');
234 }
235
236 ilUtil::sendFailure($this->lng->txt('err_check_input'));
237 $form->setValuesByPost();
238 $this->editTemplate($form);
239 }
editTemplate(ilPropertyFormGUI $form=null)
Edit template.

References $_REQUEST, $ilCtrl, editTemplate(), initEditTemplate(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

+ Here is the call graph for this function:

Field Documentation

◆ $lng

ilDidacticTemplateSettingsGUI::$lng
private

Definition at line 17 of file class.ilDidacticTemplateSettingsGUI.php.

Referenced by __construct(), and overview().

◆ $parent_object

ilDidacticTemplateSettingsGUI::$parent_object
private

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


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