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
|
|
|
* This program is distributed in the hope that it will be useful, |
7
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
8
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
9
|
|
|
* |
10
|
|
|
*-------------------------------------- |
11
|
|
|
* Author: Raul Recio (AKA UNFOR) |
12
|
|
|
* Project: The XOOPS Project |
13
|
|
|
*-------------------------------------- |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* XoopsPartners - a partner affiliation links module |
18
|
|
|
* |
19
|
|
|
* @package module\Xoopspartners\frontside |
20
|
|
|
* @author Raul Recio (aka UNFOR) |
21
|
|
|
* @author XOOPS Module Development Team |
22
|
|
|
* @copyright {@link https://xoops.org 2001-2016 XOOPS Project} |
23
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License} |
24
|
|
|
* @link https://xoops.org XOOPS |
25
|
|
|
*/ |
26
|
|
|
|
27
|
|
|
use Xmf\Module; |
28
|
|
|
use Xmf\Module\Admin; |
29
|
|
|
use Xmf\Request; |
30
|
|
|
use XoopsModules\Xoopspartners; |
31
|
|
|
use XoopsModules\Xoopspartners\Constants; |
32
|
|
|
|
33
|
|
|
require_once __DIR__ . '/header.php'; |
34
|
|
|
|
35
|
|
|
$start = Request::getInt('start', 0, 'GET'); |
36
|
|
|
|
37
|
|
|
/** @var string $xoopsOption */ |
38
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xoopspartners_index.tpl'; |
39
|
|
|
require_once $GLOBALS['xoops']->path('/header.php'); |
40
|
|
|
|
41
|
|
|
$partnersHandler = $helper->getHandler('Partners'); |
42
|
|
|
$modConfigs = $helper->getConfig(); |
43
|
|
|
|
44
|
|
|
$criteria = new \CriteriaCompo(); |
45
|
|
|
$criteria->add(new \Criteria('status', Constants::STATUS_ACTIVE, '=')); |
46
|
|
|
$criteria->setSort($modConfigs['modsort']); |
47
|
|
|
$criteria->setOrder($modConfigs['modorder']); |
48
|
|
|
$criteria->setLimit($modConfigs['modlimit']); |
49
|
|
|
|
50
|
|
|
if (!empty($modConfigs['modlimit']) && ($start > 0)) { |
51
|
|
|
$criteria->setStart($start); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
$partnerFields = ['id', 'hits', 'url', 'image', 'title', 'description']; |
55
|
|
|
$partnersArray = $partnersHandler->getAll($criteria, $partnerFields, false, false); |
56
|
|
|
$numPartners = is_array($partnersArray) ? count($partnersArray) : 0; |
57
|
|
|
|
58
|
|
|
$GLOBALS['xoopsTpl']->assign('partner_join', ($GLOBALS['xoopsUser'] instanceof \XoopsUser) ? Constants::JOIN_OK : Constants::JOIN_NOT_OK); |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* XOOPS Module config ['modshow'] |
62
|
|
|
* = 1 images (binary 01) |
63
|
|
|
* = 2 text (binary 10) |
64
|
|
|
* = 3 both (binary 11) |
65
|
|
|
*/ |
66
|
|
|
$modShow = (int)$modConfigs['modshow']; |
67
|
|
|
foreach ($partnersArray as $thisPartner) { |
68
|
|
|
if ($modShow & Constants::SHOW_IMAGE) { // want image |
69
|
|
|
if (empty($thisPartner['image'])) { //but there isn't one |
70
|
|
|
$thisPartner['image'] = $thisPartner['title']; |
71
|
|
|
} else { |
72
|
|
|
$thisPartner['image'] = "<img src='{$thisPartner['image']}' " . "alt='{$thisPartner['url']}' " . "title='{$thisPartner['title']}'>"; |
73
|
|
|
} |
74
|
|
|
} else { |
75
|
|
|
$thisPartner['image'] = ''; |
76
|
|
|
} |
77
|
|
|
if ((($modShow & Constants::SHOW_TITLE) // want text or invalid setting |
|
|
|
|
78
|
|
|
|| (0 === ($modShow && (Constants::SHOW_TITLE && Constants::SHOW_IMAGE)))) |
79
|
|
|
&& ($thisPartner['image'] !== $thisPartner['title'])) { // and valid image saved |
80
|
|
|
$sep = $modShow ? '' : '<br>'; |
81
|
|
|
$thisPartner['image'] .= $sep . $thisPartner['title']; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
if (isset($GLOBALS['xoopsUser']) && $helper->isUserAdmin()) { |
85
|
|
|
$thisPartner['admin_option'] = "<a href='admin/main.php?op=editPartner&id={$thisPartner['id']}'>" |
86
|
|
|
. "<img src='" |
87
|
|
|
. Admin::iconUrl('edit.png', '16') |
88
|
|
|
. "' alt='" |
89
|
|
|
. _EDIT |
90
|
|
|
. "' title='" |
91
|
|
|
. _EDIT |
92
|
|
|
. "'></a> " |
93
|
|
|
. "<a href='admin/main.php?op=delPartner&id={$thisPartner['id']}'>" |
94
|
|
|
. "<img src='" |
95
|
|
|
. Admin::iconUrl('delete.png', '16') |
96
|
|
|
. "' alt='" |
97
|
|
|
. _DELETE |
98
|
|
|
. "' title='" |
99
|
|
|
. _DELETE |
100
|
|
|
. "'></a>"; |
101
|
|
|
} |
102
|
|
|
$GLOBALS['xoopsTpl']->append('partners', $thisPartner); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$modLimit = (int)$modConfigs['modlimit']; |
106
|
|
|
$pageNav = null; |
107
|
|
|
if (0 !== $modLimit) { |
108
|
|
|
$nav = new \XoopsPageNav($numPartners, $modLimit, $start); |
109
|
|
|
$pageNav = $nav->renderImageNav(); |
110
|
|
|
} |
111
|
|
|
$GLOBALS['xoopsTpl']->assign( |
112
|
|
|
[ |
113
|
|
|
'lang_partner' => _MD_XOOPSPARTNERS_PARTNER, |
114
|
|
|
'lang_desc' => _MD_XOOPSPARTNERS_DESCRIPTION, |
115
|
|
|
'lang_hits' => _MD_XOOPSPARTNERS_HITS, |
116
|
|
|
'lang_no_partners' => _MD_XOOPSPARTNERS_NOPART, |
117
|
|
|
'lang_main_partner' => _MD_XOOPSPARTNERS_PARTNERS, |
118
|
|
|
//'sitename' => $GLOBALS['xoopsConfig']['sitename'], |
119
|
|
|
'pagenav' => $pageNav, |
120
|
|
|
] |
121
|
|
|
); |
122
|
|
|
require_once __DIR__ . '/footer.php'; |
123
|
|
|
|