1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher; |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
You may not change or alter any portion of this comment or credits |
7
|
|
|
of supporting developers from this source code or any supporting source code |
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
9
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
*/ |
14
|
|
|
/** |
15
|
|
|
* Publisher class |
16
|
|
|
* |
17
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
18
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
19
|
|
|
* @since 1.0 |
20
|
|
|
* @author trabis <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
require_once \dirname(__DIR__) . '/include/common.php'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class FormDateTime |
26
|
|
|
*/ |
27
|
|
|
class FormDateTime extends \XoopsFormElementTray |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @param $caption |
31
|
|
|
* @param $name |
32
|
|
|
* @param int $size |
33
|
|
|
* @param int|bool $value |
34
|
|
|
* @param bool $showtime |
35
|
|
|
* @param bool $formatTimestamp |
36
|
|
|
*/ |
37
|
|
|
public function __construct($caption, $name, $size = 15, $value = 0, $showtime = true, $formatTimestamp = true) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
parent::__construct($caption, ' '); |
40
|
|
|
$value = (int)$value; |
41
|
|
|
$value = ($value > 0) ? $value : \time(); |
42
|
|
|
if ($formatTimestamp) { |
43
|
|
|
if (\is_object($GLOBALS['xoopsUser'])) { |
44
|
|
|
$timeoffset = $GLOBALS['xoopsUser']->getVar('timezone_offset'); |
45
|
|
|
} else { |
46
|
|
|
$timeoffset = null; |
47
|
|
|
} |
48
|
|
|
$value = (int)\formatTimestamp($value, 'U', $timeoffset); |
49
|
|
|
} |
50
|
|
|
$datetime = \getdate($value); |
51
|
|
|
|
52
|
|
|
$this->addElement(new \XoopsFormTextDateSelect('', $name . '[date]', $size, $value)); |
53
|
|
|
$timearray = []; |
54
|
|
|
for ($i = 0; $i < 24; ++$i) { |
55
|
|
|
for ($j = 0; $j < 60; $j += 10) { |
56
|
|
|
$key = ($i * 3600) + ($j * 60); |
57
|
|
|
$timearray[(int)$key] = (0 != $j) ? $i . ':' . $j : $i . ':0' . $j; |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
\ksort($timearray); |
61
|
|
|
$timeselect = new \XoopsFormSelect('', $name . '[time]', $datetime['hours'] * 3600 + 600 * \floor($datetime['minutes'] / 10)); |
62
|
|
|
$timeselect->addOptionArray($timearray); |
63
|
|
|
$this->addElement($timeselect); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.