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

Create PDF certificates. More...

+ Collaboration diagram for ilCertificate:

Public Member Functions

 __construct ($adapter)
 ilCertificate constructor More...
 
 getBackgroundImagePath ()
 Returns the filesystem path of the background image. More...
 
 getBackgroundImageName ()
 Returns the filename of the background image. More...
 
 getBackgroundImageThumbPath ()
 Returns the filesystem path of the background image thumbnail. More...
 
 getBackgroundImageTempfilePath ()
 Returns the filesystem path of the background image temp file during upload. More...
 
 getXSLPath ()
 Returns the filesystem path of the XSL-FO file. More...
 
 getXSLName ()
 Returns the filename of the XSL-FO file. More...
 
 getBackgroundImagePathWeb ()
 Returns the web path of the background image. More...
 
 getBackgroundImageThumbPathWeb ()
 Returns the web path of the background image thumbnail. More...
 
 deleteBackgroundImage ()
 Deletes the background image of a certificate. More...
 
 cloneCertificate (ilCertificate $newObject)
 Clone the certificate for another test object. More...
 
 deleteCertificate ()
 Deletes the certificate and all it's data. More...
 
 getFormFieldsFromFO ()
 Convert the XSL-FO to the certificate text and the form settings using XSL transformation. More...
 
 processXHTML2FO ($form_data, $for_export=FALSE)
 Convert the certificate text to XSL-FO using XSL transformation. More...
 
 outCertificate ($params, $deliver=TRUE)
 Creates a PDF certificate. More...
 
 createPreview ()
 Creates a PDF preview of the XSL-FO certificate. More...
 
 saveCertificate ($xslfo, $filename="")
 Saves the XSL-FO code to a file. More...
 
 uploadBackgroundImage ($image_tempfilename)
 Uploads a background image for the certificate. More...
 
 hasBackgroundImage ()
 Checks for the background image of the certificate. More...
 
 isComplete ()
 Checks the status of the certificate. More...
 
 _isComplete ($adapter)
 Checks the status of the certificate. More...
 
 getPageFormats ()
 Retrieves predefined page formats. More...
 
 deliverExportFileXML ()
 Builds an export file in ZIP format and delivers it. More...
 
 importCertificate ($zipfile, $filename)
 Reads an import ZIP file and creates a certificate of it. More...
 
 getAdapter ()
 Gets the adapter. More...
 
 setAdapter ($adapter)
 Sets the adapter. More...
 
 createArchiveDirectory ()
 
 addPDFtoArchiveDirectory ($pdfdata, $dir, $filename)
 Adds PDF data as a file to a given directory. More...
 
 zipCertificatesInArchiveDirectory ($dir, $deliver=TRUE)
 Create a ZIP file from a directory with certificates. More...
 
 readActive ()
 
 writeActive ($a_value)
 
 getExchangeContent ()
 
 outCertificateWithGivenContentAndVariables ($content, $insert_tags)
 

Static Public Member Functions

static _getXSLName ()
 Returns the filename of the XSL-FO file. More...
 
static isActive ()
 
static isObjectActive ($a_obj_id)
 
static areObjectsActive (array $a_obj_ids)
 
static _goto ($ref_id)
 Creates a redirect to a certificate download. More...
 
static getCustomCertificateFields ()
 Get custom certificate fields. More...
 

Protected Attributes

 $ctrl
 
 $tree
 
 $ilias
 
 $tpl
 
 $lng
 
 $adapter
 

Static Protected Attributes

static $is_active
 

Private Member Functions

 exchangeCertificateVariables ($certificate_text, $insert_tags=array())
 Exchanges the variables in the certificate text with given values. More...
 

Detailed Description

Create PDF certificates.

Base class to create PDF certificates using XML-FO XML transformations

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 15 of file class.ilCertificate.php.

Constructor & Destructor Documentation

◆ __construct()

ilCertificate::__construct (   $adapter)

ilCertificate constructor

Parameters
object$adapterThe certificate adapter needed to construct the certificate

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

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

67  {
68  global $lng, $tpl, $ilCtrl, $ilias, $tree;
69 
70  $this->lng =& $lng;
71  $this->tpl =& $tpl;
72  $this->ctrl =& $ilCtrl;
73  $this->ilias =& $ilias;
74  $this->tree =& $tree;
75  $this->adapter =& $adapter;
76  }
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...

Member Function Documentation

◆ _getXSLName()

static ilCertificate::_getXSLName ( )
static

Returns the filename of the XSL-FO file.

Returns
string The filename of the XSL-FO file

Definition at line 143 of file class.ilCertificate.php.

Referenced by _isComplete().

144  {
145  return "certificate.xml";
146  }
+ Here is the caller graph for this function:

◆ _goto()

static ilCertificate::_goto (   $ref_id)
static

Creates a redirect to a certificate download.

Parameters
integer$ref_idRef ID of the ILIAS object

Definition at line 1009 of file class.ilCertificate.php.

1010  {
1011  global $ilCtrl;
1012  include_once "./Services/Object/classes/class.ilObject.php";
1013  $type = ilObject::_lookupType($ref_id, true);
1014  switch ($type)
1015  {
1016  case 'sahs':
1017  $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$ref_id.
1018  "&cmd=downloadCertificate";
1019  ilUtil::redirect($cmd_link);
1020  break;
1021  case 'tst':
1022  default:
1023  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
1024  break;
1025  }
1026  }
global $ilCtrl
Definition: ilias.php:18
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
static redirect($a_script)
http redirect to other script

◆ _isComplete()

ilCertificate::_isComplete (   $adapter)

Checks the status of the certificate.

Parameters
object$adapterThe certificate adapter
Returns
boolean Returns TRUE if the certificate is complete, FALSE otherwise

Definition at line 666 of file class.ilCertificate.php.

References $adapter, and _getXSLName().

Referenced by ilCourseVerificationTableGUI\getItems(), ilExerciseVerificationTableGUI\getItems(), ilSCORMVerificationTableGUI\getItems(), ilTestEvaluationGUI\resetfilterEvaluation(), and ilObjExerciseGUI\showOverviewObject().

667  {
668  if (is_object($adapter) && method_exists($adapter, "getCertificatePath"))
669  {
670  if(self::isActive())
671  {
672  $obj_id = $adapter->getCertificateID();
673  if($obj_id && !self::isObjectActive($obj_id))
674  {
675  return FALSE;
676  }
677 
678  $certificatepath = $adapter->getCertificatePath();
679  if (file_exists($certificatepath))
680  {
681  $xslpath = $adapter->getCertificatePath() . ilCertificate::_getXSLName();
682  if (file_exists($xslpath) && (filesize($xslpath) > 0))
683  {
684  return TRUE;
685  }
686  }
687  }
688  }
689  return FALSE;
690  }
static _getXSLName()
Returns the filename of the XSL-FO file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addPDFtoArchiveDirectory()

ilCertificate::addPDFtoArchiveDirectory (   $pdfdata,
  $dir,
  $filename 
)

Adds PDF data as a file to a given directory.

Parameters
binary$pdfdataBinary PDF data
string$dirDirectory to contain the PDF data
string$filenameThe filename to save the PDF data

Definition at line 905 of file class.ilCertificate.php.

906  {
907  $fh = fopen($dir . $filename, "wb");
908  fwrite($fh, $pdfdata);
909  fclose($fh);
910  }
$filename
Definition: buildRTE.php:89

◆ areObjectsActive()

static ilCertificate::areObjectsActive ( array  $a_obj_ids)
static

Definition at line 956 of file class.ilCertificate.php.

Referenced by ilCourseCertificateAdapter\_preloadListData(), and ilSCORMVerificationTableGUI\getItems().

957  {
958  global $ilDB;
959 
960  $all = array();
961  foreach($a_obj_ids as $id)
962  {
963  $all[$id] = false;
964  }
965 
966  $set = $ilDB->query("SELECT obj_id FROM il_certificate".
967  " WHERE ".$ilDB->in("obj_id", $a_obj_ids, "", "integer"));
968  while($row = $ilDB->fetchAssoc($set))
969  {
970  $all[$row["obj_id"]] = true;
971  }
972  return $all;
973  }
global $ilDB
+ Here is the caller graph for this function:

◆ cloneCertificate()

ilCertificate::cloneCertificate ( ilCertificate  $newObject)

Clone the certificate for another test object.

Parameters
$newObjectThe new certificate object

Definition at line 201 of file class.ilCertificate.php.

References getAdapter(), getBackgroundImagePath(), getBackgroundImageThumbPath(), getXSLPath(), ilUtil\makeDirParents(), readActive(), and writeActive().

202  {
203  $xsl = $this->getXSLPath();
204  $bgimage = $this->getBackgroundImagePath();
205  $bgimagethumb = $this->getBackgroundImageThumbPath();
206  $certificatepath = $this->getAdapter()->getCertificatePath();
207 
208  $new_xsl = $newObject->getXSLPath();
209  $new_bgimage = $newObject->getBackgroundImagePath();
210  $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
211  $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
212 
213  if (@file_exists($xsl))
214  {
215  ilUtil::makeDirParents($new_certificatepath);
216  @copy($xsl, $new_xsl);
217  if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
218  if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
219  }
220 
221  // #10271
222  if($this->readActive())
223  {
224  $newObject->writeActive(true);
225  }
226  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
+ Here is the call graph for this function:

◆ createArchiveDirectory()

ilCertificate::createArchiveDirectory ( )

Definition at line 890 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and importCertificate().

891  {
892  $dir = $this->getAdapter()->getCertificatePath() . time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate/";
893  include_once "./Services/Utilities/classes/class.ilUtil.php";
895  return $dir;
896  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getAdapter()
Gets the adapter.
+ Here is the caller graph for this function:

◆ createPreview()

ilCertificate::createPreview ( )

Creates a PDF preview of the XSL-FO certificate.

Definition at line 516 of file class.ilCertificate.php.

References $ilLog, ilUtil\deliverData(), exchangeCertificateVariables(), ilRpcClientFactory\factory(), getXSLPath(), and ilDatePresentation\setUseRelativeDates().

517  {
518  global $ilLog;
519 
521 
522  $xslfo = file_get_contents($this->getXSLPath());
523 
524  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
525  try
526  {
527  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
528  $this->exchangeCertificateVariables($xslfo));
529  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
530 
531  }
532  catch(XML_RPC2_FaultException $e)
533  {
534  $ilLog->write(__METHOD__.': '.$e->getMessage());
535  return false;
536  }
537  catch(Exception $e)
538  {
539  $ilLog->write(__METHOD__.': '.$e->getMessage());
540  return false;
541  }
542 
544 
545  /*
546  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
547  $fo2pdf = new ilFO2PDF();
548  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo));
549  $result = $fo2pdf->send();
550  include_once "./Services/Utilities/classes/class.ilUtil.php";
551  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename(), "application/pdf");
552  */
553  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static setUseRelativeDates($a_status)
set use relative dates
getXSLPath()
Returns the filesystem path of the XSL-FO file.
static factory($a_package)
Create an XML_RPC2 client instance.
exchangeCertificateVariables($certificate_text, $insert_tags=array())
Exchanges the variables in the certificate text with given values.
+ Here is the call graph for this function:

◆ deleteBackgroundImage()

ilCertificate::deleteBackgroundImage ( )

Deletes the background image of a certificate.

Returns
boolean TRUE if the process succeeds

Definition at line 178 of file class.ilCertificate.php.

References $result, getBackgroundImagePath(), getBackgroundImageTempfilePath(), and getBackgroundImageThumbPath().

179  {
180  $result = TRUE;
181  if (file_exists($this->getBackgroundImageThumbPath()))
182  {
183  $result = $result & unlink($this->getBackgroundImageThumbPath());
184  }
185  if (file_exists($this->getBackgroundImagePath()))
186  {
187  $result = $result & unlink($this->getBackgroundImagePath());
188  }
189  if (file_exists($this->getBackgroundImageTempfilePath()))
190  {
191  $result = $result & unlink($this->getBackgroundImageTempfilePath());
192  }
193  return $result;
194  }
$result
getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
+ Here is the call graph for this function:

◆ deleteCertificate()

ilCertificate::deleteCertificate ( )

Deletes the certificate and all it's data.

public

Definition at line 233 of file class.ilCertificate.php.

References ilUtil\delDir(), getAdapter(), and writeActive().

234  {
235  if (@file_exists($this->getAdapter()->getCertificatePath()))
236  {
237  include_once "./Services/Utilities/classes/class.ilUtil.php";
238  ilUtil::delDir($this->getAdapter()->getCertificatePath());
239  $this->getAdapter()->deleteCertificate();
240  }
241  $this->writeActive(false);
242  }
getAdapter()
Gets the adapter.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ deliverExportFileXML()

ilCertificate::deliverExportFileXML ( )

Builds an export file in ZIP format and delivers it.

Definition at line 748 of file class.ilCertificate.php.

References createArchiveDirectory(), ilUtil\delDir(), ilUtil\deliverFile(), getAdapter(), ilObjCertificateSettingsAccess\getBackgroundImageName(), getBackgroundImageName(), ilObjCertificateSettingsAccess\getBackgroundImagePath(), getBackgroundImagePath(), getXSLName(), getXSLPath(), ilObjCertificateSettingsAccess\hasBackgroundImage(), hasBackgroundImage(), ilUtil\makeDir(), saveCertificate(), and ilUtil\zip().

749  {
750  include_once "./Services/Utilities/classes/class.ilUtil.php";
751  $exportpath = $this->createArchiveDirectory();
752  ilUtil::makeDir($exportpath);
753  $xsl = file_get_contents($this->getXSLPath());
754  $xslexport = str_replace($this->getAdapter()->getCertificatePath(), "", $xsl);
755  // save export xsl file
756  $this->saveCertificate($xslexport, $exportpath . $this->getXSLName());
757  // save background image
758  if ($this->hasBackgroundImage())
759  {
760  copy($this->getBackgroundImagePath(), $exportpath . $this->getBackgroundImageName());
761  }
762  else
763  {
764  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
766  {
768  }
769  }
770  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate.zip";
771  ilUtil::zip($exportpath, $this->getAdapter()->getCertificatePath() . $zipfile);
772  ilUtil::delDir($exportpath);
773  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
774  }
getBackgroundImagePath()
Returns the filesystem path of the background image.
static getBackgroundImageName()
Returns the filename of the background image.
hasBackgroundImage()
Checks for the background image of the certificate.
saveCertificate($xslfo, $filename="")
Saves the XSL-FO code to a file.
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static hasBackgroundImage()
Returns wheather or not a default background image exists.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageName()
Returns the filename of the background image.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
getXSLName()
Returns the filename of the XSL-FO file.
+ Here is the call graph for this function:

◆ exchangeCertificateVariables()

ilCertificate::exchangeCertificateVariables (   $certificate_text,
  $insert_tags = array() 
)
private

Exchanges the variables in the certificate text with given values.

Parameters
string$certificate_textThe XSL-FO certificate text
array$insert_tagsAn associative array containing the variables and the values to replace
Returns
string XSL-FO code

Definition at line 429 of file class.ilCertificate.php.

References getAdapter().

Referenced by createPreview(), and outCertificate().

430  {
431  if (count($insert_tags) == 0)
432  {
433  $insert_tags = $this->getAdapter()->getCertificateVariablesForPreview();
434 
435  foreach (self::getCustomCertificateFields() as $k => $f)
436  {
437  $insert_tags[$f["ph"]] = $f["name"];
438  }
439  }
440  foreach ($insert_tags as $var => $value)
441  {
442  $certificate_text = str_replace($var, $value, $certificate_text);
443  }
444  return $certificate_text;
445  }
getAdapter()
Gets the adapter.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdapter()

◆ getBackgroundImageName()

ilCertificate::getBackgroundImageName ( )

Returns the filename of the background image.

Returns
string The filename of the background image

Definition at line 93 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), getBackgroundImagePath(), getBackgroundImagePathWeb(), getBackgroundImageThumbPath(), and uploadBackgroundImage().

94  {
95  return "background.jpg";
96  }
+ Here is the caller graph for this function:

◆ getBackgroundImagePath()

ilCertificate::getBackgroundImagePath ( )

Returns the filesystem path of the background image.

Returns
string The filesystem path of the background image

Definition at line 83 of file class.ilCertificate.php.

References getAdapter(), and getBackgroundImageName().

Referenced by cloneCertificate(), deleteBackgroundImage(), deliverExportFileXML(), hasBackgroundImage(), importCertificate(), processXHTML2FO(), and uploadBackgroundImage().

84  {
85  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
86  }
getAdapter()
Gets the adapter.
getBackgroundImageName()
Returns the filename of the background image.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackgroundImagePathWeb()

ilCertificate::getBackgroundImagePathWeb ( )

Returns the web path of the background image.

Returns
string The web path of the background image

Definition at line 153 of file class.ilCertificate.php.

References getAdapter(), getBackgroundImageName(), ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

154  {
155  // TODO: this is generic now -> provide better solution
156  include_once "./Services/Utilities/classes/class.ilUtil.php";
157  $webdir = $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
159  }
getAdapter()
Gets the adapter.
const ILIAS_ABSOLUTE_PATH
static removeTrailingPathSeparators($path)
getBackgroundImageName()
Returns the filename of the background image.
+ Here is the call graph for this function:

◆ getBackgroundImageTempfilePath()

ilCertificate::getBackgroundImageTempfilePath ( )

Returns the filesystem path of the background image temp file during upload.

Returns
string The filesystem path of the background image temp file

Definition at line 113 of file class.ilCertificate.php.

References getAdapter().

Referenced by deleteBackgroundImage(), and uploadBackgroundImage().

114  {
115  return $this->getAdapter()->getCertificatePath() . "background_upload";
116  }
getAdapter()
Gets the adapter.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackgroundImageThumbPath()

ilCertificate::getBackgroundImageThumbPath ( )

Returns the filesystem path of the background image thumbnail.

Returns
string The filesystem path of the background image thumbnail

Definition at line 103 of file class.ilCertificate.php.

References getAdapter(), and getBackgroundImageName().

Referenced by cloneCertificate(), deleteBackgroundImage(), getBackgroundImageThumbPathWeb(), importCertificate(), and uploadBackgroundImage().

104  {
105  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName() . ".thumb.jpg";
106  }
getAdapter()
Gets the adapter.
getBackgroundImageName()
Returns the filename of the background image.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getBackgroundImageThumbPathWeb()

ilCertificate::getBackgroundImageThumbPathWeb ( )

Returns the web path of the background image thumbnail.

Returns
string The web path of the background image thumbnail

Definition at line 166 of file class.ilCertificate.php.

References getBackgroundImageThumbPath(), ILIAS_ABSOLUTE_PATH, and ilUtil\removeTrailingPathSeparators().

167  {
168  // TODO: this is generic now -> provide better solution
169  include_once "./Services/Utilities/classes/class.ilUtil.php";
171  }
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
const ILIAS_ABSOLUTE_PATH
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:

◆ getCustomCertificateFields()

static ilCertificate::getCustomCertificateFields ( )
static

Get custom certificate fields.

Definition at line 1031 of file class.ilCertificate.php.

Referenced by ilCertificateGUI\certificateEditor().

1032  {
1033  include_once("./Services/User/classes/class.ilUserDefinedFields.php");
1034  $user_field_definitions = ilUserDefinedFields::_getInstance();
1035  $fds = $user_field_definitions->getDefinitions();
1036  $fields = array();
1037  foreach ($fds as $f)
1038  {
1039  if ($f["certificate"])
1040  {
1041  $fields[$f["field_id"]] = array("name" => $f["field_name"],
1042  "ph" => "[#".str_replace(" ", "_", strtoupper($f["field_name"]))."]");
1043  }
1044  }
1045 
1046  return $fields;
1047  }
static _getInstance()
Get instance.
+ Here is the caller graph for this function:

◆ getExchangeContent()

ilCertificate::getExchangeContent ( )
Returns
string

Definition at line 1052 of file class.ilCertificate.php.

1053  {
1054  if(!file_exists($this->getXSLPath()))
1055  {
1056  return '';
1057  }
1058 
1059  $output = '';
1060  $xsl_file_content = file_get_contents($this->getXSLPath());
1061  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
1062 
1063  if((strlen($xsl_file_content)) && (strlen($xsl)))
1064  {
1065  $args = array('/_xml' => $xsl_file_content, '/_xsl' => $xsl);
1066  $xh = xslt_create();
1067  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
1068  xslt_error($xh);
1069  xslt_free($xh);
1070  }
1071 
1072  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
1073  // dirty hack: the php xslt processing seems not to recognize the following
1074  // replacements, so we do it in the code as well
1075  $output = str_replace("&#xA0;", "<br />", $output);
1076  $output = str_replace("&#160;", "<br />", $output);
1077 
1078  return $output;
1079  }
xslt_create()
xslt_free(&$proc)
xslt_error(&$proc)
getXSLPath()
Returns the filesystem path of the XSL-FO file.

◆ getFormFieldsFromFO()

ilCertificate::getFormFieldsFromFO ( )

Convert the XSL-FO to the certificate text and the form settings using XSL transformation.

Definition at line 247 of file class.ilCertificate.php.

References getAdapter(), getXSLPath(), xslt_create(), xslt_error(), and xslt_free().

248  {
249  if (@file_exists($this->getXSLPath()))
250  {
251  $xslfo = file_get_contents($this->getXSLPath());
252  }
253  // retrieve form information (using a dirty way with regular expressions)
254  $pagewidth = "21cm";
255  if (preg_match("/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
256  {
257  $pagewidth = $matches[1];
258  }
259  $pageheight = "29.7cm";
260  if (preg_match("/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
261  {
262  $pageheight = $matches[1];
263  }
264  $certificatesettings = new ilSetting("certificate");
265  $pagesize = $certificatesettings->get("pageformat");;
266  if (((strcmp($pageheight, "29.7cm") == 0) || (strcmp($pageheight, "297mm") == 0)) && ((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)))
267  {
268  $pagesize = "a4";
269  }
270  else if (((strcmp($pagewidth, "29.7cm") == 0) || (strcmp($pagewidth, "297mm") == 0)) && ((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)))
271  {
272  $pagesize = "a4landscape";
273  }
274  else if (((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)) && ((strcmp($pagewidth, "14.8cm") == 0) || (strcmp($pagewidth, "148mm") == 0)))
275  {
276  $pagesize = "a5";
277  }
278  else if (((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)) && ((strcmp($pageheight, "14.8cm") == 0) || (strcmp($pageheight, "148mm") == 0)))
279  {
280  $pagesize = "a5landscape";
281  }
282  else if (((strcmp($pageheight, "11in") == 0)) && ((strcmp($pagewidth, "8.5in") == 0)))
283  {
284  $pagesize = "letter";
285  }
286  else if (((strcmp($pagewidth, "11in") == 0)) && ((strcmp($pageheight, "8.5in") == 0)))
287  {
288  $pagesize = "letterlandscape";
289  }
290  else
291  {
292  $pagesize = "custom";
293  }
294  if (!strlen($xslfo)) $pagesize = $certificatesettings->get("pageformat");;
295 
296  $paddingtop = "0cm";
297  if (preg_match("/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
298  {
299  $paddingtop = $matches[1];
300  }
301  $marginbody_top = "0cm";
302  $marginbody_right = "2cm";
303  $marginbody_bottom = "0cm";
304  $marginbody_left = "2cm";
305  if(preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
306  {
307  // Backwards compatibility
308  $marginbody = $matches[1];
309  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
310  {
311  $marginbody_top = $matches[1][0];
312  $marginbody_right = $matches[1][1];
313  $marginbody_bottom = $matches[1][2];
314  $marginbody_left = $matches[1][3];
315  }
316  }
317  else if(preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
318  {
319  $marginbody = $matches[1];
320  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
321  {
322  $marginbody_top = $matches[1][0];
323  $marginbody_right = $matches[1][1];
324  $marginbody_bottom = $matches[1][2];
325  $marginbody_left = $matches[1][3];
326  }
327  }
328 
329  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
330  if ((strlen($xslfo)) && (strlen($xsl)))
331  {
332  $args = array( '/_xml' => $xslfo, '/_xsl' => $xsl );
333  $xh = xslt_create();
334  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
335  xslt_error($xh);
336  xslt_free($xh);
337  }
338 
339  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
340  // dirty hack: the php xslt processing seems not to recognize the following
341  // replacements, so we do it in the code as well
342  $output = str_replace("&#xA0;", "<br />", $output);
343  $output = str_replace("&#160;", "<br />", $output);
344  $form_fields = array(
345  "pageformat" => $pagesize,
346  "pagewidth" => $pagewidth,
347  "pageheight" => $pageheight,
348  "padding_top" => $paddingtop,
349  "margin_body_top" => $marginbody_top,
350  "margin_body_right" => $marginbody_right,
351  "margin_body_bottom" => $marginbody_bottom,
352  "margin_body_left" => $marginbody_left,
353  "certificate_text" => $output
354  );
355  $this->getAdapter()->addFormFieldsFromObject($form_fields);
356  return $form_fields;
357  }
xslt_create()
ILIAS Setting Class.
xslt_free(&$proc)
xslt_error(&$proc)
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
+ Here is the call graph for this function:

◆ getPageFormats()

ilCertificate::getPageFormats ( )

Retrieves predefined page formats.

Returns
array Associative array containing available page formats

Definition at line 697 of file class.ilCertificate.php.

Referenced by processXHTML2FO().

698  {
699  return array(
700  "a4" => array(
701  "name" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
702  "value" => "a4",
703  "width" => "210mm",
704  "height" => "297mm"
705  ),
706  "a4landscape" => array(
707  "name" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
708  "value" => "a4landscape",
709  "width" => "297mm",
710  "height" => "210mm"
711  ),
712  "a5" => array(
713  "name" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
714  "value" => "a5",
715  "width" => "148mm",
716  "height" => "210mm"
717  ),
718  "a5landscape" => array(
719  "name" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
720  "value" => "a5landscape",
721  "width" => "210mm",
722  "height" => "148mm"
723  ),
724  "letter" => array(
725  "name" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
726  "value" => "letter",
727  "width" => "8.5in",
728  "height" => "11in"
729  ),
730  "letterlandscape" => array(
731  "name" => $this->lng->txt("certificate_letter_landscape"), // (8.5 inch x 11 inch)
732  "value" => "letterlandscape",
733  "width" => "11in",
734  "height" => "8.5in"
735  ),
736  "custom" => array(
737  "name" => $this->lng->txt("certificate_custom"),
738  "value" => "custom",
739  "width" => "",
740  "height" => ""
741  )
742  );
743  }
+ Here is the caller graph for this function:

◆ getXSLName()

ilCertificate::getXSLName ( )

Returns the filename of the XSL-FO file.

Returns
string The filename of the XSL-FO file

Definition at line 133 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and getXSLPath().

134  {
135  return "certificate.xml";
136  }
+ Here is the caller graph for this function:

◆ getXSLPath()

ilCertificate::getXSLPath ( )

Returns the filesystem path of the XSL-FO file.

Returns
string The filesystem path of the XSL-FO file

Definition at line 123 of file class.ilCertificate.php.

References getAdapter(), and getXSLName().

Referenced by cloneCertificate(), createPreview(), deliverExportFileXML(), getFormFieldsFromFO(), isComplete(), outCertificate(), and saveCertificate().

124  {
125  return $this->getAdapter()->getCertificatePath() . $this->getXSLName();
126  }
getAdapter()
Gets the adapter.
getXSLName()
Returns the filename of the XSL-FO file.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasBackgroundImage()

ilCertificate::hasBackgroundImage ( )

Checks for the background image of the certificate.

Returns
boolean Returns TRUE if the certificate has a background image, FALSE otherwise

Definition at line 623 of file class.ilCertificate.php.

References getBackgroundImagePath().

Referenced by deliverExportFileXML(), and processXHTML2FO().

624  {
625  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
626  {
627  return TRUE;
628  }
629  else
630  {
631  return FALSE;
632  }
633  }
getBackgroundImagePath()
Returns the filesystem path of the background image.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importCertificate()

ilCertificate::importCertificate (   $zipfile,
  $filename 
)

Reads an import ZIP file and creates a certificate of it.

Returns
boolean TRUE if the import succeeds, FALSE otherwise

Definition at line 781 of file class.ilCertificate.php.

References $file, $filename, ilUtil\convertImage(), createArchiveDirectory(), ilUtil\delDir(), getAdapter(), getBackgroundImagePath(), getBackgroundImageThumbPath(), ilUtil\getDir(), ilUtil\moveUploadedFile(), saveCertificate(), and ilUtil\unzip().

782  {
783  include_once "./Services/Utilities/classes/class.ilUtil.php";
784  $importpath = $this->createArchiveDirectory();
785  if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename))
786  {
787  ilUtil::delDir($importpath);
788  return FALSE;
789  }
790  ilUtil::unzip($importpath . $filename, TRUE);
791  $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
792  $copydir = "";
793  if (is_dir($importpath . $subdir))
794  {
795  $dirinfo = ilUtil::getDir($importpath . $subdir);
796  $copydir = $importpath . $subdir;
797  }
798  else
799  {
800  $dirinfo = ilUtil::getDir($importpath);
801  $copydir = $importpath;
802  }
803  $xmlfiles = 0;
804  $otherfiles = 0;
805  foreach ($dirinfo as $file)
806  {
807  if (strcmp($file["type"], "file") == 0)
808  {
809  if (strpos($file["entry"], ".xml") !== FALSE)
810  {
811  $xmlfiles++;
812  }
813  else if (strpos($file["entry"], ".zip") !== FALSE)
814  {
815  }
816  else
817  {
818  $otherfiles++;
819  }
820  }
821  }
822  // if one XML file is in the archive, we try to import it
823  if ($xmlfiles == 1)
824  {
825  foreach ($dirinfo as $file)
826  {
827  if (strcmp($file["type"], "file") == 0)
828  {
829  if (strpos($file["entry"], ".xml") !== FALSE)
830  {
831  $xsl = file_get_contents($copydir . $file["entry"]);
832  // as long as we cannot make RPC calls in a given directory, we have
833  // to add the complete path to every url
834  $xsl = preg_replace("/url\([']{0,1}(.*?)[']{0,1}\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
835  $this->saveCertificate($xsl);
836  }
837  else if (strpos($file["entry"], ".zip") !== FALSE)
838  {
839  }
840  else
841  {
842  @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
843  if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0)
844  {
845  // upload of the background image, create a preview
847  }
848  }
849  }
850  }
851  }
852  else
853  {
854  ilUtil::delDir($importpath);
855  return FALSE;
856  }
857  ilUtil::delDir($importpath);
858  return TRUE;
859  }
print $file
getBackgroundImagePath()
Returns the filesystem path of the background image.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
saveCertificate($xslfo, $filename="")
Saves the XSL-FO code to a file.
getAdapter()
Gets the adapter.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
$filename
Definition: buildRTE.php:89
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
+ Here is the call graph for this function:

◆ isActive()

static ilCertificate::isActive ( )
static

Definition at line 931 of file class.ilCertificate.php.

Referenced by ilCourseParticipantsTableGUI\__construct(), ilObjSAHSLearningModuleAccess\_lookupUserCertificate(), ilCourseCertificateAdapter\_preloadListData(), ilObjCourseGUI\deliverCertificateObject(), ilSCORMVerificationTableGUI\getItems(), ilObjTestGUI\getStatisticsSubTabs(), ilObjExercise\hasUserCertificate(), ilObjCourseGUI\initHeaderAction(), ilObjSAHSLearningModuleGUI\setSettingsSubTabs(), ilObjExerciseGUI\setSettingsSubTabs(), and ilObjCourseGUI\setSubTabs().

932  {
933  if(self::$is_active === null)
934  {
935  // basic admin setting active?
936  $certificate_active = new ilSetting("certificate");
937  $certificate_active = (bool)$certificate_active->get("active");
938 
939  // java/rtpc-server active?
940  if($certificate_active)
941  {
942  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
943  $certificate_active = ilRPCServerSettings::getInstance()->isEnabled();
944  }
945 
946  self::$is_active = (bool)$certificate_active;
947  }
948  return self::$is_active;
949  }
ILIAS Setting Class.
static getInstance()
Get singelton instance.
+ Here is the caller graph for this function:

◆ isComplete()

ilCertificate::isComplete ( )

Checks the status of the certificate.

Returns
boolean Returns TRUE if the certificate is complete, FALSE otherwise

Definition at line 640 of file class.ilCertificate.php.

References getAdapter(), and getXSLPath().

641  {
642  if(self::isActive())
643  {
644  $obj_id = $this->getAdapter()->getCertificateID();
645  if($obj_id && !self::isObjectActive($obj_id))
646  {
647  return FALSE;
648  }
649  if (file_exists($this->getAdapter()->getCertificatePath()))
650  {
651  if (file_exists($this->getXSLPath()) && (filesize($this->getXSLPath()) > 0))
652  {
653  return TRUE;
654  }
655  }
656  }
657  return FALSE;
658  }
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
+ Here is the call graph for this function:

◆ isObjectActive()

static ilCertificate::isObjectActive (   $a_obj_id)
static

Definition at line 951 of file class.ilCertificate.php.

Referenced by ilCourseParticipantsTableGUI\__construct(), ilObjSAHSLearningModuleAccess\_lookupUserCertificate(), ilObjCourseGUI\deliverCertificateObject(), ilObjExercise\hasUserCertificate(), and ilObjCourseGUI\initHeaderAction().

952  {
953  $chk = self::areObjectsActive(array($a_obj_id));
954  return $chk[$a_obj_id];
955  }
+ Here is the caller graph for this function:

◆ outCertificate()

ilCertificate::outCertificate (   $params,
  $deliver = TRUE 
)

Creates a PDF certificate.

Parameters
array$paramsAn array of parameters which is needed to create the certificate

Definition at line 452 of file class.ilCertificate.php.

References $ilLog, ilUtil\deliverData(), exchangeCertificateVariables(), ilRpcClientFactory\factory(), getAdapter(), getXSLPath(), and ilDatePresentation\setUseRelativeDates().

453  {
454  global $ilLog;
456  $insert_tags = $this->getAdapter()->getCertificateVariablesForPresentation($params);
457 
458  include_once("./Services/User/classes/class.ilUserDefinedData.php");
459  $cust_data = new ilUserDefinedData($this->getAdapter()->getUserIdForParams($params));
460  $cust_data = $cust_data->getAll();
461  foreach (self::getCustomCertificateFields() as $k => $f)
462  {
463  $insert_tags[$f["ph"]] = $cust_data["f_".$k];
464  }
465 
466  $xslfo = file_get_contents($this->getXSLPath());
467 
468  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
469  try
470  {
471  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
472  $this->exchangeCertificateVariables($xslfo, $insert_tags));
473  if ($deliver)
474  {
475  include_once "./Services/Utilities/classes/class.ilUtil.php";
476  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
477  }
478  else
479  {
480  return $pdf_base64->scalar;
481  }
482  }
483  catch(XML_RPC2_FaultException $e)
484  {
485  $ilLog->write(__METHOD__.': '.$e->getMessage());
486  return false;
487  }
488  catch(Exception $e)
489  {
490  $ilLog->write(__METHOD__.': '.$e->getMessage());
491  return false;
492  }
493 
495 
496  /*
497  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
498  $fo2pdf = new ilFO2PDF();
499  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo, $insert_tags));
500  $result = $fo2pdf->send();
501  if ($deliver)
502  {
503  include_once "./Services/Utilities/classes/class.ilUtil.php";
504  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
505  }
506  else
507  {
508  return $result;
509  }
510  */
511  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
Class ilUserDefinedData.
static setUseRelativeDates($a_status)
set use relative dates
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
static factory($a_package)
Create an XML_RPC2 client instance.
exchangeCertificateVariables($certificate_text, $insert_tags=array())
Exchanges the variables in the certificate text with given values.
+ Here is the call graph for this function:

◆ outCertificateWithGivenContentAndVariables()

ilCertificate::outCertificateWithGivenContentAndVariables (   $content,
  $insert_tags 
)

Definition at line 1081 of file class.ilCertificate.php.

1082  {
1083  global $ilLog;
1084 
1086 
1087  $form_fields = $this->getFormFieldsFromFO();
1088  $form_fields['certificate_text'] = $content;
1089  $xslfo = $this->processXHTML2FO($form_fields);
1090 
1091  $content = $this->exchangeCertificateVariables($xslfo, $insert_tags);
1092  $content = str_replace('[BR]', "<fo:block/>", $content);
1093 
1094  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
1095  try
1096  {
1097  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($content);
1098  include_once "./Services/Utilities/classes/class.ilUtil.php";
1099  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(array()), "application/pdf");
1100  }
1101  catch(XML_RPC2_FaultException $e)
1102  {
1103  $ilLog->write(__METHOD__.': '.$e->getMessage());
1104  return false;
1105  }
1106  catch(Exception $e)
1107  {
1108  $ilLog->write(__METHOD__.': '.$e->getMessage());
1109  return false;
1110  }
1111 
1113  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
processXHTML2FO($form_data, $for_export=FALSE)
Convert the certificate text to XSL-FO using XSL transformation.
getFormFieldsFromFO()
Convert the XSL-FO to the certificate text and the form settings using XSL transformation.
static setUseRelativeDates($a_status)
set use relative dates
static factory($a_package)
Create an XML_RPC2 client instance.
exchangeCertificateVariables($certificate_text, $insert_tags=array())
Exchanges the variables in the certificate text with given values.

◆ processXHTML2FO()

ilCertificate::processXHTML2FO (   $form_data,
  $for_export = FALSE 
)

Convert the certificate text to XSL-FO using XSL transformation.

Parameters
array$form_dataThe form data
Returns
string XSL-FO code

Definition at line 365 of file class.ilCertificate.php.

References $GLOBALS, ilObjCertificateSettingsAccess\getBackgroundImagePath(), getBackgroundImagePath(), getPageFormats(), ilObjCertificateSettingsAccess\hasBackgroundImage(), hasBackgroundImage(), xslt_create(), xslt_error(), and xslt_free().

366  {
367  $content = "<html><body>".$form_data["certificate_text"]."</body></html>";
368  $content = preg_replace("/<p>(&nbsp;){1,}<\\/p>/", "<p></p>", $content);
369  $content = preg_replace("/<p>(\\s)*?<\\/p>/", "<p></p>", $content);
370 // $content = str_replace("<p>&nbsp;</p>", "<p><br /></p>", $content);
371 // $content = str_replace("<p> </p>", "<p><br /></p>", $content);
372  $content = str_replace("<p></p>", "<p class=\"emptyrow\"></p>", $content);
373  $content = str_replace("&nbsp;", "&#160;", $content);
374  $content = preg_replace("//", "", $content);
375 
376  include_once "./Services/Certificate/classes/class.ilXmlChecker.php";
377  $check = new ilXMLChecker();
378  $check->setXMLContent($content);
379  $check->startParsing();
380  if ($check->hasError())
381  {
382  throw new Exception($this->lng->txt("certificate_not_well_formed"));
383  }
384 
385  $xsl = file_get_contents("./Services/Certificate/xml/xhtml2fo.xsl");
386 
387  // additional font support
388  $xsl = str_replace(
389  'font-family="Helvetica, unifont"',
390  'font-family="'.$GLOBALS['ilSetting']->get('rpc_pdf_font','Helvetica, unifont').'"',
391  $xsl
392  );
393 
394  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
395  $xh = xslt_create();
396  if (strcmp($form_data["pageformat"], "custom") == 0)
397  {
398  $pageheight = $form_data["pageheight"];
399  $pagewidth = $form_data["pagewidth"];
400  }
401  else
402  {
403  $pageformats = $this->getPageFormats();
404  $pageheight = $pageformats[$form_data["pageformat"]]["height"];
405  $pagewidth = $pageformats[$form_data["pageformat"]]["width"];
406  }
407  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
409  $params = array(
410  "pageheight" => $pageheight,
411  "pagewidth" => $pagewidth,
412  "backgroundimage" => $backgroundimage,
413  "marginbody" => $form_data["margin_body_top"] . " " . $form_data["margin_body_right"] . " " . $form_data["margin_body_bottom"] . " " . $form_data["margin_body_left"],
414  "paddingtop" => $form_data["padding_top"]
415  );
416  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
417  xslt_error($xh);
418  xslt_free($xh);
419  return $output;
420  }
xslt_create()
xslt_free(&$proc)
getBackgroundImagePath()
Returns the filesystem path of the background image.
hasBackgroundImage()
Checks for the background image of the certificate.
xslt_error(&$proc)
getPageFormats()
Retrieves predefined page formats.
$GLOBALS['ct_recipient']
XML checker.
Class ilObjCertificateSettingsAccess.
+ Here is the call graph for this function:

◆ readActive()

ilCertificate::readActive ( )

Definition at line 975 of file class.ilCertificate.php.

Referenced by cloneCertificate().

976  {
977  global $ilDB;
978 
979  $obj_id = $this->adapter->getCertificateID();
980  $set = $ilDB->query("SELECT obj_id FROM il_certificate".
981  " WHERE obj_id = ".$ilDB->quote($obj_id, "integer"));
982  return $ilDB->numRows($set);
983  }
global $ilDB
+ Here is the caller graph for this function:

◆ saveCertificate()

ilCertificate::saveCertificate (   $xslfo,
  $filename = "" 
)

Saves the XSL-FO code to a file.

Parameters
string$xslfoXSL-FO code

Definition at line 560 of file class.ilCertificate.php.

References $filename, getAdapter(), getXSLPath(), and ilUtil\makeDirParents().

Referenced by deliverExportFileXML(), and importCertificate().

561  {
562  if (!file_exists($this->getAdapter()->getCertificatePath()))
563  {
564  ilUtil::makeDirParents($this->getAdapter()->getCertificatePath());
565  }
566  if (strlen($filename) == 0)
567  {
568  $filename = $this->getXSLPath();
569  }
570  $fh = fopen($filename, "w");
571  fwrite($fh, $xslfo);
572  fclose($fh);
573  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
$filename
Definition: buildRTE.php:89
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAdapter()

ilCertificate::setAdapter (   $adapter)

Sets the adapter.

Parameters
object$adapterAdapter

Definition at line 876 of file class.ilCertificate.php.

References $adapter.

877  {
878  $this->adapter =& $adapter;
879  }

◆ uploadBackgroundImage()

ilCertificate::uploadBackgroundImage (   $image_tempfilename)

Uploads a background image for the certificate.

Creates a new directory for the certificate if needed. Removes an existing certificate image if necessary

Parameters
string$image_tempfilenameName of the temporary uploaded image file
Returns
integer An errorcode if the image upload fails, 0 otherwise

Definition at line 582 of file class.ilCertificate.php.

References ilUtil\convertImage(), getAdapter(), getBackgroundImageName(), getBackgroundImagePath(), getBackgroundImageTempfilePath(), getBackgroundImageThumbPath(), ilUtil\makeDirParents(), and ilUtil\moveUploadedFile().

583  {
584  if (!empty($image_tempfilename))
585  {
586  $image_filename = "background_upload";
587  $convert_filename = $this->getBackgroundImageName();
588  $imagepath = $this->getAdapter()->getCertificatePath();
589  if (!file_exists($imagepath))
590  {
591  ilUtil::makeDirParents($imagepath);
592  }
593  // upload the file
594  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $this->getBackgroundImageTempfilePath()))
595  {
596  return FALSE;
597  }
598  // convert the uploaded file to JPEG
601  if (!file_exists($this->getBackgroundImagePath()))
602  {
603  // something went wrong converting the file. use the original file and hope, that PDF can work with it
604  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
605  {
606  return FALSE;
607  }
608  }
609  unlink($this->getBackgroundImageTempfilePath());
610  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
611  {
612  return TRUE;
613  }
614  }
615  return FALSE;
616  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
getAdapter()
Gets the adapter.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
getBackgroundImageName()
Returns the filename of the background image.
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
+ Here is the call graph for this function:

◆ writeActive()

ilCertificate::writeActive (   $a_value)

Definition at line 985 of file class.ilCertificate.php.

Referenced by cloneCertificate(), and deleteCertificate().

986  {
987  global $ilDB;
988 
989  $obj_id = $this->adapter->getCertificateID();
990 
991  if((bool)$a_value)
992  {
993  $ilDB->replace("il_certificate",
994  array("obj_id"=>array("integer", $obj_id)),
995  array());
996  }
997  else
998  {
999  $ilDB->manipulate("DELETE FROM il_certificate".
1000  " WHERE obj_id = ".$ilDB->quote($obj_id, "integer"));
1001  }
1002  }
global $ilDB
+ Here is the caller graph for this function:

◆ zipCertificatesInArchiveDirectory()

ilCertificate::zipCertificatesInArchiveDirectory (   $dir,
  $deliver = TRUE 
)

Create a ZIP file from a directory with certificates.

Parameters
string$dirDirectory containing the certificates
boolean$deliverTRUE to deliver the ZIP file, FALSE to return the filename only
Returns
string The created ZIP archive path

Definition at line 919 of file class.ilCertificate.php.

920  {
921  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip";
922  ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile);
923  ilUtil::delDir($dir);
924  if ($deliver)
925  {
926  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
927  }
928  return $this->getAdapter()->getCertificatePath() . $zipfile;
929  }
getAdapter()
Gets the adapter.
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

Field Documentation

◆ $adapter

ilCertificate::$adapter
protected

Definition at line 57 of file class.ilCertificate.php.

Referenced by __construct(), _isComplete(), getAdapter(), and setAdapter().

◆ $ctrl

ilCertificate::$ctrl
protected

Definition at line 22 of file class.ilCertificate.php.

◆ $ilias

ilCertificate::$ilias
protected

Definition at line 36 of file class.ilCertificate.php.

Referenced by __construct().

◆ $is_active

ilCertificate::$is_active
staticprotected

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

◆ $lng

ilCertificate::$lng
protected

Definition at line 50 of file class.ilCertificate.php.

Referenced by __construct().

◆ $tpl

ilCertificate::$tpl
protected

Definition at line 43 of file class.ilCertificate.php.

Referenced by __construct().

◆ $tree

ilCertificate::$tree
protected

Definition at line 29 of file class.ilCertificate.php.

Referenced by __construct().


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