1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Yogurt; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Extended User Profile |
9
|
|
|
* |
10
|
|
|
* You may not change or alter any portion of this comment or credits |
11
|
|
|
* of supporting developers from this source code or any supporting source code |
12
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16
|
|
|
* |
17
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
18
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/gpl-2.0.html) |
19
|
|
|
* @package profile |
20
|
|
|
* @since 2.3.0 |
21
|
|
|
* @author Jan Pedersen |
22
|
|
|
* @author Taiwen Jiang <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
// defined('XOOPS_ROOT_PATH') || exit("XOOPS root path not defined"); |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @package kernel |
29
|
|
|
* @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
30
|
|
|
*/ |
31
|
|
|
class Category extends \XoopsObject |
32
|
|
|
{ |
33
|
|
|
public function __construct() |
34
|
|
|
{ |
35
|
|
|
$this->initVar('cat_id', \XOBJ_DTYPE_INT, null, true); |
36
|
|
|
|
37
|
|
|
$this->initVar('cat_title', \XOBJ_DTYPE_TXTBOX); |
38
|
|
|
|
39
|
|
|
$this->initVar('cat_description', \XOBJ_DTYPE_TXTAREA); |
40
|
|
|
|
41
|
|
|
$this->initVar('cat_weight', \XOBJ_DTYPE_INT); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Get {@link XoopsThemeForm} for adding/editing categories |
46
|
|
|
* |
47
|
|
|
* @param mixed $action URL to submit to or false for $_SERVER['REQUEST_URI'] |
48
|
|
|
* |
49
|
|
|
* @return object |
50
|
|
|
*/ |
51
|
|
|
|
52
|
|
|
public function getForm($action = false) |
53
|
|
|
{ |
54
|
|
|
if (false === $action) { |
55
|
|
|
$action = $_SERVER['REQUEST_URI']; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
$title = $this->isNew() ? \sprintf(_AM_YOGURT_ADD, _AM_YOGURT_CATEGORY) : \sprintf(_AM_YOGURT_EDIT, _AM_YOGURT_CATEGORY); |
59
|
|
|
|
60
|
|
|
include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
61
|
|
|
|
62
|
|
|
$form = new \XoopsThemeForm($title, 'form', $action, 'post', true); |
63
|
|
|
|
64
|
|
|
$form->addElement(new \XoopsFormText(_AM_YOGURT_TITLE, 'cat_title', 35, 255, $this->getVar('cat_title'))); |
|
|
|
|
65
|
|
|
|
66
|
|
|
if (!$this->isNew()) { |
67
|
|
|
//Load groups |
68
|
|
|
|
69
|
|
|
$form->addElement(new \XoopsFormHidden('id', $this->getVar('cat_id'))); |
|
|
|
|
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
$form->addElement(new \XoopsFormTextArea(_AM_YOGURT_DESCRIPTION, 'cat_description', $this->getVar('cat_description', 'e'))); |
|
|
|
|
73
|
|
|
|
74
|
|
|
$form->addElement(new \XoopsFormText(_AM_YOGURT_WEIGHT, 'cat_weight', 35, 35, $this->getVar('cat_weight', 'e'))); |
75
|
|
|
|
76
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
77
|
|
|
|
78
|
|
|
$form->addElement(new \XoopsFormButton('', 'submit', \_SUBMIT, 'submit')); |
79
|
|
|
|
80
|
|
|
return $form; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|