11<?php
22/* For licensing terms, see /license.txt */
3+
34require_once 'HTML/QuickForm/date.php ' ;
45
56/**
67 * Form element to select a date and hour (with popup datepicker)
8+ *
9+ * Class DatePicker
710 */
811class DatePicker extends HTML_QuickForm_text
912{
10- /**
11- * Constructor
12- */
13- public function DatePicker ($ elementName = null , $ elementLabel = null , $ attributes = null )
14- {
13+ /**
14+ * @param string $elementName
15+ * @param string $elementLabel
16+ * @param array $attributes
17+ */
18+ public function DatePicker ($ elementName = null , $ elementLabel = null , $ attributes = null )
19+ {
1520 if (!isset ($ attributes ['id ' ])) {
1621 $ attributes ['id ' ] = $ elementName ;
1722 }
1823
19- HTML_QuickForm_element::HTML_QuickForm_element ($ elementName , $ elementLabel , $ attributes );
20- $ this ->_appendName = true ;
21- $ this ->_type = 'date_picker ' ;
22- }
23-
24- /**
25- * HTML code to display this datepicker
26- */
27- public function toHtml ()
28- {
29- $ js = $ this ->getElementJS ();
30- return $ js .parent ::toHtml ();
31- }
32-
33- function setValue ($ value )
24+ HTML_QuickForm_element::HTML_QuickForm_element ($ elementName , $ elementLabel , $ attributes );
25+ $ this ->_appendName = true ;
26+ $ this ->_type = 'date_picker ' ;
27+ }
28+
29+ /**
30+ * HTML code to display this datepicker
31+ *
32+ * @return string
33+ */
34+ public function toHtml ()
35+ {
36+ $ js = $ this ->getElementJS ();
37+
38+ return $ js .parent ::toHtml ();
39+ }
40+
41+ /**
42+ * @param string $value
43+ */
44+ public function setValue ($ value )
3445 {
3546 $ value = substr ($ value , 0 , 16 );
3647 $ this ->updateAttributes (
@@ -40,11 +51,12 @@ function setValue($value)
4051 );
4152 }
4253
43- /**
44- * Get the necessary javascript for this datepicker
45- */
46- private function getElementJS ()
47- {
54+ /**
55+ * Get the necessary javascript for this datepicker
56+ * @return string
57+ */
58+ private function getElementJS ()
59+ {
4860 $ js = null ;
4961 $ id = $ this ->getAttribute ('id ' );
5062
@@ -56,6 +68,7 @@ private function getElementJS()
5668 });
5769 </script> " ;
5870
59- return $ js ;
60- }
71+ return $ js ;
72+ }
73+
6174}
0 commit comments