ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTagInputGUI 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 ilTagInputGUI:
+ Collaboration diagram for ilTagInputGUI:

Public Member Functions

 setMaxTags ($max_tags)
 
 setMaxChars ($max_chars)
 
 setAllowDuplicates ($allow_duplicates)
 
 setJsSelfInit ($js_self_init)
 
 setTypeAheadIgnoreCase ($type_ahead_ignore_case)
 
 setTypeAheadMinLength ($min_length)
 
 setTypeAheadLimit ($limit)
 
 setTypeAheadHighlight ($highlight)
 
 setTypeAheadList ($type_ahead_list)
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ()
 
 insert ($a_tpl)
 
- 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...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
 $options = array()
 
 $max_tags = 0
 
 $max_chars = 0
 
 $allow_duplicates = false
 
 $js_self_init = true
 
 $type_ahead_ignore_case = true
 
 $type_ahead_list = array()
 
 $type_ahead_min_length = 2
 
 $type_ahead_limit = 30
 
 $type_ahead_highlight = true
 
- 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 tag list property in a property form.

Author
Guido Vollbach gvoll.nosp@m.bach.nosp@m.@data.nosp@m.bay..nosp@m.de

Definition at line 24 of file class.ilTagInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Definition at line 138 of file class.ilTagInputGUI.php.

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

139  {
140  global $DIC;
141  $this->tpl = $DIC["tpl"];
142  $this->lng = $DIC->language();
143  parent::__construct($a_title, $a_postvar);
144  $this->setType("tag_input");
145  $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/bootstrap-tagsinput_2015_25_03.js');
146  $this->tpl->addJavaScript('./Modules/TestQuestionPool/templates/default/typeahead_0.11.1.js');
147  $this->tpl->addCss('./Modules/TestQuestionPool/templates/default/bootstrap-tagsinput_2015_25_03.css');
148  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilTagInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 167 of file class.ilTagInputGUI.php.

References ilFormPropertyGUI\$lng, $valid, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), ilFormPropertyGUI\strArray(), and ilLanguage\txt().

167  : bool
168  {
169  $lng = $this->lng;
170  $valid = true;
171 
172  $values = array_filter($this->strArray($this->getPostVar()));
173  if($values === [] && $this->getRequired()) {
174  $this->setAlert($lng->txt("msg_input_is_required"));
175  return false;
176  }
177  return $this->checkSubItemsInput();
178  }
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...
$valid
+ Here is the call graph for this function:

◆ getOptions()

ilTagInputGUI::getOptions ( )

Get Options.

Returns
array Options. Array

Definition at line 127 of file class.ilTagInputGUI.php.

Referenced by render().

127  : array
128  {
129  return $this->options ? $this->options : array();
130  }
+ Here is the caller graph for this function:

◆ insert()

ilTagInputGUI::insert (   $a_tpl)
Parameters
$a_tpl

Definition at line 230 of file class.ilTagInputGUI.php.

References render().

230  : void
231  {
232  $a_tpl->setCurrentBlock("prop_generic");
233  $a_tpl->setVariable("PROP_GENERIC", $this->render());
234  $a_tpl->parseCurrentBlock();
235  }
+ Here is the call graph for this function:

◆ render()

ilTagInputGUI::render ( )
Parameters
string$a_mode
Returns
string

Definition at line 184 of file class.ilTagInputGUI.php.

References $allow_duplicates, $config, $id, $max_chars, $max_tags, $type_ahead_highlight, $type_ahead_limit, $type_ahead_min_length, ilGlobalTemplateInterface\get(), ilFormPropertyGUI\getFieldId(), getOptions(), ilFormPropertyGUI\getPostVar(), ilGlobalTemplateInterface\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilGlobalTemplateInterface\setCurrentBlock(), and ilGlobalTemplateInterface\setVariable().

Referenced by insert().

184  : string
185  {
186  $this->tpl->addJavaScript('Modules/TestQuestionPool/templates/default/tagInput.js');
187  $config = [
188  'min_length' => $this->type_ahead_min_length,
189  'limit' => $this->type_ahead_limit,
190  'highlight' => $this->type_ahead_highlight,
191  'case' => '',
192  'maxtags' => $this->max_tags,
193  'maxchars' => $this->max_chars,
194  'allow_duplicates' => $this->allow_duplicates
195  ];
196  if ($this->type_ahead_ignore_case) {
197  $config['case'] = 'i';
198  }
199 
200  $this->tpl->addOnLoadCode(
201  'ilBootstrapTaggingOnLoad.initConfig(' . json_encode($config) . ');'
202  );
203 
204  $tpl = new ilTemplate("tpl.prop_tag_typeahead.html", true, true, "Modules/TestQuestionPool");
205  foreach ($this->getOptions() as $option_text) {
206  $tpl->setCurrentBlock("prop_select_option");
207  $tpl->setVariable("VAL_SELECT_OPTION", ilLegacyFormElementsUtil::prepareFormOutput($option_text));
208  $tpl->setVariable("TXT_SELECT_OPTION", $option_text);
210  }
211 
212  $tpl->setVariable("ID", $this->getFieldId());
213 
214  $tpl->setVariable("POST_VAR", $this->getPostVar() . "[]");
215 
216  if ($this->js_self_init) {
217  $id = preg_replace('/[^\d]+/', '', $this->getFieldId());
218  $this->tpl->addOnLoadCode(
219  "ilBootstrapTaggingOnLoad.appendId('#" . $this->getFieldId() . "');\n"
220  . "ilBootstrapTaggingOnLoad.appendTerms(" . $id . ", " . json_encode($this->type_ahead_list) . ");\n"
221  . "ilBootstrapTaggingOnLoad.Init();"
222  );
223  }
224  return $tpl->get();
225  }
ilGlobalTemplateInterface $tpl
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static prepareFormOutput($a_str, bool $a_strip=false)
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
getOptions()
Get Options.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setAllowDuplicates()

ilTagInputGUI::setAllowDuplicates (   $allow_duplicates)
Parameters
boolean$allow_duplicates

Definition at line 59 of file class.ilTagInputGUI.php.

References $allow_duplicates.

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

◆ setJsSelfInit()

ilTagInputGUI::setJsSelfInit (   $js_self_init)
Parameters
boolean$js_self_init

Definition at line 67 of file class.ilTagInputGUI.php.

References $js_self_init.

67  : void
68  {
69  $this->js_self_init = $js_self_init;
70  }

◆ setMaxChars()

ilTagInputGUI::setMaxChars (   $max_chars)
Parameters
int$max_chars

Definition at line 51 of file class.ilTagInputGUI.php.

References $max_chars.

51  : void
52  {
53  $this->max_chars = $max_chars;
54  }

◆ setMaxTags()

ilTagInputGUI::setMaxTags (   $max_tags)
Parameters
int$max_tags

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

References $max_tags.

43  : void
44  {
45  $this->max_tags = $max_tags;
46  }

◆ setOptions()

ilTagInputGUI::setOptions (   $a_options)

Set Options.

Parameters
array$a_optionsOptions.

Definition at line 117 of file class.ilTagInputGUI.php.

Referenced by setValueByArray().

117  : void
118  {
119  $this->options = $a_options;
120  }
+ Here is the caller graph for this function:

◆ setTypeAheadHighlight()

ilTagInputGUI::setTypeAheadHighlight (   $highlight)
Parameters
boolean$highlight

Definition at line 99 of file class.ilTagInputGUI.php.

99  : void
100  {
101  $this->type_ahead_highlight = $highlight;
102  }

◆ setTypeAheadIgnoreCase()

ilTagInputGUI::setTypeAheadIgnoreCase (   $type_ahead_ignore_case)
Parameters
boolean$type_ahead_ignore_case

Definition at line 75 of file class.ilTagInputGUI.php.

References $type_ahead_ignore_case.

75  : void
76  {
77  $this->type_ahead_ignore_case = $type_ahead_ignore_case;
78  }

◆ setTypeAheadLimit()

ilTagInputGUI::setTypeAheadLimit (   $limit)
Parameters
int$limit

Definition at line 91 of file class.ilTagInputGUI.php.

91  : void
92  {
93  $this->type_ahead_limit = $limit;
94  }

◆ setTypeAheadList()

ilTagInputGUI::setTypeAheadList (   $type_ahead_list)
Parameters
array$type_ahead_list

Definition at line 107 of file class.ilTagInputGUI.php.

References $type_ahead_list.

107  : void
108  {
109  $this->type_ahead_list = $type_ahead_list;
110  }

◆ setTypeAheadMinLength()

ilTagInputGUI::setTypeAheadMinLength (   $min_length)
Parameters
int$min_length

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

83  : void
84  {
85  $this->type_ahead_min_length = $min_length;
86  }

◆ setValueByArray()

ilTagInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 155 of file class.ilTagInputGUI.php.

References ilFormPropertyGUI\getPostVar(), ilSubEnabledFormPropertyGUI\getSubItems(), and setOptions().

155  : void
156  {
157  $this->setOptions($a_values[$this->getPostVar()]);
158  foreach ($this->getSubItems() as $item) {
159  $item->setValueByArray($a_values);
160  }
161  }
setOptions($a_options)
Set Options.
+ Here is the call graph for this function:

Field Documentation

◆ $allow_duplicates

ilTagInputGUI::$allow_duplicates = false
protected

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

Referenced by render(), and setAllowDuplicates().

◆ $js_self_init

ilTagInputGUI::$js_self_init = true
protected

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

Referenced by setJsSelfInit().

◆ $max_chars

ilTagInputGUI::$max_chars = 0
protected

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

Referenced by render(), and setMaxChars().

◆ $max_tags

ilTagInputGUI::$max_tags = 0
protected

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

Referenced by render(), and setMaxTags().

◆ $options

ilTagInputGUI::$options = array()
protected

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

◆ $tpl

ilGlobalTemplateInterface ilTagInputGUI::$tpl
protected

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

◆ $type_ahead_highlight

ilTagInputGUI::$type_ahead_highlight = true
protected

Definition at line 38 of file class.ilTagInputGUI.php.

Referenced by render().

◆ $type_ahead_ignore_case

ilTagInputGUI::$type_ahead_ignore_case = true
protected

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

Referenced by setTypeAheadIgnoreCase().

◆ $type_ahead_limit

ilTagInputGUI::$type_ahead_limit = 30
protected

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

Referenced by render().

◆ $type_ahead_list

ilTagInputGUI::$type_ahead_list = array()
protected

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

Referenced by setTypeAheadList().

◆ $type_ahead_min_length

ilTagInputGUI::$type_ahead_min_length = 2
protected

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

Referenced by render().


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