ILIAS  trunk Revision v11.0_alpha-1851-ga8564da6fed
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 ()
 
 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
 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)
 

Static Protected Member Functions

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

Protected Attributes

ILIAS DI UIServices $ui
 
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 = "" 
)

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

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

34  {
35  global $DIC;
36 
37  $this->lng = $DIC->language();
38  $this->tpl = $DIC["tpl"];
39  parent::__construct($a_title, $a_postvar);
40  $this->ui = $DIC->ui();
41  }
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilScheduleInputGUI::checkInput ( )

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

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

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

◆ getInput()

ilScheduleInputGUI::getInput ( )

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

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

120  : array
121  {
122  return $this->getPostData($this->getPostVar());
123  }
getPostData(string $a_post_var, $a_remove_invalid=true)
+ Here is the call graph for this function:

◆ getPostData()

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

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

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

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

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

◆ getValidationFailureMessage()

ilScheduleInputGUI::getValidationFailureMessage ( )

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

References $validationFailureMessage.

58  : string
59  {
61  }

◆ getValue()

ilScheduleInputGUI::getValue ( )

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

References $value.

Referenced by render().

48  : array
49  {
50  return $this->value;
51  }
+ Here is the caller graph for this function:

◆ insert()

ilScheduleInputGUI::insert ( ilTemplate  $a_tpl)

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

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

240  : void
241  {
242  $tpl = $this->tpl;
243 
244  $tpl->addJavascript("assets/js/ScheduleInput.js");
245 
246  $html = $this->render();
247 
248  $a_tpl->setCurrentBlock("prop_generic");
249  $a_tpl->setVariable("PROP_GENERIC", $html);
250  $a_tpl->parseCurrentBlock();
251  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
ilGlobalTemplateInterface $tpl
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:

◆ parseTime()

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

Parse/normalize incoming time values.

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

References ilFormPropertyGUI\int().

259  : string {
260  $hours = (int) $a_hours;
261  $min = (int) $a_minutes;
262  if ($hours > 23) {
263  $hours = 23;
264  $min = 59;
265  }
266  if ($min > 59) {
267  $min = 59;
268  }
269  return str_pad($hours, 2, "0", STR_PAD_LEFT) . ":" .
270  str_pad($min, 2, "0", STR_PAD_LEFT);
271  }
+ Here is the call graph for this function:

◆ render()

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

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

References ilFormPropertyGUI\$lng, $parts, $r, ILIAS\UICore\GlobalTemplate\get(), ilFormPropertyGUI\getFieldId(), ilFormPropertyGUI\getPostVar(), getValue(), ilLanguage\loadLanguageModule(), null, ILIAS\UICore\GlobalTemplate\parseCurrentBlock(), ILIAS\UICore\GlobalTemplate\setCurrentBlock(), ILIAS\UICore\GlobalTemplate\setVariable(), ilLanguage\txt(), and ILIAS\Repository\ui().

Referenced by insert().

164  : string {
165  $lng = $this->lng;
166 
167  $tpl = new ilTemplate("tpl.schedule_input.html", true, true, "components/ILIAS/BookingManager");
168 
169  $lng->loadLanguageModule("dateplaner");
170 
171  $def = $this->getValue();
172  if (!$def) {
173  $def = array(null => null);
174  }
175 
176  $days = array("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su");
177  $row = 0;
178  foreach ($def as $slot => $days_select) {
179  $tpl->setCurrentBlock("days");
180  foreach ($days as $day) {
181  $day_value = strtolower($day);
182 
183  $tpl->setVariable("ROW", $row);
184  $tpl->setVariable("ID", $this->getFieldId());
185  $tpl->setVariable("POST_VAR", $this->getPostVar());
186  $tpl->setVariable("DAY", $day_value);
187  $tpl->setVariable("TXT_DAY", $lng->txt($day . "_short"));
188 
189  if ($days_select && in_array($day_value, $days_select, true)) {
190  $tpl->setVariable("DAY_STATUS", " checked=\"checked\"");
191  }
192 
194  }
195 
196  $add_gl = $this->ui->factory()->symbol()->glyph()->add();
197  $rem_gl = $this->ui->factory()->symbol()->glyph()->remove();
198  $r = $this->ui->renderer();
199  $tpl->setCurrentBlock("row");
200  $tpl->setVariable("ROW", $row);
201  $tpl->setVariable("ID", $this->getFieldId());
202  $tpl->setVariable("POST_VAR", $this->getPostVar());
203  $tpl->setVariable("TXT_FROM", $lng->txt("cal_from"));
204  $tpl->setVariable("TXT_TO", $lng->txt("cal_until"));
205  $tpl->setVariable("IMG_MULTI_ADD", $r->render($add_gl));
206  $tpl->setVariable("IMG_MULTI_REMOVE", $r->render($rem_gl));
207  $tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
208  $tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
209 
210  if ($slot) {
211  $parts = explode("-", $slot);
212  $from = explode(":", $parts[0]);
213  $to = explode(":", $parts[1]);
214 
215  $tpl->setVariable("FROM_HH_VALUE", $from[0]);
216  $tpl->setVariable("FROM_MM_VALUE", $from[1]);
217  $tpl->setVariable("TO_HH_VALUE", $to[0]);
218  $tpl->setVariable("TO_MM_VALUE", $to[1]);
219  }
220 
221  // manage hidden buttons
222  if ($row > 0) {
223  // inline needed because of JS
224  $tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
225  // $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
226  } else {
227  // inline needed because of JS
228  $tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
229  // $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
230  }
231 
233 
234  $row++;
235  }
236 
237  return $tpl->get();
238  }
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
ilGlobalTemplateInterface $tpl
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...
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
loadLanguageModule(string $a_module)
Load language module.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValidationFailureMessage()

ilScheduleInputGUI::setValidationFailureMessage ( string  $a_msg)

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

53  : void
54  {
55  $this->validationFailureMessage = $a_msg;
56  }

◆ setValue()

ilScheduleInputGUI::setValue ( array  $a_value)

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

Referenced by setValueByArray().

43  : void
44  {
45  $this->value = $a_value;
46  }
+ 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 68 of file class.ilScheduleInputGUI.php.

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

68  : void
69  {
70  $this->setValue($this->getPostData($this->getPostVar(), false));
71  }
getPostData(string $a_post_var, $a_remove_invalid=true)
+ Here is the call graph for this function:

Field Documentation

◆ $tpl

ilGlobalTemplateInterface ilScheduleInputGUI::$tpl
protected

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

Referenced by insert().

◆ $ui

ILIAS DI UIServices ilScheduleInputGUI::$ui
protected

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

◆ $validationFailureMessage

string ilScheduleInputGUI::$validationFailureMessage
protected

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

Referenced by getValidationFailureMessage().

◆ $value

array ilScheduleInputGUI::$value = []
protected

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

Referenced by getValue().


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