ILIAS  release_8 Revision v8.24
ilFormFieldParser Class Reference
+ Collaboration diagram for ilFormFieldParser:

Public Member Functions

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

Private Attributes

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.

29 {
30 if (null === $xlstProcess) {
32 }
33 $this->xlstProcess = $xlstProcess;
34 }
ilCertificateXlstProcess $xlstProcess

References $xlstProcess.

Member Function Documentation

◆ fetchDefaultFormFields()

ilFormFieldParser::fetchDefaultFormFields ( string  $content)

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

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

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

Field Documentation

◆ $xlstProcess

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: