1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11: /**
12: * Publisher class
13: *
14: * @copyright The XUUPS Project http://sourceforge.net/projects/xuups/
15: * @license GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16: * @package Publisher
17: * @since 1.0
18: * @author trabis <lusopoemas@gmail.com>
19: * @version $Id$
20: */
21:
22: include_once dirname(__DIR__) . '/include/common.php';
23:
24: class PublisherFormDateTime extends Xoops\Form\ElementTray
25: {
26: /**
27: * __construct
28: *
29: * @param string $caption
30: * @param string $name
31: * @param integer $size
32: * @param integer $value
33: */
34: public function __construct($caption, $name, $size = 15, $value = 0)
35: {
36: parent::__construct($caption, ' ');
37: $value = (int)($value);
38: $value = ($value > 0) ? $value : time();
39: $datetime = getdate($value);
40: $this->addElement(new Xoops\Form\DateSelect('', $name . '[date]', $value));
41: $timearray = array();
42: for ($i = 0; $i < 24; ++$i) {
43: for ($j = 0; $j < 60; $j = $j + 10) {
44: $key = ($i * 3600) + ($j * 60);
45: $timearray[$key] = ($j != 0) ? $i . ':' . $j : $i . ':0' . $j;
46: }
47: }
48: ksort($timearray);
49: $timeselect = new Xoops\Form\Select('', $name . '[time]', $datetime['hours'] * 3600 + 600 * floor($datetime['minutes'] / 10));
50: $timeselect->addOptionArray($timearray);
51: $this->addElement($timeselect);
52: }
53: }
54: