1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: Xooopstube |
4
|
|
|
* Licence: GNU |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
use Xmf\Request; |
8
|
|
|
use XoopsModules\Xoopstube\{ |
9
|
|
|
Helper, |
10
|
|
|
Utility |
11
|
|
|
}; |
12
|
|
|
/** @var Helper $helper */ |
13
|
|
|
|
14
|
|
|
require_once __DIR__ . '/header.php'; |
15
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'lx_letter.tpl'; |
16
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
17
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php'; |
18
|
|
|
$helper = Helper::getInstance(); |
19
|
|
|
$utility = new Utility(); |
20
|
|
|
|
21
|
|
|
global $xoTheme, $xoopsUser; |
22
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
23
|
|
|
|
24
|
|
|
$init = Request::getString('init', 0, 'GET'); |
25
|
|
|
$xoopsTpl->assign('firstletter', $init); |
26
|
|
|
require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
27
|
|
|
$start = Request::getInt('start', 0, 'GET'); |
28
|
|
|
|
29
|
|
|
$publishedwords = $utility::countWords(); |
30
|
|
|
$xoopsTpl->assign('publishedwords', $publishedwords); |
31
|
|
|
|
32
|
|
|
//permissions |
33
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
34
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
35
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
36
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
37
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
38
|
|
|
$catids = implode(',', $allowed_cats); |
39
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
40
|
|
|
|
41
|
|
|
$xoopsTpl->assign('multicats', (int)$helper->getConfig('multicats')); |
42
|
|
|
|
43
|
|
|
if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) { |
44
|
|
|
/** |
45
|
|
|
* @param $string |
46
|
|
|
* @return string |
47
|
|
|
*/ |
48
|
|
|
function mb_ucfirst($string) |
49
|
|
|
{ |
50
|
|
|
$string = mb_ereg_replace('^[\ ]+', '', $string); |
51
|
|
|
$string = mb_strtoupper(mb_substr($string, 0, 1, 'UTF-8'), 'UTF-8') . mb_substr($string, 1, mb_strlen($string), 'UTF-8'); |
52
|
|
|
|
53
|
|
|
return $string; |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
// To display the linked letter list |
57
|
|
|
$alpha = $utility::getAlphaArray(); |
58
|
|
|
$xoopsTpl->assign('alpha', $alpha); |
59
|
|
|
|
60
|
|
|
[$howmanyother] = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND offline ='0' " . $catperms . ' ')); |
61
|
|
|
$xoopsTpl->assign('totalother', $howmanyother); |
62
|
|
|
|
63
|
|
|
// To display the list of categories |
64
|
|
|
if (1 == $helper->getConfig('multicats')) { |
65
|
|
|
$xoopsTpl->assign('block0', $utility::getCategoryArray()); |
66
|
|
|
$xoopsTpl->assign('layout', CONFIG_CATEGORY_LAYOUT_PLAIN); |
|
|
|
|
67
|
|
|
if ($utility::getModuleOption('useshots')) { |
68
|
|
|
$xoopsTpl->assign('show_screenshot', true); |
69
|
|
|
$xoopsTpl->assign('logo_maximgwidth', $helper->getConfig('logo_maximgwidth')); |
70
|
|
|
$xoopsTpl->assign('lang_noscreenshot', _MD_LEXIKON_NOSHOTS); |
|
|
|
|
71
|
|
|
} else { |
72
|
|
|
$xoopsTpl->assign('show_screenshot', false); |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
// No initial: we need to see all letters |
77
|
|
|
if (!$init) { |
78
|
|
|
$entriesarray = []; |
79
|
|
|
$pagetype = 0; |
80
|
|
|
|
81
|
|
|
// How many entries will we show in this page? |
82
|
|
|
//$queryA = "SELECT w. * , c.name AS catname FROM ".$xoopsDB -> prefix( 'lxentries' )." w LEFT JOIN ".$xoopsDB -> prefix( 'lxcategories' )." c ON w.categoryID = c.categoryID WHERE w.submit = '0' AND w.offline = '0' ORDER BY w.term ASC"; |
83
|
|
|
//$resultA = $xoopsDB -> query ($queryA, $helper->getConfig('indexperpage'), $start ); |
84
|
|
|
$queryA = 'SELECT * FROM ' . $xoopsDB->prefix('lxentries') . " WHERE offline = '0' AND submit = '0' " . $catperms . ' ORDER BY term ASC'; |
85
|
|
|
$resultA = $xoopsDB->query($queryA, $helper->getConfig('indexperpage'), $start); |
86
|
|
|
|
87
|
|
|
$allentries = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit ='0' AND offline = '0' " . $catperms . ' ORDER BY term ASC '); |
88
|
|
|
$totalentries = $xoopsDB->getRowsNum($allentries); |
89
|
|
|
$xoopsTpl->assign('totalentries', $totalentries); |
90
|
|
|
|
91
|
|
|
while (list($entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $comments) = $xoopsDB->fetchRow($resultA)) { |
92
|
|
|
$eachentry = []; |
93
|
|
|
$xoopsModule = XoopsModule::getByDirname('lexikon'); |
94
|
|
|
$eachentry['dir'] = $xoopsModule->dirname(); |
95
|
|
|
|
96
|
|
|
if (1 == $helper->getConfig('multicats')) { |
97
|
|
|
$eachentry['catid'] = (int)$categoryID; |
98
|
|
|
$resultF = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC"); |
99
|
|
|
while (list($name) = $xoopsDB->fetchRow($resultF)) { |
100
|
|
|
$eachentry['catname'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5); |
101
|
|
|
} |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
$eachentry['id'] = (int)$entryID; |
105
|
|
|
$eachentry['term'] = mb_ucfirst(htmlspecialchars($term, ENT_QUOTES | ENT_HTML5)); |
106
|
|
|
|
107
|
|
|
if ((0 != $helper->getConfig('com_rule')) || ((0 != $helper->getConfig('com_rule')) && is_object($xoopsUser))) { |
|
|
|
|
108
|
|
|
if (0 != $comments) { |
109
|
|
|
$eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . ' ' . _COMMENTS . '</a>'; |
110
|
|
|
} else { |
111
|
|
|
$eachentry['comments'] = ''; |
112
|
|
|
} |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
116
|
|
|
$eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
// Functional links |
120
|
|
|
$microlinks = $utility::getServiceLinks($eachentry); |
|
|
|
|
121
|
|
|
$eachentry['microlinks'] = $microlinks; |
122
|
|
|
|
123
|
|
|
$entriesarray['single'][] = $eachentry; |
124
|
|
|
} |
125
|
|
|
$pagenav = new \XoopsPageNav($totalentries, $helper->getConfig('indexperpage'), $start, 'start'); |
126
|
|
|
$entriesarray['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav(6) . '</div>'; |
127
|
|
|
|
128
|
|
|
$xoopsTpl->assign('entriesarray', $entriesarray); |
129
|
|
|
$xoopsTpl->assign('pagetype', '0'); |
130
|
|
|
$xoopsTpl->assign('pageinitial', _MD_LEXIKON_ALL); |
|
|
|
|
131
|
|
|
|
132
|
|
|
$utility::createPageTitle(htmlspecialchars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_ALL, ENT_QUOTES | ENT_HTML5)); |
|
|
|
|
133
|
|
|
} else { // $init does exist |
134
|
|
|
$pagetype = 1; |
135
|
|
|
// There IS an initial letter, so we want to show just that letter's terms |
136
|
|
|
$entriesarray2 = []; |
137
|
|
|
|
138
|
|
|
// How many entries will we show in this page? |
139
|
|
|
if (_MD_LEXIKON_OTHER == $init) { |
|
|
|
|
140
|
|
|
$queryB = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit ='0' AND offline = '0' AND init = '#' " . $catperms . ' ORDER BY term ASC'; |
141
|
|
|
$resultB = $xoopsDB->query($queryB, $helper->getConfig('indexperpage'), $start); |
142
|
|
|
} else { |
143
|
|
|
$queryB = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit ='0' AND offline = '0' AND init = '$init' AND init != '#' " . $catperms . ' ORDER BY term ASC'; |
144
|
|
|
$resultB = $xoopsDB->query($queryB, $helper->getConfig('indexperpage'), $start); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
$entrieshere = $xoopsDB->getRowsNum($resultB); |
148
|
|
|
if (0 == $entrieshere) { |
149
|
|
|
redirect_header('<script>javascript:history.go(-1)</script>', 1, _MD_LEXIKON_NOTERMSINLETTER); |
|
|
|
|
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
if (_MD_LEXIKON_OTHER == $init) { |
153
|
|
|
$allentries = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND submit ='0' AND offline = '0' " . $catperms . ' ORDER BY term ASC '); |
154
|
|
|
} else { |
155
|
|
|
$allentries = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$init' AND init != '#' AND submit ='0' AND offline = '0' " . $catperms . ' ORDER BY term ASC '); |
156
|
|
|
} |
157
|
|
|
$totalentries = $xoopsDB->getRowsNum($allentries); |
158
|
|
|
$xoopsTpl->assign('totalentries', $totalentries); |
159
|
|
|
$utility::createPageTitle(htmlspecialchars(_MD_LEXIKON_BROWSELETTER . (isset($init['init']) ? (' - ' . $init['init']) : ''), ENT_QUOTES | ENT_HTML5)); |
160
|
|
|
|
161
|
|
|
while (list($entryID, $categoryID, $term, $definition, $uid, $html, $smiley, $xcodes, $breaks, $comments) = $xoopsDB->fetchRow($resultB)) { |
162
|
|
|
$eachentry = []; |
163
|
|
|
$xoopsModule = XoopsModule::getByDirname('lexikon'); |
164
|
|
|
$eachentry['dir'] = $xoopsModule->dirname(); |
165
|
|
|
|
166
|
|
|
if (1 == $helper->getConfig('multicats')) { |
167
|
|
|
$eachentry['catid'] = (int)$categoryID; |
168
|
|
|
$resultF = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID ORDER BY name ASC"); |
169
|
|
|
while (list($name) = $xoopsDB->fetchRow($resultF)) { |
170
|
|
|
$eachentry['catname'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5); |
171
|
|
|
} |
172
|
|
|
} |
173
|
|
|
$eachentry['id'] = (int)$entryID; |
174
|
|
|
$eachentry['term'] = mb_ucfirst(htmlspecialchars($term, ENT_QUOTES | ENT_HTML5)); |
175
|
|
|
if ('#' === $init) { |
176
|
|
|
$eachentry['init'] = _MD_LEXIKON_OTHER; |
177
|
|
|
} else { |
178
|
|
|
$eachentry['init'] = $init; |
179
|
|
|
} |
180
|
|
|
|
181
|
|
|
if ((0 != $helper->getConfig('com_rule')) || ((0 != $helper->getConfig('com_rule')) && is_object($xoopsUser))) { |
|
|
|
|
182
|
|
|
if (0 != $comments) { |
183
|
|
|
$eachentry['comments'] = "<a href='entry.php?entryID=" . $eachentry['id'] . "'>" . $comments . ' ' . _COMMENTS . '</a>'; |
184
|
|
|
} else { |
185
|
|
|
$eachentry['comments'] = ''; |
186
|
|
|
} |
187
|
|
|
} |
188
|
|
|
if (!XOOPS_USE_MULTIBYTES) { |
189
|
|
|
$eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks); |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
// Functional links |
193
|
|
|
$microlinks = $utility::getServiceLinks($eachentry); |
194
|
|
|
$eachentry['microlinks'] = $microlinks; |
195
|
|
|
|
196
|
|
|
$entriesarray2['single'][] = $eachentry; |
197
|
|
|
} |
198
|
|
|
$pagenav = new \XoopsPageNav($totalentries, $helper->getConfig('indexperpage'), $start, 'init=' . $eachentry['init'] . '&start'); |
199
|
|
|
$entriesarray2['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav(6) . '</div>'; |
200
|
|
|
|
201
|
|
|
$xoopsTpl->assign('entriesarray2', $entriesarray2); |
202
|
|
|
$xoopsTpl->assign('pagetype', '1'); |
203
|
|
|
if ('#' === $eachentry['init']) { |
204
|
|
|
$xoopsTpl->assign('pageinitial', _MD_LEXIKON_OTHER); |
205
|
|
|
$utility::createPageTitle(htmlspecialchars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_OTHER, ENT_QUOTES | ENT_HTML5)); |
206
|
|
|
} else { |
207
|
|
|
$xoopsTpl->assign('pageinitial', mb_ucfirst($eachentry['init'])); |
208
|
|
|
} |
209
|
|
|
} |
210
|
|
|
|
211
|
|
|
$xoopsTpl->assign('lang_modulename', $xoopsModule->name()); |
212
|
|
|
$xoopsTpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname')); |
213
|
|
|
$xoopsTpl->assign('alpha', $alpha); |
214
|
|
|
if (1 == $helper->getConfig('syndication')) { |
215
|
|
|
$xoopsTpl->assign('syndication', true); |
216
|
|
|
} |
217
|
|
|
if ($xoopsUser) { |
218
|
|
|
$xoopsTpl->assign('syndication', true); |
219
|
|
|
} |
220
|
|
|
// Meta data |
221
|
|
|
if (0 == $publishedwords) { |
222
|
|
|
$meta_description = xoops_substr($utility::convertHtml2text($eachentry['definition']), 0, 150); |
|
|
|
|
223
|
|
|
if (1 == $helper->getConfig('multicats')) { |
224
|
|
|
$utility::extractKeywords($xoopsModule->name() . ' ,' . $eachentry['term'] . ', ' . $meta_description); |
|
|
|
|
225
|
|
|
$utility::getMetaDescription(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ' . $eachentry['catname'] . ' ' . $eachentry['term']); |
|
|
|
|
226
|
|
|
} else { |
227
|
|
|
$utility::extractKeywords(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ', ' . $eachentry['term'] . ', ' . $meta_description); |
228
|
|
|
$utility::getMetaDescription(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ' . $eachentry['term'] . ' ' . $meta_description); |
229
|
|
|
} |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="assets/css/style.css">'); |
233
|
|
|
|
234
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
235
|
|
|
|