1
|
|
|
<?php declare(strict_types=1);
|
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
|
|
|
* @author John Neill
|
20
|
|
|
* @author XOOPS Module Development Team
|
21
|
|
|
* @copyright Copyright (c) 2001-2017 {@link https://xoops.org XOOPS Project}
|
22
|
|
|
* @license https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
|
23
|
|
|
* @since :: 1.23
|
24
|
|
|
*/
|
25
|
|
|
|
26
|
|
|
use Xmf\Module\Helper\Permission;
|
27
|
|
|
use XoopsFormButtonTray;
|
28
|
|
|
use XoopsFormHidden;
|
29
|
|
|
use XoopsFormText;
|
30
|
|
|
use XoopsObject;
|
31
|
|
|
use XoopsThemeForm;
|
32
|
|
|
|
33
|
|
|
/**
|
34
|
|
|
* Category
|
35
|
|
|
*
|
36
|
|
|
* Class used to handle all of the CRUD actions for FAQ categories
|
37
|
|
|
*
|
38
|
|
|
* @author :: John Neill
|
39
|
|
|
* @copyright:: Copyright (c) 2009
|
40
|
|
|
*/
|
41
|
|
|
final class Category extends XoopsObject
|
42
|
|
|
{
|
43
|
|
|
private $category_id;
|
|
|
|
|
44
|
|
|
private $category_title;
|
|
|
|
|
45
|
|
|
private $category_order;
|
|
|
|
|
46
|
|
|
|
47
|
|
|
/**
|
48
|
|
|
* Constructor
|
49
|
|
|
*/
|
50
|
|
|
public function __construct()
|
51
|
|
|
{
|
52
|
|
|
parent::__construct();
|
53
|
|
|
$this->initVar('category_id', \XOBJ_DTYPE_INT, null, false);
|
54
|
|
|
$this->initVar('category_title', \XOBJ_DTYPE_TXTBOX, null, true, 255);
|
55
|
|
|
$this->initVar('category_order', \XOBJ_DTYPE_INT, 0, false);
|
56
|
|
|
}
|
57
|
|
|
|
58
|
|
|
/**
|
59
|
|
|
* Display the category title
|
60
|
|
|
*
|
61
|
|
|
* @return string display the category title (filtered for display)
|
62
|
|
|
*/
|
63
|
|
|
public function __toString()
|
64
|
|
|
{
|
65
|
|
|
return (string)$this->getVar('category_title', 's');
|
66
|
|
|
}
|
67
|
|
|
|
68
|
|
|
/**
|
69
|
|
|
* Display the category edit form
|
70
|
|
|
*/
|
71
|
|
|
public function displayForm(): void
|
72
|
|
|
{
|
73
|
|
|
echo $this->renderForm();
|
74
|
|
|
}
|
75
|
|
|
|
76
|
|
|
/**
|
77
|
|
|
* Render the category edit form
|
78
|
|
|
*
|
79
|
|
|
* @return string HTML entities used to edit the catagory object
|
80
|
|
|
*/
|
81
|
|
|
public function renderForm(): string
|
82
|
|
|
{
|
83
|
|
|
require_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
|
84
|
|
|
$permHelper = new Permission();
|
85
|
|
|
\xoops_load('constants', \basename(\dirname(__DIR__)));
|
86
|
|
|
|
87
|
|
|
$caption = ($this->isNew()) ? \_AM_XOOPSFAQ_CREATE_NEW : \sprintf(\_AM_XOOPSFAQ_MODIFY_ITEM, $this->getVar('category_title'));
|
|
|
|
|
88
|
|
|
|
89
|
|
|
$form = new XoopsThemeForm($caption, 'content', \xoops_getenv('SCRIPT_NAME'), 'post', true);
|
90
|
|
|
$form->addElement(new XoopsFormHidden('op', 'save'));
|
91
|
|
|
$form->addElement(new XoopsFormHidden('category_id', $this->getVar('category_id')));
|
|
|
|
|
92
|
|
|
// title
|
93
|
|
|
$category_title = new XoopsFormText(\_AM_XOOPSFAQ_E_CATEGORY_TITLE, 'category_title', 50, 150, $this->getVar('category_title', 'e'));
|
|
|
|
|
94
|
|
|
$category_title->setDescription(\_AM_XOOPSFAQ_E_CATEGORY_TITLE_DESC);
|
95
|
|
|
$form->addElement($category_title, true);
|
96
|
|
|
// order
|
97
|
|
|
$category_order = new XoopsFormText(\_AM_XOOPSFAQ_E_CATEGORY_ORDER, 'category_order', 5, 5, $this->getVar('category_order', 'e'));
|
98
|
|
|
$category_order->setDescription(\_AM_XOOPSFAQ_E_CATEGORY_ORDER_DESC);
|
99
|
|
|
$form->addElement($category_order, false);
|
100
|
|
|
$form->addElement($permHelper->getGroupSelectFormForItem('viewcat', $this->getVar('category_id'), \_AM_XOOPSFAQ_CATEGORY_GROUP_PERMS, '', Constants::INCLUDE_ANNON));
|
101
|
|
|
$form->addElement(new XoopsFormButtonTray('category_form', \_SUBMIT, 'submit'));
|
102
|
|
|
|
103
|
|
|
return $form->render();
|
104
|
|
|
}
|
105
|
|
|
}
|
106
|
|
|
|