|
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 la liste des x dernières articles |
|
23
|
|
|
* |
|
24
|
|
|
* @param array $options indice 0 = nombre d'articles à afficher |
|
25
|
|
|
* @return array Le contenu du bloc |
|
26
|
|
|
*/ |
|
27
|
|
|
function b_references_last_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
|
|
|
$categories = array(); |
|
37
|
|
View Code Duplication |
if (is_array($options) && count($options) > 1) { |
|
|
|
|
|
|
38
|
|
|
$categories = array_slice($options, 1); |
|
39
|
|
|
} |
|
40
|
|
|
$items = $h_references_articles->getRecentArticles($start, $limit, 'article_timestamp', 'DESC', true, $categories); |
|
|
|
|
|
|
41
|
|
|
if (count($items) > 0) { |
|
42
|
|
|
foreach ($items as $item) { |
|
43
|
|
|
$block['block_last_news'][] = $item->toArray(); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $block; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Paramètres du bloc |
|
53
|
|
|
* |
|
54
|
|
|
* @param array $options indice 0 = nombre d'articles à afficher |
|
55
|
|
|
* @return string |
|
56
|
|
|
*/ |
|
57
|
|
View Code Duplication |
function b_references_last_news_edit($options) |
|
|
|
|
|
|
58
|
|
|
{ |
|
59
|
|
|
global $xoopsConfig; |
|
60
|
|
|
include XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
61
|
|
|
$handlers = references_handler::getInstance(); |
|
62
|
|
|
$categories = $handlers->h_references_categories->getListArray(); |
|
63
|
|
|
$form = ''; |
|
64
|
|
|
$form .= "<table border='0'>"; |
|
65
|
|
|
$form .= '<tr><td>' . _MB_REFERENCES_ITEMS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "' /></td></tr>\n"; |
|
66
|
|
|
$form .= '<tr><td>' . _MB_REFERENCES_CATEGORIES . "</td><td><select name='options[]' multiple='multiple'>"; |
|
67
|
|
|
$size = count($options); |
|
68
|
|
|
foreach ($categories as $Idcategory => $categoryName) { |
|
69
|
|
|
$sel = ''; |
|
70
|
|
|
for ($i = 1; $i < $size; ++$i) { |
|
71
|
|
|
if ($options[$i] == $Idcategory) { |
|
72
|
|
|
$sel = " selected='selected'"; |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
$form .= "<option value='$Idcategory' $sel>$categoryName</option>"; |
|
76
|
|
|
} |
|
77
|
|
|
$form .= "</select></td></tr>\n"; |
|
78
|
|
|
$form .= '</table>'; |
|
79
|
|
|
|
|
80
|
|
|
return $form; |
|
81
|
|
|
} |
|
82
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.