19declare(strict_types=1);
59 if (
null === $certificateXlsFileLoader) {
68 public function parse(array $formData): string
70 $content =
"<html><body>" . $formData[
'certificate_text'] .
"</body></html>";
71 $content = preg_replace(
"/<p>( ){1,}<\\/p>/",
"<p></p>", $content);
72 $content = preg_replace(
"/<p>(\\s)*?<\\/p>/",
"<p></p>", $content);
73 $content = str_replace(
"<p></p>",
"<p class=\"emptyrow\"></p>", $content);
74 $content = str_replace(
" ",
" ", $content);
75 $content = str_replace(
'<br>',
'<br/>', $content);
76 $content = preg_replace(
"//",
"", $content);
78 $this->xmlChecker->parse($content);
79 if ($this->xmlChecker->result()->isError()) {
80 throw new Exception($this->
language->txt(
"certificate_not_well_formed"));
83 $xsl = $this->certificateXlsFileLoader->getXlsCertificateContent();
87 'font-family="Helvetica, unifont"',
88 'font-family="' . $this->
settings->get(
'rpc_pdf_font',
'Helvetica, unifont') .
'"',
97 if (strcmp($formData[
'pageformat'],
'custom') === 0) {
98 $pageheight = $formData[
'pageheight'] ??
'';
99 $pagewidth = $formData[
'pagewidth'] ??
'';
101 $pageformats = $this->pageFormats->fetchPageFormats();
102 $pageheight = $pageformats[$formData[
'pageformat']][
'height'];
103 $pagewidth = $pageformats[$formData[
'pageformat']][
'width'];
107 'pageheight' => $this->
formatNumberString($this->utilHelper->stripSlashes($pageheight)),
108 'pagewidth' => $this->
formatNumberString($this->utilHelper->stripSlashes($pagewidth)),
109 'backgroundimage' =>
'[BACKGROUND_IMAGE]',
110 'marginbody' => implode(
113 $this->
formatNumberString($this->utilHelper->stripSlashes($formData[
'margin_body'][
'top'])),
114 $this->formatNumberString($this->utilHelper->stripSlashes($formData[
'margin_body'][
'right'])),
115 $this->formatNumberString($this->utilHelper->stripSlashes($formData[
'margin_body'][
'bottom'])),
116 $this->formatNumberString($this->utilHelper->stripSlashes($formData[
'margin_body'][
'left']))
121 return $this->xlstProcess->process($args,
$params);
126 return str_replace(
',',
'.', $a_number);
Just a wrapper class to create Unit Test for other classes.
readonly ilCertificateXlsFileLoader $certificateXlsFileLoader
readonly ilXMLChecker $xmlChecker
readonly ilCertificateXlstProcess $xlstProcess
formatNumberString(string $a_number)
__construct(private readonly ilSetting $settings, private readonly ilPageFormats $pageFormats, ?ilXMLChecker $xmlChecker=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateXlstProcess $xlstProcess=null, ?ilLanguage $language=null, ?ilCertificateXlsFileLoader $certificateXlsFileLoader=null)
readonly ilLanguage $language
readonly ilCertificateUtilHelper $utilHelper
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.