1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* **************************************************************************** |
4
|
|
|
* references - MODULE FOR XOOPS |
5
|
|
|
* Copyright (c) Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
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 Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
15
|
|
|
* @license http://www.fsf.org/copyleft/gpl.html GNU public license |
16
|
|
|
* @package references |
17
|
|
|
* @author Hervé Thouzard of Instant Zero (http://www.instant-zero.com) |
18
|
|
|
* |
19
|
|
|
* **************************************************************************** |
20
|
|
|
*/ |
21
|
|
|
/** |
22
|
|
|
* Affiche x articles au hasard |
23
|
|
|
* |
24
|
|
|
* @param array $options indice 0 = nombre d'articles à afficher |
25
|
|
|
* @return array Le contenu du bloc |
26
|
|
|
*/ |
27
|
|
|
function b_references_random_news_show($options) |
28
|
|
|
{ |
29
|
|
|
global $xoopsConfig; |
30
|
|
|
require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
31
|
|
|
$block = array(); |
32
|
|
|
$start = 0; |
33
|
|
|
$limit = (int)$options[0]; |
34
|
|
|
if ($limit > 0) { |
35
|
|
|
$items = array(); |
|
|
|
|
36
|
|
|
$h_references_articles->setCachingOptions(array('cacheDir' => REFERENCES_CACHE_PATH, 'caching' => false, 'lifeTime' => null, 'automaticSerialization' => true, 'fileNameProtection' => false)); |
|
|
|
|
37
|
|
|
$categories = array(); |
38
|
|
View Code Duplication |
if (is_array($options) && count($options) > 1) { |
|
|
|
|
39
|
|
|
$categories = array_slice($options, 1); |
40
|
|
|
} |
41
|
|
|
$items = $h_references_articles->getRecentArticles($start, $limit, 'RAND(), NOW()', 'DESC', true, $categories); |
42
|
|
|
$h_references_articles->setCachingOptions(array('cacheDir' => REFERENCES_CACHE_PATH, 'caching' => true, 'lifeTime' => null, 'automaticSerialization' => true, 'fileNameProtection' => false)); |
43
|
|
|
if (count($items) > 0) { |
44
|
|
|
foreach ($items as $item) { |
45
|
|
|
$block['block_random_news'][] = $item->toArray(); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
return $block; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* Paramètres du bloc |
55
|
|
|
* |
56
|
|
|
* @param array $options indice 0 = nombre d'articles à afficher |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
View Code Duplication |
function b_references_random_news_edit($options) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
global $xoopsConfig; |
62
|
|
|
include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
63
|
|
|
$handlers = references_handler::getInstance(); |
64
|
|
|
$categories = $handlers->h_references_categories->getListArray(); |
65
|
|
|
$form = ''; |
66
|
|
|
$form .= "<table border='0'>"; |
67
|
|
|
$form .= '<tr><td>' . _MB_REFERENCES_ITEMS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>\n"; |
68
|
|
|
$form .= '<tr><td>' . _MB_REFERENCES_CATEGORIES . "</td><td><select name='options[]' multiple='multiple'>"; |
69
|
|
|
$size = count($options); |
70
|
|
|
foreach ($categories as $Idcategory => $categoryName) { |
71
|
|
|
$sel = ''; |
72
|
|
|
for ($i = 1; $i < $size; ++$i) { |
73
|
|
|
if ($options[$i] == $Idcategory) { |
74
|
|
|
$sel = " selected='selected'"; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
$form .= "<option value='$Idcategory' $sel>$categoryName</option>"; |
78
|
|
|
} |
79
|
|
|
$form .= "</select></td></tr>\n"; |
80
|
|
|
$form .= '</table>'; |
81
|
|
|
|
82
|
|
|
return $form; |
83
|
|
|
} |
84
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.