ILIAS  release_8 Revision v8.24
ilKprimChoiceWizardInputGUI Class Reference
+ Inheritance diagram for ilKprimChoiceWizardInputGUI:
+ Collaboration diagram for ilKprimChoiceWizardInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setFiles ($files)
 
 getFiles ()
 
 setIgnoreMissingUploadsEnabled ($ignoreMissingUploadsEnabled)
 
 isIgnoreMissingUploadsEnabled ()
 
 setValue ($value)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 checkUploads ($foundvalues)
 
 collectValidFiles ()
 
- Public Member Functions inherited from ilSingleChoiceWizardInputGUI
 __construct ($a_title='', $a_postvar='')
 Constructor. More...
 
 setValue ($a_value)
 
 setValueByArray (array $a_values)
 
 setSuffixes ($a_suffixes)
 Set Accepted Suffixes. More...
 
 setHideImages ($a_hide)
 Set hide images. More...
 
 getSuffixes ()
 Get Accepted Suffixes. More...
 
 setShowPoints ($a_value)
 
 getShowPoints ()
 
 setValues ($a_values)
 Set Values. More...
 
 getValues ()
 Get Values. More...
 
 setSingleline ($a_value)
 Set singleline. More...
 
 getSingleline ()
 Get singleline. 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...
 
 setPending (string $val)
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (ilTemplate $a_tpl)
 
- 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...
 

Data Fields

const CUSTOM_UPLOAD_ERR = 99
 

Protected Attributes

 $tpl
 
 $qstObject
 
- Protected Attributes inherited from ilSingleChoiceWizardInputGUI
 $values = []
 
 $allowMove = false
 
 $singleline = true
 
 $qstObject = null
 
 $suffixes = []
 
 $showPoints = true
 
 $hideImages = false
 
ArrayBasedRequestWrapper $post_wrapper
 
- 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
 

Private Member Functions

 cleanupAnswerText (array $answer_text, bool $is_rte)
 sk - 12.05.2023: This is one more of those that we need, but don't want. More...
 

Private Attributes

 $files
 
 $ignoreMissingUploadsEnabled
 

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

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilSingleChoiceWizardInputGUI.

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

48 {
49 parent::__construct($a_title, $a_postvar);
50
51 global $DIC;
52 $lng = $DIC['lng'];
53 $tpl = $DIC['tpl'];
54
55 $this->lng = $lng;
56 $this->tpl = $tpl;
57
58 $this->files = [];
59
60 $this->ignoreMissingUploadsEnabled = false;
61 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilKprimChoiceWizardInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilSingleChoiceWizardInputGUI.

Reimplemented in ilKprimChoiceCorrectionsInputGUI.

Definition at line 115 of file class.ilKprimChoiceWizardInputGUI.php.

115 : bool
116 {
117 global $DIC;
118 $lng = $DIC['lng'];
119
120 include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
121 if (is_array($_POST[$this->getPostVar()])) {
123 $_POST[$this->getPostVar()],
124 false,
126 );
127 } else {
128 $foundvalues = $_POST[$this->getPostVar()];
129 }
130
131 if (is_array($foundvalues)) {
132 // check answers
133 if (is_array($foundvalues['answer'])) {
134 foreach ($foundvalues['answer'] as $aidx => $answervalue) {
135 $hasImage = isset($foundvalues['imagename']) ? true : false;
136 if (((strlen($answervalue)) == 0) && !$hasImage) {
137 $this->setAlert($lng->txt("msg_input_is_required"));
138 return false;
139 }
140
141 if (mb_strlen($answervalue) > $this->getMaxLength()) {
142 $this->setAlert($lng->txt("msg_input_char_limit_max"));
143 return false;
144 }
145 }
146 }
147
148 // check correctness
149 if (!isset($foundvalues['correctness']) || count($foundvalues['correctness']) < count($foundvalues['answer'])) {
150 $this->setAlert($lng->txt("msg_input_is_required"));
151 return false;
152 }
153
154 if (!$this->checkUploads($foundvalues)) {
155 return false;
156 }
157 } else {
158 $this->setAlert($lng->txt("msg_input_is_required"));
159 return false;
160 }
161
162 return $this->checkSubItemsInput();
163 }
return true
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
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 _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.

References $DIC, ilFormPropertyGUI\$lng, ilObjAdvancedEditing\_getUsedHTMLTagsAsString(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), checkUploads(), ilTextInputGUI\getMaxLength(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\setAlert(), ilArrayUtil\stripSlashesRecursive(), true, and ilLanguage\txt().

+ Here is the call graph for this function:

◆ checkUploads()

ilKprimChoiceWizardInputGUI::checkUploads (   $foundvalues)

Definition at line 337 of file class.ilKprimChoiceWizardInputGUI.php.

337 : bool
338 {
339 if (is_array($_FILES) && count($_FILES) && $this->getSingleline()) {
340 if (!$this->hideImages) {
341 if (is_array($_FILES[$this->getPostVar()]['error']['image'])) {
342 foreach ($_FILES[$this->getPostVar()]['error']['image'] as $index => $error) {
343 // error handling
344 if ($error > 0) {
345 switch ($error) {
346 case UPLOAD_ERR_FORM_SIZE:
347 case UPLOAD_ERR_INI_SIZE:
348 $this->setAlert($this->lng->txt("form_msg_file_size_exceeds"));
349 return false;
350 break;
351
352 case UPLOAD_ERR_PARTIAL:
353 $this->setAlert($this->lng->txt("form_msg_file_partially_uploaded"));
354 return false;
355 break;
356
357 case UPLOAD_ERR_NO_FILE:
358 if ($this->getRequired() && !$this->isIgnoreMissingUploadsEnabled()) {
359 $has_image = isset($foundvalues['imagename'][$index]) ? true : false;
360 if (!$has_image && (!strlen($foundvalues['answer'][$index]))) {
361 $this->setAlert($this->lng->txt("form_msg_file_no_upload"));
362 return false;
363 }
364 }
365 break;
366
367 case UPLOAD_ERR_NO_TMP_DIR:
368 $this->setAlert($this->lng->txt("form_msg_file_missing_tmp_dir"));
369 return false;
370 break;
371
372 case UPLOAD_ERR_CANT_WRITE:
373 $this->setAlert($this->lng->txt("form_msg_file_cannot_write_to_disk"));
374 return false;
375 break;
376
377 case UPLOAD_ERR_EXTENSION:
378 $this->setAlert($this->lng->txt("form_msg_file_upload_stopped_ext"));
379 return false;
380 break;
381 }
382 }
383 }
384 } else {
385 if ($this->getRequired()) {
386 $this->setAlert($this->lng->txt("form_msg_file_no_upload"));
387 return false;
388 }
389 }
390
391 if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) {
392 foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) {
393 $filename = $_FILES[$this->getPostVar()]['name']['image'][$index];
394 $filename_arr = pathinfo($filename);
395 if (isset($filename_arr["extension"])) {
396 $suffix = $filename_arr["extension"];
397 $mimetype = $_FILES[$this->getPostVar()]['type']['image'][$index];
398 $size_bytes = $_FILES[$this->getPostVar()]['size']['image'][$index];
399 // check suffixes
400 if (strlen($tmpname) && is_array($this->getSuffixes())) {
401 if (!in_array(strtolower($suffix), $this->getSuffixes())) {
402 $this->setAlert($this->lng->txt("form_msg_file_wrong_file_type"));
403 return false;
404 }
405 }
406 }
407 }
408 }
409
410 if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) {
411 foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) {
412 if ($_FILES[$this->getPostVar()]['error']['image'][$index] > 0) {
413 continue;
414 }
415
416 $mimetype = ilObjMediaObject::getMimeType($tmpname);
417
418 if (!preg_match("/^image/", $mimetype)) {
419 $_FILES[$this->getPostVar()]['error']['image'][$index] = self::CUSTOM_UPLOAD_ERR;
420 $this->setAlert($this->lng->txt("form_msg_file_wrong_mime_type"));
421 return false;
422 }
423 }
424 }
425
426
427 if (is_array($_FILES[$this->getPostVar()]['tmp_name']['image'])) {
428 foreach ($_FILES[$this->getPostVar()]['tmp_name']['image'] as $index => $tmpname) {
429 $filename = $_FILES[$this->getPostVar()]['name']['image'][$index];
430 $filename_arr = pathinfo($filename);
431 if (isset($filename_arr["extension"])) {
432 $suffix = $filename_arr["extension"];
433 $mimetype = $_FILES[$this->getPostVar()]['type']['image'][$index];
434 $size_bytes = $_FILES[$this->getPostVar()]['size']['image'][$index];
435 // virus handling
436 if (strlen($tmpname)) {
438 if ($vir[0] == false) {
439 $_FILES[$this->getPostVar()]['error']['image'][$index] = self::CUSTOM_UPLOAD_ERR;
440 $this->setAlert($this->lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1]);
441 return false;
442 }
443 }
444 }
445 }
446 }
447 }
448 }
449
450 return true;
451 }
$filename
Definition: buildRTE.php:78
static getMimeType(string $a_file, bool $a_external=false)
get mime type for file
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
$index
Definition: metadata.php:145

References $filename, $index, ilTextInputGUI\$suffix, CUSTOM_UPLOAD_ERR, ilObjMediaObject\getMimeType(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilSingleChoiceWizardInputGUI\getSingleline(), ilSingleChoiceWizardInputGUI\getSuffixes(), isIgnoreMissingUploadsEnabled(), ILIAS\Repository\lng(), ilFormPropertyGUI\setAlert(), true, and ilVirusScanner\virusHandling().

Referenced by checkInput().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanupAnswerText()

ilKprimChoiceWizardInputGUI::cleanupAnswerText ( array  $answer_text,
bool  $is_rte 
)
private

sk - 12.05.2023: This is one more of those that we need, but don't want.

Deprecated:

Definition at line 474 of file class.ilKprimChoiceWizardInputGUI.php.

474 : array
475 {
476 if (!is_array($answer_text)) {
477 return [];
478 }
479
480 if ($is_rte) {
482 $answer_text,
483 false,
485 );
486 }
487
489 $answer_text,
490 true,
492 );
493 }
const ALLOWED_PLAIN_TEXT_TAGS
sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI.

References ilObjAdvancedEditing\_getUsedHTMLTagsAsString(), assQuestionGUI\ALLOWED_PLAIN_TEXT_TAGS, and ilArrayUtil\stripSlashesRecursive().

Referenced by setValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ collectValidFiles()

ilKprimChoiceWizardInputGUI::collectValidFiles ( )

Definition at line 453 of file class.ilKprimChoiceWizardInputGUI.php.

453 : void
454 {
455 foreach ($_FILES[$this->getPostVar()]['error']['image'] as $index => $err) {
456 if ($err > 0) {
457 continue;
458 }
459
460 $this->files[$index] = array(
461 'position' => $index,
462 'tmp_name' => $_FILES[$this->getPostVar()]['tmp_name']['image'][$index],
463 'name' => $_FILES[$this->getPostVar()]['name']['image'][$index],
464 'type' => $_FILES[$this->getPostVar()]['type']['image'][$index],
465 'size' => $_FILES[$this->getPostVar()]['size']['image'][$index]
466 );
467 }
468 }

References $index, and ilFormPropertyGUI\getPostVar().

+ Here is the call graph for this function:

◆ getFiles()

ilKprimChoiceWizardInputGUI::getFiles ( )

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

References $files.

◆ isIgnoreMissingUploadsEnabled()

ilKprimChoiceWizardInputGUI::isIgnoreMissingUploadsEnabled ( )

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

References $ignoreMissingUploadsEnabled.

Referenced by checkUploads().

+ Here is the caller graph for this function:

◆ setFiles()

ilKprimChoiceWizardInputGUI::setFiles (   $files)

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

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

References $files.

◆ setIgnoreMissingUploadsEnabled()

ilKprimChoiceWizardInputGUI::setIgnoreMissingUploadsEnabled (   $ignoreMissingUploadsEnabled)

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

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

References $ignoreMissingUploadsEnabled.

◆ setValue()

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

Reimplemented from ilSingleChoiceWizardInputGUI.

Reimplemented in ilKprimChoiceCorrectionsInputGUI.

Definition at line 83 of file class.ilKprimChoiceWizardInputGUI.php.

83 : void
84 {
85 $this->values = [];
86
87 $is_rte = isset($_POST["answer_type"]) && $_POST["answer_type"] == "multiLine";
88 $a_value = $this->cleanupAnswerText($value, $is_rte);
89
90 if (is_array($a_value) && is_array($a_value['answer'])) {
91 foreach ($a_value['answer'] as $index => $value) {
92 $answer = new ilAssKprimChoiceAnswer();
93
94 $answer->setPosition($index);
95 $answer->setAnswertext($value);
96 if (isset($a_value['imagename'])) {
97 $answer->setImageFile($a_value['imagename'][$index] ?? '');
98 }
99
100 if (isset($a_value['correctness']) && isset($a_value['correctness'][$index]) && strlen($a_value['correctness'][$index])) {
101 $answer->setCorrectness((bool) $a_value['correctness'][$index]);
102 }
103
104 $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
105 $answer->setImageFsDir($this->qstObject->getImagePath());
106 $answer->setImageWebDir($this->qstObject->getImagePathWeb());
107
108 $this->values[] = $answer;
109 }
110 }
111
112 #vd($this->values);
113 }
cleanupAnswerText(array $answer_text, bool $is_rte)
sk - 12.05.2023: This is one more of those that we need, but don't want.

References $index, ilTextInputGUI\$value, and cleanupAnswerText().

+ Here is the call graph for this function:

Field Documentation

◆ $files

ilKprimChoiceWizardInputGUI::$files
private

Definition at line 43 of file class.ilKprimChoiceWizardInputGUI.php.

Referenced by getFiles(), and setFiles().

◆ $ignoreMissingUploadsEnabled

ilKprimChoiceWizardInputGUI::$ignoreMissingUploadsEnabled
private

◆ $qstObject

ilKprimChoiceWizardInputGUI::$qstObject
protected

Definition at line 41 of file class.ilKprimChoiceWizardInputGUI.php.

◆ $tpl

ilKprimChoiceWizardInputGUI::$tpl
protected

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

Referenced by __construct().

◆ CUSTOM_UPLOAD_ERR

const ilKprimChoiceWizardInputGUI::CUSTOM_UPLOAD_ERR = 99

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

Referenced by checkUploads().


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