ILIAS  release_8 Revision v8.24
ilScheduleInputGUI 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 ilScheduleInputGUI:
+ Collaboration diagram for ilScheduleInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setValue (array $a_value)
 
 getValue ()
 
 setValidationFailureMessage (string $a_msg)
 
 getValidationFailureMessage ()
 
 setValueByArray (array $a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 getInput ()
 
 getPostData (string $a_post_var, $a_remove_invalid=true)
 
 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...
 

Protected Member Functions

 render (string $a_mode="")
 
- 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)
 

Static Protected Member Functions

static parseTime (string $a_hours, string $a_minutes)
 Parse/normalize incoming time values. More...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
array $value = []
 
string $validationFailureMessage
 
- 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 text property in a property form.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

Definition at line 24 of file class.ilScheduleInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Reimplemented from ilFormPropertyGUI.

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

33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->tpl = $DIC["tpl"];
38 parent::__construct($a_title, $a_postvar);
39 }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilScheduleInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Reimplemented from ilFormPropertyGUI.

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

71 : bool
72 {
74
75 $data = $this->getPostData($this->getPostVar(), false);
76 if (count($data)) {
77 // slots may not overlap
78 foreach ($data as $slot => $days) {
79 if (!$days) {
80 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
81 return false;
82 }
83
84 $parts = explode("-", $slot);
85 $from = str_replace(":", "", $parts[0]);
86 $to = str_replace(":", "", $parts[1]);
87 if ($from >= $to) {
88 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
89 return false;
90 }
91
92 foreach ($data as $rslot => $rdays) {
93 if ($slot != $rslot && $rdays && array_intersect($days, $rdays)) {
94 $rparts = explode("-", $rslot);
95 $rfrom = str_replace(":", "", $rparts[0]);
96 $rto = str_replace(":", "", $rparts[1]);
97
98 if (($rfrom > $from && $rfrom < $to) ||
99 ($rto > $from && $rto < $to) ||
100 ($rfrom < $from && $rto > $to)) {
101 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
102 return false;
103 }
104 }
105 }
106 }
107
108 return true;
109 }
110
111 if ($this->getRequired()) {
112 $this->setAlert($lng->txt("msg_input_is_required"));
113 return false;
114 }
115
116 return true;
117 }
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...
getPostData(string $a_post_var, $a_remove_invalid=true)
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64

References $data, ilFormPropertyGUI\$lng, $parts, getPostData(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFormPropertyGUI\setAlert(), and ilLanguage\txt().

+ Here is the call graph for this function:

◆ getInput()

ilScheduleInputGUI::getInput ( )

Definition at line 119 of file class.ilScheduleInputGUI.php.

119 : array
120 {
121 return $this->getPostData($this->getPostVar());
122 }

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

+ Here is the call graph for this function:

◆ getPostData()

ilScheduleInputGUI::getPostData ( string  $a_post_var,
  $a_remove_invalid = true 
)

Definition at line 124 of file class.ilScheduleInputGUI.php.

127 : array {
128 $res = array();
129 for ($loop = 0; $loop < 240; $loop++) {
130 $days = $this->strArray($a_post_var . "_days~" . $loop);
131 $from = self::parseTime(
132 $this->str($a_post_var . "_from_hh~" . $loop),
133 $this->str($a_post_var . "_from_mm~" . $loop)
134 );
135 $to = self::parseTime(
136 $this->str($a_post_var . "_to_hh~" . $loop),
137 $this->str($a_post_var . "_to_mm~" . $loop)
138 );
139
140 // only if any part was edited (js based gui)
141 if ($days || $from !== "00:00" || $to !== "00:00") {
142 $slot = $from . "-" . $to;
143 if ($days) {
144 if (isset($res[$slot])) {
145 $res[$slot] = array_unique(array_merge($res[$slot], $days));
146 } else {
147 $res[$slot] = $days;
148 }
149 } else {
150 $res[$slot] = array();
151 }
152
153 if ($a_remove_invalid && !($days && $from && $to && $from !== $to)) {
154 unset($res[$slot]);
155 }
156 }
157 }
158 return $res;
159 }
static parseTime(string $a_hours, string $a_minutes)
Parse/normalize incoming time values.
$res
Definition: ltiservices.php:69

References $res, parseTime(), ilFormPropertyGUI\str(), and ilFormPropertyGUI\strArray().

Referenced by checkInput(), getInput(), and setValueByArray().

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

◆ getValidationFailureMessage()

ilScheduleInputGUI::getValidationFailureMessage ( )

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

56 : string
57 {
59 }

References $validationFailureMessage.

◆ getValue()

ilScheduleInputGUI::getValue ( )

Definition at line 46 of file class.ilScheduleInputGUI.php.

46 : array
47 {
48 return $this->value;
49 }

References $value.

◆ insert()

ilScheduleInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 236 of file class.ilScheduleInputGUI.php.

236 : void
237 {
239
240 $tpl->addJavascript("Modules/BookingManager/js/ScheduleInput.js");
241
242 $html = $this->render();
243
244 $a_tpl->setCurrentBlock("prop_generic");
245 $a_tpl->setVariable("PROP_GENERIC", $html);
246 $a_tpl->parseCurrentBlock();
247 }
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
ilGlobalTemplateInterface $tpl
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)

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

+ Here is the call graph for this function:

◆ parseTime()

static ilScheduleInputGUI::parseTime ( string  $a_hours,
string  $a_minutes 
)
staticprotected

Parse/normalize incoming time values.

Definition at line 252 of file class.ilScheduleInputGUI.php.

255 : string {
256 $hours = (int) $a_hours;
257 $min = (int) $a_minutes;
258 if ($hours > 23 || $min > 59) {
259 return false;
260 }
261 return str_pad($hours, 2, "0", STR_PAD_LEFT) . ":" .
262 str_pad($min, 2, "0", STR_PAD_LEFT);
263 }

Referenced by getPostData().

+ Here is the caller graph for this function:

◆ render()

ilScheduleInputGUI::render ( string  $a_mode = "")
protected

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

163 : string {
165
166 $tpl = new ilTemplate("tpl.schedule_input.html", true, true, "Modules/BookingManager");
167
168 $lng->loadLanguageModule("dateplaner");
169
170 $def = $this->getValue();
171 if (!$def) {
172 $def = array(null => null);
173 }
174
175 $days = array("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su");
176 $row = 0;
177 foreach ($def as $slot => $days_select) {
178 $tpl->setCurrentBlock("days");
179 foreach ($days as $day) {
180 $day_value = strtolower($day);
181
182 $tpl->setVariable("ROW", $row);
183 $tpl->setVariable("ID", $this->getFieldId());
184 $tpl->setVariable("POST_VAR", $this->getPostVar());
185 $tpl->setVariable("DAY", $day_value);
186 $tpl->setVariable("TXT_DAY", $lng->txt($day . "_short"));
187
188 if ($days_select && in_array($day_value, $days_select, true)) {
189 $tpl->setVariable("DAY_STATUS", " checked=\"checked\"");
190 }
191
193 }
194
195 $tpl->setCurrentBlock("row");
196 $tpl->setVariable("ROW", $row);
197 $tpl->setVariable("ID", $this->getFieldId());
198 $tpl->setVariable("POST_VAR", $this->getPostVar());
199 $tpl->setVariable("TXT_FROM", $lng->txt("cal_from"));
200 $tpl->setVariable("TXT_TO", $lng->txt("cal_until"));
202 $tpl->setVariable("IMG_MULTI_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
203 $tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
204 $tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
205
206 if ($slot) {
207 $parts = explode("-", $slot);
208 $from = explode(":", $parts[0]);
209 $to = explode(":", $parts[1]);
210
211 $tpl->setVariable("FROM_HH_VALUE", $from[0]);
212 $tpl->setVariable("FROM_MM_VALUE", $from[1]);
213 $tpl->setVariable("TO_HH_VALUE", $to[0]);
214 $tpl->setVariable("TO_MM_VALUE", $to[1]);
215 }
216
217 // manage hidden buttons
218 if ($row > 0) {
219 // inline needed because of JS
220 $tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
221 // $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
222 } else {
223 // inline needed because of JS
224 $tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
225 // $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
226 }
227
229
230 $row++;
231 }
232
233 return $tpl->get();
234 }
static get(string $a_glyph, string $a_text="")
loadLanguageModule(string $a_module)
Load language module.
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.

◆ setValidationFailureMessage()

ilScheduleInputGUI::setValidationFailureMessage ( string  $a_msg)

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

51 : void
52 {
53 $this->validationFailureMessage = $a_msg;
54 }

◆ setValue()

ilScheduleInputGUI::setValue ( array  $a_value)

Definition at line 41 of file class.ilScheduleInputGUI.php.

41 : void
42 {
43 $this->value = $a_value;
44 }

Referenced by setValueByArray().

+ Here is the caller graph for this function:

◆ setValueByArray()

ilScheduleInputGUI::setValueByArray ( array  $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

66 : void
67 {
68 $this->setValue($this->getPostData($this->getPostVar(), false));
69 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $tpl

ilGlobalTemplateInterface ilScheduleInputGUI::$tpl
protected

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

◆ $validationFailureMessage

string ilScheduleInputGUI::$validationFailureMessage
protected

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

Referenced by getValidationFailureMessage().

◆ $value

array ilScheduleInputGUI::$value = []
protected

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

Referenced by getValue().


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