ILIAS  release_4-4 Revision
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...
 

Static Public Member Functions

static getPostData ($a_post_var, $a_remove_invalid=true)
 

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.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
global $lng
Definition: privfeed.php:40
+ 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, and $res.

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  }
$_POST['username']
Definition: cron.php:12
+ 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 260 of file class.ilScheduleInputGUI.php.

References $tpl, and render().

261  {
262  global $tpl;
263 
264  $tpl->addJavascript("Modules/BookingManager/js/ScheduleInput.js");
265 
266  $html = $this->render();
267 
268  $a_tpl->setCurrentBlock("prop_generic");
269  $a_tpl->setVariable("PROP_GENERIC", $html);
270  $a_tpl->parseCurrentBlock();
271  }
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
render($a_mode="")
Render item.
+ 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 278 of file class.ilScheduleInputGUI.php.

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

◆ render()

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

Render item.

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

References $lng, $row, $tpl, ilFormPropertyGUI\getFieldId(), ilUtil\getImagePath(), ilFormPropertyGUI\getPostVar(), and getValue().

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  $tpl->setVariable("IMG_MULTI_ADD", ilUtil::getImagePath('edit_add.png'));
217  $tpl->setVariable("IMG_MULTI_REMOVE", ilUtil::getImagePath('edit_remove.png'));
218  $tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
219  $tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
220 
221  if($slot)
222  {
223  $parts = explode("-", $slot);
224  $from = explode(":", $parts[0]);
225  $to = explode(":", $parts[1]);
226 
227  $tpl->setVariable("FROM_HH_VALUE", $from[0]);
228  $tpl->setVariable("FROM_MM_VALUE", $from[1]);
229  $tpl->setVariable("TO_HH_VALUE", $to[0]);
230  $tpl->setVariable("TO_MM_VALUE", $to[1]);
231  }
232 
233  // manage hidden buttons
234  if($row > 0)
235  {
236  // inline needed because of JS
237  $tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
238  // $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
239  }
240  else
241  {
242  // inline needed because of JS
243  $tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
244  // $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
245  }
246 
247  $tpl->parseCurrentBlock();
248 
249  $row++;
250  }
251 
252  return $tpl->get();
253  }
getPostVar()
Get Post Variable.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
+ 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: