ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilCertificateGUI Class Reference

GUI class to create PDF certificates. More...

+ Collaboration diagram for ilCertificateGUI:

Public Member Functions

 ilCertificateGUI ($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...
 

Data Fields

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

Protected Member Functions

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

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.

Member Function Documentation

◆ certificateDelete()

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

168 {
169 // display confirmation message
170 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
171 $cgui = new ilConfirmationGUI();
172 $cgui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
173 $cgui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
174 $cgui->setCancel($this->lng->txt("no"), "certificateEditor");
175 $cgui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
176
177 $this->tpl->setContent($cgui->getHTML());
178 }
Confirmation screen class.

◆ certificateDeleteConfirm()

ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

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

184 {
185 $this->object->deleteCertificate();
186 $this->ctrl->redirect($this, "certificateEditor");
187 }

◆ certificateEditor()

ilCertificateGUI::certificateEditor ( )

Shows the certificate editor for ILIAS tests.

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

241 {
242 global $ilAccess;
243
244 $form_fields = array();
245 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0)
246 {
247 $form_fields = $this->getFormFieldsFromPOST();
248 }
249 else
250 {
251 $form_fields = $this->getFormFieldsFromFO();
252 }
253 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
254 $form = new ilPropertyFormGUI();
255 $form->setPreventDoubleSubmission(false);
256 $form->setFormAction($this->ctrl->getFormAction($this));
257 $form->setTitle($this->lng->txt("certificate_edit"));
258 $form->setMultipart(TRUE);
259 $form->setTableWidth("100%");
260 $form->setId("certificate");
261
262 $active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
263 $active->setChecked($form_fields["active"]);
264 $form->addItem($active);
265
266 $import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import");
267 $import->setRequired(FALSE);
268 $import->setSuffixes(array("zip"));
269 // handle the certificate import
270 if (strlen($_FILES["certificate_import"]["tmp_name"]))
271 {
272 if ($import->checkInput())
273 {
274 $result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
275 if ($result == FALSE)
276 {
277 $import->setAlert($this->lng->txt("certificate_error_import"));
278 }
279 else
280 {
281 $this->ctrl->redirect($this, "certificateEditor");
282 }
283 }
284 }
285 $form->addItem($import);
286
287 $pageformat = new ilRadioGroupInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
288 $pageformats = $this->object->getPageFormats();
289 $pageformat->setValue($form_fields["pageformat"]);
290 foreach($pageformats as $format)
291 {
292 $option = new ilRadioOption($format["name"], $format["value"]);
293 if(strcmp($format["value"], "custom") == 0)
294 {
295 $pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight");
296 $pageheight->setValue($form_fields["pageheight"]);
297 $pageheight->setSize(6);
298 $pageheight->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
299 $pageheight->setInfo($this->lng->txt("certificate_unit_description"));
300 $pageheight->setRequired(true);
301 $option->addSubitem($pageheight);
302
303 $pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth");
304 $pagewidth->setValue($form_fields["pagewidth"]);
305 $pagewidth->setSize(6);
306 $pagewidth->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
307 $pagewidth->setInfo($this->lng->txt("certificate_unit_description"));
308 $pagewidth->setRequired(true);
309 $option->addSubitem($pagewidth);
310 }
311 $pageformat->addOption($option);
312 }
313 $pageformat->setRequired(true);
314 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $pageformat->checkInput();
315
316 $form->addItem($pageformat);
317
318 $bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
319 $bgimage->setRequired(FALSE);
320 $bgimage->setUseCache(false);
321 if (count($_POST))
322 {
323 // handle the background upload
324 if (strlen($_FILES["background"]["tmp_name"]))
325 {
326 if ($bgimage->checkInput())
327 {
328 $result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
329 if ($result == FALSE)
330 {
331 $bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
332 }
333 }
334 }
335 }
336 if (!$this->object->hasBackgroundImage())
337 {
338 include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
340 {
342 }
343 }
344 else
345 {
346 $bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
347 }
348 $form->addItem($bgimage);
349
350 $padding_top = new ilTextInputGUI($this->lng->txt("certificate_padding_top"), "padding_top");
351 $padding_top->setRequired(TRUE);
352 $padding_top->setValue($form_fields["padding_top"]);
353 $padding_top->setSize(6);
354 $padding_top->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
355 $padding_top->setInfo($this->lng->txt("certificate_unit_description"));
356 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $padding_top->checkInput();
357 $form->addItem($padding_top);
358
359 $rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body");
360 $rect->setRequired(TRUE);
361 $rect->setUseUnits(TRUE);
362 $rect->setTop($form_fields["margin_body_top"]);
363 $rect->setBottom($form_fields["margin_body_bottom"]);
364 $rect->setLeft($form_fields["margin_body_left"]);
365 $rect->setRight($form_fields["margin_body_right"]);
366 $rect->setInfo($this->lng->txt("certificate_unit_description"));
367 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $rect->checkInput();
368 $form->addItem($rect);
369
370 $certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text");
371 $certificate->removePlugin('ilimgupload');
372 $certificate->setValue($form_fields["certificate_text"]);
373 $certificate->setRequired(TRUE);
374 $certificate->setRows(20);
375 $certificate->setCols(80);
376
377 // fraunhpatch start
378 $common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate");
380 {
381 $common_desc_tpl->setCurrentBlock("cert_field");
382 $common_desc_tpl->setVariable("PH", $f["ph"]);
383 $common_desc_tpl->setVariable("PH_TXT", $f["name"]);
384 $common_desc_tpl->parseCurrentBlock();
385 }
386 $common_desc = $common_desc_tpl->get();
387 // fraunhpatch start
388
389 $certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription().$common_desc);
390 $certificate->setUseRte(TRUE, '3.4.7');
391 $tags = array(
392 "br",
393 "em",
394 "font",
395 "li",
396 "ol",
397 "p",
398 "span",
399 "strong",
400 "u",
401 "ul"
402 );
403 $certificate->setRteTags($tags);
404 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $certificate->checkInput();
405 $form->addItem($certificate);
406
407 $this->object->getAdapter()->addAdditionalFormElements($form, $form_fields);
408
409 if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
410 {
411 if ($this->object->isComplete() || $this->object->hasBackgroundImage())
412 {
413 $form->addCommandButton("certificatePreview", $this->lng->txt("certificate_preview"));
414 $form->addCommandButton("certificateExportFO", $this->lng->txt("certificate_export"));
415 $form->addCommandButton("certificateDelete", $this->lng->txt("delete"));
416 }
417 $form->addCommandButton("certificateSave", $this->lng->txt("save"));
418 }
419
420 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
421
422 if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0)
423 {
424 if ($_POST["background_delete"])
425 {
426 $this->object->deleteBackgroundImage();
427 }
428 if ($form->checkInput())
429 {
430 try
431 {
432 $xslfo = $this->object->processXHTML2FO($form_fields);
433 $this->object->getAdapter()->saveFormFields($form_fields);
434 $this->object->saveCertificate($xslfo);
435 $this->object->writeActive($form_fields["active"]);
436 ilUtil::sendSuccess($this->lng->txt("saved_successfully"), TRUE);
437 $this->ctrl->redirect($this, "certificateEditor");
438 }
439 catch (Exception $e)
440 {
441 ilUtil::sendFailure($e->getMessage());
442 }
443 }
444 }
445 }
$result
$_GET["client_id"]
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.
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.
$_POST['username']
Definition: cron.php:12

References $_GET, $_POST, $result, ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), ilCertificate\getCustomCertificateFields(), getFormFieldsFromFO(), getFormFieldsFromPOST(), ilObjCertificateSettingsAccess\hasBackgroundImage(), ilUtil\sendFailure(), and ilUtil\sendSuccess().

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

151 {
152 $this->object->deliverExportFileXML();
153 }

◆ certificateImport()

ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

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

135 {
136 $this->certificateEditor();
137 }
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 142 of file class.ilCertificateGUI.php.

143 {
144 $this->object->createPreview();
145 }

◆ certificateRemoveBackground()

ilCertificateGUI::certificateRemoveBackground ( )

Removes the background image of a certificate.

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

159 {
160 $this->object->deleteBackgroundImage();
161 $this->certificateEditor();
162 }

References certificateEditor().

+ Here is the call graph for this function:

◆ certificateSave()

ilCertificateGUI::certificateSave ( )

Saves the certificate.

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

193 {
194 $this->certificateEditor();
195 }

References certificateEditor().

+ Here is the call graph for this function:

◆ certificateUpload()

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

201 {
202 $this->certificateEditor();
203 }

References certificateEditor().

+ Here is the call graph for this function:

◆ executeCommand()

& ilCertificateGUI::executeCommand ( )

execute command

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

109 {
110 $cmd = $this->ctrl->getCmd();
111 $next_class = $this->ctrl->getNextClass($this);
112
113 $cmd = $this->getCommand($cmd);
114 switch($next_class)
115 {
116 default:
117 $ret =& $this->$cmd();
118 break;
119 }
120 return $ret;
121 }
getCommand($cmd)
Retrieves the ilCtrl command.
$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 126 of file class.ilCertificateGUI.php.

127 {
128 return $cmd;
129 }

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

230 {
231 $form_fields = $this->object->getFormFieldsFromFO();
232 $form_fields["active"] = $this->object->readActive();
233 $this->object->getAdapter()->addFormFieldsFromObject($form_fields);
234 return $form_fields;
235 }

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

209 {
210 $form_fields = array(
211 "pageformat" => ilUtil::stripSlashes($_POST["pageformat"]),
212 "padding_top" => ilUtil::stripSlashes($_POST["padding_top"]),
213 "margin_body_top" => ilUtil::stripSlashes($_POST["margin_body"]["top"]),
214 "margin_body_right" => ilUtil::stripSlashes($_POST["margin_body"]["right"]),
215 "margin_body_bottom" => ilUtil::stripSlashes($_POST["margin_body"]["bottom"]),
216 "margin_body_left" => ilUtil::stripSlashes($_POST["margin_body"]["left"]),
217 "certificate_text" => ilUtil::stripSlashes($_POST["certificate_text"], FALSE),
218 "pageheight" => ilUtil::stripSlashes($_POST["pageheight"]),
219 "pagewidth" => ilUtil::stripSlashes($_POST["pagewidth"]),
220 "active" => ilUtil::stripSlashes($_POST["active"])
221 );
222 $this->object->getAdapter()->addFormFieldsFromPOST($form_fields);
223 return $form_fields;
224 }
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:

◆ ilCertificateGUI()

ilCertificateGUI::ilCertificateGUI (   $adapter)

ilCertificateGUI constructor

Parameters
object$a_objectA reference to the test container object @access public

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

91 {
92 global $lng, $tpl, $ilCtrl, $ilias, $tree;
93
94 include_once "./Services/Certificate/classes/class.ilCertificate.php";
95 $this->object = new ilCertificate($adapter);
96 $this->lng =& $lng;
97 $this->tpl =& $tpl;
98 $this->ctrl =& $ilCtrl;
99 $this->ilias =& $ilias;
100 $this->tree =& $tree;
101 $this->ref_id = $_GET["ref_id"];
102 $this->lng->loadLanguageModule("certificate");
103 }
Create PDF certificates.
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file)

References $_GET, $ilCtrl, $ilias, $lng, $tpl, and $tree.

Field Documentation

◆ $ctrl

ilCertificateGUI::$ctrl

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

◆ $ilias

ilCertificateGUI::$ilias

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

Referenced by ilCertificateGUI().

◆ $lng

ilCertificateGUI::$lng

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

Referenced by ilCertificateGUI().

◆ $object

ilCertificateGUI::$object

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

◆ $ref_id

ilCertificateGUI::$ref_id

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

◆ $tpl

ilCertificateGUI::$tpl

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

Referenced by ilCertificateGUI().

◆ $tree

ilCertificateGUI::$tree

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

Referenced by ilCertificateGUI().


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