1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Module: Lexikon |
5
|
|
|
* Author: Yerres |
6
|
|
|
* adapted from xwords |
7
|
|
|
* Licence: GNU |
8
|
|
|
*/ |
9
|
|
|
defined('XOOPS_ROOT_PATH') || exit('Restricted access'); |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* @param $a |
13
|
|
|
* @return string |
14
|
|
|
*/ |
15
|
|
|
function uchr($a) |
16
|
|
|
{ |
17
|
|
|
if (is_scalar($a)) { |
18
|
|
|
$a = func_get_args(); |
19
|
|
|
} |
20
|
|
|
$str = ''; |
21
|
|
|
foreach ($a as $code) { |
22
|
|
|
$str .= html_entity_decode('&#' . $code . ';', ENT_NOQUOTES, 'UTF-8'); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
return $str; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param $options |
30
|
|
|
* @return array |
31
|
|
|
*/ |
32
|
|
|
function b_lxentries_alpha_show($options) |
33
|
|
|
{ |
34
|
|
|
global $xoopsDB, $xoopsUser, $xoopsModule; |
35
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
|
|
|
36
|
|
|
|
37
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
38
|
|
|
$moduleHandler = xoops_getHandler('module'); |
39
|
|
|
$lexikon = $moduleHandler->getByDirname('lexikon'); |
40
|
|
|
if (!isset($lxConfig)) { |
|
|
|
|
41
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
42
|
|
|
$configHandler = xoops_getHandler('config'); |
43
|
|
|
$lxConfig = $configHandler->getConfigsByCat(0, $lexikon->getVar('mid')); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
46
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
47
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
48
|
|
|
$module_id = $lexikon->getVar('mid'); |
49
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
50
|
|
|
$catids = implode(',', $allowed_cats); |
51
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
52
|
|
|
|
53
|
|
|
$block = []; |
54
|
|
|
// To handle options in the template |
55
|
|
|
if (1 == $options[0]) { |
56
|
|
|
$block['layout'] = 1; |
57
|
|
|
} else { |
58
|
|
|
$block['layout'] = 0; |
59
|
|
|
} |
60
|
|
|
if ($options[1]) { |
61
|
|
|
$block['number'] = $options[1]; |
62
|
|
|
} else { |
63
|
|
|
$block['number'] = 8; |
64
|
|
|
} |
65
|
|
|
$block['title'] = _MB_LEXIKON_TERMINITIAL; |
66
|
|
|
$block['moduledirname'] = $lexikon->dirname(); |
67
|
|
|
$count = 0; |
68
|
|
|
for ($a = 48; $a < (48 + 10); ++$a) { |
69
|
|
|
$letterlinks = []; |
70
|
|
|
$initial = uchr($a); |
71
|
|
|
$sql = $xoopsDB->query('SELECT init FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$initial' AND datesub < '" . time() . "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " . $catperms . ' '); |
72
|
|
|
$howmany = $xoopsDB->getRowsNum($sql); |
73
|
|
|
$letterlinks['total'] = $howmany; |
74
|
|
|
$letterlinks['id'] = uchr($a); |
75
|
|
|
$letterlinks['linktext'] = uchr($a); |
76
|
|
|
$letterlinks['count'] = $count; |
77
|
|
|
|
78
|
|
|
$block['initstuff'][] = $letterlinks; |
79
|
|
|
} |
80
|
|
|
for ($a = 65; $a < (65 + 26); ++$a) { |
81
|
|
|
$letterlinks = []; |
82
|
|
|
$initial = uchr($a); |
83
|
|
|
$sql = $xoopsDB->query('SELECT init FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$initial' AND datesub < '" . time() . "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " . $catperms . ' '); |
84
|
|
|
$howmany = $xoopsDB->getRowsNum($sql); |
85
|
|
|
$letterlinks['total'] = $howmany; |
86
|
|
|
$letterlinks['id'] = uchr($a); |
87
|
|
|
$letterlinks['linktext'] = uchr($a); |
88
|
|
|
$letterlinks['count'] = $count; |
89
|
|
|
|
90
|
|
|
$block['initstuff'][] = $letterlinks; |
91
|
|
|
} |
92
|
|
|
/*for ($a = 1040; $a < (1040 + 32); ++$a) { |
93
|
|
|
$letterlinks = []; |
94
|
|
|
$initial = uchr($a); |
95
|
|
|
$sql = $xoopsDB->query('SELECT init FROM ' |
96
|
|
|
. $xoopsDB->prefix('lxentries') |
97
|
|
|
. " WHERE init = '$initial' AND datesub < '" |
98
|
|
|
. time() |
99
|
|
|
. "' AND datesub > '0' AND offline= '0' AND submit='0' AND request='0' " |
100
|
|
|
. $catperms |
101
|
|
|
. ' '); |
102
|
|
|
$howmany = $xoopsDB->getRowsNum($sql); |
103
|
|
|
$letterlinks['total'] = $howmany; |
104
|
|
|
$letterlinks['id'] = uchr($a); |
105
|
|
|
$letterlinks['linktext'] = uchr($a); |
106
|
|
|
$letterlinks['count'] = (int)$count; |
107
|
|
|
|
108
|
|
|
$block['initstuff'][] = $letterlinks; |
109
|
|
|
}*/ |
110
|
|
|
|
111
|
|
|
return $block; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @param $options |
116
|
|
|
* @return string |
117
|
|
|
*/ |
118
|
|
|
function b_lxentries_alpha_edit($options) |
119
|
|
|
{ |
120
|
|
|
$form = _ALIGN; |
121
|
|
|
$form .= "<input type='radio' name='options[0]' value='1'" . ((1 == $options[0]) ? ' checked' : '') . ' >' . _YES . ' '; |
122
|
|
|
$form .= "<input type='radio' name='options[0]' value='0'" . ((0 == $options[0]) ? ' checked' : '') . ' >' . _NO . '<br>'; |
123
|
|
|
$form .= '' . _MB_LEXIKON_LETTERS . " <input type='text' name='options[]' value='" . $options[1] . "' > <br>"; |
124
|
|
|
|
125
|
|
|
//------------ |
126
|
|
|
return $form; |
127
|
|
|
} |
128
|
|
|
|