|
1
|
|
|
<?php |
|
|
|
|
|
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Module: SmartFAQ |
|
5
|
|
|
* Author: The SmartFactory <www.smartfactory.ca> |
|
6
|
|
|
* Licence: GNU |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
use XoopsModules\Smartfaq; |
|
10
|
|
|
|
|
11
|
|
|
require_once __DIR__ . '/admin_header.php'; |
|
12
|
|
|
|
|
13
|
|
|
/** @var Smartfaq\Helper $helper */ |
|
14
|
|
|
$helper = Smartfaq\Helper::getInstance(); |
|
15
|
|
|
|
|
16
|
|
|
// Creating the category handler object |
|
17
|
|
|
/** @var \XoopsModules\Smartfaq\CategoryHandler $categoryHandler */ |
|
18
|
|
|
$categoryHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Category'); |
|
19
|
|
|
|
|
20
|
|
|
$op = ''; |
|
21
|
|
|
|
|
22
|
|
|
if (isset($_GET['op'])) { |
|
23
|
|
|
$op = $_GET['op']; |
|
24
|
|
|
} |
|
25
|
|
|
if (isset($_POST['op'])) { |
|
26
|
|
|
$op = $_POST['op']; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
// Where do we start? |
|
30
|
|
|
$startcategory = \Xmf\Request::getInt('startcategory', 0, 'GET'); |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param XoopsObject $categoryObj |
|
|
|
|
|
|
34
|
|
|
* @param int $level |
|
35
|
|
|
*/ |
|
36
|
|
|
function displayCategory($categoryObj, $level = 0) |
|
37
|
|
|
{ |
|
38
|
|
|
global $xoopsModule, $categoryHandler, $pathIcon16; |
|
|
|
|
|
|
39
|
|
|
$description = $categoryObj->description(); |
|
40
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
|
|
|
|
|
|
41
|
|
|
if (strlen($description) >= 100) { |
|
42
|
|
|
$description = substr($description, 0, 100 - 1) . '...'; |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
$modify = "<a href='category.php?op=mod&categoryid=" . $categoryObj->categoryid() . "'><img src='" . $pathIcon16 . '/edit.png' . "' title='" . _AM_SF_EDITCOL . "' alt='" . _AM_SF_EDITCOL . "'></a>"; |
|
46
|
|
|
$delete = "<a href='category.php?op=del&categoryid=" . $categoryObj->categoryid() . "'><img src='" . $pathIcon16 . '/delete.png' . "' title='" . _AM_SF_DELETECOL . "' alt='" . _AM_SF_DELETECOL . "'></a>"; |
|
47
|
|
|
|
|
48
|
|
|
$spaces = ''; |
|
49
|
|
|
for ($j = 0; $j < $level; ++$j) { |
|
50
|
|
|
$spaces .= ' '; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
echo '<tr>'; |
|
54
|
|
|
echo "<td class='even' align='lefet'>" |
|
55
|
|
|
. $spaces |
|
56
|
|
|
. "<a href='" |
|
57
|
|
|
. XOOPS_URL |
|
|
|
|
|
|
58
|
|
|
. '/modules/' |
|
59
|
|
|
. $xoopsModule->dirname() |
|
60
|
|
|
. '/category.php?categoryid=' |
|
61
|
|
|
. $categoryObj->categoryid() |
|
62
|
|
|
. "'><img src='" |
|
63
|
|
|
. XOOPS_URL |
|
64
|
|
|
. "/modules/smartfaq/assets/images/icon/subcat.gif' alt=''> " |
|
65
|
|
|
. $categoryObj->name() |
|
66
|
|
|
. '</a></td>'; |
|
67
|
|
|
echo "<td class='even' align='left'>" . $description . '</td>'; |
|
68
|
|
|
echo "<td class='even' align='center'>" . $categoryObj->weight() . '</td>'; |
|
69
|
|
|
echo "<td class='even' align='center'> $modify $delete </td>"; |
|
70
|
|
|
echo '</tr>'; |
|
71
|
|
|
$subCategoriesObj =& $categoryHandler->getCategories(0, 0, $categoryObj->categoryid()); |
|
72
|
|
|
if (count($subCategoriesObj) > 0) { |
|
73
|
|
|
++$level; |
|
74
|
|
|
foreach ($subCategoriesObj as $key => $thiscat) { |
|
75
|
|
|
displayCategory($thiscat, $level); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
unset($categoryObj); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @param bool $showmenu |
|
83
|
|
|
* @param int $categoryid |
|
84
|
|
|
*/ |
|
85
|
|
|
function editcat($showmenu = false, $categoryid = 0) |
|
|
|
|
|
|
86
|
|
|
{ |
|
87
|
|
|
//$moderators = array(); // just to define the variable |
|
|
|
|
|
|
88
|
|
|
//$allmods = array(); |
|
|
|
|
|
|
89
|
|
|
$startfaq = \Xmf\Request::getInt('startfaq', 0, 'GET'); |
|
|
|
|
|
|
90
|
|
|
global $categoryHandler, $xoopsUser, $xoopsUser, $myts, $xoopsConfig, $xoopsDB, $modify, $xoopsModule, $_GET; |
|
|
|
|
|
|
91
|
|
|
/** @var Smartfaq\Helper $helper */ |
|
92
|
|
|
$helper = Smartfaq\Helper::getInstance(); |
|
|
|
|
|
|
93
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
|
|
|
|
|
|
94
|
|
|
|
|
95
|
|
|
// Creating the faq handler object |
|
96
|
|
|
/** @var \XoopsModules\Smartfaq\FaqHandler $faqHandler */ |
|
97
|
|
|
$faqHandler = \XoopsModules\Smartfaq\Helper::getInstance()->getHandler('Faq'); |
|
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
echo '<script type="text/javascript" src="funcs.js"></script>'; |
|
100
|
|
|
echo '<style>'; |
|
101
|
|
|
echo '<!-- '; |
|
102
|
|
|
echo 'select { width: 130px; }'; |
|
103
|
|
|
echo '-->'; |
|
104
|
|
|
echo '</style>'; |
|
105
|
|
|
// If there is a parameter, and the id exists, retrieve data: we're editing a category |
|
106
|
|
|
if (0 != $categoryid) { |
|
107
|
|
|
|
|
108
|
|
|
// Creating the category object for the selected category |
|
109
|
|
|
$categoryObj = new \XoopsModules\Smartfaq\Category($categoryid); |
|
110
|
|
|
|
|
111
|
|
|
echo "<br>\n"; |
|
112
|
|
|
if ($categoryObj->notLoaded()) { |
|
113
|
|
|
redirect_header('category.php', 1, _AM_SF_NOCOLTOEDIT); |
|
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon'); |
|
116
|
|
|
echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a> " . _AM_SF_EDITCOL . '</h3>'; |
|
|
|
|
|
|
117
|
|
|
echo "<div id='bottomtable'>"; |
|
118
|
|
|
} else { |
|
119
|
|
|
$categoryObj = $categoryHandler->create(); |
|
120
|
|
|
echo "<br>\n"; |
|
121
|
|
|
Smartfaq\Utility::collapsableBar('bottomtable', 'bottomtableicon'); |
|
122
|
|
|
echo "<img id='bottomtableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a> " . _AM_SF_CATEGORY_CREATE . '</h3>'; |
|
123
|
|
|
echo "<div id='bottomtable'>"; |
|
124
|
|
|
} |
|
125
|
|
|
// Start category form |
|
126
|
|
|
$sform = new \XoopsThemeForm(_AM_SF_CATEGORY, 'op', xoops_getenv('PHP_SELF'), 'post', true); |
|
|
|
|
|
|
127
|
|
|
$sform->setExtra('enctype="multipart/form-data"'); |
|
128
|
|
|
|
|
129
|
|
|
// Name |
|
130
|
|
|
$sform->addElement(new \XoopsFormText(_AM_SF_CATEGORY, 'name', 50, 255, $categoryObj->name('e')), true); |
|
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
// Parent Category |
|
133
|
|
|
$mytree = new Smartfaq\Tree($xoopsDB->prefix('smartfaq_categories'), 'categoryid', 'parentid'); |
|
134
|
|
|
ob_start(); |
|
135
|
|
|
$mytree->makeMySelBox('name', 'weight', $categoryObj->parentid(), 1, 'parentid'); |
|
136
|
|
|
|
|
137
|
|
|
//makeMySelBox($title,$order="",$preset_id=0, $none=0, $sel_name="", $onchange="") |
|
|
|
|
|
|
138
|
|
|
$sform->addElement(new \XoopsFormLabel(_AM_SF_PARENT_CATEGORY_EXP, ob_get_contents())); |
|
|
|
|
|
|
139
|
|
|
ob_end_clean(); |
|
140
|
|
|
|
|
141
|
|
|
/* $mytree = new Smartfaq\Tree($xoopsDB->prefix("smartfaq_categories"), "categoryid" , "parentid"); |
|
|
|
|
|
|
142
|
|
|
ob_start(); |
|
143
|
|
|
$sform->addElement(new \XoopsFormHidden('categoryid', $categoryObj->categoryid())); |
|
144
|
|
|
$mytree->makeMySelBox("name", "weight", $categoryObj->categoryid()); |
|
145
|
|
|
$sform->addElement(new \XoopsFormLabel(_AM_SF_CATEGORY_FAQ, ob_get_contents())); |
|
146
|
|
|
ob_end_clean(); |
|
147
|
|
|
*/ |
|
148
|
|
|
|
|
149
|
|
|
// Decsription |
|
150
|
|
|
$sform->addElement(new \XoopsFormTextArea(_AM_SF_COLDESCRIPT, 'description', $categoryObj->description('e'), 7, 60)); |
|
|
|
|
|
|
151
|
|
|
|
|
152
|
|
|
// Weight |
|
153
|
|
|
$sform->addElement(new \XoopsFormText(_AM_SF_COLPOSIT, 'weight', 4, 4, $categoryObj->weight())); |
|
154
|
|
|
|
|
155
|
|
|
// READ PERMISSIONS |
|
156
|
|
|
$memberHandler = xoops_getHandler('member'); |
|
|
|
|
|
|
157
|
|
|
$group_list = $memberHandler->getGroupList(); |
|
158
|
|
|
|
|
159
|
|
|
$groups_read_checkbox = new \XoopsFormCheckBox(_AM_SF_PERMISSIONS_CAT_READ, 'groups_read[]', $categoryObj->getGroups_read()); |
|
|
|
|
|
|
160
|
|
|
foreach ($group_list as $group_id => $group_name) { |
|
161
|
|
|
if (XOOPS_GROUP_ADMIN != $group_id) { |
|
|
|
|
|
|
162
|
|
|
$groups_read_checkbox->addOption($group_id, $group_name); |
|
163
|
|
|
} |
|
164
|
|
|
} |
|
165
|
|
|
$sform->addElement($groups_read_checkbox); |
|
166
|
|
|
// Apply permissions on all faqs |
|
167
|
|
|
$addapplyall_radio = new \XoopsFormRadioYN(_AM_SF_PERMISSIONS_APPLY_ON_FAQS, 'applyall', 0, ' ' . _AM_SF_YES . '', ' ' . _AM_SF_NO . ''); |
|
|
|
|
|
|
168
|
|
|
$sform->addElement($addapplyall_radio); |
|
169
|
|
|
// MODERATORS |
|
170
|
|
|
//$moderators_tray = new \XoopsFormElementTray(_AM_SF_MODERATORS_DEF, ''); |
|
|
|
|
|
|
171
|
|
|
|
|
172
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
|
|
|
|
|
173
|
|
|
|
|
174
|
|
|
/*$gpermHandler = xoops_getHandler('groupperm'); |
|
|
|
|
|
|
175
|
|
|
$mod_perms = $gpermHandler->getGroupIds('category_moderation', $categoryid, $module_id); |
|
176
|
|
|
|
|
177
|
|
|
$moderators_select = new \XoopsFormSelect('', 'moderators', $moderators, 5, true); |
|
178
|
|
|
$moderators_tray->addElement($moderators_select); |
|
179
|
|
|
|
|
180
|
|
|
$butt_mngmods = new \XoopsFormButton('', '', 'Manage mods', 'button'); |
|
181
|
|
|
$butt_mngmods->setExtra('onclick="javascript:small_window(\'pop.php\', 370, 350);"'); |
|
182
|
|
|
$moderators_tray->addElement($butt_mngmods); |
|
183
|
|
|
|
|
184
|
|
|
$butt_delmod = new \XoopsFormButton('', '', 'Delete mod', 'button'); |
|
185
|
|
|
$butt_delmod->setExtra('onclick="javascript:deleteSelectedItemsFromList(this.form.elements[\'moderators[]\']);"'); |
|
186
|
|
|
$moderators_tray->addElement($butt_delmod); |
|
187
|
|
|
|
|
188
|
|
|
$sform->addElement($moderators_tray); |
|
189
|
|
|
*/ |
|
190
|
|
|
$sform->addElement(new \XoopsFormHidden('categoryid', $categoryid)); |
|
|
|
|
|
|
191
|
|
|
|
|
192
|
|
|
// Action buttons tray |
|
193
|
|
|
$button_tray = new \XoopsFormElementTray('', ''); |
|
|
|
|
|
|
194
|
|
|
|
|
195
|
|
|
/*for ($i = 0, $iMax = count($moderators); $i < $iMax; ++$i) { |
|
|
|
|
|
|
196
|
|
|
$allmods[] = $moderators[$i]; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
$hiddenmods = new \XoopsFormHidden('allmods', $allmods); |
|
200
|
|
|
$button_tray->addElement($hiddenmods); |
|
201
|
|
|
*/ |
|
202
|
|
|
$hidden = new \XoopsFormHidden('op', 'addcategory'); |
|
203
|
|
|
$button_tray->addElement($hidden); |
|
204
|
|
|
// No ID for category -- then it's new category, button says 'Create' |
|
205
|
|
|
if (!$categoryid) { |
|
206
|
|
|
$butt_create = new \XoopsFormButton('', '', _AM_SF_CREATE, 'submit'); |
|
|
|
|
|
|
207
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
|
208
|
|
|
$button_tray->addElement($butt_create); |
|
209
|
|
|
|
|
210
|
|
|
$butt_clear = new \XoopsFormButton('', '', _AM_SF_CLEAR, 'reset'); |
|
211
|
|
|
$button_tray->addElement($butt_clear); |
|
212
|
|
|
|
|
213
|
|
|
$butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); |
|
214
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
215
|
|
|
$button_tray->addElement($butt_cancel); |
|
216
|
|
|
} else { |
|
217
|
|
|
// button says 'Update' |
|
218
|
|
|
$butt_create = new \XoopsFormButton('', '', _AM_SF_MODIFY, 'submit'); |
|
219
|
|
|
$butt_create->setExtra('onclick="this.form.elements.op.value=\'addcategory\'"'); |
|
220
|
|
|
$button_tray->addElement($butt_create); |
|
221
|
|
|
|
|
222
|
|
|
$butt_cancel = new \XoopsFormButton('', '', _AM_SF_CANCEL, 'button'); |
|
223
|
|
|
$butt_cancel->setExtra('onclick="history.go(-1)"'); |
|
224
|
|
|
$button_tray->addElement($butt_cancel); |
|
225
|
|
|
} |
|
226
|
|
|
|
|
227
|
|
|
$sform->addElement($button_tray); |
|
228
|
|
|
$sform->display(); |
|
229
|
|
|
echo '</div>'; |
|
230
|
|
|
|
|
231
|
|
|
if ($categoryid) { |
|
232
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/smartfaq/include/displayfaqs.php'; |
|
233
|
|
|
} |
|
234
|
|
|
|
|
235
|
|
|
unset($hidden); |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
switch ($op) { |
|
239
|
|
|
case 'mod': |
|
240
|
|
|
$categoryid = \Xmf\Request::getInt('categoryid', 0, 'GET'); |
|
241
|
|
|
$destList = \Xmf\Request::getString('destList', '', 'POST'); |
|
242
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
|
|
|
|
|
243
|
|
|
xoops_cp_header(); |
|
|
|
|
|
|
244
|
|
|
|
|
245
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
246
|
|
|
editcat(true, $categoryid); |
|
247
|
|
|
break; |
|
248
|
|
|
|
|
249
|
|
|
case 'addcategory': |
|
250
|
|
|
global $_POST, $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $xoopsModule, $modify, $myts, $categoryid; |
|
|
|
|
|
|
251
|
|
|
|
|
252
|
|
|
$categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST'); |
|
253
|
|
|
|
|
254
|
|
|
if (0 != $categoryid) { |
|
255
|
|
|
$categoryObj = new Smartfaq\Category($categoryid); |
|
256
|
|
|
} else { |
|
257
|
|
|
$categoryObj = $categoryHandler->create(); |
|
258
|
|
|
} |
|
259
|
|
|
|
|
260
|
|
|
//if (isset($_POST['allmods'])) $allmods = $_POST['allmods']; |
|
|
|
|
|
|
261
|
|
|
//if (isset($_POST['moderators'])) $moderators = $_POST['moderators']; |
|
|
|
|
|
|
262
|
|
|
|
|
263
|
|
|
$categoryObj->setVar('parentid', isset($_POST['parentid']) ? (int)$_POST['parentid'] : 0); |
|
264
|
|
|
$applyall = \Xmf\Request::getInt('applyall', 0, 'POST'); |
|
265
|
|
|
$categoryObj->setVar('weight', isset($_POST['weight']) ? (int)$_POST['weight'] : 1); |
|
266
|
|
|
|
|
267
|
|
|
// Groups and permissions |
|
268
|
|
|
if (isset($_POST['groups_read'])) { |
|
269
|
|
|
$categoryObj->setGroups_read($_POST['groups_read']); |
|
270
|
|
|
} else { |
|
271
|
|
|
$categoryObj->setGroups_read(); |
|
272
|
|
|
} |
|
273
|
|
|
// $groups_admin = isset($_POST['groups_admin'])? $_POST['groups_admin'] : array(); |
|
|
|
|
|
|
274
|
|
|
// $mod_perms = isset($_POST['mod_perms'])? $_POST['mod_perms'] : array(); |
|
|
|
|
|
|
275
|
|
|
|
|
276
|
|
|
$categoryObj->setVar('name', $_POST['name']); |
|
277
|
|
|
|
|
278
|
|
|
$categoryObj->setVar('description', $_POST['description']); |
|
279
|
|
|
if ($categoryObj->isNew()) { |
|
280
|
|
|
$redirect_msg = _AM_SF_CATCREATED; |
|
281
|
|
|
$redirect_to = 'category.php?op=mod'; |
|
282
|
|
|
} else { |
|
283
|
|
|
$redirect_msg = _AM_SF_COLMODIFIED; |
|
284
|
|
|
$redirect_to = 'category.php'; |
|
285
|
|
|
} |
|
286
|
|
|
|
|
287
|
|
|
if (!$categoryObj->store()) { |
|
288
|
|
|
redirect_header('javascript:history.go(-1)', 3, _AM_SF_CATEGORY_SAVE_ERROR . Smartfaq\Utility::formatErrors($categoryObj->getErrors())); |
|
|
|
|
|
|
289
|
|
|
} |
|
290
|
|
|
// TODO : put this function in the category class |
|
291
|
|
|
Smartfaq\Utility::saveCategoryPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read'); |
|
292
|
|
|
//Smartfaq\Utility::saveCategoryPermissions($groups_admin, $categoriesObj->categoryid(), 'category_admin'); |
|
|
|
|
|
|
293
|
|
|
|
|
294
|
|
|
if ($applyall) { |
|
295
|
|
|
// TODO : put this function in the category class |
|
296
|
|
|
Smartfaq\Utility::overrideFaqsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid()); |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
redirect_header($redirect_to, 2, $redirect_msg); |
|
300
|
|
|
break; |
|
301
|
|
|
|
|
302
|
|
|
case 'del': |
|
303
|
|
|
global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET; |
|
|
|
|
|
|
304
|
|
|
|
|
305
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
|
306
|
|
|
$gpermHandler = xoops_getHandler('groupperm'); |
|
|
|
|
|
|
307
|
|
|
|
|
308
|
|
|
$categoryid = \Xmf\Request::getInt('categoryid', 0, 'POST'); |
|
309
|
|
|
$categoryid = \Xmf\Request::getInt('categoryid', $categoryid, 'GET'); |
|
310
|
|
|
|
|
311
|
|
|
$categoryObj = new Smartfaq\Category($categoryid); |
|
312
|
|
|
|
|
313
|
|
|
$confirm = \Xmf\Request::getInt('confirm', 0, POST); |
|
|
|
|
|
|
314
|
|
|
$name = \Xmf\Request::getString('name', '', 'POST'); |
|
315
|
|
|
|
|
316
|
|
|
if ($confirm) { |
|
317
|
|
|
if (!$categoryHandler->delete($categoryObj)) { |
|
318
|
|
|
redirect_header('category.php', 1, _AM_SF_DELETE_CAT_ERROR); |
|
319
|
|
|
} |
|
320
|
|
|
redirect_header('category.php', 1, sprintf(_AM_SF_COLISDELETED, $name)); |
|
321
|
|
|
} else { |
|
322
|
|
|
// no confirm: show deletion condition |
|
323
|
|
|
$categoryid = \Xmf\Request::getInt('categoryid', 0, 'GET'); |
|
324
|
|
|
xoops_cp_header(); |
|
325
|
|
|
xoops_confirm([ |
|
|
|
|
|
|
326
|
|
|
'op' => 'del', |
|
327
|
|
|
'categoryid' => $categoryObj->categoryid(), |
|
328
|
|
|
'confirm' => 1, |
|
329
|
|
|
'name' => $categoryObj->name() |
|
330
|
|
|
], 'category.php', _AM_SF_DELETECOL . " '" . $categoryObj->name() . "'. <br> <br>" . _AM_SF_DELETE_CAT_CONFIRM, _AM_SF_DELETE); |
|
331
|
|
|
xoops_cp_footer(); |
|
|
|
|
|
|
332
|
|
|
} |
|
333
|
|
|
exit(); |
|
334
|
|
|
break; |
|
335
|
|
|
|
|
336
|
|
|
case 'cancel': |
|
337
|
|
|
redirect_header('category.php', 1, sprintf(_AM_SF_BACK2IDX, '')); |
|
338
|
|
|
break; |
|
339
|
|
|
case 'default': |
|
340
|
|
|
default: |
|
341
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
|
342
|
|
|
xoops_cp_header(); |
|
343
|
|
|
|
|
344
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
|
345
|
|
|
echo "<br>\n"; |
|
346
|
|
|
|
|
347
|
|
|
// Creating the objects for top categories |
|
348
|
|
|
$categoriesObj =& $categoryHandler->getCategories($helper->getConfig('perpage'), $startcategory, 0); |
|
349
|
|
|
|
|
350
|
|
|
Smartfaq\Utility::collapsableBar('toptable', 'toptableicon'); |
|
351
|
|
|
echo "<img id='toptableicon' src=" . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . "/assets/images/icon/close12.gif alt=''></a> " . _AM_SF_CATEGORIES_TITLE . '</h3>'; |
|
|
|
|
|
|
352
|
|
|
echo "<div id='toptable'>"; |
|
353
|
|
|
echo '<span style="color: #567; margin: 3px 0 12px 0; font-size: small; display: block; ">' . _AM_SF_CATEGORIES_DSC . '</span>'; |
|
354
|
|
|
|
|
355
|
|
|
echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>"; |
|
356
|
|
|
echo '<tr>'; |
|
357
|
|
|
echo "<th width='35%' class='bg3' align='left'><b>" . _AM_SF_ARTCOLNAME . '</b></td>'; |
|
358
|
|
|
echo "<th class='bg3' align='left'><b>" . _AM_SF_DESCRIP . '</b></td>'; |
|
359
|
|
|
echo "<th class='bg3' width='65' align='center'><b>" . _AM_SF_WEIGHT . '</b></td>'; |
|
360
|
|
|
echo "<th width='60' class='bg3' align='center'><b>" . _AM_SF_ACTION . '</b></td>'; |
|
361
|
|
|
echo '</tr>'; |
|
362
|
|
|
$totalCategories = $categoryHandler->getCategoriesCount(0); |
|
363
|
|
|
if (count($categoriesObj) > 0) { |
|
364
|
|
|
foreach ($categoriesObj as $key => $thiscat) { |
|
365
|
|
|
displayCategory($thiscat); |
|
366
|
|
|
} |
|
367
|
|
|
} else { |
|
368
|
|
|
echo '<tr>'; |
|
369
|
|
|
echo "<td class='head' align='center' colspan= '7'>" . _AM_SF_NOCAT . '</td>'; |
|
370
|
|
|
echo '</tr>'; |
|
371
|
|
|
$categoryid = '0'; |
|
372
|
|
|
} |
|
373
|
|
|
echo "</table>\n"; |
|
374
|
|
|
require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
|
|
|
|
|
|
375
|
|
|
$pagenav = new \XoopsPageNav($totalCategories, $helper->getConfig('perpage'), $startcategory, 'startcategory'); |
|
|
|
|
|
|
376
|
|
|
echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; |
|
377
|
|
|
echo '</div>'; |
|
378
|
|
|
|
|
379
|
|
|
editcat(false); |
|
380
|
|
|
|
|
381
|
|
|
break; |
|
382
|
|
|
} |
|
383
|
|
|
|
|
384
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
|
385
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.