ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 1004 of file class.ilCertificate.php.

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

References $adapter, and _getXSLName().

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

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

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

◆ areObjectsActive()

static ilCertificate::areObjectsActive ( array  $a_obj_ids)
static

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

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

952  {
953  global $ilDB;
954 
955  $all = array();
956  foreach($a_obj_ids as $id)
957  {
958  $all[$id] = false;
959  }
960 
961  $set = $ilDB->query("SELECT obj_id FROM il_certificate".
962  " WHERE ".$ilDB->in("obj_id", $a_obj_ids, "", "integer"));
963  while($row = $ilDB->fetchAssoc($set))
964  {
965  $all[$row["obj_id"]] = true;
966  }
967  return $all;
968  }
global $ilDB
+ 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(), ilUtil\makeDirParents(), and readActive().

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

Referenced by deliverExportFileXML(), and importCertificate().

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

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

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

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

References getAdapter().

Referenced by createPreview(), and outCertificate().

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

Referenced by ilCertificateGUI\getFormFieldsFromFO().

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

◆ getExchangeContent()

ilCertificate::getExchangeContent ( )
Returns
string

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

1048  {
1049  if(!file_exists($this->getXSLPath()))
1050  {
1051  return '';
1052  }
1053 
1054  $output = '';
1055  $xsl_file_content = file_get_contents($this->getXSLPath());
1056  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
1057 
1058  if((strlen($xsl_file_content)) && (strlen($xsl)))
1059  {
1060  $args = array('/_xml' => $xsl_file_content, '/_xsl' => $xsl);
1061  $xh = xslt_create();
1062  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
1063  xslt_error($xh);
1064  xslt_free($xh);
1065  }
1066 
1067  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
1068  // dirty hack: the php xslt processing seems not to recognize the following
1069  // replacements, so we do it in the code as well
1070  $output = str_replace("&#xA0;", "<br />", $output);
1071  $output = str_replace("&#160;", "<br />", $output);
1072 
1073  return $output;
1074  }
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  $marginbody_top = "0cm";
297  $marginbody_right = "2cm";
298  $marginbody_bottom = "0cm";
299  $marginbody_left = "2cm";
300  if(preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
301  {
302  // Backwards compatibility
303  $marginbody = $matches[1];
304  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
305  {
306  $marginbody_top = $matches[1][0];
307  $marginbody_right = $matches[1][1];
308  $marginbody_bottom = $matches[1][2];
309  $marginbody_left = $matches[1][3];
310  }
311  }
312  else if(preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
313  {
314  $marginbody = $matches[1];
315  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
316  {
317  $marginbody_top = $matches[1][0];
318  $marginbody_right = $matches[1][1];
319  $marginbody_bottom = $matches[1][2];
320  $marginbody_left = $matches[1][3];
321  }
322  }
323 
324  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
325  if ((strlen($xslfo)) && (strlen($xsl)))
326  {
327  $args = array( '/_xml' => $xslfo, '/_xsl' => $xsl );
328  $xh = xslt_create();
329  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
330  xslt_error($xh);
331  xslt_free($xh);
332  }
333 
334  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
335  // dirty hack: the php xslt processing seems not to recognize the following
336  // replacements, so we do it in the code as well
337  $output = str_replace("&#xA0;", "<br />", $output);
338  $output = str_replace("&#160;", "<br />", $output);
339  $form_fields = array(
340  "pageformat" => $pagesize,
341  "pagewidth" => $pagewidth,
342  "pageheight" => $pageheight,
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.
+ 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 692 of file class.ilCertificate.php.

Referenced by processXHTML2FO().

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

References getBackgroundImagePath().

Referenced by deliverExportFileXML(), and processXHTML2FO().

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

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

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

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

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

References getAdapter(), and getXSLPath().

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

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

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

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

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

◆ outCertificateWithGivenContentAndVariables()

ilCertificate::outCertificateWithGivenContentAndVariables (   $content,
  $insert_tags 
)

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

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

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  );
409  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
410  xslt_error($xh);
411  xslt_free($xh);
412  return $output;
413  }
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.
XML checker.
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
Definition: CAS.php:276
$params
Definition: example_049.php:96
Class ilObjCertificateSettingsAccess.
+ Here is the call graph for this function:

◆ readActive()

ilCertificate::readActive ( )

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

Referenced by cloneCertificate().

971  {
972  global $ilDB;
973 
974  $obj_id = $this->adapter->getCertificateID();
975  $set = $ilDB->query("SELECT obj_id FROM il_certificate".
976  " WHERE obj_id = ".$ilDB->quote($obj_id, "integer"));
977  return $ilDB->numRows($set);
978  }
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 553 of file class.ilCertificate.php.

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

Referenced by deliverExportFileXML(), and importCertificate().

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

References $adapter.

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

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

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

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

Referenced by deleteCertificate().

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

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