-
Notifications
You must be signed in to change notification settings - Fork 3
/
list.php
105 lines (90 loc) · 4.15 KB
/
list.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/*
You may not change or alter any portion of this comment or credits
of supporting developers from this source code or any supporting source code
which is considered copyrighted (c) material of the original comment or credit authors.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* oledrion
*
* @copyright {@link https://xoops.org/ XOOPS Project}
* @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license}
* @author Hervé Thouzard (http://www.herve-thouzard.com/)
*/
/**
* Displaying the contents of a list
*
* @param int list_id Identifier of the list
*/
use XoopsModules\Oledrion;
use XoopsModules\Oledrion\Constants;
require_once __DIR__ . '/header.php';
$GLOBALS['current_category'] = -1;
$GLOBALS['xoopsOption']['template_main'] = 'oledrion_list.tpl';
require_once XOOPS_ROOT_PATH . '/header.php';
if (\Xmf\Request::hasVar('list_id', 'GET')) {
$list_id = \Xmf\Request::getInt('list_id', 0, 'GET');
} else {
Oledrion\Utility::redirect(_OLEDRION_ERROR21, 'index.php', 5);
}
//$handlers = HandlerManager::getInstance();
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$listsHandler = new Oledrion\ListsHandler($db);
// The list exists ?
/** @var Oledrion\Lists $list */
//$list = null;
$list = $listsHandler->get($list_id);
if (!is_object($list)) {
Oledrion\Utility::redirect(_OLEDRION_ERROR21, 'index.php', 5);
}
// Verification of the type of list (public / private)
if (!$list->isSuitableForCurrentUser()) {
Oledrion\Utility::redirect(_OLEDRION_ERROR22, 'index.php', 5);
}
$xoopsTpl->assign('mod_pref', $mod_pref); // Module Preferences
$xoopsTpl->assign('columnsCount', Oledrion\Utility::getModuleOption('category_colums'));
$xoopsTpl->assign('list', $list->toArray());
// TVA
// $vatArray = [];
$vatArray = $vatHandler->getAllVats(new Oledrion\Parameters());
// Search products from the list
$products = $listsHandler->getListProducts($list);
if (count($products) > 0) {
/** @var Oledrion\Products $product */
foreach ($products as $product) {
$xoopsTpl->append('products', $product->toArray());
}
}
// Update view count
$listsHandler->incrementListViews($list);
// Search this user's other lists
if ($listsHandler->getRecentListsCount(Constants::OLEDRION_LISTS_ALL_PUBLIC, Oledrion\Utility::getCurrentUserID()) > 1) {
$otherUserLists = $listsHandler->getRecentLists(new Oledrion\Parameters([
'start' => 0,
'limit' => 0,
'sort' => 'list_date',
'order' => 'DESC',
'idAsKey' => true,
'listType' => Constants::OLEDRION_LISTS_ALL_PUBLIC,
'list_uid' => Oledrion\Utility::getCurrentUserID(),
]));
if (count($otherUserLists) > 0) {
foreach ($otherUserLists as $oneOtherList) {
$xoopsTpl->append('otherUserLists', $oneOtherList->toArray());
}
}
}
Oledrion\Utility::setCSS();
Oledrion\Utility::setLocalCSS($xoopsConfig['language']);
$helper->loadLanguage('modinfo');
$breadcrumb = [
OLEDRION_URL . 'all-lists.php' => _MI_OLEDRION_SMNAME11,
OLEDRION_URL . basename(__FILE__) => $list->getVar('list_title'),
];
$xoopsTpl->assign('breadcrumb', Oledrion\Utility::breadcrumb($breadcrumb));
$title = $list->getVar('list_title') . ' - ' . Oledrion\Utility::getModuleName();
Oledrion\Utility::setMetas($title, $title, Oledrion\Utility::createMetaKeywords($list->getVar('list_description', 'n') . ' ' . $list->getVar('list_title', 'n')));
require_once XOOPS_ROOT_PATH . '/footer.php';