1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Xoops\Form;
13:
14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: class DateSelect extends Text
25: {
26: 27: 28: 29: 30: 31: 32:
33: public function __construct($caption, $name = null, $value = null)
34: {
35: if (is_array($caption)) {
36: parent::__construct($caption);
37: $this->setIfNotSet('size', 15);
38: $this->setIfNotSet('value', 0);
39: $this->set('value', \Xoops\Core\Locale\Time::cleanTime($this->get('value', null)));
40: } else {
41: parent::__construct([]);
42: $this->setCaption($caption);
43: $this->setName($name);
44: $this->set('size', 15);
45: $this->setValue(\Xoops\Core\Locale\Time::cleanTime($value));
46: }
47: }
48:
49: 50: 51: 52: 53:
54: public function render()
55: {
56: $xoops = \Xoops::getInstance();
57:
58: $display_value = \Xoops\Core\Locale\Time::formatDate($this->getValue(false));
59:
60: $dataList = $this->isDatalist();
61: if (!empty($dataList)) {
62: $this->add('list', 'list_' . $this->getName());
63: }
64:
65: $this->themeDecorateElement();
66: $this->suppressRender(['value']);
67: $attributes = $this->renderAttributeString();
68:
69: $xoops->theme()->addBaseStylesheetAssets('@jqueryuicss');
70: $xoops->theme()->addBaseScriptAssets('@jqueryui');
71: \Xoops\Core\Locale\Time::localizeDatePicker();
72:
73: $xoops->theme()->addScript(
74: '',
75: '',
76: ' $(function() { $( "#' . $this->get('id') . '" ).datepicker({' .
77: 'showOn: "button", buttonImageOnly: false, changeYear: true, constrainInput: false, ' .
78: 'buttonImage: "' . $xoops->url('media/xoops/images/icons/calendar.png') .'", ' .
79: 'buttonImageOnly: false, buttonText: "' . \XoopsLocale::A_SELECT . '" }); }); '
80: );
81:
82: return '<input ' . $attributes . 'value="' . $display_value . '" '
83: . $this->getExtra() .' >';
84: }
85: }
86: