1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Module: Lexikon - glossary module |
5
|
|
|
* Author: Yerres |
6
|
|
|
* Licence: GNU |
7
|
|
|
*/ |
8
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @param $options |
12
|
|
|
* @return array |
13
|
|
|
*/ |
14
|
|
|
function b_lxcategories_show($options) |
15
|
|
|
{ |
16
|
|
|
global $xoopsDB, $xoopsUser; |
17
|
|
|
$myts = MyTextSanitizer:: getInstance(); |
18
|
|
|
|
19
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
20
|
|
|
$moduleHandler = xoops_getHandler('module'); |
21
|
|
|
$lexikon = $moduleHandler->getByDirname('lexikon'); |
22
|
|
|
if (!isset($lxConfig)) { |
|
|
|
|
23
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
24
|
|
|
$configHandler = xoops_getHandler('config'); |
25
|
|
|
$lxConfig = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid')); |
26
|
|
|
} |
27
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
28
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
29
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
30
|
|
|
$module_id = $lexikon->getVar('mid'); |
31
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
32
|
|
|
$catids = implode(',', $allowed_cats); |
33
|
|
|
$catperms = " categoryID IN ($catids) "; |
34
|
|
|
|
35
|
|
|
$cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
36
|
|
|
$totalcats = count($cats); |
37
|
|
|
|
38
|
|
|
$block = []; |
39
|
|
|
$sql = 'SELECT categoryID, name, total FROM ' . $xoopsDB->prefix('lxcategories') . ' WHERE ' . $catperms . ' ORDER BY ' . $options[0] . ' DESC'; |
40
|
|
|
$result = $xoopsDB->query($sql, $options[1], 0); |
41
|
|
|
|
42
|
|
|
if ($totalcats > 0) { // If there are categories |
43
|
|
|
while (list($categoryID, $name, $total) = $xoopsDB->fetchRow($result)) { |
44
|
|
|
$catlist = []; |
45
|
|
|
$linktext = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5); |
46
|
|
|
$catlist['dir'] = $lexikon->dirname(); |
47
|
|
|
$catlist['linktext'] = $linktext; |
48
|
|
|
$catlist['id'] = (int)$categoryID; |
49
|
|
|
$catlist['total'] = (int)$total; |
50
|
|
|
|
51
|
|
|
$block['catstuff'][] = $catlist; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return $block; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param $options |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
function b_lxcategories_edit($options) |
63
|
|
|
{ |
64
|
|
|
$form = '' . _MB_LEXIKON_ORDER . " <select name='options[]'>"; |
65
|
|
|
$form .= "<option value='weight' " . (('weight' === $options[0]) ? ' selected' : '') . '>' . _MB_LEXIKON_WEIGHT . "</option>\n"; |
66
|
|
|
$form .= "<option value='name' " . (('name' === $options[0]) ? ' selected' : '') . '>' . _MB_LEXIKON_NAME . "</option>\n"; |
67
|
|
|
$form .= "<option value='total' " . (('total' === $options[0]) ? ' selected' : '') . '>' . _MB_LEXIKON_TOTAL . "</option>\n"; |
68
|
|
|
$form .= "</select>\n<br>"; |
69
|
|
|
$form .= ' ' . _MB_LEXIKON_DISP . " <input type='text' name='options[]' value='" . $options[1] . "' > " . _MB_LEXIKON_CATS . ''; |
70
|
|
|
|
71
|
|
|
return $form; |
72
|
|
|
} |
73
|
|
|
|