ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilCertificateGUI Class Reference

GUI class to create PDF certificates. More...

+ Collaboration diagram for ilCertificateGUI:

Public Member Functions

 ilCertificateGUI ($adapter)
 ilCertificateGUI constructor
executeCommand ()
 execute command
 getCommand ($cmd)
 Retrieves the ilCtrl command.
 certificateImport ()
 Import a certificate from a ZIP archive.
 certificatePreview ()
 Creates a certificate preview.
 certificateExportFO ()
 Exports the certificate.
 certificateRemoveBackground ()
 Removes the background image of a certificate.
 certificateDelete ()
 Deletes the certificate and all its data.
 certificateDeleteConfirm ()
 Deletes the certificate and all its data.
 certificateSave ()
 Saves the certificate.
 certificateUpload ()
 Uploads the certificate.
 certificateEditor ()
 Shows the certificate editor for ILIAS tests.

Data Fields

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

Protected Member Functions

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

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

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

{
// display confirmation message
include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
$cgui = new ilConfirmationGUI();
$cgui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
$cgui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
$cgui->setCancel($this->lng->txt("no"), "certificateEditor");
$cgui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
$this->tpl->setContent($cgui->getHTML());
}
ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

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

{
$this->object->deleteCertificate();
$this->ctrl->redirect($this, "certificateEditor");
}
ilCertificateGUI::certificateEditor ( )

Shows the certificate editor for ILIAS tests.

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

References $_GET, $_POST, $result, ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), ilCertificate\getCustomCertificateFields(), getFormFieldsFromFO(), getFormFieldsFromPOST(), ilObjCertificateSettingsAccess\hasBackgroundImage(), ilTextAreaInputGUI\removePlugin(), ilUtil\sendFailure(), ilUtil\sendSuccess(), ilCheckboxInputGUI\setChecked(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setValue(), and ilSelectInputGUI\setValue().

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

{
global $ilAccess;
$form_fields = array();
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0)
{
$form_fields = $this->getFormFieldsFromPOST();
}
else
{
$form_fields = $this->getFormFieldsFromFO();
}
include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
$form = new ilPropertyFormGUI();
$form->setFormAction($this->ctrl->getFormAction($this));
$form->setTitle($this->lng->txt("certificate_edit"));
$form->setMultipart(TRUE);
$form->setTableWidth("100%");
$form->setId("certificate");
$active = new ilCheckboxInputGUI($this->lng->txt("active"), "active");
$active->setChecked($form_fields["active"]);
$form->addItem($active);
$import = new ilFileInputGUI($this->lng->txt("import"), "certificate_import");
$import->setRequired(FALSE);
$import->setSuffixes(array("zip"));
// handle the certificate import
if (strlen($_FILES["certificate_import"]["tmp_name"]))
{
if ($import->checkInput())
{
$result = $this->object->importCertificate($_FILES["certificate_import"]["tmp_name"], $_FILES["certificate_import"]["name"]);
if ($result == FALSE)
{
$import->setAlert($this->lng->txt("certificate_error_import"));
}
else
{
$this->ctrl->redirect($this, "certificateEditor");
}
}
}
$form->addItem($import);
$pageformat = new ilSelectInputGUI($this->lng->txt("certificate_page_format"), "pageformat");
$pageformats = $this->object->getPageFormats();
$pageformat->setValue($form_fields["pageformat"]);
$options = array();
foreach ($pageformats as $format)
{
$options[$format["value"]] = $format["name"];
}
$pageformat->setRequired(TRUE);
$pageformat->setOptions($options);
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $pageformat->checkInput();
if (strcmp($form_fields["pageformat"], "custom") == 0)
{
$pageheight = new ilTextInputGUI($this->lng->txt("certificate_pageheight"), "pageheight");
$pageheight->setValue($form_fields["pageheight"]);
$pageheight->setSize(6);
$pageheight->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
$pageheight->setInfo($this->lng->txt("certificate_unit_description"));
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $pageheight->checkInput();
$pageformat->addSubitem($pageheight);
$pagewidth = new ilTextInputGUI($this->lng->txt("certificate_pagewidth"), "pagewidth");
$pagewidth->setValue($form_fields["pagewidth"]);
$pagewidth->setSize(6);
$pagewidth->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
$pagewidth->setInfo($this->lng->txt("certificate_unit_description"));
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $pagewidth->checkInput();
$pageformat->addSubitem($pagewidth);
}
$form->addItem($pageformat);
$bgimage = new ilImageFileInputGUI($this->lng->txt("certificate_background_image"), "background");
$bgimage->setRequired(FALSE);
$bgimage->setUseCache(false);
if (count($_POST))
{
// handle the background upload
if (strlen($_FILES["background"]["tmp_name"]))
{
if ($bgimage->checkInput())
{
$result = $this->object->uploadBackgroundImage($_FILES["background"]["tmp_name"]);
if ($result == FALSE)
{
$bgimage->setAlert($this->lng->txt("certificate_error_upload_bgimage"));
}
}
}
}
if (!$this->object->hasBackgroundImage())
{
include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
{
}
}
else
{
$bgimage->setImage($this->object->getBackgroundImageThumbPathWeb());
}
$form->addItem($bgimage);
$padding_top = new ilTextInputGUI($this->lng->txt("certificate_padding_top"), "padding_top");
$padding_top->setRequired(TRUE);
$padding_top->setValue($form_fields["padding_top"]);
$padding_top->setSize(6);
$padding_top->setValidationRegexp("/[0123456789\\.](cm|mm|in|pt|pc|px|em)/is");
$padding_top->setInfo($this->lng->txt("certificate_unit_description"));
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $padding_top->checkInput();
$form->addItem($padding_top);
$rect = new ilCSSRectInputGUI($this->lng->txt("certificate_margin_body"), "margin_body");
$rect->setRequired(TRUE);
$rect->setUseUnits(TRUE);
$rect->setTop($form_fields["margin_body_top"]);
$rect->setBottom($form_fields["margin_body_bottom"]);
$rect->setLeft($form_fields["margin_body_left"]);
$rect->setRight($form_fields["margin_body_right"]);
$rect->setInfo($this->lng->txt("certificate_unit_description"));
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $rect->checkInput();
$form->addItem($rect);
$certificate = new ilTextAreaInputGUI($this->lng->txt("certificate_text"), "certificate_text");
$certificate->removePlugin('ilimgupload');
$certificate->setValue($form_fields["certificate_text"]);
$certificate->setRequired(TRUE);
$certificate->setRows(20);
$certificate->setCols(80);
// fraunhpatch start
$common_desc_tpl = new ilTemplate("tpl.common_desc.html", true, true, "Services/Certificate");
{
$common_desc_tpl->setCurrentBlock("cert_field");
$common_desc_tpl->setVariable("PH", $f["ph"]);
$common_desc_tpl->setVariable("PH_TXT", $f["name"]);
$common_desc_tpl->parseCurrentBlock();
}
$common_desc = $common_desc_tpl->get();
// fraunhpatch start
$certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription().$common_desc);
$certificate->setUseRte(TRUE, '3.4.7');
$tags = array(
"br",
"em",
"font",
"li",
"ol",
"p",
"span",
"strong",
"u",
"ul"
);
$certificate->setRteTags($tags);
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0) $certificate->checkInput();
$form->addItem($certificate);
$this->object->getAdapter()->addAdditionalFormElements($form, $form_fields);
if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
{
if ($this->object->isComplete() || $this->object->hasBackgroundImage())
{
$form->addCommandButton("certificatePreview", $this->lng->txt("certificate_preview"));
$form->addCommandButton("certificateExportFO", $this->lng->txt("certificate_export"));
$form->addCommandButton("certificateDelete", $this->lng->txt("delete"));
}
$form->addCommandButton("certificateSave", $this->lng->txt("save"));
}
$this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
if (strcmp($this->ctrl->getCmd(), "certificateSave") == 0)
{
if ($_POST["background_delete"])
{
$this->object->deleteBackgroundImage();
}
if ($form->checkInput())
{
try
{
$xslfo = $this->object->processXHTML2FO($form_fields);
$this->object->getAdapter()->saveFormFields($form_fields);
$this->object->saveCertificate($xslfo);
$this->object->writeActive($form_fields["active"]);
ilUtil::sendSuccess($this->lng->txt("saved_successfully"), TRUE);
$this->ctrl->redirect($this, "certificateEditor");
}
catch (Exception $e)
{
ilUtil::sendFailure($e->getMessage());
}
}
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCertificateGUI::certificateExportFO ( )

Exports the certificate.

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

{
$this->object->deliverExportFileXML();
}
ilCertificateGUI::certificateImport ( )

Import a certificate from a ZIP archive.

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

References certificateEditor().

{
}

+ Here is the call graph for this function:

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

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

{
$this->object->createPreview();
}
ilCertificateGUI::certificateRemoveBackground ( )

Removes the background image of a certificate.

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

References certificateEditor().

{
$this->object->deleteBackgroundImage();
}

+ Here is the call graph for this function:

ilCertificateGUI::certificateSave ( )

Saves the certificate.

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

References certificateEditor().

{
}

+ Here is the call graph for this function:

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

References certificateEditor().

{
}

+ Here is the call graph for this function:

& ilCertificateGUI::executeCommand ( )

execute command

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

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

{
$cmd = $this->ctrl->getCmd();
$next_class = $this->ctrl->getNextClass($this);
$cmd = $this->getCommand($cmd);
switch($next_class)
{
default:
$ret =& $this->$cmd();
break;
}
return $ret;
}

+ Here is the call graph for this function:

ilCertificateGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

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

References $cmd.

Referenced by executeCommand().

{
return $cmd;
}

+ Here is the caller graph for this function:

ilCertificateGUI::getFormFieldsFromFO ( )
protected

Get the form values from the certificate xsl-fo.

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

Referenced by certificateEditor().

{
$form_fields = $this->object->getFormFieldsFromFO();
$form_fields["active"] = $this->object->readActive();
$this->object->getAdapter()->addFormFieldsFromObject($form_fields);
return $form_fields;
}

+ Here is the caller graph for this function:

ilCertificateGUI::getFormFieldsFromPOST ( )
protected

Get the form values from an HTTP POST.

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

References $_POST, and ilUtil\stripSlashes().

Referenced by certificateEditor().

{
$form_fields = array(
"pageformat" => ilUtil::stripSlashes($_POST["pageformat"]),
"padding_top" => ilUtil::stripSlashes($_POST["padding_top"]),
"margin_body_top" => ilUtil::stripSlashes($_POST["margin_body"]["top"]),
"margin_body_right" => ilUtil::stripSlashes($_POST["margin_body"]["right"]),
"margin_body_bottom" => ilUtil::stripSlashes($_POST["margin_body"]["bottom"]),
"margin_body_left" => ilUtil::stripSlashes($_POST["margin_body"]["left"]),
"certificate_text" => ilUtil::stripSlashes($_POST["certificate_text"], FALSE),
"pageheight" => ilUtil::stripSlashes($_POST["pageheight"]),
"pagewidth" => ilUtil::stripSlashes($_POST["pagewidth"]),
"active" => ilUtil::stripSlashes($_POST["active"])
);
$this->object->getAdapter()->addFormFieldsFromPOST($form_fields);
return $form_fields;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilCertificateGUI::ilCertificateGUI (   $adapter)

ilCertificateGUI constructor

Parameters
object$a_objectA reference to the test container object public

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

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

{
include_once "./Services/Certificate/classes/class.ilCertificate.php";
$this->object = new ilCertificate($adapter);
$this->lng =& $lng;
$this->tpl =& $tpl;
$this->ctrl =& $ilCtrl;
$this->ilias =& $ilias;
$this->tree =& $tree;
$this->ref_id = $_GET["ref_id"];
$this->lng->loadLanguageModule("certificate");
}

Field Documentation

ilCertificateGUI::$ctrl

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

ilCertificateGUI::$ilias

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

Referenced by ilCertificateGUI().

ilCertificateGUI::$lng

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

Referenced by ilCertificateGUI().

ilCertificateGUI::$object

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

ilCertificateGUI::$ref_id

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

ilCertificateGUI::$tpl

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

Referenced by ilCertificateGUI().

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: