1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Songlist; |
4
|
|
|
|
5
|
|
|
use XoopsFormText; |
6
|
|
|
use XoopsObject; |
7
|
|
|
|
8
|
|
|
require_once \dirname(__DIR__) . '/include/songlist.object.php'; |
9
|
|
|
// require_once \dirname(__DIR__) . '/include/songlist.form.php'; |
10
|
|
|
use XoopsModules\Songlist\Form\FormController; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Requests |
14
|
|
|
*/ |
15
|
|
|
class Requests extends XoopsObject |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Requests constructor. |
19
|
|
|
* @param null $fid |
|
|
|
|
20
|
|
|
*/ |
21
|
|
|
public function __construct($fid = null) |
|
|
|
|
22
|
|
|
{ |
23
|
|
|
$this->initVar('rid', \XOBJ_DTYPE_INT, 0, false); |
24
|
|
|
$this->initVar('aid', \XOBJ_DTYPE_INT, 0, false); |
25
|
|
|
$this->initVar('artist', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
26
|
|
|
$this->initVar('album', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
27
|
|
|
$this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
28
|
|
|
$this->initVar('lyrics', \XOBJ_DTYPE_OTHER, null, false); |
29
|
|
|
$this->initVar('uid', \XOBJ_DTYPE_INT, 0, false); |
30
|
|
|
$this->initVar('name', \XOBJ_DTYPE_TXTBOX, null, false, 128); |
31
|
|
|
$this->initVar('email', \XOBJ_DTYPE_TXTBOX, null, false, 255); |
32
|
|
|
$this->initVar('songid', \XOBJ_DTYPE_TXTBOX, null, false, 32); |
33
|
|
|
$this->initVar('sid', \XOBJ_DTYPE_INT, 0, false); |
34
|
|
|
$this->initVar('created', \XOBJ_DTYPE_INT, 0, false); |
35
|
|
|
$this->initVar('updated', \XOBJ_DTYPE_INT, 0, false); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param bool $as_array |
40
|
|
|
* @return array|string |
41
|
|
|
*/ |
42
|
|
|
public function getForm($as_array = false) |
43
|
|
|
{ |
44
|
|
|
return FormController::getFormRequests($this, $as_array); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function toArray(): array |
51
|
|
|
{ |
52
|
|
|
$ret = parent::toArray(); |
53
|
|
|
$form = $this->getForm(true); |
54
|
|
|
$form['songid'] = new XoopsFormText('', $this->getVar('rid') . '[songid]', 11, 32); |
55
|
|
|
foreach ($form as $key => $element) { |
56
|
|
|
$ret['form'][$key] = $element->render(); |
57
|
|
|
} |
58
|
|
|
foreach (['created', 'updated'] as $key) { |
59
|
|
|
if ($this->getVar($key) > 0) { |
60
|
|
|
$ret['form'][$key] = \date(_DATESTRING, $this->getVar($key)); |
61
|
|
|
$ret[$key] = \date(_DATESTRING, $this->getVar($key)); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
return $ret; |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|