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

index.php (3 issues)

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
 ------------------------------------------------------------------------
4
               XOOPS - PHP Content Management System
5
                   Copyright (c) 2000 XOOPS.org
6
                      <http://www.xoops.org/>
7
 ------------------------------------------------------------------------
8
 This program is free software; you can redistribute it and/or modify
9
 it under the terms of the GNU General Public License as published by
10
 the Free Software Foundation; either version 2 of the License, or
11
 (at your option) any later version.
12
13
 You may not change or alter any portion of this comment or credits
14
 of supporting developers from this source code or any supporting
15
 source code which is considered copyrighted (c) material of the
16
 original comment or credit authors.
17
18
 This program is distributed in the hope that it will be useful,
19
 but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 GNU General Public License for more details.
22
23
 You should have received a copy of the GNU General Public License
24
 along with this program; if not, write to the Free Software
25
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
26
 ------------------------------------------------------------------------
27
 Author: Raul Recio (AKA UNFOR)
28
 Project: The XOOPS Project
29
 ------------------------------------------------------------------------
30
 */
31
/**
32
 * XoopsPartners - a partner affiliation links module
33
 *
34
 * @category     Module
35
 * @package      xoopspartners
36
 * @subpackage   front
37
 * @author       Raul Recio (aka UNFOR)
38
 * @author       XOOPS Module Development Team
39
 * @copyright    {@link http://xoops.org 2001-2016 XOOPS Project}
40
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
41
 * @link         http://xoops.org XOOPS
42
 */
43
44
require __DIR__ . '/header.php';
45
/** @var string $xoopsOption */
46
$xoopsOption['template_main'] = 'xoopspartners_index.tpl';
47
include $GLOBALS['xoops']->path('/header.php');
48
49
$start = XoopsRequest::getInt('start', 0, 'GET');
50
51
$xpPartnersHandler = xoops_getModuleHandler('partners', $moduleDirname);
52
53
$moduleHandler = xoops_getHandler('module');
54
$moduleInfo    = $moduleHandler->get($GLOBALS['xoopsModule']->getVar('mid'));
55
$pathIcon16    = $GLOBALS['xoops']->url('www/' . $GLOBALS['xoopsModule']->getInfo('icons16'));
56
57
$criteria = new CriteriaCompo();
58
$criteria->add(new Criteria('status', XoopspartnersConstants::STATUS_ACTIVE, '='));
59
$criteria->setSort($GLOBALS['xoopsModuleConfig']['modsort']);
60
$criteria->setOrder($GLOBALS['xoopsModuleConfig']['modorder']);
61
$criteria->setLimit($GLOBALS['xoopsModuleConfig']['modlimit']);
62
63
if (0 != $GLOBALS['xoopsModuleConfig']['modlimit'] && ($start > 0)) {
64
    $criteria->setStart($start);
65
}
66
67
$partnerFields = array('id', 'hits', 'url', 'image', 'title', 'description');
68
$partnersArray = $xpPartnersHandler->getAll($criteria, $partnerFields, false, false);
69
$numPartners   = is_array($partnersArray) ? count($partnersArray) : 0;
70
71
$GLOBALS['xoopsTpl']->assign('partner_join', ($GLOBALS['xoopsUser'] instanceof XoopsUser) ? XoopspartnersConstants::JOIN_OK : XoopspartnersConstants::JOIN_NOT_OK);
0 ignored issues
show
The class XoopsUser does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
72
73
/**
74
 * $GLOBALS['xoopsModuleConfig']['modshow']
75
 *    = 1        images
76
 *    = 2        text
77
 *    = 3        both
78
 */
79
foreach ($partnersArray as $thisPartner) {
80
    switch ($GLOBALS['xoopsModuleConfig']['modshow']) {
81
        case 3: //both image and text
82 View Code Duplication
            if (empty($thisPartner['image'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
83
                $thisPartner['image'] = $thisPartner['title'];
84
            } else {
85
                $thisPartner['image'] = "<img src='{$thisPartner['image']}' alt='{$thisPartner['url']}' title='{$thisPartner['title']}'>" . "<br>{$thisPartner['title']}";
86
            }
87
            break;
88
        case 2: // text
89
            $thisPartner['image'] = $thisPartner['title'];
90
            break;
91
        case 1: // images
92
        default:
93 View Code Duplication
            if (empty($thisPartner['image'])) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
94
                $thisPartner['image'] = $thisPartner['title'];
95
            } else {
96
                $thisPartner['image'] = "<img src='{$thisPartner['image']}' alt='{$thisPartner['url']}' title='{$thisPartner['title']}'>";
97
            }
98
            break;
99
    }
100
101
    if ($xoopsUserIsAdmin) {
102
        $thisPartner['admin_option'] =
103
            "<a href='admin/main.php?op=editPartner&amp;id={$thisPartner['id']}'><img src='{$pathIcon16}/edit.png' alt='" . _EDIT . "' title='" . _EDIT . "'></a>&nbsp;<a href='admin/main.php?op=delPartner&amp;id={$thisPartner['id']}'><img src='{$pathIcon16}/delete.png' alt='" . _DELETE . "' title='"
104
            . _DELETE . "'></a>";
105
    }
106
    $GLOBALS['xoopsTpl']->append('partners', $thisPartner);
107
}
108
109
if (0 != (int)$GLOBALS['xoopsModuleConfig']['modlimit']) {
110
    $nav     = new XoopsPageNav($numPartners, (int)$GLOBALS['xoopsModuleConfig']['modlimit'], $start);
111
    $pagenav = $nav->renderImageNav();
112
}
113
$GLOBALS['xoopsTpl']->assign(array(
114
                                 'lang_partner'      => _MD_XPARTNERS_PARTNER,
115
                                 'lang_desc'         => _MD_XPARTNERS_DESCRIPTION,
116
                                 'lang_hits'         => _MD_XPARTNERS_HITS,
117
                                 'lang_no_partners'  => _MD_XPARTNERS_NOPART,
118
                                 'lang_main_partner' => _MD_XPARTNERS_PARTNERS,
119
                                 'sitename'          => $GLOBALS['xoopsConfig']['sitename'],
120
                                 'pagenav'           => $pagenav
121
                             ));
122
include_once __DIR__ . '/footer.php';
123