ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. 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 11 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 26 of file class.ilScheduleInputGUI.php.

27 {
28 global $DIC;
29
30 $this->lng = $DIC->language();
31 $this->tpl = $DIC["tpl"];
32 parent::__construct($a_title, $a_postvar);
33 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$DIC
Definition: xapitoken.php:46

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

+ 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.

Returns
boolean Input ok, true/false

Reimplemented from ilFormPropertyGUI.

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

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

References $data, 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 133 of file class.ilScheduleInputGUI.php.

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

References $_POST, $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 65 of file class.ilScheduleInputGUI.php.

66 {
67 return $this->validationFailureMessage;
68 }

◆ getValue()

ilScheduleInputGUI::getValue ( )

Get Value.

Returns
string Value

Definition at line 50 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 251 of file class.ilScheduleInputGUI.php.

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

References $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 269 of file class.ilScheduleInputGUI.php.

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

Referenced by getPostData().

+ Here is the caller graph for this function:

◆ render()

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

Render item.

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

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

References ilFormPropertyGUI\$lng, $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 60 of file class.ilScheduleInputGUI.php.

61 {
62 $this->validationFailureMessage = $a_msg;
63 }

◆ setValue()

ilScheduleInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

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

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

76 {
77 $this->setValue(self::getPostData($this->getPostVar(), false));
78 }
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 16 of file class.ilScheduleInputGUI.php.

Referenced by insert(), and render().

◆ $value

ilScheduleInputGUI::$value
protected

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

Referenced by getValue().


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