111 return "background.jpg";
131 return $this->
getAdapter()->getCertificatePath() .
"background_upload";
151 return "certificate.xml";
161 return "certificate.xml";
172 include_once
"./Services/Utilities/classes/class.ilUtil.php";
185 include_once
"./Services/Utilities/classes/class.ilUtil.php";
222 $certificatepath = $this->
getAdapter()->getCertificatePath();
224 $new_xsl = $newObject->getXSLPath();
225 $new_bgimage = $newObject->getBackgroundImagePath();
226 $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
227 $new_certificatepath = $newObject->getAdapter()->getCertificatePath();
229 if (@file_exists($xsl))
232 @copy($xsl, $new_xsl);
233 if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
234 if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
245 if (@file_exists($this->
getAdapter()->getCertificatePath()))
247 include_once
"./Services/Utilities/classes/class.ilUtil.php";
260 $xslfo = file_get_contents($this->
getXSLPath());
264 if (preg_match(
"/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
266 $pagewidth = $matches[1];
268 $pageheight =
"29.7cm";
269 if (preg_match(
"/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
271 $pageheight = $matches[1];
273 $certificatesettings =
new ilSetting(
"certificate");
274 $pagesize = $certificatesettings->get(
"pageformat");;
275 if (((strcmp($pageheight,
"29.7cm") == 0) || (strcmp($pageheight,
"297mm") == 0)) && ((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)))
279 else if (((strcmp($pagewidth,
"29.7cm") == 0) || (strcmp($pagewidth,
"297mm") == 0)) && ((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)))
281 $pagesize =
"a4landscape";
283 else if (((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)) && ((strcmp($pagewidth,
"14.8cm") == 0) || (strcmp($pagewidth,
"148mm") == 0)))
287 else if (((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)) && ((strcmp($pageheight,
"14.8cm") == 0) || (strcmp($pageheight,
"148mm") == 0)))
289 $pagesize =
"a5landscape";
291 else if (((strcmp($pageheight,
"11in") == 0)) && ((strcmp($pagewidth,
"8.5in") == 0)))
293 $pagesize =
"letter";
295 else if (((strcmp($pagewidth,
"11in") == 0)) && ((strcmp($pageheight,
"8.5in") == 0)))
297 $pagesize =
"letterlandscape";
299 if (!strlen($xslfo)) $pagesize = $certificatesettings->get(
"pageformat");;
302 if (preg_match(
"/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
304 $paddingtop = $matches[1];
306 $marginbody_top =
"0cm";
307 $marginbody_right =
"2cm";
308 $marginbody_bottom =
"0cm";
309 $marginbody_left =
"2cm";
310 if (preg_match(
"/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
312 $marginbody = $matches[1];
313 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
315 $marginbody_top = $matches[1][0];
316 $marginbody_right = $matches[1][1];
317 $marginbody_bottom = $matches[1][2];
318 $marginbody_left = $matches[1][3];
322 $xsl = file_get_contents(
"./Services/Certificate/xml/fo2xhtml.xsl");
323 if ((strlen($xslfo)) && (strlen($xsl)))
325 $args = array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
327 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, NULL);
332 $output = preg_replace(
"/<\?xml[^>]+?>/",
"", $output);
335 $output = str_replace(
" ",
"<br />", $output);
336 $output = str_replace(
" ",
"<br />", $output);
337 $form_fields = array(
338 "pageformat" => $pagesize,
339 "pagewidth" => $pagewidth,
340 "pageheight" => $pageheight,
341 "padding_top" => $paddingtop,
342 "margin_body_top" => $marginbody_top,
343 "margin_body_right" => $marginbody_right,
344 "margin_body_bottom" => $marginbody_bottom,
345 "margin_body_left" => $marginbody_left,
346 "certificate_text" => $output
348 $this->
getAdapter()->addFormFieldsFromObject($form_fields);
360 $content =
"<html><body>".$form_data[
"certificate_text"].
"</body></html>";
361 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
362 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
365 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
366 $content = str_replace(
" ",
" ", $content);
367 $content = preg_replace(
"//",
"", $content);
369 include_once
"./Services/Certificate/classes/class.ilXmlChecker.php";
371 $check->setXMLContent($content);
372 $check->startParsing();
373 if ($check->hasError())
375 throw new Exception($this->lng->txt(
"certificate_not_well_formed"));
378 $xsl = file_get_contents(
"./Services/Certificate/xml/xhtml2fo.xsl");
379 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
381 if (strcmp($form_data[
"pageformat"],
"custom") == 0)
383 $pageheight = $form_data[
"pageheight"];
384 $pagewidth = $form_data[
"pagewidth"];
389 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
390 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
392 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
395 "pageheight" => $pageheight,
396 "pagewidth" => $pagewidth,
397 "backgroundimage" => $backgroundimage,
398 "marginbody" => $form_data[
"margin_body_top"] .
" " . $form_data[
"margin_body_right"] .
" " . $form_data[
"margin_body_bottom"] .
" " . $form_data[
"margin_body_left"],
399 "paddingtop" => $form_data[
"padding_top"]
401 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
416 if (count($insert_tags) == 0)
418 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPreview();
420 foreach ($insert_tags as $var => $value)
422 $certificate_text = str_replace($var, $value, $certificate_text);
424 return $certificate_text;
436 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPresentation($params);
437 $xslfo = file_get_contents($this->
getXSLPath());
439 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
446 include_once
"./Services/Utilities/classes/class.ilUtil.php";
447 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params),
"application/pdf");
451 return $pdf_base64->scalar;
456 $ilLog->write(__METHOD__.
': '.$e->getMessage());
461 $ilLog->write(__METHOD__.
': '.$e->getMessage());
489 $xslfo = file_get_contents($this->
getXSLPath());
491 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
496 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(),
"application/pdf");
501 $ilLog->write(__METHOD__.
': '.$e->getMessage());
506 $ilLog->write(__METHOD__.
': '.$e->getMessage());
527 if (!file_exists($this->
getAdapter()->getCertificatePath()))
549 if (!empty($image_tempfilename))
551 $image_filename =
"background_upload";
553 $imagepath = $this->
getAdapter()->getCertificatePath();
554 if (!file_exists($imagepath))
607 if (file_exists($this->
getAdapter()->getCertificatePath()))
627 $certificatepath =
$adapter->getCertificatePath();
628 if (file_exists($certificatepath))
631 if (file_exists($xslpath) && (filesize($xslpath) > 0))
649 "name" => $this->lng->txt(
"certificate_a4"),
654 "a4landscape" => array(
655 "name" => $this->lng->txt(
"certificate_a4_landscape"),
656 "value" =>
"a4landscape",
661 "name" => $this->lng->txt(
"certificate_a5"),
666 "a5landscape" => array(
667 "name" => $this->lng->txt(
"certificate_a5_landscape"),
668 "value" =>
"a5landscape",
673 "name" => $this->lng->txt(
"certificate_letter"),
678 "letterlandscape" => array(
679 "name" => $this->lng->txt(
"certificate_letter_landscape"),
680 "value" =>
"letterlandscape",
685 "name" => $this->lng->txt(
"certificate_custom"),
698 include_once
"./Services/Utilities/classes/class.ilUtil.php";
701 $xsl = file_get_contents($this->
getXSLPath());
702 $xslexport = str_replace($this->
getAdapter()->getCertificatePath(),
"", $xsl);
712 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
718 $zipfile = time() .
"__" . IL_INST_ID .
"__" . $this->
getAdapter()->getAdapterType() .
"__" . $this->
getAdapter()->getCertificateId() .
"__certificate.zip";
731 include_once
"./Services/Utilities/classes/class.ilUtil.php";
739 $subdir = str_replace(
".zip",
"", strtolower($filename)) .
"/";
741 if (is_dir($importpath . $subdir))
744 $copydir = $importpath . $subdir;
749 $copydir = $importpath;
753 foreach ($dirinfo as
$file)
755 if (strcmp($file[
"type"],
"file") == 0)
757 if (strpos($file[
"entry"],
".xml") !== FALSE)
761 else if (strpos($file[
"entry"],
".zip") !== FALSE)
773 foreach ($dirinfo as $file)
775 if (strcmp($file[
"type"],
"file") == 0)
777 if (strpos($file[
"entry"],
".xml") !== FALSE)
779 $xsl = file_get_contents($copydir . $file[
"entry"]);
782 $xsl = preg_replace(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
"url(" . $this->
getAdapter()->getCertificatePath() .
"\${1})", $xsl);
785 else if (strpos($file[
"entry"],
".zip") !== FALSE)
790 @copy($copydir . $file[
"entry"], $this->
getAdapter()->getCertificatePath() . $file[
"entry"]);