21use GuzzleHttp\Psr7\UploadedFile;
29use Psr\Http\Message\ServerRequestInterface;
45 return $this->
http->request();
55 if ($this->
upload->hasUploads()) {
56 if (!$this->
upload->hasBeenProcessed()) {
59 $uploads = $this->
upload->getResults();
70 public function getUploadFilename(array $http_names,
int $index): ?
string
72 $uploaded_files = $this->
http->request()->getUploadedFiles();
74 while (($current_key = array_shift($http_names)) !==
null) {
75 if (!
isset($uploaded_files[$current_key])) {
79 $uploaded_files = $uploaded_files[$current_key];
81 if (
isset($uploaded_files[$index]) && $http_names === []) {
83 $file = $uploaded_files[$index];
84 $c = \Closure::bind(
static function (UploadedFile $file): ?
string {
85 return $file->file ??
null;
102 return $this->
raw($key) !==
null;
107 return $this->
raw(
'ref_id') !==
null;
112 return $this->
int(
'ref_id');
117 return $this->
raw(
'q_id') !==
null;
122 return $this->
int(
'q_id');
136 public function raw(
string $key): mixed
138 return $this->
get($key, $this->
refinery->identity());
144 return $this->
get($key, $this->
refinery->kindlyTo()->float()) ?? 0.0;
152 return $this->
get($key, $this->
refinery->kindlyTo()->string()) ??
'';
157 return $this->
get($key, $this->
refinery->kindlyTo()->bool());
162 return $this->
http->request()->getParsedBody();
178 return $this->
intArray(
'category_ids');
183 if (!$this->
http->wrapper()->post()->has(
'matching')) {
187 return $this->
http->wrapper()->post()->retrieve(
190 $this->refinery->container()->mapValues(
191 $this->refinery->custom()->transformation(
192 fn(
string $v): array => $this->
refinery->container()->mapValues(
193 $this->refinery->kindlyTo()->int()
194 )->transform(json_decode($v))
204 return $this->
http->wrapper()->post()->keys();
210 if (!
isset($cmd[$key]) || !is_array($cmd[$key])) {
213 return key($cmd[$key]);
219 public function strArray(
string $key,
int $depth = 1): array
250 return $this->
get($key, $this->
refinery->byTrying([
252 $this->refinery->kindlyTo()->string(),
253 $this->refinery->custom()->transformation(fn(array $v):
string|
int => $v[0])
262 $query = $this->
http->wrapper()->query();
264 if (!$query->has($key)) {
268 return $query->retrieve(
270 $this->
refinery->custom()->transformation(
271 static fn(array|
string $value): array|
string => $value ===
'ALL_OBJECTS' || $value[0] ===
'ALL_OBJECTS'
273 : array_map(
'intval', $value)
280 $chain = $this->
refinery->kindlyTo()->dictOf($transformation);
281 for ($i = 1; $i < $depth; $i++) {
282 $chain = $this->
refinery->kindlyTo()->dictOf($chain);
trait BaseGUIRequest
Base gui request wrapper.
retrieveArray(string $key, int $depth, Transformation $transformation)
getMultiSelectionIds(string $key)
__construct(Services $http, Factory $refinery, protected readonly FileUpload $upload)
strArray(string $key, int $depth=1)
getRowIdParameter(string $key)
static http()
Fetches the global http state from ILIAS.
initRequest(HTTP\Services $http, Refinery\Factory $refinery, ?array $passed_query_params=null, ?array $passed_post_data=null)
Query params and post data parameters are used for testing.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...