1: | <?php |
2: | |
3: | namespace Zippy\Html\Form; |
4: | |
5: | use Zippy\WebApplication; |
6: | use Zippy\Event; |
7: | use Zippy\Interfaces\ChangeListener; |
8: | use Zippy\Interfaces\EventReceiver; |
9: | use Zippy\Interfaces\Requestable; |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | class Time extends TextInput implements Requestable, ChangeListener |
16: | { |
17: | private $event; |
18: | |
19: | |
20: | public function __construct($id, $value = null) { |
21: | parent::__construct($id); |
22: | $this->setDateTime($value); |
23: | |
24: | } |
25: | |
26: | |
27: | public function RenderImpl() { |
28: | TextInput::RenderImpl(); |
29: | |
30: | $this->setAttribute('type', 'time') ; |
31: | |
32: | |
33: | } |
34: | |
35: | |
36: | |
37: | |
38: | |
39: | public function getDateTime($date) { |
40: | |
41: | $d = date('Y-m-d', $date); |
42: | return strtotime($d . ' '.$this->getText()); |
43: | |
44: | |
45: | } |
46: | |
47: | |
48: | |
49: | |
50: | |
51: | public function setDateTime($t = 0) { |
52: | if ($t > 0) { |
53: | $this->setText(date('H:i', $t)); |
54: | } else { |
55: | $this->setText(""); |
56: | } |
57: | } |
58: | |
59: | |
60: | |
61: | |
62: | public function onChange(EventReceiver $receiver, $handler, $ajax = true) { |
63: | |
64: | $this->event = new Event($receiver, $handler); |
65: | $this->event->isajax = $ajax; |
66: | } |
67: | |
68: | |
69: | |
70: | |
71: | public function OnEvent() { |
72: | if ($this->event != null) { |
73: | $this->event->onEvent($this); |
74: | } |
75: | } |
76: | |
77: | |
78: | |
79: | |
80: | public function RequestHandle() { |
81: | $this->OnEvent(); |
82: | } |
83: | |
84: | } |
85: | |