source: branches/mvc/Base/Types/Date.php

Last change on this file was 47, checked in by chronos, 10 years ago
  • Odstraněno: Zbytečná PHP ukončovací značka "?>" z konce všech souborů.
File size: 1.6 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/Base.php');
4
5class TypeDate extends TypeBase
6{
7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
8
9 function OnView($Item)
10 {
11 global $MonthNames;
12
13 $Parts = explode('-', $Item['Value']);
14
15 $Output = ($Parts[2] * 1).'.'.$MonthNames[$Parts[1] * 1].' '.$Parts[0];
16 return($Output);
17 }
18
19 function OnEdit($Item)
20 {
21 global $MonthNames;
22
23 $Parts = explode('-', $Item['Value']);
24
25 // Day
26 $Output = '<select name="'.$Item['Name'].'-day">';
27 for($I = 1; $I <= 31; $I++)
28 {
29 if($Parts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';
30 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
31 }
32 $Output .= '</select>';
33 // Month
34 $Output .= '<select name="'.$Item['Name'].'-month">';
35 for($I = 1; $I <= 12; $I++)
36 {
37 if($Parts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';
38 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$MonthNames[$I].'</option>';
39 }
40 $Output .= '</select>';
41 // Year
42 $Output .= '<select name="'.$Item['Name'].'-year">';
43 for($I = 1900; $I < 2100; $I++)
44 {
45 if($Parts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';
46 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
47 }
48 $Output .= '</select>';
49 return($Output);
50 }
51
52 function OnLoad($Item)
53 {
54 return($_POST[$Item['Name'].'-year'].'-'.$_POST[$Item['Name'].'-month'].'-'.$_POST[$Item['Name'].'-day']);
55 }
56
57 function DatabaseEscape($Value)
58 {
59 return('"'.addslashes($Value).'"');
60 }
61}
Note: See TracBrowser for help on using the repository browser.