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

blocks/oledrion_categoy_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 les plus vues
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
function b_oledrion_category_lists_show($options)
27
{
28
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
29
    Oledrion_utils::loadLanguageFile('main.php');
30
    $limit    = (int)$options[0];
31
    $listType = (int)$options[1];
32
    $block    = array();
33
    if (isset($GLOBALS['current_category']) && (int)$GLOBALS['current_category'] > 0) {
34
        $handlers = OledrionHandler::getInstance();
35
        $items    = array();
36
        $items    = $handlers->h_oledrion_lists->listsFromCurrentCategory($GLOBALS['current_category'], $listType, $limit);
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...
37
        if (count($items) > 0) {
38
            foreach ($items as $item) {
39
                $block['category_lists'][] = $item->toArray();
40
            }
41
        }
42
    }
43
44
    return $block;
45
}
46
47
/**
48
 * Edition des paramètres du bloc
49
 *
50
 * @param  array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés)
51
 * @return array
52
 */
53 View Code Duplication
function b_oledrion_category_lists_edit($options)
54
{
55
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
56
    $form = '';
57
    $form .= "<table border='0'>";
58
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "' /></td></tr>";
59
    $listTypes      = Oledrion_lists::getTypesArray();
60
    $listTypeSelect = Oledrion_utils::htmlSelect('options[]', $listTypes, (int)$options[1], false);
61
    $form .= '<tr><td>' . _MB_OLEDRION_LISTS_TYPE . '</td><td>' . $listTypeSelect . '</td></tr>';
62
    $form .= '</table>';
63
64
    return $form;
65
}
66
67
/**
68
 * Bloc à la volée
69
 * @param $options
70
 */
71 View Code Duplication
function b_oledrion_category_lists_duplicatable($options)
72
{
73
    $options = explode('|', $options);
74
    $block   = b_oledrion_category_lists_show($options);
75
76
    $tpl = new XoopsTpl();
77
    $tpl->assign('block', $block);
78
    $tpl->display('oledrion_block_category_lists.tpl');
79
}
80