ILIAS  Release_4_2_x_branch Revision 61807
 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

Private 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:
class.ilCertificateGUI.php 23079 2010-02-26 19:41:26Z hschottm

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

Member Function Documentation

ilCertificateGUI::certificateDelete ( )

Deletes the certificate and all its data.

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

{
include_once("Services/Utilities/classes/class.ilSimpleConfirmationGUI.php");
$c_gui = new ilSimpleConfirmationGUI();
// set confirm/cancel commands
$c_gui->setFormAction($this->ctrl->getFormAction($this, "certificateEditor"));
$c_gui->setHeaderText($this->lng->txt("certificate_confirm_deletion_text"));
$c_gui->setConfirm($this->lng->txt("yes"), "certificateDeleteConfirm");
$c_gui->setCancel($this->lng->txt("no"), "certificateEditor");
$this->tpl->setContent($c_gui->getHTML());
}
ilCertificateGUI::certificateDeleteConfirm ( )

Deletes the certificate and all its data.

Definition at line 181 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 236 of file class.ilCertificateGUI.php.

References $_GET, $_POST, $result, ilObjCertificateSettingsAccess\getBackgroundImageThumbPathWeb(), getFormFieldsFromFO(), getFormFieldsFromPOST(), ilObjCertificateSettingsAccess\hasBackgroundImage(), ilUtil\sendFailure(), ilUtil\sendSuccess(), ilFormPropertyGUI\setRequired(), ilTextInputGUI\setValue(), ilSelectInputGUI\setValue(), and ilTextAreaInputGUI\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");
$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->setValue($form_fields["certificate_text"]);
$certificate->setRequired(TRUE);
$certificate->setRows(20);
$certificate->setCols(80);
$certificate->setInfo($this->object->getAdapter()->getCertificateVariablesDescription());
$certificate->setUseRte(TRUE);
$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);
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 148 of file class.ilCertificateGUI.php.

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

Import a certificate from a ZIP archive.

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

References certificateEditor().

{
}

+ Here is the call graph for this function:

ilCertificateGUI::certificatePreview ( )

Creates a certificate preview.

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

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

Removes the background image of a certificate.

Definition at line 156 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 190 of file class.ilCertificateGUI.php.

References certificateEditor().

{
}

+ Here is the call graph for this function:

ilCertificateGUI::certificateUpload ( )

Uploads the certificate.

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

References certificateEditor().

{
}

+ Here is the call graph for this function:

& ilCertificateGUI::executeCommand ( )

execute command

Definition at line 106 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 124 of file class.ilCertificateGUI.php.

References $cmd.

Referenced by executeCommand().

{
return $cmd;
}

+ Here is the caller graph for this function:

ilCertificateGUI::getFormFieldsFromFO ( )
private

Get the form values from the certificate xsl-fo.

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

Referenced by certificateEditor().

{
$form_fields = $this->object->getFormFieldsFromFO();
$this->object->getAdapter()->addFormFieldsFromObject($form_fields);
return $form_fields;
}

+ Here is the caller graph for this function:

ilCertificateGUI::getFormFieldsFromPOST ( )
private

Get the form values from an HTTP POST.

Definition at line 206 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"])
);
$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 88 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 45 of file class.ilCertificateGUI.php.

ilCertificateGUI::$ilias

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

Referenced by ilCertificateGUI().

ilCertificateGUI::$lng

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

Referenced by ilCertificateGUI().

ilCertificateGUI::$object

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

ilCertificateGUI::$ref_id

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

ilCertificateGUI::$tpl

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

Referenced by ilCertificateGUI().

ilCertificateGUI::$tree

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

Referenced by ilCertificateGUI().


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