ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilIdentifiedMultiFilesJsPositionIndexRemover.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected $postVar = null;
27
28 public function getPostVar()
29 {
30 return $this->postVar;
31 }
32
33 public function setPostVar($postVar): void
34 {
35 $this->postVar = $postVar;
36 }
37
38 public function manipulateFormInputValues(array $inputValues): array
39 {
40 // KEEP THIS INTERFACE METHOD OVERWRITTEN THIS LIKE (!)
41 return $inputValues;
42 }
43
44 public function manipulateFormSubmitValues(array $values): array
45 {
46 if ($this->isFileSubmitAvailable()) {
47 $this->prepareFileSubmit();
48 }
49
50 return $values;
51 }
52
53 protected function isFileSubmitAvailable(): bool
54 {
55 if (!isset($_FILES[$this->getPostVar()])) {
56 return false;
57 }
58
59 if (!is_array($_FILES[$this->getPostVar()])) {
60 return false;
61 }
62
63 if (!in_array('tmp_name', array_keys($_FILES[$this->getPostVar()]))) {
64 return false;
65 }
66
67 return true;
68 }
69
70 #[AllowSuperglobalWrite('normalises the shape of $_FILES[postVar], because the inherited getInput() reads it back from there.', 12)]
71 protected function prepareFileSubmit(): void
72 {
73 $_FILES[$this->getPostVar()] = $this->prepareMultiFilesSubmitValues(
74 $_FILES[$this->getPostVar()]
75 );
76 }
77
78 protected function prepareMultiFilesSubmitValues($filesSubmitValues): array
79 {
80 return $this->removePositionIndexLevels($filesSubmitValues);
81 }
82}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...