ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 ()
 Check input, strip slashes etc. More...
 
 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
Deprecated:
12 This component will be removed with ILIAS 12

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

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

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

43 {
44 global $DIC;
45
46 $this->lng = $DIC->language();
47 parent::__construct($a_title, $a_postvar);
48 $this->setType("duration");
49 }
__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()

ilDurationInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

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

162 : bool
163 {
164 return true;
165 }

◆ getDays()

ilDurationInputGUI::getDays ( )

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

56 : int
57 {
58 return $this->days;
59 }

References $days.

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

+ Here is the caller graph for this function:

◆ getHours()

ilDurationInputGUI::getHours ( )

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

66 : int
67 {
68 return $this->hours;
69 }

References $hours.

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

+ Here is the caller graph for this function:

◆ getInput()

ilDurationInputGUI::getInput ( )

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

167 : array
168 {
169 return $this->strArray($this->getPostVar());
170 }

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

Referenced by getPostValueForComparison().

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

◆ getMinutes()

ilDurationInputGUI::getMinutes ( )

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

76 : int
77 {
78 return $this->minutes;
79 }

References $minutes.

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

+ Here is the caller graph for this function:

◆ getMonths()

ilDurationInputGUI::getMonths ( )

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

91 : int
92 {
93 return $this->months;
94 }

References $months.

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

+ Here is the caller graph for this function:

◆ getPostValueForComparison()

ilDurationInputGUI::getPostValueForComparison ( )

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

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

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

+ Here is the call graph for this function:

◆ getSeconds()

ilDurationInputGUI::getSeconds ( )

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

96 : int
97 {
98 return $this->seconds;
99 }

References $seconds.

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

+ Here is the caller graph for this function:

◆ getShowDays()

ilDurationInputGUI::getShowDays ( )

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

116 : bool
117 {
118 return $this->showdays;
119 }

References $showdays.

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

+ Here is the caller graph for this function:

◆ getShowHours()

ilDurationInputGUI::getShowHours ( )

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

126 : bool
127 {
128 return $this->showhours;
129 }

References $showhours.

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

+ Here is the caller graph for this function:

◆ getShowMinutes()

ilDurationInputGUI::getShowMinutes ( )

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

136 : bool
137 {
138 return $this->showminutes;
139 }

References $showminutes.

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

+ Here is the caller graph for this function:

◆ getShowMonths()

ilDurationInputGUI::getShowMonths ( )

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

106 : bool
107 {
108 return $this->showmonths;
109 }

References $showmonths.

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

+ Here is the caller graph for this function:

◆ getShowSeconds()

ilDurationInputGUI::getShowSeconds ( )

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

146 : bool
147 {
148 return $this->showseconds;
149 }

References $showseconds.

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

+ Here is the caller graph for this function:

◆ getTableFilterHTML()

ilDurationInputGUI::getTableFilterHTML ( )

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

306 : string
307 {
308 $html = $this->render();
309 return $html;
310 }

References render().

+ 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 381 of file class.ilDurationInputGUI.php.

381 : array
382 {
383 return [
384 'MM' => $this->getMonths(),
385 'dd' => $this->getDays(),
386 'hh' => $this->getHours(),
387 'mm' => $this->getMinutes(),
388 'ss' => $this->getSeconds()
389 ];
390 }

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

+ Here is the call graph for this function:

◆ getValueInSeconds()

ilDurationInputGUI::getValueInSeconds ( )

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

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

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

+ Here is the call graph for this function:

◆ insert()

ilDurationInputGUI::insert ( ilTemplate  $a_tpl)

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

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

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

+ Here is the call graph for this function:

◆ render()

ilDurationInputGUI::render ( )

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

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

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().

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

◆ serializeData()

ilDurationInputGUI::serializeData ( )

Reimplemented from ilFormPropertyGUI.

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

312 : string
313 {
314 $data = array("months" => $this->getMonths(),
315 "days" => $this->getDays(),
316 "hours" => $this->getHours(),
317 "minutes" => $this->getMinutes(),
318 "seconds" => $this->getSeconds());
319
320 return serialize($data);
321 }

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

+ Here is the call graph for this function:

◆ setDays()

ilDurationInputGUI::setDays ( int  $a_days)

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

51 : void
52 {
53 $this->days = $a_days;
54 }

Referenced by setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setHours()

ilDurationInputGUI::setHours ( int  $a_hours)

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

61 : void
62 {
63 $this->hours = $a_hours;
64 }

Referenced by setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setMinutes()

ilDurationInputGUI::setMinutes ( int  $a_minutes)

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

71 : void
72 {
73 $this->minutes = $a_minutes;
74 }

Referenced by setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setMonths()

ilDurationInputGUI::setMonths ( int  $a_months)

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

86 : void
87 {
88 $this->months = $a_months;
89 }

Referenced by setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setSeconds()

ilDurationInputGUI::setSeconds ( int  $a_seconds)

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

81 : void
82 {
83 $this->seconds = $a_seconds;
84 }

Referenced by setValueByArray(), and unserializeData().

+ Here is the caller graph for this function:

◆ setShowDays()

ilDurationInputGUI::setShowDays ( bool  $a_showdays)

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

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

◆ setShowHours()

ilDurationInputGUI::setShowHours ( bool  $a_showhours)

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

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

◆ setShowMinutes()

ilDurationInputGUI::setShowMinutes ( bool  $a_showminutes)

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

131 : void
132 {
133 $this->showminutes = $a_showminutes;
134 }

◆ setShowMonths()

ilDurationInputGUI::setShowMonths ( bool  $a_show_months)

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

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

◆ setShowSeconds()

ilDurationInputGUI::setShowSeconds ( bool  $a_showseconds)

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

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

◆ setValueByArray()

ilDurationInputGUI::setValueByArray ( array  $a_values)

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

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

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

+ Here is the call graph for this function:

◆ unserializeData()

ilDurationInputGUI::unserializeData ( string  $a_data)

Reimplemented from ilFormPropertyGUI.

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

323 : void
324 {
325 $data = unserialize($a_data);
326
327 $this->setMonths($data["months"]);
328 $this->setDays($data["days"]);
329 $this->setHours($data["hours"]);
330 $this->setMinutes($data["minutes"]);
331 $this->setSeconds($data["seconds"]);
332 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $days

int ilDurationInputGUI::$days = 0
protected

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

Referenced by getDays().

◆ $hours

int ilDurationInputGUI::$hours = 0
protected

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

Referenced by getHours().

◆ $minutes

int ilDurationInputGUI::$minutes = 0
protected

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

Referenced by getMinutes().

◆ $months

int ilDurationInputGUI::$months = 0
protected

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

Referenced by getMonths().

◆ $seconds

int ilDurationInputGUI::$seconds = 0
protected

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

Referenced by getSeconds().

◆ $showdays

bool ilDurationInputGUI::$showdays = false
protected

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

Referenced by getShowDays().

◆ $showhours

bool ilDurationInputGUI::$showhours = true
protected

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

Referenced by getShowHours().

◆ $showminutes

bool ilDurationInputGUI::$showminutes = true
protected

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

Referenced by getShowMinutes().

◆ $showmonths

bool ilDurationInputGUI::$showmonths = false
protected

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

Referenced by getShowMonths().

◆ $showseconds

bool ilDurationInputGUI::$showseconds = false
protected

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

Referenced by getShowSeconds().


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