ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilBirthdayInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Form/classes/class.ilDateTimeInputGUI.php");
5
14{
20 function setValueByArray($a_values)
21 {
22 if (isset($a_values[$this->getPostVar()]["date"]) && is_array($a_values[$this->getPostVar()]["date"]))
23 {
24 if (@checkdate($a_values[$this->getPostVar()]["date"]['m'], $a_values[$this->getPostVar()]["date"]['d'], $a_values[$this->getPostVar()]["date"]['y']))
25 {
26 parent::setValueByArray($a_values);
27 return;
28 }
29 }
30 elseif(is_array($a_values[$this->getPostVar()]) && isset($a_values[$this->getPostVar()]["date"]) && !is_array($a_values[$this->getPostVar()]["date"]))
31 {
32 $this->setDate(new ilDate($a_values[$this->getPostVar()]["date"], IL_CAL_DATE));
33 }
34 else
35 {
36 if (!is_array($a_values[$this->getPostVar()]) && strlen($a_values[$this->getPostVar()]))
37 {
38 $this->setDate(new ilDate($a_values[$this->getPostVar()], IL_CAL_DATE));
39 }
40 else
41 {
42 $this->date = null;
43 }
44 }
45 foreach($this->getSubItems() as $item)
46 {
47 $item->setValueByArray($a_values);
48 }
49 }
50
56 function checkInput()
57 {
58 global $lng,$ilUser;
59
60 $ok = true;
61
62 $_POST[$this->getPostVar()]["date"]["y"] =
63 ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["y"]);
64 $_POST[$this->getPostVar()]["date"]["m"] =
65 ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["m"]);
66 $_POST[$this->getPostVar()]["date"]["d"] =
67 ilUtil::stripSlashes($_POST[$this->getPostVar()]["date"]["d"]);
68 $_POST[$this->getPostVar()]["time"]["h"] =
69 ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["h"]);
70 $_POST[$this->getPostVar()]["time"]["m"] =
71 ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["m"]);
72 $_POST[$this->getPostVar()]["time"]["s"] =
73 ilUtil::stripSlashes($_POST[$this->getPostVar()]["time"]["s"]);
74
75 // verify date
76
77 $dt['year'] = (int) $_POST[$this->getPostVar()]['date']['y'];
78 $dt['mon'] = (int) $_POST[$this->getPostVar()]['date']['m'];
79 $dt['mday'] = (int) $_POST[$this->getPostVar()]['date']['d'];
80 $dt['hours'] = (int) $_POST[$this->getPostVar()]['time']['h'];
81 $dt['minutes'] = (int) $_POST[$this->getPostVar()]['time']['m'];
82 $dt['seconds'] = (int) $_POST[$this->getPostVar()]['time']['s'];
83 if ($dt['year'] == 0 && $dt['mon'] == 0 && $dt['mday'] == 0 && $this->getRequired())
84 {
85 $this->date = null;
86 $this->setAlert($lng->txt("msg_input_is_required"));
87 return false;
88 }
89 else if ($dt['year'] == 0 && $dt['mon'] == 0 && $dt['mday'] == 0)
90 {
91 $this->date = null;
92 $_POST[$this->getPostVar()]['date'] = ""; // #10413
93 }
94 else
95 {
96 if (!checkdate((int)$dt['mon'], (int)$dt['mday'], (int)$dt['year']))
97 {
98 $this->date = null;
99 $this->setAlert($lng->txt("exc_date_not_valid"));
100 return false;
101 }
102 $date = new ilDateTime($dt,IL_CAL_FKT_GETDATE,$ilUser->getTimeZone());
103 $_POST[$this->getPostVar()]['date'] = $date->get(IL_CAL_FKT_DATE,'Y-m-d',$ilUser->getTimeZone());
104 $this->setDate($date);
105 }
106 return true;
107 }
108
113 function render()
114 {
115 global $lng,$ilUser;
116
117 $tpl = new ilTemplate("tpl.prop_datetime.html", true, true, "Services/Form");
118 if (is_object($this->getDate()))
119 {
120 $date_info = $this->getDate()->get(IL_CAL_FKT_GETDATE,'','UTC');
121 }
122 else
123 {
124 $date_info = array(
125 'year' => $_POST[$this->getPostVar()]['date']['y'],
126 'mon' => $_POST[$this->getPostVar()]['date']['m'],
127 'mday' => $_POST[$this->getPostVar()]['date']['d']
128 );
129 }
130
131 $lng->loadLanguageModule("jscalendar");
132 require_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
134
135 if(strlen($this->getActivationPostVar()))
136 {
137 $tpl->setCurrentBlock('prop_date_activation');
138 $tpl->setVariable('CHECK_ENABLED_DATE',$this->getActivationPostVar());
139 $tpl->setVariable('TXT_DATE_ENABLED',$this->activation_title);
140 $tpl->setVariable('CHECKED_ENABLED',$this->activation_checked ? 'checked="checked"' : '');
141 $tpl->setVariable('CHECKED_DISABLED',$this->getDisabled() ? 'disabled="disabled" ' : '');
142 $tpl->parseCurrentBlock();
143 }
144
145 $tpl->setCurrentBlock("prop_date");
146 include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
147 $tpl->setVariable("IMG_DATE_CALENDAR", ilGlyphGUI::get(ilGlyphGUI::CALENDAR, $lng->txt("open_calendar")));
148 $tpl->setVariable("DATE_ID", $this->getPostVar());
149 $tpl->setVariable("INPUT_FIELDS_DATE", $this->getPostVar()."[date]");
150 include_once './Services/Calendar/classes/class.ilCalendarUserSettings.php';
151 $tpl->setVariable('DATE_FIRST_DAY',ilCalendarUserSettings::_getInstance()->getWeekStart());
152 $tpl->setVariable("DATE_SELECT",
153 ilUtil::makeDateSelect($this->getPostVar()."[date]", $date_info['year'], $date_info['mon'], $date_info['mday'],
154 $this->startyear,true,array('disabled' => $this->getDisabled()), $this->getShowEmpty()));
155 $tpl->parseCurrentBlock();
156
157 return $tpl->get();
158 }
159}
160?>
global $tpl
Definition: ilias.php:8
const IL_CAL_FKT_GETDATE
const IL_CAL_DATE
const IL_CAL_FKT_DATE
This class represents a text property in a property form.
render()
Insert property html.
checkInput()
Check input, strip slashes etc.
setValueByArray($a_values)
Set value by array.
static _getInstance()
get instance for logged in user
static initJSCalendar()
Init Javascript Calendar.
This class represents a date/time property in a property form.
getShowEmpty()
Get Show Empty Information.
setDate(ilDateTime $a_date=NULL)
set date E.g $dt_form->setDate(new ilDateTime(time(),IL_CAL_UTC)); or $dt_form->setDate(new ilDateTim...
getActivationPostVar()
Get activation post var.
getDate()
Get Date, yyyy-mm-dd.
@classDescription Date and time handling
Class for single dates.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static get($a_glyph, $a_text="")
Get glyph html.
special template class to simplify handling of ITX/PEAR
static makeDateSelect($prefix, $year="", $month="", $day="", $startyear="", $a_long_month=true, $a_further_options=array(), $emptyoption=false)
Creates a combination of HTML selects for date inputs.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
$_POST['username']
Definition: cron.php:12
global $lng
Definition: privfeed.php:40
global $ilUser
Definition: imgupload.php:15