ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSelectInputGUI Class Reference

This class represents a selection list property in a property form. More...

+ Inheritance diagram for ilSelectInputGUI:
+ Collaboration diagram for ilSelectInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setOptions ($a_options)
 Set Options. More...
 
 getOptions ()
 Get Options. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 addCustomAttribute ($a_attr)
 
 getCustomAttributes ()
 
 render ($a_mode="")
 Render item. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getTableFilterHTML ()
 Get HTML for table filter. More...
 
 getToolbarHTML ()
 Get HTML for toolbar. More...
 
 setHideSubForm ($a_value, $a_condition=null)
 Set initial sub form visibility, optionally add dynamic value-based condition. More...
 
 hideSubForm ()
 
- 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

 $cust_attr = array()
 
 $options = array()
 
 $value
 
- 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 selection list property in a property form.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

References ilFormPropertyGUI\setType().

30  {
31  parent::__construct($a_title, $a_postvar);
32  $this->setType("select");
33  }
setType($a_type)
Set Type.
+ Here is the call graph for this function:

Member Function Documentation

◆ addCustomAttribute()

ilSelectInputGUI::addCustomAttribute (   $a_attr)

Definition at line 144 of file class.ilSelectInputGUI.php.

Referenced by setHideSubForm().

145  {
146  $this->cust_attr[] = $a_attr;
147  }
+ Here is the caller graph for this function:

◆ checkInput()

ilSelectInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Definition at line 100 of file class.ilSelectInputGUI.php.

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

101  {
102  global $lng;
103 
104  $valid = true;
105  if(!$this->getMulti())
106  {
107  $_POST[$this->getPostVar()] = ilUtil::stripSlashes($_POST[$this->getPostVar()]);
108  if($this->getRequired() && trim($_POST[$this->getPostVar()]) == "")
109  {
110  $valid = false;
111  }
112  if(!array_key_exists($_POST[$this->getPostVar()], (array) $this->getOptions()))
113  {
114  $this->setAlert($lng->txt('msg_invalid_post_input'));
115  return false;
116  }
117  }
118  else
119  {
120  foreach($_POST[$this->getPostVar()] as $idx => $value)
121  {
122  $_POST[$this->getPostVar()][$idx] = ilUtil::stripSlashes($value);
123  if(!array_key_exists($value, (array) $this->getOptions()))
124  {
125  $this->setAlert($lng->txt('msg_invalid_post_input'));
126  return false;
127  }
128  }
129  $_POST[$this->getPostVar()] = array_unique($_POST[$this->getPostVar()]);
130 
131  if($this->getRequired() && !trim(implode("", $_POST[$this->getPostVar()])))
132  {
133  $valid = false;
134  }
135  }
136  if (!$valid)
137  {
138  $this->setAlert($lng->txt("msg_input_is_required"));
139  return false;
140  }
141  return $this->checkSubItemsInput();
142  }
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
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:

◆ getCustomAttributes()

ilSelectInputGUI::getCustomAttributes ( )

Definition at line 149 of file class.ilSelectInputGUI.php.

References $cust_attr, and array.

Referenced by render().

150  {
151  return (array) $this->cust_attr;
152  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getOptions()

ilSelectInputGUI::getOptions ( )

Get Options.

Returns
array Options. Array ("value" => "option_text")

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

References array.

Referenced by checkInput(), and render().

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

◆ getTableFilterHTML()

ilSelectInputGUI::getTableFilterHTML ( )

Get HTML for table filter.

Implements ilTableFilterItem.

Definition at line 257 of file class.ilSelectInputGUI.php.

References $html, and render().

258  {
259  $html = $this->render();
260  return $html;
261  }
render($a_mode="")
Render item.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ getToolbarHTML()

ilSelectInputGUI::getToolbarHTML ( )

Get HTML for toolbar.

Implements ilToolbarItem.

Definition at line 266 of file class.ilSelectInputGUI.php.

References $html, and render().

267  {
268  $html = $this->render("toolbar");
269  return $html;
270  }
render($a_mode="")
Render item.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ getValue()

ilSelectInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

76  {
77  return $this->value;
78  }
+ Here is the caller graph for this function:

◆ hideSubForm()

ilSelectInputGUI::hideSubForm ( )

Definition at line 291 of file class.ilSelectInputGUI.php.

292  {
293  return (bool)$this->hide_sub;
294  }

◆ insert()

ilSelectInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

Definition at line 247 of file class.ilSelectInputGUI.php.

References render().

248  {
249  $a_tpl->setCurrentBlock("prop_generic");
250  $a_tpl->setVariable("PROP_GENERIC", $this->render());
251  $a_tpl->parseCurrentBlock();
252  }
render($a_mode="")
Render item.
+ Here is the call graph for this function:

◆ render()

ilSelectInputGUI::render (   $a_mode = "")

Render item.

Definition at line 157 of file class.ilSelectInputGUI.php.

References ilFormPropertyGUI\$postvar, $tpl, $value, getCustomAttributes(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), ilFormPropertyGUI\getHiddenTag(), ilFormPropertyGUI\getMulti(), ilFormPropertyGUI\getMultiIconsHTML(), ilFormPropertyGUI\getMultiValues(), getOptions(), ilFormPropertyGUI\getPostVar(), getValue(), and ilUtil\prepareFormOutput().

Referenced by getTableFilterHTML(), getToolbarHTML(), and insert().

158  {
159  $tpl = new ilTemplate("tpl.prop_select.html", true, true, "Services/Form");
160 
161  foreach($this->getCustomAttributes() as $attr)
162  {
163  $tpl->setCurrentBlock('cust_attr');
164  $tpl->setVariable('CUSTOM_ATTR',$attr);
165  $tpl->parseCurrentBlock();
166  }
167 
168  // determin value to select. Due to accessibility reasons we
169  // should always select a value (per default the first one)
170  $first = true;
171  foreach($this->getOptions() as $option_value => $option_text)
172  {
173  if ($first)
174  {
175  $sel_value = $option_value;
176  }
177  $first = false;
178  if ((string) $option_value == (string) $this->getValue())
179  {
180  $sel_value = $option_value;
181  }
182  }
183  foreach($this->getOptions() as $option_value => $option_text)
184  {
185  $tpl->setCurrentBlock("prop_select_option");
186  $tpl->setVariable("VAL_SELECT_OPTION", ilUtil::prepareFormOutput($option_value));
187  if((string) $sel_value == (string) $option_value)
188  {
189  $tpl->setVariable("CHK_SEL_OPTION",
190  'selected="selected"');
191  }
192  $tpl->setVariable("TXT_SELECT_OPTION", $option_text);
193  $tpl->parseCurrentBlock();
194  }
195  $tpl->setVariable("ID", $this->getFieldId());
196 
197  $postvar = $this->getPostVar();
198  if($this->getMulti() && substr($postvar, -2) != "[]")
199  {
200  $postvar .= "[]";
201  }
202 
203  if ($this->getDisabled())
204  {
205  if($this->getMulti())
206  {
207  $value = $this->getMultiValues();
208  $hidden = "";
209  if(is_array($value))
210  {
211  foreach($value as $item)
212  {
213  $hidden .= $this->getHiddenTag($postvar, $item);
214  }
215  }
216  }
217  else
218  {
219  $hidden = $this->getHiddenTag($postvar, $this->getValue());
220  }
221  if($hidden)
222  {
223  $tpl->setVariable("DISABLED", " disabled=\"disabled\"");
224  $tpl->setVariable("HIDDEN_INPUT", $hidden);
225  }
226  }
227  else
228  {
229  $tpl->setVariable("POST_VAR", $postvar);
230  }
231 
232  // multi icons
233  if($this->getMulti() && !$a_mode && !$this->getDisabled())
234  {
235  $tpl->touchBlock("inline_in_bl");
236  $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
237  }
238 
239  return $tpl->get();
240  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getHiddenTag($a_post_var, $a_value)
Get hidden tag (used for disabled properties)
getPostVar()
Get Post Variable.
getMultiIconsHTML()
Get HTML for multiple value icons.
global $tpl
Definition: ilias.php:8
getMultiValues()
Get multi values.
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHideSubForm()

ilSelectInputGUI::setHideSubForm (   $a_value,
  $a_condition = null 
)

Set initial sub form visibility, optionally add dynamic value-based condition.

See also
ilObjBookingPoolGUI
Parameters
bool$a_value
string$a_condition

Definition at line 279 of file class.ilSelectInputGUI.php.

References addCustomAttribute(), and ilFormPropertyGUI\getFieldId().

280  {
281  $this->hide_sub = (bool)$a_value;
282 
283  if($a_condition)
284  {
285  $this->addCustomAttribute('onchange="if(this.value '.$a_condition.')'.
286  ' { il.Form.showSubForm(\'subform_'.$this->getFieldId().'\', \'il_prop_cont_'.$this->getFieldId().'\'); }'.
287  ' else { il.Form.hideSubForm(\'subform_'.$this->getFieldId().'\'); };"');
288  }
289  }
getFieldId()
Get Post Variable.
+ Here is the call graph for this function:

◆ setOptions()

ilSelectInputGUI::setOptions (   $a_options)

Set Options.

Parameters
array$a_optionsOptions. Array ("value" => "option_text")

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

Referenced by ilChatroomHistoryGUI\__construct(), FormMailCodesGUI\__construct(), ilSurveyEvaluationGUI\addApprSelectionToToolbar(), ilMemberAgreementGUI\addCustomFields(), ilTestExpressPageObjectGUI\addQuestion(), ilObjTestGUI\addQuestionObject(), ilSurveyPageGUI\addQuestionToolbarForm(), ilUserProfile\addStandardFieldsToForm(), ilTestSkillEvaluationToolbarGUI\build(), ilObjQuestionPoolGUI\buildCreateQuestionForm(), ilSurveyEvaluationGUI\buildExportModal(), ilDclPluginFieldRepresentation\buildFieldCreationInput(), ilDclReferenceFieldRepresentation\buildFieldCreationInput(), ilObjStudyProgrammeSettingsGUI\buildForm(), ilObjTestDynamicQuestionSetConfigGUI\buildForm(), ilSurveyEvaluationGUI\competenceEval(), ilSurveyConstraintsGUI\constraintForm(), ilSurveyEditorGUI\copyQuestionsToPoolObject(), ilSurveyEditorGUI\createQuestionObject(), ilObjTestGUI\createQuestionObject(), ilSessionStatisticsGUI\current(), ilPCTableGUI\editCellAlignment(), ilObjExternalToolsSettingsGUI\editMapsObject(), ilObjHelpSettingsGUI\editSettings(), ilObjNewsSettingsGUI\editSettings(), ilPDNewsBlockGUI\editSettings(), ilSurveyEvaluationGUI\evaluation(), ilTestEvaluationGUI\exportFileUploadsForAllParticipants(), ilObjAuthSettingsGUI\getApacheAuthSettingsForm(), ilNotificationAdminSettingsForm\getChannelForm(), ilNotificationAdminSettingsForm\getGeneralSettingsForm(), ilMultilingualismGUI\getMultiLangForm(), ilObjectTranslationGUI\getMultiLangForm(), ilPCIIMTriggerEditorGUI\getToolbar(), ilImageMapEditorGUI\getToolbar(), ilExAssignmentEditorGUI\getTypeDropdown(), ilNotificationAdminSettingsForm\getTypeForm(), ilObjUserGUI\getValues(), ilPageLayoutAdministrationGUI\initAddPageLayoutForm(), ilAdvancedSearchGUI\initAdvancedMetaDataForm(), ilSetupGUI\initBasicSettingsForm(), ilECSSettingsGUI\initCategoryMappingForm(), ilObjStyleSheetGUI\initCharacteristicForm(), ilObjGlossaryGUI\initCreateForm(), ilTestManScoringParticipantsBySelectedQuestionAndPassTableGUI\initFilter(), ilTestManScoringParticipantsTableGUI\initFilter(), ilTestDynamicQuestionSetStatisticTableGUI\initFilter(), ilBuddySystemRelationsTableGUI\initFilter(), ilTestParticipantsTableGUI\initFilter(), ilRoleTableGUI\initFilter(), ilTermsOfServiceAcceptanceHistoryTableGUI\initFilter(), ilRegistrationCodesTableGUI\initFilter(), ilUserTableGUI\initFilter(), ilObjMailGUI\initForm(), ilPCTabsGUI\initForm(), ilPCAMDPageListGUI\initForm(), ilPageLayoutGUI\initForm(), ilCalendarAppointmentGUI\initForm(), ilLDAPSettingsGUI\initForm(), ilECSMappingSettingsGUI\initFormCSettings(), ilObjLinkResourceGUI\initFormLink(), ilCourseObjectivesGUI\initFormRandom(), ilConsultationHoursGUI\initFormSequence(), ilCASSettingsGUI\initFormSettings(), ilObjAwarenessAdministrationGUI\initFormSettings(), ilObjLoggingSettingsGUI\initFormSettings(), ilObjCalendarSettingsGUI\initFormSettings(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilIndividualAssessmentMemberGUI\initGradingForm(), ilSurveyEditorGUI\initHeadingForm(), ilObjSurveyGUI\initImportForm(), ilObjSystemFolderGUI\initJavaServerIniForm(), ilPCListGUI\initListForm(), ilPersonalSettingsGUI\initMailOptionsForm(), ilMailOptionsGUI\initMailOptionsForm(), ilObjSCORM2004LearningModuleGUI\initPropertiesEditableForm(), ilPCTableGUI\initPropertiesForm(), ilObjSCORM2004LearningModuleGUI\initPropertiesForm(), ilPCSourceCodeGUI\initPropertyForm(), ilObjRepositorySettingsGUI\initSettingsForm(), ilCalendarUserSettingsGUI\initSettingsForm(), ilECSSettingsGUI\initSettingsForm(), ilObjTaxonomyGUI\initSettingsForm(), ilObjContentObjectGUI\initStylePropertiesForm(), ilObjPortfolioBaseGUI\initStylePropertiesForm(), ilObjSCORM2004LearningModuleGUI\initStylePropertiesForm(), ilObjGlossaryGUI\initStylePropertiesForm(), ilObjWikiGUI\initStylePropertiesForm(), ilObjBlogGUI\initStylePropertiesForm(), ilContainerGUI\initStylePropertiesForm(), ilObjStyleSheetGUI\initTagStyleForm(), ilObjStyleSheetGUI\initTemplateGenerationForm(), ilObjSAHSLearningModuleGUI\initUploadForm(), ilPCQuestionGUI\insert(), assFormulaQuestionGUI\isSaveCommand(), ilBadgeManagementGUI\listBadges(), ilBadgeManagementGUI\listUsers(), ilSessionStatisticsGUI\long(), ilSurveyPageGUI\movePageForm(), ilObjTestGUI\movePageFormObject(), ilSCORM2004TrackingItemsPerUserFilterGUI\parse(), assKprimChoiceGUI\populateQuestionSpecificFormPart(), assTextSubsetGUI\populateQuestionSpecificFormPart(), ilSurveyEditorGUI\printViewObject(), ilObjSCORMLearningModuleGUI\properties(), ilSurveyEditorGUI\questionsObject(), ilTestEvaluationGUI\resetfilterEvaluation(), ilObjOrgUnitSettingsFormGUI\saveObject(), ilSurveyEditorGUI\setBrowseForQuestionsSubtabs(), ilRadiusSettingsGUI\settings(), ilSessionStatisticsGUI\short(), ilExcCriteriaGUI\view(), ilPDNotesGUI\view(), and ilWikiStatGUI\viewToolbar().

41  {
42  $this->options = $a_options;
43  }
+ Here is the caller graph for this function:

◆ setValue()

ilSelectInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

References ilFormPropertyGUI\getMulti(), and ilFormPropertyGUI\setMultiValues().

Referenced by ilUserProfile\addStandardFieldsToForm(), ilECSSettingsGUI\initCategoryMappingForm(), ilOrgUnitTypeFormGUI\initForm(), ilCalendarAppointmentGUI\initForm(), ilObjSearchSettingsGUI\initFormSettings(), ilAuthLoginPageEditorGUI\initLoginForm(), ilECSSettingsGUI\initMappingsForm(), ilTaxAssignInputGUI\setCurrentValues(), and setValueByArray().

61  {
62  if($this->getMulti() && is_array($a_value))
63  {
64  $this->setMultiValues($a_value);
65  $a_value = array_shift($a_value);
66  }
67  $this->value = $a_value;
68  }
setMultiValues(array $a_values)
Set multi values.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValueByArray()

ilSelectInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

Definition at line 86 of file class.ilSelectInputGUI.php.

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

87  {
88  $this->setValue($a_values[$this->getPostVar()]);
89  foreach($this->getSubItems() as $item)
90  {
91  $item->setValueByArray($a_values);
92  }
93  }
getPostVar()
Get Post Variable.
setValue($a_value)
Set Value.
+ Here is the call graph for this function:

Field Documentation

◆ $cust_attr

ilSelectInputGUI::$cust_attr = array()
protected

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

Referenced by getCustomAttributes().

◆ $options

ilSelectInputGUI::$options = array()
protected

◆ $value

ilSelectInputGUI::$value
protected

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

Referenced by checkInput(), getValue(), and render().


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