ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilCertificate Class Reference

Create PDF certificates. More...

+ Collaboration diagram for ilCertificate:

Public Member Functions

 __construct (ilCertificateAdapter $adapter)
 ilCertificate constructor More...
 
 formatNumberString ($a_number)
 
 getBackgroundImagePath ($asRelative=false)
 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...
 
 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, array $insert_tags)
 

Static Public Member Functions

static _getXSLName ()
 Returns the filename of the XSL-FO file. More...
 
static _isComplete ($adapter)
 Checks the status of the certificate. More...
 
static isActive ()
 
static isObjectActive ($a_obj_id)
 
static getCustomCertificateFields ()
 Get custom certificate fields. More...
 

Protected Attributes

 $ctrl
 
 $tree
 
 $ilias
 
 $lng
 
 $adapter
 
 $settings
 
 $log
 
 $db
 

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 ( ilCertificateAdapter  $adapter)

ilCertificate constructor

Parameters
ilCertificateAdapter$adapterThe certificate adapter needed to construct the certificate

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

References $adapter, $DIC, and settings().

77  {
78  global $DIC;
79 
80  $this->lng = $DIC['lng'];
81  $this->ctrl = $DIC['ilCtrl'];
82  $this->ilias = $DIC['ilias'];
83  $this->tree = $DIC['tree'];
84  $this->settings = $DIC['ilSetting'];
85  $this->log = $DIC['ilLog'];
86  $this->db = $DIC['ilDB'];
87 
88  $this->adapter = $adapter;
89  }
redirection script todo: (a better solution should control the processing via a xml file) ...
settings()
Definition: settings.php:2
global $DIC
+ Here is the call graph for this function:

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

Referenced by _isComplete().

175  {
176  return "certificate.xml";
177  }
+ Here is the caller graph for this function:

◆ _isComplete()

static ilCertificate::_isComplete (   $adapter)
static

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

References $adapter, and _getXSLName().

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

679  {
680  if (is_object($adapter) && method_exists($adapter, "getCertificatePath"))
681  {
682  if(self::isActive())
683  {
684  $obj_id = $adapter->getCertificateID();
685  if($obj_id && !self::isObjectActive($obj_id))
686  {
687  return FALSE;
688  }
689 
690  $certificatepath = $adapter->getCertificatePath();
691  if (file_exists($certificatepath))
692  {
693  $xslpath = $adapter->getCertificatePath() . ilCertificate::_getXSLName();
694  if (file_exists($xslpath) && (filesize($xslpath) > 0))
695  {
696  return TRUE;
697  }
698  }
699  }
700  }
701  return FALSE;
702  }
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 917 of file class.ilCertificate.php.

918  {
919  $fh = fopen($dir . $filename, "wb");
920  fwrite($fh, $pdfdata);
921  fclose($fh);
922  }

◆ cloneCertificate()

ilCertificate::cloneCertificate (   $newObject)

Clone the certificate for another test object.

Parameters
$newObjectThe new certificate object

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

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

233  {
234  $xsl = $this->getXSLPath();
235  $bgimage = $this->getBackgroundImagePath();
236  $bgimagethumb = $this->getBackgroundImageThumbPath();
237  $certificatepath = $this->getAdapter()->getCertificatePath();
238 
239  $new_xsl = $newObject->getXSLPath();
240  $new_bgimage = $newObject->getBackgroundImagePath();
241  $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
242  $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
243 
244  if (@file_exists($xsl))
245  {
246  ilUtil::makeDirParents($new_certificatepath);
247  @copy($xsl, $new_xsl);
248  if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
249  if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
250  }
251 
252  // #10271
253  if($this->readActive())
254  {
255  $newObject->writeActive(true);
256  }
257  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getBackgroundImagePath($asRelative=false)
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 902 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and importCertificate().

903  {
904  $dir = $this->getAdapter()->getCertificatePath() . time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate/";
905  include_once "./Services/Utilities/classes/class.ilUtil.php";
907  return $dir;
908  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getAdapter()
Gets the adapter.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the caller graph for this function:

◆ createPreview()

ilCertificate::createPreview ( )

Creates a PDF preview of the XSL-FO certificate.

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

References ilUtil\deliverData(), exchangeCertificateVariables(), ilRpcClientFactory\factory(), ilMathJax\getInstance(), getXSLPath(), ilMathJax\PURPOSE_PDF, ilMathJax\RENDER_PNG_AS_FO_FILE, and ilDatePresentation\setUseRelativeDates().

535  {
537 
538  $xslfo = file_get_contents($this->getXSLPath());
539 
540  // render tex as fo graphics
541  require_once('Services/MathJax/classes/class.ilMathJax.php');
542  $xslfo = ilMathJax::getInstance()
543  ->init(ilMathJax::PURPOSE_PDF)
544  ->setRendering(ilMathJax::RENDER_PNG_AS_FO_FILE)
545  ->insertLatexImages($xslfo);
546 
547  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
548  try
549  {
550  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
551  $this->exchangeCertificateVariables($xslfo));
552  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
553 
554  }
555  catch(Exception $e)
556  {
557  $this->log->write(__METHOD__.': '.$e->getMessage());
558  return false;
559  }
560 
562 
563  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
const PURPOSE_PDF
static setUseRelativeDates($a_status)
set use relative dates
getXSLPath()
Returns the filesystem path of the XSL-FO file.
const RENDER_PNG_AS_FO_FILE
static getInstance()
Singleton: get 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 209 of file class.ilCertificate.php.

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

210  {
211  $result = TRUE;
212  if (file_exists($this->getBackgroundImageThumbPath()))
213  {
214  $result = $result & unlink($this->getBackgroundImageThumbPath());
215  }
216  if (file_exists($this->getBackgroundImagePath()))
217  {
218  $result = $result & unlink($this->getBackgroundImagePath());
219  }
220  if (file_exists($this->getBackgroundImageTempfilePath()))
221  {
222  $result = $result & unlink($this->getBackgroundImageTempfilePath());
223  }
224  return $result;
225  }
$result
getBackgroundImagePath($asRelative=false)
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 264 of file class.ilCertificate.php.

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

265  {
266  if (@file_exists($this->getAdapter()->getCertificatePath()))
267  {
268  include_once "./Services/Utilities/classes/class.ilUtil.php";
269  ilUtil::delDir($this->getAdapter()->getCertificatePath());
270  $this->getAdapter()->deleteCertificate();
271  }
272  $this->writeActive(false);
273  }
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 760 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(), time, and ilUtil\zip().

761  {
762  include_once "./Services/Utilities/classes/class.ilUtil.php";
763  $exportpath = $this->createArchiveDirectory();
764  ilUtil::makeDir($exportpath);
765  $xsl = file_get_contents($this->getXSLPath());
766  $xslexport = str_replace($this->getAdapter()->getCertificatePath(), "", $xsl);
767  // save export xsl file
768  $this->saveCertificate($xslexport, $exportpath . $this->getXSLName());
769  // save background image
770  if ($this->hasBackgroundImage())
771  {
772  copy($this->getBackgroundImagePath(), $exportpath . $this->getBackgroundImageName());
773  }
774  else
775  {
776  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
778  {
780  }
781  }
782  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate.zip";
783  ilUtil::zip($exportpath, $this->getAdapter()->getCertificatePath() . $zipfile);
784  ilUtil::delDir($exportpath);
785  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
786  }
static getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
getBackgroundImagePath($asRelative=false)
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 ...
getBackgroundImageName()
Returns the filename of the background image.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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 458 of file class.ilCertificate.php.

References getAdapter(), and ilUtil\prepareFormOutput().

Referenced by createPreview(), and outCertificate().

459  {
460  if (count($insert_tags) == 0)
461  {
462  $insert_tags = $this->getAdapter()->getCertificateVariablesForPreview();
463  foreach (self::getCustomCertificateFields() as $k => $f)
464  {
465  $insert_tags[$f["ph"]] = ilUtil::prepareFormOutput($f["name"]);
466  }
467  }
468  foreach ($insert_tags as $var => $value)
469  {
470  $certificate_text = str_replace($var, $value, $certificate_text);
471  }
472 
473  $certificate_text = str_replace('[CLIENT_WEB_DIR]', CLIENT_WEB_DIR, $certificate_text);
474 
475  return $certificate_text;
476  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getAdapter()
Gets the adapter.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ formatNumberString()

ilCertificate::formatNumberString (   $a_number)
Parameters
string$a_number
Returns
float

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

96  {
97  return str_replace(',', '.', $a_number);
98  }

◆ getAdapter()

◆ getBackgroundImageName()

ilCertificate::getBackgroundImageName ( )

Returns the filename of the background image.

Returns
string The filename of the background image

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

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

125  {
126  return "background.jpg";
127  }
+ Here is the caller graph for this function:

◆ getBackgroundImagePath()

ilCertificate::getBackgroundImagePath (   $asRelative = false)

Returns the filesystem path of the background image.

Parameters
bool$asRelative
Returns
string The filesystem path of the background image

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

References array, getAdapter(), and getBackgroundImageName().

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

106  {
107  if($asRelative)
108  {
109  return str_replace(
110  array(CLIENT_WEB_DIR, '//'),
111  array('[CLIENT_WEB_DIR]', '/'),
112  $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName()
113  );
114  }
115 
116  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
117  }
getAdapter()
Gets the adapter.
Create styles array
The data for the language used.
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 184 of file class.ilCertificate.php.

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

185  {
186  // TODO: this is generic now -> provide better solution
187  include_once "./Services/Utilities/classes/class.ilUtil.php";
188  $webdir = $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
189  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $webdir);
190  }
getAdapter()
Gets the adapter.
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 144 of file class.ilCertificate.php.

References getAdapter().

Referenced by deleteBackgroundImage(), and uploadBackgroundImage().

145  {
146  return $this->getAdapter()->getCertificatePath() . "background_upload.tmp";
147  }
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 134 of file class.ilCertificate.php.

References getAdapter(), and getBackgroundImageName().

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

135  {
136  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName() . ".thumb.jpg";
137  }
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 197 of file class.ilCertificate.php.

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

198  {
199  // TODO: this is generic now -> provide better solution
200  include_once "./Services/Utilities/classes/class.ilUtil.php";
201  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImageThumbPath());
202  }
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
static removeTrailingPathSeparators($path)
+ Here is the call graph for this function:

◆ getCustomCertificateFields()

static ilCertificate::getCustomCertificateFields ( )
static

Get custom certificate fields.

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

Referenced by ilCertificateGUI\certificateEditor().

1062  {
1063  include_once("./Services/User/classes/class.ilUserDefinedFields.php");
1064  $user_field_definitions = ilUserDefinedFields::_getInstance();
1065  $fds = $user_field_definitions->getDefinitions();
1066  $fields = array();
1067  foreach ($fds as $f)
1068  {
1069  if ($f["certificate"])
1070  {
1071  $fields[$f["field_id"]] = array("name" => $f["field_name"],
1072  "ph" => "[#".str_replace(" ", "_", strtoupper($f["field_name"]))."]");
1073  }
1074  }
1075 
1076  return $fields;
1077  }
static _getInstance()
Get instance.
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getExchangeContent()

ilCertificate::getExchangeContent ( )
Returns
string

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

1083  {
1084  if(!file_exists($this->getXSLPath()))
1085  {
1086  return '';
1087  }
1088 
1089  $output = '';
1090  $xsl_file_content = file_get_contents($this->getXSLPath());
1091  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
1092 
1093  if((strlen($xsl_file_content)) && (strlen($xsl)))
1094  {
1095  $args = array('/_xml' => $xsl_file_content, '/_xsl' => $xsl);
1096  $xh = xslt_create();
1097  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
1098  xslt_error($xh);
1099  xslt_free($xh);
1100  }
1101 
1102  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
1103  // dirty hack: the php xslt processing seems not to recognize the following
1104  // replacements, so we do it in the code as well
1105  $output = str_replace("&#xA0;", "<br />", $output);
1106  $output = str_replace("&#160;", "<br />", $output);
1107 
1108  return $output;
1109  }
xslt_create()
xslt_free(&$proc)
xslt_error(&$proc)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
getXSLPath()
Returns the filesystem path of the XSL-FO file.
Create styles array
The data for the language used.

◆ getFormFieldsFromFO()

ilCertificate::getFormFieldsFromFO ( )

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

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

References $output, array, getAdapter(), getXSLPath(), xslt_create(), xslt_error(), and xslt_free().

279  {
280  if (@file_exists($this->getXSLPath()))
281  {
282  $xslfo = file_get_contents($this->getXSLPath());
283  }
284  // retrieve form information (using a dirty way with regular expressions)
285  $pagewidth = "21cm";
286  if (preg_match("/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
287  {
288  $pagewidth = $matches[1];
289  }
290  $pageheight = "29.7cm";
291  if (preg_match("/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
292  {
293  $pageheight = $matches[1];
294  }
295  $certificatesettings = new ilSetting("certificate");
296  $pagesize = $certificatesettings->get("pageformat");;
297  if (((strcmp($pageheight, "29.7cm") == 0) || (strcmp($pageheight, "297mm") == 0)) && ((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)))
298  {
299  $pagesize = "a4";
300  }
301  else if (((strcmp($pagewidth, "29.7cm") == 0) || (strcmp($pagewidth, "297mm") == 0)) && ((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)))
302  {
303  $pagesize = "a4landscape";
304  }
305  else if (((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)) && ((strcmp($pagewidth, "14.8cm") == 0) || (strcmp($pagewidth, "148mm") == 0)))
306  {
307  $pagesize = "a5";
308  }
309  else if (((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)) && ((strcmp($pageheight, "14.8cm") == 0) || (strcmp($pageheight, "148mm") == 0)))
310  {
311  $pagesize = "a5landscape";
312  }
313  else if (((strcmp($pageheight, "11in") == 0)) && ((strcmp($pagewidth, "8.5in") == 0)))
314  {
315  $pagesize = "letter";
316  }
317  else if (((strcmp($pagewidth, "11in") == 0)) && ((strcmp($pageheight, "8.5in") == 0)))
318  {
319  $pagesize = "letterlandscape";
320  }
321  else
322  {
323  $pagesize = "custom";
324  }
325  if (!strlen($xslfo)) $pagesize = $certificatesettings->get("pageformat");;
326 
327  $marginbody_top = "0cm";
328  $marginbody_right = "2cm";
329  $marginbody_bottom = "0cm";
330  $marginbody_left = "2cm";
331  if(preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
332  {
333  // Backwards compatibility
334  $marginbody = $matches[1];
335  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
336  {
337  $marginbody_top = $matches[1][0];
338  $marginbody_right = $matches[1][1];
339  $marginbody_bottom = $matches[1][2];
340  $marginbody_left = $matches[1][3];
341  }
342  }
343  else if(preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
344  {
345  $marginbody = $matches[1];
346  if (preg_match_all("/([^\s]+)/", $marginbody, $matches))
347  {
348  $marginbody_top = $matches[1][0];
349  $marginbody_right = $matches[1][1];
350  $marginbody_bottom = $matches[1][2];
351  $marginbody_left = $matches[1][3];
352  }
353  }
354 
355  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
356  if ((strlen($xslfo)) && (strlen($xsl)))
357  {
358  $args = array( '/_xml' => $xslfo, '/_xsl' => $xsl );
359  $xh = xslt_create();
360  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, NULL);
361  xslt_error($xh);
362  xslt_free($xh);
363  }
364 
365  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
366  // dirty hack: the php xslt processing seems not to recognize the following
367  // replacements, so we do it in the code as well
368  $output = str_replace("&#xA0;", "<br />", $output);
369  $output = str_replace("&#160;", "<br />", $output);
370  $form_fields = array(
371  "pageformat" => $pagesize,
372  "pagewidth" => $pagewidth,
373  "pageheight" => $pageheight,
374  "margin_body_top" => $marginbody_top,
375  "margin_body_right" => $marginbody_right,
376  "margin_body_bottom" => $marginbody_bottom,
377  "margin_body_left" => $marginbody_left,
378  "certificate_text" => $output
379  );
380  $this->getAdapter()->addFormFieldsFromObject($form_fields);
381  return $form_fields;
382  }
xslt_create()
ILIAS Setting Class.
xslt_free(&$proc)
xslt_error(&$proc)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
Create styles array
The data for the language used.
+ 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 709 of file class.ilCertificate.php.

References array.

Referenced by processXHTML2FO().

710  {
711  return array(
712  "a4" => array(
713  "name" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
714  "value" => "a4",
715  "width" => "210mm",
716  "height" => "297mm"
717  ),
718  "a4landscape" => array(
719  "name" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
720  "value" => "a4landscape",
721  "width" => "297mm",
722  "height" => "210mm"
723  ),
724  "a5" => array(
725  "name" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
726  "value" => "a5",
727  "width" => "148mm",
728  "height" => "210mm"
729  ),
730  "a5landscape" => array(
731  "name" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
732  "value" => "a5landscape",
733  "width" => "210mm",
734  "height" => "148mm"
735  ),
736  "letter" => array(
737  "name" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
738  "value" => "letter",
739  "width" => "8.5in",
740  "height" => "11in"
741  ),
742  "letterlandscape" => array(
743  "name" => $this->lng->txt("certificate_letter_landscape"), // (8.5 inch x 11 inch)
744  "value" => "letterlandscape",
745  "width" => "11in",
746  "height" => "8.5in"
747  ),
748  "custom" => array(
749  "name" => $this->lng->txt("certificate_custom"),
750  "value" => "custom",
751  "width" => "",
752  "height" => ""
753  )
754  );
755  }
Create styles array
The data for the language used.
+ 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 164 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and getXSLPath().

165  {
166  return "certificate.xml";
167  }
+ 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 154 of file class.ilCertificate.php.

References getAdapter(), and getXSLName().

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

155  {
156  return $this->getAdapter()->getCertificatePath() . $this->getXSLName();
157  }
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 635 of file class.ilCertificate.php.

References getBackgroundImagePath().

Referenced by deliverExportFileXML(), and processXHTML2FO().

636  {
637  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
638  {
639  return TRUE;
640  }
641  else
642  {
643  return FALSE;
644  }
645  }
getBackgroundImagePath($asRelative=false)
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 793 of file class.ilCertificate.php.

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

794  {
795  include_once "./Services/Utilities/classes/class.ilUtil.php";
796  $importpath = $this->createArchiveDirectory();
797  if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename))
798  {
799  ilUtil::delDir($importpath);
800  return FALSE;
801  }
802  ilUtil::unzip($importpath . $filename, TRUE);
803  $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
804  $copydir = "";
805  if (is_dir($importpath . $subdir))
806  {
807  $dirinfo = ilUtil::getDir($importpath . $subdir);
808  $copydir = $importpath . $subdir;
809  }
810  else
811  {
812  $dirinfo = ilUtil::getDir($importpath);
813  $copydir = $importpath;
814  }
815  $xmlfiles = 0;
816  $otherfiles = 0;
817  foreach ($dirinfo as $file)
818  {
819  if (strcmp($file["type"], "file") == 0)
820  {
821  if (strpos($file["entry"], ".xml") !== FALSE)
822  {
823  $xmlfiles++;
824  }
825  else if (strpos($file["entry"], ".zip") !== FALSE)
826  {
827  }
828  else
829  {
830  $otherfiles++;
831  }
832  }
833  }
834  // if one XML file is in the archive, we try to import it
835  if ($xmlfiles == 1)
836  {
837  foreach ($dirinfo as $file)
838  {
839  if (strcmp($file["type"], "file") == 0)
840  {
841  if (strpos($file["entry"], ".xml") !== FALSE)
842  {
843  $xsl = file_get_contents($copydir . $file["entry"]);
844  // as long as we cannot make RPC calls in a given directory, we have
845  // to add the complete path to every url
846  $xsl = preg_replace("/url\([']{0,1}(.*?)[']{0,1}\)/", "url(" . $this->getAdapter()->getCertificatePath() . "\${1})", $xsl);
847  $this->saveCertificate($xsl);
848  }
849  else if (strpos($file["entry"], ".zip") !== FALSE)
850  {
851  }
852  else
853  {
854  @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
855  if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0)
856  {
857  // upload of the background image, create a preview
859  }
860  }
861  }
862  }
863  }
864  else
865  {
866  ilUtil::delDir($importpath);
867  return FALSE;
868  }
869  ilUtil::delDir($importpath);
870  return TRUE;
871  }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
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
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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 943 of file class.ilCertificate.php.

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

944  {
945  if(self::$is_active === null)
946  {
947  // basic admin setting active?
948  $certificate_active = new ilSetting("certificate");
949  $certificate_active = (bool)$certificate_active->get("active");
950 
951  // java/rtpc-server active?
952  if($certificate_active)
953  {
954  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
955  $certificate_active = ilRPCServerSettings::getInstance()->isEnabled();
956  }
957 
958  self::$is_active = (bool)$certificate_active;
959  }
960  return self::$is_active;
961  }
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 652 of file class.ilCertificate.php.

References getAdapter(), and getXSLPath().

653  {
654  if(self::isActive())
655  {
656  $obj_id = $this->getAdapter()->getCertificateID();
657  if($obj_id && !self::isObjectActive($obj_id))
658  {
659  return FALSE;
660  }
661  if (file_exists($this->getAdapter()->getCertificatePath()))
662  {
663  if (file_exists($this->getXSLPath()) && (filesize($this->getXSLPath()) > 0))
664  {
665  return TRUE;
666  }
667  }
668  }
669  return FALSE;
670  }
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
Parameters
int$a_obj_id
Returns
bool

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

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

968  {
969  $chk = self::areObjectsActive(array($a_obj_id));
970  return $chk[$a_obj_id];
971  }
Create styles array
The data for the language used.
+ 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
bool$deliver
Returns
void|string

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

References $params, ilUtil\deliverData(), exchangeCertificateVariables(), ilRpcClientFactory\factory(), getAdapter(), ilMathJax\getInstance(), getXSLPath(), ilUtil\prepareFormOutput(), ilMathJax\PURPOSE_PDF, ilMathJax\RENDER_PNG_AS_FO_FILE, and ilDatePresentation\setUseRelativeDates().

485  {
487  $insert_tags = $this->getAdapter()->getCertificateVariablesForPresentation($params);
488 
489  include_once("./Services/User/classes/class.ilUserDefinedData.php");
490  $cust_data = new ilUserDefinedData($this->getAdapter()->getUserIdForParams($params));
491  $cust_data = $cust_data->getAll();
492  foreach (self::getCustomCertificateFields() as $k => $f)
493  {
494  $insert_tags[$f["ph"]] = ilUtil::prepareFormOutput($cust_data["f_".$k]);
495  }
496 
497  $xslfo = file_get_contents($this->getXSLPath());
498 
499  // render tex as fo graphics
500  require_once('Services/MathJax/classes/class.ilMathJax.php');
501  $xslfo = ilMathJax::getInstance()
502  ->init(ilMathJax::PURPOSE_PDF)
503  ->setRendering(ilMathJax::RENDER_PNG_AS_FO_FILE)
504  ->insertLatexImages($xslfo);
505 
506  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
507  try
508  {
509  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
510  $this->exchangeCertificateVariables($xslfo, $insert_tags));
511  if ($deliver)
512  {
513  include_once "./Services/Utilities/classes/class.ilUtil.php";
514  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
515  }
516  else
517  {
518  return $pdf_base64->scalar;
519  }
520  }
521  catch(Exception $e)
522  {
523  $this->log->write(__METHOD__.': '.$e->getMessage());
524  return false;
525  }
526 
528 
529  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
Class ilUserDefinedData.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
const PURPOSE_PDF
static setUseRelativeDates($a_status)
set use relative dates
getAdapter()
Gets the adapter.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
const RENDER_PNG_AS_FO_FILE
static getInstance()
Singleton: get 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,
array  $insert_tags 
)
Parameters
string$content
array$insert_tags
Returns
bool
Exceptions
Exception

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

1118  {
1120 
1121  $form_fields = $this->getFormFieldsFromFO();
1122  $form_fields['certificate_text'] = $content;
1123  $xslfo = $this->processXHTML2FO($form_fields);
1124 
1125  $content = $this->exchangeCertificateVariables($xslfo, $insert_tags);
1126  $content = str_replace('[BR]', "<fo:block/>", $content);
1127 
1128  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
1129  try
1130  {
1131  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($content);
1132  include_once "./Services/Utilities/classes/class.ilUtil.php";
1133  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(array()), "application/pdf");
1134  }
1135  catch(Exception $e)
1136  {
1137  $this->log->write(__METHOD__.': '.$e->getMessage());
1138  return false;
1139  }
1140 
1142  }
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 factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
static setUseRelativeDates($a_status)
set use relative dates
Create styles array
The data for the language used.
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 390 of file class.ilCertificate.php.

References $output, $params, array, ilObjCertificateSettingsAccess\getBackgroundImagePath(), getBackgroundImagePath(), getPageFormats(), ilObjCertificateSettingsAccess\hasBackgroundImage(), hasBackgroundImage(), settings(), xslt_create(), xslt_error(), and xslt_free().

391  {
392  $content = "<html><body>".$form_data["certificate_text"]."</body></html>";
393  $content = preg_replace("/<p>(&nbsp;){1,}<\\/p>/", "<p></p>", $content);
394  $content = preg_replace("/<p>(\\s)*?<\\/p>/", "<p></p>", $content);
395 // $content = str_replace("<p>&nbsp;</p>", "<p><br /></p>", $content);
396 // $content = str_replace("<p> </p>", "<p><br /></p>", $content);
397  $content = str_replace("<p></p>", "<p class=\"emptyrow\"></p>", $content);
398  $content = str_replace("&nbsp;", "&#160;", $content);
399  $content = preg_replace("//", "", $content);
400 
401  include_once "./Services/Certificate/classes/class.ilXmlChecker.php";
402  $check = new ilXMLChecker();
403  $check->setXMLContent($content);
404  $check->startParsing();
405  if ($check->hasError())
406  {
407  throw new Exception($this->lng->txt("certificate_not_well_formed"));
408  }
409 
410  $xsl = file_get_contents("./Services/Certificate/xml/xhtml2fo.xsl");
411 
412  // additional font support
413  $xsl = str_replace(
414  'font-family="Helvetica, unifont"',
415  'font-family="'.$this->settings->get('rpc_pdf_font','Helvetica, unifont').'"',
416  $xsl
417  );
418 
419  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
420  $xh = xslt_create();
421  if (strcmp($form_data["pageformat"], "custom") == 0)
422  {
423  $pageheight = $form_data["pageheight"];
424  $pagewidth = $form_data["pagewidth"];
425  }
426  else
427  {
428  $pageformats = $this->getPageFormats();
429  $pageheight = $pageformats[$form_data["pageformat"]]["height"];
430  $pagewidth = $pageformats[$form_data["pageformat"]]["width"];
431  }
432  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
434  $params = array(
435  "pageheight" => $pageheight,
436  "pagewidth" => $pagewidth,
437  "backgroundimage" => $backgroundimage,
438  "marginbody" => implode(' ', array(
439  $form_data["margin_body_top"],
440  $form_data["margin_body_right"],
441  $form_data["margin_body_bottom"],
442  $form_data["margin_body_left"]
443  ))
444  );
445  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params);
446  xslt_error($xh);
447  xslt_free($xh);
448  return $output;
449  }
xslt_create()
xslt_free(&$proc)
getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
hasBackgroundImage()
Checks for the background image of the certificate.
xslt_error(&$proc)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
getPageFormats()
Retrieves predefined page formats.
XML checker.
Create styles array
The data for the language used.
settings()
Definition: settings.php:2
$params
Definition: example_049.php:96
Class ilObjCertificateSettingsAccess.
+ Here is the call graph for this function:

◆ readActive()

ilCertificate::readActive ( )
Returns
int

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

Referenced by cloneCertificate().

1005  {
1006  $obj_id = $this->adapter->getCertificateID();
1007  $set = $this->db->query("SELECT obj_id FROM il_certificate WHERE obj_id = " . $this->db->quote($obj_id, "integer"));
1008  return $this->db->numRows($set);
1009  }
+ 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 570 of file class.ilCertificate.php.

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

Referenced by deliverExportFileXML(), and importCertificate().

571  {
572  if (!file_exists($this->getAdapter()->getCertificatePath()))
573  {
574  ilUtil::makeDirParents($this->getAdapter()->getCertificatePath());
575  }
576  if (strlen($filename) == 0)
577  {
578  $filename = $this->getXSLPath();
579  }
580  $fh = fopen($filename, "w");
581  fwrite($fh, $xslfo);
582  fclose($fh);
583  }
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.
+ 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 888 of file class.ilCertificate.php.

References $adapter.

889  {
890  $this->adapter =& $adapter;
891  }

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

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

593  {
594  if (!empty($image_tempfilename))
595  {
596  $convert_filename = $this->getBackgroundImageName();
597  $imagepath = $this->getAdapter()->getCertificatePath();
598  if (!file_exists($imagepath))
599  {
600  ilUtil::makeDirParents($imagepath);
601  }
602  // upload the file
604  $image_tempfilename,
605  basename($this->getBackgroundImageTempfilePath()),
607  )) {
608  return FALSE;
609  }
610  // convert the uploaded file to JPEG
613  if (!file_exists($this->getBackgroundImagePath()))
614  {
615  // something went wrong converting the file. use the original file and hope, that PDF can work with it
616  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath()))
617  {
618  return FALSE;
619  }
620  }
621  unlink($this->getBackgroundImageTempfilePath());
622  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0))
623  {
624  return TRUE;
625  }
626  }
627  return FALSE;
628  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
getBackgroundImagePath($asRelative=false)
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)
Parameters
$a_valuebool

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

Referenced by deleteCertificate().

1015  {
1016  $obj_id = $this->adapter->getCertificateID();
1017 
1018  if((bool)$a_value)
1019  {
1020  $this->db->replace("il_certificate", array("obj_id" => array("integer", $obj_id)), array());
1021  }
1022  else
1023  {
1024  $this->db->manipulate("DELETE FROM il_certificate WHERE obj_id = " . $this->db->quote($obj_id, "integer"));
1025  }
1026  }
Create styles array
The data for the language used.
+ 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 931 of file class.ilCertificate.php.

932  {
933  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip";
934  ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile);
935  ilUtil::delDir($dir);
936  if ($deliver)
937  {
938  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
939  }
940  return $this->getAdapter()->getCertificatePath() . $zipfile;
941  }
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
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
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 50 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.

◆ $db

ilCertificate::$db
protected

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

◆ $ilias

ilCertificate::$ilias
protected

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

◆ $is_active

ilCertificate::$is_active
staticprotected

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

◆ $lng

ilCertificate::$lng
protected

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

◆ $log

ilCertificate::$log
protected

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

◆ $settings

ilCertificate::$settings
protected

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

◆ $tree

ilCertificate::$tree
protected

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


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