Completed
Push — master ( 00e474...9d3fbd )
by Michael
04:26
created

blocks/oledrion_random_lists.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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 http://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
/**
21
 * Affichage des listes au hasard
22
 *
23
 * @param  array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés)
24
 * @return array
25
 */
26 View Code Duplication
function b_oledrion_random_lists_show($options)
27
{
28
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
29
    Oledrion_utils::loadLanguageFile('main.php');
30
    $start    = 0;
31
    $limit    = (int)$options[0];
32
    $listType = (int)$options[1];
33
    $block    = array();
34
    $handlers = OledrionHandler::getInstance();
35
    $items    = array();
36
    //$items = $handlers->h_oledrion_lists->getRecentLists(new Oledrion_parameters(array('start' => $start, 'limit' => $limit, 'sort' => 'RAND()', 'order' => 'DESC', 'idAsKey' => true, 'listType' => $listType)));
37
    $items = $handlers->h_oledrion_lists->getRecentLists(new Oledrion_parameters(array(
0 ignored issues
show
The property h_oledrion_lists does not exist on object<OledrionHandler>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
38
                                                                                     'start'    => $start,
39
                                                                                     'limit'    => $limit,
40
                                                                                     'sort'     => 'RAND()',
41
                                                                                     'order'    => 'DESC',
42
                                                                                     'idAsKey'  => true,
43
                                                                                     'listType' => OLEDRION_LISTS_ALL_PUBLIC
44
                                                                                 )));
45
    if (count($items) > 0) {
46
        foreach ($items as $item) {
47
            $block['random_lists'][] = $item->toArray();
48
        }
49
    }
50
51
    return $block;
52
}
53
54
/**
55
 * Edition des paramètres du bloc
56
 *
57
 * @param  array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés)
58
 * @return array
59
 */
60 View Code Duplication
function b_oledrion_random_lists_edit($options)
61
{
62
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
63
    $form = '';
64
    $form .= "<table border='0'>";
65
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "' /></td></tr>";
66
    $listTypes      = Oledrion_lists::getTypesArray();
67
    $listTypeSelect = Oledrion_utils::htmlSelect('options[]', $listTypes, (int)$options[1], false);
68
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_TYPE . '</td><td>' . $listTypeSelect . '</td></tr>';
69
    $form .= '</table>';
70
71
    return $form;
72
}
73
74
/**
75
 * Bloc à la volée
76
 * @param $options
77
 */
78 View Code Duplication
function b_oledrion_random_lists_duplicatable($options)
79
{
80
    $options = explode('|', $options);
81
    $block   = b_oledrion_random_lists_show($options);
82
83
    $tpl = new XoopsTpl();
84
    $tpl->assign('block', $block);
85
    $tpl->display('db:oledrion_block_random_lists.tpl');
86
}
87