adsense.php ➔ editclass()   B
last analyzed

Complexity

Conditions 7
Paths 10

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 10
nop 3
dl 0
loc 29
rs 8.5226
c 0
b 0
f 0
1
<?php
2
3
/**
4
 *
5
 * Module: Class_Booking
6
 * Author: The SmartFactory <www.smartfactory.ca>
7
 * Licence: GNU
8
 * @param bool $showmenu
9
 * @param int  $adsenseid
10
 * @param bool $clone
11
 */
12
13
use XoopsModules\Smartobject;
14
15
/**
16
 * @param bool $showmenu
17
 * @param int  $adsenseid
18
 * @param bool $clone
19
 */
20
function editclass($showmenu = false, $adsenseid = 0, $clone = false)
21
{
22
    global $smartobjectAdsenseHandler;
23
24
    $adsenseObj = $smartobjectAdsenseHandler->get($adsenseid);
25
26
    if (!$clone && !$adsenseObj->isNew()) {
27
        if ($showmenu) {
28
            //Smartobject\Utility::getAdminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _AM_SOBJECT_EDITING);
29
        }
30
        Smartobject\Utility::getCollapsableBar('adsenseedit', _AM_SOBJECT_ADSENSES_EDIT, _AM_SOBJECT_ADSENSES_EDIT_INFO);
31
32
        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_EDIT, 'addadsense');
33
        $sform->display();
34
        Smartobject\Utility::closeCollapsable('adsenseedit');
35
    } else {
36
        $adsenseObj->setVar('adsenseid', 0);
37
        $adsenseObj->setVar('tag', '');
38
39
        if ($showmenu) {
40
            //Smartobject\Utility::getAdminMenu(3, _AM_SOBJECT_ADSENSES . " > " . _CO_SOBJECT_CREATINGNEW);
41
        }
42
43
        Smartobject\Utility::getCollapsableBar('adsensecreate', _AM_SOBJECT_ADSENSES_CREATE, _AM_SOBJECT_ADSENSES_CREATE_INFO);
44
        $sform = $adsenseObj->getForm(_AM_SOBJECT_ADSENSES_CREATE, 'addadsense', false, false, false, true);
45
        $sform->display();
46
        Smartobject\Utility::closeCollapsable('adsensecreate');
47
    }
48
}
49
50
require_once __DIR__ . '/admin_header.php';
51
//require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
52
require_once SMARTOBJECT_ROOT_PATH . 'class/adsense.php';
53
54
//$helper = \XoopsModules\Smartobject\Helper::getInstance();
55
//$helper = Smartobject\Helper::getInstance();
56
57
$smartobjectAdsenseHandler = $helper->getHandler('Adsense');
58
$helper->loadLanguage('adsense');
59
$adminObject = \Xmf\Module\Admin::getInstance();
60
61
$op = '';
62
63
if (isset($_GET['op'])) {
64
    $op = $_GET['op'];
65
}
66
if (isset($_POST['op'])) {
67
    $op = $_POST['op'];
68
}
69
70
switch ($op) {
71 View Code Duplication
    case 'mod':
0 ignored issues
show
Duplication introduced by
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...
72
73
        $adsenseid = \Xmf\Request::getInt('adsenseid', 0, 'GET');
74
75
        Smartobject\Utility::getXoopsCpHeader();
76
        $adminObject->displayNavigation(basename(__FILE__));
77
78
        editclass(true, $adsenseid);
79
        break;
80
81 View Code Duplication
    case 'clone':
0 ignored issues
show
Duplication introduced by
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...
82
83
        $adsenseid = \Xmf\Request::getInt('adsenseid', 0, 'GET');
84
85
        Smartobject\Utility::getXoopsCpHeader();
86
        $adminObject->displayNavigation(basename(__FILE__));
87
88
        editclass(true, $adsenseid, true);
89
        break;
90
91
    case 'addadsense':
92
        if (@require_once SMARTOBJECT_ROOT_PATH . 'include/captcha/captcha.php') {
93
            $xoopsCaptcha = XoopsCaptcha::getInstance();
94
            if (!$xoopsCaptcha->verify()) {
95
                redirect_header('javascript:history.go(-1);', 3, $xoopsCaptcha->getMessage());
96
            }
97
        }
98
//        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
99
        $controller = new XoopsModules\Smartobject\ObjectController($smartobjectAdsenseHandler);
100
        $controller->storeFromDefaultForm(_AM_SOBJECT_ADSENSES_CREATED, _AM_SOBJECT_ADSENSES_MODIFIED);
101
        break;
102
103
    case 'del':
104
105
//        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
106
        $controller = new XoopsModules\Smartobject\ObjectController($smartobjectAdsenseHandler);
107
        $controller->handleObjectDeletion();
108
109
        break;
110
111
    default:
112
113
        Smartobject\Utility::getXoopsCpHeader();
114
        $adminObject->displayNavigation(basename(__FILE__));
115
116
        //Smartobject\Utility::getAdminMenu(3, _AM_SOBJECT_ADSENSES);
117
118
        Smartobject\Utility::getCollapsableBar('createdadsenses', _AM_SOBJECT_ADSENSES, _AM_SOBJECT_ADSENSES_DSC);
119
120
//        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
121
        $objectTable = new XoopsModules\Smartobject\Table($smartobjectAdsenseHandler);
122
        $objectTable->addColumn(new XoopsModules\Smartobject\ObjectColumn('description', 'left'));
123
        $objectTable->addColumn(new XoopsModules\Smartobject\ObjectColumn(_AM_SOBJECT_ADSENSE_TAG, 'center', 200, 'getXoopsCode'));
0 ignored issues
show
Documentation introduced by
200 is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
'getXoopsCode' is of type string, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
124
125
        //      $objectTable->addCustomAction('getCreateItemLink');
126
        //      $objectTable->addCustomAction('getCreateAttributLink');
127
128
        $objectTable->addIntroButton('addadsense', 'adsense.php?op=mod', _AM_SOBJECT_ADSENSES_CREATE);
129
        /*
130
                $criteria_upcoming = new \CriteriaCompo();
131
                $criteria_upcoming->add(new \Criteria('start_date', time(), '>'));
132
                $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
133
                                            'key' => 'start_date',
134
                                            'criteria' => $criteria_upcoming
135
                ));
136
137
                $criteria_last7days = new \CriteriaCompo();
138
                $criteria_last7days->add(new \Criteria('start_date', time() - 30 *(60 * 60 * 24), '>'));
139
                $criteria_last7days->add(new \Criteria('start_date', time(), '<'));
140
                $objectTable->addFilter(_AM_SOBJECT_FILTER_LAST7DAYS, array(
141
                                            'key' => 'start_date',
142
                                            'criteria' => $criteria_last7days
143
                ));
144
145
                $criteria_last30days = new \CriteriaCompo();
146
                $criteria_last30days->add(new \Criteria('start_date', time() - 30 *(60 * 60 * 24), '>'));
147
                $criteria_last30days->add(new \Criteria('start_date', time(), '<'));
148
                $objectTable->addFilter(_AM_SOBJECT_FILTER_LAST30DAYS, array(
149
                                            'key' => 'start_date',
150
                                            'criteria' => $criteria_last30days
151
                ));
152
        */
153
        $objectTable->addQuickSearch(['title', 'summary', 'description']);
154
        $objectTable->addCustomAction('getCloneLink');
155
156
        $objectTable->render();
157
158
        echo '<br>';
159
        Smartobject\Utility::closeCollapsable('createdadsenses');
160
        echo '<br>';
161
162
        break;
163
}
164
165
//Smartobject\Utility::getModFooter();
166
//xoops_cp_footer();
167
require_once __DIR__ . '/admin_footer.php';
168