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 récents |
24
|
|
|
* @param $options |
25
|
|
|
* @return array|bool |
26
|
|
|
*/ |
27
|
|
|
function b_oledrion_new_show($options) |
28
|
|
|
{ |
29
|
|
|
// '10|0|0'; // Voir 10 produits, pour toutes les catégories ou une catégorie particulière, uniquement les produits du mois ? |
30
|
|
|
global $xoopsConfig, $xoTheme; |
31
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
32
|
|
|
$start = 0; |
33
|
|
|
$limit = $options[0]; |
34
|
|
|
$categoryId = $options[1]; |
35
|
|
|
$thisMonthOnly = (int)$options[2]; |
36
|
|
|
|
37
|
|
|
$shelfParameters->resetDefaultValues()->setProductsType('recent')->setStart($start)->setLimit($limit)->setSort('product_id DESC, product_title')->setCategory($categoryId)->setThisMonthOnly($thisMonthOnly); |
|
|
|
|
38
|
|
|
$products = $shelf->getProducts($shelfParameters); |
|
|
|
|
39
|
|
|
if (isset($products['lastTitle'])) { |
40
|
|
|
unset($products['lastTitle']); |
41
|
|
|
} |
42
|
|
|
if (count($products) > 0) { |
43
|
|
|
$block = []; |
44
|
|
|
$block['nostock_msg'] = Oledrion\Utility::getModuleOption('nostock_msg'); |
45
|
|
|
$block['block_products'] = $products; |
46
|
|
|
$xoTheme->addStylesheet(OLEDRION_URL . 'assets/css/oledrion.css'); |
47
|
|
|
|
48
|
|
|
return $block; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return false; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Paramètres du bloc |
56
|
|
|
* @param $options |
57
|
|
|
* @return string |
58
|
|
|
*/ |
59
|
|
|
function b_oledrion_new_edit($options) |
60
|
|
|
{ |
61
|
|
|
// '10|0|0'; // Voir 10 produits, pour toutes les catégories, uniquement les produits du mois ? |
62
|
|
|
global $xoopsConfig; |
63
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
64
|
|
|
// require_once OLEDRION_PATH . 'class/tree.php'; |
65
|
|
|
$tblCategories = []; |
|
|
|
|
66
|
|
|
$tblCategories = $categoryHandler->getAllCategories(new Oledrion\Parameters()); |
|
|
|
|
67
|
|
|
$mytree = new Oledrion\XoopsObjectTree($tblCategories, 'cat_cid', 'cat_pid'); |
68
|
|
|
$form = ''; |
69
|
|
|
$form .= "<table border='0'>"; |
70
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_PRODUCTS_CNT . "</td><td><input type='text' name='options[]' id='options' value='" . $options[0] . "'></td></tr>"; |
71
|
|
|
|
72
|
|
|
$select0 = $mytree->makeSelectElement('options[]', 'cat_title', '-', $options[1], true, 0, '', _MB_OLEDRION_ALL_CATEGORIES); |
73
|
|
|
$select = $select0->render(); |
74
|
|
|
|
75
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_CATEGORY . '</td><td>' . $select . '</td></tr>'; |
76
|
|
|
|
77
|
|
|
$checked = ['', '']; |
78
|
|
|
$checked[$options[2]] = 'checked'; |
79
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_THIS_MONTH . "</td><td><input type='radio' name='options[]' id='options' value='1'" . $checked[1] . '>' . _YES . " <input type='radio' name='options[]' id='options' value='0'" . $checked[0] . '>' . _NO . '</td></tr>'; |
80
|
|
|
|
81
|
|
|
$form .= '</table>'; |
82
|
|
|
|
83
|
|
|
return $form; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* Bloc à la volée |
88
|
|
|
* @param $options |
89
|
|
|
*/ |
90
|
|
|
function b_oledrion_new_show_duplicatable($options) |
91
|
|
|
{ |
92
|
|
|
$options = explode('|', $options); |
93
|
|
|
$block = b_oledrion_new_show($options); |
94
|
|
|
|
95
|
|
|
$tpl = new \XoopsTpl(); |
96
|
|
|
$tpl->assign('block', $block); |
97
|
|
|
$tpl->display('db:oledrion_block_new.tpl'); |
98
|
|
|
} |
99
|
|
|
|