CategoryForm::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 24
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 13
nc 2
nop 1
dl 0
loc 24
rs 9.8333
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Countdown\Form;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
*/
16
17
/**
18
 * Module: Countdown
19
 *
20
 * @category        Module
21
 * @package         countdown
22
 * @author          XOOPS Development Team <https://xoops.org>
23
 * @copyright       {@link https://xoops.org/ XOOPS Project}
24
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
25
 * @link            https://xoops.org/
26
 * @since           1.0.0
27
 */
28
29
use Xmf\Request;
30
use XoopsModules\Countdown;
31
32
require_once dirname(dirname(__DIR__)) . '/include/common.php';
33
34
$moduleDirName = basename(dirname(dirname(__DIR__)));
35
$helper        = Countdown\Helper::getInstance();
36
$permHelper    = new \Xmf\Module\Helper\Permission();
37
38
xoops_load('XoopsFormLoader');
39
40
/**
41
 * Class CategoryForm
42
 */
43
class CategoryForm extends \XoopsThemeForm
44
{
45
    public $targetObject;
46
47
    /**
48
     * Constructor
49
     *
50
     * @param $target
51
     */
52
    public function __construct($target)
53
    {
54
        global $helper;
55
        $this->targetObject = $target;
56
57
        $title = $this->targetObject->isNew() ? sprintf(_AM_COUNTDOWN_CATEGORY_ADD) : sprintf(_AM_COUNTDOWN_CATEGORY_EDIT);
58
        parent::__construct($title, 'form', xoops_getenv('PHP_SELF'), 'post', true);
59
        $this->setExtra('enctype="multipart/form-data"');
60
61
        //include ID field, it's needed so the module knows if it is a new form or an edited form
62
63
        $hidden = new \XoopsFormHidden('category_id', $this->targetObject->getVar('category_id'));
64
        $this->addElement($hidden);
65
        unset($hidden);
66
67
        // Id
68
        $this->addElement(new \XoopsFormLabel(_AM_COUNTDOWN_CATEGORY_ID, $this->targetObject->getVar('category_id'), 'category_id'));
69
        // Name
70
        $this->addElement(new \XoopsFormText(_AM_COUNTDOWN_CATEGORY_TITLE, 'category_title', 50, 255, $this->targetObject->getVar('category_title')), false);
71
        // Weight
72
        $this->addElement(new \XoopsFormText(_AM_COUNTDOWN_CATEGORY_WEIGHT, 'category_weight', 3, 255, $this->targetObject->getVar('category_weight')), false);
73
74
        $this->addElement(new \XoopsFormHidden('op', 'save'));
75
        $this->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
76
    }
77
}
78