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

Public Member Functions

 __construct (\ILIAS\Refinery\Factory $refinery, \ILIAS\HTTP\GlobalHttpState $http)
 
 securedString (string $parameter, bool $cast_null_to_string=true)
 
 isNotValidSize (array $sizes)
 
 isNotValidText (array $texts)
 
 validatePathOrUrl (array $parameters)
 
 int (string $parameter, bool $cast_null_to_int=true)
 
 bool (string $parameter, bool $cast_null_to_false=true)
 
 float (string $parameter, bool $cast_null_to_zero=true)
 

Protected Member Functions

 isPathOrUrlValid (string $url)
 

Private Attributes

ILIAS Refinery Factory $refinery
 
ILIAS HTTP GlobalHttpState $http
 

Detailed Description

Deprecated:

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

Constructor & Destructor Documentation

◆ __construct()

ilPDFGenerationRequest::__construct ( \ILIAS\Refinery\Factory  $refinery,
\ILIAS\HTTP\GlobalHttpState  $http 
)

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

30 {
31 $this->refinery = $refinery;
32 $this->http = $http;
33 }
ILIAS HTTP GlobalHttpState $http
static http()
Fetches the global http state from ILIAS.

References $http, $refinery, ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Member Function Documentation

◆ bool()

ilPDFGenerationRequest::bool ( string  $parameter,
bool  $cast_null_to_false = true 
)

Definition at line 184 of file class.ilPDFGenerationRequest.php.

184 : bool
185 {
186 $null_to_false = $this->refinery->custom()->transformation(static function ($value): bool {
187 if ($value === null) {
188 return false;
189 }
190
191 throw new ilException('Expected null in transformation');
192 });
193
194 $as_bool = $cast_null_to_false ?
195 $this->refinery->byTrying([$this->refinery->kindlyTo()->bool(), $null_to_false]) :
196 $this->refinery->kindlyTo()->bool();
197
198 $bool = false;
199 if ($this->http->wrapper()->post()->has($parameter)) {
200 $bool = $this->http->wrapper()->post()->retrieve(
201 $parameter,
202 $as_bool
203 );
204 } elseif ($this->http->wrapper()->query()->has($parameter)) {
205 $bool = $this->http->wrapper()->query()->retrieve(
206 $parameter,
207 $as_bool
208 );
209 }
210
211 return $bool;
212 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ float()

ilPDFGenerationRequest::float ( string  $parameter,
bool  $cast_null_to_zero = true 
)

Definition at line 214 of file class.ilPDFGenerationRequest.php.

214 : float
215 {
216 $null_to_zero = $this->refinery->custom()->transformation(static function ($value): float {
217 if ($value === null) {
218 return 0.0;
219 }
220
221 throw new ilException('Expected null in transformation');
222 });
223
224 $as_float = $cast_null_to_zero ?
225 $this->refinery->byTrying([$this->refinery->kindlyTo()->float(), $null_to_zero]) :
226 $this->refinery->kindlyTo()->float();
227
228 $float = 0.0;
229 if ($this->http->wrapper()->post()->has($parameter)) {
230 $float = $this->http->wrapper()->post()->retrieve(
231 $parameter,
232 $as_float
233 );
234 } elseif ($this->http->wrapper()->query()->has($parameter)) {
235 $float = $this->http->wrapper()->query()->retrieve(
236 $parameter,
237 $as_float
238 );
239 }
240
241 return $float;
242 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ int()

ilPDFGenerationRequest::int ( string  $parameter,
bool  $cast_null_to_int = true 
)

Definition at line 154 of file class.ilPDFGenerationRequest.php.

154 : int
155 {
156 $null_to_zero = $this->refinery->custom()->transformation(static function ($value): int {
157 if ($value === null) {
158 return 0;
159 }
160
161 throw new ilException('Expected null in transformation');
162 });
163
164 $as_int = $cast_null_to_int ?
165 $this->refinery->byTrying([$this->refinery->kindlyTo()->int(), $null_to_zero]) :
166 $this->refinery->kindlyTo()->int();
167
168 $int = 0;
169 if ($this->http->wrapper()->post()->has($parameter)) {
170 $int = $this->http->wrapper()->post()->retrieve(
171 $parameter,
172 $as_int
173 );
174 } elseif ($this->http->wrapper()->query()->has($parameter)) {
175 $int = $this->http->wrapper()->query()->retrieve(
176 $parameter,
177 $as_int
178 );
179 }
180
181 return $int;
182 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ isNotValidSize()

ilPDFGenerationRequest::isNotValidSize ( array  $sizes)

Definition at line 104 of file class.ilPDFGenerationRequest.php.

104 : bool
105 {
106 foreach ($sizes as $size) {
107 if (is_int($size)) {
108 continue;
109 }
110 if (!preg_match('/(\d)+?(\W)*(cm|mm)$/', $size)) {
111 if ($size !== 0 && $size !== "0" && $size !== null && $size !== "") {
112 return true;
113 }
114 }
115 }
116
117 return false;
118 }

◆ isNotValidText()

ilPDFGenerationRequest::isNotValidText ( array  $texts)

Definition at line 120 of file class.ilPDFGenerationRequest.php.

120 : bool
121 {
122 foreach ($texts as $text) {
123 if (!preg_match('/[a-zA-Z\d ]+$/', $text)) {
124 if ($text !== '' && $text !== null) {
125 return true;
126 }
127 }
128 }
129
130 return false;
131 }

◆ isPathOrUrlValid()

ilPDFGenerationRequest::isPathOrUrlValid ( string  $url)
protected

Definition at line 72 of file class.ilPDFGenerationRequest.php.

72 : bool
73 {
74 $is_valid = false;
75 $is_url = filter_var($url, FILTER_VALIDATE_URL);
76
77 if ($is_url) {
78 try {
80 $c->init();
81 $c->setOpt(CURLOPT_CUSTOMREQUEST, 'HEAD');
82 $c->setOpt(CURLOPT_SSL_VERIFYPEER, 0);
83 $c->setOpt(CURLOPT_SSL_VERIFYHOST, 0);
84 $c->setOpt(CURLOPT_RETURNTRANSFER, 1);
85 $c->setOpt(CURLOPT_FOLLOWLOCATION, 0);
86 $c->setOpt(CURLOPT_MAXREDIRS, 0);
87 $c->setOpt(CURLOPT_URL, $url);
88 $c->setOpt(CURLOPT_HEADER, true);
89 $c->setOpt(CURLOPT_NOBODY, true);
90
91 $result = $c->exec();
92 $is_valid = $c->getInfo(CURLINFO_HTTP_CODE) === 200;
93
95 return false;
96 }
97 } elseif (is_file($url)) {
98 $is_valid = true;
99 }
100
101 return $is_valid;
102 }
$c
Definition: cli.php:38
$url

References $c, Vendor\Package\$e, and $url.

Referenced by validatePathOrUrl().

+ Here is the caller graph for this function:

◆ securedString()

ilPDFGenerationRequest::securedString ( string  $parameter,
bool  $cast_null_to_string = true 
)

Definition at line 35 of file class.ilPDFGenerationRequest.php.

35 : string
36 {
37 $as_sanizited_string = $this->refinery->custom()->transformation(static function (string $value): string {
38 return ilUtil::stripSlashes($value);
39 });
40
41 $null_to_empty_string = $this->refinery->custom()->transformation(static function ($value): string {
42 if ($value === null) {
43 return '';
44 }
45
46 throw new ilException('Expected null in transformation');
47 });
48
49 $sanizite_as_string = $this->refinery->in()->series([
50 $cast_null_to_string ?
51 $this->refinery->byTrying([$this->refinery->kindlyTo()->string(), $null_to_empty_string]) :
52 $this->refinery->kindlyTo()->string(),
53 $as_sanizited_string
54 ]);
55
56 $string = '';
57 if ($this->http->wrapper()->post()->has($parameter)) {
58 $string = $this->http->wrapper()->post()->retrieve(
59 $parameter,
60 $sanizite_as_string
61 );
62 } elseif ($this->http->wrapper()->query()->has($parameter)) {
63 $string = $this->http->wrapper()->query()->retrieve(
64 $parameter,
65 $sanizite_as_string
66 );
67 }
68
69 return $string;
70 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ILIAS\FileDelivery\http(), ILIAS\Repository\refinery(), and ilUtil\stripSlashes().

Referenced by validatePathOrUrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ validatePathOrUrl()

ilPDFGenerationRequest::validatePathOrUrl ( array  $parameters)
Parameters
array$parameters
Returns
bool

Definition at line 137 of file class.ilPDFGenerationRequest.php.

137 : bool
138 {
139 $valid = false;
140 foreach ($parameters as $parameter) {
141 $value = $this->securedString($parameter);
142 if ($value === '') {
143 $valid = true;
144 } else {
145 $valid = $this->isPathOrUrlValid($value);
146 }
147 if ($valid === false) {
148 return false;
149 }
150 }
151 return true;
152 }
securedString(string $parameter, bool $cast_null_to_string=true)
$valid

References $valid, isPathOrUrlValid(), and securedString().

+ Here is the call graph for this function:

Field Documentation

◆ $http

ILIAS HTTP GlobalHttpState ilPDFGenerationRequest::$http
private

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

Referenced by __construct().

◆ $refinery

ILIAS Refinery Factory ilPDFGenerationRequest::$refinery
private

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

Referenced by __construct().


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