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

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setValue (array $a_value)
 
 setValueByLOMDuration (string $a_value)
 
 setShowSeconds (bool $status)
 
 getShowSeconds ()
 
 getValue ()
 
 setValueByArray (array $a_values)
 
 checkInput ()
 
 __buildMonthsSelect (string $sel_month)
 
 __buildDaysSelect (string $sel_day)
 
 insert (ilTemplate $a_tpl)
 
- 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...
 

Data Fields

const POST_NAME_MONTH = 'mo'
 
const POST_NAME_DAY = 'd'
 
const POST_NAME_HOUR = 'h'
 
const POST_NAME_MINUTE = 'm'
 
const POST_NAME_SECOND = 's'
 

Protected Member Functions

 getInputFromPost (string $post_name)
 
- 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)
 

Protected Attributes

array $value
 
bool $valid = true
 
string $lom_duration = ''
 
bool $show_seconds = false
 
- 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...
 

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 typical learning time 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 27 of file class.ilTypicalLearningTimeInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTypicalLearningTimeInputGUI::__construct ( string  $a_title = "",
string  $a_postvar = "" 
)

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

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

41  {
42  parent::__construct($a_title, $a_postvar);
43 
44  $this->lng->loadLanguageModule("meta");
45  $this->setType("typical_learntime");
46  $this->setValue(array(0, 0, 0, 0, 0));
47  }
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ __buildDaysSelect()

ilTypicalLearningTimeInputGUI::__buildDaysSelect ( string  $sel_day)

Definition at line 132 of file class.ilTypicalLearningTimeInputGUI.php.

References $i, ilLegacyFormElementsUtil\formSelect(), and ilFormPropertyGUI\getPostVar().

Referenced by insert().

132  : string
133  {
134  $options = [];
135  for ($i = 0; $i <= 31; $i++) {
136  $options[$i] = sprintf('%02d', $i);
137  }
138  return ilLegacyFormElementsUtil::formSelect($sel_day, $this->getPostVar() . '[d]', $options, false, true);
139  }
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ __buildMonthsSelect()

ilTypicalLearningTimeInputGUI::__buildMonthsSelect ( string  $sel_month)

Definition at line 123 of file class.ilTypicalLearningTimeInputGUI.php.

References $i, ilLegacyFormElementsUtil\formSelect(), and ilFormPropertyGUI\getPostVar().

Referenced by insert().

123  : string
124  {
125  $options = [];
126  for ($i = 0; $i <= 24; $i++) {
127  $options[$i] = sprintf('%02d', $i);
128  }
129  return ilLegacyFormElementsUtil::formSelect($sel_month, $this->getPostVar() . '[mo]', $options, false, true);
130  }
static formSelect( $selected, string $varname, array $options, bool $multiple=false, bool $direct_text=false, int $size=0, string $style_class="", array $attribs=[], bool $disabled=false)
Builds a select form field with options and shows the selected option first.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkInput()

ilTypicalLearningTimeInputGUI::checkInput ( )

Definition at line 105 of file class.ilTypicalLearningTimeInputGUI.php.

References getInputFromPost(), ilFormPropertyGUI\getRequired(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setAlert().

105  : bool
106  {
107  $counter = 0;
108  $required_fullfilled = false;
109  foreach ([self::POST_NAME_MONTH, self::POST_NAME_DAY, self::POST_NAME_HOUR, self::POST_NAME_MINUTE, self::POST_NAME_SECOND] as $post_name) {
110  $value = $this->getInputFromPost($post_name);
111  if ($value > 0) {
112  $required_fullfilled = true;
113  }
114  $this->value[$counter++] = $this->getInputFromPost($post_name);
115  }
116  if ($this->getRequired() && !$required_fullfilled) {
117  $this->setAlert($this->lng->txt("msg_input_is_required"));
118  return false;
119  }
120  return true;
121  }
+ Here is the call graph for this function:

◆ getInputFromPost()

ilTypicalLearningTimeInputGUI::getInputFromPost ( string  $post_name)
protected

Definition at line 94 of file class.ilTypicalLearningTimeInputGUI.php.

References ilFormPropertyGUI\getPostVar(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by checkInput().

94  : int
95  {
96  if ($this->http->wrapper()->post()->has($this->getPostVar() . '[' . $post_name . ']')) {
97  return $this->http->wrapper()->post()->retrieve(
98  $this->getPostVar() . '[' . $post_name . ']',
99  $this->refinery->kindlyTo()->int()
100  );
101  }
102  return 0;
103  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getShowSeconds()

ilTypicalLearningTimeInputGUI::getShowSeconds ( )

Definition at line 76 of file class.ilTypicalLearningTimeInputGUI.php.

References $show_seconds.

76  : bool
77  {
78  return $this->show_seconds;
79  }

◆ getValue()

ilTypicalLearningTimeInputGUI::getValue ( )
Returns
int[]

Definition at line 84 of file class.ilTypicalLearningTimeInputGUI.php.

References $value.

Referenced by insert().

84  : array
85  {
86  return $this->value;
87  }
+ Here is the caller graph for this function:

◆ insert()

ilTypicalLearningTimeInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 141 of file class.ilTypicalLearningTimeInputGUI.php.

References __buildDaysSelect(), __buildMonthsSelect(), ilFormPropertyGUI\getPostVar(), getValue(), ILIAS\Repository\lng(), ilLegacyFormElementsUtil\makeTimeSelect(), ilTemplate\parseCurrentBlock(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

141  : void
142  {
143  $ttpl = new ilTemplate("tpl.prop_typical_learning_time.html", true, true, "Services/MetaData");
144  $val = $this->getValue();
145 
146  $ttpl->setVariable("TXT_MONTH", $this->lng->txt('md_months'));
147  $ttpl->setVariable("SEL_MONTHS", $this->__buildMonthsSelect((string) ($val[0] ?? "")));
148  $ttpl->setVariable("SEL_DAYS", $this->__buildDaysSelect((string) ($val[1] ?? "")));
149 
150  $ttpl->setVariable("TXT_DAYS", $this->lng->txt('md_days'));
151  $ttpl->setVariable("TXT_TIME", $this->lng->txt('md_time'));
152 
153  $ttpl->setVariable(
154  "SEL_TLT",
156  $this->getPostVar(),
157  !($val[4] ?? 0),
158  (int) ($val[2] ?? 0),
159  (int) ($val[3] ?? 0),
160  (int) ($val[4] ?? 0),
161  false
162  )
163  );
164  $ttpl->setVariable("TLT_HINT", ($val[4] ?? false) ? '(hh:mm:ss)' : '(hh:mm)');
165 
166  if (!$this->valid) {
167  $ttpl->setCurrentBlock("tlt_not_valid");
168  $ttpl->setVariable("TXT_CURRENT_VAL", $this->lng->txt('meta_current_value'));
169  $ttpl->setVariable("TLT", $this->lom_duration);
170  $ttpl->setVariable("INFO_TLT_NOT_VALID", $this->lng->txt('meta_info_tlt_not_valid'));
171  $ttpl->parseCurrentBlock();
172  }
173 
174  $a_tpl->setCurrentBlock("prop_generic");
175  $a_tpl->setVariable("PROP_GENERIC", $ttpl->get());
176  $a_tpl->parseCurrentBlock();
177  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static makeTimeSelect(string $prefix, bool $short=true, int $hour=0, int $minute=0, int $second=0, bool $a_use_default=true, array $a_further_options=[])
Creates a combination of HTML selects for time inputs.
+ Here is the call graph for this function:

◆ setShowSeconds()

ilTypicalLearningTimeInputGUI::setShowSeconds ( bool  $status)

Definition at line 71 of file class.ilTypicalLearningTimeInputGUI.php.

71  : void
72  {
73  $this->show_seconds = $status;
74  }

◆ setValue()

ilTypicalLearningTimeInputGUI::setValue ( array  $a_value)

Definition at line 49 of file class.ilTypicalLearningTimeInputGUI.php.

Referenced by __construct(), setValueByArray(), and setValueByLOMDuration().

49  : void
50  {
51  $this->value = $a_value;
52  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilTypicalLearningTimeInputGUI::setValueByArray ( array  $a_values)

Definition at line 89 of file class.ilTypicalLearningTimeInputGUI.php.

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

89  : void
90  {
91  $this->setValue($a_values[$this->getPostVar()]);
92  }
+ Here is the call graph for this function:

◆ setValueByLOMDuration()

ilTypicalLearningTimeInputGUI::setValueByLOMDuration ( string  $a_value)

Definition at line 54 of file class.ilTypicalLearningTimeInputGUI.php.

References ilMDUtils\_LOMDurationToArray(), and setValue().

Referenced by ilMDEditorGUI\initQuickEditForm().

54  : void
55  {
56  $this->lom_duration = $a_value;
57  $this->valid = true;
58 
59  $tlt = ilMDUtils::_LOMDurationToArray($a_value);
60 
61  if (!$tlt) {
62  $this->setValue(array(0, 0, 0, 0, 0));
63  if ($a_value !== "") {
64  $this->valid = false;
65  }
66  } else {
67  $this->setValue($tlt);
68  }
69  }
static _LOMDurationToArray(string $a_string)
LOM datatype duration is a string like P2M4DT7H18M2S (2 months 4 days 7 hours 18 minutes 2 seconds) T...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $lom_duration

string ilTypicalLearningTimeInputGUI::$lom_duration = ''
protected

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

◆ $show_seconds

bool ilTypicalLearningTimeInputGUI::$show_seconds = false
protected

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

Referenced by getShowSeconds().

◆ $valid

bool ilTypicalLearningTimeInputGUI::$valid = true
protected

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

◆ $value

array ilTypicalLearningTimeInputGUI::$value
protected

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

Referenced by getValue().

◆ POST_NAME_DAY

const ilTypicalLearningTimeInputGUI::POST_NAME_DAY = 'd'

◆ POST_NAME_HOUR

const ilTypicalLearningTimeInputGUI::POST_NAME_HOUR = 'h'

◆ POST_NAME_MINUTE

const ilTypicalLearningTimeInputGUI::POST_NAME_MINUTE = 'm'

◆ POST_NAME_MONTH

const ilTypicalLearningTimeInputGUI::POST_NAME_MONTH = 'mo'

◆ POST_NAME_SECOND

const ilTypicalLearningTimeInputGUI::POST_NAME_SECOND = 's'

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