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
|
|
|
* Renvoie la liste des produits recommandés |
24
|
|
|
* @param $options |
25
|
|
|
* @return array|bool |
26
|
|
|
*/ |
27
|
|
|
function b_oledrion_recomm_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 = []; |
|
|
|
|
33
|
|
|
$start = 0; |
34
|
|
|
$limit = $options[0]; |
35
|
|
|
$categoyrId = $options[1]; |
36
|
|
|
|
37
|
|
|
$shelfParameters->resetDefaultValues()->setProductsType('recommended')->setStart($start)->setLimit($limit)->setSort('product_recommended')->setOrder('DESC')->setCategory($categoyrId); |
|
|
|
|
38
|
|
|
$products = $shelf->getProducts($shelfParameters); |
|
|
|
|
39
|
|
|
|
40
|
|
|
if ($productsHandler->getRecommendedCount() > $limit) { |
|
|
|
|
41
|
|
|
// 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 |
42
|
|
|
$block['showMore'] = true; |
43
|
|
|
} |
44
|
|
|
if (isset($products['lastTitle'])) { |
45
|
|
|
unset($products['lastTitle']); |
46
|
|
|
} |
47
|
|
|
if (count($products) > 0) { |
48
|
|
|
$block['nostock_msg'] = Oledrion\Utility::getModuleOption('nostock_msg'); |
49
|
|
|
$block['block_products'] = $products; |
50
|
|
|
$xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css'); |
51
|
|
|
|
52
|
|
|
return $block; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
// Pas de produits recommandés |
56
|
|
|
|
57
|
|
|
return false; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Paramètres du bloc |
62
|
|
|
* @param $options |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
|
|
function b_oledrion_recomm_edit($options) |
66
|
|
|
{ |
67
|
|
|
// '10|0'; // Voir 10 produits, pour toutes les catégories |
68
|
|
|
global $xoopsConfig; |
69
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
70
|
|
|
// require_once OLEDRION_PATH . 'class/tree.php'; |
71
|
|
|
$tblCategories = []; |
|
|
|
|
72
|
|
|
$tblCategories = $categoryHandler->getAllCategories(new Oledrion\Parameters()); |
|
|
|
|
73
|
|
|
$mytree = new Oledrion\XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
74
|
|
|
$form = ''; |
75
|
|
|
$checkeds = ['', '']; |
76
|
|
|
$checkeds[$options[1]] = 'checked'; |
77
|
|
|
$form .= "<table border='0'>"; |
78
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_PRODUCTS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>"; |
79
|
|
|
|
80
|
|
|
$select0 = $mytree->makeSelectElement('options[]', 'cat_title', '-', $options[1], true, 0, '', _MB_OLEDRION_ALL_CATEGORIES); |
81
|
|
|
$select = $select0->render(); |
82
|
|
|
|
83
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
84
|
|
|
$form .= '</table>'; |
85
|
|
|
|
86
|
|
|
return $form; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* Bloc à la volée |
91
|
|
|
* @param $options |
92
|
|
|
*/ |
93
|
|
|
function b_oledrion_recomm_show_duplicatable($options) |
94
|
|
|
{ |
95
|
|
|
$options = explode('|', $options); |
96
|
|
|
$block = b_oledrion_recomm_show($options); |
97
|
|
|
|
98
|
|
|
$tpl = new \XoopsTpl(); |
99
|
|
|
$tpl->assign('block', $block); |
100
|
|
|
$tpl->display('db:oledrion_block_recommended.tpl'); |
101
|
|
|
} |
102
|
|
|
|