Code Duplication    Length = 25-30 lines in 6 locations

blocks/oledrion_new.php 1 location

@@ 25-50 (lines=26) @@
22
 * @param $options
23
 * @return array|bool
24
 */
25
function b_oledrion_new_show($options)
26
{
27
    // '10|0|0';    // Voir 10 produits, pour toutes les catégories ou une catégorie particulière, uniquement les produits du mois ?
28
    global $xoopsConfig, $xoTheme;
29
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
30
    $start         = 0;
31
    $limit         = $options[0];
32
    $categoryId    = $options[1];
33
    $thisMonthOnly = (int)$options[2];
34
35
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('recent')->setStart($start)->setLimit($limit)->setSort('product_id DESC, product_title')->setCategory($categoryId)->setThisMonthOnly($thisMonthOnly);
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                   = array();
42
        $block['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
43
        $block['block_products'] = $products;
44
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
45
46
        return $block;
47
    } else {
48
        return false;
49
    }
50
}
51
52
/**
53
 * Paramètres du bloc

blocks/oledrion_promotion.php 1 location

@@ 25-49 (lines=25) @@
22
 * @param $options
23
 * @return array|bool
24
 */
25
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

blocks/oledrion_random.php 1 location

@@ 25-51 (lines=27) @@
22
 * @param $options
23
 * @return array|bool
24
 */
25
function b_oledrion_random_show($options)
26
{
27
    // '10|0|0';    // Voir 10 produits, pour toutes les catégories ou une catégorie particulière, et pour ce mois-ci ou pour tout le temps ?
28
    global $xoopsConfig, $xoTheme;
29
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
30
    $products      = $block = array();
31
    $start         = 0;
32
    $limit         = $options[0];
33
    $categoryId    = $options[1];
34
    $thisMonthOnly = (int)$options[2];
35
36
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('random')->setStart($start)->setLimit($limit)->setSort('RAND()')->setCategory($categoryId)->setThisMonthOnly($thisMonthOnly);
37
    $products = $oledrion_shelf->getProducts($oledrion_shelf_parameters);
38
39
    if (isset($products['lastTitle'])) {
40
        unset($products['lastTitle']);
41
    }
42
    if (count($products) > 0) {
43
        $block['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
44
        $block['block_products'] = $products;
45
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
46
47
        return $block;
48
    } else {
49
        return false;
50
    }
51
}
52
53
/**
54
 * Paramètres du bloc

blocks/oledrion_rated.php 1 location

@@ 25-50 (lines=26) @@
22
 * @param $options
23
 * @return array|bool
24
 */
25
function b_oledrion_rated_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
    $products   = $block = array();
31
    $start      = 0;
32
    $limit      = $options[0];
33
    $categoryId = $options[1];
34
35
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('bestrated')->setStart($start)->setLimit($limit)->setSort('product_rating')->setOrder('DESC')->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 { // La liste des produits est introuvable (on ne trouve pas les produits vendus dans le stock des produits)
47
48
        return false;
49
    }
50
}
51
52
/**
53
 * Paramètres du bloc

blocks/oledrion_recommended.php 1 location

@@ 25-54 (lines=30) @@
22
 * @param $options
23
 * @return array|bool
24
 */
25
function b_oledrion_recomm_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
    $products   = $block = array();
31
    $start      = 0;
32
    $limit      = $options[0];
33
    $categoyrId = $options[1];
34
35
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('recommended')->setStart($start)->setLimit($limit)->setSort('product_recommended')->setOrder('DESC')->setCategory($categoyrId);
36
    $products = $oledrion_shelf->getProducts($oledrion_shelf_parameters);
37
38
    if ($h_oledrion_products->getRecommendedCount() > $limit) { // Il y a plus de produits recommandés dans la BDD que dans le bloc, on affiche donc un lien vers la page des produits recommandés
39
        $block['showMore'] = true;
40
    }
41
    if (isset($products['lastTitle'])) {
42
        unset($products['lastTitle']);
43
    }
44
    if (count($products) > 0) {
45
        $block['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
46
        $block['block_products'] = $products;
47
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
48
49
        return $block;
50
    } else { // Pas de produits recommandés
51
52
        return false;
53
    }
54
}
55
56
/**
57
 * Paramètres du bloc

blocks/oledrion_top.php 1 location

@@ 24-48 (lines=25) @@
21
 * @param $options
22
 * @return array|bool
23
 */
24
function b_oledrion_top_show($options)
25
{
26
    // '10|0';  // Voir 10 produits, pour toutes les catégories ou une catégorie particulière
27
    global $xoopsConfig, $xoTheme;
28
    include XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php';
29
    $products   = $block = array();
30
    $start      = 0;
31
    $limit      = $options[0];
32
    $categoyrId = $options[1];
33
    $oledrion_shelf_parameters->resetDefaultValues()->setProductsType('mostviewed')->setStart($start)->setLimit($limit)->setSort('product_hits')->setOrder('DESC')->setCategory($categoyrId);
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['nostock_msg']    = OledrionUtility::getModuleOption('nostock_msg');
40
        $block['block_products'] = $products;
41
        $xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css');
42
43
        return $block;
44
    } else { // La liste des produits est introuvable (on ne trouve pas les produits vendus dans le stock des produits)
45
46
        return false;
47
    }
48
}
49
50
/**
51
 * Paramètres du bloc