ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilXlsFoParser Class Reference
+ Collaboration diagram for ilXlsFoParser:

Public Member Functions

 __construct (private readonly ilSetting $settings, private readonly ilPageFormats $pageFormats, ?ilXMLChecker $xmlChecker=null, ?ilCertificateUtilHelper $utilHelper=null, ?ilCertificateXlstProcess $xlstProcess=null, ?ilLanguage $language=null, ?ilCertificateXlsFileLoader $certificateXlsFileLoader=null)
 
 parse (array $formData)
 

Private Member Functions

 formatNumberString (string $a_number)
 

Private Attributes

readonly ilXMLChecker $xmlChecker
 
readonly ilCertificateUtilHelper $utilHelper
 
readonly ilCertificateXlstProcess $xlstProcess
 
readonly ilLanguage $language
 
readonly ilCertificateXlsFileLoader $certificateXlsFileLoader
 

Detailed Description

Definition at line 21 of file class.ilXlsFoParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilXlsFoParser::__construct ( private readonly ilSetting  $settings,
private readonly ilPageFormats  $pageFormats,
?ilXMLChecker  $xmlChecker = null,
?ilCertificateUtilHelper  $utilHelper = null,
?ilCertificateXlstProcess  $xlstProcess = null,
?ilLanguage  $language = null,
?ilCertificateXlsFileLoader  $certificateXlsFileLoader = null 
)

Definition at line 29 of file class.ilXlsFoParser.php.

37 {
38 if (null === $xmlChecker) {
39 $xmlChecker = new ilXMLChecker(new ILIAS\Data\Factory());
40 }
41 $this->xmlChecker = $xmlChecker;
42
43 if (null === $utilHelper) {
45 }
46 $this->utilHelper = $utilHelper;
47
48 if (null === $xlstProcess) {
50 }
51 $this->xlstProcess = $xlstProcess;
52
53 if (null === $language) {
54 global $DIC;
55 $language = $DIC->language();
56 }
57 $this->language = $language;
58
59 if (null === $certificateXlsFileLoader) {
61 }
62 $this->certificateXlsFileLoader = $certificateXlsFileLoader;
63 }
Just a wrapper class to create Unit Test for other classes.
readonly ilCertificateXlsFileLoader $certificateXlsFileLoader
readonly ilXMLChecker $xmlChecker
readonly ilCertificateXlstProcess $xlstProcess
readonly ilLanguage $language
readonly ilCertificateUtilHelper $utilHelper
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26

References $certificateXlsFileLoader, $DIC, $language, $utilHelper, $xlstProcess, $xmlChecker, and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

Member Function Documentation

◆ formatNumberString()

ilXlsFoParser::formatNumberString ( string  $a_number)
private

Definition at line 124 of file class.ilXlsFoParser.php.

124 : string
125 {
126 return str_replace(',', '.', $a_number);
127 }

Referenced by parse().

+ Here is the caller graph for this function:

◆ parse()

ilXlsFoParser::parse ( array  $formData)
Parameters
array{"certificate_text"string, "pageformat": string, "pagewidth"?: string, "pageheight"?: string, "margin_body": array{"top": string, "right": string, "bottom": string, "left": string}} $formData

Definition at line 68 of file class.ilXlsFoParser.php.

68 : string
69 {
70 $content = "<html><body>" . $formData['certificate_text'] . "</body></html>";
71 $content = preg_replace("/<p>(&nbsp;){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("&nbsp;", "&#160;", $content);
75 $content = str_replace('<br>', '<br/>', $content);
76 $content = preg_replace("//", "", $content);
77
78 $this->xmlChecker->parse($content);
79 if ($this->xmlChecker->result()->isError()) {
80 throw new Exception($this->language->txt("certificate_not_well_formed"));
81 }
82
83 $xsl = $this->certificateXlsFileLoader->getXlsCertificateContent();
84
85 // additional font support
86 $xsl = str_replace(
87 'font-family="Helvetica, unifont"',
88 'font-family="' . $this->settings->get('rpc_pdf_font', 'Helvetica, unifont') . '"',
89 $xsl
90 );
91
92 $args = [
93 '/_xml' => $content,
94 '/_xsl' => $xsl
95 ];
96
97 if (strcmp($formData['pageformat'], 'custom') === 0) {
98 $pageheight = $formData['pageheight'] ?? '';
99 $pagewidth = $formData['pagewidth'] ?? '';
100 } else {
101 $pageformats = $this->pageFormats->fetchPageFormats();
102 $pageheight = $pageformats[$formData['pageformat']]['height'];
103 $pagewidth = $pageformats[$formData['pageformat']]['width'];
104 }
105
106 $params = [
107 'pageheight' => $this->formatNumberString($this->utilHelper->stripSlashes($pageheight)),
108 'pagewidth' => $this->formatNumberString($this->utilHelper->stripSlashes($pagewidth)),
109 'backgroundimage' => '[BACKGROUND_IMAGE]',
110 'marginbody' => implode(
111 ' ',
112 [
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']))
117 ]
118 )
119 ];
120
121 return $this->xlstProcess->process($args, $params);
122 }
formatNumberString(string $a_number)
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $params, formatNumberString(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\settings().

+ Here is the call graph for this function:

Field Documentation

◆ $certificateXlsFileLoader

readonly ilCertificateXlsFileLoader ilXlsFoParser::$certificateXlsFileLoader
private

Definition at line 27 of file class.ilXlsFoParser.php.

Referenced by __construct().

◆ $language

readonly ilLanguage ilXlsFoParser::$language
private

Definition at line 26 of file class.ilXlsFoParser.php.

Referenced by __construct().

◆ $utilHelper

readonly ilCertificateUtilHelper ilXlsFoParser::$utilHelper
private

Definition at line 24 of file class.ilXlsFoParser.php.

Referenced by __construct().

◆ $xlstProcess

readonly ilCertificateXlstProcess ilXlsFoParser::$xlstProcess
private

Definition at line 25 of file class.ilXlsFoParser.php.

Referenced by __construct().

◆ $xmlChecker

readonly ilXMLChecker ilXlsFoParser::$xmlChecker
private

Definition at line 23 of file class.ilXlsFoParser.php.

Referenced by __construct().


The documentation for this class was generated from the following file: