ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 (int $max_tags)
 
 setMaxChars (int $max_chars)
 
 setAllowDuplicates (bool $allow_duplicates)
 
 setJsSelfInit (bool $js_self_init)
 
 setTypeAheadIgnoreCase (bool $type_ahead_ignore_case)
 
 setTypeAheadMinLength (int $min_length)
 
 setTypeAheadLimit (int $limit)
 
 setTypeAheadHighlight (bool $highlight)
 
 setTypeAheadList (array $type_ahead_list)
 
 setOptions (?array $a_options)
 
 getOptions ()
 
 __construct (string $a_title='', string $a_postvar='')
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ()
 
 insert (ilTemplate $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)
 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...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
array $options = null
 
int $max_tags = 0
 
int $max_chars = 0
 
bool $allow_duplicates = false
 
bool $js_self_init = true
 
bool $type_ahead_ignore_case = true
 
array $type_ahead_list = []
 
int $type_ahead_min_length = 2
 
int $type_ahead_limit = 30
 
bool $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
 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

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 ( string  $a_title = '',
string  $a_postvar = '' 
)

Reimplemented from ilFormPropertyGUI.

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

96 {
97 global $DIC;
98 $this->tpl = $DIC['tpl'];
99 $this->lng = $DIC->language();
100 parent::__construct($a_title, $a_postvar);
101 $this->setType('tag_input');
102 $this->tpl->addJavaScript('assets/js/bootstrap-tagsinput_2015_25_03.js');
103 $this->tpl->addJavaScript('assets/js/typeahead_0.11.1.js');
104 $this->tpl->addCss('assets/css/bootstrap-tagsinput_2015_25_03.css');
105 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

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

+ 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.

Reimplemented from ilFormPropertyGUI.

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

120 : bool
121 {
123 $valid = true;
124
125 $values = array_filter($this->strArray($this->getPostVar()));
126 if ($values === [] && $this->getRequired()) {
127 $this->setAlert($lng->txt(msg_input_is_required));
128 return false;
129 }
130 return $this->checkSubItemsInput();
131 }
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

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

+ Here is the call graph for this function:

◆ getOptions()

ilTagInputGUI::getOptions ( )

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

90 : array
91 {
92 return $this->options ? $this->options : [];
93 }

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilTagInputGUI::insert ( ilTemplate  $tpl)

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

176 : void
177 {
178 $tpl->setCurrentBlock('prop_generic');
179 $tpl->setVariable('PROP_GENERIC', $this->render());
180 $tpl->parseCurrentBlock();
181 }
ilGlobalTemplateInterface $tpl
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable(string $variable, $value='')
Sets the given variable to the given value.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.

References $tpl, ilTemplate\parseCurrentBlock(), render(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

◆ render()

ilTagInputGUI::render ( )

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

133 : string
134 {
135 $this->tpl->addJavaScript('assets/js/testQuestionPoolTagInput.js');
136 $config = [
137 'min_length' => $this->type_ahead_min_length,
138 'limit' => $this->type_ahead_limit,
139 'highlight' => $this->type_ahead_highlight,
140 'case' => '',
141 'maxtags' => $this->max_tags,
142 'maxchars' => $this->max_chars,
143 'allow_duplicates' => $this->allow_duplicates
144 ];
145 if ($this->type_ahead_ignore_case) {
146 $config['case'] = 'i';
147 }
148
149 $this->tpl->addOnLoadCode(
150 'ilBootstrapTaggingOnLoad.initConfig(' . json_encode($config) . ');'
151 );
152
153 $tpl = new ilTemplate('tpl.prop_tag_typeahead.html', true, true, 'components/ILIAS/TestQuestionPool');
154 foreach ($this->getOptions() as $option_text) {
155 $tpl->setCurrentBlock('prop_select_option');
156 $tpl->setVariable('VAL_SELECT_OPTION', ilLegacyFormElementsUtil::prepareFormOutput($option_text));
157 $tpl->setVariable('TXT_SELECT_OPTION', $option_text);
159 }
160
161 $tpl->setVariable('ID', $this->getFieldId());
162
163 $tpl->setVariable('POST_VAR', $this->getPostVar() . '[]');
164
165 if ($this->js_self_init) {
166 $id = preg_replace('/[^\d]+/', '', $this->getFieldId());
167 $this->tpl->addOnLoadCode(
168 "ilBootstrapTaggingOnLoad.appendId('#{$this->getFieldId()}');\n"
169 . "ilBootstrapTaggingOnLoad.appendTerms({$id}, " . json_encode($this->type_ahead_list) . ");\n"
170 . 'ilBootstrapTaggingOnLoad.Init();'
171 );
172 }
173 return $tpl->get();
174 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static prepareFormOutput($a_str, bool $a_strip=false)
special template class to simplify handling of ITX/PEAR
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

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

Referenced by insert().

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

◆ setAllowDuplicates()

ilTagInputGUI::setAllowDuplicates ( bool  $allow_duplicates)

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

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

References $allow_duplicates.

◆ setJsSelfInit()

ilTagInputGUI::setJsSelfInit ( bool  $js_self_init)

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

55 : void
56 {
57 $this->js_self_init = $js_self_init;
58 }

References $js_self_init.

◆ setMaxChars()

ilTagInputGUI::setMaxChars ( int  $max_chars)

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

45 : void
46 {
47 $this->max_chars = $max_chars;
48 }

References $max_chars.

◆ setMaxTags()

ilTagInputGUI::setMaxTags ( int  $max_tags)

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

40 : void
41 {
42 $this->max_tags = $max_tags;
43 }

References $max_tags.

◆ setOptions()

ilTagInputGUI::setOptions ( ?array  $a_options)

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

85 : void
86 {
87 $this->options = $a_options;
88 }

Referenced by setValueByArray().

+ Here is the caller graph for this function:

◆ setTypeAheadHighlight()

ilTagInputGUI::setTypeAheadHighlight ( bool  $highlight)

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

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

◆ setTypeAheadIgnoreCase()

ilTagInputGUI::setTypeAheadIgnoreCase ( bool  $type_ahead_ignore_case)

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

60 : void
61 {
62 $this->type_ahead_ignore_case = $type_ahead_ignore_case;
63 }

References $type_ahead_ignore_case.

◆ setTypeAheadLimit()

ilTagInputGUI::setTypeAheadLimit ( int  $limit)

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

70 : void
71 {
72 $this->type_ahead_limit = $limit;
73 }

◆ setTypeAheadList()

ilTagInputGUI::setTypeAheadList ( array  $type_ahead_list)

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

80 : void
81 {
82 $this->type_ahead_list = $type_ahead_list;
83 }

References $type_ahead_list.

◆ setTypeAheadMinLength()

ilTagInputGUI::setTypeAheadMinLength ( int  $min_length)

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

65 : void
66 {
67 $this->type_ahead_min_length = $min_length;
68 }

◆ setValueByArray()

ilTagInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

112 : void
113 {
114 $this->setOptions($a_values[$this->getPostVar()]);
115 foreach ($this->getSubItems() as $item) {
116 $item->setValueByArray($a_values);
117 }
118 }
setOptions(?array $a_options)

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

+ Here is the call graph for this function:

Field Documentation

◆ $allow_duplicates

bool ilTagInputGUI::$allow_duplicates = false
protected

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

Referenced by render(), and setAllowDuplicates().

◆ $js_self_init

bool ilTagInputGUI::$js_self_init = true
protected

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

Referenced by setJsSelfInit().

◆ $max_chars

int ilTagInputGUI::$max_chars = 0
protected

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

Referenced by render(), and setMaxChars().

◆ $max_tags

int ilTagInputGUI::$max_tags = 0
protected

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

Referenced by render(), and setMaxTags().

◆ $options

array ilTagInputGUI::$options = null
protected

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

◆ $tpl

ilGlobalTemplateInterface ilTagInputGUI::$tpl
protected

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

Referenced by insert(), and render().

◆ $type_ahead_highlight

bool ilTagInputGUI::$type_ahead_highlight = true
protected

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

Referenced by render().

◆ $type_ahead_ignore_case

bool ilTagInputGUI::$type_ahead_ignore_case = true
protected

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

Referenced by setTypeAheadIgnoreCase().

◆ $type_ahead_limit

int ilTagInputGUI::$type_ahead_limit = 30
protected

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

Referenced by render().

◆ $type_ahead_list

array ilTagInputGUI::$type_ahead_list = []
protected

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

Referenced by setTypeAheadList().

◆ $type_ahead_min_length

int 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: