1: <?php
2: /**
3: * Extended User Profile
4: *
5: * You may not change or alter any portion of this comment or credits
6: * of supporting developers from this source code or any supporting source code
7: * which is considered copyrighted (c) material of the original comment or credit authors.
8: * This program is distributed in the hope that it will be useful,
9: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11: *
12: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
13: * @license GNU GPL 2 (https://www.gnu.org/licenses/gpl-2.0.html)
14: * @package profile
15: * @since 2.3.0
16: * @author Jan Pedersen
17: * @author Taiwen Jiang <phppp@users.sourceforge.net>
18: */
19:
20: // defined('XOOPS_ROOT_PATH') || exit("XOOPS root path not defined");
21:
22: /**
23: * @package kernel
24: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
25: */
26: class ProfileCategory extends XoopsObject
27: {
28: public $cat_id;
29: public $cat_title;
30: public $cat_description;
31: public $cat_weight;
32:
33: /**
34: *
35: */
36: public function __construct()
37: {
38: $this->initVar('cat_id', XOBJ_DTYPE_INT, null, true);
39: $this->initVar('cat_title', XOBJ_DTYPE_TXTBOX);
40: $this->initVar('cat_description', XOBJ_DTYPE_TXTAREA);
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: public function getForm($action = false)
52: {
53: if ($action === false) {
54: $action = $_SERVER['REQUEST_URI'];
55: }
56: $title = $this->isNew() ? sprintf(_PROFILE_AM_ADD, _PROFILE_AM_CATEGORY) : sprintf(_PROFILE_AM_EDIT, _PROFILE_AM_CATEGORY);
57:
58: include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
59:
60: $form = new XoopsThemeForm($title, 'form', $action, 'post', true);
61: $form->addElement(new XoopsFormText(_PROFILE_AM_TITLE, 'cat_title', 35, 255, $this->getVar('cat_title')));
62: if (!$this->isNew()) {
63: //Load groups
64: $form->addElement(new XoopsFormHidden('id', $this->getVar('cat_id')));
65: }
66: $form->addElement(new XoopsFormTextArea(_PROFILE_AM_DESCRIPTION, 'cat_description', $this->getVar('cat_description', 'e')));
67: $form->addElement(new XoopsFormText(_PROFILE_AM_WEIGHT, 'cat_weight', 35, 35, $this->getVar('cat_weight', 'e')));
68:
69: $form->addElement(new XoopsFormHidden('op', 'save'));
70: $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
71:
72: return $form;
73: }
74: }
75:
76: /**
77: * @package kernel
78: * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org)
79: */
80: class ProfileCategoryHandler extends XoopsPersistableObjectHandler
81: {
82: /**
83: * @param null|XoopsDatabase $db
84: */
85: public function __construct(XoopsDatabase $db)
86: {
87: parent::__construct($db, 'profile_category', 'profilecategory', 'cat_id', 'cat_title');
88: }
89: }
90: