b_oledrion_rated_show_duplicatable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
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
22
/**
23
 * Affiche les produits les mieux notés
24
 * @param $options
25
 * @return array|bool
26
 */
27
function b_oledrion_rated_show($options)
28
{
29
    // '10|0';  // Voir 10 produits, pour toutes les catégories ou une catégorie particulière
30
    global $xoopsConfig, $xoTheme;
31
    require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
32
    $products   = $block = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $products is dead and can be removed.
Loading history...
33
    $start      = 0;
34
    $limit      = $options[0];
35
    $categoryId = $options[1];
36
37
    $shelfParameters->resetDefaultValues()->setProductsType('bestrated')->setStart($start)->setLimit($limit)->setSort('product_rating')->setOrder('DESC')->setCategory($categoryId);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $shelfParameters seems to be never defined.
Loading history...
38
    $products = $shelf->getProducts($shelfParameters);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $shelf seems to be never defined.
Loading history...
39
    if (isset($products['lastTitle'])) {
40
        unset($products['lastTitle']);
41
    }
42
    if (count($products) > 0) {
43
        $block['nostock_msg']    = Oledrion\Utility::getModuleOption('nostock_msg');
44
        $block['block_products'] = $products;
45
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
46
47
        return $block;
48
    }
49
50
    // La liste des produits est introuvable (on ne trouve pas les produits vendus dans le stock des produits)
51
52
    return false;
53
}
54
55
/**
56
 * Paramètres du bloc
57
 * @param $options
58
 * @return string
59
 */
60
function b_oledrion_rated_edit($options)
61
{
62
    // '10|0';  // Voir 10 produits, pour toutes les catégories
63
    global $xoopsConfig;
64
    require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
65
    // require_once OLEDRION_PATH . 'class/tree.php';
66
    $tblCategories         = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $tblCategories is dead and can be removed.
Loading history...
67
    $tblCategories         = $categoryHandler->getAllCategories(new Oledrion\Parameters());
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $categoryHandler seems to be never defined.
Loading history...
68
    $mytree                = new Oledrion\XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid');
69
    $form                  = '';
70
    $checkeds              = ['', ''];
71
    $checkeds[$options[1]] = 'checked';
72
    $form                  .= "<table border='0'>";
73
    $form                  .= '<tr><td>' . _MB_OLEDRION_PRODUCTS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>";
74
    //$form .= '<tr><td>'._MB_OLEDRION_SORT_ORDER."</td><td><input type='radio' name='options[]' id='options[]' value='0' ".$checkeds[0].">"._MB_OLEDRION_SORT_1." <input type='radio' name='options[]' id='options[]' value='1' ".$checkeds[1].">"._MB_OLEDRION_SORT_2.'</td></tr>';
75
        $select0 = $mytree->makeSelectElement('options[]', 'cat_title', '-', $options[1], true, 0, '', _MB_OLEDRION_ALL_CATEGORIES);
76
        $select  = $select0->render();
77
78
79
    $form .= '<tr><td>' . _MB_OLEDRION_CATEGORY . '</td><td>' . $select . '</td></tr>';
80
    $form .= '</table>';
81
82
    return $form;
83
}
84
85
/**
86
 * Bloc à la volée
87
 * @param $options
88
 */
89
function b_oledrion_rated_show_duplicatable($options)
90
{
91
    $options = explode('|', $options);
92
    $block   = b_oledrion_rated_show($options);
93
94
    $tpl = new \XoopsTpl();
95
    $tpl->assign('block', $block);
96
    $tpl->display('db:oledrion_block_rated.tpl');
97
}
98