ILIAS  release_4-4 Revision
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 ($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 1003 of file class.ilCertificate.php.

1004  {
1005  global $ilCtrl;
1006  include_once "./Services/Object/classes/class.ilObject.php";
1007  $type = ilObject::_lookupType($ref_id, true);
1008  switch ($type)
1009  {
1010  case 'sahs':
1011  $cmd_link = "ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=".$ref_id.
1012  "&cmd=downloadCertificate";
1013  ilUtil::redirect($cmd_link);
1014  break;
1015  case 'tst':
1016  default:
1017  $ilCtrl->redirectByClass("ilrepositorygui", "frameset");
1018  break;
1019  }
1020  }
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 660 of file class.ilCertificate.php.

References $adapter, and _getXSLName().

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

661  {
662  if (is_object($adapter) && method_exists($adapter, "getCertificatePath"))
663  {
664  if(self::isActive())
665  {
666  $obj_id = $adapter->getCertificateID();
667  if($obj_id && !self::isObjectActive($obj_id))
668  {
669  return FALSE;
670  }
671 
672  $certificatepath = $adapter->getCertificatePath();
673  if (file_exists($certificatepath))
674  {
675  $xslpath = $adapter->getCertificatePath() . ilCertificate::_getXSLName();
676  if (file_exists($xslpath) && (filesize($xslpath) > 0))
677  {
678  return TRUE;
679  }
680  }
681  }
682  }
683  return FALSE;
684  }
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 899 of file class.ilCertificate.php.

900  {
901  $fh = fopen($dir . $filename, "wb");
902  fwrite($fh, $pdfdata);
903  fclose($fh);
904  }
$filename
Definition: buildRTE.php:89

◆ areObjectsActive()

static ilCertificate::areObjectsActive ( array  $a_obj_ids)
static

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

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

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

◆ cloneCertificate()

ilCertificate::cloneCertificate (   $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(), and ilUtil\makeDirParents().

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

Referenced by deliverExportFileXML(), and importCertificate().

885  {
886  $dir = $this->getAdapter()->getCertificatePath() . time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate/";
887  include_once "./Services/Utilities/classes/class.ilUtil.php";
889  return $dir;
890  }
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 510 of file class.ilCertificate.php.

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

511  {
512  global $ilLog;
513 
515 
516  $xslfo = file_get_contents($this->getXSLPath());
517 
518  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
519  try
520  {
521  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
522  $this->exchangeCertificateVariables($xslfo));
523  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
524 
525  }
526  catch(XML_RPC2_FaultException $e)
527  {
528  $ilLog->write(__METHOD__.': '.$e->getMessage());
529  return false;
530  }
531  catch(Exception $e)
532  {
533  $ilLog->write(__METHOD__.': '.$e->getMessage());
534  return false;
535  }
536 
538 
539  /*
540  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
541  $fo2pdf = new ilFO2PDF();
542  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo));
543  $result = $fo2pdf->send();
544  include_once "./Services/Utilities/classes/class.ilUtil.php";
545  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename(), "application/pdf");
546  */
547  }
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 227 of file class.ilCertificate.php.

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

228  {
229  if (@file_exists($this->getAdapter()->getCertificatePath()))
230  {
231  include_once "./Services/Utilities/classes/class.ilUtil.php";
232  ilUtil::delDir($this->getAdapter()->getCertificatePath());
233  $this->getAdapter()->deleteCertificate();
234  }
235  $this->writeActive(false);
236  }
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 742 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().

743  {
744  include_once "./Services/Utilities/classes/class.ilUtil.php";
745  $exportpath = $this->createArchiveDirectory();
746  ilUtil::makeDir($exportpath);
747  $xsl = file_get_contents($this->getXSLPath());
748  $xslexport = str_replace($this->getAdapter()->getCertificatePath(), "", $xsl);
749  // save export xsl file
750  $this->saveCertificate($xslexport, $exportpath . $this->getXSLName());
751  // save background image
752  if ($this->hasBackgroundImage())
753  {
754  copy($this->getBackgroundImagePath(), $exportpath . $this->getBackgroundImageName());
755  }
756  else
757  {
758  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
760  {
762  }
763  }
764  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate.zip";
765  ilUtil::zip($exportpath, $this->getAdapter()->getCertificatePath() . $zipfile);
766  ilUtil::delDir($exportpath);
767  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
768  }
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 423 of file class.ilCertificate.php.

References getAdapter().

Referenced by createPreview(), and outCertificate().

424  {
425  if (count($insert_tags) == 0)
426  {
427  $insert_tags = $this->getAdapter()->getCertificateVariablesForPreview();
428 
429  foreach (self::getCustomCertificateFields() as $k => $f)
430  {
431  $insert_tags[$f["ph"]] = $f["name"];
432  }
433  }
434  foreach ($insert_tags as $var => $value)
435  {
436  $certificate_text = str_replace($var, $value, $certificate_text);
437  }
438  return $certificate_text;
439  }
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 1025 of file class.ilCertificate.php.

Referenced by ilCertificateGUI\certificateEditor().

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

◆ getExchangeContent()

ilCertificate::getExchangeContent ( )
Returns
string

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

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

◆ getFormFieldsFromFO()

ilCertificate::getFormFieldsFromFO ( )

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

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

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

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

Referenced by processXHTML2FO().

692  {
693  return array(
694  "a4" => array(
695  "name" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
696  "value" => "a4",
697  "width" => "210mm",
698  "height" => "297mm"
699  ),
700  "a4landscape" => array(
701  "name" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
702  "value" => "a4landscape",
703  "width" => "297mm",
704  "height" => "210mm"
705  ),
706  "a5" => array(
707  "name" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
708  "value" => "a5",
709  "width" => "148mm",
710  "height" => "210mm"
711  ),
712  "a5landscape" => array(
713  "name" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
714  "value" => "a5landscape",
715  "width" => "210mm",
716  "height" => "148mm"
717  ),
718  "letter" => array(
719  "name" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
720  "value" => "letter",
721  "width" => "8.5in",
722  "height" => "11in"
723  ),
724  "letterlandscape" => array(
725  "name" => $this->lng->txt("certificate_letter_landscape"), // (8.5 inch x 11 inch)
726  "value" => "letterlandscape",
727  "width" => "11in",
728  "height" => "8.5in"
729  ),
730  "custom" => array(
731  "name" => $this->lng->txt("certificate_custom"),
732  "value" => "custom",
733  "width" => "",
734  "height" => ""
735  )
736  );
737  }
+ 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 617 of file class.ilCertificate.php.

References getBackgroundImagePath().

Referenced by deliverExportFileXML(), and processXHTML2FO().

618  {
619  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
620  {
621  return TRUE;
622  }
623  else
624  {
625  return FALSE;
626  }
627  }
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 775 of file class.ilCertificate.php.

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

776  {
777  include_once "./Services/Utilities/classes/class.ilUtil.php";
778  $importpath = $this->createArchiveDirectory();
779  if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename))
780  {
781  ilUtil::delDir($importpath);
782  return FALSE;
783  }
784  ilUtil::unzip($importpath . $filename, TRUE);
785  $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
786  $copydir = "";
787  if (is_dir($importpath . $subdir))
788  {
789  $dirinfo = ilUtil::getDir($importpath . $subdir);
790  $copydir = $importpath . $subdir;
791  }
792  else
793  {
794  $dirinfo = ilUtil::getDir($importpath);
795  $copydir = $importpath;
796  }
797  $xmlfiles = 0;
798  $otherfiles = 0;
799  foreach ($dirinfo as $file)
800  {
801  if (strcmp($file["type"], "file") == 0)
802  {
803  if (strpos($file["entry"], ".xml") !== FALSE)
804  {
805  $xmlfiles++;
806  }
807  else if (strpos($file["entry"], ".zip") !== FALSE)
808  {
809  }
810  else
811  {
812  $otherfiles++;
813  }
814  }
815  }
816  // if one XML file is in the archive, we try to import it
817  if ($xmlfiles == 1)
818  {
819  foreach ($dirinfo as $file)
820  {
821  if (strcmp($file["type"], "file") == 0)
822  {
823  if (strpos($file["entry"], ".xml") !== FALSE)
824  {
825  $xsl = file_get_contents($copydir . $file["entry"]);
826  // as long as we cannot make RPC calls in a given directory, we have
827  // to add the complete path to every url
828  $xsl = preg_replace("/url\([']{0,1}(.*?)[']{0,1}\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
829  $this->saveCertificate($xsl);
830  }
831  else if (strpos($file["entry"], ".zip") !== FALSE)
832  {
833  }
834  else
835  {
836  @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
837  if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0)
838  {
839  // upload of the background image, create a preview
841  }
842  }
843  }
844  }
845  }
846  else
847  {
848  ilUtil::delDir($importpath);
849  return FALSE;
850  }
851  ilUtil::delDir($importpath);
852  return TRUE;
853  }
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 925 of file class.ilCertificate.php.

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

926  {
927  if(self::$is_active === null)
928  {
929  // basic admin setting active?
930  $certificate_active = new ilSetting("certificate");
931  $certificate_active = (bool)$certificate_active->get("active");
932 
933  // java/rtpc-server active?
934  if($certificate_active)
935  {
936  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
937  $certificate_active = ilRPCServerSettings::getInstance()->isEnabled();
938  }
939 
940  self::$is_active = (bool)$certificate_active;
941  }
942  return self::$is_active;
943  }
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 634 of file class.ilCertificate.php.

References getAdapter(), and getXSLPath().

635  {
636  if(self::isActive())
637  {
638  $obj_id = $this->getAdapter()->getCertificateID();
639  if($obj_id && !self::isObjectActive($obj_id))
640  {
641  return FALSE;
642  }
643  if (file_exists($this->getAdapter()->getCertificatePath()))
644  {
645  if (file_exists($this->getXSLPath()) && (filesize($this->getXSLPath()) > 0))
646  {
647  return TRUE;
648  }
649  }
650  }
651  return FALSE;
652  }
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 945 of file class.ilCertificate.php.

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

946  {
947  $chk = self::areObjectsActive(array($a_obj_id));
948  return $chk[$a_obj_id];
949  }
+ 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 446 of file class.ilCertificate.php.

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

447  {
448  global $ilLog;
450  $insert_tags = $this->getAdapter()->getCertificateVariablesForPresentation($params);
451 
452  include_once("./Services/User/classes/class.ilUserDefinedData.php");
453  $cust_data = new ilUserDefinedData($this->getAdapter()->getUserIdForParams($params));
454  $cust_data = $cust_data->getAll();
455  foreach (self::getCustomCertificateFields() as $k => $f)
456  {
457  $insert_tags[$f["ph"]] = $cust_data["f_".$k];
458  }
459 
460  $xslfo = file_get_contents($this->getXSLPath());
461 
462  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
463  try
464  {
465  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
466  $this->exchangeCertificateVariables($xslfo, $insert_tags));
467  if ($deliver)
468  {
469  include_once "./Services/Utilities/classes/class.ilUtil.php";
470  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
471  }
472  else
473  {
474  return $pdf_base64->scalar;
475  }
476  }
477  catch(XML_RPC2_FaultException $e)
478  {
479  $ilLog->write(__METHOD__.': '.$e->getMessage());
480  return false;
481  }
482  catch(Exception $e)
483  {
484  $ilLog->write(__METHOD__.': '.$e->getMessage());
485  return false;
486  }
487 
489 
490  /*
491  include_once "./Services/Transformation/classes/class.ilFO2PDF.php";
492  $fo2pdf = new ilFO2PDF();
493  $fo2pdf->setFOString($this->exchangeCertificateVariables($xslfo, $insert_tags));
494  $result = $fo2pdf->send();
495  if ($deliver)
496  {
497  include_once "./Services/Utilities/classes/class.ilUtil.php";
498  ilUtil::deliverData($result, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
499  }
500  else
501  {
502  return $result;
503  }
504  */
505  }
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 1075 of file class.ilCertificate.php.

1076  {
1077  global $ilLog;
1078 
1080 
1081  $form_fields = $this->getFormFieldsFromFO();
1082  $form_fields['certificate_text'] = $content;
1083  $xslfo = $this->processXHTML2FO($form_fields);
1084 
1085  $content = $this->exchangeCertificateVariables($xslfo, $insert_tags);
1086  $content = str_replace('[BR]', "<fo:block/>", $content);
1087 
1088  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
1089  try
1090  {
1091  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($content);
1092  include_once "./Services/Utilities/classes/class.ilUtil.php";
1093  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(array()), "application/pdf");
1094  }
1095  catch(XML_RPC2_FaultException $e)
1096  {
1097  $ilLog->write(__METHOD__.': '.$e->getMessage());
1098  return false;
1099  }
1100  catch(Exception $e)
1101  {
1102  $ilLog->write(__METHOD__.': '.$e->getMessage());
1103  return false;
1104  }
1105 
1107  }
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 359 of file class.ilCertificate.php.

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

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

◆ readActive()

ilCertificate::readActive ( )

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

970  {
971  global $ilDB;
972 
973  $obj_id = $this->adapter->getCertificateID();
974  $set = $ilDB->query("SELECT obj_id FROM il_certificate".
975  " WHERE obj_id = ".$ilDB->quote($obj_id, "integer"));
976  return $ilDB->numRows($set);
977  }

◆ saveCertificate()

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

Saves the XSL-FO code to a file.

Parameters
string$xslfoXSL-FO code

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

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

Referenced by deliverExportFileXML(), and importCertificate().

555  {
556  if (!file_exists($this->getAdapter()->getCertificatePath()))
557  {
558  ilUtil::makeDirParents($this->getAdapter()->getCertificatePath());
559  }
560  if (strlen($filename) == 0)
561  {
562  $filename = $this->getXSLPath();
563  }
564  $fh = fopen($filename, "w");
565  fwrite($fh, $xslfo);
566  fclose($fh);
567  }
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 870 of file class.ilCertificate.php.

References $adapter.

871  {
872  $this->adapter =& $adapter;
873  }

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

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

577  {
578  if (!empty($image_tempfilename))
579  {
580  $image_filename = "background_upload";
581  $convert_filename = $this->getBackgroundImageName();
582  $imagepath = $this->getAdapter()->getCertificatePath();
583  if (!file_exists($imagepath))
584  {
585  ilUtil::makeDirParents($imagepath);
586  }
587  // upload the file
588  if (!ilUtil::moveUploadedFile($image_tempfilename, $image_filename, $this->getBackgroundImageTempfilePath()))
589  {
590  return FALSE;
591  }
592  // convert the uploaded file to JPEG
595  if (!file_exists($this->getBackgroundImagePath()))
596  {
597  // something went wrong converting the file. use the original file and hope, that PDF can work with it
598  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
599  {
600  return FALSE;
601  }
602  }
603  unlink($this->getBackgroundImageTempfilePath());
604  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
605  {
606  return TRUE;
607  }
608  }
609  return FALSE;
610  }
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 979 of file class.ilCertificate.php.

Referenced by deleteCertificate().

980  {
981  global $ilDB;
982 
983  $obj_id = $this->adapter->getCertificateID();
984 
985  if((bool)$a_value)
986  {
987  $ilDB->replace("il_certificate",
988  array("obj_id"=>array("integer", $obj_id)),
989  array());
990  }
991  else
992  {
993  $ilDB->manipulate("DELETE FROM il_certificate".
994  " WHERE obj_id = ".$ilDB->quote($obj_id, "integer"));
995  }
996  }
+ 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 913 of file class.ilCertificate.php.

914  {
915  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip";
916  ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile);
917  ilUtil::delDir($dir);
918  if ($deliver)
919  {
920  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
921  }
922  return $this->getAdapter()->getCertificatePath() . $zipfile;
923  }
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: