b_oledrion_my_lists_show()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 32
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 32
rs 9.536
c 0
b 0
f 0
cc 4
nc 3
nop 1
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
/**
13
 * oledrion
14
 *
15
 * @copyright   {@link https://xoops.org/ XOOPS Project}
16
 * @license     {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
17
 * @author      Hervé Thouzard (http://www.herve-thouzard.com/)
18
 */
19
20
use XoopsModules\Oledrion;
21
use XoopsModules\Oledrion\Constants;
22
23
/**
24
 * Affiche les listes de l'utilisateur
25
 *
26
 * @param  array $options [0] = Nombre maximum de listes à voir
27
 * @return array
28
 */
29
function b_oledrion_my_lists_show($options)
30
{
31
    require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
32
    $helper->loadLanguage('modinfo');
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $helper seems to be never defined.
Loading history...
33
    $start = 0;
34
    $limit = (int)$options[0];
35
    $uid   = Oledrion\Utility::getCurrentUserID();
36
    if (0 == $uid) {
37
        return null;
38
    }
39
    $listType = Constants::OLEDRION_LISTS_ALL;
40
    $block    = [];
41
    //    $handlers = HandlerManager::getInstance();
42
    $db           = \XoopsDatabaseFactory::getDatabaseConnection();
43
    $listsHandler = new Oledrion\ListsHandler($db);
44
    $items        = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $items is dead and can be removed.
Loading history...
45
    $items        = $listsHandler->getRecentLists(new Oledrion\Parameters([
46
                                                                              'start'    => $start,
47
                                                                              'limit'    => $limit,
48
                                                                              'sort'     => 'list_date',
49
                                                                              'order'    => 'DESC',
50
                                                                              'idAsKey'  => true,
51
                                                                              'listType' => $listType,
52
                                                                              'list_uid' => $uid,
53
                                                                          ]));
54
    if (count($items) > 0) {
55
        foreach ($items as $item) {
56
            $block['my_lists'][] = $item->toArray();
57
        }
58
    }
59
60
    return $block;
61
}
62
63
/**
64
 * Edition des paramètres du bloc
65
 *
66
 * @param  array $options [0] = Nombre maximum de listes à voir
67
 * @return string
68
 */
69
function b_oledrion_my_lists_edit($options)
70
{
71
    require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
72
    $form = '';
73
    $form .= "<table border='0'>";
74
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "'></td></tr>";
75
    $form .= '</table>';
76
77
    return $form;
78
}
79
80
/**
81
 * Bloc à la volée
82
 * @param $options
83
 */
84
function b_oledrion_my_lists_duplicatable($options)
85
{
86
    $options = explode('|', $options);
87
    $block   = b_oledrion_my_lists_show($options);
88
89
    $tpl = new \XoopsTpl();
90
    $tpl->assign('block', $block);
91
    $tpl->display('db:oledrion_block_my_lists.tpl');
92
}
93