104 $this->
object =& $a_object;
105 $this->tree =&
$tree;
118 return CLIENT_WEB_DIR .
"/assessment/certificates/" . $this->
object->getId() .
"/";
131 return CLIENT_WEB_DIR .
"/assessment/certificates/" . $this->
object->getId() .
"/" . $this->
getBackgroundImageName();
144 return "background.jpg";
157 return CLIENT_WEB_DIR .
"/assessment/certificates/" . $this->
object->getId() .
"/" . $this->
getBackgroundImageName() .
".thumb.jpg";
170 return CLIENT_WEB_DIR .
"/assessment/certificates/" . $this->
object->getId() .
"/background_upload";
183 return CLIENT_WEB_DIR .
"/assessment/certificates/" . $this->
object->getId() .
"/" . $this->
getXSLName();
196 return "certificate.xml";
209 include_once
"./Services/Utilities/classes/class.ilUtil.php";
256 include_once
"./Services/Utilities/classes/class.ilUtil.php";
273 if ((strlen($form_fields[
"padding_top"]) == 0) ||
274 (strlen($form_fields[
"margin_body_top"]) == 0) ||
275 (strlen($form_fields[
"margin_body_right"]) == 0) ||
276 (strlen($form_fields[
"margin_body_bottom"]) == 0) ||
277 (strlen($form_fields[
"margin_body_left"]) == 0) ||
278 (strlen($form_fields[
"certificate_text"]) == 0))
280 return $this->lng->txt(
"fill_out_all_required_fields");
283 $unitexpression =
"^([\d\.]+)(pt|pc|px|em|mm|cm|in){0,1}\$";
284 if (!preg_match(
"/$unitexpression/", $form_fields[
"padding_top"], $matches))
286 return $this->lng->txt(
"certificate_wrong_unit");
288 if (strcmp($form_fields[
"pageformat"],
"custom") == 0)
290 if (!preg_match(
"/$unitexpression/", $form_fields[
"pageheight"], $matches))
292 return $this->lng->txt(
"certificate_wrong_unit");
294 if (!preg_match(
"/$unitexpression/", $form_fields[
"pagewidth"], $matches))
296 return $this->lng->txt(
"certificate_wrong_unit");
299 if (!preg_match(
"/$unitexpression/", $form_fields[
"margin_body_top"], $matches))
301 return $this->lng->txt(
"certificate_wrong_unit");
303 if (!preg_match(
"/$unitexpression/", $form_fields[
"margin_body_right"], $matches))
305 return $this->lng->txt(
"certificate_wrong_unit");
307 if (!preg_match(
"/$unitexpression/", $form_fields[
"margin_body_bottom"], $matches))
309 return $this->lng->txt(
"certificate_wrong_unit");
311 if (!preg_match(
"/$unitexpression/", $form_fields[
"margin_body_left"], $matches))
313 return $this->lng->txt(
"certificate_wrong_unit");
315 if (strlen($form_fields[
"certificate_text"]) == 0)
317 return $this->lng->txt(
"certificate_missing_text");
319 if (strlen($form_fields[
"certificate_text"]) > 0)
321 include_once
"class.ilXMLChecker.php";
323 $check->setXMLContent(str_replace(
" ",
" ",
"<html>" . $form_fields[
"certificate_text"] .
"</html>"));
324 $check->startParsing();
325 if ($check->hasError())
327 return $this->lng->txt(
"certificate_not_well_formed");
344 $xslfo = file_get_contents($this->
getXSLPath());
348 if (preg_match(
"/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
350 $pagewidth = $matches[1];
352 $pageheight =
"29.7cm";
353 if (preg_match(
"/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
355 $pageheight = $matches[1];
357 $pagesize =
"custom";
358 if (((strcmp($pageheight,
"29.7cm") == 0) || (strcmp($pageheight,
"297mm") == 0)) && ((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)))
362 else if (((strcmp($pagewidth,
"29.7cm") == 0) || (strcmp($pagewidth,
"297mm") == 0)) && ((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)))
364 $pagesize =
"a4landscape";
366 else if (((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)) && ((strcmp($pagewidth,
"14.8cm") == 0) || (strcmp($pagewidth,
"148mm") == 0)))
370 else if (((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)) && ((strcmp($pageheight,
"14.8cm") == 0) || (strcmp($pageheight,
"148mm") == 0)))
372 $pagesize =
"a5landscape";
374 else if (((strcmp($pageheight,
"11in") == 0)) && ((strcmp($pagewidth,
"8.5in") == 0)))
376 $pagesize =
"letter";
378 else if (((strcmp($pagewidth,
"11in") == 0)) && ((strcmp($pageheight,
"8.5in") == 0)))
380 $pagesize =
"letterlandscape";
392 if (preg_match(
"/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
394 $paddingtop = $matches[1];
396 $marginbody_top =
"0cm";
397 $marginbody_right =
"2cm";
398 $marginbody_bottom =
"0cm";
399 $marginbody_left =
"2cm";
400 if (preg_match(
"/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
402 $marginbody = $matches[1];
403 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
405 $marginbody_top = $matches[1][0];
406 $marginbody_right = $matches[1][1];
407 $marginbody_bottom = $matches[1][2];
408 $marginbody_left = $matches[1][3];
412 $xsl = file_get_contents(
"./Modules/Test/xml/fo2xhtml.xsl");
413 if ((strlen($xslfo)) && (strlen($xsl)))
415 $args = array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
417 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, NULL);
422 $output = preg_replace(
"/<\?xml[^>]+?>/",
"", $output);
425 $output = str_replace(
" ",
"<br />", $output);
426 $output = str_replace(
" ",
"<br />", $output);
428 "pageformat" => $pagesize,
429 "pagewidth" => $pagewidth,
430 "pageheight" => $pageheight,
431 "padding_top" => $paddingtop,
432 "margin_body_top" => $marginbody_top,
433 "margin_body_right" => $marginbody_right,
434 "margin_body_bottom" => $marginbody_bottom,
435 "margin_body_left" => $marginbody_left,
436 "certificate_text" => $output,
437 "certificate_visibility" => $this->object->getCertificateVisibility()
452 $content =
"<html><body>".$form_data[
"certificate_text"].
"</body></html>";
453 $content = str_replace(
"<p> </p>",
"<p><br /></p>", $content);
454 $content = str_replace(
" ",
" ", $content);
455 $xsl = file_get_contents(
"./Modules/Test/xml/xhtml2fo.xsl");
456 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
458 if (strcmp($form_data[
"pageformat"],
"custom") == 0)
460 $pageheight = $form_data[
"pageheight"];
461 $pagewidth = $form_data[
"pagewidth"];
466 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
467 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
471 "pageheight" => $pageheight,
472 "pagewidth" => $pagewidth,
473 "backgroundimage" => $backgroundimage,
474 "marginbody" => $form_data[
"margin_body_top"] .
" " . $form_data[
"margin_body_right"] .
" " . $form_data[
"margin_body_bottom"] .
" " . $form_data[
"margin_body_left"],
475 "paddingtop" => $form_data[
"padding_top"]
477 $output =
xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
493 $this->
object->saveCertificateVisibility($a_value);
508 if (count($user_data) == 0)
510 include_once
"./classes/class.ilFormat.php";
533 foreach ($user_data as $var => $value)
535 $certificate_text = str_replace($var, $value, $certificate_text);
537 return $certificate_text;
542 $dir = $this->
getCertificatePath() . time() .
"__" . IL_INST_ID .
"__" .
"test" .
"__" . $this->
object->getId() .
"__certificate/";
543 include_once
"./Services/Utilities/classes/class.ilUtil.php";
551 fwrite($fh, $pdfdata);
566 include_once
"./Services/Utilities/classes/class.ilUtil.php";
568 $total_users = array();
569 $total_users =& $this->
object->evalTotalPersonsArray();
570 if (count($total_users))
572 foreach ($total_users as $active_id => $name)
574 $user_id = $this->
object->_getUserIdFromActiveId($active_id);
575 $pdf = $this->
outCertificate($active_id,
"", FALSE, $userfilter, $passedonly);
581 $zipfile = time() .
"__" . IL_INST_ID .
"__" .
"test" .
"__" . $this->
object->getId() .
"__certificates.zip";
599 $result_array =& $this->
object->getTestResult($active_id,
$pass);
603 $result_array =& $this->
object->getTestResult($active_id);
605 if (($passedonly) && ($result_array[
"test"][
"passed"] == FALSE))
return "";
606 $passed = $result_array[
"test"][
"passed"] ? $this->lng->txt(
"certificate_passed") : $this->lng->txt(
"certificate_failed");
607 if (!$result_array[
"test"][
"total_max_points"])
613 $percentage = ($result_array[
"test"][
"total_reached_points"]/$result_array[
"test"][
"total_max_points"])*100;
615 $mark_obj = $this->
object->mark_schema->getMatchingMark($percentage);
616 $user_id = $this->
object->_getUserIdFromActiveId($active_id);
617 include_once
'./Services/User/classes/class.ilObjUser.php';
619 if (strlen($userfilter))
621 if (!@preg_match(
"/$userfilter/i", $user_data[
"lastname"] .
", " . $user_data[
"firstname"] .
" " . $user_data[
"title"]))
626 include_once
"./classes/class.ilFormat.php";
628 "[USER_FULLNAME]" =>
ilUtil::prepareFormOutput(trim($user_data[
"title"] .
" " . $user_data[
"firstname"] .
" " . $user_data[
"lastname"])),
640 "[RESULT_PERCENT]" => sprintf(
"%2.2f", $percentage) .
"%",
648 $xslfo = file_get_contents($this->
getXSLPath());
649 include_once
"./Services/Transformation/classes/class.ilFO2PDF.php";
655 include_once
"./Services/Utilities/classes/class.ilUtil.php";
673 $xslfo = file_get_contents($this->
getXSLPath());
674 include_once
"./Services/Transformation/classes/class.ilFO2PDF.php";
678 include_once
"./Services/Utilities/classes/class.ilUtil.php";
717 if (!empty($image_tempfilename))
719 $image_filename =
"background_upload";
722 if (!file_exists($imagepath))
801 $certificatepath = CLIENT_WEB_DIR .
"/assessment/certificates/" . $obj_id .
"/";
802 if (file_exists($certificatepath))
805 if (file_exists($xslpath) && (filesize($xslpath) > 0))
825 "name" => $this->lng->txt(
"certificate_a4"),
830 "a4landscape" => array(
831 "name" => $this->lng->txt(
"certificate_a4_landscape"),
832 "value" =>
"a4landscape",
837 "name" => $this->lng->txt(
"certificate_a5"),
842 "a5landscape" => array(
843 "name" => $this->lng->txt(
"certificate_a5_landscape"),
844 "value" =>
"a5landscape",
849 "name" => $this->lng->txt(
"certificate_letter"),
854 "letterlandscape" => array(
855 "name" => $this->lng->txt(
"certificate_letter_landscape"),
856 "value" =>
"letterlandscape",
861 "name" => $this->lng->txt(
"certificate_custom"),
881 $new_certificatepath = str_replace(
"/" . $this->object->getId() .
"/",
"/" . $new_id .
"/", $certificatepath);
882 $new_xsl = str_replace(
"/" . $this->object->getId() .
"/",
"/" . $new_id .
"/", $xsl);
883 $new_bgimage = str_replace(
"/" . $this->object->getId() .
"/",
"/" . $new_id .
"/", $bgimage);
884 $new_bgimagethumb = str_replace(
"/" . $this->object->getId() .
"/",
"/" . $new_id .
"/", $bgimagethumb);
886 if (@file_exists($xsl))
889 @copy($xsl, $new_xsl);
890 if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
891 if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
904 include_once
"./Services/Utilities/classes/class.ilUtil.php";
907 $xsl = file_get_contents($this->
getXSLPath());
916 $zipfile = time() .
"__" . IL_INST_ID .
"__" .
"test" .
"__" . $this->
object->getId() .
"__certificate.zip";
932 include_once
"./Services/Utilities/classes/class.ilUtil.php";
940 $subdir = str_replace(
".zip",
"", strtolower($filename)) .
"/";
942 if (is_dir($importpath . $subdir))
945 $copydir = $importpath . $subdir;
950 $copydir = $importpath;
954 foreach ($dirinfo as
$file)
956 if (strcmp($file[
"type"],
"file") == 0)
958 if (strpos($file[
"entry"],
".xml") !== FALSE)
962 else if (strpos($file[
"entry"],
".zip") !== FALSE)
974 foreach ($dirinfo as $file)
976 if (strcmp($file[
"type"],
"file") == 0)
978 if (strpos($file[
"entry"],
".xml") !== FALSE)
980 $xsl = file_get_contents($copydir . $file[
"entry"]);
983 $xsl = preg_replace(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
"url(" . $this->
getCertificatePath() .
"\${1})", $xsl);
986 else if (strpos($file[
"entry"],
".zip") !== FALSE)