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