Completed
Push — master ( 484dcf...d1b073 )
by Michael
14s
created

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
 * XoopsPartners - a partner affiliation links module
17
 *
18
 * @package      module\xoopspartners\frontside
19
 * @author       Raul Recio (aka UNFOR)
20
 * @author       XOOPS Module Development Team
21
 * @copyright    {@link https://xoops.org 2001-2016 XOOPS Project}
22
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
23
 * @link         https://xoops.org XOOPS
24
 */
25
use Xmf\Request;
26
use Xmf\Module;
27
use Xmf\Module\Admin;
28
29
require __DIR__ . '/header.php';
30
31
$start = Request::getInt('start', 0, 'GET');
32
33
/** @var string $xoopsOption */
34
$xoopsOption['template_main'] = 'xoopspartners_index.tpl';
35
include $GLOBALS['xoops']->path('/header.php');
36
37
$xpPartnersHandler = $xpHelper->getHandler('partners');
38
$modConfigs        = $xpHelper->getConfig();
39
40
$criteria = new CriteriaCompo();
41
$criteria->add(new Criteria('status', XoopspartnersConstants::STATUS_ACTIVE, '='));
42
$criteria->setSort($modConfigs['modsort']);
43
$criteria->setOrder($modConfigs['modorder']);
44
$criteria->setLimit($modConfigs['modlimit']);
45
46
if (!empty($modConfigs['modlimit']) && ($start > 0)) {
47
    $criteria->setStart($start);
48
}
49
50
$partnerFields = array('id', 'hits', 'url', 'image', 'title', 'description');
51
$partnersArray = $xpPartnersHandler->getAll($criteria, $partnerFields, false, false);
52
$numPartners   = is_array($partnersArray) ? count($partnersArray) : 0;
53
54
$GLOBALS['xoopsTpl']->assign('partner_join',
55
                        ($GLOBALS['xoopsUser'] instanceof XoopsUser)
56
                        ? XoopspartnersConstants::JOIN_OK
57
                        : XoopspartnersConstants::JOIN_NOT_OK
58
);
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 & XoopspartnersConstants::SHOW_IMAGE) { // want image
69
        if (empty($thisPartner['image'])) { //but there isn't one
70
                $thisPartner['image'] = $thisPartner['title'];
71
            } else {
72
            $thisPartner['image'] =
73
            "<img src='{$thisPartner['image']}' "
74
            .   "alt='{$thisPartner['url']}' "
75
            .   "title='{$thisPartner['title']}'>";
76
            }
77
            } else {
78
        $thisPartner['image'] = '';
79
            }
80
    if ((($modShow & XoopspartnersConstants::SHOW_TITLE) // want text or invalid setting
81
        || (0 === ($modShow & (XoopspartnersConstants::SHOW_TITLE && XoopspartnersConstants::SHOW_IMAGE))))
82
        && ($thisPartner['image'] !== $thisPartner['title'])) // and valid image saved
83
    {
84
        $sep = $modShow ? '' : '<br>';
85
        $thisPartner['image'] = $thisPartner['image'] . $sep . $thisPartner['title'];
86
    }
87
88
    if (isset($GLOBALS['xoopsUser']) && $xpHelper->isUserAdmin()) {
89
        $thisPartner['admin_option'] =
90
            "<a href='admin/main.php?op=editPartner&amp;id={$thisPartner['id']}'>"
91
          . "<img src='" . Admin::iconUrl('edit.png', '16') . "' alt='" . _EDIT . "' title='" . _EDIT . "'></a>&nbsp;"
92
          . "<a href='admin/main.php?op=delPartner&amp;id={$thisPartner['id']}'>"
93
          . "<img src='" . Admin::iconUrl('delete.png', '16') . "' alt='" . _DELETE . "' title='" . _DELETE . "'></a>";
94
    }
95
    $GLOBALS['xoopsTpl']->append('partners', $thisPartner);
96
}
97
98
$modLimit = (int)$modConfigs['modlimit'];
99
$pageNav  = null;
100
if (0 !== $modLimit) {
101
    $nav     = new XoopsPageNav($numPartners, $modLimit, $start);
102
    $pageNav = $nav->renderImageNav();
103
}
104
$GLOBALS['xoopsTpl']->assign(array(
105
                                 'lang_partner'      => _MD_XOOPSPARTNERS_PARTNER,
106
                                 'lang_desc'         => _MD_XOOPSPARTNERS_DESCRIPTION,
107
                                 'lang_hits'         => _MD_XOOPSPARTNERS_HITS,
108
                                 'lang_no_partners'  => _MD_XOOPSPARTNERS_NOPART,
109
                                 'lang_main_partner' => _MD_XOOPSPARTNERS_PARTNERS,
110
                                //'sitename'          => $GLOBALS['xoopsConfig']['sitename'],
0 ignored issues
show
Unused Code Comprehensibility introduced by
84% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
111
                                'pagenav'           => $pageNav
112
                             )
113
);
114
include_once __DIR__ . '/footer.php';
115