ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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.

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

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  }
readonly ilCertificateXlsFileLoader $certificateXlsFileLoader
readonly ilCertificateUtilHelper $utilHelper
Class ChatMainBarProvider .
global $DIC
Definition: feed.php:28
readonly ilCertificateXlstProcess $xlstProcess
Just a wrapper class to create Unit Test for other classes.
readonly ilXMLChecker $xmlChecker
readonly ilLanguage $language
+ Here is the call graph for this function:

Member Function Documentation

◆ formatNumberString()

ilXlsFoParser::formatNumberString ( string  $a_number)
private

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

Referenced by parse().

123  : string
124  {
125  return str_replace(',', '.', $a_number);
126  }
+ 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.

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

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