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";
301 $pagesize =
"custom";
303 if (!strlen($xslfo)) $pagesize = $certificatesettings->get(
"pageformat");;
306 if (preg_match(
"/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
308 $paddingtop = $matches[1];
310 $marginbody_top =
"0cm";
311 $marginbody_right =
"2cm";
312 $marginbody_bottom =
"0cm";
313 $marginbody_left =
"2cm";
314 if(preg_match(
"/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
317 $marginbody = $matches[1];
318 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
320 $marginbody_top = $matches[1][0];
321 $marginbody_right = $matches[1][1];
322 $marginbody_bottom = $matches[1][2];
323 $marginbody_left = $matches[1][3];
326 else if(preg_match(
"/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
328 $marginbody = $matches[1];
329 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
331 $marginbody_top = $matches[1][0];
332 $marginbody_right = $matches[1][1];
333 $marginbody_bottom = $matches[1][2];
334 $marginbody_left = $matches[1][3];
338 $xsl = file_get_contents(
"./Services/Certificate/xml/fo2xhtml.xsl");
339 if ((strlen($xslfo)) && (strlen($xsl)))
341 $args = array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
343 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, NULL);
348 $output = preg_replace(
"/<\?xml[^>]+?>/",
"", $output);
351 $output = str_replace(
" ",
"<br />", $output);
352 $output = str_replace(
" ",
"<br />", $output);
353 $form_fields = array(
354 "pageformat" => $pagesize,
355 "pagewidth" => $pagewidth,
356 "pageheight" => $pageheight,
357 "padding_top" => $paddingtop,
358 "margin_body_top" => $marginbody_top,
359 "margin_body_right" => $marginbody_right,
360 "margin_body_bottom" => $marginbody_bottom,
361 "margin_body_left" => $marginbody_left,
362 "certificate_text" => $output
364 $this->
getAdapter()->addFormFieldsFromObject($form_fields);
376 $content =
"<html><body>".$form_data[
"certificate_text"].
"</body></html>";
377 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
378 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
381 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
382 $content = str_replace(
" ",
" ", $content);
383 $content = preg_replace(
"//",
"", $content);
385 include_once
"./Services/Certificate/classes/class.ilXmlChecker.php";
387 $check->setXMLContent($content);
388 $check->startParsing();
389 if ($check->hasError())
391 throw new Exception($this->lng->txt(
"certificate_not_well_formed"));
394 $xsl = file_get_contents(
"./Services/Certificate/xml/xhtml2fo.xsl");
395 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
397 if (strcmp($form_data[
"pageformat"],
"custom") == 0)
399 $pageheight = $form_data[
"pageheight"];
400 $pagewidth = $form_data[
"pagewidth"];
405 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
406 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
408 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
411 "pageheight" => $pageheight,
412 "pagewidth" => $pagewidth,
413 "backgroundimage" => $backgroundimage,
414 "marginbody" => $form_data[
"margin_body_top"] .
" " . $form_data[
"margin_body_right"] .
" " . $form_data[
"margin_body_bottom"] .
" " . $form_data[
"margin_body_left"],
415 "paddingtop" => $form_data[
"padding_top"]
417 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
432 if (count($insert_tags) == 0)
434 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPreview();
436 foreach ($insert_tags as $var => $value)
438 $certificate_text = str_replace($var, $value, $certificate_text);
440 return $certificate_text;
454 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPresentation($params);
455 $xslfo = file_get_contents($this->
getXSLPath());
457 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
464 include_once
"./Services/Utilities/classes/class.ilUtil.php";
465 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params),
"application/pdf");
469 return $pdf_base64->scalar;
474 $ilLog->write(__METHOD__.
': '.$e->getMessage());
479 $ilLog->write(__METHOD__.
': '.$e->getMessage());
511 $xslfo = file_get_contents($this->
getXSLPath());
513 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
518 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(),
"application/pdf");
523 $ilLog->write(__METHOD__.
': '.$e->getMessage());
528 $ilLog->write(__METHOD__.
': '.$e->getMessage());
551 if (!file_exists($this->
getAdapter()->getCertificatePath()))
573 if (!empty($image_tempfilename))
575 $image_filename =
"background_upload";
577 $imagepath = $this->
getAdapter()->getCertificatePath();
578 if (!file_exists($imagepath))
631 if (file_exists($this->
getAdapter()->getCertificatePath()))
651 $certificatepath =
$adapter->getCertificatePath();
652 if (file_exists($certificatepath))
655 if (file_exists($xslpath) && (filesize($xslpath) > 0))
673 "name" => $this->lng->txt(
"certificate_a4"),
678 "a4landscape" => array(
679 "name" => $this->lng->txt(
"certificate_a4_landscape"),
680 "value" =>
"a4landscape",
685 "name" => $this->lng->txt(
"certificate_a5"),
690 "a5landscape" => array(
691 "name" => $this->lng->txt(
"certificate_a5_landscape"),
692 "value" =>
"a5landscape",
697 "name" => $this->lng->txt(
"certificate_letter"),
702 "letterlandscape" => array(
703 "name" => $this->lng->txt(
"certificate_letter_landscape"),
704 "value" =>
"letterlandscape",
709 "name" => $this->lng->txt(
"certificate_custom"),
722 include_once
"./Services/Utilities/classes/class.ilUtil.php";
725 $xsl = file_get_contents($this->
getXSLPath());
726 $xslexport = str_replace($this->
getAdapter()->getCertificatePath(),
"", $xsl);
736 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
742 $zipfile = time() .
"__" . IL_INST_ID .
"__" . $this->
getAdapter()->getAdapterType() .
"__" . $this->
getAdapter()->getCertificateId() .
"__certificate.zip";
755 include_once
"./Services/Utilities/classes/class.ilUtil.php";
763 $subdir = str_replace(
".zip",
"", strtolower($filename)) .
"/";
765 if (is_dir($importpath . $subdir))
768 $copydir = $importpath . $subdir;
773 $copydir = $importpath;
777 foreach ($dirinfo as
$file)
779 if (strcmp($file[
"type"],
"file") == 0)
781 if (strpos($file[
"entry"],
".xml") !== FALSE)
785 else if (strpos($file[
"entry"],
".zip") !== FALSE)
797 foreach ($dirinfo as $file)
799 if (strcmp($file[
"type"],
"file") == 0)
801 if (strpos($file[
"entry"],
".xml") !== FALSE)
803 $xsl = file_get_contents($copydir . $file[
"entry"]);
806 $xsl = preg_replace(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
"url(" . $this->
getAdapter()->getCertificatePath() .
"\${1})", $xsl);
809 else if (strpos($file[
"entry"],
".zip") !== FALSE)
814 @copy($copydir . $file[
"entry"], $this->
getAdapter()->getCertificatePath() . $file[
"entry"]);