ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilScheduleInputGUI Class Reference

This class represents a text property in a property form. More...

+ Inheritance diagram for ilScheduleInputGUI:
+ Collaboration diagram for ilScheduleInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setValidationFailureMessage ($a_msg)
 Set message string for validation failure. More...
 
 getValidationFailureMessage ()
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert (&$a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 

Static Public Member Functions

static getPostData ($a_post_var, $a_remove_invalid=true)
 
- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 

Protected Member Functions

 render ($a_mode="")
 Render item. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Static Protected Member Functions

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

Protected Attributes

 $value
 
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Detailed Description

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

24  {
25  parent::__construct($a_title, $a_postvar);
26  }

Member Function Documentation

◆ checkInput()

ilScheduleInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

References $data, $lng, ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), and ilFormPropertyGUI\setAlert().

79  {
80  global $lng;
81 
82  $data = self::getPostData($this->getPostVar(), false);
83  if(sizeof($data))
84  {
85  // slots may not overlap
86  foreach($data as $slot => $days)
87  {
88  if(!$days)
89  {
90  $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
91  return false;
92  }
93 
94  $parts = explode("-", $slot);
95  $from = str_replace(":", "", $parts[0]);
96  $to = str_replace(":", "", $parts[1]);
97 
98  foreach($data as $rslot => $rdays)
99  {
100  if($slot != $rslot && $rdays && array_intersect($days, $rdays))
101  {
102  $rparts = explode("-", $rslot);
103  $rfrom = str_replace(":", "", $rparts[0]);
104  $rto = str_replace(":", "", $rparts[1]);
105 
106  if(($rfrom > $from && $rfrom < $to) ||
107  ($rto > $from && $rto < $to) ||
108  ($rfrom < $from && $rto > $to))
109  {
110  $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
111  return false;
112  }
113  }
114  }
115  }
116 
117  return true;
118  }
119 
120  if ($this->getRequired())
121  {
122  $this->setAlert($lng->txt("msg_input_is_required"));
123  return false;
124  }
125 
126  return true;
127  }
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getPostData()

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

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

References $_POST, $res, and array.

Referenced by ilBookingScheduleGUI\formToObject().

130  {
131  $res = array();
132  for($loop = 0; $loop < 24; $loop++)
133  {
134  $days = $_POST[$a_post_var."_days~".$loop];
135  $from = self::parseTime($_POST[$a_post_var."_from_hh~".$loop],
136  $_POST[$a_post_var."_from_mm~".$loop]);
137  $to = self::parseTime($_POST[$a_post_var."_to_hh~".$loop],
138  $_POST[$a_post_var."_to_mm~".$loop]);
139 
140  // only if any part was edited (js based gui)
141  if($days || $from != "00:00" || $to != "00:00")
142  {
143  $slot = $from."-".$to;
144  if($days)
145  {
146  if(isset($res[$slot]))
147  {
148  $res[$slot] = array_unique(array_merge($res[$slot], $days));
149  }
150  else
151  {
152  $res[$slot] = $days;
153  }
154  }
155  else
156  {
157  $res[$slot] = array();
158  }
159 
160  if($a_remove_invalid && !($days && $from && $to && $from != $to))
161  {
162  unset($res[$slot]);
163  }
164  }
165  }
166 
167  return $res;
168  }
Create styles array
The data for the language used.
$_POST["username"]
+ Here is the caller graph for this function:

◆ getValidationFailureMessage()

ilScheduleInputGUI::getValidationFailureMessage ( )

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

59  {
60  return $this->validationFailureMessage;
61  }

◆ getValue()

ilScheduleInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

44  {
45  return $this->value;
46  }
+ Here is the caller graph for this function:

◆ insert()

ilScheduleInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

References $html, $tpl, and render().

262  {
263  global $tpl;
264 
265  $tpl->addJavascript("Modules/BookingManager/js/ScheduleInput.js");
266 
267  $html = $this->render();
268 
269  $a_tpl->setCurrentBlock("prop_generic");
270  $a_tpl->setVariable("PROP_GENERIC", $html);
271  $a_tpl->parseCurrentBlock();
272  }
global $tpl
Definition: ilias.php:8
render($a_mode="")
Render item.
$html
Definition: example_001.php:87
+ Here is the call graph for this function:

◆ parseTime()

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

Parse/normalize incoming time values.

Parameters
string$a_hours
string$a_minutes

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

280  {
281  $hours = (int)$a_hours;
282  $min = (int)$a_minutes;
283  if($hours > 23 || $min > 59)
284  {
285  return false;
286  }
287  return str_pad($hours, 2, "0", STR_PAD_LEFT).":".
288  str_pad($min, 2, "0", STR_PAD_LEFT);
289  }

◆ render()

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

Render item.

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

References $lng, $row, $tpl, ilGlyphGUI\ADD, array, ilGlyphGUI\get(), ilFormPropertyGUI\getFieldId(), ilFormPropertyGUI\getPostVar(), getValue(), and ilGlyphGUI\REMOVE.

Referenced by insert().

174  {
175  global $lng;
176 
177  $tpl = new ilTemplate("tpl.schedule_input.html", true, true, "Modules/BookingManager");
178 
179  $lng->loadLanguageModule("dateplaner");
180 
181  $def = $this->getValue();
182  if(!$def)
183  {
184  $def = array(null=>null);
185  }
186 
187  $days = array("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su");
188  $row = 0;
189  foreach($def as $slot => $days_select)
190  {
191  $tpl->setCurrentBlock("days");
192  foreach($days as $day)
193  {
194  $day_value = strtolower($day);
195 
196  $tpl->setVariable("ROW", $row);
197  $tpl->setVariable("ID", $this->getFieldId());
198  $tpl->setVariable("POST_VAR", $this->getPostVar());
199  $tpl->setVariable("DAY", $day_value);
200  $tpl->setVariable("TXT_DAY", $lng->txt($day."_short"));
201 
202  if($days_select && in_array($day_value, $days_select))
203  {
204  $tpl->setVariable("DAY_STATUS", " checked=\"checked\"");
205  }
206 
207  $tpl->parseCurrentBlock();
208  }
209 
210  $tpl->setCurrentBlock("row");
211  $tpl->setVariable("ROW", $row);
212  $tpl->setVariable("ID", $this->getFieldId());
213  $tpl->setVariable("POST_VAR", $this->getPostVar());
214  $tpl->setVariable("TXT_FROM", $lng->txt("cal_from"));
215  $tpl->setVariable("TXT_TO", $lng->txt("cal_until"));
216  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
217  $tpl->setVariable("IMG_MULTI_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
218  $tpl->setVariable("IMG_MULTI_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
219  $tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
220  $tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
221 
222  if($slot)
223  {
224  $parts = explode("-", $slot);
225  $from = explode(":", $parts[0]);
226  $to = explode(":", $parts[1]);
227 
228  $tpl->setVariable("FROM_HH_VALUE", $from[0]);
229  $tpl->setVariable("FROM_MM_VALUE", $from[1]);
230  $tpl->setVariable("TO_HH_VALUE", $to[0]);
231  $tpl->setVariable("TO_MM_VALUE", $to[1]);
232  }
233 
234  // manage hidden buttons
235  if($row > 0)
236  {
237  // inline needed because of JS
238  $tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
239  // $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
240  }
241  else
242  {
243  // inline needed because of JS
244  $tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
245  // $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
246  }
247 
248  $tpl->parseCurrentBlock();
249 
250  $row++;
251  }
252 
253  return $tpl->get();
254  }
getPostVar()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
global $tpl
Definition: ilias.php:8
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setValidationFailureMessage()

ilScheduleInputGUI::setValidationFailureMessage (   $a_msg)

Set message string for validation failure.

Returns
Parameters
string$a_msg

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

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

◆ setValue()

ilScheduleInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

34  {
35  $this->value = $a_value;
36  }
+ Here is the caller graph for this function:

◆ setValueByArray()

ilScheduleInputGUI::setValueByArray (   $a_values)

Set value by array.

Parameters
array$a_valuesvalue array

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

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

69  {
70  $this->setValue(self::getPostData($this->getPostVar(), false));
71  }
setValue($a_value)
Set Value.
getPostVar()
Get Post Variable.
+ Here is the call graph for this function:

Field Documentation

◆ $value

ilScheduleInputGUI::$value
protected

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

Referenced by getValue().


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