|
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
|
|
|
* Wfdownloads module |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
|
17
|
|
|
* @package wfdownload |
|
18
|
|
|
* @since 3.23 |
|
19
|
|
|
* @author Xoops Development Team |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
use Xmf\Request; |
|
23
|
|
|
use XoopsModules\Wfdownloads\{ |
|
24
|
|
|
Common, |
|
25
|
|
|
Common\LetterChoice, |
|
26
|
|
|
Helper, |
|
27
|
|
|
Utility, |
|
28
|
|
|
DownloadHandler, |
|
29
|
|
|
ObjectTree |
|
30
|
|
|
}; |
|
31
|
|
|
/** @var Helper $helper */ |
|
32
|
|
|
/** @var Utility $utility */ |
|
33
|
|
|
|
|
34
|
|
|
$currentFile = basename(__FILE__); |
|
35
|
|
|
require_once __DIR__ . '/header.php'; |
|
36
|
|
|
|
|
37
|
|
|
$GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_newlistindex.tpl"; |
|
38
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
|
39
|
|
|
|
|
40
|
|
|
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js'); |
|
41
|
|
|
$xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js'); |
|
|
|
|
|
|
42
|
|
|
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css'); |
|
43
|
|
|
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css'); |
|
44
|
|
|
|
|
45
|
|
|
$xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/'); |
|
46
|
|
|
|
|
47
|
|
|
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS]; |
|
48
|
|
|
|
|
49
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
|
50
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
|
51
|
|
|
$catArray['imageheader'] = Utility::headerImage(); |
|
52
|
|
|
//$catArray['letters'] = Utility::lettersChoice(); |
|
53
|
|
|
$db = XoopsDatabaseFactory::getDatabaseConnection(); |
|
54
|
|
|
$objHandler = new DownloadHandler($db); |
|
55
|
|
|
$choicebyletter = new LetterChoice($objHandler, null, null, range('a', 'z'), 'letter'); |
|
56
|
|
|
$catarray['letters'] = $choicebyletter->render(); |
|
57
|
|
|
|
|
58
|
|
|
$catArray['toolbar'] = Utility::toolbar(); |
|
59
|
|
|
$xoopsTpl->assign('catarray', $catArray); |
|
60
|
|
|
|
|
61
|
|
|
// Breadcrumb |
|
62
|
|
|
$breadcrumb = new Common\Breadcrumb(); |
|
63
|
|
|
$breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL); |
|
64
|
|
|
|
|
65
|
|
|
// Get number of downloads... |
|
66
|
|
|
$allowedCategories = $grouppermHandler->getItemIds('WFDownCatPerm', $groups, $helper->getModule()->mid()); |
|
67
|
|
|
// ... in the last week |
|
68
|
|
|
$oneWeekAgo = strtotime('-1 week'); //$oneWeekAgo = time() - 3600*24*7; //@TODO: Change to strtotime (TODAY-1week); |
|
69
|
|
|
$criteria = new Criteria('published', $oneWeekAgo, '>='); |
|
70
|
|
|
$allWeekDownloads = $helper->getHandler('Download')->getActiveCount($criteria); |
|
71
|
|
|
// ... in the last month |
|
72
|
|
|
$oneMonthAgo = strtotime('-1 month'); //$one_month_ago = time() - 3600*24*7; //@TODO: Change to strtotime (TODAY-1month); |
|
73
|
|
|
$criteria = new Criteria('published', $oneMonthAgo, '>='); |
|
74
|
|
|
$allMonthDownloads = $helper->getHandler('Download')->getActiveCount($criteria); |
|
75
|
|
|
$xoopsTpl->assign('allweekdownloads', $allWeekDownloads); |
|
76
|
|
|
$xoopsTpl->assign('allmonthdownloads', $allMonthDownloads); |
|
77
|
|
|
|
|
78
|
|
|
// Get latest downloads |
|
79
|
|
|
$criteria = new CriteriaCompo(new Criteria('offline', 0)); |
|
80
|
|
|
if (Request::hasVar('newdownloadshowdays', 'GET')) { |
|
81
|
|
|
$days = Request::getInt('newdownloadshowdays', 0, 'GET'); |
|
82
|
|
|
$days_limit = [7, 14, 30]; |
|
83
|
|
|
if (in_array($days, $days_limit)) { |
|
84
|
|
|
$xoopsTpl->assign('newdownloadshowdays', $days); |
|
85
|
|
|
$downloadshowdays = time() - (3600 * 24 * $days); |
|
86
|
|
|
$criteria->add(new Criteria('published', $downloadshowdays, '>='), 'AND'); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
$criteria->setSort('published'); |
|
90
|
|
|
$criteria->setOrder('DESC'); |
|
91
|
|
|
$criteria->setLimit($helper->getConfig('perpage')); |
|
92
|
|
|
$criteria->setStart(0); |
|
93
|
|
|
$downloadObjs = $helper->getHandler('Download')->getActiveDownloads($criteria); |
|
94
|
|
|
foreach ($downloadObjs as $downloadObj) { |
|
95
|
|
|
$downloadInfo = $downloadObj->getDownloadInfo(); |
|
96
|
|
|
$xoopsTpl->assign('lang_dltimes', sprintf(_MD_WFDOWNLOADS_DLTIMES, $downloadInfo['hits'])); |
|
97
|
|
|
$xoopsTpl->assign('lang_subdate', $downloadInfo['is_updated']); |
|
98
|
|
|
$xoopsTpl->append('file', $downloadInfo); |
|
99
|
|
|
$xoopsTpl->append('downloads', $downloadInfo); // this definition is not removed for backward compatibility issues |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
// Screenshots display |
|
103
|
|
|
$xoopsTpl->assign('show_screenshot', false); |
|
104
|
|
|
if (1 == $helper->getConfig('screenshot')) { |
|
105
|
|
|
$xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots')); |
|
106
|
|
|
$xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth')); |
|
107
|
|
|
$xoopsTpl->assign('shotheight', $helper->getConfig('shotheight')); |
|
108
|
|
|
$xoopsTpl->assign('show_screenshot', true); |
|
109
|
|
|
$xoopsTpl->assign('viewcat', true); |
|
110
|
|
|
} |
|
111
|
|
|
if (isset($days)) { |
|
112
|
|
|
$which_new_downloads = ' > ' . sprintf(_MD_WFDOWNLOADS_NEWDOWNLOADS_INTHELAST, (int)$days); |
|
113
|
|
|
$xoopsTpl->assign('categoryPath', '<a href="' . WFDOWNLOADS_URL . '/newlist.php">' . _MD_WFDOWNLOADS_NEWDOWNLOADS . '</a>' . $which_new_downloads); |
|
114
|
|
|
$breadcrumb->addLink(_MD_WFDOWNLOADS_LATESTLIST, $currentFile); |
|
115
|
|
|
$breadcrumb->addLink(sprintf(_MD_WFDOWNLOADS_NEWDOWNLOADS_INTHELAST, (int)$days), ''); |
|
116
|
|
|
} else { |
|
117
|
|
|
$xoopsTpl->assign('categoryPath', _MD_WFDOWNLOADS_NEWDOWNLOADS); |
|
118
|
|
|
$breadcrumb->addLink(_MD_WFDOWNLOADS_LATESTLIST, ''); |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
// Breadcrumb |
|
122
|
|
|
$xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render()); |
|
123
|
|
|
|
|
124
|
|
|
$xoopsTpl->assign('module_home', Utility::moduleHome(true)); |
|
125
|
|
|
require_once __DIR__ . '/footer.php'; |
|
126
|
|
|
|