ILIAS  release_7 Revision v7.30-3-g800a261c036
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
 
 $globalCertificateSettings
 

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 184 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().

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

Member Function Documentation

◆ certificateDelete()

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

406  {
407  // display confirmation message
408  $cgui = new ilConfirmationGUI();
409  $cgui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
410  $cgui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
411  $cgui->setCancel($this->lng->txt("no"), "certificateEditor");
412  $cgui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
413 
414  $this->tpl->setContent($cgui->getHTML());
415  }
Confirmation screen class.

◆ certificateDeleteConfirm()

ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

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

421  {
422  $template = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
423  $templateId = $template->getId();
424 
425  $this->deleteAction->delete($templateId, $this->objectId);
426  $this->ctrl->redirect($this, "certificateEditor");
427  }

◆ certificateExportFO()

ilCertificateGUI::certificateExportFO ( )

Exports the certificate.

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

389  {
390  $this->exportAction->export();
391  }

◆ certificateImport()

ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

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

368  {
369  $this->certificateEditor();
370  }

◆ certificatePreview()

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

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

References ilUtil\sendFailure().

376  {
377  try {
378  $this->previewAction->createPreviewPdf($this->objectId);
379  } catch (Exception $exception) {
380  ilUtil::sendFailure($this->lng->txt('error_creating_certificate_pdf', true));
381  $this->certificateEditor();
382  }
383  }
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 396 of file class.ilCertificateGUI.php.

397  {
398  $this->backgroundImageDelete->deleteBackgroundImage('');
399  $this->certificateEditor();
400  }

◆ certificateSave()

ilCertificateGUI::certificateSave ( )

Saves the certificate.

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

References $DIC.

433  {
434  global $DIC;
435 
436  $form = $this->settingsFormFactory->createForm(
437  $this
438  );
439 
440  $form->setValuesByPost();
441 
442  $request = $DIC->http()->request();
443 
444  $formFields = $request->getParsedBody();
445 
446  $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
447 
448  $this->saveCertificate($form, $formFields, $this->objectId);
449  }
global $DIC
Definition: goto.php:24

◆ certificateUpload()

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

455  {
456  $this->certificateEditor();
457  }

◆ createFormatArray()

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

Definition at line 684 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().

685  {
686  if ('' === $certificateTemplate->getCertificateHash()) {
687  $format = $this->settings->get('pageformat');
688  $formats = $this->pageFormats->fetchPageFormats();
689 
690  $formFieldArray = array(
691  'pageformat' => $format,
692  'pagewidth' => $formats['width'],
693  'pageheight' => $formats['height'],
694  'margin_body_top' => ilPageFormats::DEFAULT_MARGIN_BODY_TOP,
695  'margin_body_right' => ilPageFormats::DEFAULT_MARGIN_BODY_RIGHT,
696  'margin_body_bottom' => ilPageFormats::DEFAULT_MARGIN_BODY_BOTTOM,
697  'margin_body_left' => ilPageFormats::DEFAULT_MARGIN_BODY_LEFT,
698  'certificate_text' => $certificateTemplate->getCertificateContent()
699  );
700 
701  return $formFieldArray;
702  }
703  return $this->settingsFormFactory->fetchFormFieldData($certificateTemplate->getCertificateContent());
704  }
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 337 of file class.ilCertificateGUI.php.

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

338  {
339  $cmd = $this->ctrl->getCmd();
340  $next_class = $this->ctrl->getNextClass($this);
341 
342  $cmd = $this->getCommand($cmd);
343  switch ($next_class) {
344  case 'ilpropertyformgui':
345  $form = $this->getEditorForm();
346  $this->ctrl->forwardCommand($form);
347  break;
348 
349  default:
350  $ret = $this->$cmd();
351  break;
352  }
353  return $ret;
354  }
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 359 of file class.ilCertificateGUI.php.

Referenced by executeCommand().

360  {
361  return $cmd;
362  }
+ Here is the caller graph for this function:

◆ getEditorForm()

ilCertificateGUI::getEditorForm ( )
private
Returns
ilPropertyFormGUI
Exceptions

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

References $_POST, $DIC, Vendor\Package\$e, $objId, $result, ilObjUserTracking\_enabledLearningProgress(), ilObject\_lookupType(), ilPropertyFormGUI\checkInput(), createFormatArray(), 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().

469  {
470  $certificateTemplate = $this->templateRepository->fetchCurrentlyUsedCertificate($this->objectId);
471 
472  $form = $this->settingsFormFactory->createForm(
473  $this
474  );
475 
476  $formFields = $this->createFormatArray($certificateTemplate);
477 
478  $formFields['active'] = $certificateTemplate->isCurrentlyActive();
479 
480  $form->setValuesByArray($formFields);
481 
482  return $form;
483  }
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 670 of file class.ilCertificateGUI.php.

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

671  {
672  $form_fields = $this->settingsFormFactory->fetchFormFieldData($certificate->getCertificateContent());
673  $form_fields['active'] = $certificate->isCurrentlyActive();
674 
675  $form->setValuesByArray($form_fields);
676 
677  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
678  }
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().

◆ $globalCertificateSettings

ilCertificateGUI::$globalCertificateSettings
private

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

◆ $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: