ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilIdentifiedMultiFilesJsPositionIndexRemover.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/classes/class.ilIdentifiedMultiValuesJsPositionIndexRemover.php';
5
13{
14 protected $postVar = null;
15
16 public function getPostVar()
17 {
18 return $this->postVar;
19 }
20
21 public function setPostVar($postVar)
22 {
23 $this->postVar = $postVar;
24 }
25
26 public function manipulateFormInputValues($inputValues)
27 {
28 // KEEP THIS INTERFACE METHOD OVERWRITTEN THIS LIKE (!)
29 return $inputValues;
30 }
31
32 public function manipulateFormSubmitValues($values)
33 {
34 if( $this->isFileSubmitAvailable() )
35 {
36 $this->prepareFileSubmit();
37 }
38
39 return $values;
40 }
41
42 protected function isFileSubmitAvailable()
43 {
44 if( !isset($_FILES[$this->getPostVar()]) )
45 {
46 return false;
47 }
48
49 if( !is_array($_FILES[$this->getPostVar()]) )
50 {
51 return false;
52 }
53
54 if( !in_array('tmp_name', array_keys($_FILES[$this->getPostVar()])) )
55 {
56 return false;
57 }
58
59 return true;
60 }
61
62 protected function prepareFileSubmit()
63 {
64 $_FILES[$this->getPostVar()] = $this->prepareMultiFilesSubmitValues(
65 $_FILES[$this->getPostVar()]
66 );
67 }
68
69 protected function prepareMultiFilesSubmitValues($filesSubmitValues)
70 {
71 return $this->removePositionIndexLevels($filesSubmitValues);
72 }
73}
An exception for terminatinating execution or to throw for unit testing.