Completed
Push — master ( 9d3fbd...af269e )
by Michael
09:48
created

blocks/oledrion_best_sales.php (3 issues)

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 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
/**
21
 * Affiche les meilleures ventes
22
 * @param $options
23
 * @return array|bool
24
 */
25
function b_oledrion_bestsales_show($options)
26
{
27
    // '10|0';  // Voir 10 produits, pour toutes les catégories ou une catégorie particulière
28
    global $xoopsConfig, $xoTheme;
29
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
30
    $categoryId = $options[1];
31
    $start      = 0;
32
    $limit      = $options[0];
33
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('mostsold')->setStart($start)->setLimit($limit)->setSort('product_submitted DESC, product_title')->setCategory($categoryId);
34
    $products = $oledrion_shelf->getProducts($oledrion_shelf_parameters);
35
    if (isset($products['lastTitle'])) {
36
        unset($products['lastTitle']);
37
    }
38
    if (count($products) > 0) {
39
        $block                   = array();
40
        $block['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
41
        $block['block_products'] = $products;
42
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
43
44
        return $block;
45
    } else {
46
        return false;
47
    }
48
}
49
50
/**
51
 * Paramètres du bloc
52
 * @param $options
53
 * @return string
54
 */
55
function b_oledrion_bestsales_edit($options)
56
{
57
    // '10|0';  // Voir 10 produits, pour toutes les catégories
58
    require XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
59
    require_once OLEDRION_PATH . 'class/tree.php';
60
    $categories            = array();
61
    $categories            = $h_oledrion_cat->getAllCategories(new Oledrion_parameters());
62
    $mytree                = new Oledrion_XoopsObjectTree($categories, 'cat_cid', 'cat_pid');
63
    $form                  = '';
64
    $checkeds              = array('', '');
65
    $checkeds[$options[1]] = 'checked';
66
    $form                  .= "<table border='0'>";
67
    $form                  .= '<tr><td>' . _MB_OLEDRION_PRODUCTS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>";
68
69
    if (OledrionUtility::checkVerXoops($module, '2.5.9')) {
0 ignored issues
show
The variable $module does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The method checkVerXoops() does not seem to exist on object<OledrionUtility>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
70
        $select0 = $mytree->makeSelectElement('options[]', 'cat_title', '-', $options[1], true, 0, '', _MB_OLEDRION_CATEGORY);
71
        $select  = $select0->render();
72
    } else {
73
        $select = $mytree->makeSelBox('options[]', 'cat_title', '-', $options[1], _MB_OLEDRION_ALL_CATEGORIES);
0 ignored issues
show
Deprecated Code introduced by
The method Oledrion_XoopsObjectTree::makeSelBox() has been deprecated with message: since 2.5.9, please use makeSelectElement()

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
74
    }
75
76
    $form .= '<tr><td>' . _MB_OLEDRION_CATEGORY . '</td><td>' . $select . '</td></tr>';
77
    $form .= '</table>';
78
79
    return $form;
80
}
81
82
/**
83
 * Bloc à la volée
84
 * @param $options
85
 */
86 View Code Duplication
function b_oledrion_bestsales_duplicatable($options)
87
{
88
    $options = explode('|', $options);
89
    $block   = b_oledrion_bestsales_show($options);
90
91
    $tpl = new XoopsTpl();
92
    $tpl->assign('block', $block);
93
    $tpl->display('db:oledrion_block_bestsales.tpl');
94
}
95