ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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.
 setValue ($a_value)
 Set Value.
 getValue ()
 Get Value.
 setValidationFailureMessage ($a_msg)
 Set message string for validation failure.
 getValidationFailureMessage ()
 setValueByArray ($a_values)
 Set value by array.
 checkInput ()
 Check input, strip slashes etc.
 insert (&$a_tpl)
 Insert property html.
- Public Member Functions inherited from ilFormPropertyGUI
executeCommand ()
 Execute command.
 getType ()
 Get Type.
 setTitle ($a_title)
 Set Title.
 getTitle ()
 Get Title.
 setPostVar ($a_postvar)
 Set Post Variable.
 getPostVar ()
 Get Post Variable.
 getFieldId ()
 Get Post Variable.
 setInfo ($a_info)
 Set Information Text.
 getInfo ()
 Get Information Text.
 setAlert ($a_alert)
 Set Alert Text.
 getAlert ()
 Get Alert Text.
 setRequired ($a_required)
 Set Required.
 getRequired ()
 Get Required.
 setDisabled ($a_disabled)
 Set Disabled.
 getDisabled ()
 Get Disabled.
 setParentForm ($a_parentform)
 Set Parent Form.
 getParentForm ()
 Get Parent Form.
 setParent ($a_val)
 Set Parent GUI object.
 getParent ()
 Get Parent GUI object.
 getSubForm ()
 Get sub form html.
 hideSubForm ()
 Sub form hidden on init?
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders)
 getHiddenTitle ()
 Get hidden title.
 getItemByPostVar ($a_post_var)
 Get item by post var.
 serializeData ()
 serialize data
 unserializeData ($a_data)
 unserialize data
 writeToSession ()
 Write to session.
 clearFromSession ()
 Clear session value.
 readFromSession ()
 Read from session.
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties)
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi.
 getMulti ()
 Get Multi.
 setMultiValues (array $a_values)
 Set multi values.
 getMultiValues ()
 Get multi values.
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g.

Static Public Member Functions

static getPostData ($a_post_var, $a_remove_invalid=true)

Protected Member Functions

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

Static Protected Member Functions

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

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

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFormPropertyGUI.

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

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

Member Function Documentation

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

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

{
global $lng;
$data = self::getPostData($this->getPostVar(), false);
if(sizeof($data))
{
// slots may not overlap
foreach($data as $slot => $days)
{
if(!$days)
{
$this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
return false;
}
$parts = explode("-", $slot);
$from = str_replace(":", "", $parts[0]);
$to = str_replace(":", "", $parts[1]);
foreach($data as $rslot => $rdays)
{
if($slot != $rslot && $rdays && array_intersect($days, $rdays))
{
$rparts = explode("-", $rslot);
$rfrom = str_replace(":", "", $rparts[0]);
$rto = str_replace(":", "", $rparts[1]);
if(($rfrom > $from && $rfrom < $to) ||
($rto > $from && $rto < $to) ||
($rfrom < $from && $rto > $to))
{
$this->setAlert($lng->txt("msg_input_does_not_match_regexp"));
return false;
}
}
}
}
return true;
}
if ($this->getRequired())
{
$this->setAlert($lng->txt("msg_input_is_required"));
return false;
}
return true;
}

+ Here is the call graph for this function:

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

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

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

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

{
$res = array();
for($loop = 0; $loop < 24; $loop++)
{
$days = $_POST[$a_post_var."_days~".$loop];
$from = self::parseTime($_POST[$a_post_var."_from_hh~".$loop],
$_POST[$a_post_var."_from_mm~".$loop]);
$to = self::parseTime($_POST[$a_post_var."_to_hh~".$loop],
$_POST[$a_post_var."_to_mm~".$loop]);
// only if any part was edited (js based gui)
if($days || $from != "00:00" || $to != "00:00")
{
$slot = $from."-".$to;
if($days)
{
if(isset($res[$slot]))
{
$res[$slot] = array_unique(array_merge($res[$slot], $days));
}
else
{
$res[$slot] = $days;
}
}
else
{
$res[$slot] = array();
}
if($a_remove_invalid && !($days && $from && $to && $from != $to))
{
unset($res[$slot]);
}
}
}
return $res;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilScheduleInputGUI::getValidationFailureMessage ( )

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

{
return $this->validationFailureMessage;
}
ilScheduleInputGUI::getValue ( )

Get Value.

Returns
string Value

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

References $value.

Referenced by render().

{
return $this->value;
}

+ Here is the caller graph for this function:

ilScheduleInputGUI::insert ( $a_tpl)

Insert property html.

Returns
int Size

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

References $tpl, and render().

{
global $tpl;
$tpl->addJavascript("Modules/BookingManager/js/ScheduleInput.js");
$html = $this->render();
$a_tpl->setCurrentBlock("prop_generic");
$a_tpl->setVariable("PROP_GENERIC", $html);
$a_tpl->parseCurrentBlock();
}

+ Here is the call graph for this function:

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.

Referenced by getPostData().

{
$hours = (int)$a_hours;
$min = (int)$a_minutes;
if($hours > 23 || $min > 59)
{
return false;
}
return str_pad($hours, 2, "0", STR_PAD_LEFT).":".
str_pad($min, 2, "0", STR_PAD_LEFT);
}

+ Here is the caller graph for this function:

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

Render item.

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

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

Referenced by insert().

{
global $lng;
$tpl = new ilTemplate("tpl.schedule_input.html", true, true, "Modules/BookingManager");
$lng->loadLanguageModule("dateplaner");
$def = $this->getValue();
if(!$def)
{
$def = array(null=>null);
}
$days = array("Mo", "Tu", "We", "Th", "Fr", "Sa", "Su");
$row = 0;
foreach($def as $slot => $days_select)
{
$tpl->setCurrentBlock("days");
foreach($days as $day)
{
$day_value = strtolower($day);
$tpl->setVariable("ROW", $row);
$tpl->setVariable("ID", $this->getFieldId());
$tpl->setVariable("POST_VAR", $this->getPostVar());
$tpl->setVariable("DAY", $day_value);
$tpl->setVariable("TXT_DAY", $lng->txt($day."_short"));
if($days_select && in_array($day_value, $days_select))
{
$tpl->setVariable("DAY_STATUS", " checked=\"checked\"");
}
$tpl->parseCurrentBlock();
}
$tpl->setCurrentBlock("row");
$tpl->setVariable("ROW", $row);
$tpl->setVariable("ID", $this->getFieldId());
$tpl->setVariable("POST_VAR", $this->getPostVar());
$tpl->setVariable("TXT_FROM", $lng->txt("cal_from"));
$tpl->setVariable("TXT_TO", $lng->txt("cal_until"));
include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
$tpl->setVariable("IMG_MULTI_ADD", ilGlyphGUI::get(ilGlyphGUI::ADD));
$tpl->setVariable("IMG_MULTI_REMOVE", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
$tpl->setVariable("TXT_MULTI_ADD", $lng->txt("add"));
$tpl->setVariable("TXT_MULTI_REMOVE", $lng->txt("remove"));
if($slot)
{
$parts = explode("-", $slot);
$from = explode(":", $parts[0]);
$to = explode(":", $parts[1]);
$tpl->setVariable("FROM_HH_VALUE", $from[0]);
$tpl->setVariable("FROM_MM_VALUE", $from[1]);
$tpl->setVariable("TO_HH_VALUE", $to[0]);
$tpl->setVariable("TO_MM_VALUE", $to[1]);
}
// manage hidden buttons
if($row > 0)
{
// inline needed because of JS
$tpl->setVariable("ADD_STYLE", " style=\"display:none\"");
// $tpl->setVariable("ADD_CLASS", "ilNoDisplay");
}
else
{
// inline needed because of JS
$tpl->setVariable("RMV_STYLE", " style=\"display:none\"");
// $tpl->setVariable("RMV_CLASS", "ilNoDisplay");
}
$tpl->parseCurrentBlock();
$row++;
}
return $tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilScheduleInputGUI::setValidationFailureMessage (   $a_msg)

Set message string for validation failure.

Returns
Parameters
string$a_msg

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

{
$this->validationFailureMessage = $a_msg;
}
ilScheduleInputGUI::setValue (   $a_value)

Set Value.

Parameters
string$a_valueValue

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

Referenced by setValueByArray().

{
$this->value = $a_value;
}

+ Here is the caller graph for this function:

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().

{
$this->setValue(self::getPostData($this->getPostVar(), false));
}

+ Here is the call graph for this function:

Field Documentation

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: