95 return "background.jpg";
115 return $this->
getAdapter()->getCertificatePath() .
"background_upload";
135 return "certificate.xml";
145 return "certificate.xml";
156 include_once
"./Services/Utilities/classes/class.ilUtil.php";
169 include_once
"./Services/Utilities/classes/class.ilUtil.php";
206 $certificatepath = $this->
getAdapter()->getCertificatePath();
211 $new_certificatepath = $newObject->
getAdapter()->getCertificatePath();
213 if (@file_exists($xsl))
216 @copy($xsl, $new_xsl);
217 if (@file_exists($bgimage)) @copy($bgimage, $new_bgimage);
218 if (@file_exists($bgimagethumb)) @copy($bgimagethumb, $new_bgimagethumb);
235 if (@file_exists($this->
getAdapter()->getCertificatePath()))
237 include_once
"./Services/Utilities/classes/class.ilUtil.php";
251 $xslfo = file_get_contents($this->
getXSLPath());
255 if (preg_match(
"/page-width\=\"([^\"]+)\"/", $xslfo, $matches))
257 $pagewidth = $matches[1];
259 $pageheight =
"29.7cm";
260 if (preg_match(
"/page-height\=\"([^\"]+)\"/", $xslfo, $matches))
262 $pageheight = $matches[1];
264 $certificatesettings =
new ilSetting(
"certificate");
265 $pagesize = $certificatesettings->get(
"pageformat");;
266 if (((strcmp($pageheight,
"29.7cm") == 0) || (strcmp($pageheight,
"297mm") == 0)) && ((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)))
270 else if (((strcmp($pagewidth,
"29.7cm") == 0) || (strcmp($pagewidth,
"297mm") == 0)) && ((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)))
272 $pagesize =
"a4landscape";
274 else if (((strcmp($pageheight,
"21cm") == 0) || (strcmp($pageheight,
"210mm") == 0)) && ((strcmp($pagewidth,
"14.8cm") == 0) || (strcmp($pagewidth,
"148mm") == 0)))
278 else if (((strcmp($pagewidth,
"21cm") == 0) || (strcmp($pagewidth,
"210mm") == 0)) && ((strcmp($pageheight,
"14.8cm") == 0) || (strcmp($pageheight,
"148mm") == 0)))
280 $pagesize =
"a5landscape";
282 else if (((strcmp($pageheight,
"11in") == 0)) && ((strcmp($pagewidth,
"8.5in") == 0)))
284 $pagesize =
"letter";
286 else if (((strcmp($pagewidth,
"11in") == 0)) && ((strcmp($pageheight,
"8.5in") == 0)))
288 $pagesize =
"letterlandscape";
292 $pagesize =
"custom";
294 if (!strlen($xslfo)) $pagesize = $certificatesettings->get(
"pageformat");;
297 if (preg_match(
"/padding-top\=\"([^\"]+)\"/", $xslfo, $matches))
299 $paddingtop = $matches[1];
301 $marginbody_top =
"0cm";
302 $marginbody_right =
"2cm";
303 $marginbody_bottom =
"0cm";
304 $marginbody_left =
"2cm";
305 if(preg_match(
"/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
308 $marginbody = $matches[1];
309 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
311 $marginbody_top = $matches[1][0];
312 $marginbody_right = $matches[1][1];
313 $marginbody_bottom = $matches[1][2];
314 $marginbody_left = $matches[1][3];
317 else if(preg_match(
"/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
319 $marginbody = $matches[1];
320 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
322 $marginbody_top = $matches[1][0];
323 $marginbody_right = $matches[1][1];
324 $marginbody_bottom = $matches[1][2];
325 $marginbody_left = $matches[1][3];
329 $xsl = file_get_contents(
"./Services/Certificate/xml/fo2xhtml.xsl");
330 if ((strlen($xslfo)) && (strlen($xsl)))
332 $args = array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
334 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, NULL);
339 $output = preg_replace(
"/<\?xml[^>]+?>/",
"", $output);
342 $output = str_replace(
" ",
"<br />", $output);
343 $output = str_replace(
" ",
"<br />", $output);
344 $form_fields = array(
345 "pageformat" => $pagesize,
346 "pagewidth" => $pagewidth,
347 "pageheight" => $pageheight,
348 "padding_top" => $paddingtop,
349 "margin_body_top" => $marginbody_top,
350 "margin_body_right" => $marginbody_right,
351 "margin_body_bottom" => $marginbody_bottom,
352 "margin_body_left" => $marginbody_left,
353 "certificate_text" => $output
355 $this->
getAdapter()->addFormFieldsFromObject($form_fields);
367 $content =
"<html><body>".$form_data[
"certificate_text"].
"</body></html>";
368 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
369 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
372 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
373 $content = str_replace(
" ",
" ", $content);
374 $content = preg_replace(
"//",
"", $content);
376 include_once
"./Services/Certificate/classes/class.ilXmlChecker.php";
378 $check->setXMLContent($content);
379 $check->startParsing();
380 if ($check->hasError())
382 throw new Exception($this->lng->txt(
"certificate_not_well_formed"));
385 $xsl = file_get_contents(
"./Services/Certificate/xml/xhtml2fo.xsl");
389 'font-family="Helvetica, unifont"',
390 'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
394 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
396 if (strcmp($form_data[
"pageformat"],
"custom") == 0)
398 $pageheight = $form_data[
"pageheight"];
399 $pagewidth = $form_data[
"pagewidth"];
404 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
405 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
407 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
410 "pageheight" => $pageheight,
411 "pagewidth" => $pagewidth,
412 "backgroundimage" => $backgroundimage,
413 "marginbody" => $form_data[
"margin_body_top"] .
" " . $form_data[
"margin_body_right"] .
" " . $form_data[
"margin_body_bottom"] .
" " . $form_data[
"margin_body_left"],
414 "paddingtop" => $form_data[
"padding_top"]
416 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, $params);
431 if (count($insert_tags) == 0)
433 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPreview();
435 foreach (self::getCustomCertificateFields() as $k => $f)
437 $insert_tags[$f[
"ph"]] = $f[
"name"];
440 foreach ($insert_tags as $var => $value)
442 $certificate_text = str_replace($var, $value, $certificate_text);
444 return $certificate_text;
456 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPresentation($params);
458 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
460 $cust_data = $cust_data->getAll();
461 foreach (self::getCustomCertificateFields() as $k => $f)
463 $insert_tags[$f[
"ph"]] = $cust_data[
"f_".$k];
466 $xslfo = file_get_contents($this->
getXSLPath());
468 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
475 include_once
"./Services/Utilities/classes/class.ilUtil.php";
476 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename($params),
"application/pdf");
480 return $pdf_base64->scalar;
485 $ilLog->write(__METHOD__.
': '.$e->getMessage());
490 $ilLog->write(__METHOD__.
': '.$e->getMessage());
522 $xslfo = file_get_contents($this->
getXSLPath());
524 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
529 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(),
"application/pdf");
534 $ilLog->write(__METHOD__.
': '.$e->getMessage());
539 $ilLog->write(__METHOD__.
': '.$e->getMessage());
562 if (!file_exists($this->
getAdapter()->getCertificatePath()))
584 if (!empty($image_tempfilename))
586 $image_filename =
"background_upload";
588 $imagepath = $this->
getAdapter()->getCertificatePath();
589 if (!file_exists($imagepath))
644 $obj_id = $this->
getAdapter()->getCertificateID();
645 if($obj_id && !self::isObjectActive($obj_id))
649 if (file_exists($this->
getAdapter()->getCertificatePath()))
672 $obj_id =
$adapter->getCertificateID();
673 if($obj_id && !self::isObjectActive($obj_id))
678 $certificatepath =
$adapter->getCertificatePath();
679 if (file_exists($certificatepath))
682 if (file_exists($xslpath) && (filesize($xslpath) > 0))
701 "name" => $this->lng->txt(
"certificate_a4"),
706 "a4landscape" => array(
707 "name" => $this->lng->txt(
"certificate_a4_landscape"),
708 "value" =>
"a4landscape",
713 "name" => $this->lng->txt(
"certificate_a5"),
718 "a5landscape" => array(
719 "name" => $this->lng->txt(
"certificate_a5_landscape"),
720 "value" =>
"a5landscape",
725 "name" => $this->lng->txt(
"certificate_letter"),
730 "letterlandscape" => array(
731 "name" => $this->lng->txt(
"certificate_letter_landscape"),
732 "value" =>
"letterlandscape",
737 "name" => $this->lng->txt(
"certificate_custom"),
750 include_once
"./Services/Utilities/classes/class.ilUtil.php";
753 $xsl = file_get_contents($this->
getXSLPath());
754 $xslexport = str_replace($this->
getAdapter()->getCertificatePath(),
"", $xsl);
764 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
770 $zipfile = time() .
"__" . IL_INST_ID .
"__" . $this->
getAdapter()->getAdapterType() .
"__" . $this->
getAdapter()->getCertificateId() .
"__certificate.zip";
783 include_once
"./Services/Utilities/classes/class.ilUtil.php";
791 $subdir = str_replace(
".zip",
"", strtolower(
$filename)) .
"/";
793 if (is_dir($importpath . $subdir))
796 $copydir = $importpath . $subdir;
801 $copydir = $importpath;
805 foreach ($dirinfo as
$file)
807 if (strcmp(
$file[
"type"],
"file") == 0)
809 if (strpos(
$file[
"entry"],
".xml") !== FALSE)
813 else if (strpos(
$file[
"entry"],
".zip") !== FALSE)
825 foreach ($dirinfo as
$file)
827 if (strcmp(
$file[
"type"],
"file") == 0)
829 if (strpos(
$file[
"entry"],
".xml") !== FALSE)
831 $xsl = file_get_contents($copydir .
$file[
"entry"]);
834 $xsl = preg_replace(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
"url(" . $this->
getAdapter()->getCertificatePath() .
"\${1})", $xsl);
837 else if (strpos(
$file[
"entry"],
".zip") !== FALSE)
_isComplete($adapter)
Checks the status of the certificate.
getBackgroundImageTempfilePath()
Returns the filesystem path of the background image temp file during upload.
deliverExportFileXML()
Builds an export file in ZIP format and delivers it.
getBackgroundImageThumbPath()
Returns the filesystem path of the background image thumbnail.
deleteBackgroundImage()
Deletes the background image of a certificate.
processXHTML2FO($form_data, $for_export=FALSE)
Convert the certificate text to XSL-FO using XSL transformation.
getBackgroundImagePath()
Returns the filesystem path of the background image.
getBackgroundImageThumbPathWeb()
Returns the web path of the background image thumbnail.
uploadBackgroundImage($image_tempfilename)
Uploads a background image for the certificate.
exchangeCertificateVariables($certificate_text, $insert_tags=array())
Exchanges the variables in the certificate text with given values.
getPageFormats()
Retrieves predefined page formats.
__construct($adapter)
ilCertificate constructor
importCertificate($zipfile, $filename)
Reads an import ZIP file and creates a certificate of it.
getBackgroundImagePathWeb()
Returns the web path of the background image.
cloneCertificate(ilCertificate $newObject)
Clone the certificate for another test object.
isComplete()
Checks the status of the certificate.
getXSLName()
Returns the filename of the XSL-FO file.
setAdapter($adapter)
Sets the adapter.
getBackgroundImageName()
Returns the filename of the background image.
deleteCertificate()
Deletes the certificate and all it's data.
hasBackgroundImage()
Checks for the background image of the certificate.
static _getXSLName()
Returns the filename of the XSL-FO file.
getFormFieldsFromFO()
Convert the XSL-FO to the certificate text and the form settings using XSL transformation.
createPreview()
Creates a PDF preview of the XSL-FO certificate.
outCertificate($params, $deliver=TRUE)
Creates a PDF certificate.
getXSLPath()
Returns the filesystem path of the XSL-FO file.
getAdapter()
Gets the adapter.
saveCertificate($xslfo, $filename="")
Saves the XSL-FO code to a file.
static setUseRelativeDates($a_status)
set use relative dates
static hasBackgroundImage()
Returns wheather or not a default background image exists.
static getBackgroundImageName()
Returns the filename of the background image.
static getBackgroundImagePath()
Returns the filesystem path of the background image.
static factory($a_package)
Create an XML_RPC2 client instance.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static deliverData($a_data, $a_filename, $mime="application/octet-stream", $charset="")
deliver data for download via browser.
static zip($a_dir, $a_file, $compress_content=false)
static getDir($a_dir, $a_rec=false, $a_sub_dir="")
get directory
static convertImage($a_from, $a_to, $a_target_format="", $a_geometry="", $a_background_color="")
convert image
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static removeTrailingPathSeparators($path)
static deliverFile($a_file, $a_filename, $a_mime='', $isInline=false, $removeAfterDelivery=false, $a_exit_after=true)
deliver file for download via browser.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
redirection script todo: (a better solution should control the processing via a xml file)
const ILIAS_ABSOLUTE_PATH