customtag.php ➔ editcustomtag()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
nc 4
nop 3
dl 0
loc 29
rs 9.1448
c 0
b 0
f 0
1
<?php
2
3
use XoopsModules\Smartobject;
4
use XoopsModules\Smartobject\ObjectColumn;
5
use XoopsModules\Smartobject\ObjectController;
6
use XoopsModules\Smartobject\Table;
7
8
/**
9
 *
10
 * Module: Class_Booking
11
 * Author: The SmartFactory <www.smartfactory.ca>
12
 * Licence: GNU
13
 * @param bool $showmenu
14
 * @param int  $customtagid
15
 * @param bool $clone
16
 */
17
18
function editcustomtag($showmenu = false, $customtagid = 0, $clone = false)
19
{
20
    global $smartobjectCustomtagHandler;
21
22
    $customtagObj = $smartobjectCustomtagHandler->get($customtagid);
23
24
    if (!$clone && !$customtagObj->isNew()) {
25
        if ($showmenu) {
26
            //Smartobject\Utility::getAdminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _AM_SOBJECT_EDITING);
27
        }
28
        Smartobject\Utility::getCollapsableBar('customtagedit', _AM_SOBJECT_CUSTOMTAGS_EDIT, _AM_SOBJECT_CUSTOMTAGS_EDIT_INFO);
29
30
        $sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_EDIT, 'addcustomtag');
31
        $sform->display();
32
        Smartobject\Utility::closeCollapsable('customtagedit');
33
    } else {
34
        $customtagObj->setVar('customtagid', 0);
35
        $customtagObj->setVar('tag', '');
36
37
        if ($showmenu) {
38
            //Smartobject\Utility::getAdminMenu(2, _AM_SOBJECT_CUSTOMTAGS . " > " . _CO_SOBJECT_CREATINGNEW);
39
        }
40
41
        Smartobject\Utility::getCollapsableBar('customtagcreate', _AM_SOBJECT_CUSTOMTAGS_CREATE, _AM_SOBJECT_CUSTOMTAGS_CREATE_INFO);
42
        $sform = $customtagObj->getForm(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'addcustomtag');
43
        $sform->display();
44
        Smartobject\Utility::closeCollapsable('customtagcreate');
45
    }
46
}
47
48
require_once __DIR__ . '/admin_header.php';
49
Smartobject\Utility::loadLanguageFile('smartobject', 'customtag');
50
51
//require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
52
//require_once SMARTOBJECT_ROOT_PATH . 'class/customtag.php';
53
$smartobjectCustomtagHandler = Smartobject\Helper::getInstance()->getHandler('Customtag');
54
55
$adminObject = \Xmf\Module\Admin::getInstance();
56
57
$op = '';
58
59
if (isset($_GET['op'])) {
60
    $op = $_GET['op'];
61
}
62
if (isset($_POST['op'])) {
63
    $op = $_POST['op'];
64
}
65
66
switch ($op) {
67 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...
68
69
        $customtagid = \Xmf\Request::getInt('customtagid', 0, 'GET');
70
71
        Smartobject\Utility::getXoopsCpHeader();
72
        $adminObject->displayNavigation(basename(__FILE__));
73
74
        editcustomtag(true, $customtagid);
75
        break;
76
77 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...
78
79
        $customtagid = \Xmf\Request::getInt('customtagid', 0, 'GET');
80
81
        Smartobject\Utility::getXoopsCpHeader();
82
        $adminObject->displayNavigation(basename(__FILE__));
83
84
        editcustomtag(true, $customtagid, true);
85
        break;
86
87
    case 'addcustomtag':
88
//        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
89
        $controller = new XoopsModules\Smartobject\ObjectController($smartobjectCustomtagHandler);
90
        $controller->storeFromDefaultForm(_AM_SOBJECT_CUSTOMTAGS_CREATED, _AM_SOBJECT_CUSTOMTAGS_MODIFIED);
91
        break;
92
93
    case 'del':
94
95
//        require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectcontroller.php';
96
        $controller = new XoopsModules\Smartobject\ObjectController($smartobjectCustomtagHandler);
97
        $controller->handleObjectDeletion();
98
99
        break;
100
101
    default:
102
103
        Smartobject\Utility::getXoopsCpHeader();
104
        $adminObject->displayNavigation(basename(__FILE__));
105
        $adminObject->addItemButton(_AM_SOBJECT_CUSTOMTAGS_CREATE, 'customtag.php?op=mod', 'add', '');
106
        $adminObject->displayButton('left', '');
107
108
        //Smartobject\Utility::getAdminMenu(2, _AM_SOBJECT_CUSTOMTAGS);
109
110
        Smartobject\Utility::getCollapsableBar('createdcustomtags', _AM_SOBJECT_CUSTOMTAGS, _AM_SOBJECT_CUSTOMTAGS_DSC);
111
112
//        require_once SMARTOBJECT_ROOT_PATH . 'class/smartobjecttable.php';
113
        $objectTable = new XoopsModules\Smartobject\Table($smartobjectCustomtagHandler);
114
        $objectTable->addColumn(new XoopsModules\Smartobject\ObjectColumn('name', 'left', 150, 'getCustomtagName'));
0 ignored issues
show
Documentation introduced by
150 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
'getCustomtagName' 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...
115
        $objectTable->addColumn(new XoopsModules\Smartobject\ObjectColumn('description', 'left'));
116
        $objectTable->addColumn(new XoopsModules\Smartobject\ObjectColumn('language', 'center', 150));
0 ignored issues
show
Documentation introduced by
150 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...
117
118
        //      $objectTable->addCustomAction('getCreateItemLink');
119
        //      $objectTable->addCustomAction('getCreateAttributLink');
120
121
        //      $objectTable->addIntroButton('addcustomtag', 'customtag.php?op=mod', _AM_SOBJECT_CUSTOMTAGS_CREATE); //mb button
122
123
        /*
124
                $criteria_upcoming = new \CriteriaCompo();
125
                $criteria_upcoming->add(new \Criteria('start_date', time(), '>'));
126
                $objectTable->addFilter(_AM_SOBJECT_FILTER_UPCOMING, array(
127
                                            'key' => 'start_date',
128
                                            'criteria' => $criteria_upcoming
129
                ));
130
131
                $criteria_last7days = new \CriteriaCompo();
132
                $criteria_last7days->add(new \Criteria('start_date', time() - 30 *(60 * 60 * 24), '>'));
133
                $criteria_last7days->add(new \Criteria('start_date', time(), '<'));
134
                $objectTable->addFilter(_AM_SOBJECT_FILTER_LAST7DAYS, array(
135
                                            'key' => 'start_date',
136
                                            'criteria' => $criteria_last7days
137
                ));
138
139
                $criteria_last30days = new \CriteriaCompo();
140
                $criteria_last30days->add(new \Criteria('start_date', time() - 30 *(60 * 60 * 24), '>'));
141
                $criteria_last30days->add(new \Criteria('start_date', time(), '<'));
142
                $objectTable->addFilter(_AM_SOBJECT_FILTER_LAST30DAYS, array(
143
                                            'key' => 'start_date',
144
                                            'criteria' => $criteria_last30days
145
                ));
146
        */
147
        $objectTable->addQuickSearch(['title', 'summary', 'description']);
148
        $objectTable->addCustomAction('getCloneLink');
149
150
        $objectTable->render();
151
152
        echo '<br>';
153
        Smartobject\Utility::closeCollapsable('createdcustomtags');
154
        echo '<br>';
155
156
        break;
157
}
158
159
//Smartobject\Utility::getModFooter();
160
//xoops_cp_footer();
161
require_once __DIR__ . '/admin_footer.php';
162