ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  }
global $DIC
Definition: saml.php:7
redirection script todo: (a better solution should control the processing via a xml file) ...
settings()
Definition: settings.php:2
+ 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 173 of file class.ilCertificate.php.

Referenced by _isComplete().

174  {
175  return "certificate.xml";
176  }
+ 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 624 of file class.ilCertificate.php.

References $adapter, and _getXSLName().

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

625  {
626  if (is_object($adapter) && method_exists($adapter, "getCertificatePath")) {
627  if (self::isActive()) {
628  $obj_id = $adapter->getCertificateID();
629  if ($obj_id && !self::isObjectActive($obj_id)) {
630  return false;
631  }
632 
633  $certificatepath = $adapter->getCertificatePath();
634  if (file_exists($certificatepath)) {
635  $xslpath = $adapter->getCertificatePath() . ilCertificate::_getXSLName();
636  if (file_exists($xslpath) && (filesize($xslpath) > 0)) {
637  return true;
638  }
639  }
640  }
641  }
642  return false;
643  }
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 837 of file class.ilCertificate.php.

838  {
839  $fh = fopen($dir . $filename, "wb");
840  fwrite($fh, $pdfdata);
841  fclose($fh);
842  }

◆ cloneCertificate()

ilCertificate::cloneCertificate (   $newObject)

Clone the certificate for another test object.

Parameters
$newObjectThe new certificate object

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

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

229  {
230  $xsl = $this->getXSLPath();
231  $bgimage = $this->getBackgroundImagePath();
232  $bgimagethumb = $this->getBackgroundImageThumbPath();
233  $certificatepath = $this->getAdapter()->getCertificatePath();
234 
235  $new_xsl = $newObject->getXSLPath();
236  $new_bgimage = $newObject->getBackgroundImagePath();
237  $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
238  $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
239 
240  if (@file_exists($xsl)) {
241  ilUtil::makeDirParents($new_certificatepath);
242  @copy($xsl, $new_xsl);
243  if (@file_exists($bgimage)) {
244  @copy($bgimage, $new_bgimage);
245  }
246  if (@file_exists($bgimagethumb)) {
247  @copy($bgimagethumb, $new_bgimagethumb);
248  }
249  }
250 
251  // #10271
252  if ($this->readActive()) {
253  $newObject->writeActive(true);
254  }
255  }
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 822 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and importCertificate().

823  {
824  $dir = $this->getAdapter()->getCertificatePath() . time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate/";
825  include_once "./Services/Utilities/classes/class.ilUtil.php";
827  return $dir;
828  }
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 498 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().

499  {
501 
502  $xslfo = file_get_contents($this->getXSLPath());
503 
504  // render tex as fo graphics
505  require_once('Services/MathJax/classes/class.ilMathJax.php');
506  $xslfo = ilMathJax::getInstance()
507  ->init(ilMathJax::PURPOSE_PDF)
508  ->setRendering(ilMathJax::RENDER_PNG_AS_FO_FILE)
509  ->insertLatexImages($xslfo);
510 
511  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
512  try {
513  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
514  $this->exchangeCertificateVariables($xslfo)
515  );
516  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(), "application/pdf");
517  } catch (Exception $e) {
518  $this->log->write(__METHOD__ . ': ' . $e->getMessage());
519  return false;
520  }
521 
523  }
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 208 of file class.ilCertificate.php.

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

209  {
210  $result = true;
211  if (file_exists($this->getBackgroundImageThumbPath())) {
212  $result = $result & unlink($this->getBackgroundImageThumbPath());
213  }
214  if (file_exists($this->getBackgroundImagePath())) {
215  $result = $result & unlink($this->getBackgroundImagePath());
216  }
217  if (file_exists($this->getBackgroundImageTempfilePath())) {
218  $result = $result & unlink($this->getBackgroundImageTempfilePath());
219  }
220  return $result;
221  }
$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 262 of file class.ilCertificate.php.

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

263  {
264  if (@file_exists($this->getAdapter()->getCertificatePath())) {
265  include_once "./Services/Utilities/classes/class.ilUtil.php";
266  ilUtil::delDir($this->getAdapter()->getCertificatePath());
267  $this->getAdapter()->deleteCertificate();
268  }
269  $this->writeActive(false);
270  }
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 701 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().

702  {
703  include_once "./Services/Utilities/classes/class.ilUtil.php";
704  $exportpath = $this->createArchiveDirectory();
705  ilUtil::makeDir($exportpath);
706  $xsl = file_get_contents($this->getXSLPath());
707  $xslexport = str_replace($this->getAdapter()->getCertificatePath(), "", $xsl);
708  // save export xsl file
709  $this->saveCertificate($xslexport, $exportpath . $this->getXSLName());
710  // save background image
711  if ($this->hasBackgroundImage()) {
712  copy($this->getBackgroundImagePath(), $exportpath . $this->getBackgroundImageName());
713  } else {
714  include_once "./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
717  }
718  }
719  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificate.zip";
720  ilUtil::zip($exportpath, $this->getAdapter()->getCertificatePath() . $zipfile);
721  ilUtil::delDir($exportpath);
722  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
723  }
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 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.
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
+ 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 432 of file class.ilCertificate.php.

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

Referenced by createPreview(), and outCertificate().

433  {
434  if (count($insert_tags) == 0) {
435  $insert_tags = $this->getAdapter()->getCertificateVariablesForPreview();
436  foreach (self::getCustomCertificateFields() as $k => $f) {
437  $insert_tags[$f["ph"]] = ilUtil::prepareFormOutput($f["name"]);
438  }
439  }
440  foreach ($insert_tags as $var => $value) {
441  $certificate_text = str_replace($var, $value, $certificate_text);
442  }
443 
444  $certificate_text = str_replace('[CLIENT_WEB_DIR]', CLIENT_WEB_DIR, $certificate_text);
445 
446  return $certificate_text;
447  }
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 123 of file class.ilCertificate.php.

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

124  {
125  return "background.jpg";
126  }
+ 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  return str_replace(
109  array(CLIENT_WEB_DIR, '//'),
110  array('[CLIENT_WEB_DIR]', '/'),
111  $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName()
112  );
113  }
114 
115  return $this->getAdapter()->getCertificatePath() . $this->getBackgroundImageName();
116  }
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 183 of file class.ilCertificate.php.

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

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

References getAdapter().

Referenced by deleteBackgroundImage(), and uploadBackgroundImage().

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

References getAdapter(), and getBackgroundImageName().

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

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

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

197  {
198  // TODO: this is generic now -> provide better solution
199  include_once "./Services/Utilities/classes/class.ilUtil.php";
200  return str_replace(ilUtil::removeTrailingPathSeparators(ILIAS_ABSOLUTE_PATH), ilUtil::removeTrailingPathSeparators(ILIAS_HTTP_PATH), $this->getBackgroundImageThumbPath());
201  }
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 972 of file class.ilCertificate.php.

Referenced by ilCertificateGUI\certificateEditor().

973  {
974  include_once("./Services/User/classes/class.ilUserDefinedFields.php");
975  $user_field_definitions = ilUserDefinedFields::_getInstance();
976  $fds = $user_field_definitions->getDefinitions();
977  $fields = array();
978  foreach ($fds as $f) {
979  if ($f["certificate"]) {
980  $fields[$f["field_id"]] = array("name" => $f["field_name"],
981  "ph" => "[#" . str_replace(" ", "_", strtoupper($f["field_name"])) . "]");
982  }
983  }
984 
985  return $fields;
986  }
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 991 of file class.ilCertificate.php.

992  {
993  if (!file_exists($this->getXSLPath())) {
994  return '';
995  }
996 
997  $output = '';
998  $xsl_file_content = file_get_contents($this->getXSLPath());
999  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
1000 
1001  if ((strlen($xsl_file_content)) && (strlen($xsl))) {
1002  $args = array('/_xml' => $xsl_file_content, '/_xsl' => $xsl);
1003  $xh = xslt_create();
1004  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, null);
1005  xslt_error($xh);
1006  xslt_free($xh);
1007  }
1008 
1009  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
1010  // dirty hack: the php xslt processing seems not to recognize the following
1011  // replacements, so we do it in the code as well
1012  $output = str_replace("&#xA0;", "<br />", $output);
1013  $output = str_replace("&#160;", "<br />", $output);
1014 
1015  return $output;
1016  }
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 275 of file class.ilCertificate.php.

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

276  {
277  if (@file_exists($this->getXSLPath())) {
278  $xslfo = file_get_contents($this->getXSLPath());
279  }
280  // retrieve form information (using a dirty way with regular expressions)
281  $pagewidth = "21cm";
282  if (preg_match("/page-width\=\"([^\"]+)\"/", $xslfo, $matches)) {
283  $pagewidth = $matches[1];
284  }
285  $pageheight = "29.7cm";
286  if (preg_match("/page-height\=\"([^\"]+)\"/", $xslfo, $matches)) {
287  $pageheight = $matches[1];
288  }
289  $certificatesettings = new ilSetting("certificate");
290  $pagesize = $certificatesettings->get("pageformat");
291  ;
292  if (((strcmp($pageheight, "29.7cm") == 0) || (strcmp($pageheight, "297mm") == 0)) && ((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0))) {
293  $pagesize = "a4";
294  } elseif (((strcmp($pagewidth, "29.7cm") == 0) || (strcmp($pagewidth, "297mm") == 0)) && ((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0))) {
295  $pagesize = "a4landscape";
296  } elseif (((strcmp($pageheight, "21cm") == 0) || (strcmp($pageheight, "210mm") == 0)) && ((strcmp($pagewidth, "14.8cm") == 0) || (strcmp($pagewidth, "148mm") == 0))) {
297  $pagesize = "a5";
298  } elseif (((strcmp($pagewidth, "21cm") == 0) || (strcmp($pagewidth, "210mm") == 0)) && ((strcmp($pageheight, "14.8cm") == 0) || (strcmp($pageheight, "148mm") == 0))) {
299  $pagesize = "a5landscape";
300  } elseif (((strcmp($pageheight, "11in") == 0)) && ((strcmp($pagewidth, "8.5in") == 0))) {
301  $pagesize = "letter";
302  } elseif (((strcmp($pagewidth, "11in") == 0)) && ((strcmp($pageheight, "8.5in") == 0))) {
303  $pagesize = "letterlandscape";
304  } else {
305  $pagesize = "custom";
306  }
307  if (!strlen($xslfo)) {
308  $pagesize = $certificatesettings->get("pageformat");
309  };
310 
311  $marginbody_top = "0cm";
312  $marginbody_right = "2cm";
313  $marginbody_bottom = "0cm";
314  $marginbody_left = "2cm";
315  if (preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches)) {
316  // Backwards compatibility
317  $marginbody = $matches[1];
318  if (preg_match_all("/([^\s]+)/", $marginbody, $matches)) {
319  $marginbody_top = $matches[1][0];
320  $marginbody_right = $matches[1][1];
321  $marginbody_bottom = $matches[1][2];
322  $marginbody_left = $matches[1][3];
323  }
324  } elseif (preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches)) {
325  $marginbody = $matches[1];
326  if (preg_match_all("/([^\s]+)/", $marginbody, $matches)) {
327  $marginbody_top = $matches[1][0];
328  $marginbody_right = $matches[1][1];
329  $marginbody_bottom = $matches[1][2];
330  $marginbody_left = $matches[1][3];
331  }
332  }
333 
334  $xsl = file_get_contents("./Services/Certificate/xml/fo2xhtml.xsl");
335  if ((strlen($xslfo)) && (strlen($xsl))) {
336  $args = array( '/_xml' => $xslfo, '/_xsl' => $xsl );
337  $xh = xslt_create();
338  $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", null, $args, null);
339  xslt_error($xh);
340  xslt_free($xh);
341  }
342 
343  $output = preg_replace("/<\?xml[^>]+?>/", "", $output);
344  // dirty hack: the php xslt processing seems not to recognize the following
345  // replacements, so we do it in the code as well
346  $output = str_replace("&#xA0;", "<br />", $output);
347  $output = str_replace("&#160;", "<br />", $output);
348  $form_fields = array(
349  "pageformat" => $pagesize,
350  "pagewidth" => $pagewidth,
351  "pageheight" => $pageheight,
352  "margin_body_top" => $marginbody_top,
353  "margin_body_right" => $marginbody_right,
354  "margin_body_bottom" => $marginbody_bottom,
355  "margin_body_left" => $marginbody_left,
356  "certificate_text" => $output
357  );
358  $this->getAdapter()->addFormFieldsFromObject($form_fields);
359  return $form_fields;
360  }
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
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 650 of file class.ilCertificate.php.

References array.

Referenced by processXHTML2FO().

651  {
652  return array(
653  "a4" => array(
654  "name" => $this->lng->txt("certificate_a4"), // (297 mm x 210 mm)
655  "value" => "a4",
656  "width" => "210mm",
657  "height" => "297mm"
658  ),
659  "a4landscape" => array(
660  "name" => $this->lng->txt("certificate_a4_landscape"), // (210 mm x 297 mm)",
661  "value" => "a4landscape",
662  "width" => "297mm",
663  "height" => "210mm"
664  ),
665  "a5" => array(
666  "name" => $this->lng->txt("certificate_a5"), // (210 mm x 148.5 mm)
667  "value" => "a5",
668  "width" => "148mm",
669  "height" => "210mm"
670  ),
671  "a5landscape" => array(
672  "name" => $this->lng->txt("certificate_a5_landscape"), // (148.5 mm x 210 mm)
673  "value" => "a5landscape",
674  "width" => "210mm",
675  "height" => "148mm"
676  ),
677  "letter" => array(
678  "name" => $this->lng->txt("certificate_letter"), // (11 inch x 8.5 inch)
679  "value" => "letter",
680  "width" => "8.5in",
681  "height" => "11in"
682  ),
683  "letterlandscape" => array(
684  "name" => $this->lng->txt("certificate_letter_landscape"), // (8.5 inch x 11 inch)
685  "value" => "letterlandscape",
686  "width" => "11in",
687  "height" => "8.5in"
688  ),
689  "custom" => array(
690  "name" => $this->lng->txt("certificate_custom"),
691  "value" => "custom",
692  "width" => "",
693  "height" => ""
694  )
695  );
696  }
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 163 of file class.ilCertificate.php.

Referenced by deliverExportFileXML(), and getXSLPath().

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

References getAdapter(), and getXSLName().

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

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

References getBackgroundImagePath().

Referenced by deliverExportFileXML(), and processXHTML2FO().

589  {
590  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0)) {
591  return true;
592  } else {
593  return false;
594  }
595  }
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 730 of file class.ilCertificate.php.

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

731  {
732  include_once "./Services/Utilities/classes/class.ilUtil.php";
733  $importpath = $this->createArchiveDirectory();
734  if (!ilUtil::moveUploadedFile($zipfile, $filename, $importpath . $filename)) {
735  ilUtil::delDir($importpath);
736  return false;
737  }
738  ilUtil::unzip($importpath . $filename, true);
739  $subdir = str_replace(".zip", "", strtolower($filename)) . "/";
740  $copydir = "";
741  if (is_dir($importpath . $subdir)) {
742  $dirinfo = ilUtil::getDir($importpath . $subdir);
743  $copydir = $importpath . $subdir;
744  } else {
745  $dirinfo = ilUtil::getDir($importpath);
746  $copydir = $importpath;
747  }
748  $xmlfiles = 0;
749  $otherfiles = 0;
750  foreach ($dirinfo as $file) {
751  if (strcmp($file["type"], "file") == 0) {
752  if (strpos($file["entry"], ".xml") !== false) {
753  $xmlfiles++;
754  } elseif (strpos($file["entry"], ".zip") !== false) {
755  } else {
756  $otherfiles++;
757  }
758  }
759  }
760  // if one XML file is in the archive, we try to import it
761  if ($xmlfiles == 1) {
762  foreach ($dirinfo as $file) {
763  if (strcmp($file["type"], "file") == 0) {
764  if (strpos($file["entry"], ".xml") !== false) {
765  $xsl = file_get_contents($copydir . $file["entry"]);
766  // as long as we cannot make RPC calls in a given directory, we have
767  // to add the complete path to every url
768  $xsl = preg_replace_callback("/url\([']{0,1}(.*?)[']{0,1}\)/", function (array $matches) {
769  $basePath = rtrim(dirname($this->getBackgroundImagePath(true)), '/');
770  $fileName = basename($matches[1]);
771 
772  return 'url(' . $basePath . '/' . $fileName . ')';
773  }, $xsl);
774  $this->saveCertificate($xsl);
775  } elseif (strpos($file["entry"], ".zip") !== false) {
776  } else {
777  @copy($copydir . $file["entry"], $this->getAdapter()->getCertificatePath() . $file["entry"]);
778  if (strcmp($this->getBackgroundImagePath(), $this->getAdapter()->getCertificatePath() . $file["entry"]) == 0) {
779  // upload of the background image, create a preview
781  }
782  }
783  }
784  }
785  } else {
786  ilUtil::delDir($importpath);
787  return false;
788  }
789  ilUtil::delDir($importpath);
790  return true;
791  }
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 convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
Create styles array
The data for the language used.
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 862 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().

863  {
864  if (self::$is_active === null) {
865  // basic admin setting active?
866  $certificate_active = new ilSetting("certificate");
867  $certificate_active = (bool) $certificate_active->get("active");
868 
869  // java/rtpc-server active?
870  if ($certificate_active) {
871  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
872  $certificate_active = ilRPCServerSettings::getInstance()->isEnabled();
873  }
874 
875  self::$is_active = (bool) $certificate_active;
876  }
877  return self::$is_active;
878  }
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 602 of file class.ilCertificate.php.

References getAdapter(), and getXSLPath().

603  {
604  if (self::isActive()) {
605  $obj_id = $this->getAdapter()->getCertificateID();
606  if ($obj_id && !self::isObjectActive($obj_id)) {
607  return false;
608  }
609  if (file_exists($this->getAdapter()->getCertificatePath())) {
610  if (file_exists($this->getXSLPath()) && (filesize($this->getXSLPath()) > 0)) {
611  return true;
612  }
613  }
614  }
615  return false;
616  }
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 884 of file class.ilCertificate.php.

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

885  {
886  $chk = self::areObjectsActive(array($a_obj_id));
887  return $chk[$a_obj_id];
888  }
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 455 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().

456  {
458  $insert_tags = $this->getAdapter()->getCertificateVariablesForPresentation($params);
459 
460  include_once("./Services/User/classes/class.ilUserDefinedData.php");
461  $cust_data = new ilUserDefinedData($this->getAdapter()->getUserIdForParams($params));
462  $cust_data = $cust_data->getAll();
463  foreach (self::getCustomCertificateFields() as $k => $f) {
464  $insert_tags[$f["ph"]] = ilUtil::prepareFormOutput($cust_data["f_" . $k]);
465  }
466 
467  $xslfo = file_get_contents($this->getXSLPath());
468 
469  // render tex as fo graphics
470  require_once('Services/MathJax/classes/class.ilMathJax.php');
471  $xslfo = ilMathJax::getInstance()
472  ->init(ilMathJax::PURPOSE_PDF)
473  ->setRendering(ilMathJax::RENDER_PNG_AS_FO_FILE)
474  ->insertLatexImages($xslfo);
475 
476  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
477  try {
478  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF(
479  $this->exchangeCertificateVariables($xslfo, $insert_tags)
480  );
481  if ($deliver) {
482  include_once "./Services/Utilities/classes/class.ilUtil.php";
483  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params), "application/pdf");
484  } else {
485  return $pdf_base64->scalar;
486  }
487  } catch (Exception $e) {
488  $this->log->write(__METHOD__ . ': ' . $e->getMessage());
489  return false;
490  }
491 
493  }
$params
Definition: disable.php:11
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.
+ 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 1024 of file class.ilCertificate.php.

1025  {
1027 
1028  $form_fields = $this->getFormFieldsFromFO();
1029  $form_fields['certificate_text'] = $content;
1030  $xslfo = $this->processXHTML2FO($form_fields);
1031 
1032  $content = $this->exchangeCertificateVariables($xslfo, $insert_tags);
1033  $content = str_replace('[BR]', "<fo:block/>", $content);
1034 
1035  include_once './Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
1036  try {
1037  $pdf_base64 = ilRpcClientFactory::factory('RPCTransformationHandler')->ilFO2PDF($content);
1038  include_once "./Services/Utilities/classes/class.ilUtil.php";
1039  ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(array()), "application/pdf");
1040  } catch (Exception $e) {
1041  $this->log->write(__METHOD__ . ': ' . $e->getMessage());
1042  return false;
1043  }
1044 
1046  }
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
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
processXHTML2FO($form_data, $for_export=false)
Convert the certificate text to XSL-FO using XSL transformation.
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 368 of file class.ilCertificate.php.

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

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

◆ readActive()

ilCertificate::readActive ( )
Returns
int

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

Referenced by cloneCertificate().

920  {
921  $obj_id = $this->adapter->getCertificateID();
922  $set = $this->db->query("SELECT obj_id FROM il_certificate WHERE obj_id = " . $this->db->quote($obj_id, "integer"));
923  return $this->db->numRows($set);
924  }
+ 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 530 of file class.ilCertificate.php.

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

Referenced by deliverExportFileXML(), and importCertificate().

531  {
532  if (!file_exists($this->getAdapter()->getCertificatePath())) {
533  ilUtil::makeDirParents($this->getAdapter()->getCertificatePath());
534  }
535  if (strlen($filename) == 0) {
536  $filename = $this->getXSLPath();
537  }
538  $fh = fopen($filename, "w");
539  fwrite($fh, $xslfo);
540  fclose($fh);
541  }
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 808 of file class.ilCertificate.php.

References $adapter.

809  {
810  $this->adapter =&$adapter;
811  }

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

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

551  {
552  if (!empty($image_tempfilename)) {
553  $convert_filename = $this->getBackgroundImageName();
554  $imagepath = $this->getAdapter()->getCertificatePath();
555  if (!file_exists($imagepath)) {
556  ilUtil::makeDirParents($imagepath);
557  }
558  // upload the file
559  if (!ilUtil::moveUploadedFile(
560  $image_tempfilename,
561  basename($this->getBackgroundImageTempfilePath()),
563  )) {
564  return false;
565  }
566  // convert the uploaded file to JPEG
569  if (!file_exists($this->getBackgroundImagePath())) {
570  // something went wrong converting the file. use the original file and hope, that PDF can work with it
571  if (!ilUtil::moveUploadedFile($this->getBackgroundImageTempfilePath(), $convert_filename, $this->getBackgroundImagePath())) {
572  return false;
573  }
574  }
575  unlink($this->getBackgroundImageTempfilePath());
576  if (file_exists($this->getBackgroundImagePath()) && (filesize($this->getBackgroundImagePath()) > 0)) {
577  return true;
578  }
579  }
580  return false;
581  }
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.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
static convertImage( $a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
getBackgroundImageName()
Returns the filename of the background image.
+ Here is the call graph for this function:

◆ writeActive()

ilCertificate::writeActive (   $a_value)
Parameters
$a_valuebool

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

Referenced by deleteCertificate().

930  {
931  $obj_id = $this->adapter->getCertificateID();
932 
933  if ((bool) $a_value) {
934  $this->db->replace("il_certificate", array("obj_id" => array("integer", $obj_id)), array());
935  } else {
936  $this->db->manipulate("DELETE FROM il_certificate WHERE obj_id = " . $this->db->quote($obj_id, "integer"));
937  }
938  }
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 851 of file class.ilCertificate.php.

852  {
853  $zipfile = time() . "__" . IL_INST_ID . "__" . $this->getAdapter()->getAdapterType() . "__" . $this->getAdapter()->getCertificateId() . "__certificates.zip";
854  ilUtil::zip($dir, $this->getAdapter()->getCertificatePath() . $zipfile);
855  ilUtil::delDir($dir);
856  if ($deliver) {
857  ilUtil::deliverFile($this->getAdapter()->getCertificatePath() . $zipfile, $zipfile, "application/zip");
858  }
859  return $this->getAdapter()->getCertificatePath() . $zipfile;
860  }
getAdapter()
Gets the adapter.
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
static deliverFile( $a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.

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: