ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 @access public

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

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 }
$_GET["client_id"]
Create PDF certificates.
redirection script todo: (a better solution should control the processing via a xml file)
global $DIC

References $_GET, $adapter, and $DIC.

Member Function Documentation

◆ certificateDelete()

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

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

◆ certificateDeleteConfirm()

ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

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

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

◆ certificateEditor()

ilCertificateGUI::certificateEditor ( )

Shows the certificate editor for ILIAS tests.

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

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

References $_GET, $_POST, $certificate, $preview, $result, ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), ilCertificate\getCustomCertificateFields(), getFormFieldsFromFO(), getFormFieldsFromPOST(), ilSubmitButton\getInstance(), ilObjCertificateSettingsAccess\hasBackgroundImage(), ilUtil\sendFailure(), ilUtil\sendSuccess(), ilWACSignedPath\setTokenMaxLifetimeInSeconds(), and ilWACSignedPath\signFile().

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

+ 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 164 of file class.ilCertificateGUI.php.

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

◆ certificateImport()

ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

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

149 {
150 $this->certificateEditor();
151 }
certificateEditor()
Shows the certificate editor for ILIAS tests.

References certificateEditor().

+ Here is the call graph for this function:

◆ certificatePreview()

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

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

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

◆ certificateRemoveBackground()

ilCertificateGUI::certificateRemoveBackground ( )

Removes the background image of a certificate.

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

173 {
174 $this->object->deleteBackgroundImage();
175 $this->certificateEditor();
176 }

References certificateEditor().

+ Here is the call graph for this function:

◆ certificateSave()

ilCertificateGUI::certificateSave ( )

Saves the certificate.

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

207 {
208 $this->certificateEditor();
209 }

References certificateEditor().

+ Here is the call graph for this function:

◆ certificateUpload()

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

215 {
216 $this->certificateEditor();
217 }

References certificateEditor().

+ Here is the call graph for this function:

◆ executeCommand()

ilCertificateGUI::executeCommand ( )

execute command

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

123 {
124 $cmd = $this->ctrl->getCmd();
125 $next_class = $this->ctrl->getNextClass($this);
126
127 $cmd = $this->getCommand($cmd);
128 switch($next_class)
129 {
130 default:
131 $ret = $this->$cmd();
132 break;
133 }
134 return $ret;
135 }
getCommand($cmd)
Retrieves the ilCtrl command.
$ret
Definition: parser.php:6
$cmd
Definition: sahs_server.php:35

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

+ Here is the call graph for this function:

◆ getCommand()

ilCertificateGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

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

141 {
142 return $cmd;
143 }

References $cmd.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ getFormFieldsFromFO()

ilCertificateGUI::getFormFieldsFromFO ( )
protected

Get the form values from the certificate xsl-fo.

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

243 {
244 $form_fields = $this->object->getFormFieldsFromFO();
245 $form_fields["active"] = $this->object->readActive();
246 $this->object->getAdapter()->addFormFieldsFromObject($form_fields);
247 return $form_fields;
248 }

Referenced by certificateEditor().

+ Here is the caller graph for this function:

◆ getFormFieldsFromPOST()

ilCertificateGUI::getFormFieldsFromPOST ( )
protected

Get the form values from an HTTP POST.

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

223 {
224 $form_fields = array(
225 "pageformat" => ilUtil::stripSlashes($_POST["pageformat"]),
226 "margin_body_top" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["top"])),
227 "margin_body_right" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["right"])),
228 "margin_body_bottom" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["bottom"])),
229 "margin_body_left" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["margin_body"]["left"])),
230 "certificate_text" => ilUtil::stripSlashes($_POST["certificate_text"], FALSE),
231 "pageheight" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["pageheight"])),
232 "pagewidth" => $this->object->formatNumberString(ilUtil::stripSlashes($_POST["pagewidth"])),
233 "active" => ilUtil::stripSlashes($_POST["active"])
234 );
235 $this->object->getAdapter()->addFormFieldsFromPOST($form_fields);
236 return $form_fields;
237 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References $_POST, and ilUtil\stripSlashes().

Referenced by certificateEditor().

+ 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: