source: trunk/www/Base/Types/Time.php

Last change on this file was 93, checked in by chronos, 11 years ago
  • Fixed: System variable as parameter to constructors of descendents of Module class.
  • Removed: End PHP mark "?>" from all files.
File size: 1.5 KB
Line 
1<?php
2
3class TypeTime extends TypeBase
4{
5 var $DatabaseCompareOperators = array('Rovno' => '=', 'Nerovno' => '!=', 'Menší' => '<', 'Větší' => '>');
6
7 function OnView($Item)
8 {
9 $TimeParts = explode(':', $Item['Value']);
10
11 $Output = $TimeParts[0].':'.$TimeParts[1].':'.$TimeParts[2];
12 return($Output);
13 }
14
15 function OnEdit($Item)
16 {
17 $TimeParts = explode(':', $Item['Value']);
18
19 // Hour
20 $Output = '<select name="'.$Item['Name'].'-hour">';
21 for($I = 1; $I <= 24; $I++)
22 {
23 if($TimeParts[2] == $I) $Selected = ' selected="1"'; else $Selected = '';
24 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
25 }
26 $Output .= '</select>';
27 // Minute
28 $Output .= '<select name="'.$Item['Name'].'-minute">';
29 for($I = 1; $I <= 60; $I++)
30 {
31 if($TimeParts[1] == $I) $Selected = ' selected="1"'; else $Selected = '';
32 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
33 }
34 $Output .= '</select>';
35 // Second
36 $Output .= '<select name="'.$Item['Name'].'-second">';
37 for($I = 1; $I <= 60; $I++)
38 {
39 if($TimeParts[0] == $I) $Selected = ' selected="1"'; else $Selected = '';
40 $Output .= '<option value="'.$I.'"'.$Selected.'>'.$I.'</option>';
41 }
42 $Output .= '</select>';
43 return($Output);
44 }
45
46 function OnLoad($Item)
47 {
48 return($_POST[$Item['Name'].'-hour'].':'.$_POST[$Item['Name'].'-minute'].':'.$_POST[$Item['Name'].'-second']);
49 }
50
51 function DatabaseEscape($Value)
52 {
53 return('"'.addslashes($Value).'"');
54 }
55}
Note: See TracBrowser for help on using the repository browser.