ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTagInputGUI Class Reference

This class represents a tag list property in a property form. 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)
 
 setTypeAhead ($type_ahead)
 
 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 ($a_mode="")
 
 insert ($a_tpl)
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($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...
 

Protected Attributes

 $tpl
 
 $options = array()
 
 $max_tags = 0
 
 $max_chars = 0
 
 $allow_duplicates = false
 
 $js_self_init = true
 
 $type_ahead = false
 
 $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
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $ctrl
 
 $lng
 
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Detailed Description

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
Version
$Id$

Definition at line 11 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 137 of file class.ilTagInputGUI.php.

References $DIC, $tpl, and ilFormPropertyGUI\setType().

138  {
139  global $DIC;
140 
141  $this->tpl = $DIC["tpl"];
142  $this->lng = $DIC->language();
143  parent::__construct($a_title, $a_postvar);
144  $this->setType("tag_input");
145  $tpl = $DIC["tpl"];
146  $tpl->addJavaScript('./Services/Form/js/bootstrap-tagsinput_2015_25_03.js');
147  $tpl->addJavaScript('./Services/Form/js/typeahead_0.11.1.js');
148  $tpl->addCss('./Services/Form/css/bootstrap-tagsinput_2015_25_03.css');
149  }
global $DIC
Definition: saml.php:7
setType($a_type)
Set Type.
+ 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 169 of file class.ilTagInputGUI.php.

References $_POST, ilFormPropertyGUI\$lng, $valid, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilUtil\stripSlashes().

170  {
171  $lng = $this->lng;
172 
173  $valid = true;
174  if (array_key_exists($this->getPostVar(), $_POST)) {
175  foreach ($_POST[$this->getPostVar()] as $idx => $value) {
176  $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
177  }
178  $_POST[$this->getPostVar()] = array_unique($_POST[$this->getPostVar()]);
179 
180  if ($this->getRequired() && !trim(implode("", $_POST[$this->getPostVar()]))) {
181  $valid = false;
182  }
183  } elseif ($this->getRequired()) {
184  $valid = false;
185  }
186  if (!$valid) {
187  $this->setAlert($lng->txt("msg_input_is_required"));
188  return false;
189  }
190  return $this->checkSubItemsInput();
191  }
getPostVar()
Get Post Variable.
$valid
setAlert($a_alert)
Set Alert Text.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST["username"]
+ Here is the call graph for this function:

◆ getOptions()

ilTagInputGUI::getOptions ( )

Get Options.

Returns
array Options. Array

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

Referenced by render().

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

◆ insert()

ilTagInputGUI::insert (   $a_tpl)
Parameters
$a_tpl

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

References render().

239  {
240  $a_tpl->setCurrentBlock("prop_generic");
241  $a_tpl->setVariable("PROP_GENERIC", $this->render());
242  $a_tpl->parseCurrentBlock();
243  }
+ Here is the call graph for this function:

◆ render()

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

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

References $tpl, ilFormPropertyGUI\getFieldId(), getOptions(), ilFormPropertyGUI\getPostVar(), and ilUtil\prepareFormOutput().

Referenced by insert().

198  {
199  if ($this->type_ahead) {
200  $tpl = new ilTemplate("tpl.prop_tag_typeahead.html", true, true, "Services/Form");
201  $tpl->setVariable("MIN_LENGTH", $this->type_ahead_min_length);
202  $tpl->setVariable("LIMIT", $this->type_ahead_limit);
203  $tpl->setVariable("HIGHLIGHT", $this->type_ahead_highlight);
204  if ($this->type_ahead_ignore_case) {
205  $tpl->setVariable("CASE", 'i');
206  }
207  $tpl->setVariable("TERMS", json_encode($this->type_ahead_list));
208  } else {
209  $tpl = new ilTemplate("tpl.prop_tag.html", true, true, "Services/Form");
210  }
211 
212  $tpl->setVariable("MAXTAGS", $this->max_tags);
213  $tpl->setVariable("MAXCHARS", $this->max_chars);
214  $tpl->setVariable("ALLOW_DUPLICATES", $this->allow_duplicates);
215 
216  foreach ($this->getOptions() as $option_value => $option_text) {
217  $tpl->setCurrentBlock("prop_select_option");
218  $tpl->setVariable("VAL_SELECT_OPTION", ilUtil::prepareFormOutput($option_text));
219  $tpl->setVariable("TXT_SELECT_OPTION", $option_text);
220  $tpl->parseCurrentBlock();
221  }
222 
223  $tpl->setVariable("ID", $this->getFieldId());
224 
225  $tpl->setVariable("POST_VAR", $this->getPostVar() . "[]");
226 
227  if ($this->js_self_init) {
228  $tpl->setCurrentBlock("initialize_on_page_load");
229  $tpl->parseCurrentBlock();
230  }
231  $tpl->setVariable("ID", $this->getFieldId());
232  return $tpl->get();
233  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getPostVar()
Get Post Variable.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
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 50 of file class.ilTagInputGUI.php.

References $allow_duplicates.

51  {
52  $this->allow_duplicates = $allow_duplicates;
53  }

◆ setJsSelfInit()

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

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

References $js_self_init.

59  {
60  $this->js_self_init = $js_self_init;
61  }

◆ setMaxChars()

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

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

References $max_chars.

43  {
44  $this->max_chars = $max_chars;
45  }

◆ setMaxTags()

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

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

References $max_tags.

35  {
36  $this->max_tags = $max_tags;
37  }

◆ setOptions()

ilTagInputGUI::setOptions (   $a_options)

Set Options.

Parameters
array$a_optionsOptions.

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

Referenced by setValueByArray().

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

◆ setTypeAhead()

ilTagInputGUI::setTypeAhead (   $type_ahead)
Parameters
boolean$type_ahead

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

References $type_ahead.

67  {
68  $this->type_ahead = $type_ahead;
69  }

◆ setTypeAheadHighlight()

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

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

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

◆ setTypeAheadIgnoreCase()

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

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

References $type_ahead_ignore_case.

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

◆ setTypeAheadLimit()

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

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

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

◆ setTypeAheadList()

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

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

References $type_ahead_list.

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

◆ setTypeAheadMinLength()

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

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

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

◆ setValueByArray()

ilTagInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

157  {
158  $this->setOptions($a_values[$this->getPostVar()]);
159  foreach ($this->getSubItems() as $item) {
160  $item->setValueByArray($a_values);
161  }
162  }
getPostVar()
Get Post Variable.
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 21 of file class.ilTagInputGUI.php.

Referenced by setAllowDuplicates().

◆ $js_self_init

ilTagInputGUI::$js_self_init = true
protected

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

Referenced by setJsSelfInit().

◆ $max_chars

ilTagInputGUI::$max_chars = 0
protected

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

Referenced by setMaxChars().

◆ $max_tags

ilTagInputGUI::$max_tags = 0
protected

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

Referenced by setMaxTags().

◆ $options

ilTagInputGUI::$options = array()
protected

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

◆ $tpl

ilTagInputGUI::$tpl
protected

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

Referenced by __construct(), and render().

◆ $type_ahead

ilTagInputGUI::$type_ahead = false
protected

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

Referenced by setTypeAhead().

◆ $type_ahead_highlight

ilTagInputGUI::$type_ahead_highlight = true
protected

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

◆ $type_ahead_ignore_case

ilTagInputGUI::$type_ahead_ignore_case = true
protected

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

Referenced by setTypeAheadIgnoreCase().

◆ $type_ahead_limit

ilTagInputGUI::$type_ahead_limit = 30
protected

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

◆ $type_ahead_list

ilTagInputGUI::$type_ahead_list = array()
protected

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

Referenced by setTypeAheadList().

◆ $type_ahead_min_length

ilTagInputGUI::$type_ahead_min_length = 2
protected

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


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