ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilKprimChoiceWizardInputGUI Class Reference
+ Inheritance diagram for ilKprimChoiceWizardInputGUI:
+ Collaboration diagram for ilKprimChoiceWizardInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 
 setFiles ($files)
 
 getFiles ()
 
 setIgnoreMissingUploadsEnabled ($ignoreMissingUploadsEnabled)
 
 isIgnoreMissingUploadsEnabled ()
 
 setValue ($value)
 
 checkInput ()
 
 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 ()
 
 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)
 
- 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
 getTableFilterLabelFor ()
 Get label "for" attribute value. 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
 
GlyphFactory $glyph_factory
 
Renderer $renderer
 
UploadLimitResolver $upload_limit
 
- 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
 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

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ilFormPropertyGUI\$lng, $tpl, ILIAS\MetaData\Repository\Validation\Data\__construct(), and ILIAS\Repository\lng().

44  {
45  parent::__construct($a_title, $a_postvar);
46 
47  global $DIC;
48  $lng = $DIC['lng'];
49  $tpl = $DIC['tpl'];
50 
51  $this->lng = $lng;
52  $this->tpl = $tpl;
53 
54  $this->files = [];
55 
56  $this->ignoreMissingUploadsEnabled = false;
57  }
global $DIC
Definition: feed.php:28
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilKprimChoiceWizardInputGUI::checkInput ( )

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

References $DIC, ilFormPropertyGUI\$lng, ilTextInputGUI\$suffix, $tpl, ilTextInputGUI\$value, ilObjAdvancedEditing\_getUsedHTMLTagsAsString(), ilSubEnabledFormPropertyGUI\checkSubItemsInput(), checkUploads(), ilSingleChoiceWizardInputGUI\getAllowMove(), ilFormPropertyGUI\getDisabled(), ilFileUtils\getFileSizeInfo(), ilTextInputGUI\getMaxLength(), ilFormPropertyGUI\getPostVar(), ilSingleChoiceWizardInputGUI\getSingleline(), ilTextInputGUI\getSize(), ilSingleChoiceWizardInputGUI\getSuffixes(), ilSingleChoiceWizardInputGUI\insert(), ILIAS\Repository\lng(), ilTemplate\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilFormPropertyGUI\setAlert(), ilTemplate\setCurrentBlock(), HTML_Template_IT\setVariable(), ilArrayUtil\stripSlashesRecursive(), and ilLanguage\txt().

111  : bool
112  {
113  global $DIC;
114  $lng = $DIC['lng'];
115 
116  if (is_array($_POST[$this->getPostVar()])) {
117  $foundvalues = ilArrayUtil::stripSlashesRecursive(
118  $_POST[$this->getPostVar()],
119  false,
121  );
122  } else {
123  $foundvalues = $_POST[$this->getPostVar()];
124  }
125 
126  if (is_array($foundvalues)) {
127  // check answers
128  if (is_array($foundvalues['answer'])) {
129  foreach ($foundvalues['answer'] as $aidx => $answervalue) {
130  $hasImage = isset($foundvalues['imagename']) ? true : false;
131  if (((strlen($answervalue)) == 0) && !$hasImage) {
132  $this->setAlert($lng->txt("msg_input_is_required"));
133  return false;
134  }
135 
136  if (mb_strlen($answervalue) > $this->getMaxLength()) {
137  $this->setAlert($lng->txt("msg_input_char_limit_max"));
138  return false;
139  }
140  }
141  }
142 
143  // check correctness
144  if (!isset($foundvalues['correctness']) || count($foundvalues['correctness']) < count($foundvalues['answer'])) {
145  $this->setAlert($lng->txt("msg_input_is_required"));
146  return false;
147  }
148 
149  if (!$this->checkUploads($foundvalues)) {
150  return false;
151  }
152  } else {
153  $this->setAlert($lng->txt("msg_input_is_required"));
154  return false;
155  }
156 
157  return $this->checkSubItemsInput();
158  }
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...
global $DIC
Definition: feed.php:28
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
+ Here is the call graph for this function:

◆ checkUploads()

ilKprimChoiceWizardInputGUI::checkUploads (   $foundvalues)

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

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

Referenced by checkInput().

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

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

Referenced by setValue().

469  : array
470  {
471  if (!is_array($answer_text)) {
472  return [];
473  }
474 
475  if ($is_rte) {
477  $answer_text,
478  false,
480  );
481  }
482 
484  $answer_text,
485  true,
487  );
488  }
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
static _getUsedHTMLTagsAsString(string $a_module="")
Returns a string of all allowed HTML tags for text editing.
const ALLOWED_PLAIN_TEXT_TAGS
sk - 12.05.2023: This const is also used in ilKprimChoiceWizardInputGUI.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ collectValidFiles()

ilKprimChoiceWizardInputGUI::collectValidFiles ( )

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

References ilFormPropertyGUI\getPostVar().

448  : void
449  {
450  foreach ($_FILES[$this->getPostVar()]['error']['image'] as $index => $err) {
451  if ($err > 0) {
452  continue;
453  }
454 
455  $this->files[$index] = array(
456  'position' => $index,
457  'tmp_name' => $_FILES[$this->getPostVar()]['tmp_name']['image'][$index],
458  'name' => $_FILES[$this->getPostVar()]['name']['image'][$index],
459  'type' => $_FILES[$this->getPostVar()]['type']['image'][$index],
460  'size' => $_FILES[$this->getPostVar()]['size']['image'][$index]
461  );
462  }
463  }
+ Here is the call graph for this function:

◆ getFiles()

ilKprimChoiceWizardInputGUI::getFiles ( )

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

References $files.

64  : array
65  {
66  return $this->files;
67  }

◆ isIgnoreMissingUploadsEnabled()

ilKprimChoiceWizardInputGUI::isIgnoreMissingUploadsEnabled ( )

Definition at line 74 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 59 of file class.ilKprimChoiceWizardInputGUI.php.

References $files.

59  : void
60  {
61  $this->files = $files;
62  }

◆ setIgnoreMissingUploadsEnabled()

ilKprimChoiceWizardInputGUI::setIgnoreMissingUploadsEnabled (   $ignoreMissingUploadsEnabled)

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

References $ignoreMissingUploadsEnabled.

69  : void
70  {
71  $this->ignoreMissingUploadsEnabled = $ignoreMissingUploadsEnabled;
72  }

◆ setValue()

ilKprimChoiceWizardInputGUI::setValue (   $value)

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

References ilTextInputGUI\$value, and cleanupAnswerText().

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

Field Documentation

◆ $files

ilKprimChoiceWizardInputGUI::$files
private

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

Referenced by getFiles(), and setFiles().

◆ $ignoreMissingUploadsEnabled

ilKprimChoiceWizardInputGUI::$ignoreMissingUploadsEnabled
private

◆ $qstObject

ilKprimChoiceWizardInputGUI::$qstObject
protected

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

◆ $tpl

ilKprimChoiceWizardInputGUI::$tpl
protected

◆ CUSTOM_UPLOAD_ERR

const ilKprimChoiceWizardInputGUI::CUSTOM_UPLOAD_ERR = 99

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


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