|
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
|
|
|
use XoopsModules\Oledrion\Constants; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Affichage des listes au hasard |
|
25
|
|
|
* |
|
26
|
|
|
* @param array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés) |
|
27
|
|
|
* @return array |
|
28
|
|
|
*/ |
|
29
|
|
|
function b_oledrion_random_lists_show($options) |
|
30
|
|
|
{ |
|
31
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
|
32
|
|
|
$helper->loadLanguage('main'); |
|
|
|
|
|
|
33
|
|
|
$start = 0; |
|
34
|
|
|
$limit = (int)$options[0]; |
|
35
|
|
|
$listType = (int)$options[1]; |
|
|
|
|
|
|
36
|
|
|
$block = []; |
|
37
|
|
|
// $handlers = HandlerManager::getInstance(); |
|
38
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
39
|
|
|
$listsHandler = new Oledrion\ListsHandler($db); |
|
40
|
|
|
$items = []; |
|
|
|
|
|
|
41
|
|
|
//$items = $listsHandler->getRecentLists(new Oledrion\Parameters(array('start' => $start, 'limit' => $limit, 'sort' => 'RAND()', 'order' => 'DESC', 'idAsKey' => true, 'listType' => $listType))); |
|
42
|
|
|
$items = $listsHandler->getRecentLists(new Oledrion\Parameters([ |
|
43
|
|
|
'start' => $start, |
|
44
|
|
|
'limit' => $limit, |
|
45
|
|
|
'sort' => 'RAND()', |
|
46
|
|
|
'order' => 'DESC', |
|
47
|
|
|
'idAsKey' => true, |
|
48
|
|
|
'listType' => Constants::OLEDRION_LISTS_ALL_PUBLIC, |
|
49
|
|
|
])); |
|
50
|
|
|
if (count($items) > 0) { |
|
51
|
|
|
foreach ($items as $item) { |
|
52
|
|
|
$block['random_lists'][] = $item->toArray(); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
return $block; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Edition des paramètres du bloc |
|
61
|
|
|
* |
|
62
|
|
|
* @param array $options [0] = Nombre maximum de listes à voir, [1] = Type de listes (0 = les 2, 1 = liste cadeaux, 2 = produits recommandés) |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
function b_oledrion_random_lists_edit($options) |
|
66
|
|
|
{ |
|
67
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/oledrion/include/common.php'; |
|
68
|
|
|
$form = ''; |
|
69
|
|
|
$form .= "<table border='0'>"; |
|
70
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_LISTS_COUNT . "</td><td><input type='text' name='options[]' id='options' value='" . (int)$options[0] . "'></td></tr>"; |
|
71
|
|
|
$listTypes = Oledrion\Lists::getTypesArray(); |
|
72
|
|
|
$listTypeSelect = Oledrion\Utility::htmlSelect('options[]', $listTypes, (int)$options[1], false); |
|
73
|
|
|
$form .= '<tr><td>' . _MB_OLEDRION_LISTS_TYPE . '</td><td>' . $listTypeSelect . '</td></tr>'; |
|
74
|
|
|
$form .= '</table>'; |
|
75
|
|
|
|
|
76
|
|
|
return $form; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Bloc à la volée |
|
81
|
|
|
* @param $options |
|
82
|
|
|
*/ |
|
83
|
|
|
function b_oledrion_random_lists_duplicatable($options) |
|
84
|
|
|
{ |
|
85
|
|
|
$options = explode('|', $options); |
|
86
|
|
|
$block = b_oledrion_random_lists_show($options); |
|
87
|
|
|
|
|
88
|
|
|
$tpl = new \XoopsTpl(); |
|
89
|
|
|
$tpl->assign('block', $block); |
|
90
|
|
|
$tpl->display('db:oledrion_block_random_lists.tpl'); |
|
91
|
|
|
} |
|
92
|
|
|
|