80 $this->lng = $DIC[
'lng'];
81 $this->ctrl = $DIC[
'ilCtrl'];
82 $this->
ilias = $DIC[
'ilias'];
83 $this->tree = $DIC[
'tree'];
85 $this->log = $DIC[
'ilLog'];
86 $this->db = $DIC[
'ilDB'];
97 return str_replace(
',',
'.', $a_number);
109 array(CLIENT_WEB_DIR,
'//'),
110 array(
'[CLIENT_WEB_DIR]',
'/'),
125 return "background.jpg";
145 return $this->
getAdapter()->getCertificatePath() .
"background_upload.tmp";
165 return "certificate.xml";
175 return "certificate.xml";
186 include_once
"./Services/Utilities/classes/class.ilUtil.php";
199 include_once
"./Services/Utilities/classes/class.ilUtil.php";
233 $certificatepath = $this->
getAdapter()->getCertificatePath();
235 $new_xsl = $newObject->getXSLPath();
236 $new_bgimage = $newObject->getBackgroundImagePath();
237 $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
238 $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
240 if (@file_exists($xsl)) {
242 @copy($xsl, $new_xsl);
243 if (@file_exists($bgimage)) {
244 @copy($bgimage, $new_bgimage);
246 if (@file_exists($bgimagethumb)) {
247 @copy($bgimagethumb, $new_bgimagethumb);
253 $newObject->writeActive(
true);
264 if (@file_exists($this->
getAdapter()->getCertificatePath())) {
265 include_once
"./Services/Utilities/classes/class.ilUtil.php";
278 $xslfo = file_get_contents($this->
getXSLPath());
282 if (preg_match(
"/page-width\=\"([^\"]+)\"/", $xslfo, $matches)) {
283 $pagewidth = $matches[1];
285 $pageheight =
"29.7cm";
286 if (preg_match(
"/page-height\=\"([^\"]+)\"/", $xslfo, $matches)) {
287 $pageheight = $matches[1];
289 $certificatesettings =
new ilSetting(
"certificate");
290 $pagesize = $certificatesettings->get(
"pageformat");
292 if (((strcmp($pageheight,
"29.7cm") == 0) || (strcmp($pageheight,
"297mm") == 0)) && ((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0))) {
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))) {
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";
305 $pagesize =
"custom";
307 if (!strlen($xslfo)) {
308 $pagesize = $certificatesettings->get(
"pageformat");
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)) {
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];
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];
334 $xsl = file_get_contents(
"./Services/Certificate/xml/fo2xhtml.xsl");
335 if ((strlen($xslfo)) && (strlen($xsl))) {
336 $args =
array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
338 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args, null);
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,
358 $this->
getAdapter()->addFormFieldsFromObject($form_fields);
370 $content =
"<html><body>" . $form_data[
"certificate_text"] .
"</body></html>";
371 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
372 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
375 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
376 $content = str_replace(
" ",
" ", $content);
377 $content = preg_replace(
"//",
"", $content);
379 include_once
"./Services/Certificate/classes/class.ilXmlChecker.php";
381 $check->setXMLContent($content);
382 $check->startParsing();
383 if ($check->hasError()) {
384 throw new Exception($this->lng->txt(
"certificate_not_well_formed"));
387 $xsl = file_get_contents(
"./Services/Certificate/xml/xhtml2fo.xsl");
391 'font-family="Helvetica, unifont"',
392 'font-family="' . $this->
settings->get(
'rpc_pdf_font',
'Helvetica, unifont') .
'"',
396 $args =
array(
'/_xml' => $content,
'/_xsl' => $xsl );
398 if (strcmp($form_data[
"pageformat"],
"custom") == 0) {
399 $pageheight = $form_data[
"pageheight"];
400 $pagewidth = $form_data[
"pagewidth"];
403 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
404 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
406 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
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"]
419 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", null, $args,
$params);
434 if (count($insert_tags) == 0) {
435 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPreview();
436 foreach (self::getCustomCertificateFields() as $k => $f) {
440 foreach ($insert_tags as $var => $value) {
441 $certificate_text = str_replace($var, $value, $certificate_text);
444 $certificate_text = str_replace(
'[CLIENT_WEB_DIR]', CLIENT_WEB_DIR, $certificate_text);
446 return $certificate_text;
458 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPresentation(
$params);
460 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
462 $cust_data = $cust_data->getAll();
463 foreach (self::getCustomCertificateFields() as $k => $f) {
467 $xslfo = file_get_contents($this->
getXSLPath());
470 require_once(
'Services/MathJax/classes/class.ilMathJax.php');
474 ->insertLatexImages($xslfo);
476 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
482 include_once
"./Services/Utilities/classes/class.ilUtil.php";
485 return $pdf_base64->scalar;
488 $this->log->write(__METHOD__ .
': ' . $e->getMessage());
502 $xslfo = file_get_contents($this->
getXSLPath());
505 require_once(
'Services/MathJax/classes/class.ilMathJax.php');
509 ->insertLatexImages($xslfo);
511 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
516 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(),
"application/pdf");
518 $this->log->write(__METHOD__ .
': ' . $e->getMessage());
532 if (!file_exists($this->
getAdapter()->getCertificatePath())) {
552 if (!empty($image_tempfilename)) {
554 $imagepath = $this->
getAdapter()->getCertificatePath();
555 if (!file_exists($imagepath)) {
559 if (!ilUtil::moveUploadedFile(
604 if (self::isActive()) {
605 $obj_id = $this->
getAdapter()->getCertificateID();
606 if ($obj_id && !self::isObjectActive($obj_id)) {
609 if (file_exists($this->
getAdapter()->getCertificatePath())) {
627 if (self::isActive()) {
628 $obj_id =
$adapter->getCertificateID();
629 if ($obj_id && !self::isObjectActive($obj_id)) {
633 $certificatepath =
$adapter->getCertificatePath();
634 if (file_exists($certificatepath)) {
636 if (file_exists($xslpath) && (filesize($xslpath) > 0)) {
654 "name" => $this->lng->txt(
"certificate_a4"),
659 "a4landscape" =>
array(
660 "name" => $this->lng->txt(
"certificate_a4_landscape"),
661 "value" =>
"a4landscape",
666 "name" => $this->lng->txt(
"certificate_a5"),
671 "a5landscape" =>
array(
672 "name" => $this->lng->txt(
"certificate_a5_landscape"),
673 "value" =>
"a5landscape",
678 "name" => $this->lng->txt(
"certificate_letter"),
683 "letterlandscape" =>
array(
684 "name" => $this->lng->txt(
"certificate_letter_landscape"),
685 "value" =>
"letterlandscape",
690 "name" => $this->lng->txt(
"certificate_custom"),
703 include_once
"./Services/Utilities/classes/class.ilUtil.php";
706 $xsl = file_get_contents($this->
getXSLPath());
707 $xslexport = str_replace($this->
getAdapter()->getCertificatePath(),
"", $xsl);
714 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
719 $zipfile =
time() .
"__" . IL_INST_ID .
"__" . $this->
getAdapter()->getAdapterType() .
"__" . $this->
getAdapter()->getCertificateId() .
"__certificate.zip";
732 include_once
"./Services/Utilities/classes/class.ilUtil.php";
739 $subdir = str_replace(
".zip",
"", strtolower($filename)) .
"/";
741 if (is_dir($importpath . $subdir)) {
743 $copydir = $importpath . $subdir;
746 $copydir = $importpath;
750 foreach ($dirinfo as
$file) {
751 if (strcmp($file[
"type"],
"file") == 0) {
752 if (strpos($file[
"entry"],
".xml") !==
false) {
754 } elseif (strpos($file[
"entry"],
".zip") !==
false) {
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"]);
768 $xsl = preg_replace_callback(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
function (
array $matches) {
770 $fileName = basename($matches[1]);
772 return 'url(' . $basePath .
'/' . $fileName .
')';
775 } elseif (strpos($file[
"entry"],
".zip") !==
false) {
777 @copy($copydir . $file[
"entry"], $this->
getAdapter()->getCertificatePath() . $file[
"entry"]);
static makeDirParents($a_dir)
Create a new directory and all parent directories.
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.
__construct(ilCertificateAdapter $adapter)
ilCertificate constructor
deleteCertificate()
Deletes the certificate and all it's data.
static _isComplete($adapter)
Checks the status of the certificate.
createPreview()
Creates a PDF preview of the XSL-FO certificate.
getFormFieldsFromFO()
Convert the XSL-FO to the certificate text and the form settings using XSL transformation.
static getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
static factory($a_package, $a_timeout=0)
Creates an ilRpcClient instance to our ilServer.
getBackgroundImagePathWeb()
Returns the web path of the background image.
outCertificate($params, $deliver=true)
Creates a PDF certificate.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
formatNumberString($a_number)
static setUseRelativeDates($a_status)
set use relative dates
deleteBackgroundImage()
Deletes the background image of a certificate.
getBackgroundImagePath($asRelative=false)
Returns the filesystem path of the background image.
static getBackgroundImageName()
Returns the filename of the background image.
uploadBackgroundImage($image_tempfilename)
Uploads a background image for the certificate.
hasBackgroundImage()
Checks for the background image of the certificate.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
saveCertificate($xslfo, $filename="")
Saves the XSL-FO code to a file.
getAdapter()
Gets the adapter.
getPageFormats()
Retrieves predefined page formats.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
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
redirection script todo: (a better solution should control the processing via a xml file) ...
static removeTrailingPathSeparators($path)
static zip($a_dir, $a_file, $compress_content=false)
zips given directory/file into given zip.file
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.
static hasBackgroundImage()
Returns wheather or not a default background image exists.
const RENDER_PNG_AS_FO_FILE
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
importCertificate($zipfile, $filename)
Reads an import ZIP file and creates a certificate of it.
isComplete()
Checks the status of the certificate.
setAdapter($adapter)
Sets the adapter.
getBackgroundImageName()
Returns the filename of the background image.
static getInstance()
Singleton: get instance.
deliverExportFileXML()
Builds an export file in ZIP format and delivers it.
Adapter class to provide certificate data for the certificate generator.
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
exchangeCertificateVariables($certificate_text, $insert_tags=array())
Exchanges the variables in the certificate text with given values.
static _getXSLName()
Returns the filename of the XSL-FO file.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
cloneCertificate($newObject)
Clone the certificate for another test object.
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.