1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Module: Lexikon - glossary module |
4
|
|
|
* Author: hsalazar |
5
|
|
|
* Licence: GNU |
6
|
|
|
*/ |
7
|
|
|
|
8
|
|
|
use Xmf\Request; |
9
|
|
|
use XoopsModules\Lexikon\{ |
10
|
|
|
Helper, |
11
|
|
|
Keyhighlighter, |
12
|
|
|
Utility |
13
|
|
|
}; |
14
|
|
|
/** @var Helper $helper */ |
15
|
|
|
|
16
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'lx_entry.tpl'; |
17
|
|
|
|
18
|
|
|
require __DIR__ . '/header.php'; |
19
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
20
|
|
|
global $xoTheme, $xoopsUser, $lexikon_module_header; |
21
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
22
|
|
|
xoops_load('XoopsUserUtility'); |
23
|
|
|
|
24
|
|
|
$helper = Helper::getInstance(); |
25
|
|
|
$utility = new Utility(); |
26
|
|
|
|
27
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php'; |
28
|
|
|
$highlight = $utility::getModuleOption('config_highlighter'); |
29
|
|
|
|
30
|
|
|
$entryID = Request::getInt('entryID', 0, 'GET'); |
31
|
|
|
if (empty($entryID)) { |
32
|
|
|
redirect_header('index.php', 3, _MD_LEXIKON_UNKNOWNERROR); |
33
|
|
|
} |
34
|
|
|
$entrytype = 1; |
35
|
|
|
// permissions |
36
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
37
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
38
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
39
|
|
|
$module_id = $xoopsModule->getVar('mid'); |
40
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
41
|
|
|
$catids = implode(',', $allowed_cats); |
42
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
43
|
|
|
|
44
|
|
|
// If there's no entries yet in the system... |
45
|
|
|
$publishedwords = $utility::countWords(); |
46
|
|
|
$xoopsTpl->assign('publishedwords', $publishedwords); |
47
|
|
|
if (0 == $publishedwords) { |
48
|
|
|
$xoopsTpl->assign('empty', '1'); |
49
|
|
|
$xoopsTpl->assign('stillnothing', _MD_LEXIKON_STILLNOTHINGHERE); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
// To display the linked letter list |
53
|
|
|
$alpha = $utility::getAlphaArray(); |
54
|
|
|
$xoopsTpl->assign('alpha', $alpha); |
55
|
|
|
|
56
|
|
|
[$howmanyother] = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(entryID) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND offline ='0' " . $catperms . ' ')); |
57
|
|
|
$xoopsTpl->assign('totalother', $howmanyother); |
58
|
|
|
|
59
|
|
|
$xoopsTpl->assign('multicats', (int)$helper->getConfig('multicats')); |
60
|
|
|
// To display the list of categories |
61
|
|
|
if (1 == $helper->getConfig('multicats')) { |
62
|
|
|
$xoopsTpl->assign('block0', $utility::getCategoryArray()); |
63
|
|
|
$xoopsTpl->assign('layout', CONFIG_CATEGORY_LAYOUT_PLAIN); |
64
|
|
|
if (1 == $helper->getConfig('useshots')) { |
65
|
|
|
$xoopsTpl->assign('show_screenshot', true); |
66
|
|
|
$xoopsTpl->assign('logo_maximgwidth', $helper->getConfig('logo_maximgwidth')); |
67
|
|
|
$xoopsTpl->assign('lang_noscreenshot', _MD_LEXIKON_NOSHOTS); |
68
|
|
|
} else { |
69
|
|
|
$xoopsTpl->assign('show_screenshot', false); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if (!$entryID) { |
74
|
|
|
redirect_header('<script>javascript:history.go(-1)</script>', 2, _MD_LEXIKON_UNKNOWNERROR); |
75
|
|
|
} else { |
76
|
|
|
if ($entryID <= 0) { |
77
|
|
|
redirect_header('<script>javascript:history.go(-1)</script>', 2, _MD_LEXIKON_UNKNOWNERROR); |
78
|
|
|
} |
79
|
|
|
if (!$xoopsUser || ($xoopsUser->isAdmin($xoopsModule->mid()) && 1 == $helper->getConfig('adminhits')) |
80
|
|
|
|| ($xoopsUser |
81
|
|
|
&& !$xoopsUser->isAdmin($xoopsModule->mid()))) { |
82
|
|
|
$xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('lxentries') . " SET counter = counter+1 WHERE entryID = $entryID "); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
$result = $xoopsDB->query( |
86
|
|
|
'SELECT entryID, categoryID, term, init, definition, ref, url, uid, submit, datesub, counter, html, smiley, xcodes, breaks, block, offline, notifypub |
87
|
|
|
FROM ' . $xoopsDB->prefix('lxentries') . " |
88
|
|
|
WHERE entryID = $entryID" |
89
|
|
|
); |
90
|
|
|
// verify result |
91
|
|
|
if ($xoopsDB->getRowsNum($result) <= 0) { |
92
|
|
|
redirect_header('index.php', 2, _MD_LEXIKON_UNKNOWNERROR); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
while (list($entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline) = $xoopsDB->fetchRow($result)) { |
97
|
|
|
$catID = (int)$categoryID; |
98
|
|
|
if (!$grouppermHandler->checkRight('lexikon_view', (int)$categoryID, $groups, $module_id)) { |
99
|
|
|
redirect_header('index.php', 3, _NOPERM); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
$thisterm = []; |
103
|
|
|
$xoopsModule = XoopsModule::getByDirname('lexikon'); |
104
|
|
|
$thisterm['id'] = (int)$entryID; |
105
|
|
|
$thisterm['offline'] = (int)$offline; |
106
|
|
|
// exit if offline - except admin |
107
|
|
|
if (1 == $thisterm['offline'] && !$xoopsUserIsAdmin) { |
108
|
|
|
redirect_header('<script>javascript:history.go(-1)</script>', 3, _MD_LEXIKON_ENTRYISOFF); |
109
|
|
|
} |
110
|
|
|
if (1 == $helper->getConfig('multicats')) { |
111
|
|
|
$thisterm['categoryID'] = (int)$categoryID; |
112
|
|
|
$catname = $xoopsDB->query('SELECT name FROM ' . $xoopsDB->prefix('lxcategories') . " WHERE categoryID = $categoryID "); |
113
|
|
|
while (list($name) = $xoopsDB->fetchRow($catname)) { |
114
|
|
|
$thisterm['catname'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
$glossaryterm = htmlspecialchars($term, ENT_QUOTES | ENT_HTML5); |
119
|
|
|
$thisterm['term'] = ucfirst(htmlspecialchars($term, ENT_QUOTES | ENT_HTML5)); |
120
|
|
|
if ('#' === $init) { |
121
|
|
|
$thisterm['init'] = _MD_LEXIKON_OTHER; |
122
|
|
|
} else { |
123
|
|
|
$thisterm['init'] = ucfirst($init); |
124
|
|
|
} |
125
|
|
|
$thisterm['offline'] = (int)$offline; |
126
|
|
|
|
127
|
|
|
if (1 != $helper->getConfig('linkterms') && 2 != $helper->getConfig('linkterms')) { |
128
|
|
|
$utility::getModuleHeader(); |
129
|
|
|
$xoopsTpl->assign('xoops_module_header', $lexikon_module_header); |
130
|
|
|
} else { |
131
|
|
|
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="assets/css/style.css">'); |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
if (1 != $helper->getConfig('linkterms')) { |
135
|
|
|
// Code to make links out of glossary terms |
136
|
|
|
$parts = explode('>', $definition); |
137
|
|
|
|
138
|
|
|
// First, retrieve all terms from the glossary... |
139
|
|
|
$allterms = $xoopsDB->query('SELECT entryID, term, definition FROM ' . $xoopsDB->prefix('lxentries') . " WHERE offline ='0' " . $catperms . ' '); |
140
|
|
|
|
141
|
|
|
while (list($entryID, $term, $definition) = $xoopsDB->fetchRow($allterms)) { |
142
|
|
|
foreach ($parts as $key => $part) { |
143
|
|
|
if ($term != $glossaryterm) { |
144
|
|
|
$term_q = preg_quote($term, '/'); |
145
|
|
|
$search_term = "/\b$term_q\b/SsUi"; |
146
|
|
|
//static link |
147
|
|
|
$staticURL = '' . XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/entry.php?entryID=' . ucfirst($entryID) . ''; |
148
|
|
|
switch ($helper->getConfig('linkterms')) { |
149
|
|
|
default: |
150
|
|
|
$replace_term = '<span><b><a style="cursor:help;border-bottom: 1px dotted #000;color: #2F5376;" href="' . $staticURL . '" >' . $term . '</a></b></span>'; |
151
|
|
|
break; |
152
|
|
|
case 3: //tooltip |
153
|
|
|
$tooltipdef = htmlspecialchars(xoops_substr(strip_tags($definition), 0, 150), ENT_QUOTES | ENT_HTML5); |
154
|
|
|
$replace_term = '<a class="parser" href="' . $staticURL . '" onMouseover="ddrivetip(\'' . $tooltipdef . '\', 300)"; onMouseout=\'hideddrivetip()\'>' . $term . '</a>'; |
155
|
|
|
break; |
156
|
|
|
case 4://simple popup |
157
|
|
|
$replace_term = '<a style="cursor:help;border-bottom: 1px dotted #000;color: #2F5376;" href="#" onClick=\'popup("popup.php?entryID=' . $entryID . '","details", 420, 350); return false\'>' . $term . '</a>'; |
158
|
|
|
break; |
159
|
|
|
case 5:// balloon tooltip |
160
|
|
|
$tooltipdef = htmlspecialchars(xoops_substr(strip_tags($definition), 0, 150), ENT_QUOTES | ENT_HTML5); |
161
|
|
|
$replace_term = '<a class="parser" href="' . $staticURL . '" onMouseover="showToolTip(event,\'' . $tooltipdef . '\');return false"; onMouseout=\'hideToolTip()\'>' . $term . '</a>'; |
162
|
|
|
break; |
163
|
|
|
case 6:// shadow tooltip |
164
|
|
|
$tooltipdef = htmlspecialchars(xoops_substr(strip_tags($definition), 0, 150), ENT_QUOTES | ENT_HTML5); |
165
|
|
|
$replace_term = '<a class="parser" href="' . $staticURL . '" onmouseout="hideTooltip()" onmouseover="showTooltip(event,\'' . $tooltipdef . '\')"; >' . $term . '</a>'; |
166
|
|
|
break; |
167
|
|
|
} |
168
|
|
|
$parts[$key] = preg_replace($search_term, $replace_term, $parts[$key]); |
169
|
|
|
} |
170
|
|
|
} |
171
|
|
|
} |
172
|
|
|
$definition = implode('>', $parts); |
173
|
|
|
} |
174
|
|
|
$thisterm['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks); |
175
|
|
|
$thisterm['ref'] = $myts->displayTarea($ref, $html, $smiley, $xcodes, 1, $breaks); |
176
|
|
|
$thisterm['url'] = $myts->makeClickable($url, $allowimage = 0); |
|
|
|
|
177
|
|
|
//$thisterm['submitter'] = XoopsUserUtility::getUnameFromId ( $uid ); |
178
|
|
|
if (1 == $helper->getConfig('showsubmitter')) { |
179
|
|
|
$xoopsTpl->assign('showsubmitter', true); |
180
|
|
|
if (1 == $helper->getConfig('authorprofile')) { |
181
|
|
|
$thisterm['submitter'] = $utility::getLinkedProfileFromId($uid); |
182
|
|
|
} else { |
183
|
|
|
$thisterm['submitter'] = \XoopsUserUtility::getUnameFromId($uid); |
184
|
|
|
} |
185
|
|
|
} else { |
186
|
|
|
$xoopsTpl->assign('showsubmitter', false); |
187
|
|
|
} |
188
|
|
|
$thisterm['submit'] = (int)$submit; |
189
|
|
|
$thisterm['datesub'] = formatTimestamp($datesub, $helper->getConfig('dateformat')); |
190
|
|
|
$thisterm['counter'] = (int)$counter; |
191
|
|
|
$thisterm['block'] = (int)$block; |
192
|
|
|
$thisterm['dir'] = $xoopsModule->dirname(); |
193
|
|
|
if ($highlight && isset($_GET['keywords'])) { |
194
|
|
|
$keywords = htmlspecialchars(trim(urldecode($_GET['keywords'])), ENT_QUOTES | ENT_HTML5); |
195
|
|
|
$h = new Keyhighlighter($keywords, true, 'lx_myhighlighter'); |
196
|
|
|
$thisterm['definition'] = $h->highlight($thisterm['definition']); |
197
|
|
|
$thisterm['ref'] = $h->highlight($thisterm['ref']); |
198
|
|
|
} |
199
|
|
|
} |
200
|
|
|
//smartry strings |
201
|
|
|
$xoopsTpl->assign('thisterm', $thisterm); |
202
|
|
|
$microlinks = $utility::getServiceLinks($thisterm); |
203
|
|
|
$microlinksnew = $utility::getServiceLinksNew($thisterm); |
204
|
|
|
$xoopsTpl->assign('microlinks', $microlinks); |
205
|
|
|
$xoopsTpl->assign('microlinksnew', $microlinksnew); |
206
|
|
|
$xoopsTpl->assign('lang_modulename', $xoopsModule->name()); |
207
|
|
|
$xoopsTpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname')); |
208
|
|
|
$xoopsTpl->assign('entryID', $entryID); |
209
|
|
|
$xoopsTpl->assign('submittedon', sprintf(_MD_LEXIKON_SUBMITTEDON, $thisterm['datesub'])); |
210
|
|
|
if (1 == $helper->getConfig('showsubmitter')) { |
211
|
|
|
$xoopsTpl->assign('submitter', sprintf(_MD_LEXIKON_SUBMITTEDBY, $thisterm['submitter'])); |
212
|
|
|
} |
213
|
|
|
$xoopsTpl->assign('counter', sprintf(_MD_LEXIKON_COUNT, $thisterm['counter'])); |
214
|
|
|
$xoopsTpl->assign('entrytype', '1'); |
215
|
|
|
|
216
|
|
|
// --- keywordshighligher --- |
217
|
|
|
/** |
218
|
|
|
* @param $matches |
219
|
|
|
* @return string |
220
|
|
|
*/ |
221
|
|
|
function lx_myhighlighter($matches) |
222
|
|
|
{ |
223
|
|
|
return '<span style="font-weight: bolder; background-color: #FFFF80;">' . $matches[0] . '</span>'; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
|
227
|
|
|
//--- Display tags of this term |
228
|
|
|
$tagsmeta = ''; |
229
|
|
|
#$itemid = $entryID; |
230
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
231
|
|
|
//$moduleHandler = xoops_getHandler('module'); |
232
|
|
|
//$tagsModule = $moduleHandler->getByDirname('tag'); |
233
|
|
|
//if (is_object($tagsModule)) { |
234
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/tag/include/tagbar.php'; |
235
|
|
|
// |
236
|
|
|
// $itemid = Request::getInt('entryID', 0, 'GET'); |
237
|
|
|
// $catid = 0; |
238
|
|
|
// //$xoopsTpl->assign('tagbar', tagBar($itemid, $catid = 0)); |
239
|
|
|
// $tagbar = tagBar($itemid, $catid); |
240
|
|
|
// if ($tagbar) { |
241
|
|
|
// $xoopsTpl->assign('tagbar', $tagbar); |
242
|
|
|
// $tagsmeta = implode(' ', $tagbar['tags']); |
243
|
|
|
// } else { |
244
|
|
|
// $tagsmeta = ''; |
245
|
|
|
// } |
246
|
|
|
//} else { |
247
|
|
|
// $xoopsTpl->assign('tagbar', false); |
248
|
|
|
// $tagsmeta = ''; |
249
|
|
|
//} |
250
|
|
|
|
251
|
|
|
//--- linkterms assigns |
252
|
|
|
// Balloontips |
253
|
|
|
if (5 == $helper->getConfig('linkterms')) { |
254
|
|
|
$xoopsTpl->assign('balloontips', true); |
255
|
|
|
} else { |
256
|
|
|
$xoopsTpl->assign('balloontips', false); |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
// Show Bookmark icons ? |
260
|
|
|
switch ($helper->getConfig('bookmarkme')) { |
261
|
|
|
case '0': |
262
|
|
|
default: |
263
|
|
|
$xoopsTpl->assign('bookmarkme', false); |
264
|
|
|
break; |
265
|
|
|
case '1': |
266
|
|
|
$xoopsTpl->assign('bookmarkme', 1); |
267
|
|
|
$xoopsTpl->assign('encoded_title', rawurlencode($thisterm['term'])); |
268
|
|
|
break; |
269
|
|
|
case '2': |
270
|
|
|
$xoopsTpl->assign('bookmarkme', 2); |
271
|
|
|
break; |
272
|
|
|
case '3': |
273
|
|
|
$xoopsTpl->assign('bookmarkme', 3); |
274
|
|
|
break; |
275
|
|
|
} |
276
|
|
|
// Meta data |
277
|
|
|
$meta_description = xoops_substr($utility::convertHtml2text($thisterm['definition']), 0, 150); |
|
|
|
|
278
|
|
|
if (1 == $helper->getConfig('multicats')) { |
279
|
|
|
$utility::createPageTitle($thisterm['term'] . ' - ' . $thisterm['catname']); |
280
|
|
|
$utility::extractKeywords(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ,' . $thisterm['term'] . ' ,' . $thisterm['catname'] . ', ' . $meta_description . ', ' . $tagsmeta); |
281
|
|
|
$utility::getMetaDescription(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ' . $thisterm['catname'] . ' ' . $thisterm['term'] . ' ' . $meta_description); |
282
|
|
|
} else { |
283
|
|
|
$utility::createPageTitle($thisterm['term']); |
284
|
|
|
$utility::extractKeywords(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ,' . $thisterm['term'] . ', ' . $meta_description . ', ' . $tagsmeta); |
285
|
|
|
$utility::getMetaDescription(htmlspecialchars($xoopsModule->name(), ENT_QUOTES | ENT_HTML5) . ' ' . $thisterm['term'] . ' ' . $meta_description); |
286
|
|
|
} |
287
|
|
|
//Mondarse |
288
|
|
|
require XOOPS_ROOT_PATH . '/include/comment_view.php'; |
289
|
|
|
//Mondarse |
290
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
291
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.