1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* $Id: functions.php v 1.0 8 May 2004 hsalazar Exp $ |
4
|
|
|
* Module: Lexikon |
5
|
|
|
* Author: hsalazar |
6
|
|
|
* Additions and Modifications: Yerres |
7
|
|
|
* Licence: GNU |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
use Xmf\Request; |
11
|
|
|
use XoopsModules\Lexikon\{ |
12
|
|
|
Helper, |
13
|
|
|
Utility |
14
|
|
|
}; |
15
|
|
|
/** @var Helper $helper */ |
16
|
|
|
|
17
|
|
|
if (!defined('XOOPS_ROOT_PATH')) { |
18
|
|
|
exit('XOOPS root path not defined'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* lx_getLinkedUnameFromId() |
23
|
|
|
* |
24
|
|
|
* @param int $userid Userid of author etc |
25
|
|
|
* @param int $name : 0 Use Usenamer 1 Use realname |
26
|
|
|
* @return int|string |
27
|
|
|
*/ |
28
|
|
|
function lx_getLinkedUnameFromId($userid = 0, $name = 0) |
29
|
|
|
{ |
30
|
|
|
if (!is_numeric($userid)) { |
|
|
|
|
31
|
|
|
return $userid; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$userid = (int)$userid; |
35
|
|
|
if ($userid > 0) { |
36
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
37
|
|
|
$memberHandler = xoops_getHandler('member'); |
38
|
|
|
$user = $memberHandler->getUser($userid); |
39
|
|
|
|
40
|
|
|
if (is_object($user)) { |
41
|
|
|
$ts = \MyTextSanitizer::getInstance(); |
42
|
|
|
$username = $user->getVar('uname'); |
43
|
|
|
$usernameu = $user->getVar('name'); |
44
|
|
|
|
45
|
|
|
if ($name && !empty($usernameu)) { |
46
|
|
|
$username = $user->getVar('name'); |
47
|
|
|
} |
48
|
|
|
if (!empty($usernameu)) { |
49
|
|
|
$linkeduser = "$usernameu [<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . $ts->htmlSpecialChars($username) . '</a>]'; |
50
|
|
|
} else { |
51
|
|
|
$linkeduser = "<a href='" . XOOPS_URL . '/userinfo.php?uid=' . $userid . "'>" . ucfirst($ts->htmlSpecialChars($username)) . '</a>'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $linkeduser; |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return $GLOBALS['xoopsConfig']['anonymous']; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @param $user |
63
|
|
|
*/ |
64
|
|
|
function lx_getuserForm($user) |
65
|
|
|
{ |
66
|
|
|
global $xoopsDB, $xoopsConfig; |
67
|
|
|
|
68
|
|
|
echo "<select name='author'>"; |
69
|
|
|
echo "<option value='-1'>------</option>"; |
70
|
|
|
$result = $xoopsDB->query('SELECT uid, uname FROM ' . $xoopsDB->prefix('users') . ' ORDER BY uname'); |
71
|
|
|
|
72
|
|
|
while (list($uid, $uname) = $xoopsDB->fetchRow($result)) { |
73
|
|
|
if ($uid == $user) { |
74
|
|
|
$opt_selected = "selected='selected'"; |
75
|
|
|
} else { |
76
|
|
|
$opt_selected = ''; |
77
|
|
|
} |
78
|
|
|
echo "<option value='" . $uid . "' $opt_selected>" . $uname . '</option>'; |
79
|
|
|
} |
80
|
|
|
echo '</select></div>'; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* |
85
|
|
|
*/ |
86
|
|
|
function lx_calculateTotals() |
87
|
|
|
{ |
88
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule; |
89
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
90
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
91
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
92
|
|
|
|
93
|
|
|
$result01 = $xoopsDB->query('SELECT categoryID, total FROM ' . $xoopsDB->prefix('lxcategories') . ' '); |
94
|
|
|
[$totalcategories] = $xoopsDB->getRowsNum($result01); |
95
|
|
|
while (list($categoryID, $total) = $xoopsDB->fetchRow($result01)) { |
96
|
|
|
if ($grouppermHandler->checkRight('lexikon_view', $categoryID, $groups, $xoopsModule->getVar('mid'))) { |
97
|
|
|
$newcount = lx_countByCategory($categoryID); |
98
|
|
|
$xoopsDB->queryF('UPDATE ' . $xoopsDB->prefix('lxcategories') . " SET total = '$newcount' WHERE categoryID = '$categoryID'"); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param $c |
105
|
|
|
* @return int |
106
|
|
|
*/ |
107
|
|
|
function lx_countByCategory($c) |
108
|
|
|
{ |
109
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule; |
110
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
111
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
112
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
113
|
|
|
$count = 0; |
114
|
|
|
$sql = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE offline = '0' AND categoryID = '$c'"); |
115
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($sql))) { |
116
|
|
|
//if ($grouppermHandler->checkRight('lexikon_view', $c, $groups, $xoopsModule->getVar('mid'))) { |
117
|
|
|
$count++; |
118
|
|
|
//} |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
return $count; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return int |
126
|
|
|
*/ |
127
|
|
|
function lx_countCats() |
128
|
|
|
{ |
129
|
|
|
global $xoopsUser, $xoopsModule; |
130
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
131
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
132
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
133
|
|
|
$totalcats = $grouppermHandler->getItemIds('lexikon_view', $groups, $xoopsModule->getVar('mid')); |
134
|
|
|
|
135
|
|
|
return count($totalcats); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* @return int |
140
|
|
|
*/ |
141
|
|
|
function lx_countWords() |
142
|
|
|
{ |
143
|
|
|
global $xoopsUser, $xoopsDB; |
144
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
145
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
146
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
147
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
148
|
|
|
$moduleHandler = xoops_getHandler('module'); |
149
|
|
|
$module = $moduleHandler->getByDirname('lexikon'); |
150
|
|
|
$module_id = $module->getVar('mid'); |
151
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
152
|
|
|
$catids = implode(',', $allowed_cats); |
153
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
154
|
|
|
|
155
|
|
|
$pubwords = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit = '0' AND offline ='0' AND request = '0' " . $catperms . ' '); |
156
|
|
|
$publishedwords = $xoopsDB->getRowsNum($pubwords); |
157
|
|
|
|
158
|
|
|
return $publishedwords; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
// To display the list of categories |
162
|
|
|
/** |
163
|
|
|
* @return array |
164
|
|
|
*/ |
165
|
|
|
function lx_CatsArray() |
166
|
|
|
{ |
167
|
|
|
global $xoopsDB, $xoopsModuleConfig, $xoopsUser, $xoopsModule; |
168
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
169
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
170
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
171
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
172
|
|
|
$block0 = []; |
173
|
|
|
$count = 1; |
174
|
|
|
$resultcat = $xoopsDB->query('SELECT categoryID, name, total, logourl FROM ' . $xoopsDB->prefix('lxcategories') . ' ORDER BY weight ASC'); |
175
|
|
|
while (list($catID, $name, $total, $logourl) = $xoopsDB->fetchRow($resultcat)) { |
176
|
|
|
if ($grouppermHandler->checkRight('lexikon_view', $catID, $groups, $xoopsModule->getVar('mid'))) { |
177
|
|
|
$catlinks = []; |
178
|
|
|
$count++; |
179
|
|
|
if ($logourl && 'http://' !== $logourl) { |
180
|
|
|
$logourl = htmlspecialchars($logourl, ENT_QUOTES | ENT_HTML5); |
181
|
|
|
} else { |
182
|
|
|
$logourl = ''; |
183
|
|
|
} |
184
|
|
|
$xoopsModule = XoopsModule::getByDirname('lexikon'); |
185
|
|
|
$catlinks['id'] = (int)$catID; |
186
|
|
|
$catlinks['total'] = (int)$total; |
187
|
|
|
$catlinks['linktext'] = htmlspecialchars($name, ENT_QUOTES | ENT_HTML5); |
188
|
|
|
$catlinks['image'] = $logourl; |
189
|
|
|
$catlinks['count'] = $count; |
190
|
|
|
|
191
|
|
|
$block0['categories'][] = $catlinks; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
return $block0; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @return array |
200
|
|
|
*/ |
201
|
|
|
function lx_alphaArray() |
202
|
|
|
{ |
203
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule; |
204
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
205
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
206
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
207
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
208
|
|
|
$moduleHandler = xoops_getHandler('module'); |
209
|
|
|
$module = $moduleHandler->getByDirname('lexikon'); |
210
|
|
|
$module_id = $module->getVar('mid'); |
211
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
212
|
|
|
$catids = implode(',', $allowed_cats); |
213
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
214
|
|
|
$alpha = []; |
215
|
|
|
for ($a = 65; $a < (65 + 26); $a++) { |
216
|
|
|
$letterlinks = []; |
217
|
|
|
$initial = chr($a); |
218
|
|
|
$sql = $xoopsDB->query('SELECT entryID FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '$initial' AND submit = '0' AND offline ='0' AND request = '0' " . $catperms . ''); |
219
|
|
|
$howmany = $xoopsDB->getRowsNum($sql); |
220
|
|
|
$letterlinks['total'] = $howmany; |
221
|
|
|
$letterlinks['id'] = chr($a); |
222
|
|
|
$letterlinks['linktext'] = chr($a); |
223
|
|
|
|
224
|
|
|
$alpha['initial'][] = $letterlinks; |
225
|
|
|
} |
226
|
|
|
|
227
|
|
|
return $alpha; |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* chr() with unicode support |
232
|
|
|
* I found this on this site http://en.php.net/chr |
233
|
|
|
* don't take credit for this. |
234
|
|
|
* @param $initials |
235
|
|
|
* @return string |
236
|
|
|
*/ |
237
|
|
|
function lx_uchr($initials) |
238
|
|
|
{ |
239
|
|
|
if (is_scalar($initials)) { |
240
|
|
|
$initials = func_get_args(); |
241
|
|
|
} |
242
|
|
|
$str = ''; |
243
|
|
|
foreach ($initials as $init) { |
244
|
|
|
$str .= html_entity_decode('&#' . $init . ';', ENT_NOQUOTES, 'UTF-8'); |
245
|
|
|
} |
246
|
|
|
|
247
|
|
|
return $str; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/* sample */ |
251
|
|
|
/* |
252
|
|
|
echo lx_uchr(23383); echo '<br>'; |
253
|
|
|
echo lx_uchr(23383,215,23383); echo '<br>'; |
254
|
|
|
echo lx_uchr(array(23383,215,23383,215,23383)); echo '<br>'; |
255
|
|
|
*/ |
256
|
|
|
|
257
|
|
|
// Functional links |
258
|
|
|
/** |
259
|
|
|
* @param $variable |
260
|
|
|
* @return string |
261
|
|
|
*/ |
262
|
|
|
function lx_serviceLinks($variable) |
263
|
|
|
{ |
264
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsConfig, $entrytype; |
265
|
|
|
|
266
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
267
|
|
|
$moduleHandler = xoops_getHandler('module'); |
268
|
|
|
$moduleInfo = $moduleHandler->get($xoopsModule->getVar('mid')); |
269
|
|
|
$pathIcon16 = $xoopsModule->getInfo('icons16'); |
270
|
|
|
$helper = Helper::getInstance(); |
271
|
|
|
|
272
|
|
|
$srvlinks = ''; |
273
|
|
|
if ($xoopsUser) { |
274
|
|
|
if ($xoopsUser->isAdmin()) { |
275
|
|
|
$srvlinks .= '<a title="' |
276
|
|
|
. _EDIT |
277
|
|
|
. '" href="admin/entry.php?op=mod&entryID=' |
278
|
|
|
. $variable['id'] |
279
|
|
|
. '" target="_blank"><img src="' |
280
|
|
|
. $pathIcon16 |
281
|
|
|
. '/edit.png" alt="' |
282
|
|
|
. _MD_LEXIKON_EDITTERM |
283
|
|
|
. '" style="width:16px; height:16px;"></a> <a TITLE="' |
284
|
|
|
. _DELETE |
285
|
|
|
. '" href="admin/entry.php?op=del&entryID=' |
286
|
|
|
. $variable['id'] |
287
|
|
|
. '" target="_self"><img src="' |
288
|
|
|
. $pathIcon16 |
289
|
|
|
. '/delete.png" alt="' |
290
|
|
|
. _MD_LEXIKON_DELTERM |
291
|
|
|
. '" style="width:16px; height:16px;"></a> '; |
292
|
|
|
} |
293
|
|
|
} |
294
|
|
|
if ('1' != $entrytype) { |
295
|
|
|
$srvlinks .= '<a title="' |
296
|
|
|
. _MD_LEXIKON_PRINTTERM |
297
|
|
|
. '" href="print.php?entryID=' |
298
|
|
|
. $variable['id'] |
299
|
|
|
. '" target="_blank"><img src="' |
300
|
|
|
. $pathIcon16 |
301
|
|
|
. '/printer.png" alt="' |
302
|
|
|
. _MD_LEXIKON_PRINTTERM |
303
|
|
|
. '" style="width:16px; height:16px;"></a> <a TITLE="' |
304
|
|
|
. _MD_LEXIKON_SENDTOFRIEND |
305
|
|
|
. '" href="mailto:?subject=' |
306
|
|
|
. sprintf(_MD_LEXIKON_INTENTRY, $xoopsConfig['sitename']) |
307
|
|
|
. '&body=' |
308
|
|
|
. sprintf(_MD_LEXIKON_INTENTRYFOUND, $xoopsConfig['sitename']) |
309
|
|
|
. ': ' |
310
|
|
|
. XOOPS_URL |
311
|
|
|
. '/modules/' |
312
|
|
|
. $xoopsModule->dirname() |
313
|
|
|
. '/entry.php?entryID=' |
314
|
|
|
. $variable['id'] |
315
|
|
|
. ' " target="_blank"><img src="' |
316
|
|
|
. $pathIcon16 |
317
|
|
|
. '/mail_replay.png" alt="' |
318
|
|
|
. _MD_LEXIKON_SENDTOFRIEND |
319
|
|
|
. '" style="width:16px; height:16px;"></a> '; |
320
|
|
|
if ((0 != $helper->getConfig('com_rule')) && (!empty($helper->getConfig('com_anonpost')) || is_object($xoopsUser))) { |
321
|
|
|
$srvlinks .= '<a title="' . _COMMENTS . '?" href="comment_new.php?com_itemid=' . $variable['id'] . '" target="_parent"><img src="images/comments.gif" alt="' . _COMMENTS . '?" style="width:16px; height:16px;"></a> '; |
322
|
|
|
} |
323
|
|
|
} |
324
|
|
|
|
325
|
|
|
return $srvlinks; |
326
|
|
|
} |
327
|
|
|
|
328
|
|
|
// entry footer |
329
|
|
|
/** |
330
|
|
|
* @param $variable |
331
|
|
|
* @return string |
332
|
|
|
*/ |
333
|
|
|
function lx_serviceLinksnew($variable) |
334
|
|
|
{ |
335
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsConfig, $myts; |
336
|
|
|
$srvlinks2 = '<a title="' |
337
|
|
|
. _MD_LEXIKON_PRINTTERM |
338
|
|
|
. '" href="print.php?entryID=' |
339
|
|
|
. $variable['id'] |
340
|
|
|
. '" target="_blank"><img src="images/print.gif" alt="' |
341
|
|
|
. _MD_LEXIKON_PRINTTERM |
342
|
|
|
. '" style="vertical-align: middle; width:16px; height:16px; margin: 2px 4px;"> ' |
343
|
|
|
. _MD_LEXIKON_PRINTTERM2 |
344
|
|
|
. '</a> <a title="' |
345
|
|
|
. _MD_LEXIKON_SENDTOFRIEND |
346
|
|
|
. '" href="mailto:?subject=' |
347
|
|
|
. sprintf(_MD_LEXIKON_INTENTRY, $xoopsConfig['sitename']) |
348
|
|
|
. '&body=' |
349
|
|
|
. sprintf(_MD_LEXIKON_INTENTRYFOUND, $xoopsConfig['sitename']) |
350
|
|
|
. ': ' |
351
|
|
|
. $variable['term'] |
352
|
|
|
. ' ' |
353
|
|
|
. XOOPS_URL |
354
|
|
|
. '/modules/' |
355
|
|
|
. $xoopsModule->dirname() |
356
|
|
|
. '/entry.php?entryID=' |
357
|
|
|
. $variable['id'] |
358
|
|
|
. ' " target="_blank"><img src="images/friend.gif" alt="' |
359
|
|
|
. _MD_LEXIKON_SENDTOFRIEND |
360
|
|
|
. '" style="vertical-align: middle; width:16px; height:16px; margin: 2px 4px;"> ' |
361
|
|
|
. _MD_LEXIKON_SENDTOFRIEND2 |
362
|
|
|
. '</a> '; |
363
|
|
|
|
364
|
|
|
return $srvlinks2; |
365
|
|
|
} |
366
|
|
|
|
367
|
|
|
/** |
368
|
|
|
* @return string |
369
|
|
|
*/ |
370
|
|
|
function lx_showSearchForm() |
371
|
|
|
{ |
372
|
|
|
global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsConfig; |
373
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
374
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
375
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
376
|
|
|
|
377
|
|
|
$searchform = '<table style="width:100%;">'; |
378
|
|
|
$searchform .= '<form name="op" id="op" action="search.php" method="post">'; |
379
|
|
|
$searchform .= '<tr><td style="text-align: right; line-height: 200%; width:150px;">'; |
380
|
|
|
$searchform .= _MD_LEXIKON_LOOKON . '</td><td style="width:10px;"> </td><td style="text-align: left;">'; |
381
|
|
|
$searchform .= '<select name="type"><option value="1">' . _MD_LEXIKON_TERMS . '</option><option value="2">' . _MD_LEXIKON_DEFINS . '</option>'; |
382
|
|
|
$searchform .= '<option SELECTED value="3">' . _MD_LEXIKON_TERMSDEFS . '</option></select></td></tr>'; |
383
|
|
|
|
384
|
|
|
if (1 == $helper->getConfig('multicats')) { |
385
|
|
|
$searchform .= '<tr><td style="text-align: right; line-height: 200%;">' . _MD_LEXIKON_CATEGORY . '</td>'; |
386
|
|
|
$searchform .= '<td> </td><td style="text-align: left;">'; |
387
|
|
|
$resultcat = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . ' ORDER BY categoryID'); |
388
|
|
|
$searchform .= '<select name="categoryID">'; |
389
|
|
|
$searchform .= '<option value="0">' . _MD_LEXIKON_ALLOFTHEM . '</option>'; |
390
|
|
|
|
391
|
|
|
while (list($categoryID, $name) = $xoopsDB->fetchRow($resultcat)) { |
392
|
|
|
if ($grouppermHandler->checkRight('lexikon_view', (int)$categoryID, $groups, $xoopsModule->getVar('mid'))) { |
393
|
|
|
$searchform .= "<option value=\"$categoryID\">$categoryID : $name</option>"; |
394
|
|
|
} |
395
|
|
|
} |
396
|
|
|
$searchform .= '</select></td></tr>'; |
397
|
|
|
} |
398
|
|
|
|
399
|
|
|
$searchform .= '<tr><td style="text-align: right; line-height: 200%;">'; |
400
|
|
|
$searchform .= _MD_LEXIKON_TERM . '</td><td> </td><td style="text-align: left;">'; |
401
|
|
|
$searchform .= '<input type="text" name="term" class="searchBox" ></td></tr><tr>'; |
402
|
|
|
$searchform .= '<td> </td><td> </td><td><input type="submit" class="btnDefault" value="' . _MD_LEXIKON_SEARCH . '" >'; |
403
|
|
|
$searchform .= '</td></tr></form></table>'; |
404
|
|
|
|
405
|
|
|
return $searchform; |
406
|
|
|
} |
407
|
|
|
|
408
|
|
|
/** |
409
|
|
|
* @param $needle |
410
|
|
|
* @param $haystack |
411
|
|
|
* @param $hlS |
412
|
|
|
* @param $hlE |
413
|
|
|
* @return string |
414
|
|
|
*/ |
415
|
|
|
function lx_getHTMLHighlight($needle, $haystack, $hlS, $hlE) |
416
|
|
|
{ |
417
|
|
|
$parts = explode('>', $haystack); |
418
|
|
|
foreach ($parts as $key => $part) { |
419
|
|
|
$pL = ''; |
420
|
|
|
$pR = ''; |
421
|
|
|
|
422
|
|
|
if (false === ($pos = mb_strpos($part, '<'))) { |
423
|
|
|
$pL = $part; |
424
|
|
|
} elseif ($pos > 0) { |
425
|
|
|
$pL = mb_substr($part, 0, $pos); |
426
|
|
|
$pR = mb_substr($part, $pos, mb_strlen($part)); |
427
|
|
|
} |
428
|
|
|
if ('' != $pL) { |
429
|
|
|
$parts[$key] = preg_replace('|(' . quotemeta($needle) . ')|iU', $hlS . '\\1' . $hlE, $pL) . $pR; |
430
|
|
|
} |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
return implode('>', $parts); |
434
|
|
|
} |
435
|
|
|
|
436
|
|
|
/* ******************************************************************************* |
437
|
|
|
* Most of the following functions are modified functions from Herve's News Module |
438
|
|
|
* other functions are from AMS by Novasmart/Mithrandir |
439
|
|
|
* others from Red Mexico Soft Rmdp |
440
|
|
|
* others from Xhelp 0.78 thanks to ackbarr and eric_juden |
441
|
|
|
* ******************************************************************************* |
442
|
|
|
*/ |
443
|
|
|
|
444
|
|
|
// Create the meta keywords based on content |
445
|
|
|
/** |
446
|
|
|
* @param $content |
447
|
|
|
*/ |
448
|
|
|
function lx_extract_keywords($content) |
449
|
|
|
{ |
450
|
|
|
global $xoopsTpl, $xoTheme, $xoopsModule, $xoopsModuleConfig; |
451
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php'; |
452
|
|
|
$keywords_count = $helper->getConfig('metakeywordsnum'); |
453
|
|
|
$tmp = []; |
454
|
|
|
if (Request::hasVar('xoops_keywords_limit', 'SESSION')) { // Search the "Minimum keyword length" |
455
|
|
|
$limit = $_SESSION['xoops_keywords_limit']; |
456
|
|
|
} else { |
457
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
458
|
|
|
$configHandler = xoops_getHandler('config'); |
459
|
|
|
$xoopsConfigSearch = $configHandler->getConfigsByCat(XOOPS_CONF_SEARCH); |
460
|
|
|
$limit = $xoopsConfigSearch['keyword_min']; |
461
|
|
|
$_SESSION['xoops_keywords_limit'] = $limit; |
462
|
|
|
} |
463
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
464
|
|
|
$content = str_replace('<br >', ' ', $content); |
465
|
|
|
$content = $myts->undoHtmlSpecialChars($content); |
466
|
|
|
$content = strip_tags($content); |
467
|
|
|
$content = mb_strtolower($content); |
468
|
|
|
$search_pattern = [ |
469
|
|
|
' ', |
470
|
|
|
"\t", |
471
|
|
|
"\r\n", |
472
|
|
|
"\r", |
473
|
|
|
"\n", |
474
|
|
|
',', |
475
|
|
|
'.', |
476
|
|
|
"'", |
477
|
|
|
';', |
478
|
|
|
':', |
479
|
|
|
')', |
480
|
|
|
'(', |
481
|
|
|
'"', |
482
|
|
|
'?', |
483
|
|
|
'!', |
484
|
|
|
'{', |
485
|
|
|
'}', |
486
|
|
|
'[', |
487
|
|
|
']', |
488
|
|
|
'<', |
489
|
|
|
'>', |
490
|
|
|
'/', |
491
|
|
|
'+', |
492
|
|
|
'-', |
493
|
|
|
'_', |
494
|
|
|
'\\', |
495
|
|
|
'*', |
496
|
|
|
]; |
497
|
|
|
$replace_pattern = [ |
498
|
|
|
' ', |
499
|
|
|
' ', |
500
|
|
|
' ', |
501
|
|
|
' ', |
502
|
|
|
' ', |
503
|
|
|
' ', |
504
|
|
|
' ', |
505
|
|
|
' ', |
506
|
|
|
'', |
507
|
|
|
'', |
508
|
|
|
'', |
509
|
|
|
'', |
510
|
|
|
'', |
511
|
|
|
'', |
512
|
|
|
'', |
513
|
|
|
'', |
514
|
|
|
'', |
515
|
|
|
'', |
516
|
|
|
'', |
517
|
|
|
'', |
518
|
|
|
'', |
519
|
|
|
'', |
520
|
|
|
'', |
521
|
|
|
'', |
522
|
|
|
'', |
523
|
|
|
'', |
524
|
|
|
'', |
525
|
|
|
]; |
526
|
|
|
$content = str_replace($search_pattern, $replace_pattern, $content); |
527
|
|
|
$keywords = explode(' ', $content); |
528
|
|
|
switch (META_KEYWORDS_ORDER) { |
529
|
|
|
case 1: // Returns keywords in the same order that they were created in the text |
530
|
|
|
$keywords = array_unique($keywords); |
531
|
|
|
break; |
532
|
|
|
case 2: // the keywords order is made according to the reverse keywords frequency (so the less frequent words appear in first in the list) |
533
|
|
|
$keywords = array_count_values($keywords); |
534
|
|
|
asort($keywords); |
535
|
|
|
$keywords = array_keys($keywords); |
536
|
|
|
break; |
537
|
|
|
case 3: // Same as previous, the only difference is that the most frequent words will appear in first in the list |
538
|
|
|
$keywords = array_count_values($keywords); |
539
|
|
|
arsort($keywords); |
540
|
|
|
$keywords = array_keys($keywords); |
541
|
|
|
break; |
542
|
|
|
} |
543
|
|
|
foreach ($keywords as $keyword) { |
544
|
|
|
if (mb_strlen($keyword) >= $limit && !is_numeric($keyword)) { |
545
|
|
|
$tmp[] = $keyword; |
546
|
|
|
} |
547
|
|
|
} |
548
|
|
|
$tmp = array_slice($tmp, 0, $keywords_count); |
549
|
|
|
if (count($tmp) > 0) { |
550
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
551
|
|
|
$xoTheme->addMeta('meta', 'keywords', implode(',', $tmp)); |
552
|
|
|
} else { // Compatibility for old Xoops versions |
553
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', implode(',', $tmp)); |
554
|
|
|
} |
555
|
|
|
} else { |
556
|
|
|
if (!isset($configHandler) || !is_object($configHandler)) { |
557
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
558
|
|
|
$configHandler = xoops_getHandler('config'); |
559
|
|
|
} |
560
|
|
|
$xoopsConfigMetaFooter = $configHandler->getConfigsByCat(XOOPS_CONF_METAFOOTER); |
561
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
562
|
|
|
$xoTheme->addMeta('meta', 'keywords', $xoopsConfigMetaFooter['meta_keywords']); |
563
|
|
|
} else { // Compatibility for old Xoops versions |
564
|
|
|
$xoopsTpl->assign('xoops_meta_keywords', $xoopsConfigMetaFooter['meta_keywords']); |
565
|
|
|
} |
566
|
|
|
} |
567
|
|
|
} |
568
|
|
|
|
569
|
|
|
// Create meta description based on content |
570
|
|
|
/** |
571
|
|
|
* @param $content |
572
|
|
|
*/ |
573
|
|
|
function lx_get_metadescription($content) |
574
|
|
|
{ |
575
|
|
|
global $xoopsTpl, $xoTheme; |
576
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
577
|
|
|
$content = $myts->undoHtmlSpecialChars($myts->displayTarea($content)); |
578
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
579
|
|
|
$xoTheme->addMeta('meta', 'description', strip_tags($content)); |
580
|
|
|
} else { // Compatibility for old Xoops versions |
581
|
|
|
$xoopsTpl->assign('xoops_meta_description', strip_tags($content)); |
582
|
|
|
} |
583
|
|
|
} |
584
|
|
|
|
585
|
|
|
// Create pagetitles |
586
|
|
|
/** |
587
|
|
|
* @param string $article |
588
|
|
|
* @param string $topic |
589
|
|
|
*/ |
590
|
|
|
function lx_create_pagetitle($article = '', $topic = '') |
591
|
|
|
{ |
592
|
|
|
global $xoopsModule, $xoopsTpl; |
593
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
594
|
|
|
$content = ''; |
595
|
|
|
if (!empty($article)) { |
596
|
|
|
$content .= strip_tags($myts->displayTarea($article)); |
597
|
|
|
} |
598
|
|
|
if (!empty($topic)) { |
599
|
|
|
if ('' != xoops_trim($content)) { |
600
|
|
|
$content .= ' - ' . strip_tags($myts->displayTarea($topic)); |
601
|
|
|
} else { |
602
|
|
|
$content .= strip_tags($myts->displayTarea($topic)); |
603
|
|
|
} |
604
|
|
|
} |
605
|
|
|
if (is_object($xoopsModule) && '' != xoops_trim($xoopsModule->name())) { |
606
|
|
|
if ('' != xoops_trim($content)) { |
607
|
|
|
$content .= ' - ' . strip_tags($myts->displayTarea($xoopsModule->name())); |
608
|
|
|
} else { |
609
|
|
|
$content .= strip_tags($myts->displayTarea($xoopsModule->name())); |
610
|
|
|
} |
611
|
|
|
} |
612
|
|
|
if ('' != $content) { |
613
|
|
|
$xoopsTpl->assign('xoops_pagetitle', $content); |
614
|
|
|
} |
615
|
|
|
} |
616
|
|
|
|
617
|
|
|
// clear descriptions |
618
|
|
|
/** |
619
|
|
|
* @param $document |
620
|
|
|
* @return null|string|string[] |
621
|
|
|
*/ |
622
|
|
|
function lx_html2text($document) |
623
|
|
|
{ |
624
|
|
|
// PHP Manual:: function preg_replace $document should contain an HTML document. |
625
|
|
|
// This will remove HTML tags, javascript sections and white space. It will also |
626
|
|
|
// convert some common HTML entities to their text equivalent. |
627
|
|
|
|
628
|
|
|
$search = [ |
629
|
|
|
"'<script[^>]*?>.*?</script>'si", // Strip out javascript |
630
|
|
|
"'<[\/\!]*?[^<>]*?>'si", // Strip out HTML tags |
631
|
|
|
"'([\r\n])[\s]+'", // Strip out white space |
632
|
|
|
"'&(quot|#34);'i", // Replace HTML entities |
633
|
|
|
"'&(amp|#38);'i", |
634
|
|
|
"'&(lt|#60);'i", |
635
|
|
|
"'&(gt|#62);'i", |
636
|
|
|
"'&(nbsp|#160);'i", |
637
|
|
|
"'&(iexcl|#161);'i", |
638
|
|
|
"'&(cent|#162);'i", |
639
|
|
|
"'&(pound|#163);'i", |
640
|
|
|
"'&(copy|#169);'i", |
641
|
|
|
]; |
642
|
|
|
|
643
|
|
|
$replace = [ |
644
|
|
|
'', |
645
|
|
|
'', |
646
|
|
|
'\\1', |
647
|
|
|
'"', |
648
|
|
|
'&', |
649
|
|
|
'<', |
650
|
|
|
'>', |
651
|
|
|
' ', |
652
|
|
|
chr(161), |
653
|
|
|
chr(162), |
654
|
|
|
chr(163), |
655
|
|
|
chr(169), |
656
|
|
|
]; |
657
|
|
|
|
658
|
|
|
$text = preg_replace($search, $replace, $document); |
659
|
|
|
|
660
|
|
|
$text = preg_replace_callback('&#(\d+)&', create_function('$matches', 'return chr($matches[1]);'), $text); |
661
|
|
|
|
662
|
|
|
return $text; |
663
|
|
|
} |
664
|
|
|
|
665
|
|
|
//Retrieve moduleoptions equivalent to $Xoopsmoduleconfig |
666
|
|
|
/** |
667
|
|
|
* @param $option |
668
|
|
|
* @param string $repmodule |
669
|
|
|
* @return bool|mixed |
670
|
|
|
*/ |
671
|
|
|
function lx_getmoduleoption($option, $repmodule = 'lexikon') |
672
|
|
|
{ |
673
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
674
|
|
|
static $tbloptions = []; |
675
|
|
|
if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
676
|
|
|
return $tbloptions[$option]; |
677
|
|
|
} |
678
|
|
|
|
679
|
|
|
$retval = false; |
680
|
|
|
if (isset($xoopsModuleConfig) && (is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $repmodule && $xoopsModule->getVar('isactive'))) { |
681
|
|
|
if (isset($xoopsModuleConfig[$option])) { |
682
|
|
|
$retval = $xoopsModuleConfig[$option]; |
683
|
|
|
} |
684
|
|
|
} else { |
685
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
686
|
|
|
$moduleHandler = xoops_getHandler('module'); |
687
|
|
|
$module = $moduleHandler->getByDirname($repmodule); |
688
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
689
|
|
|
$configHandler = xoops_getHandler('config'); |
690
|
|
|
if ($module) { |
691
|
|
|
$moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
692
|
|
|
if (isset($moduleConfig[$option])) { |
693
|
|
|
$retval = $moduleConfig[$option]; |
694
|
|
|
} |
695
|
|
|
} |
696
|
|
|
} |
697
|
|
|
$tbloptions[$option] = $retval; |
698
|
|
|
|
699
|
|
|
return $retval; |
700
|
|
|
} |
701
|
|
|
|
702
|
|
|
/** |
703
|
|
|
* Is Xoops 2.3.x ? |
704
|
|
|
* |
705
|
|
|
* @return bool need to say it ? |
706
|
|
|
*/ |
707
|
|
|
function lx_isX23() |
708
|
|
|
{ |
709
|
|
|
$x23 = false; |
710
|
|
|
$xv = str_replace('XOOPS ', '', XOOPS_VERSION); |
711
|
|
|
if (mb_substr($xv, 2, 1) >= '3') { |
712
|
|
|
$x23 = true; |
713
|
|
|
} |
714
|
|
|
|
715
|
|
|
return $x23; |
716
|
|
|
} |
717
|
|
|
|
718
|
|
|
/** |
719
|
|
|
* Retreive an editor according to the module's option "form_options" |
720
|
|
|
* following function is from News modified by trabis |
721
|
|
|
* @param $caption |
722
|
|
|
* @param $name |
723
|
|
|
* @param string $value |
724
|
|
|
* @param string $width |
725
|
|
|
* @param string $height |
726
|
|
|
* @param string $supplemental |
727
|
|
|
* @return bool|\XoopsFormDhtmlTextArea|\XoopsFormEditor|\XoopsFormHtmlarea|\XoopsFormTextArea|\XoopsFormTinyeditorTextArea |
728
|
|
|
*/ |
729
|
|
|
function &lx_getWysiwygForm($caption, $name, $value = '', $width = '100%', $height = '400px', $supplemental = '') |
730
|
|
|
{ |
731
|
|
|
$editor_option = mb_strtolower(lx_getmoduleoption('form_options')); |
732
|
|
|
$editor = false; |
733
|
|
|
$editor_configs = []; |
734
|
|
|
$editor_configs['name'] = $name; |
735
|
|
|
$editor_configs['value'] = $value; |
736
|
|
|
$editor_configs['rows'] = 35; |
737
|
|
|
$editor_configs['cols'] = 60; |
738
|
|
|
$editor_configs['width'] = '100%'; |
739
|
|
|
$editor_configs['height'] = '350px'; |
740
|
|
|
$editor_configs['editor'] = $editor_option; |
741
|
|
|
|
742
|
|
|
if (lx_isX23()) { |
743
|
|
|
$editor = new \XoopsFormEditor($caption, $name, $editor_configs); |
744
|
|
|
|
745
|
|
|
return $editor; |
746
|
|
|
} |
747
|
|
|
|
748
|
|
|
// Only for Xoops 2.0.x |
749
|
|
|
switch ($editor_option) { |
750
|
|
|
case 'htmlarea': |
751
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php')) { |
752
|
|
|
require_once XOOPS_ROOT_PATH . '/class/htmlarea/formhtmlarea.php'; |
753
|
|
|
$editor = new \XoopsFormHtmlarea($caption, $name, $value); |
754
|
|
|
} |
755
|
|
|
break; |
756
|
|
|
case 'dhtmltextarea': |
757
|
|
|
case 'dhtml': |
758
|
|
|
$editor = new \XoopsFormDhtmlTextArea($caption, $name, $value, 10, 50, $supplemental); |
759
|
|
|
break; |
760
|
|
|
case 'textarea': |
761
|
|
|
$editor = new \XoopsFormTextArea($caption, $name, $value); |
762
|
|
|
break; |
763
|
|
|
case 'tinyeditor': |
764
|
|
|
case 'tinymce': |
765
|
|
|
if (is_readable(XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php')) { |
766
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopseditor/tinyeditor/formtinyeditortextarea.php'; |
767
|
|
|
$editor = new \XoopsFormTinyeditorTextArea(['caption' => $caption, 'name' => $name, 'value' => $value, 'width' => '100%', 'height' => '400px']); |
768
|
|
|
} |
769
|
|
|
break; |
770
|
|
|
} |
771
|
|
|
|
772
|
|
|
return $editor; |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
/** |
776
|
|
|
* linkterms: assign module header |
777
|
|
|
* |
778
|
|
|
* tooltips (c) dhtmlgoodies |
779
|
|
|
*/ |
780
|
|
|
function lx_module_header() |
781
|
|
|
{ |
782
|
|
|
global $xoopsTpl, $xoTheme, $xoopsModule, $xoopsModuleConfig, $lexikon_module_header; |
783
|
|
|
if (isset($xoTheme) && is_object($xoTheme)) { |
784
|
|
|
$xoTheme->addStylesheet('modules/lexikon/assets/css/style.css'); |
785
|
|
|
if (3 == $helper->getConfig('linkterms')) { |
786
|
|
|
$xoTheme->addStylesheet('modules/lexikon/assets/css/linkterms.css'); |
787
|
|
|
$xoTheme->addScript('/modules/lexikon/assets/js/tooltipscript2.js', ['type' => 'text/javascript']); |
788
|
|
|
} |
789
|
|
|
if (4 == $helper->getConfig('linkterms')) { |
790
|
|
|
$xoTheme->addScript('/modules/lexikon/assets/js/popup.js', ['type' => 'text/javascript']); |
791
|
|
|
} |
792
|
|
|
if (5 == $helper->getConfig('linkterms')) { |
793
|
|
|
$xoTheme->addStylesheet('modules/lexikon/assets/css/linkterms.css'); |
794
|
|
|
$xoTheme->addScript('/modules/lexikon/assets/js/balloontooltip.js', ['type' => 'text/javascript']); |
795
|
|
|
} |
796
|
|
|
if (6 == $helper->getConfig('linkterms')) { |
797
|
|
|
$xoTheme->addStylesheet('modules/lexikon/assets/css/linkterms.css'); |
798
|
|
|
$xoTheme->addScript('/modules/lexikon/assets/js/shadowtooltip.js', ['type' => 'text/javascript']); |
799
|
|
|
} |
800
|
|
|
} else { |
801
|
|
|
$lexikon_url = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname'); |
802
|
|
|
if (3 == $helper->getConfig('linkterms')) { |
803
|
|
|
$lexikon_module_header = '<link rel="stylesheet" type="text/css" href="style.css" > |
804
|
|
|
<link rel="stylesheet" type="text/css" href="assets/css/linkterms.css" > |
805
|
|
|
<script src="' . $lexikon_url . '/assets/js/tooltipscript2.js" type="text/javascript"></script>'; |
806
|
|
|
} |
807
|
|
|
if (4 == $helper->getConfig('linkterms')) { |
808
|
|
|
$lexikon_module_header = '<link rel="stylesheet" type="text/css" href="style.css" > |
809
|
|
|
<link rel="stylesheet" type="text/css" href="assets/css/linkterms.css" > |
810
|
|
|
<script src="' . $lexikon_url . '/assets/js/popup.js" type="text/javascript"></script>'; |
811
|
|
|
} |
812
|
|
|
if (5 == $helper->getConfig('linkterms')) { |
813
|
|
|
$lexikon_module_header = '<link rel="stylesheet" type="text/css" href="style.css" > |
814
|
|
|
<link rel="stylesheet" type="text/css" href="assets/css/linkterms.css" > |
815
|
|
|
<script src="' . $lexikon_url . '/assets/js/balloontooltip.js" type="text/javascript"></script>'; |
816
|
|
|
} |
817
|
|
|
if (6 == $helper->getConfig('linkterms')) { |
818
|
|
|
$lexikon_module_header = '<link rel="stylesheet" type="text/css" href="style.css" > |
819
|
|
|
<link rel="stylesheet" type="text/css" href="assets/css/linkterms.css" > |
820
|
|
|
<script src="' . $lexikon_url . '/assets/js/shadowtooltip.js" type="text/javascript"></script>'; |
821
|
|
|
} |
822
|
|
|
} |
823
|
|
|
} |
824
|
|
|
|
825
|
|
|
/** |
826
|
|
|
* Validate userid |
827
|
|
|
* @param $uids |
828
|
|
|
* @return array|bool|false |
829
|
|
|
*/ |
830
|
|
|
function lx_val_user_data($uids) |
831
|
|
|
{ |
832
|
|
|
global $xoopsDB, $xoopsUser, $xoopsUserIsAdmin; |
833
|
|
|
|
834
|
|
|
if ($uids <= 0) { |
835
|
|
|
return false; |
836
|
|
|
} |
837
|
|
|
if ($uids > 0) { |
838
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
839
|
|
|
$memberHandler = xoops_getHandler('member'); |
840
|
|
|
$user = $memberHandler->getUser($uids); |
841
|
|
|
if (!is_object($user)) { |
842
|
|
|
return false; |
843
|
|
|
} |
844
|
|
|
} |
845
|
|
|
$result = $xoopsDB->query('SELECT * FROM ' . $xoopsDB->prefix('users') . " WHERE uid='$uids'"); |
846
|
|
|
if ($xoopsDB->getRowsNum($result) <= 0) { |
847
|
|
|
return false; |
848
|
|
|
} |
849
|
|
|
$row = $xoopsDB->fetchArray($result); |
850
|
|
|
|
851
|
|
|
return $row; |
852
|
|
|
} |
853
|
|
|
|
854
|
|
|
// Get all terms published by an author |
855
|
|
|
/** |
856
|
|
|
* @param $uid |
857
|
|
|
*/ |
858
|
|
|
function lx_AuthorProfile($uid) |
859
|
|
|
{ |
860
|
|
|
require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
861
|
|
|
global $authortermstotal, $xoopsTpl, $xoopsDB, $xoopsUser, $xoopsModuleConfig; |
862
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
863
|
|
|
//permissions |
864
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
865
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
866
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
867
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
868
|
|
|
$moduleHandler = xoops_getHandler('module'); |
869
|
|
|
$module = $moduleHandler->getByDirname('lexikon'); |
870
|
|
|
$module_id = $module->getVar('mid'); |
871
|
|
|
$allowed_cats = $grouppermHandler->getItemIds('lexikon_view', $groups, $module_id); |
872
|
|
|
$catids = implode(',', $allowed_cats); |
873
|
|
|
$catperms = " AND categoryID IN ($catids) "; |
874
|
|
|
|
875
|
|
|
$start = Request::getInt('start', 0, 'GET'); |
876
|
|
|
$limit = $helper->getConfig('indexperpage'); |
877
|
|
|
|
878
|
|
|
$sql = $xoopsDB->query( |
879
|
|
|
'SELECT * |
880
|
|
|
FROM ' . $xoopsDB->prefix('lxentries') . " |
881
|
|
|
WHERE uid='" . (int)$uid . "' AND offline = '0' AND submit = '0' AND request = '0' " . $catperms . " |
882
|
|
|
ORDER BY term |
883
|
|
|
LIMIT $start,$limit" |
884
|
|
|
); |
885
|
|
|
|
886
|
|
|
while (false !== ($row = $xoopsDB->fetchArray($sql))) { |
887
|
|
|
$xoopsTpl->append('entries', ['id' => $row['entryID'], 'name' => $row['term'], 'date' => date($helper->getConfig('dateformat'), $row['datesub']), 'counter' => $row['counter']]); |
888
|
|
|
} |
889
|
|
|
|
890
|
|
|
$navstring = ''; |
891
|
|
|
$navstring .= 'uid=' . $uid . '&start'; |
892
|
|
|
$pagenav = new \XoopsPageNav($authortermstotal, $helper->getConfig('indexperpage'), $start, $navstring); |
893
|
|
|
$authortermsarr['navbar'] = '<span style="text-align:right;">' . $pagenav->renderNav(6) . '</span>'; |
894
|
|
|
$xoopsTpl->assign('authortermsarr', $authortermsarr); |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
// Returns the author's IDs for authorslist |
898
|
|
|
/** |
899
|
|
|
* @param int $limit |
900
|
|
|
* @param int $start |
901
|
|
|
* @return array |
902
|
|
|
*/ |
903
|
|
|
function lx_getAuthors($limit = 0, $start = 0) |
904
|
|
|
{ |
905
|
|
|
global $xoopsDB; |
906
|
|
|
|
907
|
|
|
$ret = []; |
908
|
|
|
$sql = 'SELECT DISTINCT(uid) AS uid FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE offline = 0 '; |
909
|
|
|
$sql .= ' ORDER BY uid'; |
910
|
|
|
$result = $xoopsDB->query($sql); |
911
|
|
|
while (false !== ($myrow = $xoopsDB->fetchArray($result))) { |
912
|
|
|
$ret[] = $myrow['uid']; |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
return $ret; |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
// link to userprofile |
919
|
|
|
/** |
920
|
|
|
* @param $userid |
921
|
|
|
* @return string |
922
|
|
|
*/ |
923
|
|
|
function lx_getLinkedProfileFromId($userid) |
924
|
|
|
{ |
925
|
|
|
global $uid, $xoopsModule; |
926
|
|
|
$userid = (int)$uid; |
927
|
|
|
if ($userid > 0) { |
928
|
|
|
/** @var \XoopsMemberHandler $memberHandler */ |
929
|
|
|
$memberHandler = xoops_getHandler('member'); |
930
|
|
|
$user = $memberHandler->getUser($userid); |
931
|
|
|
if (is_object($user)) { |
932
|
|
|
$linkeduser = '<a title="' . _MD_LEXIKON_AUTHORPROFILETEXT . '" href="' . XOOPS_URL . '/modules/' . $xoopsModule->dirname() . '/profile.php?uid=' . $uid . '">' . $user->getVar('uname') . '</a>'; |
933
|
|
|
//$linkeduser = XoopsUserUtility::getUnameFromId ( $uid ); |
934
|
|
|
//$linkeduser .= '<div style=\'position:relative; right: 4px; top: 2px;\'><a title="'._MD_LEXIKON_AUTHORPROFILETEXT.'" href="'.XOOPS_URL.'/modules/'.$xoopsModule->dirname().'/profile.php?uid='.$uid.'">'._MD_LEXIKON_AUTHORPROFILETEXT.'</a></div>'; |
935
|
|
|
return $linkeduser; |
936
|
|
|
} |
937
|
|
|
} |
938
|
|
|
|
939
|
|
|
return $GLOBALS['xoopsConfig']['anonymous']; |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
// functionset to assign terms with accentuated or umlaut initials to the adequate initial |
943
|
|
|
/** |
944
|
|
|
* @param $string |
945
|
|
|
* @return array|string|string[] |
946
|
|
|
*/ |
947
|
|
|
function lx_removeAccents($string) |
948
|
|
|
{ |
949
|
|
|
$chars['in'] = chr(128) |
950
|
|
|
. chr(131) |
951
|
|
|
. chr(138) |
952
|
|
|
. chr(142) |
953
|
|
|
. chr(154) |
954
|
|
|
. chr(158) |
955
|
|
|
. chr(159) |
956
|
|
|
. chr(162) |
957
|
|
|
. chr(165) |
958
|
|
|
. chr(181) |
959
|
|
|
. chr(192) |
960
|
|
|
. chr(193) |
961
|
|
|
. chr(194) |
962
|
|
|
. chr(195) |
963
|
|
|
. chr(196) |
964
|
|
|
. chr(197) |
965
|
|
|
. chr(199) |
966
|
|
|
. chr(200) |
967
|
|
|
. chr(201) |
968
|
|
|
. chr(202) |
969
|
|
|
. chr(203) |
970
|
|
|
. chr(204) |
971
|
|
|
. chr(205) |
972
|
|
|
. chr(206) |
973
|
|
|
. chr(207) |
974
|
|
|
. chr( |
975
|
|
|
209 |
976
|
|
|
) |
977
|
|
|
. chr(210) |
978
|
|
|
. chr(211) |
979
|
|
|
. chr(212) |
980
|
|
|
. chr(213) |
981
|
|
|
. chr(214) |
982
|
|
|
. chr(216) |
983
|
|
|
. chr(217) |
984
|
|
|
. chr(218) |
985
|
|
|
. chr(219) |
986
|
|
|
. chr(220) |
987
|
|
|
. chr(221) |
988
|
|
|
. chr(224) |
989
|
|
|
. chr(225) |
990
|
|
|
. chr(226) |
991
|
|
|
. chr(227) |
992
|
|
|
. chr(228) |
993
|
|
|
. chr(229) |
994
|
|
|
. chr(231) |
995
|
|
|
. chr(232) |
996
|
|
|
. chr(233) |
997
|
|
|
. chr(234) |
998
|
|
|
. chr(235) |
999
|
|
|
. chr(236) |
1000
|
|
|
. chr(237) |
1001
|
|
|
. chr(238) |
1002
|
|
|
. chr(239) |
1003
|
|
|
. chr(241) |
1004
|
|
|
. chr(242) |
1005
|
|
|
. chr(243) |
1006
|
|
|
. chr(244) |
1007
|
|
|
. chr(245) |
1008
|
|
|
. chr(246) |
1009
|
|
|
. chr(248) |
1010
|
|
|
. chr(249) |
1011
|
|
|
. chr(250) |
1012
|
|
|
. chr(251) |
1013
|
|
|
. chr(252) |
1014
|
|
|
. chr(253) |
1015
|
|
|
. chr(255); |
1016
|
|
|
$chars['out'] = 'EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy'; |
1017
|
|
|
if (lx_seemsUtf8($string)) { |
1018
|
|
|
$invalid_latin_chars = [ |
1019
|
|
|
chr(197) . chr(146) => 'OE', |
1020
|
|
|
chr(197) . chr(147) => 'oe', |
1021
|
|
|
chr(197) . chr(160) => 'S', |
1022
|
|
|
chr(197) . chr(189) => 'Z', |
1023
|
|
|
chr(197) . chr(161) => 's', |
1024
|
|
|
chr(197) . chr(190) => 'z', |
1025
|
|
|
chr(226) . chr(130) . chr(172) => 'E', |
1026
|
|
|
]; |
1027
|
|
|
$string = utf8_decode(strtr($string, $invalid_latin_chars)); |
1028
|
|
|
} |
1029
|
|
|
$string = strtr($string, $chars['in'], $chars['out']); |
1030
|
|
|
$double_chars['in'] = [ |
1031
|
|
|
chr(140), |
1032
|
|
|
chr(156), |
1033
|
|
|
chr(198), |
1034
|
|
|
chr(208), |
1035
|
|
|
chr(222), |
1036
|
|
|
chr(223), |
1037
|
|
|
chr(230), |
1038
|
|
|
chr(240), |
1039
|
|
|
chr(254), |
1040
|
|
|
]; |
1041
|
|
|
$double_chars['out'] = [ |
1042
|
|
|
'OE', |
1043
|
|
|
'oe', |
1044
|
|
|
'AE', |
1045
|
|
|
'DH', |
1046
|
|
|
'TH', |
1047
|
|
|
'ss', |
1048
|
|
|
'ae', |
1049
|
|
|
'dh', |
1050
|
|
|
'th', |
1051
|
|
|
]; |
1052
|
|
|
$string = str_replace($double_chars['in'], $double_chars['out'], $string); |
1053
|
|
|
|
1054
|
|
|
return $string; |
1055
|
|
|
} |
1056
|
|
|
|
1057
|
|
|
/** |
1058
|
|
|
* @param $Str |
1059
|
|
|
* @return bool |
1060
|
|
|
*/ |
1061
|
|
|
function lx_seemsUtf8($Str) |
1062
|
|
|
{ # by bmorel at ssi dot fr |
1063
|
|
|
for ($i = 0, $iMax = mb_strlen($Str); $i < $iMax; ++$i) { |
1064
|
|
|
if (ord($Str[$i]) < 0x80) { |
1065
|
|
|
continue; |
1066
|
|
|
} |
1067
|
|
|
|
1068
|
|
|
if (0xC0 == (ord($Str[$i]) & 0xE0)) { |
1069
|
|
|
$n = 1; |
1070
|
|
|
} # 0bbbbbbb |
1071
|
|
|
# 110bbbbb |
1072
|
|
|
elseif (0xE0 == (ord($Str[$i]) & 0xF0)) { |
1073
|
|
|
$n = 2; |
1074
|
|
|
} # 1110bbbb |
1075
|
|
|
elseif (0xF0 == (ord($Str[$i]) & 0xF8)) { |
1076
|
|
|
$n = 3; |
1077
|
|
|
} # 11110bbb |
1078
|
|
|
elseif (0xF8 == (ord($Str[$i]) & 0xFC)) { |
1079
|
|
|
$n = 4; |
1080
|
|
|
} # 111110bb |
1081
|
|
|
elseif (0xFC == (ord($Str[$i]) & 0xFE)) { |
1082
|
|
|
$n = 5; |
1083
|
|
|
} # 1111110b |
1084
|
|
|
else { |
1085
|
|
|
return false; |
1086
|
|
|
} # Does not match any model |
1087
|
|
|
for ($j = 0; $j < $n; $j++) { # n bytes matching 10bbbbbb follow ? |
1088
|
|
|
if ((++$i == mb_strlen($Str)) || (0x80 != (ord($Str[$i]) & 0xC0))) { |
1089
|
|
|
return false; |
1090
|
|
|
} |
1091
|
|
|
} |
1092
|
|
|
} |
1093
|
|
|
|
1094
|
|
|
return true; |
1095
|
|
|
} |
1096
|
|
|
|
1097
|
|
|
/** |
1098
|
|
|
* @param $field |
1099
|
|
|
* @return string |
1100
|
|
|
*/ |
1101
|
|
|
function lx_sanitizeFieldName($field) |
1102
|
|
|
{ |
1103
|
|
|
$field = lx_removeAccents($field); |
1104
|
|
|
$field = mb_strtolower($field); |
1105
|
|
|
$field = preg_replace('/&.+?;/', '', $field); // kill entities |
1106
|
|
|
$field = preg_replace('/[^a-z0-9 _-]/', '', $field); |
1107
|
|
|
$field = preg_replace('/\s+/', ' ', $field); |
1108
|
|
|
$field = str_replace(' ', '-', $field); |
1109
|
|
|
$field = preg_replace('|-+|', '-', $field); |
1110
|
|
|
$field = trim($field, '-'); |
1111
|
|
|
|
1112
|
|
|
return $field; |
1113
|
|
|
} |
1114
|
|
|
|
1115
|
|
|
// Verify that a term does not exist for submissions and requests (both user frontend and admin backend) |
1116
|
|
|
/** |
1117
|
|
|
* @param $term |
1118
|
|
|
* @param $table |
1119
|
|
|
* @return mixed |
1120
|
|
|
*/ |
1121
|
|
|
function lx_TermExists($term, $table) |
1122
|
|
|
{ |
1123
|
|
|
global $xoopsDB; |
1124
|
|
|
$sql = sprintf('SELECT COUNT(*) FROM `%s` WHERE term = %s', $table, $xoopsDB->quoteString(addslashes($term))); |
1125
|
|
|
$result = $xoopsDB->query($sql); |
1126
|
|
|
[$count] = $xoopsDB->fetchRow($result); |
1127
|
|
|
|
1128
|
|
|
return $count; |
1129
|
|
|
} |
1130
|
|
|
|
1131
|
|
|
// Static method to get author data block authors - from AMS |
1132
|
|
|
/** |
1133
|
|
|
* @param int $limit |
1134
|
|
|
* @param string $sort |
1135
|
|
|
* @param string $name |
1136
|
|
|
* @param string $compute_method |
1137
|
|
|
* @return array|bool |
1138
|
|
|
*/ |
1139
|
|
|
function lexikon_block_getAuthors($limit = 5, $sort = 'count', $name = 'uname', $compute_method = 'average') |
1140
|
|
|
{ |
1141
|
|
|
$limit = (int)$limit; |
1142
|
|
|
if ('uname' !== $name) { |
1143
|
|
|
$name = 'name'; |
1144
|
|
|
} //making sure that there is not invalid information in field value |
1145
|
|
|
$ret = []; |
1146
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
1147
|
|
|
if ('count' === $sort) { |
1148
|
|
|
$sql = 'SELECT u.' . $name . ' AS name, u.uid , count( n.entryID ) AS count |
1149
|
|
|
FROM ' . $db->prefix('users') . ' u, ' . $db->prefix('lxentries') . ' n |
1150
|
|
|
WHERE u.uid = n.uid |
1151
|
|
|
AND n.datesub > 0 AND n.datesub <= ' . time() . ' AND n.offline = 0 AND n.submit = 0 |
1152
|
|
|
GROUP BY u.uid ORDER BY count DESC'; |
1153
|
|
|
} elseif ('read' === $sort) { |
1154
|
|
|
if ('average' === $compute_method) { |
1155
|
|
|
$compute = 'sum( n.counter ) / count( n.entryID )'; |
1156
|
|
|
} else { |
1157
|
|
|
$compute = 'sum( n.counter )'; |
1158
|
|
|
} |
1159
|
|
|
$sql = 'SELECT u.' . $name . " AS name, u.uid , $compute AS count |
1160
|
|
|
FROM " . $db->prefix('users') . ' u, ' . $db->prefix('lxentries') . ' n |
1161
|
|
|
WHERE u.uid = n.uid |
1162
|
|
|
AND n.datesub > 0 AND n.datesub <= ' . time() . ' AND n.offline = 0 AND n.submit = 0 |
1163
|
|
|
GROUP BY u.uid ORDER BY count DESC'; |
1164
|
|
|
} |
1165
|
|
|
if (!$result = $db->query($sql, $limit)) { |
1166
|
|
|
return false; |
1167
|
|
|
} |
1168
|
|
|
|
1169
|
|
|
while (false !== ($row = $db->fetchArray($result))) { |
1170
|
|
|
if ('name' === $name && '' == $row['name']) { |
1171
|
|
|
$row['name'] = \XoopsUser::getUnameFromId($row['uid']); |
1172
|
|
|
} |
1173
|
|
|
$row['count'] = round($row['count'], 0); |
1174
|
|
|
$ret[] = $row; |
1175
|
|
|
} |
1176
|
|
|
|
1177
|
|
|
return $ret; |
1178
|
|
|
} |
1179
|
|
|
|
1180
|
|
|
/** |
1181
|
|
|
* close all unclosed xhtml tags *Test* |
1182
|
|
|
* |
1183
|
|
|
* @param string $html |
1184
|
|
|
* @return string |
1185
|
|
|
* @author Milian Wolff <mail -at- milianw.de> |
1186
|
|
|
*/ |
1187
|
|
|
function lx_closetags2($html) |
1188
|
|
|
{ |
1189
|
|
|
// put all opened tags into an array |
1190
|
|
|
preg_match_all('#<([a-z]+)( .*)?(?!/)>#iU', $html, $result); |
1191
|
|
|
$openedtags = $result[1]; |
1192
|
|
|
|
1193
|
|
|
// put all closed tags into an array |
1194
|
|
|
preg_match_all('#</([a-z]+)>#iU', $html, $result); |
1195
|
|
|
$closedtags = $result[1]; |
1196
|
|
|
$len_opened = count($openedtags); |
1197
|
|
|
// all tags are closed |
1198
|
|
|
if (count($closedtags) == $len_opened) { |
1199
|
|
|
return $html; |
1200
|
|
|
} |
1201
|
|
|
|
1202
|
|
|
$openedtags = array_reverse($openedtags); |
1203
|
|
|
// close tags |
1204
|
|
|
for ($i = 0; $i < $len_opened; ++$i) { |
1205
|
|
|
if (!in_array($openedtags[$i], $closedtags)) { |
1206
|
|
|
$html .= '</' . $openedtags[$i] . '>'; |
1207
|
|
|
} else { |
1208
|
|
|
unset($closedtags[array_search($openedtags[$i], $closedtags, true)]); |
1209
|
|
|
} |
1210
|
|
|
} |
1211
|
|
|
|
1212
|
|
|
return $html; |
1213
|
|
|
} |
1214
|
|
|
|
1215
|
|
|
/** |
1216
|
|
|
* @param $string |
1217
|
|
|
* @return string |
1218
|
|
|
* @author Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson |
1219
|
|
|
* <amos dot robinson at gmail dot com> |
1220
|
|
|
*/ |
1221
|
|
|
function lx_close_tags($string) |
1222
|
|
|
{ |
1223
|
|
|
// match opened tags |
1224
|
|
|
if (preg_match_all('/<([a-z\:\-]+)[^\/]>/', $string, $start_tags)) { |
1225
|
|
|
$start_tags = $start_tags[1]; |
1226
|
|
|
// match closed tags |
1227
|
|
|
if (preg_match_all('/<\/([a-z]+)>/', $string, $end_tags)) { |
1228
|
|
|
$complete_tags = []; |
1229
|
|
|
$end_tags = $end_tags[1]; |
1230
|
|
|
|
1231
|
|
|
foreach ($start_tags as $key => $val) { |
1232
|
|
|
$posb = array_search($val, $end_tags, true); |
1233
|
|
|
if (is_int($posb)) { |
1234
|
|
|
unset($end_tags[$posb]); |
1235
|
|
|
} else { |
1236
|
|
|
$complete_tags[] = $val; |
1237
|
|
|
} |
1238
|
|
|
} |
1239
|
|
|
} else { |
1240
|
|
|
$complete_tags = $start_tags; |
1241
|
|
|
} |
1242
|
|
|
|
1243
|
|
|
$complete_tags = array_reverse($complete_tags); |
1244
|
|
|
for ($i = 0, $iMax = count($complete_tags); $i < $iMax; ++$i) { |
1245
|
|
|
$string .= '</' . $complete_tags[$i] . '>'; |
1246
|
|
|
} |
1247
|
|
|
} |
1248
|
|
|
|
1249
|
|
|
return $string; |
1250
|
|
|
} |
1251
|
|
|
|
1252
|
|
|
/** |
1253
|
|
|
* Smarty plugin |
1254
|
|
|
* @param mixed $string |
1255
|
|
|
* @param mixed $length |
1256
|
|
|
* @param mixed $etc |
1257
|
|
|
* @param mixed $break_words |
1258
|
|
|
* @package Smarty |
1259
|
|
|
* @subpackage plugins |
1260
|
|
|
*/ |
1261
|
|
|
/** |
1262
|
|
|
* Smarty truncate_tagsafe modifier plugin |
1263
|
|
|
* |
1264
|
|
|
* Type: modifier<br> |
1265
|
|
|
* Name: truncate_tagsafe<br> |
1266
|
|
|
* Purpose: Truncate a string to a certain length if necessary, |
1267
|
|
|
* optionally splitting in the middle of a word, and |
1268
|
|
|
* appending the $etc string or inserting $etc into the middle. |
1269
|
|
|
* Makes sure no tags are left half-open or half-closed (e.g. "Banana in a <a...") |
1270
|
|
|
* @param $string |
1271
|
|
|
* @param int $length |
1272
|
|
|
* @param string $etc |
1273
|
|
|
* @param bool $break_words |
1274
|
|
|
* @return null|string|string[] |
1275
|
|
|
* @author Monte Ohrt <monte at ohrt dot com>, modified by Amos Robinson |
1276
|
|
|
* <amos dot robinson at gmail dot com> |
1277
|
|
|
* used in Block entries_scrolling.php |
1278
|
|
|
*/ |
1279
|
|
|
function lx_truncate_tagsafe($string, $length = 80, $etc = '...', $break_words = false) |
1280
|
|
|
{ |
1281
|
|
|
if (0 == $length) { |
1282
|
|
|
return ''; |
1283
|
|
|
} |
1284
|
|
|
if (mb_strlen($string) > $length) { |
1285
|
|
|
$length -= mb_strlen($etc); |
1286
|
|
|
if (!$break_words) { |
1287
|
|
|
$string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length + 1)); |
1288
|
|
|
$string = preg_replace('/<[^>]*$/', '', $string); |
1289
|
|
|
$string = lx_close_tags($string); |
1290
|
|
|
} |
1291
|
|
|
|
1292
|
|
|
return $string . $etc; |
1293
|
|
|
} |
1294
|
|
|
|
1295
|
|
|
return $string; |
1296
|
|
|
} |
1297
|
|
|
|
1298
|
|
|
/** |
1299
|
|
|
* @return array |
1300
|
|
|
*/ |
1301
|
|
|
function lexikon_summary() |
1302
|
|
|
{ |
1303
|
|
|
global $xoopsDB; |
1304
|
|
|
|
1305
|
|
|
$summary = []; |
1306
|
|
|
|
1307
|
|
|
$result01 = $xoopsDB->query( |
1308
|
|
|
'SELECT COUNT(*) |
1309
|
|
|
FROM ' . $xoopsDB->prefix('lxcategories') . ' ' |
1310
|
|
|
); |
1311
|
|
|
[$totalcategories] = $xoopsDB->fetchRow($result01); |
1312
|
|
|
|
1313
|
|
|
$result02 = $xoopsDB->query( |
1314
|
|
|
'SELECT COUNT(*) |
1315
|
|
|
FROM ' . $xoopsDB->prefix('lxentries') . ' |
1316
|
|
|
WHERE submit = 0' |
1317
|
|
|
); |
1318
|
|
|
[$totalpublished] = $xoopsDB->fetchRow($result02); |
1319
|
|
|
|
1320
|
|
|
$result03 = $xoopsDB->query( |
1321
|
|
|
'SELECT COUNT(*) |
1322
|
|
|
FROM ' . $xoopsDB->prefix('lxentries') . " |
1323
|
|
|
WHERE submit = '1' AND request = '0' " |
1324
|
|
|
); |
1325
|
|
|
[$totalsubmitted] = $xoopsDB->fetchRow($result03); |
1326
|
|
|
|
1327
|
|
|
$result04 = $xoopsDB->query( |
1328
|
|
|
'SELECT COUNT(*) |
1329
|
|
|
FROM ' . $xoopsDB->prefix('lxentries') . " |
1330
|
|
|
WHERE submit = '1' AND request = '1' " |
1331
|
|
|
); |
1332
|
|
|
[$totalrequested] = $xoopsDB->fetchRow($result04); |
1333
|
|
|
|
1334
|
|
|
// Recuperer les valeurs dans la base de donnees |
1335
|
|
|
|
1336
|
|
|
$summary['publishedEntries'] = $totalpublished ?: '0'; |
1337
|
|
|
$summary['availableCategories'] = $totalcategories ?: '0'; |
1338
|
|
|
$summary['submittedEntries'] = $totalsubmitted ?: '0'; |
1339
|
|
|
$summary['requestedEntries'] = $totalrequested ?: '0'; |
1340
|
|
|
|
1341
|
|
|
//print_r($summary); |
1342
|
|
|
return $summary; |
1343
|
|
|
} // end function |
1344
|
|
|
|