|
1
|
|
|
<?php declare(strict_types=1); |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Suico; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Extended User Profile |
|
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
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @since 2.3.0 |
|
18
|
|
|
* @author Jan Pedersen |
|
19
|
|
|
* @author Taiwen Jiang <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
|
24
|
|
|
*/ |
|
25
|
|
|
class Category extends \XoopsObject |
|
26
|
|
|
{ |
|
27
|
|
|
public $cat_id; |
|
28
|
|
|
public $cat_title; |
|
29
|
|
|
public $cat_description; |
|
30
|
|
|
public $cat_weight; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct() |
|
33
|
|
|
{ |
|
34
|
|
|
$this->initVar('cat_id', \XOBJ_DTYPE_INT, null, true); |
|
35
|
|
|
$this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX); |
|
36
|
|
|
$this->initVar('cat_description', \XOBJ_DTYPE_TXTAREA); |
|
37
|
|
|
$this->initVar('cat_weight', \XOBJ_DTYPE_INT); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get {@link XoopsThemeForm} for adding/editing categories |
|
42
|
|
|
* |
|
43
|
|
|
* @param mixed $action URL to submit to or false for $_SERVER['REQUEST_URI'] |
|
44
|
|
|
* |
|
45
|
|
|
* @return object |
|
46
|
|
|
*/ |
|
47
|
|
|
public function getForm($action = false) |
|
48
|
|
|
{ |
|
49
|
|
|
if (false === $action) { |
|
50
|
|
|
$action = $_SERVER['REQUEST_URI']; |
|
51
|
|
|
} |
|
52
|
|
|
$title = $this->isNew() ? \sprintf(\_AM_SUICO_ADD, \_AM_SUICO_CATEGORY) : \sprintf(\_AM_SUICO_EDIT, \_AM_SUICO_CATEGORY); |
|
53
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
54
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
|
55
|
|
|
$form->addElement(new \XoopsFormText(\_AM_SUICO_TITLE, 'cat_title', 35, 255, $this->getVar('cat_title'))); |
|
|
|
|
|
|
56
|
|
|
if (!$this->isNew()) { |
|
57
|
|
|
//Load groups |
|
58
|
|
|
$form->addElement(new \XoopsFormHidden('id', $this->getVar('cat_id'))); |
|
|
|
|
|
|
59
|
|
|
} |
|
60
|
|
|
$form->addElement(new \XoopsFormTextArea(\_AM_SUICO_DESCRIPTION, 'cat_description', $this->getVar('cat_description', 'e'))); |
|
|
|
|
|
|
61
|
|
|
$form->addElement(new \XoopsFormText(\_AM_SUICO_WEIGHT, 'cat_weight', 35, 35, $this->getVar('cat_weight', 'e'))); |
|
62
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
63
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
|
64
|
|
|
|
|
65
|
|
|
return $form; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|