ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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

 $tpl
 
 $value
 
- Protected Attributes inherited from ilFormPropertyGUI
 $ctrl
 
 $lng
 
 $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

Reimplemented from ilFormPropertyGUI.

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

29 {
30 global $DIC;
31
32 $this->lng = $DIC->language();
33 $this->tpl = $DIC["tpl"];
34 parent::__construct($a_title, $a_postvar);
35 }
global $DIC
Definition: saml.php:7

References $DIC.

Member Function Documentation

◆ checkInput()

ilScheduleInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

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

88 {
90
91 $data = self::getPostData($this->getPostVar(), false);
92 if (sizeof($data)) {
93 // slots may not overlap
94 foreach ($data as $slot => $days) {
95 if (!$days) {
96 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
97 return false;
98 }
99 $parts = explode("-", $slot);
100 $from = str_replace(":", "", $parts[0]);
101 $to = str_replace(":", "", $parts[1]);
102 if ($from > $to) {
103 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
104 return false;
105 }
106
107 foreach ($data as $rslot => $rdays) {
108 if ($slot != $rslot && $rdays && array_intersect($days, $rdays)) {
109 $rparts = explode("-", $rslot);
110 $rfrom = str_replace(":", "", $rparts[0]);
111 $rto = str_replace(":", "", $rparts[1]);
112
113 if (($rfrom > $from && $rfrom < $to) ||
114 ($rto > $from && $rto < $to) ||
115 ($rfrom < $from && $rto > $to)) {
116 $this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
117 return false;
118 }
119 }
120 }
121 }
122
123 return true;
124 }
125
126 if ($this->getRequired()) {
127 $this->setAlert($lng->txt("msg_input_is_required"));
128 return false;
129 }
130
131 return true;
132 }
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static getPostData($a_post_var, $a_remove_invalid=true)
$from

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

+ Here is the call graph for this function:

◆ getPostData()

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

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

135 {
136 $res = array();
137 for ($loop = 0; $loop < 24; $loop++) {
138 $days = $_POST[$a_post_var . "_days~" . $loop];
140 $_POST[$a_post_var . "_from_hh~" . $loop],
141 $_POST[$a_post_var . "_from_mm~" . $loop]
142 );
143 $to = self::parseTime(
144 $_POST[$a_post_var . "_to_hh~" . $loop],
145 $_POST[$a_post_var . "_to_mm~" . $loop]
146 );
147
148 // only if any part was edited (js based gui)
149 if ($days || $from != "00:00" || $to != "00:00") {
150 $slot = $from . "-" . $to;
151 if ($days) {
152 if (isset($res[$slot])) {
153 $res[$slot] = array_unique(array_merge($res[$slot], $days));
154 } else {
155 $res[$slot] = $days;
156 }
157 } else {
158 $res[$slot] = array();
159 }
160
161 if ($a_remove_invalid && !($days && $from && $to && $from != $to)) {
162 unset($res[$slot]);
163 }
164 }
165 }
166
167 return $res;
168 }
$_POST["username"]
static parseTime($a_hours, $a_minutes)
Parse/normalize incoming time values.
foreach($_POST as $key=> $value) $res

References $_POST, $from, $res, and parseTime().

Referenced by checkInput(), and ilBookingScheduleGUI\formToObject().

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

◆ getValidationFailureMessage()

ilScheduleInputGUI::getValidationFailureMessage ( )

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

68 {
69 return $this->validationFailureMessage;
70 }

◆ getValue()

ilScheduleInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

+ Here is the caller graph for this function:

◆ insert()

ilScheduleInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

254 {
256
257 $tpl->addJavascript("Modules/BookingManager/js/ScheduleInput.js");
258
259 $html = $this->render();
260
261 $a_tpl->setCurrentBlock("prop_generic");
262 $a_tpl->setVariable("PROP_GENERIC", $html);
263 $a_tpl->parseCurrentBlock();
264 }
render($a_mode="")
Render item.
$html
Definition: example_001.php:87

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

+ 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 271 of file class.ilScheduleInputGUI.php.

272 {
273 $hours = (int) $a_hours;
274 $min = (int) $a_minutes;
275 if ($hours > 23 || $min > 59) {
276 return false;
277 }
278 return str_pad($hours, 2, "0", STR_PAD_LEFT) . ":" .
279 str_pad($min, 2, "0", STR_PAD_LEFT);
280 }

Referenced by getPostData().

+ Here is the caller graph for this function:

◆ render()

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

Render item.

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

174 {
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 $def = array(null=>null);
184 }
185
186 $days = array("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su");
187 $row = 0;
188 foreach ($def as $slot => $days_select) {
189 $tpl->setCurrentBlock("days");
190 foreach ($days as $day) {
191 $day_value = strtolower($day);
192
193 $tpl->setVariable("ROW", $row);
194 $tpl->setVariable("ID", $this->getFieldId());
195 $tpl->setVariable("POST_VAR", $this->getPostVar());
196 $tpl->setVariable("DAY", $day_value);
197 $tpl->setVariable("TXT_DAY", $lng->txt($day . "_short"));
198
199 if ($days_select && in_array($day_value, $days_select)) {
200 $tpl->setVariable("DAY_STATUS", " checked=\"checked\"");
201 }
202
203 $tpl->parseCurrentBlock();
204 }
205
206 $tpl->setCurrentBlock("row");
207 $tpl->setVariable("ROW", $row);
208 $tpl->setVariable("ID", $this->getFieldId());
209 $tpl->setVariable("POST_VAR", $this->getPostVar());
210 $tpl->setVariable("TXT_FROM", $lng->txt("cal_from"));
211 $tpl->setVariable("TXT_TO", $lng->txt("cal_until"));
212 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
213 $tpl->setVariable("IMG_MULTI_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
214 $tpl->setVariable("IMG_MULTI_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
215 $tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
216 $tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
217
218 if ($slot) {
219 $parts = explode("-", $slot);
220 $from = explode(":", $parts[0]);
221 $to = explode(":", $parts[1]);
222
223 $tpl->setVariable("FROM_HH_VALUE", $from[0]);
224 $tpl->setVariable("FROM_MM_VALUE", $from[1]);
225 $tpl->setVariable("TO_HH_VALUE", $to[0]);
226 $tpl->setVariable("TO_MM_VALUE", $to[1]);
227 }
228
229 // manage hidden buttons
230 if ($row > 0) {
231 // inline needed because of JS
232 $tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
233 // $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
234 } else {
235 // inline needed because of JS
236 $tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
237 // $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
238 }
239
240 $tpl->parseCurrentBlock();
241
242 $row++;
243 }
244
245 return $tpl->get();
246 }
getFieldId()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
special template class to simplify handling of ITX/PEAR
$def
Definition: croninfo.php:21

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

Referenced by insert().

+ 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 62 of file class.ilScheduleInputGUI.php.

63 {
64 $this->validationFailureMessage = $a_msg;
65 }

◆ setValue()

ilScheduleInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

43 {
44 $this->value = $a_value;
45 }

Referenced by setValueByArray().

+ 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 77 of file class.ilScheduleInputGUI.php.

78 {
79 $this->setValue(self::getPostData($this->getPostVar(), false));
80 }
setValue($a_value)
Set Value.

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

+ Here is the call graph for this function:

Field Documentation

◆ $tpl

ilScheduleInputGUI::$tpl
protected

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

Referenced by insert(), and render().

◆ $value

ilScheduleInputGUI::$value
protected

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

Referenced by getValue().


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