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

blocks/oledrion_promotion.php (1 issue)

Severity

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 x produit(s) en promotion
22
 * @param $options
23
 * @return array|bool
24
 */
25 View Code Duplication
function b_oledrion_promotion_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
    $block      = $products = array();
31
    $start      = 0;
32
    $limit      = $options[0];
33
    $categoryId = $options[1];
34
35
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('promotional')->setStart($start)->setLimit($limit)->setSort('product_submitted DESC, product_title')->setOrder('ASC')->setCategory($categoryId);
36
    $products = $oledrion_shelf->getProducts($oledrion_shelf_parameters);
37
    if (isset($products['lastTitle'])) {
38
        unset($products['lastTitle']);
39
    }
40
    if (count($products) > 0) {
41
        $block['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
42
        $block['block_products'] = $products;
43
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
44
45
        return $block;
46
    } else {
47
        return false;
48
    }
49
}
50
51
/**
52
 * Paramètres du bloc
53
 * @param $options
54
 * @return string
55
 */
56 View Code Duplication
function b_oledrion_promotion_edit($options)
57
{
58
    // '10|0';  // Voir 10 produits, pour toutes les catégories
59
    global $xoopsConfig;
60
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
61
    require_once OLEDRION_PATH . 'class/tree.php';
62
    $tblCategories         = array();
63
    $tblCategories         = $h_oledrion_cat->getAllCategories(new Oledrion_parameters());
64
    $mytree                = new Oledrion_XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid');
65
    $form                  = '';
66
    $checkeds              = array('', '');
67
    $checkeds[$options[1]] = 'checked';
68
    $form                  .= "<table border='0'>";
69
    $form                  .= '<tr><td>' . _MB_OLEDRION_PRODUCTS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>";
70
    //$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>';
71
    $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...
72
    $form   .= '<tr><td>' . _MB_OLEDRION_CATEGORY . '</td><td>' . $select . '</td></tr>';
73
    $form   .= '</table>';
74
75
    return $form;
76
}
77
78
/**
79
 * Bloc à la volée
80
 * @param $options
81
 */
82 View Code Duplication
function b_oledrion_promotion_show_duplicatable($options)
83
{
84
    $options = explode('|', $options);
85
    $block   = b_oledrion_promotion_show($options);
86
87
    $tpl = new XoopsTpl();
88
    $tpl->assign('block', $block);
89
    $tpl->display('db:oledrion_block_promotion.tpl');
90
}
91