ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilFormFieldParser Class Reference
+ Collaboration diagram for ilFormFieldParser:

Public Member Functions

 __construct (?ilCertificateXlstProcess $xlstProcess=null)
 
 fetchDefaultFormFields (string $content)
 

Private Attributes

readonly ilCertificateXlstProcess $xlstProcess
 

Detailed Description

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilFormFieldParser::__construct ( ?ilCertificateXlstProcess  $xlstProcess = null)

Definition at line 28 of file class.ilFormFieldParser.php.

References $xlstProcess, and null.

29  {
30  if (null === $xlstProcess) {
32  }
33  $this->xlstProcess = $xlstProcess;
34  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
readonly ilCertificateXlstProcess $xlstProcess

Member Function Documentation

◆ fetchDefaultFormFields()

ilFormFieldParser::fetchDefaultFormFields ( string  $content)
Returns
array{pageformat: string, pagewidth: mixed, pageheight: mixed, margin_body_top: mixed, margin_body_right: mixed, margin_body_bottom: mixed, margin_body_left: mixed, certificate_text: string}

Definition at line 39 of file class.ilFormFieldParser.php.

References ilPageFormats\DEFAULT_MARGIN_BODY_BOTTOM, ilPageFormats\DEFAULT_MARGIN_BODY_LEFT, ilPageFormats\DEFAULT_MARGIN_BODY_RIGHT, and ilPageFormats\DEFAULT_MARGIN_BODY_TOP.

39  : array
40  {
41  $pagewidth = "21cm";
42  if (preg_match("/page-width\=\"([^\"]+)\"/", $content, $matches)) {
43  $pagewidth = $matches[1];
44  }
45  $pageheight = "29.7cm";
46  if (preg_match("/page-height\=\"([^\"]+)\"/", $content, $matches)) {
47  $pageheight = $matches[1];
48  }
49 
50  $pagesize = 'custom';
51  if (((strcmp($pageheight, "29.7cm") === 0) || (strcmp($pageheight, "297mm") === 0))
52  && ((strcmp($pagewidth, "21cm") === 0) || (strcmp($pagewidth, "210mm") === 0))) {
53  $pagesize = "a4";
54  } elseif (((strcmp($pagewidth, "29.7cm") === 0) || (strcmp($pagewidth, "297mm") === 0))
55  && ((strcmp($pageheight, "21cm") === 0) || (strcmp($pageheight, "210mm") === 0))) {
56  $pagesize = "a4landscape";
57  } elseif (((strcmp($pageheight, "21cm") === 0) || (strcmp($pageheight, "210mm") === 0))
58  && ((strcmp($pagewidth, "14.8cm") === 0) || (strcmp($pagewidth, "148mm") === 0))) {
59  $pagesize = "a5";
60  } elseif (((strcmp($pagewidth, "21cm") === 0) || (strcmp($pagewidth, "210mm") === 0))
61  && ((strcmp($pageheight, "14.8cm") === 0) || (strcmp($pageheight, "148mm") === 0))) {
62  $pagesize = "a5landscape";
63  } elseif (((strcmp($pageheight, "11in") === 0))
64  && ((strcmp($pagewidth, "8.5in") === 0))) {
65  $pagesize = "letter";
66  } elseif (((strcmp($pagewidth, "11in") === 0))
67  && ((strcmp($pageheight, "8.5in") === 0))) {
68  $pagesize = "letterlandscape";
69  }
70 
72  $marginBody_right = ilPageFormats::DEFAULT_MARGIN_BODY_RIGHT;
73  $marginBody_bottom = ilPageFormats::DEFAULT_MARGIN_BODY_BOTTOM;
74  $marginBody_left = ilPageFormats::DEFAULT_MARGIN_BODY_LEFT;
75  if (preg_match("/fo:flow[^>]*margin\=\"([^\"]+)\"/", $content, $matches)) {
76  // Backwards compatibility
77  $marginbody = $matches[1];
78  if (preg_match_all("/([^\s]+)/", (string) $marginbody, $matches)) {
79  $marginBody_top = $matches[1][0];
80  $marginBody_right = $matches[1][1];
81  $marginBody_bottom = $matches[1][2];
82  $marginBody_left = $matches[1][3];
83  }
84  } elseif (preg_match("/fo:region-body[^>]*margin\=\"([^\"]+)\"/", $content, $matches)) {
85  $marginbody = $matches[1];
86  if (preg_match_all("/([^\s]+)/", (string) $marginbody, $matches)) {
87  $marginBody_top = $matches[1][0];
88  $marginBody_right = $matches[1][1];
89  $marginBody_bottom = $matches[1][2];
90  $marginBody_left = $matches[1][3];
91  }
92  }
93 
94  $xsl = file_get_contents(__DIR__ . '/../../xml/fo2xhtml.xsl');
95  if ($content !== '' && (is_string($xsl) && $xsl !== '')) {
96  $args = [
97  '/_xml' => $content,
98  '/_xsl' => $xsl
99  ];
100 
101  $content = $this->xlstProcess->process($args, []);
102  }
103 
104  $content = preg_replace("/<\?xml[^>]+?>/", "", $content);
105  // dirty hack: the php xslt processing seems not to recognize the following
106  // replacements, so we do it in the code as well
107  $content = str_replace(["&#xA0;", "&#160;"], "<br />", $content);
108 
109  return [
110  'pageformat' => $pagesize,
111  'pagewidth' => $pagewidth,
112  'pageheight' => $pageheight,
113  'margin_body_top' => $marginBody_top,
114  'margin_body_right' => $marginBody_right,
115  'margin_body_bottom' => $marginBody_bottom,
116  'margin_body_left' => $marginBody_left,
117  'certificate_text' => $content
118  ];
119  }
final const DEFAULT_MARGIN_BODY_TOP
final const DEFAULT_MARGIN_BODY_RIGHT
final const DEFAULT_MARGIN_BODY_LEFT
final const DEFAULT_MARGIN_BODY_BOTTOM

Field Documentation

◆ $xlstProcess

readonly ilCertificateXlstProcess ilFormFieldParser::$xlstProcess
private

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

Referenced by __construct().


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