|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopsfaq; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits of |
|
7
|
|
|
supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit |
|
9
|
|
|
authors. |
|
10
|
|
|
|
|
11
|
|
|
This program is distributed in the hope that it will be useful, but |
|
12
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
*/ |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* XOOPS FAQ Category & Category Handler Class Definitions |
|
18
|
|
|
* |
|
19
|
|
|
* @package module\xoopsfaq\class |
|
20
|
|
|
* @author John Neill |
|
21
|
|
|
* @author XOOPS Module Development Team |
|
22
|
|
|
* @copyright Copyright (c) 2001-2017 {@link http://xoops.org XOOPS Project} |
|
23
|
|
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU Public License |
|
24
|
|
|
* @since :: 1.23 |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
use XoopsModules\Xoopsfaq; |
|
29
|
|
|
|
|
30
|
|
|
defined('XOOPS_ROOT_PATH') || die('Restricted access'); |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Category |
|
34
|
|
|
* |
|
35
|
|
|
* Class used to handle all of the CRUD actions for FAQ categories |
|
36
|
|
|
* |
|
37
|
|
|
* @author :: John Neill |
|
38
|
|
|
* @copyright:: Copyright (c) 2009 |
|
39
|
|
|
*/ |
|
40
|
|
|
class Category extends \XoopsObject |
|
41
|
|
|
{ |
|
42
|
|
|
/** |
|
43
|
|
|
* Constructor |
|
44
|
|
|
*/ |
|
45
|
|
|
public function __construct() |
|
46
|
|
|
{ |
|
47
|
|
|
parent::__construct(); |
|
48
|
|
|
$this->initVar('category_id', XOBJ_DTYPE_INT, null, false); |
|
49
|
|
|
$this->initVar('category_title', XOBJ_DTYPE_TXTBOX, null, true, 255); |
|
50
|
|
|
$this->initVar('category_order', XOBJ_DTYPE_INT, 0, false); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Display the category title |
|
55
|
|
|
* |
|
56
|
|
|
* @return string display the category title (filtered for display) |
|
57
|
|
|
*/ |
|
58
|
|
|
public function __toString() |
|
59
|
|
|
{ |
|
60
|
|
|
return $this->getVar('category_title', 's'); |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Display the category edit form |
|
65
|
|
|
* |
|
66
|
|
|
* @return void |
|
67
|
|
|
*/ |
|
68
|
|
|
public function displayForm() |
|
69
|
|
|
{ |
|
70
|
|
|
echo $this->renderForm(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Render the category edit form |
|
75
|
|
|
* |
|
76
|
|
|
* @return string HTML entities used to edit the catagory object |
|
77
|
|
|
*/ |
|
78
|
|
|
public function renderForm() |
|
79
|
|
|
{ |
|
80
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
81
|
|
|
$permHelper = new \Xmf\Module\Helper\Permission(); |
|
82
|
|
|
xoops_load('constants', basename(dirname(__DIR__))); |
|
83
|
|
|
|
|
84
|
|
|
$caption = ($this->isNew()) ? _AM_XOOPSFAQ_CREATE_NEW : sprintf(_AM_XOOPSFAQ_MODIFY_ITEM, $this->getVar('category_title')); |
|
85
|
|
|
|
|
86
|
|
|
$form = new \XoopsThemeForm($caption, 'content', xoops_getenv('SCRIPT_NAME'), 'post', true); |
|
87
|
|
|
$form->addElement(new \XoopsFormHidden('op', 'save')); |
|
88
|
|
|
$form->addElement(new \XoopsFormHidden('category_id', $this->getVar('category_id'))); |
|
89
|
|
|
// title |
|
90
|
|
|
$category_title = new \XoopsFormText(_AM_XOOPSFAQ_E_CATEGORY_TITLE, 'category_title', 50, 150, $this->getVar('category_title', 'e')); |
|
91
|
|
|
$category_title->setDescription(_AM_XOOPSFAQ_E_CATEGORY_TITLE_DESC); |
|
92
|
|
|
$form->addElement($category_title, true); |
|
93
|
|
|
// order |
|
94
|
|
|
$category_order = new \XoopsFormText(_AM_XOOPSFAQ_E_CATEGORY_ORDER, 'category_order', 5, 5, $this->getVar('category_order', 'e')); |
|
95
|
|
|
$category_order->setDescription(_AM_XOOPSFAQ_E_CATEGORY_ORDER_DESC); |
|
96
|
|
|
$form->addElement($category_order, false); |
|
97
|
|
|
$form->addElement($permHelper->getGroupSelectFormForItem('viewcat', $this->getVar('category_id'), _AM_XOOPSFAQ_CATEGORY_GROUP_PERMS, '', Xoopsfaq\Constants::INCLUDE_ANNON)); |
|
98
|
|
|
$form->addElement(new \XoopsFormButtonTray('category_form', _SUBMIT, 'submit')); |
|
99
|
|
|
|
|
100
|
|
|
return $form->render(); |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|