ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilDurationInputGUI Class Reference

This class represents a duration (typical hh:mm:ss) property in a property form. More...

+ Inheritance diagram for ilDurationInputGUI:
+ Collaboration diagram for ilDurationInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setDays (int $a_days)
 
 getDays ()
 
 setHours (int $a_hours)
 
 getHours ()
 
 setMinutes (int $a_minutes)
 
 getMinutes ()
 
 setSeconds (int $a_seconds)
 
 setMonths (int $a_months)
 
 getMonths ()
 
 getSeconds ()
 
 setShowMonths (bool $a_show_months)
 
 getShowMonths ()
 
 setShowDays (bool $a_showdays)
 
 getShowDays ()
 
 setShowHours (bool $a_showhours)
 
 getShowHours ()
 
 setShowMinutes (bool $a_showminutes)
 
 getShowMinutes ()
 
 setShowSeconds (bool $a_showseconds)
 
 getShowSeconds ()
 
 setValueByArray (array $a_values)
 
 checkInput ()
 
 getInput ()
 
 insert (ilTemplate $a_tpl)
 
 render ()
 
 getTableFilterHTML ()
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 getValueInSeconds ()
 
 getPostValueForComparison ()
 
 getValueAsArray ()
 
- 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

int $months = 0
 
int $days = 0
 
int $hours = 0
 
int $minutes = 0
 
int $seconds = 0
 
bool $showmonths = false
 
bool $showdays = false
 
bool $showhours = true
 
bool $showminutes = true
 
bool $showseconds = 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...
 
- 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 class represents a duration (typical hh:mm:ss) property in a property form.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 39 of file class.ilDurationInputGUI.php.

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

42  {
43  global $DIC;
44 
45  $this->lng = $DIC->language();
46  parent::__construct($a_title, $a_postvar);
47  $this->setType("duration");
48  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilDurationInputGUI::checkInput ( )

Definition at line 161 of file class.ilDurationInputGUI.php.

161  : bool
162  {
163  return true;
164  }

◆ getDays()

ilDurationInputGUI::getDays ( )

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

References $days.

Referenced by getValueAsArray(), getValueInSeconds(), render(), and serializeData().

55  : int
56  {
57  return $this->days;
58  }
+ Here is the caller graph for this function:

◆ getHours()

ilDurationInputGUI::getHours ( )

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

References $hours.

Referenced by getValueAsArray(), getValueInSeconds(), render(), and serializeData().

65  : int
66  {
67  return $this->hours;
68  }
+ Here is the caller graph for this function:

◆ getInput()

ilDurationInputGUI::getInput ( )

Definition at line 166 of file class.ilDurationInputGUI.php.

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

Referenced by getPostValueForComparison().

166  : array
167  {
168  return $this->strArray($this->getPostVar());
169  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMinutes()

ilDurationInputGUI::getMinutes ( )

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

References $minutes.

Referenced by getValueAsArray(), getValueInSeconds(), render(), and serializeData().

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

◆ getMonths()

ilDurationInputGUI::getMonths ( )

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

References $months.

Referenced by getValueAsArray(), getValueInSeconds(), render(), and serializeData().

90  : int
91  {
92  return $this->months;
93  }
+ Here is the caller graph for this function:

◆ getPostValueForComparison()

ilDurationInputGUI::getPostValueForComparison ( )

Definition at line 354 of file class.ilDurationInputGUI.php.

References getInput(), getShowDays(), getShowHours(), getShowMinutes(), getShowMonths(), getShowSeconds(), and ilFormPropertyGUI\int().

354  : int
355  {
356  $values = $this->getInput();
357  $value_or_zero = fn ($part) => array_key_exists($part, $values ?? []) ? (int) $values[$part] : 0;
358  $value = 0;
359  if ($this->getShowMonths()) {
360  $value += $value_or_zero("MM") * 30 * 24 * 60 * 60;
361  }
362  if ($this->getShowDays()) {
363  $value += $value_or_zero("dd") * 24 * 60 * 60;
364  }
365  if ($this->getShowHours()) {
366  $value += $value_or_zero("hh") * 60 * 60;
367  }
368  if ($this->getShowMinutes()) {
369  $value += $value_or_zero("mm") * 60;
370  }
371  if ($this->getShowSeconds()) {
372  $value += $value_or_zero("ss");
373  }
374  return $value;
375  }
+ Here is the call graph for this function:

◆ getSeconds()

ilDurationInputGUI::getSeconds ( )

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

References $seconds.

Referenced by getValueAsArray(), getValueInSeconds(), render(), and serializeData().

95  : int
96  {
97  return $this->seconds;
98  }
+ Here is the caller graph for this function:

◆ getShowDays()

ilDurationInputGUI::getShowDays ( )

Definition at line 115 of file class.ilDurationInputGUI.php.

References $showdays.

Referenced by getPostValueForComparison(), getValueInSeconds(), and render().

115  : bool
116  {
117  return $this->showdays;
118  }
+ Here is the caller graph for this function:

◆ getShowHours()

ilDurationInputGUI::getShowHours ( )

Definition at line 125 of file class.ilDurationInputGUI.php.

References $showhours.

Referenced by getPostValueForComparison(), getValueInSeconds(), and render().

125  : bool
126  {
127  return $this->showhours;
128  }
+ Here is the caller graph for this function:

◆ getShowMinutes()

ilDurationInputGUI::getShowMinutes ( )

Definition at line 135 of file class.ilDurationInputGUI.php.

References $showminutes.

Referenced by getPostValueForComparison(), getValueInSeconds(), and render().

135  : bool
136  {
137  return $this->showminutes;
138  }
+ Here is the caller graph for this function:

◆ getShowMonths()

ilDurationInputGUI::getShowMonths ( )

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

References $showmonths.

Referenced by getPostValueForComparison(), getValueInSeconds(), and render().

105  : bool
106  {
107  return $this->showmonths;
108  }
+ Here is the caller graph for this function:

◆ getShowSeconds()

ilDurationInputGUI::getShowSeconds ( )

Definition at line 145 of file class.ilDurationInputGUI.php.

References $showseconds.

Referenced by getPostValueForComparison(), getValueInSeconds(), and render().

145  : bool
146  {
147  return $this->showseconds;
148  }
+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilDurationInputGUI::getTableFilterHTML ( )

Definition at line 305 of file class.ilDurationInputGUI.php.

References render().

305  : string
306  {
307  $html = $this->render();
308  return $html;
309  }
+ Here is the call graph for this function:

◆ getValueAsArray()

ilDurationInputGUI::getValueAsArray ( )
Returns
array{MM: int, dd: int, hh: int, mm: int, ss: int}

Definition at line 380 of file class.ilDurationInputGUI.php.

References getDays(), getHours(), getMinutes(), getMonths(), and getSeconds().

380  : array
381  {
382  return [
383  'MM' => $this->getMonths(),
384  'dd' => $this->getDays(),
385  'hh' => $this->getHours(),
386  'mm' => $this->getMinutes(),
387  'ss' => $this->getSeconds()
388  ];
389  }
+ Here is the call graph for this function:

◆ getValueInSeconds()

ilDurationInputGUI::getValueInSeconds ( )

Definition at line 333 of file class.ilDurationInputGUI.php.

References getDays(), getHours(), getMinutes(), getMonths(), getSeconds(), getShowDays(), getShowHours(), getShowMinutes(), getShowMonths(), and getShowSeconds().

333  : int
334  {
335  $value = 0;
336  if ($this->getShowMonths()) {
337  $value += $this->getMonths() * 30 * 24 * 60 * 60;
338  }
339  if ($this->getShowDays()) {
340  $value += $this->getDays() * 24 * 60 * 60;
341  }
342  if ($this->getShowHours()) {
343  $value += $this->getHours() * 60 * 60;
344  }
345  if ($this->getShowMinutes()) {
346  $value += $this->getMinutes() * 60;
347  }
348  if ($this->getShowSeconds()) {
349  $value += $this->getSeconds();
350  }
351  return $value;
352  }
+ Here is the call graph for this function:

◆ insert()

ilDurationInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 171 of file class.ilDurationInputGUI.php.

References ilTemplate\parseCurrentBlock(), render(), ilTemplate\setCurrentBlock(), and HTML_Template_IT\setVariable().

171  : void
172  {
173  $html = $this->render();
174 
175  $a_tpl->setCurrentBlock("prop_generic");
176  $a_tpl->setVariable("PROP_GENERIC", $html);
177  $a_tpl->parseCurrentBlock();
178  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
+ Here is the call graph for this function:

◆ render()

ilDurationInputGUI::render ( )

Definition at line 180 of file class.ilDurationInputGUI.php.

References ilFormPropertyGUI\$lng, ilLegacyFormElementsUtil\formSelect(), getDays(), ilFormPropertyGUI\getDisabled(), getHours(), getMinutes(), getMonths(), ilFormPropertyGUI\getPostVar(), getSeconds(), getShowDays(), getShowHours(), getShowMinutes(), getShowMonths(), getShowSeconds(), and ilLanguage\txt().

Referenced by getTableFilterHTML(), and insert().

180  : string
181  {
182  $lng = $this->lng;
183 
184  $tpl = new ilTemplate("tpl.prop_duration.html", true, true, "components/ILIAS/Form");
185 
186  if ($this->getShowMonths()) {
187  $tpl->setCurrentBlock("dur_months");
188  $tpl->setVariable("TXT_MONTHS", $lng->txt("form_months"));
189  $val = array();
190  for ($i = 0; $i <= 36; $i++) {
191  $val[$i] = $i;
192  }
193  $tpl->setVariable(
194  "SELECT_MONTHS",
196  $this->getMonths(),
197  $this->getPostVar() . "[MM]",
198  $val,
199  false,
200  true,
201  0,
202  '',
203  [],
204  $this->getDisabled()
205  )
206  );
207  $tpl->parseCurrentBlock();
208  }
209  if ($this->getShowDays()) {
210  $tpl->setCurrentBlock("dur_days");
211  $tpl->setVariable("TXT_DAYS", $lng->txt("form_days"));
212  $val = array();
213  for ($i = 0; $i <= 366; $i++) {
214  $val[$i] = $i;
215  }
216  $tpl->setVariable(
217  "SELECT_DAYS",
219  $this->getDays(),
220  $this->getPostVar() . "[dd]",
221  $val,
222  false,
223  true,
224  0,
225  '',
226  [],
227  $this->getDisabled()
228  )
229  );
230  $tpl->parseCurrentBlock();
231  }
232  if ($this->getShowHours()) {
233  $tpl->setCurrentBlock("dur_hours");
234  $tpl->setVariable("TXT_HOURS", $lng->txt("form_hours"));
235  $val = array();
236  for ($i = 0; $i <= 23; $i++) {
237  $val[$i] = $i;
238  }
239  $tpl->setVariable(
240  "SELECT_HOURS",
242  $this->getHours(),
243  $this->getPostVar() . "[hh]",
244  $val,
245  false,
246  true,
247  0,
248  '',
249  [],
250  $this->getDisabled()
251  )
252  );
253  $tpl->parseCurrentBlock();
254  }
255  if ($this->getShowMinutes()) {
256  $tpl->setCurrentBlock("dur_minutes");
257  $tpl->setVariable("TXT_MINUTES", $lng->txt("form_minutes"));
258  $val = array();
259  for ($i = 0; $i <= 59; $i++) {
260  $val[$i] = $i;
261  }
262  $tpl->setVariable(
263  "SELECT_MINUTES",
265  $this->getMinutes(),
266  $this->getPostVar() . "[mm]",
267  $val,
268  false,
269  true,
270  0,
271  '',
272  [],
273  $this->getDisabled()
274  )
275  );
276  $tpl->parseCurrentBlock();
277  }
278  if ($this->getShowSeconds()) {
279  $tpl->setCurrentBlock("dur_seconds");
280  $tpl->setVariable("TXT_SECONDS", $lng->txt("form_seconds"));
281  $val = array();
282  for ($i = 0; $i <= 59; $i++) {
283  $val[$i] = $i;
284  }
285  $tpl->setVariable(
286  "SELECT_SECONDS",
288  $this->getSeconds(),
289  $this->getPostVar() . "[ss]",
290  $val,
291  false,
292  true,
293  0,
294  '',
295  [],
296  $this->getDisabled()
297  )
298  );
299  $tpl->parseCurrentBlock();
300  }
301 
302  return $tpl->get();
303  }
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...
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serializeData()

ilDurationInputGUI::serializeData ( )

Definition at line 311 of file class.ilDurationInputGUI.php.

References $data, getDays(), getHours(), getMinutes(), getMonths(), and getSeconds().

311  : string
312  {
313  $data = array("months" => $this->getMonths(),
314  "days" => $this->getDays(),
315  "hours" => $this->getHours(),
316  "minutes" => $this->getMinutes(),
317  "seconds" => $this->getSeconds());
318 
319  return serialize($data);
320  }
+ Here is the call graph for this function:

◆ setDays()

ilDurationInputGUI::setDays ( int  $a_days)

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

Referenced by setValueByArray(), and unserializeData().

50  : void
51  {
52  $this->days = $a_days;
53  }
+ Here is the caller graph for this function:

◆ setHours()

ilDurationInputGUI::setHours ( int  $a_hours)

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

Referenced by setValueByArray(), and unserializeData().

60  : void
61  {
62  $this->hours = $a_hours;
63  }
+ Here is the caller graph for this function:

◆ setMinutes()

ilDurationInputGUI::setMinutes ( int  $a_minutes)

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

Referenced by setValueByArray(), and unserializeData().

70  : void
71  {
72  $this->minutes = $a_minutes;
73  }
+ Here is the caller graph for this function:

◆ setMonths()

ilDurationInputGUI::setMonths ( int  $a_months)

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

Referenced by setValueByArray(), and unserializeData().

85  : void
86  {
87  $this->months = $a_months;
88  }
+ Here is the caller graph for this function:

◆ setSeconds()

ilDurationInputGUI::setSeconds ( int  $a_seconds)

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

Referenced by setValueByArray(), and unserializeData().

80  : void
81  {
82  $this->seconds = $a_seconds;
83  }
+ Here is the caller graph for this function:

◆ setShowDays()

ilDurationInputGUI::setShowDays ( bool  $a_showdays)

Definition at line 110 of file class.ilDurationInputGUI.php.

110  : void
111  {
112  $this->showdays = $a_showdays;
113  }

◆ setShowHours()

ilDurationInputGUI::setShowHours ( bool  $a_showhours)

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

120  : void
121  {
122  $this->showhours = $a_showhours;
123  }

◆ setShowMinutes()

ilDurationInputGUI::setShowMinutes ( bool  $a_showminutes)

Definition at line 130 of file class.ilDurationInputGUI.php.

Referenced by ilConsultationHoursGUI\initFormSequence().

130  : void
131  {
132  $this->showminutes = $a_showminutes;
133  }
+ Here is the caller graph for this function:

◆ setShowMonths()

ilDurationInputGUI::setShowMonths ( bool  $a_show_months)

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

100  : void
101  {
102  $this->showmonths = $a_show_months;
103  }

◆ setShowSeconds()

ilDurationInputGUI::setShowSeconds ( bool  $a_showseconds)

Definition at line 140 of file class.ilDurationInputGUI.php.

140  : void
141  {
142  $this->showseconds = $a_showseconds;
143  }

◆ setValueByArray()

ilDurationInputGUI::setValueByArray ( array  $a_values)

Definition at line 150 of file class.ilDurationInputGUI.php.

References ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\int(), setDays(), setHours(), setMinutes(), setMonths(), and setSeconds().

150  : void
151  {
152  $values = ($a_values[$this->getPostVar()] ?? []);
153  $value_or_zero = fn ($part) => array_key_exists($part, $values ?? []) ? (int) $values[$part] : 0;
154  $this->setMonths($value_or_zero("MM"));
155  $this->setDays($value_or_zero("dd"));
156  $this->setHours($value_or_zero("hh"));
157  $this->setMinutes($value_or_zero("mm"));
158  $this->setSeconds($value_or_zero("ss"));
159  }
+ Here is the call graph for this function:

◆ unserializeData()

ilDurationInputGUI::unserializeData ( string  $a_data)

Definition at line 322 of file class.ilDurationInputGUI.php.

References $data, setDays(), setHours(), setMinutes(), setMonths(), and setSeconds().

322  : void
323  {
324  $data = unserialize($a_data);
325 
326  $this->setMonths($data["months"]);
327  $this->setDays($data["days"]);
328  $this->setHours($data["hours"]);
329  $this->setMinutes($data["minutes"]);
330  $this->setSeconds($data["seconds"]);
331  }
+ Here is the call graph for this function:

Field Documentation

◆ $days

int ilDurationInputGUI::$days = 0
protected

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

Referenced by getDays().

◆ $hours

int ilDurationInputGUI::$hours = 0
protected

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

Referenced by getHours().

◆ $minutes

int ilDurationInputGUI::$minutes = 0
protected

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

Referenced by getMinutes().

◆ $months

int ilDurationInputGUI::$months = 0
protected

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

Referenced by getMonths().

◆ $seconds

int ilDurationInputGUI::$seconds = 0
protected

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

Referenced by getSeconds().

◆ $showdays

bool ilDurationInputGUI::$showdays = false
protected

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

Referenced by getShowDays().

◆ $showhours

bool ilDurationInputGUI::$showhours = true
protected

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

Referenced by getShowHours().

◆ $showminutes

bool ilDurationInputGUI::$showminutes = true
protected

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

Referenced by getShowMinutes().

◆ $showmonths

bool ilDurationInputGUI::$showmonths = false
protected

Definition at line 33 of file class.ilDurationInputGUI.php.

Referenced by getShowMonths().

◆ $showseconds

bool ilDurationInputGUI::$showseconds = false
protected

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

Referenced by getShowSeconds().


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