ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilFileWizardInputGUI Class Reference

This class represents a file wizard property in a property form. More...

+ Inheritance diagram for ilFileWizardInputGUI:
+ Collaboration diagram for ilFileWizardInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setImagePathWeb (string $a_path)
 
 getImagePathWeb ()
 
 setFilenames (array $a_filenames)
 
 getFilenames ()
 
 setAllowMove (bool $a_allow_move)
 
 getAllowMove ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (ilTemplate $a_tpl)
 
- Public Member Functions inherited from ilFileInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setValueByArray (array $a_values)
 
 setValue (string $a_value)
 Set Value. More...
 
 getValue ()
 
 setSize (int $a_size)
 
 getSize ()
 
 setFilename (string $a_val)
 
 getFilename ()
 
 setSuffixes (array $a_suffixes)
 
 getSuffixes ()
 
 setForbiddenSuffixes (array $a_suffixes)
 
 getForbiddenSuffixes ()
 
 setPending (string $a_val)
 
 getPending ()
 
 enableFileNameSelection (string $a_post_var)
 
 isFileNameSelectionEnabled ()
 
 getFileNamePostVar ()
 
 setAllowDeletion (bool $a_val)
 
 getALlowDeletion ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 render (string $a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getDeletionFlag ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
ILIAS UI Factory $ui_factory
 
ILIAS UI Renderer $ui_renderer
 
array $filenames = array()
 
bool $allowMove = false
 
string $imagepath_web = ""
 
- Protected Attributes inherited from ilFileInputGUI
int $size = 40
 
string $pending = ""
 
bool $allow_deletion = false
 
bool $filename_selection = false
 
array $forbidden_suffixes = []
 
array $suffixes = []
 
string $value = ""
 
FileUpload $upload_service
 
UploadLimitResolver $upload_limit
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes (ilTemplate $a_tpl, string $a_block="allowed_suffixes")
 
 getMaxFileSizeString ()
 
 getMaxFileUploads ()
 Get number of maximum file uploads as declared in php.ini. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 symbol ()
 
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Detailed Description

This class represents a file wizard property in a property form.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Deprecated:
12 This component will be removed with ILIAS 12

Definition at line 30 of file class.ilFileWizardInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileWizardInputGUI::__construct ( string  $a_title = "",
string  $a_postvar = "" 
)

Reimplemented from ilFileInputGUI.

Definition at line 39 of file class.ilFileWizardInputGUI.php.

42 {
43 global $DIC;
44
45 $this->lng = $DIC->language();
46 $this->lng->loadLanguageModule("form");
47 $this->tpl = $DIC["tpl"];
48 $this->ui_factory = $DIC->ui()->factory();
49 $this->ui_renderer = $DIC->ui()->renderer();
50 parent::__construct($a_title, $a_postvar);
51 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilFileWizardInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFileInputGUI.

Definition at line 84 of file class.ilFileWizardInputGUI.php.

84 : bool
85 {
87
88 // see ilFileInputGUI
89 // if no information is received, something went wrong
90 // this is e.g. the case, if the post_max_size has been exceeded
91 if (!isset($_FILES[$this->getPostVar()]) || !is_array($_FILES[$this->getPostVar()])) {
92 $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
93 return false;
94 }
95
96 $pictures = $_FILES[$this->getPostVar()];
97 $uploadcheck = true;
98 if (is_array($pictures)) {
99 foreach ($pictures['name'] as $index => $name) {
100 // remove trailing '/'
101 $name = rtrim($name, '/');
102
103 $filename = $name;
104 $filename_arr = pathinfo($name);
105 $suffix = $filename_arr["extension"] ?? "";
106 $temp_name = $pictures["tmp_name"][$index];
107 $error = $pictures["error"][$index];
108
109 $_FILES[$this->getPostVar()]["name"][$index] = Util::sanitizeFileName($_FILES[$this->getPostVar()]["name"][$index]);
110
111
112 // error handling
113 if ($error > 0) {
114 switch ($error) {
115 case UPLOAD_ERR_FORM_SIZE:
116 case UPLOAD_ERR_INI_SIZE:
117 $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
118 $uploadcheck = false;
119 break;
120
121 case UPLOAD_ERR_PARTIAL:
122 $this->setAlert($lng->txt("form_msg_file_partially_uploaded"));
123 $uploadcheck = false;
124 break;
125
126 case UPLOAD_ERR_NO_FILE:
127 if ($this->getRequired()) {
128 $filename = $this->filenames[$index];
129 if (!strlen($filename)) {
130 $this->setAlert($lng->txt("form_msg_file_no_upload"));
131 $uploadcheck = false;
132 }
133 }
134 break;
135
136 case UPLOAD_ERR_NO_TMP_DIR:
137 $this->setAlert($lng->txt("form_msg_file_missing_tmp_dir"));
138 $uploadcheck = false;
139 break;
140
141 case UPLOAD_ERR_CANT_WRITE:
142 $this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk"));
143 $uploadcheck = false;
144 break;
145
146 case UPLOAD_ERR_EXTENSION:
147 $this->setAlert($lng->txt("form_msg_file_upload_stopped_ext"));
148 $uploadcheck = false;
149 break;
150 }
151 }
152
153 // check suffixes
154 if ($pictures["tmp_name"][$index] != "" && is_array($this->getSuffixes()) && count($this->getSuffixes()) > 0) {
155 if (!in_array(strtolower($suffix), $this->getSuffixes())) {
156 $this->setAlert($lng->txt("form_msg_file_wrong_file_type"));
157 $uploadcheck = false;
158 }
159 }
160
161 // virus handling
162 if ($pictures["tmp_name"][$index] != "") {
163 $vir = ilVirusScanner::virusHandling($temp_name, $filename);
164 if ($vir[0] == false) {
165 $this->setAlert($lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1]);
166 $uploadcheck = false;
167 }
168 }
169 }
170 }
171
172 if (!$uploadcheck) {
173 return false;
174 }
175
176 return $this->checkSubItemsInput();
177 }
txt(string|LanguageIdentifier $a_topic, ?int $n=null)
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)

References ilFileInputGUI\$filename, ilFormPropertyGUI\$lng, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFileInputGUI\getSuffixes(), ilFormPropertyGUI\setAlert(), ilLanguage\txt(), and ilVirusScanner\virusHandling().

+ Here is the call graph for this function:

◆ getAllowMove()

ilFileWizardInputGUI::getAllowMove ( )

Definition at line 78 of file class.ilFileWizardInputGUI.php.

78 : bool
79 {
80 return $this->allowMove;
81 }

References $allowMove.

Referenced by insert().

+ Here is the caller graph for this function:

◆ getFilenames()

ilFileWizardInputGUI::getFilenames ( )

Definition at line 68 of file class.ilFileWizardInputGUI.php.

68 : array
69 {
70 return $this->filenames;
71 }

References $filenames.

◆ getImagePathWeb()

ilFileWizardInputGUI::getImagePathWeb ( )

Definition at line 58 of file class.ilFileWizardInputGUI.php.

58 : string
59 {
61 }

References $imagepath_web.

Referenced by insert().

+ Here is the caller graph for this function:

◆ insert()

ilFileWizardInputGUI::insert ( ilTemplate  $a_tpl)

Reimplemented from ilFileInputGUI.

Definition at line 179 of file class.ilFileWizardInputGUI.php.

179 : void
180 {
182
183 $tpl = new ilTemplate("tpl.prop_filewizardinput.html", true, true, "components/ILIAS/Form");
184
185 $i = 0;
186 foreach ($this->filenames as $value) {
187 if (strlen($value)) {
188 $tpl->setCurrentBlock("image");
190 "SRC_IMAGE",
192 $value
193 )
194 );
196 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
199 }
200 if ($this->getAllowMove()) {
201 $tpl->setCurrentBlock("move");
202 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
203 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
204 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
206 "UP_BUTTON",
207 $this->ui_renderer->render(
208 $this->ui_factory->symbol()->glyph()->up()
209 )
210 );
212 "DOWN_BUTTON",
213 $this->ui_renderer->render(
214 $this->ui_factory->symbol()->glyph()->down()
215 )
216 );
218 }
219
220 $this->outputSuffixes($tpl, "allowed_image_suffixes");
221
222 $tpl->setCurrentBlock("row");
223 $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
224 $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
225 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
226 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
227 $tpl->setVariable("ALT_ADD", $lng->txt("add"));
228 $tpl->setVariable("ALT_REMOVE", $lng->txt("remove"));
229 if ($this->getDisabled()) {
231 "DISABLED",
232 " disabled=\"disabled\""
233 );
234 }
235
237 "ADD_BUTTON",
238 $this->ui_renderer->render(
239 $this->ui_factory->symbol()->glyph()->add()
240 )
241 );
243 "REMOVE_BUTTON",
244 $this->ui_renderer->render(
245 $this->ui_factory->symbol()->glyph()->remove()
246 )
247 );
248 $tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString());
249 $tpl->setVariable("MAX_UPLOAD_VALUE", $this->getMaxFileUploads());
250 $tpl->setVariable("TXT_MAX_UPLOADS", $lng->txt("form_msg_max_upload") . " " . $this->getMaxFileUploads());
252 $i++;
253 }
254 $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
255
256 $a_tpl->setCurrentBlock("prop_generic");
257 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
258 $a_tpl->parseCurrentBlock();
259
260 $main_tpl = $this->tpl;
261 $main_tpl->addJavascript("assets/js/ServiceFormWizardInput.js");
262 $main_tpl->addJavascript("assets/js/filewizard.js");
263 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
getMaxFileUploads()
Get number of maximum file uploads as declared in php.ini.
outputSuffixes(ilTemplate $a_tpl, string $a_block="allowed_suffixes")
ilGlobalTemplateInterface $tpl
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

References ilFormPropertyGUI\$lng, $tpl, ilFileInputGUI\$value, ILIAS\UICore\GlobalTemplate\get(), getAllowMove(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getImagePathWeb(), ilFileInputGUI\getMaxFileUploads(), ilFormPropertyGUI\getPostVar(), ilFileInputGUI\outputSuffixes(), ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilTemplate\setCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), ILIAS\UICore\GlobalTemplate\setVariable(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ setAllowMove()

ilFileWizardInputGUI::setAllowMove ( bool  $a_allow_move)

Definition at line 73 of file class.ilFileWizardInputGUI.php.

73 : void
74 {
75 $this->allowMove = $a_allow_move;
76 }

◆ setFilenames()

ilFileWizardInputGUI::setFilenames ( array  $a_filenames)

Definition at line 63 of file class.ilFileWizardInputGUI.php.

63 : void
64 {
65 $this->filenames = $a_filenames;
66 }

◆ setImagePathWeb()

ilFileWizardInputGUI::setImagePathWeb ( string  $a_path)

Definition at line 53 of file class.ilFileWizardInputGUI.php.

53 : void
54 {
55 $this->imagepath_web = $a_path;
56 }

Field Documentation

◆ $allowMove

bool ilFileWizardInputGUI::$allowMove = false
protected

Definition at line 36 of file class.ilFileWizardInputGUI.php.

Referenced by getAllowMove().

◆ $filenames

array ilFileWizardInputGUI::$filenames = array()
protected

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

Referenced by getFilenames().

◆ $imagepath_web

string ilFileWizardInputGUI::$imagepath_web = ""
protected

Definition at line 37 of file class.ilFileWizardInputGUI.php.

Referenced by getImagePathWeb().

◆ $tpl

ilGlobalTemplateInterface ilFileWizardInputGUI::$tpl
protected

Definition at line 32 of file class.ilFileWizardInputGUI.php.

Referenced by insert().

◆ $ui_factory

ILIAS UI Factory ilFileWizardInputGUI::$ui_factory
protected

Definition at line 33 of file class.ilFileWizardInputGUI.php.

◆ $ui_renderer

ILIAS UI Renderer ilFileWizardInputGUI::$ui_renderer
protected

Definition at line 34 of file class.ilFileWizardInputGUI.php.


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