1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: 14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class Form_Element_DatePicker extends Form_Element_Date
24: {
25: private $icon;
26: private $timepicker;
27: 28: 29: 30: 31: 32: 33:
34: public function __construct($nom,$form)
35: {
36: parent::__construct($nom,$form);
37: $this->attrs['id'] = $nom;
38: $this->icon = 'pub/struct/picto/clock.png';
39: $this->timePicker = false;
40: }
41:
42: 43: 44: 45: 46: 47: 48:
49: public function icon($icon)
50: {
51: $this->icon = $icon;
52: return $this;
53: }
54:
55: public function setTimepicker($bool)
56: {
57: $this->timepicker = $bool;
58: return $this;
59: }
60: 61: 62: 63: 64: 65:
66: public function __toString()
67: {
68:
69: $field = parent::__toString();
70: $timepickerOption = '';
71: if($this->timepicker)
72: $timepickerOption = 'showTime:true,
73: constrainInput:true,
74: time24h:true';
75:
76: $this->form->javascript .= '$(function() {
77: $.datepicker.setDefaults($.extend({
78: showMonthAfterYear: false,
79: showOn:\'both\',
80: duration:\'\',
81: buttonImage:\''.$this->icon.'\',
82: buttonImageOnly:true}';
83: if($this->format == 'fr')
84: $this->form->javascript.=',$.datepicker.regional[\'fr\']';
85: $this->form->javascript.='
86: ));
87: $("#'.$this->attrs['id'].'").datepicker({'.$timepickerOption.'});
88: });
89: ';
90: $error = '';
91: return $field;
92: }
93: }
94: ?>