1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Mylinks Random Term Block |
4
|
|
|
* |
5
|
|
|
* Xoops Mylinks - a links module |
6
|
|
|
* |
7
|
|
|
* You may not change or alter any portion of this comment or credits |
8
|
|
|
* of supporting developers from this source code or any supporting source code |
9
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
10
|
|
|
* This program is distributed in the hope that it will be useful, |
11
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
13
|
|
|
* |
14
|
|
|
* @copyright :: © {@link http://xoops.org/ XOOPS Project} |
15
|
|
|
* @license :: {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
16
|
|
|
* @package :: mylinks |
17
|
|
|
* @subpackage:: blocks |
18
|
|
|
* @author :: hsalazar |
19
|
|
|
* @author :: zyspec (owners@zyspec) |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
function b_mylinks_random_show() |
23
|
|
|
{ |
24
|
|
|
global $xoopsDB, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $xoopsUser; |
25
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
26
|
|
|
$myts = MyTextSanitizer::getInstance(); |
27
|
|
|
|
28
|
|
|
$block = array(); |
29
|
|
|
|
30
|
|
|
$result = $xoopsDB->query('SELECT l.lid, l.cid, l.title, l.url, l.logourl, l.status, l.date, l.hits, l.rating, l.votes, l.comments, t.description FROM ' . $xoopsDB->prefix('mylinks_links') . ' l, ' . $xoopsDB->prefix('mylinks_text') |
31
|
|
|
. ' t WHERE l.lid=t.lid AND status>0 ORDER BY RAND() LIMIT 0,1'); |
32
|
|
|
if ($result) { |
33
|
|
|
list($lid, $cid, $ltitle, $url, $logourl, $status, $time, $hits, $rating, $votes, $comments, $description) = $xoopsDB->fetchRow($result); |
|
|
|
|
34
|
|
|
$link = $myts->displayTarea(ucfirst($myts->stripSlashesGPC($ltitle))); |
35
|
|
|
$description = $myts->displayTarea(mb_substr($myts->stripSlashesGPC($description), 0, 100)) . '...'; |
36
|
|
|
|
37
|
|
|
$mylinksCatHandler = xoops_getModuleHandler('category', $moduleDirName); |
38
|
|
|
$catObj = $mylinksCatHandler->get($cid); |
39
|
|
|
if (is_object($catObj) && !empty($catObj)) { |
40
|
|
|
$categoryName = $catObj->getVar('title'); |
41
|
|
|
$categoryName = $myts->displayTarea($categoryName); |
42
|
|
|
} else { |
43
|
|
|
$cid = 0; |
44
|
|
|
$categoryName = ''; |
45
|
|
|
} |
46
|
|
|
$block['title'] = _MB_MYLINKS_RANDOMTITLE; |
47
|
|
|
$block['content'] = "<div style=\"font-size: 12px; font-weight: bold; background-color: #ccc; padding: 4px; margin: 0;\"><a href=\"" . XOOPS_URL . "/modules/{$moduleDirName}/viewcat.php?cid={$cid}\">{$categoryName}</a></div>"; |
48
|
|
|
$block['content'] .= "<div style=\"padding: 4px 0 0 0; color: #456;\"><h5 style=\"margin: 0;\"><a href=\"" . XOOPS_URL . "/modules/{$moduleDirName}/singlelink.php?lid={$lid}\">{$link}</a></h5></div><div>{$description}</div>"; |
49
|
|
|
unset($catObj, $mylinksCatHandler); |
50
|
|
|
$block['content'] .= "<div style=\"text-align: right; font-size: x-small;\"><a href=\"" . XOOPS_URL . "/modules/{$moduleDirName}/index.php\">" . _MB_MYLINKS_SEEMORE . '</a></div>'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $block; |
54
|
|
|
} |
55
|
|
|
|
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.