ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilADTDateSearchUtil Class Reference

Date form handling helper. More...

+ Collaboration diagram for ilADTDateSearchUtil:

Static Public Member Functions

static handleSelectInputPost ($a_mode, $a_post)
 Import select post data. More...
 
static handleTextInputPost ($a_mode, $a_post)
 Import text input post data. More...
 

Data Fields

const MODE_DATE = 1
 
const MODE_DATETIME = 2
 

Detailed Description

Date form handling helper.

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.ilADTDateSearchUtil.php.

Member Function Documentation

◆ handleSelectInputPost()

static ilADTDateSearchUtil::handleSelectInputPost (   $a_mode,
  $a_post 
)
static

Import select post data.

Parameters
int$a_mode
array$a_post
Returns
int timestamp

Definition at line 25 of file class.ilADTDateSearchUtil.php.

26 {
27 if(!is_array($a_post))
28 {
29 return;
30 }
31
32 if($a_mode == self::MODE_DATE)
33 {
34 return mktime(12, 0, 0,
35 $a_post["date"]["m"],
36 $a_post["date"]["d"],
37 $a_post["date"]["y"]);
38 }
39 else
40 {
41 return mktime(
42 $a_post["time"]["h"],
43 $a_post["time"]["m"],
44 1,
45 $a_post["date"]["m"],
46 $a_post["date"]["d"],
47 $a_post["date"]["y"]);
48 }
49 }

Referenced by ilADTDateSearchBridgeRange\importFromPost(), ilADTDateSearchBridgeSingle\importFromPost(), ilADTDateTimeSearchBridgeRange\importFromPost(), and ilADTDateTimeSearchBridgeSingle\importFromPost().

+ Here is the caller graph for this function:

◆ handleTextInputPost()

static ilADTDateSearchUtil::handleTextInputPost (   $a_mode,
  $a_post 
)
static

Import text input post data.

Parameters
int$a_mode
array$a_post
Returns
int timestamp

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

59 {
60 global $ilUser;
61
62 // see ilDateTimeInputGUI::checkInput()
63
64 $a_post["date"] = ilUtil::stripSlashes($a_post["date"]);
65
66 if($a_post["date"])
67 {
68 switch($ilUser->getDateFormat())
69 {
71 $date = explode(".", $a_post["date"]);
72 $dt['mday'] = (int)$date[0];
73 $dt['mon'] = (int)$date[1];
74 $dt['year'] = (int)$date[2];
75 break;
76
78 $date = explode("-", $a_post["date"]);
79 $dt['mday'] = (int)$date[2];
80 $dt['mon'] = (int)$date[1];
81 $dt['year'] = (int)$date[0];
82 break;
83
85 $date = explode("/", $a_post["date"]);
86 $dt['mday'] = (int)$date[1];
87 $dt['mon'] = (int)$date[0];
88 $dt['year'] = (int)$date[2];
89 break;
90 }
91
92 if($a_mode == self::MODE_DATE)
93 {
94 return mktime(12, 0, 0, $dt["mon"], $dt["mday"], $dt["year"]);
95 }
96
97
98 $a_post["time"] = ilUtil::stripSlashes($a_post["time"]);
99
100 if($a_post["time"])
101 {
102 if($ilUser->getTimeFormat() == ilCalendarSettings::TIME_FORMAT_12)
103 {
104 $seconds = "";
105 if(preg_match("/([0-9]{1,2})\s*:\s*([0-9]{1,2})\s*".$seconds."(am|pm)/", trim(strtolower($a_post["time"])), $matches))
106 {
107 $dt['hours'] = (int)$matches[1];
108 $dt['minutes'] = (int)$matches[2];
109 if($seconds)
110 {
111 $dt['seconds'] = (int)$time[2];
112 $ampm = $matches[4];
113 }
114 else
115 {
116 $dt['seconds'] = 0;
117 $ampm = $matches[3];
118 }
119 if($dt['hours'] == 12)
120 {
121 if($ampm == "am")
122 {
123 $dt['hours'] = 0;
124 }
125 }
126 else if($ampm == "pm")
127 {
128 $dt['hours'] += 12;
129 }
130 }
131 }
132 else
133 {
134 $time = explode(":", $a_post["time"]);
135 $dt['hours'] = (int)$time[0];
136 $dt['minutes'] = (int)$time[1];
137 $dt['seconds'] = (int)$time[2];
138 }
139 }
140
141 return mktime($dt["hours"], $dt["minutes"], $dt["seconds"], $dt["mon"], $dt["mday"], $dt["year"]);
142 }
143 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilUser
Definition: imgupload.php:15

References $ilUser, ilCalendarSettings\DATE_FORMAT_DMY, ilCalendarSettings\DATE_FORMAT_MDY, ilCalendarSettings\DATE_FORMAT_YMD, ilUtil\stripSlashes(), and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ilADTDateSearchBridgeRange\importFromPost(), ilADTDateSearchBridgeSingle\importFromPost(), ilADTDateTimeSearchBridgeRange\importFromPost(), and ilADTDateTimeSearchBridgeSingle\importFromPost().

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

Field Documentation

◆ MODE_DATE

const ilADTDateSearchUtil::MODE_DATE = 1

◆ MODE_DATETIME

const ilADTDateSearchUtil::MODE_DATETIME = 2

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