ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilMultipleImagesAdditionalIndexLevelRemover.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Form/interfaces/interface.ilFormValuesManipulator.php';
5
13{
14 protected $filesSubmissionProperties = array(
15 'name', 'tmp_name', 'type', 'error', 'size'
16 );
17
18 protected $postVar;
19
20 public function getPostVar()
21 {
22 return $this->postVar;
23 }
24
25 public function setPostVar($postVar)
26 {
27 $this->postVar = $postVar;
28 }
29
30 protected function getFilesSubmissionProperties()
31 {
33 }
34 public function manipulateFormInputValues($inputValues)
35 {
36 return $inputValues;
37 }
38
39 public function manipulateFormSubmitValues($submitValues)
40 {
41 $submitValues = $this->removeAdditionalSubFieldsLevelFromSubmitValues($submitValues);
42
44 $_FILES[$this->getPostVar()]
45 );
46
47 return $submitValues;
48 }
49 protected function isSubFieldAvailable($values, $subFieldName)
50 {
51 if( !is_array($values) )
52 {
53 return false;
54 }
55
56 if( !isset($values[$subFieldName]) )
57 {
58 return false;
59 }
60
61 if( !is_array($values[$subFieldName]) )
62 {
63 return false;
64 }
65
66 return true;
67 }
68
69 protected function isIteratorSubfieldAvailable($values)
70 {
72 }
73
74 protected function isUploadSubfieldAvailable($values)
75 {
77 }
78
80 {
81 if( !$this->isIteratorSubfieldAvailable($values) )
82 {
83 return $values;
84 }
85
87 $actualValues = array();
88
89 foreach($values[ilMultipleImagesInputGUI::ITERATOR_SUBFIELD_NAME] as $index => $value)
90 {
91 if( !isset($storedImages[$index]) )
92 {
93 $actualValues[$index] = '';
94 continue;
95 }
96
97 $actualValues[$index] = $storedImages[$index];
98 }
99
100 return $actualValues;
101 }
102
104 {
105 if( !$this->isUploadSubfieldAvailable($uploadProperty) )
106 {
107 return $uploadProperty;
108 }
109
110 foreach($uploadProperty as $subField => $submittedFile )
111 {
112 foreach($submittedFile as $identifier => $uploadValue)
113 {
114 $uploadProperty[$identifier] = $uploadValue;
115 }
116
117 unset($uploadProperty[$subField]);
118 }
119
120 return $uploadProperty;
121 }
122
123 protected function removeAdditionalSubFieldsLevelFromFilesSubmit($filesSubmit)
124 {
125 foreach($this->getFilesSubmissionProperties() as $uploadProperty)
126 {
127 if( !isset($filesSubmit[$uploadProperty]) )
128 {
129 continue;
130 }
131
132 $filesSubmit[$uploadProperty] = $this->removeAdditionalSubFieldsLevelFromFilesSubmitProperty(
133 $filesSubmit[$uploadProperty]
134 );
135 }
136
137 return $filesSubmit;
138 }
139}
An exception for terminatinating execution or to throw for unit testing.