ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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...
 

Protected Attributes

 $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
 $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 132 of file class.ilTagInputGUI.php.

References $tpl, and ilFormPropertyGUI\setType().

133  {
134  parent::__construct($a_title, $a_postvar);
135  $this->setType("tag_input");
136  global $tpl;
137  $tpl->addJavaScript('./Services/Form/js/bootstrap-tagsinput_2015_25_03.js');
138  $tpl->addJavaScript('./Services/Form/js/typeahead_0.11.1.js');
139  $tpl->addCss('./Services/Form/css/bootstrap-tagsinput_2015_25_03.css');
140 
141  }
global $tpl
Definition: ilias.php:8
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 162 of file class.ilTagInputGUI.php.

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

163  {
164  global $lng;
165 
166  $valid = true;
167  if(array_key_exists($this->getPostVar(), $_POST))
168  {
169  foreach($_POST[$this->getPostVar()] as $idx => $value)
170  {
171  $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
172  }
173  $_POST[$this->getPostVar()] = array_unique($_POST[$this->getPostVar()]);
174 
175  if($this->getRequired() && !trim(implode("", $_POST[$this->getPostVar()])))
176  {
177  $valid = false;
178  }
179  }
180  else if($this->getRequired())
181  {
182  $valid = false;
183  }
184  if (!$valid)
185  {
186  $this->setAlert($lng->txt("msg_input_is_required"));
187  return false;
188  }
189  return $this->checkSubItemsInput();
190  }
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
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ getOptions()

ilTagInputGUI::getOptions ( )

Get Options.

Returns
array Options. Array

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

References array.

Referenced by render().

122  {
123  return $this->options ? $this->options : array();
124  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ insert()

ilTagInputGUI::insert (   $a_tpl)
Parameters
$a_tpl

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

References render().

245  {
246  $a_tpl->setCurrentBlock("prop_generic");
247  $a_tpl->setVariable("PROP_GENERIC", $this->render());
248  $a_tpl->parseCurrentBlock();
249  }
+ Here is the call graph for this function:

◆ render()

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

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

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

Referenced by insert().

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

References $allow_duplicates.

46  {
47  $this->allow_duplicates = $allow_duplicates;
48  }

◆ setJsSelfInit()

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

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

References $js_self_init.

54  {
55  $this->js_self_init = $js_self_init;
56  }

◆ setMaxChars()

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

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

References $max_chars.

38  {
39  $this->max_chars = $max_chars;
40  }

◆ setMaxTags()

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

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

References $max_tags.

30  {
31  $this->max_tags = $max_tags;
32  }

◆ setOptions()

ilTagInputGUI::setOptions (   $a_options)

Set Options.

Parameters
array$a_optionsOptions.

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

Referenced by setValueByArray().

112  {
113  $this->options = $a_options;
114  }
+ Here is the caller graph for this function:

◆ setTypeAhead()

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

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

References $type_ahead.

62  {
63  $this->type_ahead = $type_ahead;
64  }

◆ setTypeAheadHighlight()

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

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

94  {
95  $this->type_ahead_highlight = $highlight;
96  }

◆ setTypeAheadIgnoreCase()

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

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

References $type_ahead_ignore_case.

70  {
71  $this->type_ahead_ignore_case = $type_ahead_ignore_case;
72  }

◆ setTypeAheadLimit()

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

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

86  {
87  $this->type_ahead_limit = $limit;
88  }

◆ setTypeAheadList()

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

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

References $type_ahead_list.

102  {
103  $this->type_ahead_list = $type_ahead_list;
104  }

◆ setTypeAheadMinLength()

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

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

78  {
79  $this->type_ahead_min_length = $min_length;
80  }

◆ setValueByArray()

ilTagInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

149  {
150  $this->setOptions($a_values[$this->getPostVar()]);
151  foreach($this->getSubItems() as $item)
152  {
153  $item->setValueByArray($a_values);
154  }
155  }
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 16 of file class.ilTagInputGUI.php.

Referenced by setAllowDuplicates().

◆ $js_self_init

ilTagInputGUI::$js_self_init = true
protected

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

Referenced by setJsSelfInit().

◆ $max_chars

ilTagInputGUI::$max_chars = 0
protected

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

Referenced by setMaxChars().

◆ $max_tags

ilTagInputGUI::$max_tags = 0
protected

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

Referenced by setMaxTags().

◆ $options

ilTagInputGUI::$options = array()
protected

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

◆ $type_ahead

ilTagInputGUI::$type_ahead = false
protected

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

Referenced by setTypeAhead().

◆ $type_ahead_highlight

ilTagInputGUI::$type_ahead_highlight = true
protected

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

◆ $type_ahead_ignore_case

ilTagInputGUI::$type_ahead_ignore_case = true
protected

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

Referenced by setTypeAheadIgnoreCase().

◆ $type_ahead_limit

ilTagInputGUI::$type_ahead_limit = 30
protected

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

◆ $type_ahead_list

ilTagInputGUI::$type_ahead_list = array()
protected

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

Referenced by setTypeAheadList().

◆ $type_ahead_min_length

ilTagInputGUI::$type_ahead_min_length = 2
protected

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


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