source: branches/mvc/Base/Types/Time.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 TypeTime extends TypeBase
6{
7 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
8
9 function OnView($Item)
10 {
11 $TimeParts = explode(':', $Item['Value']);
12
13 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2];
14 return($Output);
15 }
16
17 function OnEdit($Item)
18 {
19 $TimeParts = explode(':', $Item['Value']);
20
21 // Hour
22 $Output = '<select name="'.$Item['Name'].'-hour">';
23 for($I = 1; $I <= 24; $I++)
24 {
25 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';
26 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
27 }
28 $Output .= '</select>';
29 // Minute
30 $Output .= '<select name="'.$Item['Name'].'-minute">';
31 for($I = 1; $I <= 60; $I++)
32 {
33 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';
34 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
35 }
36 $Output .= '</select>';
37 // Second
38 $Output .= '<select name="'.$Item['Name'].'-second">';
39 for($I = 1; $I <= 60; $I++)
40 {
41 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';
42 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
43 }
44 $Output .= '</select>';
45 return($Output);
46 }
47
48 function OnLoad($Item)
49 {
50 return($_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']);
51 }
52
53 function DatabaseEscape($Value)
54 {
55 return('"'.addslashes($Value).'"');
56 }
57}
Note: See TracBrowser for help on using the repository browser.