ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateGUI Class Reference

GUI class to create PDF certificates. More...

+ Collaboration diagram for ilCertificateGUI:

Public Member Functions

 __construct (ilCertificatePlaceholderDescription $placeholderDescriptionObject, ilCertificatePlaceholderValues $placeholderValuesObject, $objectId, $certificatePath, ilCertificateFormRepository $settingsFormFactory=null, ilCertificateDeleteAction $deleteAction=null, ilCertificateTemplateRepository $templateRepository=null, ilPageFormats $pageFormats=null, ilXlsFoParser $xlsFoParser=null, ilFormFieldParser $formFieldParser=null, ilCertificateTemplateExportAction $exportAction=null, ilCertificateBackgroundImageUpload $upload=null, ilCertificateTemplatePreviewAction $previewAction=null, \ILIAS\FileUpload\FileUpload $fileUpload=null, ilSetting $settings=null, ilCertificateBackgroundImageDelete $backgroundImageDelete=null, \ILIAS\Filesystem\Filesystem $fileSystem=null, ilCertificateBackgroundImageFileService $imageFileService=null, \ILIAS\Filesystem\Filesystem $tmp_file_system=null)
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 Retrieves the ilCtrl command. More...
 
 certificateImport ()
 Import a certificate from a ZIP archive. More...
 
 certificatePreview ()
 Creates a certificate preview. More...
 
 certificateExportFO ()
 Exports the certificate. More...
 
 certificateRemoveBackground ()
 Removes the background image of a certificate. More...
 
 certificateDelete ()
 Deletes the certificate and all its data. More...
 
 certificateDeleteConfirm ()
 Deletes the certificate and all its data. More...
 
 certificateSave ()
 Saves the certificate. More...
 
 certificateUpload ()
 Uploads the certificate. More...
 

Protected Attributes

 $ctrl
 
 $tree
 
 $ilias
 
 $tpl
 
 $lng
 
 $ref_id
 
 $access
 
 $toolbar
 

Private Member Functions

 getEditorForm ()
 
 setTemplateContent (ilCertificateTemplate $certificate, ilPropertyFormGUI $form)
 
 createFormatArray (ilCertificateTemplate $certificateTemplate)
 

Private Attributes

 $backgroundImageDelete
 
 $fileSystem
 
 $templateRepository
 
 $formFieldParser
 
 $placeholderDescriptionObject
 
 $objectId
 
 $settingsFormFactory
 
 $placeholderValuesObject
 
 $xlsFoParser
 
 $deleteAction
 
 $exportAction
 
 $backgroundImageUpload
 
 $previewAction
 
 $thumbnailImageUpload
 
 $fileUpload
 
 $certificatePath
 
 $settings
 
 $pageFormats
 
 $tmp_file_system
 

Detailed Description

GUI class to create PDF certificates.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

: ilCertificateGUI: ilPropertyFormGUI

Definition at line 32 of file class.ilCertificateGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilCertificateGUI::__construct ( ilCertificatePlaceholderDescription  $placeholderDescriptionObject,
ilCertificatePlaceholderValues  $placeholderValuesObject,
  $objectId,
  $certificatePath,
ilCertificateFormRepository  $settingsFormFactory = null,
ilCertificateDeleteAction  $deleteAction = null,
ilCertificateTemplateRepository  $templateRepository = null,
ilPageFormats  $pageFormats = null,
ilXlsFoParser  $xlsFoParser = null,
ilFormFieldParser  $formFieldParser = null,
ilCertificateTemplateExportAction  $exportAction = null,
ilCertificateBackgroundImageUpload  $upload = null,
ilCertificateTemplatePreviewAction  $previewAction = null,
\ILIAS\FileUpload\FileUpload  $fileUpload = null,
ilSetting  $settings = null,
ilCertificateBackgroundImageDelete  $backgroundImageDelete = null,
\ILIAS\Filesystem\Filesystem  $fileSystem = null,
ilCertificateBackgroundImageFileService  $imageFileService = null,
\ILIAS\Filesystem\Filesystem  $tmp_file_system = null 
)

Definition at line 179 of file class.ilCertificateGUI.php.

References $_GET, $backgroundImageDelete, $certificatePath, $deleteAction, $DIC, $exportAction, $fileSystem, $fileUpload, $formFieldParser, $objectId, $pageFormats, $placeholderDescriptionObject, $placeholderValuesObject, $previewAction, $settings, $settingsFormFactory, $templateRepository, $tmp_file_system, $xlsFoParser, and settings().

199  {
200  global $DIC;
201 
202  $this->lng = $DIC['lng'];
203  $this->tpl = $DIC['tpl'];
204  $this->ctrl = $DIC['ilCtrl'];
205  $this->ilias = $DIC['ilias'];
206  $this->tree = $DIC['tree'];
207  $this->access = $DIC['ilAccess'];
208  $this->toolbar = $DIC['ilToolbar'];
209 
210  $this->lng->loadLanguageModule('certificate');
211  $this->lng->loadLanguageModule('cert');
212  $this->lng->loadLanguageModule("trac");
213 
214  $this->ref_id = (int) $_GET['ref_id'];
215 
216  $this->placeholderDescriptionObject = $placeholderDescriptionObject;
217 
218  $this->placeholderValuesObject = $placeholderValuesObject;
219 
220  $this->objectId = $objectId;
221 
222  $logger = $DIC->logger()->cert();
223 
224  if (null === $settingsFormFactory) {
225  $settingsFormFactory = new ilCertificateSettingsFormRepository(
226  $this->objectId,
228  $this->lng,
229  $this->tpl,
230  $this->ctrl,
231  $this->access,
232  $this->toolbar,
233  $placeholderDescriptionObject
234  );
235  }
236  $this->settingsFormFactory = $settingsFormFactory;
237 
238  if (null === $templateRepository) {
239  $templateRepository = new ilCertificateTemplateRepository($DIC->database(), $logger);
240  }
241  $this->templateRepository = $templateRepository;
242 
243  if (null === $deleteAction) {
244  $deleteAction = new ilCertificateTemplateDeleteAction($templateRepository);
245  }
246  $this->deleteAction = $deleteAction;
247 
248  if (null === $formFieldParser) {
249  $formFieldParser = new ilFormFieldParser();
250  }
251  $this->formFieldParser = $formFieldParser;
252 
253  if (null === $pageFormats) {
254  $pageFormats = new ilPageFormats($DIC->language());
255  }
256  $this->pageFormats = $pageFormats;
257 
258  if (null === $xlsFoParser) {
259  $xlsFoParser = new ilXlsFoParser($DIC->settings(), $pageFormats);
260  }
261  $this->xlsFoParser = $xlsFoParser;
262 
263  if (null === $upload) {
265  $DIC->upload(),
267  $DIC->language(),
268  $logger
269  );
270  }
271  $this->backgroundImageUpload = $upload;
272 
273  if (null === $exportAction) {
274  $exportAction = new ilCertificateTemplateExportAction(
275  $this->objectId,
277  $this->templateRepository,
278  $DIC->filesystem()->web()
279  );
280  }
281  $this->exportAction = $exportAction;
282 
283  if (null === $previewAction) {
284  $previewAction = new ilCertificateTemplatePreviewAction($templateRepository, $placeholderValuesObject);
285  }
286  $this->previewAction = $previewAction;
287 
288  if (null === $fileUpload) {
289  global $DIC;
290  $fileUpload = $DIC->upload();
291  }
292  $this->fileUpload = $fileUpload;
293 
294  $this->certificatePath = $certificatePath;
295 
296  if (null === $settings) {
297  $settings = new ilSetting('certificate');
298  }
299  $this->settings = $settings;
300 
301  if (null === $fileSystem) {
302  $fileSystem = $DIC->filesystem()->web();
303  }
304  $this->fileSystem = $fileSystem;
305 
306  if (null === $imageFileService) {
307  $imageFileService = new ilCertificateBackgroundImageFileService(
308  $this->certificatePath,
309  $this->fileSystem
310  );
311  }
312 
313  if (null === $backgroundImageDelete) {
314  $backgroundImageDelete = new ilCertificateBackgroundImageDelete(
315  $this->certificatePath,
316  $imageFileService
317  );
318  }
319  $this->backgroundImageDelete = $backgroundImageDelete;
320 
321  if (null === $tmp_file_system) {
322  $tmp_file_system = $DIC->filesystem()->temp();
323  }
324  $this->tmp_file_system = $tmp_file_system;
325  }
settings()
Definition: settings.php:2
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ certificateDelete()

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

Definition at line 398 of file class.ilCertificateGUI.php.

399  {
400  // display confirmation message
401  $cgui = new ilConfirmationGUI();
402  $cgui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
403  $cgui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
404  $cgui->setCancel($this->lng->txt("no"), "certificateEditor");
405  $cgui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
406 
407  $this->tpl->setContent($cgui->getHTML());
408  }
Confirmation screen class.

◆ certificateDeleteConfirm()

ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

Definition at line 413 of file class.ilCertificateGUI.php.

414  {
415  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
416  $templateId = $template->getId();
417 
418  $this->deleteAction->delete($templateId, $this->objectId);
419  $this->ctrl->redirect($this, "certificateEditor");
420  }

◆ certificateExportFO()

ilCertificateGUI::certificateExportFO ( )

Exports the certificate.

Definition at line 381 of file class.ilCertificateGUI.php.

382  {
383  $this->exportAction->export();
384  }

◆ certificateImport()

ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

Definition at line 360 of file class.ilCertificateGUI.php.

361  {
362  $this->certificateEditor();
363  }

◆ certificatePreview()

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

Definition at line 368 of file class.ilCertificateGUI.php.

References ilUtil\sendFailure().

369  {
370  try {
371  $this->previewAction->createPreviewPdf($this->objectId);
372  } catch (Exception $exception) {
373  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf', true));
374  $this->certificateEditor();
375  }
376  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ Here is the call graph for this function:

◆ certificateRemoveBackground()

ilCertificateGUI::certificateRemoveBackground ( )

Removes the background image of a certificate.

Definition at line 389 of file class.ilCertificateGUI.php.

390  {
391  $this->backgroundImageDelete->deleteBackgroundImage('');
392  $this->certificateEditor();
393  }

◆ certificateSave()

ilCertificateGUI::certificateSave ( )

Saves the certificate.

Definition at line 425 of file class.ilCertificateGUI.php.

References $DIC.

426  {
427  global $DIC;
428 
429  $form = $this->settingsFormFactory->createForm(
430  $this
431  );
432 
433  $form->setValuesByPost();
434 
435  $request = $DIC->http()->request();
436 
437  $formFields = $request->getParsedBody();
438 
439  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
440 
441  $this->saveCertificate($form, $formFields, $this->objectId);
442  }
$DIC
Definition: xapitoken.php:46

◆ certificateUpload()

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

Definition at line 447 of file class.ilCertificateGUI.php.

448  {
449  $this->certificateEditor();
450  }

◆ createFormatArray()

ilCertificateGUI::createFormatArray ( ilCertificateTemplate  $certificateTemplate)
private
Parameters
ilCertificateTemplate$certificateTemplate
Returns
array|mixed

Definition at line 678 of file class.ilCertificateGUI.php.

References $format, $formats, ilPageFormats\DEFAULT_MARGIN_BODY_BOTTOM, ilPageFormats\DEFAULT_MARGIN_BODY_LEFT, ilPageFormats\DEFAULT_MARGIN_BODY_RIGHT, ilPageFormats\DEFAULT_MARGIN_BODY_TOP, ilCertificateTemplate\getCertificateContent(), ilCertificateTemplate\getCertificateHash(), and settings().

Referenced by getEditorForm().

679  {
680  if ('' === $certificateTemplate->getCertificateHash()) {
681  $format = $this->settings->get('pageformat');
682  $formats = $this->pageFormats->fetchPageFormats();
683 
684  $formFieldArray = array(
685  'pageformat' => $format,
686  'pagewidth' => $formats['width'],
687  'pageheight' => $formats['height'],
688  'margin_body_top' => ilPageFormats::DEFAULT_MARGIN_BODY_TOP,
689  'margin_body_right' => ilPageFormats::DEFAULT_MARGIN_BODY_RIGHT,
690  'margin_body_bottom' => ilPageFormats::DEFAULT_MARGIN_BODY_BOTTOM,
691  'margin_body_left' => ilPageFormats::DEFAULT_MARGIN_BODY_LEFT,
692  'certificate_text' => $certificateTemplate->getCertificateContent()
693  );
694 
695  return $formFieldArray;
696  }
697  return $this->settingsFormFactory->fetchFormFieldData($certificateTemplate->getCertificateContent());
698  }
settings()
Definition: settings.php:2
$format
Definition: metadata.php:218
const DEFAULT_MARGIN_BODY_BOTTOM
$formats
Definition: date.php:77
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilCertificateGUI::executeCommand ( )

execute command

Definition at line 330 of file class.ilCertificateGUI.php.

References $ret, getCommand(), and getEditorForm().

331  {
332  $cmd = $this->ctrl->getCmd();
333  $next_class = $this->ctrl->getNextClass($this);
334 
335  $cmd = $this->getCommand($cmd);
336  switch ($next_class) {
337  case 'ilpropertyformgui':
338  $form = $this->getEditorForm();
339  $this->ctrl->forwardCommand($form);
340  break;
341 
342  default:
343  $ret = $this->$cmd();
344  break;
345  }
346  return $ret;
347  }
getCommand($cmd)
Retrieves the ilCtrl command.
$ret
Definition: parser.php:6
+ Here is the call graph for this function:

◆ getCommand()

ilCertificateGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

Definition at line 352 of file class.ilCertificateGUI.php.

Referenced by executeCommand().

353  {
354  return $cmd;
355  }
+ Here is the caller graph for this function:

◆ getEditorForm()

ilCertificateGUI::getEditorForm ( )
private
Returns
ilPropertyFormGUI
Exceptions

Definition at line 461 of file class.ilCertificateGUI.php.

References $_POST, $DIC, Vendor\Package\$e, $objId, $result, ilObjUserTracking\_enabledLearningProgress(), ilObject\_lookupType(), ilPropertyFormGUI\checkInput(), createFormatArray(), ilObjCertificateSettingsAccess\getBackgroundImagePath(), ilPropertyFormGUI\getHTML(), ilPropertyFormGUI\getInput(), ilObjectFactory\getInstanceByObjId(), ilPropertyFormGUI\getItemByPostVar(), ILIAS_VERSION_NUMERIC, ilLPObjSettings\LP_MODE_DEACTIVATED, ILIAS\FileUpload\DTO\ProcessingStatus\OK, ilUtil\sendFailure(), ilUtil\sendInfo(), and ilPropertyFormGUI\setValuesByPost().

Referenced by executeCommand().

462  {
463  $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
464 
465  $form = $this->settingsFormFactory->createForm(
466  $this
467  );
468 
469  $formFields = $this->createFormatArray($certificateTemplate);
470 
471  $formFields['active'] = $certificateTemplate->isCurrentlyActive();
472 
473  $form->setValuesByArray($formFields);
474 
475  return $form;
476  }
This class represents a property form user interface.
createFormatArray(ilCertificateTemplate $certificateTemplate)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTemplateContent()

ilCertificateGUI::setTemplateContent ( ilCertificateTemplate  $certificate,
ilPropertyFormGUI  $form 
)
private
Parameters
$content
$certificate
$form

Definition at line 664 of file class.ilCertificateGUI.php.

References ilCertificateTemplate\getCertificateContent(), ilPropertyFormGUI\getHTML(), ilCertificateTemplate\isCurrentlyActive(), and ilPropertyFormGUI\setValuesByArray().

665  {
666  $form_fields = $this->settingsFormFactory->fetchFormFieldData($certificate->getCertificateContent());
667  $form_fields['active'] = $certificate->isCurrentlyActive();
668 
669  $form->setValuesByArray($form_fields);
670 
671  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
672  }
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilCertificateGUI::$access
protected

Definition at line 89 of file class.ilCertificateGUI.php.

◆ $backgroundImageDelete

ilCertificateGUI::$backgroundImageDelete
private

Definition at line 37 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $backgroundImageUpload

ilCertificateGUI::$backgroundImageUpload
private

Definition at line 144 of file class.ilCertificateGUI.php.

◆ $certificatePath

ilCertificateGUI::$certificatePath
private

Definition at line 164 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $ctrl

ilCertificateGUI::$ctrl
protected

Definition at line 49 of file class.ilCertificateGUI.php.

◆ $deleteAction

ilCertificateGUI::$deleteAction
private

Definition at line 134 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $exportAction

ilCertificateGUI::$exportAction
private

Definition at line 139 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $fileSystem

ilCertificateGUI::$fileSystem
private

Definition at line 42 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $fileUpload

ilCertificateGUI::$fileUpload
private

Definition at line 159 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $formFieldParser

ilCertificateGUI::$formFieldParser
private

Definition at line 104 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $ilias

ilCertificateGUI::$ilias
protected

Definition at line 63 of file class.ilCertificateGUI.php.

◆ $lng

ilCertificateGUI::$lng
protected

Definition at line 77 of file class.ilCertificateGUI.php.

◆ $objectId

ilCertificateGUI::$objectId
private

Definition at line 114 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $pageFormats

ilCertificateGUI::$pageFormats
private

Definition at line 174 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $placeholderDescriptionObject

ilCertificateGUI::$placeholderDescriptionObject
private

Definition at line 109 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $placeholderValuesObject

ilCertificateGUI::$placeholderValuesObject
private

Definition at line 124 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $previewAction

ilCertificateGUI::$previewAction
private

Definition at line 149 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $ref_id

ilCertificateGUI::$ref_id
protected

Definition at line 84 of file class.ilCertificateGUI.php.

◆ $settings

ilCertificateGUI::$settings
private

Definition at line 169 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $settingsFormFactory

ilCertificateGUI::$settingsFormFactory
private

Definition at line 119 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $templateRepository

ilCertificateGUI::$templateRepository
private

Definition at line 99 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $thumbnailImageUpload

ilCertificateGUI::$thumbnailImageUpload
private

Definition at line 154 of file class.ilCertificateGUI.php.

◆ $tmp_file_system

ilCertificateGUI::$tmp_file_system
private

Definition at line 177 of file class.ilCertificateGUI.php.

Referenced by __construct().

◆ $toolbar

ilCertificateGUI::$toolbar
protected

Definition at line 94 of file class.ilCertificateGUI.php.

◆ $tpl

ilCertificateGUI::$tpl
protected

Definition at line 70 of file class.ilCertificateGUI.php.

◆ $tree

ilCertificateGUI::$tree
protected

Definition at line 56 of file class.ilCertificateGUI.php.

◆ $xlsFoParser

ilCertificateGUI::$xlsFoParser
private

Definition at line 129 of file class.ilCertificateGUI.php.

Referenced by __construct().


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