-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutil.php
More file actions
56 lines (50 loc) · 1.6 KB
/
util.php
File metadata and controls
56 lines (50 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
function makeDateSelector($name, $value, $id=null, $class=null, $attributes = array())
{
$attr = '';
foreach($attributes as $key => $val) {
$val = htmlEncode($val);
$attr .= "$key='$val' ";
}
$id_str = $id?'id="'.htmlEncode($id).'"':'';
if ($class == null) $class = "";
$class_str = 'class="datepickerinput '.htmlEncode($class).'"';
return "<input type='text' $id_str $class_str size='16' name='".htmlEncode($name)."' value='".htmlEncode($value)."' {$attr} />\n";
}
function makeHidden($name, $value, $id=null, $class=null, $attributes = array())
{
$attr = '';
foreach($attributes as $key => $val) {
$val = htmlEncode($val);
$attr .= "$key='$val' ";
}
$id_str = $id?'id="'.htmlEncode($id).'"':'';
if ($class == null) $class = "";
$class_str = 'class="'.htmlEncode($class).'"';
$res = '';
if (is_array($value)) {
foreach ($value as $part) {
$res .= "<input type='hidden' $id_str $class_str name='".htmlEncode($name)."[]' value='".htmlEncode($part)."' {$attr} />\n";
}
} else {
$res .= "<input type='hidden' $id_str $class_str name='".htmlEncode($name)."' value='".htmlEncode($value)."' {$attr} />\n";
}
return $res;
}
function formatDate($tm)
{
return date('Y-m-d', $tm);
}
function today()
{
$now = time();
$year = date('Y', $now);
$month = date('m', $now);
$day = date('d', $now);
return mktime(12, 0, 0, $month, $day, $year);
}
function parseDate($date)
{
list($year, $month, $day) = explode('-',$date);
return mktime(12, 0, 0, $month, $day, $year);
}