ILIAS  release_8 Revision v8.24
ilImageWizardInputGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilImageWizardInputGUI:
+ Collaboration diagram for ilImageWizardInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValue ($a_value)
 
 setSuffixes ($a_suffixes)
 Set Accepted Suffixes. More...
 
 getSuffixes ()
 Get Accepted Suffixes. More...
 
 setValues ($a_values)
 Set Values. More...
 
 getValues ()
 Get Values. More...
 
 setQuestionObject ($a_value)
 Set question object. More...
 
 getQuestionObject ()
 Get question object. More...
 
 setAllowMove ($a_allow_move)
 Set allow move. More...
 
 getAllowMove ()
 Get allow move. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (ilTemplate $a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilTextInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setValue ($a_value)
 
 getValue ()
 
 setValidationFailureMessage (string $a_msg)
 
 getValidationFailureMessage ()
 
 setValidationRegexp (string $a_value)
 
 getValidationRegexp ()
 
 setMaxLength (?int $a_maxlength)
 
 getMaxLength ()
 
 setSize (int $a_size)
 
 setInlineStyle (string $a_style)
 
 getInlineStyle ()
 
 setCssClass (string $a_class)
 
 getCssClass ()
 
 setValueByArray (array $a_values)
 
 getSize ()
 
 setSuffix (string $a_value)
 
 getSuffix ()
 
 setInputType (string $a_type)
 set input type More...
 
 getInputType ()
 
 setSubmitFormOnEnter (bool $a_val)
 
 getSubmitFormOnEnter ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 getDataSource ()
 
 setDataSource (string $href, string $a_delimiter=null)
 
 setDataSourceSubmitOnSelection (bool $a_stat)
 
 getDataSourceSubmitOnSelection ()
 
 setDataSourceSubmitUrl (string $a_url)
 
 getDataSourceSubmitUrl ()
 
 setMultiValues (array $a_values)
 
 render (string $a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
 setDisableHtmlAutoComplete (bool $autocomplete)
 
 isHtmlAutoCompleteDisabled ()
 
 getPostValueForComparison ()
 
- 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...
 
- Public Member Functions inherited from ilTableFilterItem
 getTableFilterHTML ()
 Get input item HTML to be inserted into table filters. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Attributes

 $values = array()
 
 $allowMove = false
 
 $qstObject = null
 
 $suffixes = array()
 
- Protected Attributes inherited from ilTextInputGUI
 $value = null
 
int $maxlength = 200
 
int $size = 40
 
string $validationRegexp = ""
 
string $validationFailureMessage = ''
 
string $suffix = ""
 
string $style_css = ""
 
string $css_class = ""
 
string $ajax_datasource = ""
 
string $ajax_datasource_delimiter = null
 
bool $ajax_datasource_commit = false
 
string $ajax_datasource_commit_url = ""
 
bool $submit_form_on_enter = false
 
bool $autocomplete_disabled = false
 
string $input_type = ""
 
- 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 ilFormPropertyGUI
 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 file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning This class represents a single choice wizard property in a property form.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de
Version
$Id$

Definition at line 26 of file class.ilImageWizardInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilImageWizardInputGUI::__construct (   $a_title = "",
  $a_postvar = "" 
)

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

40 {
41 parent::__construct($a_title, $a_postvar);
43 $this->setSize('25');
44 $this->validationRegexp = "";
45 }
static getAllowedImageMaterialFileExtensions()
setSuffixes($a_suffixes)
Set Accepted Suffixes.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), assQuestion\getAllowedImageMaterialFileExtensions(), ilTextInputGUI\setSize(), and setSuffixes().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilImageWizardInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilTextInputGUI.

Definition at line 143 of file class.ilImageWizardInputGUI.php.

143 : bool
144 {
145 global $DIC;
146 $lng = $DIC['lng'];
147
148 if (is_array($_POST[$this->getPostVar()])) {
149 $_POST[$this->getPostVar()] = ilArrayUtil::stripSlashesRecursive($_POST[$this->getPostVar()]);
150 }
151 if (is_array($_FILES[$this->getPostVar()]['error']['image'])) {
152 foreach ($_FILES[$this->getPostVar()]['error']['image'] as $index => $error) {
153 // error handling
154 if ($error > 0) {
155 switch ($error) {
156 case UPLOAD_ERR_FORM_SIZE:
157 case UPLOAD_ERR_INI_SIZE:
158 $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
159 return false;
160 break;
161
162 case UPLOAD_ERR_PARTIAL:
163 $this->setAlert($lng->txt("form_msg_file_partially_uploaded"));
164 return false;
165 break;
166
167 case UPLOAD_ERR_NO_FILE:
168 if ($this->getRequired()) {
169 if (!strlen($_POST[$this->getPostVar()]['imagename'][$index])) {
170 $this->setAlert($lng->txt("form_msg_file_no_upload"));
171 return false;
172 }
173 }
174 break;
175
176 case UPLOAD_ERR_NO_TMP_DIR:
177 $this->setAlert($lng->txt("form_msg_file_missing_tmp_dir"));
178 return false;
179 break;
180
181 case UPLOAD_ERR_CANT_WRITE:
182 $this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk"));
183 return false;
184 break;
185
186 case UPLOAD_ERR_EXTENSION:
187 $this->setAlert($lng->txt("form_msg_file_upload_stopped_ext"));
188 return false;
189 break;
190 }
191 }
192 }
193 } else {
194 if ($this->getRequired()) {
195 $this->setAlert($lng->txt("form_msg_file_no_upload"));
196 return false;
197 }
198 }
199
200 if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) {
201 foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) {
202 $filename = $_FILES[$this->getPostVar()]['name']['image'][$index];
203 $filename_arr = pathinfo($filename);
204 $suffix = $filename_arr["extension"];
205 $mimetype = $_FILES[$this->getPostVar()]['type']['image'][$index];
206 $size_bytes = $_FILES[$this->getPostVar()]['size']['image'][$index];
207 // check suffixes
208 if (strlen($tmpname) && is_array($this->getSuffixes())) {
209 if (!in_array(strtolower($suffix), $this->getSuffixes())) {
210 $this->setAlert($lng->txt("form_msg_file_wrong_file_type"));
211 return false;
212 }
213 }
214 }
215 }
216
217 if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) {
218 foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) {
219 $filename = $_FILES[$this->getPostVar()]['name']['image'][$index];
220 $filename_arr = pathinfo($filename);
221 $suffix = $filename_arr["extension"];
222 $mimetype = $_FILES[$this->getPostVar()]['type']['image'][$index];
223 $size_bytes = $_FILES[$this->getPostVar()]['size']['image'][$index];
224 // virus handling
225 if (strlen($tmpname)) {
227 if ($vir[0] == false) {
228 $this->setAlert($lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1]);
229 return false;
230 }
231 }
232 }
233 }
234
235 return $this->checkSubItemsInput();
236 }
$filename
Definition: buildRTE.php:78
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
getSuffixes()
Get Accepted Suffixes.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
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)
global $DIC
Definition: feed.php:28
$index
Definition: metadata.php:145

References $DIC, $filename, $index, ilFormPropertyGUI\$lng, ilTextInputGUI\$suffix, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), getSuffixes(), ilFormPropertyGUI\setAlert(), ilArrayUtil\stripSlashesRecursive(), ilLanguage\txt(), and ilVirusScanner\virusHandling().

+ Here is the call graph for this function:

◆ getAllowMove()

ilImageWizardInputGUI::getAllowMove ( )

Get allow move.

Returns
boolean Allow move

Definition at line 134 of file class.ilImageWizardInputGUI.php.

134 : bool
135 {
136 return $this->allowMove;
137 }

References $allowMove.

Referenced by insert().

+ Here is the caller graph for this function:

◆ getQuestionObject()

ilImageWizardInputGUI::getQuestionObject ( )

Get question object.

Returns
object Value

Definition at line 114 of file class.ilImageWizardInputGUI.php.

114 : ?object
115 {
116 return $this->qstObject;
117 }

References $qstObject.

◆ getSuffixes()

ilImageWizardInputGUI::getSuffixes ( )

Get Accepted Suffixes.

Returns
array Accepted Suffixes

Definition at line 74 of file class.ilImageWizardInputGUI.php.

74 : array
75 {
76 return $this->suffixes;
77 }

References $suffixes.

Referenced by checkInput(), and insert().

+ Here is the caller graph for this function:

◆ getValues()

ilImageWizardInputGUI::getValues ( )

Get Values.

Returns
array Values

Definition at line 94 of file class.ilImageWizardInputGUI.php.

94 : array
95 {
96 return $this->values;
97 }

References $values.

◆ insert()

ilImageWizardInputGUI::insert ( ilTemplate  $a_tpl)

Insert property html.

Returns
void Size

Reimplemented from ilTextInputGUI.

Definition at line 242 of file class.ilImageWizardInputGUI.php.

242 : void
243 {
244 global $DIC;
245 $lng = $DIC['lng'];
246
247 $tpl = new ilTemplate("tpl.prop_imagewizardinput.html", true, true, "Modules/TestQuestionPool");
248 $i = 0;
249 foreach ($this->values as $value) {
250 if (strlen($value)) {
251 $imagename = $this->qstObject->getImagePathWeb() . $value;
252 if ($this->qstObject->getThumbSize()) {
253 if (@file_exists($this->qstObject->getImagePath() . $this->qstObject->getThumbPrefix() . $value)) {
254 $imagename = $this->qstObject->getImagePathWeb() . $this->qstObject->getThumbPrefix() . $value;
255 }
256 }
257 $tpl->setCurrentBlock('image');
258 $tpl->setVariable('SRC_IMAGE', $imagename);
259 $tpl->setVariable('IMAGE_NAME', $value);
260 $tpl->setVariable('ALT_IMAGE', ilLegacyFormElementsUtil::prepareFormOutput($value));
261 $tpl->setVariable("TXT_DELETE_EXISTING", $lng->txt("delete_existing_file"));
262 $tpl->setVariable("IMAGE_ROW_NUMBER", $i);
263 $tpl->setVariable("IMAGE_POST_VAR", $this->getPostVar());
264 $tpl->parseCurrentBlock();
265 }
266 $tpl->setCurrentBlock('addimage');
267 $tpl->setVariable("IMAGE_BROWSE", $lng->txt('select_file'));
268 $tpl->setVariable("IMAGE_ID", $this->getPostVar() . "[image][$i]");
269 $tpl->setVariable("IMAGE_SUBMIT", $lng->txt("upload"));
270 $tpl->setVariable("IMAGE_ROW_NUMBER", $i);
271 $tpl->setVariable("IMAGE_POST_VAR", $this->getPostVar());
272 $tpl->parseCurrentBlock();
273
274 if ($this->getAllowMove()) {
275 $tpl->setCurrentBlock("move");
276 $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
277 $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
278 $tpl->setVariable("ID", $this->getPostVar() . "[$i]");
279 $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
280 $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
281 $tpl->parseCurrentBlock();
282 }
283 $tpl->setCurrentBlock("row");
284 $tpl->setVariable("POST_VAR", $this->getPostVar());
285 $tpl->setVariable("ROW_NUMBER", $i);
286 $tpl->setVariable("ID", $this->getPostVar() . "[answer][$i]");
287 $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
288 $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
289 $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
290 $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
291 $tpl->parseCurrentBlock();
292 $i++;
293 }
294
295 if (is_array($this->getSuffixes())) {
296 $suff_str = $delim = "";
297 foreach ($this->getSuffixes() as $suffix) {
298 $suff_str .= $delim . "." . $suffix;
299 $delim = ", ";
300 }
301 $tpl->setCurrentBlock('allowed_image_suffixes');
302 $tpl->setVariable("TXT_ALLOWED_SUFFIXES", $lng->txt("file_allowed_suffixes") . " " . $suff_str);
303 $tpl->parseCurrentBlock();
304 }
305 /*
306 $tpl->setCurrentBlock("image_heading");
307 $tpl->setVariable("ANSWER_IMAGE", $lng->txt('answer_image'));
308 $tpl->parseCurrentBlock();
309 */
310
311 $tpl->setVariable("TXT_MAX_SIZE", ilFileUtils::getFileSizeInfo());
312 $tpl->setVariable("ELEMENT_ID", $this->getPostVar());
313 $tpl->setVariable("TEXT_YES", $lng->txt('yes'));
314 $tpl->setVariable("TEXT_NO", $lng->txt('no'));
315 $tpl->setVariable("DELETE_IMAGE_HEADER", $lng->txt('delete_image_header'));
316 $tpl->setVariable("DELETE_IMAGE_QUESTION", $lng->txt('delete_image_question'));
317 $tpl->setVariable("ANSWER_TEXT", $lng->txt('answer_text'));
318 $tpl->setVariable("COMMANDS_TEXT", $lng->txt('actions'));
319
320 $a_tpl->setCurrentBlock("prop_generic");
321 $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
322 $a_tpl->parseCurrentBlock();
323
324 global $DIC;
325 $tpl = $DIC['tpl'];
326 $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
327 $tpl->addJavascript("./Modules/TestQuestionPool/templates/default/imagewizard.js");
328 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
static getFileSizeInfo()
static get(string $a_glyph, string $a_text="")
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)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$i
Definition: metadata.php:41

References $DIC, $i, ilFormPropertyGUI\$lng, ilTextInputGUI\$suffix, $tpl, ilTextInputGUI\$value, ilGlyphGUI\ADD, ilGlyphGUI\DOWN, ilGlyphGUI\get(), getAllowMove(), ilFormPropertyGUI\getFieldId(), ilFileUtils\getFileSizeInfo(), ilFormPropertyGUI\getPostVar(), getSuffixes(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilGlyphGUI\REMOVE, ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), ilLanguage\txt(), and ilGlyphGUI\UP.

+ Here is the call graph for this function:

◆ setAllowMove()

ilImageWizardInputGUI::setAllowMove (   $a_allow_move)

Set allow move.

Parameters
boolean$a_allow_moveAllow move

Definition at line 124 of file class.ilImageWizardInputGUI.php.

124 : void
125 {
126 $this->allowMove = $a_allow_move;
127 }

◆ setQuestionObject()

ilImageWizardInputGUI::setQuestionObject (   $a_value)

Set question object.

Parameters
object$a_valuetest object

Definition at line 104 of file class.ilImageWizardInputGUI.php.

104 : void
105 {
106 $this->qstObject = &$a_value;
107 }

◆ setSuffixes()

ilImageWizardInputGUI::setSuffixes (   $a_suffixes)

Set Accepted Suffixes.

Parameters
array$a_suffixesAccepted Suffixes

Definition at line 64 of file class.ilImageWizardInputGUI.php.

64 : void
65 {
66 $this->suffixes = $a_suffixes;
67 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ setValue()

ilImageWizardInputGUI::setValue (   $a_value)
Parameters
string | array$a_value

Reimplemented from ilTextInputGUI.

Definition at line 47 of file class.ilImageWizardInputGUI.php.

47 : void
48 {
49 $this->values = array();
50 if (is_array($a_value)) {
51 if (is_array($a_value['count'])) {
52 foreach ($a_value['count'] as $index => $value) {
53 array_push($this->values, $a_value['imagename'][$index]);
54 }
55 }
56 }
57 }

References $index, and ilTextInputGUI\$value.

◆ setValues()

ilImageWizardInputGUI::setValues (   $a_values)

Set Values.

Parameters
array$a_valueValue

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

84 : void
85 {
86 $this->values = $a_values;
87 }

Field Documentation

◆ $allowMove

ilImageWizardInputGUI::$allowMove = false
protected

Definition at line 29 of file class.ilImageWizardInputGUI.php.

Referenced by getAllowMove().

◆ $qstObject

ilImageWizardInputGUI::$qstObject = null
protected

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

Referenced by getQuestionObject().

◆ $suffixes

ilImageWizardInputGUI::$suffixes = array()
protected

Definition at line 31 of file class.ilImageWizardInputGUI.php.

Referenced by getSuffixes().

◆ $values

ilImageWizardInputGUI::$values = array()
protected

Definition at line 28 of file class.ilImageWizardInputGUI.php.

Referenced by getValues().


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