95 return "background.jpg";
115 return $this->
getAdapter()->getCertificatePath() .
"background_upload.tmp";
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();
208 $new_xsl = $newObject->getXSLPath();
209 $new_bgimage = $newObject->getBackgroundImagePath();
210 $new_bgimagethumb = $newObject->getBackgroundImageThumbPath();
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);
224 $newObject->writeActive(
true);
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");;
296 $marginbody_top =
"0cm";
297 $marginbody_right =
"2cm";
298 $marginbody_bottom =
"0cm";
299 $marginbody_left =
"2cm";
300 if(preg_match(
"/fo:flow[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
303 $marginbody = $matches[1];
304 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
306 $marginbody_top = $matches[1][0];
307 $marginbody_right = $matches[1][1];
308 $marginbody_bottom = $matches[1][2];
309 $marginbody_left = $matches[1][3];
312 else if(preg_match(
"/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $xslfo, $matches))
314 $marginbody = $matches[1];
315 if (preg_match_all(
"/([^\s]+)/", $marginbody, $matches))
317 $marginbody_top = $matches[1][0];
318 $marginbody_right = $matches[1][1];
319 $marginbody_bottom = $matches[1][2];
320 $marginbody_left = $matches[1][3];
324 $xsl = file_get_contents(
"./Services/Certificate/xml/fo2xhtml.xsl");
325 if ((strlen($xslfo)) && (strlen($xsl)))
327 $args = array(
'/_xml' => $xslfo,
'/_xsl' => $xsl );
329 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args, NULL);
334 $output = preg_replace(
"/<\?xml[^>]+?>/",
"", $output);
337 $output = str_replace(
" ",
"<br />", $output);
338 $output = str_replace(
" ",
"<br />", $output);
339 $form_fields = array(
340 "pageformat" => $pagesize,
341 "pagewidth" => $pagewidth,
342 "pageheight" => $pageheight,
343 "margin_body_top" => $marginbody_top,
344 "margin_body_right" => $marginbody_right,
345 "margin_body_bottom" => $marginbody_bottom,
346 "margin_body_left" => $marginbody_left,
347 "certificate_text" => $output
349 $this->
getAdapter()->addFormFieldsFromObject($form_fields);
361 $content =
"<html><body>".$form_data[
"certificate_text"].
"</body></html>";
362 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
363 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
366 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
367 $content = str_replace(
" ",
" ", $content);
368 $content = preg_replace(
"//",
"", $content);
370 include_once
"./Services/Certificate/classes/class.ilXmlChecker.php";
372 $check->setXMLContent($content);
373 $check->startParsing();
374 if ($check->hasError())
376 throw new Exception($this->lng->txt(
"certificate_not_well_formed"));
379 $xsl = file_get_contents(
"./Services/Certificate/xml/xhtml2fo.xsl");
383 'font-family="Helvetica, unifont"',
384 'font-family="'.
$GLOBALS[
'ilSetting']->
get(
'rpc_pdf_font',
'Helvetica, unifont').
'"',
388 $args = array(
'/_xml' => $content,
'/_xsl' => $xsl );
390 if (strcmp($form_data[
"pageformat"],
"custom") == 0)
392 $pageheight = $form_data[
"pageheight"];
393 $pagewidth = $form_data[
"pagewidth"];
398 $pageheight = $pageformats[$form_data[
"pageformat"]][
"height"];
399 $pagewidth = $pageformats[$form_data[
"pageformat"]][
"width"];
401 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
404 "pageheight" => $pageheight,
405 "pagewidth" => $pagewidth,
406 "backgroundimage" => $backgroundimage,
407 "marginbody" => $form_data[
"margin_body_top"] .
" " . $form_data[
"margin_body_right"] .
" " . $form_data[
"margin_body_bottom"] .
" " . $form_data[
"margin_body_left"]
409 $output = xslt_process($xh,
"arg:/_xml",
"arg:/_xsl", NULL, $args,
$params);
424 if (count($insert_tags) == 0)
426 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPreview();
428 foreach (self::getCustomCertificateFields() as $k => $f)
430 $insert_tags[$f[
"ph"]] = $f[
"name"];
433 foreach ($insert_tags as $var => $value)
435 $certificate_text = str_replace($var, $value, $certificate_text);
437 return $certificate_text;
449 $insert_tags = $this->
getAdapter()->getCertificateVariablesForPresentation(
$params);
451 include_once(
"./Services/User/classes/class.ilUserDefinedData.php");
453 $cust_data = $cust_data->getAll();
454 foreach (self::getCustomCertificateFields() as $k => $f)
456 $insert_tags[$f[
"ph"]] = $cust_data[
"f_".$k];
459 $xslfo = file_get_contents($this->
getXSLPath());
461 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
468 include_once
"./Services/Utilities/classes/class.ilUtil.php";
473 return $pdf_base64->scalar;
478 $ilLog->write(__METHOD__.
': '.$e->getMessage());
483 $ilLog->write(__METHOD__.
': '.$e->getMessage());
515 $xslfo = file_get_contents($this->
getXSLPath());
517 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientFactory.php';
522 ilUtil::deliverData($pdf_base64->scalar, $this->getAdapter()->getCertificateFilename(),
"application/pdf");
527 $ilLog->write(__METHOD__.
': '.$e->getMessage());
532 $ilLog->write(__METHOD__.
': '.$e->getMessage());
555 if (!file_exists($this->
getAdapter()->getCertificatePath()))
577 if (!empty($image_tempfilename))
580 $imagepath = $this->
getAdapter()->getCertificatePath();
581 if (!file_exists($imagepath))
639 $obj_id = $this->
getAdapter()->getCertificateID();
640 if($obj_id && !self::isObjectActive($obj_id))
644 if (file_exists($this->
getAdapter()->getCertificatePath()))
667 $obj_id =
$adapter->getCertificateID();
668 if($obj_id && !self::isObjectActive($obj_id))
673 $certificatepath =
$adapter->getCertificatePath();
674 if (file_exists($certificatepath))
677 if (file_exists($xslpath) && (filesize($xslpath) > 0))
696 "name" => $this->lng->txt(
"certificate_a4"),
701 "a4landscape" => array(
702 "name" => $this->lng->txt(
"certificate_a4_landscape"),
703 "value" =>
"a4landscape",
708 "name" => $this->lng->txt(
"certificate_a5"),
713 "a5landscape" => array(
714 "name" => $this->lng->txt(
"certificate_a5_landscape"),
715 "value" =>
"a5landscape",
720 "name" => $this->lng->txt(
"certificate_letter"),
725 "letterlandscape" => array(
726 "name" => $this->lng->txt(
"certificate_letter_landscape"),
727 "value" =>
"letterlandscape",
732 "name" => $this->lng->txt(
"certificate_custom"),
745 include_once
"./Services/Utilities/classes/class.ilUtil.php";
748 $xsl = file_get_contents($this->
getXSLPath());
749 $xslexport = str_replace($this->
getAdapter()->getCertificatePath(),
"", $xsl);
759 include_once
"./Services/Certificate/classes/class.ilObjCertificateSettingsAccess.php";
765 $zipfile = time() .
"__" . IL_INST_ID .
"__" . $this->
getAdapter()->getAdapterType() .
"__" . $this->
getAdapter()->getCertificateId() .
"__certificate.zip";
778 include_once
"./Services/Utilities/classes/class.ilUtil.php";
786 $subdir = str_replace(
".zip",
"", strtolower(
$filename)) .
"/";
788 if (is_dir($importpath . $subdir))
791 $copydir = $importpath . $subdir;
796 $copydir = $importpath;
800 foreach ($dirinfo as
$file)
802 if (strcmp(
$file[
"type"],
"file") == 0)
804 if (strpos(
$file[
"entry"],
".xml") !== FALSE)
808 else if (strpos(
$file[
"entry"],
".zip") !== FALSE)
820 foreach ($dirinfo as
$file)
822 if (strcmp(
$file[
"type"],
"file") == 0)
824 if (strpos(
$file[
"entry"],
".xml") !== FALSE)
826 $xsl = file_get_contents($copydir .
$file[
"entry"]);
829 $xsl = preg_replace(
"/url\([']{0,1}(.*?)[']{0,1}\)/",
"url(" . $this->
getAdapter()->getCertificatePath() .
"\${1})", $xsl);
832 else if (strpos(
$file[
"entry"],
".zip") !== FALSE)
_isComplete($adapter)
Checks the status of the certificate.
cloneCertificate($newObject)
Clone the certificate for another test object.
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.
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 ...
$GLOBALS['PHPCAS_CLIENT']
This global variable is used by the interface class phpCAS.
redirection script todo: (a better solution should control the processing via a xml file)
const ILIAS_ABSOLUTE_PATH