ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCertificateGUI Class Reference

GUI class to create PDF certificates. More...

+ Collaboration diagram for ilCertificateGUI:

Public Member Functions

 __construct (ilCertificateAdapter $adapter)
 ilCertificateGUI constructor More...
 
 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...
 
 certificateEditor ()
 Shows the certificate editor for ILIAS tests. More...
 

Protected Member Functions

 getFormFieldsFromPOST ()
 Get the form values from an HTTP POST. More...
 
 getFormFieldsFromFO ()
 Get the form values from the certificate xsl-fo. More...
 

Protected Attributes

 $object
 
 $ctrl
 
 $tree
 
 $ilias
 
 $tpl
 
 $lng
 
 $ref_id
 
 $acccess
 
 $toolbar
 

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$

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

Constructor & Destructor Documentation

◆ __construct()

ilCertificateGUI::__construct ( ilCertificateAdapter  $adapter)

ilCertificateGUI constructor

Parameters
ilCertificateAdapter$adapterA reference to the test container object public

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

References $_GET, and $DIC.

99  {
100  global $DIC;
101 
102  include_once "./Services/Certificate/classes/class.ilCertificate.php";
103  $this->object = new ilCertificate($adapter);
104 
105  $this->lng = $DIC['lng'];
106  $this->tpl = $DIC['tpl'];
107  $this->ctrl = $DIC['ilCtrl'];
108  $this->ilias = $DIC['ilias'];
109  $this->tree = $DIC['tree'];
110  $this->tree = $DIC['tree'];
111  $this->acccess = $DIC['ilAccess'];
112  $this->toolbar = $DIC['ilToolbar'];
113 
114  $this->ref_id = (int) $_GET['ref_id'];
115 
116  $this->lng->loadLanguageModule('certificate');
117  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
redirection script todo: (a better solution should control the processing via a xml file) ...
Create PDF certificates.

Member Function Documentation

◆ certificateDelete()

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

181  {
182  // display confirmation message
183  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
184  $cgui = new ilConfirmationGUI();
185  $cgui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
186  $cgui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
187  $cgui->setCancel($this->lng->txt("no"), "certificateEditor");
188  $cgui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
189 
190  $this->tpl->setContent($cgui->getHTML());
191  }
Confirmation screen class.

◆ certificateDeleteConfirm()

ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

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

197  {
198  $this->object->deleteCertificate();
199  $this->ctrl->redirect($this, "certificateEditor");
200  }

◆ certificateEditor()

ilCertificateGUI::certificateEditor ( )

Shows the certificate editor for ILIAS tests.

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

References $_GET, $_POST, $certificate, $form, $format, $preview, $result, $tags, array, ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), ilCertificate\getCustomCertificateFields(), getFormFieldsFromFO(), getFormFieldsFromPOST(), ilSubmitButton\getInstance(), ilObjCertificateSettingsAccess\hasBackgroundImage(), object, ilUtil\sendFailure(), ilUtil\sendSuccess(), ilCheckboxInputGUI\setChecked(), ilFormPropertyGUI\setRequired(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), ilTextInputGUI\setValue(), ilRadioGroupInputGUI\setValue(), and ilWACSignedPath\signFile().

Referenced by certificateImport(), certificateRemoveBackground(), certificateSave(), and certificateUpload().

253  {
254  if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
255  $form_fields = $this->getFormFieldsFromPOST();
256  } else {
257  $form_fields = $this->getFormFieldsFromFO();
258  }
259  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
260  $form = new ilPropertyFormGUI();
261  $form->setPreventDoubleSubmission(false);
262  $form->setFormAction($this->ctrl->getFormAction($this));
263  $form->setTitle($this->lng->txt("certificate_edit"));
264  $form->setMultipart(true);
265  $form->setTableWidth("100%");
266  $form->setId("certificate");
267 
268  $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
269  $active->setChecked($form_fields["active"]);
270  $form->addItem($active);
271 
272  $import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import");
273  $import->setRequired(false);
274  $import->setSuffixes(array("zip"));
275  // handle the certificate import
276  if (strlen($_FILES["certificate_import"]["name"])) {
277  if ($import->checkInput()) {
278  $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
279  if ($result == false) {
280  $import->setAlert($this->lng->txt("certificate_error_import"));
281  } else {
282  $this->ctrl->redirect($this, "certificateEditor");
283  }
284  }
285  }
286  $form->addItem($import);
287 
288  $pageformat = new ilRadioGroupInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
289  $pageformats = $this->object->getPageFormats();
290  $pageformat->setValue($form_fields["pageformat"]);
291  foreach ($pageformats as $format) {
292  $option = new ilRadioOption($format["name"], $format["value"]);
293  if (strcmp($format["value"], "custom") == 0) {
294  $pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight");
295  $pageheight->setValue($form_fields["pageheight"]);
296  $pageheight->setSize(6);
297  $pageheight->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
298  $pageheight->setInfo($this->lng->txt("certificate_unit_description"));
299  $pageheight->setRequired(true);
300  $option->addSubitem($pageheight);
301 
302  $pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth");
303  $pagewidth->setValue($form_fields["pagewidth"]);
304  $pagewidth->setSize(6);
305  $pagewidth->setValidationRegexp('/^(([1-9]+|([1-9]+[0]*[\.,]{0,1}[\d]+))|(0[\.,](0*[1-9]+[\d]*)))(cm|mm|in|pt|pc|px|em)$/is');
306  $pagewidth->setInfo($this->lng->txt("certificate_unit_description"));
307  $pagewidth->setRequired(true);
308  $option->addSubitem($pagewidth);
309  }
310  $pageformat->addOption($option);
311  }
312  $pageformat->setRequired(true);
313  if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
314  $pageformat->checkInput();
315  }
316 
317  $form->addItem($pageformat);
318 
319  $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
320  $bgimage->setRequired(false);
321  $bgimage->setUseCache(false);
322  if (count($_POST)) {
323  // handle the background upload
324  if (strlen($_FILES["background"]["tmp_name"])) {
325  if ($bgimage->checkInput()) {
326  $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
327  if ($result == false) {
328  $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
329  }
330  }
331  }
332  }
333  if (!$this->object->hasBackgroundImage()) {
334  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
336  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
339  }
340  } else {
341  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
343  $bgimage->setImage(ilWACSignedPath::signFile($this->object->getBackgroundImageThumbPathWeb()));
344  }
345  $form->addItem($bgimage);
346 
347  $rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body");
348  $rect->setRequired(true);
349  $rect->setUseUnits(true);
350  $rect->setTop($form_fields["margin_body_top"]);
351  $rect->setBottom($form_fields["margin_body_bottom"]);
352  $rect->setLeft($form_fields["margin_body_left"]);
353  $rect->setRight($form_fields["margin_body_right"]);
354  $rect->setInfo($this->lng->txt("certificate_unit_description"));
355  if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
356  $rect->checkInput();
357  }
358  $form->addItem($rect);
359 
360  $certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text");
361  $certificate->removePlugin('ilimgupload');
362  $certificate->setValue($form_fields["certificate_text"]);
363  $certificate->setRequired(true);
364  $certificate->setRows(20);
365  $certificate->setCols(80);
366 
367  // fraunhpatch start
368  $common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate");
370  $common_desc_tpl->setCurrentBlock("cert_field");
371  $common_desc_tpl->setVariable("PH", $f["ph"]);
372  $common_desc_tpl->setVariable("PH_TXT", $f["name"]);
373  $common_desc_tpl->parseCurrentBlock();
374  }
375  $common_desc = $common_desc_tpl->get();
376  // fraunhpatch start
377 
378  $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription() . $common_desc);
379  $certificate->setUseRte(true, '3.4.7');
380  $tags = array(
381  "br",
382  "em",
383  "font",
384  "li",
385  "ol",
386  "p",
387  "span",
388  "strong",
389  "u",
390  "ul"
391  );
392  $certificate->setRteTags($tags);
393  if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
394  $certificate->checkInput();
395  }
396  $form->addItem($certificate);
397 
398  $this->object->getAdapter()->addAdditionalFormElements($form, $form_fields);
399 
400  if ($this->acccess->checkAccess("write", "", $_GET["ref_id"])) {
401  if ($this->object->isComplete() || $this->object->hasBackgroundImage()) {
402  $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
403 
404  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
406  $preview->setCaption('certificate_preview');
407  $preview->setCommand('certificatePreview');
408  $this->toolbar->addStickyItem($preview);
409 
410  $export = ilSubmitButton::getInstance();
411  $export->setCaption('certificate_export');
412  $export->setCommand('certificateExportFO');
413  $this->toolbar->addButtonInstance($export);
414 
415  $delete = ilSubmitButton::getInstance();
416  $delete->setCaption('delete');
417  $delete->setCommand('certificateDelete');
418  $this->toolbar->addButtonInstance($delete);
419  }
420  $form->addCommandButton("certificateSave", $this->lng->txt("save"));
421  }
422 
423  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
424 
425  if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) {
426  if ($_POST["background_delete"]) {
427  $this->object->deleteBackgroundImage();
428  }
429  if ($form->checkInput()) {
430  try {
431  $xslfo = $this->object->processXHTML2FO($form_fields);
432  $this->object->getAdapter()->saveFormFields($form_fields);
433  $this->object->saveCertificate($xslfo);
434  $this->object->writeActive($form_fields["active"]);
435  ilUtil::sendSuccess($this->lng->txt("saved_successfully"), true);
436  $this->ctrl->redirect($this, "certificateEditor");
437  } catch (Exception $e) {
438  ilUtil::sendFailure($e->getMessage());
439  }
440  }
441  }
442  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
This class represents an option in a radio group.
$format
Definition: metadata.php:141
$result
This class represents a property form user interface.
$_GET["client_id"]
This class represents a file property in a property form.
$preview
This class represents a checkbox property in a property form.
This class represents a text property in a property form.
if(@file_exists(dirname(__FILE__).'/lang/eng.php')) $certificate
Definition: example_052.php:77
setChecked($a_checked)
Set Checked.
This class represents a property in a property form.
getFormFieldsFromPOST()
Get the form values from an HTTP POST.
if(isset($_POST['submit'])) $form
$tags
Definition: croninfo.php:19
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
getFormFieldsFromFO()
Get the form values from the certificate xsl-fo.
static getCustomCertificateFields()
Get custom certificate fields.
static signFile($path_to_file)
Create styles array
The data for the language used.
static hasBackgroundImage()
Returns wheather or not a default background image exists.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
This class represents an image file property in a property form.
Create new PHPExcel object
obj_idprivate
This class represents a text area property in a property form.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
setValue($a_value)
Set Value.
$_POST["username"]
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ certificateExportFO()

ilCertificateGUI::certificateExportFO ( )

Exports the certificate.

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

164  {
165  $this->object->deliverExportFileXML();
166  }

◆ certificateImport()

ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

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

References certificateEditor().

148  {
149  $this->certificateEditor();
150  }
certificateEditor()
Shows the certificate editor for ILIAS tests.
+ Here is the call graph for this function:

◆ certificatePreview()

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

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

156  {
157  $this->object->createPreview();
158  }

◆ certificateRemoveBackground()

ilCertificateGUI::certificateRemoveBackground ( )

Removes the background image of a certificate.

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

References certificateEditor().

172  {
173  $this->object->deleteBackgroundImage();
174  $this->certificateEditor();
175  }
certificateEditor()
Shows the certificate editor for ILIAS tests.
+ Here is the call graph for this function:

◆ certificateSave()

ilCertificateGUI::certificateSave ( )

Saves the certificate.

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

References certificateEditor().

206  {
207  $this->certificateEditor();
208  }
certificateEditor()
Shows the certificate editor for ILIAS tests.
+ Here is the call graph for this function:

◆ certificateUpload()

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

References certificateEditor().

214  {
215  $this->certificateEditor();
216  }
certificateEditor()
Shows the certificate editor for ILIAS tests.
+ Here is the call graph for this function:

◆ executeCommand()

ilCertificateGUI::executeCommand ( )

execute command

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

References $ret, and getCommand().

123  {
124  $cmd = $this->ctrl->getCmd();
125  $next_class = $this->ctrl->getNextClass($this);
126 
127  $cmd = $this->getCommand($cmd);
128  switch ($next_class) {
129  default:
130  $ret = $this->$cmd();
131  break;
132  }
133  return $ret;
134  }
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 139 of file class.ilCertificateGUI.php.

Referenced by executeCommand().

140  {
141  return $cmd;
142  }
+ Here is the caller graph for this function:

◆ getFormFieldsFromFO()

ilCertificateGUI::getFormFieldsFromFO ( )
protected

Get the form values from the certificate xsl-fo.

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

Referenced by certificateEditor().

242  {
243  $form_fields = $this->object->getFormFieldsFromFO();
244  $form_fields["active"] = $this->object->readActive();
245  $this->object->getAdapter()->addFormFieldsFromObject($form_fields);
246  return $form_fields;
247  }
+ Here is the caller graph for this function:

◆ getFormFieldsFromPOST()

ilCertificateGUI::getFormFieldsFromPOST ( )
protected

Get the form values from an HTTP POST.

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

References $_POST, array, object, and ilUtil\stripSlashes().

Referenced by certificateEditor().

222  {
223  $form_fields = array(
224  "pageformat" => ilUtil::stripSlashes($_POST["pageformat"]),
225  "margin_body_top" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["top"])),
226  "margin_body_right" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["right"])),
227  "margin_body_bottom" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["bottom"])),
228  "margin_body_left" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["left"])),
229  "certificate_text" => ilUtil::stripSlashes($_POST["certificate_text"], false),
230  "pageheight" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["pageheight"])),
231  "pagewidth" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["pagewidth"])),
232  "active" => ilUtil::stripSlashes($_POST["active"])
233  );
234  $this->object->getAdapter()->addFormFieldsFromPOST($form_fields);
235  return $form_fields;
236  }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
Create styles array
The data for the language used.
Create new PHPExcel object
obj_idprivate
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $acccess

ilCertificateGUI::$acccess
protected

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

◆ $ctrl

ilCertificateGUI::$ctrl
protected

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

◆ $ilias

ilCertificateGUI::$ilias
protected

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

◆ $lng

ilCertificateGUI::$lng
protected

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

◆ $object

ilCertificateGUI::$object
protected

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

◆ $ref_id

ilCertificateGUI::$ref_id
protected

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

◆ $toolbar

ilCertificateGUI::$toolbar
protected

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

◆ $tpl

ilCertificateGUI::$tpl
protected

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

◆ $tree

ilCertificateGUI::$tree
protected

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


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