-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathnewlist.php
125 lines (109 loc) · 5.33 KB
/
newlist.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?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.
*/
/**
* Wfdownloads module
*
* @copyright XOOPS Project (https://xoops.org)
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
* @package wfdownload
* @since 3.23
* @author Xoops Development Team
*/
use Xmf\Request;
use XoopsModules\Wfdownloads\{
Common,
Common\LetterChoice,
Helper,
Utility,
DownloadHandler,
ObjectTree
};
/** @var Helper $helper */
/** @var Utility $utility */
$currentFile = basename(__FILE__);
require_once __DIR__ . '/header.php';
$GLOBALS['xoopsOption']['template_main'] = "{$helper->getModule()->dirname()}_newlistindex.tpl";
require_once XOOPS_ROOT_PATH . '/header.php';
$xoTheme->addScript(XOOPS_URL . '/browse.php?Frameworks/jquery/jquery.js');
$xoTheme->addScript(WFDOWNLOADS_URL . '/assets/js/magnific/jquery.magnific-popup.min.js');
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/js/magnific/magnific-popup.css');
$xoTheme->addStylesheet(WFDOWNLOADS_URL . '/assets/css/module.css');
$xoopsTpl->assign('wfdownloads_url', WFDOWNLOADS_URL . '/');
$groups = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : [0 => XOOPS_GROUP_ANONYMOUS];
/** @var \XoopsGroupPermHandler $grouppermHandler */
$grouppermHandler = xoops_getHandler('groupperm');
$catArray['imageheader'] = Utility::headerImage();
//$catArray['letters'] = Utility::lettersChoice();
$db = XoopsDatabaseFactory::getDatabaseConnection();
$objHandler = new DownloadHandler($db);
$choicebyletter = new LetterChoice($objHandler, null, null, range('a', 'z'), 'letter');
$catarray['letters'] = $choicebyletter->render();
$catArray['toolbar'] = Utility::toolbar();
$xoopsTpl->assign('catarray', $catArray);
// Breadcrumb
$breadcrumb = new Common\Breadcrumb();
$breadcrumb->addLink($helper->getModule()->getVar('name'), WFDOWNLOADS_URL);
// Get number of downloads...
$allowedCategories = $grouppermHandler->getItemIds('WFDownCatPerm', $groups, $helper->getModule()->mid());
// ... in the last week
$oneWeekAgo = strtotime('-1 week'); //$oneWeekAgo = time() - 3600*24*7; //@TODO: Change to strtotime (TODAY-1week);
$criteria = new Criteria('published', $oneWeekAgo, '>=');
$allWeekDownloads = $helper->getHandler('Download')->getActiveCount($criteria);
// ... in the last month
$oneMonthAgo = strtotime('-1 month'); //$one_month_ago = time() - 3600*24*7; //@TODO: Change to strtotime (TODAY-1month);
$criteria = new Criteria('published', $oneMonthAgo, '>=');
$allMonthDownloads = $helper->getHandler('Download')->getActiveCount($criteria);
$xoopsTpl->assign('allweekdownloads', $allWeekDownloads);
$xoopsTpl->assign('allmonthdownloads', $allMonthDownloads);
// Get latest downloads
$criteria = new CriteriaCompo(new Criteria('offline', 0));
if (Request::hasVar('newdownloadshowdays', 'GET')) {
$days = Request::getInt('newdownloadshowdays', 0, 'GET');
$days_limit = [7, 14, 30];
if (in_array($days, $days_limit)) {
$xoopsTpl->assign('newdownloadshowdays', $days);
$downloadshowdays = time() - (3600 * 24 * $days);
$criteria->add(new Criteria('published', $downloadshowdays, '>='), 'AND');
}
}
$criteria->setSort('published');
$criteria->setOrder('DESC');
$criteria->setLimit($helper->getConfig('perpage'));
$criteria->setStart(0);
$downloadObjs = $helper->getHandler('Download')->getActiveDownloads($criteria);
foreach ($downloadObjs as $downloadObj) {
$downloadInfo = $downloadObj->getDownloadInfo();
$xoopsTpl->assign('lang_dltimes', sprintf(_MD_WFDOWNLOADS_DLTIMES, $downloadInfo['hits']));
$xoopsTpl->assign('lang_subdate', $downloadInfo['is_updated']);
$xoopsTpl->append('file', $downloadInfo);
$xoopsTpl->append('downloads', $downloadInfo); // this definition is not removed for backward compatibility issues
}
// Screenshots display
$xoopsTpl->assign('show_screenshot', false);
if (1 == $helper->getConfig('screenshot')) {
$xoopsTpl->assign('shots_dir', $helper->getConfig('screenshots'));
$xoopsTpl->assign('shotwidth', $helper->getConfig('shotwidth'));
$xoopsTpl->assign('shotheight', $helper->getConfig('shotheight'));
$xoopsTpl->assign('show_screenshot', true);
$xoopsTpl->assign('viewcat', true);
}
if (isset($days)) {
$which_new_downloads = ' > ' . sprintf(_MD_WFDOWNLOADS_NEWDOWNLOADS_INTHELAST, (int)$days);
$xoopsTpl->assign('categoryPath', '<a href="' . WFDOWNLOADS_URL . '/newlist.php">' . _MD_WFDOWNLOADS_NEWDOWNLOADS . '</a>' . $which_new_downloads);
$breadcrumb->addLink(_MD_WFDOWNLOADS_LATESTLIST, $currentFile);
$breadcrumb->addLink(sprintf(_MD_WFDOWNLOADS_NEWDOWNLOADS_INTHELAST, (int)$days), '');
} else {
$xoopsTpl->assign('categoryPath', _MD_WFDOWNLOADS_NEWDOWNLOADS);
$breadcrumb->addLink(_MD_WFDOWNLOADS_LATESTLIST, '');
}
// Breadcrumb
$xoopsTpl->assign('wfdownloads_breadcrumb', $breadcrumb->render());
$xoopsTpl->assign('module_home', Utility::moduleHome(true));
require_once __DIR__ . '/footer.php';