Passed
Push — master ( dcbd4a...4bb7b0 )
by Michael
02:37
created

main.php ➔ AddEditMarqueeForm()   F

Complexity

Conditions 10
Paths 512

Size

Total Lines 100
Code Lines 77

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 77
nc 512
nop 18
dl 0
loc 100
rs 3.2187
c 0
b 0
f 0

How to fix   Long Method    Complexity    Many Parameters   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 44 and the first side effect is on line 25.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (http://www.herve-thouzard.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright          Hervé Thouzard (http://www.herve-thouzard.com)
15
 * @license            http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package            marquee
17
 * @author             Hervé Thouzard (http://www.herve-thouzard.com)
18
 *
19
 * ****************************************************************************
20
 */
21
22
use Xmf\Request;
0 ignored issues
show
Bug introduced by
The type Xmf\Request was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use XoopsModules\Marquee;
24
25
require_once __DIR__ . '/admin_header.php';
26
require_once __DIR__ . '/../../../include/cp_header.php';
27
require_once XOOPS_ROOT_PATH . '/modules/marquee/admin/functions.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
28
//require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php';
0 ignored issues
show
Unused Code Comprehensibility introduced by
36% 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...
29
//require_once XOOPS_ROOT_PATH . '/modules/marquee/class/marquee_utils.php';
30
31
32
$adminObject = \Xmf\Module\Admin::getInstance();
0 ignored issues
show
Bug introduced by
The type Xmf\Module\Admin was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
33
34
$op = Request::getCmd('op', Request::getCmd('op', 'default', 'POST'), 'GET');
35
36
// Verify that a field exists inside a mysql table
37
38
/**
39
 * @param $fieldname
40
 * @param $table
41
 *
42
 * @return bool
43
 */
44
function marquee_FieldExists($fieldname, $table)
45
{
46
    global $xoopsDB;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
47
    $result = $xoopsDB->queryF("SHOW COLUMNS FROM   $table LIKE '$fieldname'");
48
49
    return ($xoopsDB->getRowsNum($result) > 0);
50
}
51
52
// Verify if the table is up to date
53
if (!marquee_FieldExists('marquee_marqueeid', $xoopsDB->prefix('marquee'))) {
54
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . ' CHANGE `marqueeid` `marquee_marqueeid` INT( 8 ) NOT NULL AUTO_INCREMENT');
55
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `uid` `marquee_uid` MEDIUMINT( 8 ) NOT NULL DEFAULT '0'");
56
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `direction` `marquee_direction` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
57
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `scrollamount` `marquee_scrollamount` INT( 11 ) NOT NULL DEFAULT '0'");
58
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `behaviour` `marquee_behaviour` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
59
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . ' CHANGE `bgcolor` `marquee_bgcolor` VARCHAR( 7 ) NOT NULL');
60
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `align` `marquee_align` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
61
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `height` `marquee_height` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
62
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . ' CHANGE `width` `marquee_width` VARCHAR( 4 ) NOT NULL');
63
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `hspace` `marquee_hspace` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
64
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `scrolldelay` `marquee_scrolldelay` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
65
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `stoponmouseover` `marquee_stoponmouseover` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
66
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `loop` `marquee_loop` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
67
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `vspace` `marquee_vspace` SMALLINT( 6 ) NOT NULL DEFAULT '0'");
68
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . ' CHANGE `content` `marquee_content` TEXT NOT NULL');
69
    $result = $xoopsDB->queryF('ALTER TABLE ' . $xoopsDB->prefix('marquee') . " CHANGE `source` `marquee_source` VARCHAR( 255 ) NOT NULL DEFAULT 'fixed'");
70
}
71
72
//$marqueeHandler = Marquee\Helper::getInstance()->getHandler('Marqueex');
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
73
//$marqueeHandler = new MarqueeHandler($db);
74
75
// Function used to add and modify an element
76
/**
77
 * @param        $marqueeid
78
 * @param        $Action
79
 * @param        $FormTitle
80
 * @param        $contentvalue
81
 * @param        $bgcolorvalue
82
 * @param        $widthvalue
83
 * @param        $heightvalue
84
 * @param        $scrollamountvalue
85
 * @param        $hspacevalue
86
 * @param        $vspacevalue
87
 * @param        $scrolldelayvalue
88
 * @param        $directionvalue
89
 * @param        $behaviourvalue
90
 * @param        $alignvalue
91
 * @param        $loopvalue
92
 * @param        $stopvalue
93
 * @param        $LabelSubmitButton
94
 * @param string $sourcevalue
95
 * @throws \Exception
96
 */
97
function AddEditMarqueeForm(
98
    $marqueeid,
99
    $Action,
100
    $FormTitle,
101
    $contentvalue,
102
    $bgcolorvalue,
103
    $widthvalue,
104
    $heightvalue,
105
    $scrollamountvalue,
106
    $hspacevalue,
107
    $vspacevalue,
108
    $scrolldelayvalue,
109
    $directionvalue,
110
    $behaviourvalue,
111
    $alignvalue,
112
    $loopvalue,
113
    $stopvalue,
114
    $LabelSubmitButton,
115
    $sourcevalue = 'fixed'
116
) {
117
    require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
118
    global $xoopsModule;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
119
120
    $sform = new \XoopsThemeForm($FormTitle, 'marqueeform', XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php');
0 ignored issues
show
Bug introduced by
The type XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
121
122
    $source = new \XoopsFormSelect(_AM_MARQUEE_SOURCE, 'source', $sourcevalue);
0 ignored issues
show
Bug introduced by
The type XoopsFormSelect was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
123
    $source->addOption('fixed', _AM_MARQUEE_SOURCE_FIXED);
124
    $fileslst = myglob(XOOPS_ROOT_PATH . '/modules/marquee/plugins/', 'php');
125
    foreach ($fileslst as $onefile) {
126
        $onefile = basename($onefile, '.php');
127
        $source->addOption($onefile, $onefile);
128
    }
129
    $sform->addElement($source);
130
131
    /** @var \XoopsModules\Marquee\Utility $utility */
132
    $utility = new Marquee\Utility();
133
134
    $editor = $utility::getWysiwygForm(_AM_MARQUEE_CONTENT, 'content', $contentvalue, 15, 60, 'content_text_hidden');
135
    if ($editor) {
136
        $sform->addElement($editor, false);
137
    }
138
139
    if ('DHTML' !== $utility::getModuleOption('methodtouse')) {
0 ignored issues
show
introduced by
The condition 'DHTML' !== $utility::ge...leOption('methodtouse') is always true.
Loading history...
140
        // $sform->addElement(new \XoopsFormText(_AM_MARQUEE_BGCOLOR, 'bgcolor', 7, 7, $bgcolorvalue), false);
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% 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...
141
        $sform->addElement(new \XoopsFormColorPicker(_AM_MARQUEE_BGCOLOR, 'bgcolor', $bgcolorvalue), false);
0 ignored issues
show
Bug introduced by
The type XoopsFormColorPicker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
142
    }
143
    $sform->addElement(new \XoopsFormText(_AM_MARQUEE_WIDTH, 'width', 4, 4, $widthvalue), false);
0 ignored issues
show
Bug introduced by
The type XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
144
    $sform->addElement(new \XoopsFormText(_AM_MARQUEE_HEIGHT, 'height', 4, 4, $heightvalue), false);
145
    $sform->addElement(new \XoopsFormText(_AM_MARQUEE_SCRAMOUNT, 'scrollamount', 4, 4, $scrollamountvalue), false);
146
    if ('DHTML' !== $utility::getModuleOption('methodtouse')) {
0 ignored issues
show
introduced by
The condition 'DHTML' !== $utility::ge...leOption('methodtouse') is always true.
Loading history...
147
        $sform->addElement(new \XoopsFormText(_AM_MARQUEE_HSPACE, 'hspace', 4, 4, $hspacevalue), false);
148
        $sform->addElement(new \XoopsFormText(_AM_MARQUEE_VSPACE, 'vspace', 4, 4, $vspacevalue), false);
149
    }
150
151
    $sform->addElement(new \XoopsFormText(_AM_MARQUEE_SCRDELAY, 'scrolldelay', 6, 6, $scrolldelayvalue), false);
152
    $direction = new \XoopsFormSelect(_AM_MARQUEE_DIRECTION, 'direction', $directionvalue);
153
    $direction->addOption('0', _AM_MARQUEE_DIRECTION1);
154
    $direction->addOption('1', _AM_MARQUEE_DIRECTION2);
155
    $direction->addOption('2', _AM_MARQUEE_DIRECTION3);
156
    $direction->addOption('3', _AM_MARQUEE_DIRECTION4);
157
    $sform->addElement($direction, true);
158
159
    $behaviour = new \XoopsFormSelect(_AM_MARQUEE_BEHAVIOUR, 'behaviour', $behaviourvalue);
160
    $behaviour->addOption('0', _AM_MARQUEE_BEHAVIOUR1);
161
    if ('DHTML' !== $utility::getModuleOption('methodtouse')) {
0 ignored issues
show
introduced by
The condition 'DHTML' !== $utility::ge...leOption('methodtouse') is always true.
Loading history...
162
        $behaviour->addOption('1', _AM_MARQUEE_BEHAVIOUR2);
163
    }
164
    $behaviour->addOption('2', _AM_MARQUEE_BEHAVIOUR3);
165
    $sform->addElement($behaviour, true);
166
167
    if ('DHTML' !== $utility::getModuleOption('methodtouse')) {
0 ignored issues
show
introduced by
The condition 'DHTML' !== $utility::ge...leOption('methodtouse') is always true.
Loading history...
168
        $align = new \XoopsFormSelect(_AM_MARQUEE_ALIGN, 'align', $alignvalue);
169
        $align->addOption('0', _AM_MARQUEE_ALIGN1);
170
        $align->addOption('1', _AM_MARQUEE_ALIGN2);
171
        $align->addOption('2', _AM_MARQUEE_ALIGN3);
172
        $sform->addElement($align, true);
173
    }
174
175
    $loop = new \XoopsFormSelect(_AM_MARQUEE_LOOP, 'loop', $loopvalue);
176
    $loop->addOption('0', _AM_MARQUEE_INFINITELOOP);
177
    for ($i = 1; $i <= 100; ++$i) {
178
        $loop->addOption($i, $i);
179
    }
180
    if ('DHTML' !== $utility::getModuleOption('methodtouse')) {
0 ignored issues
show
introduced by
The condition 'DHTML' !== $utility::ge...leOption('methodtouse') is always true.
Loading history...
181
        $sform->addElement($loop, true);
182
        $sform->addElement(new \XoopsFormRadioYN(_AM_MARQUEE_STOP, 'stoponmouseover', $stopvalue, _YES, _NO));
0 ignored issues
show
Bug introduced by
The constant _NO was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The constant _YES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormRadioYN was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
183
    }
184
185
    $sform->addElement(new \XoopsFormHidden('op', $Action), false);
0 ignored issues
show
Bug introduced by
The type XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
186
    if (!empty($marqueeid)) {
187
        $sform->addElement(new \XoopsFormHidden('marqueeid', $marqueeid), false);
188
    }
189
    $button_tray = new \XoopsFormElementTray('', '');
0 ignored issues
show
Bug introduced by
The type XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
190
    $submit_btn  = new \XoopsFormButton('', 'submit', $LabelSubmitButton, 'submit');
0 ignored issues
show
Bug introduced by
The type XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
191
    $button_tray->addElement($submit_btn);
192
    $cancel_btn = new \XoopsFormButton('', 'reset', _AM_MARQUEE_RESETBUTTON, 'reset');
193
    $button_tray->addElement($cancel_btn);
194
    $sform->addElement($button_tray);
195
    $sform->display();
196
}
197
198
// ******************************************************************************************************************************************
199
// **** Main ********************************************************************************************************************************
200
// ******************************************************************************************************************************************
201
switch ($op) {
202
    // Verify before to edit an element
203
    case 'verifybeforeedit':
204
        if ('' !== Request::getString('submit', '', 'POST')) {
205
            $marquee = $marqueeHandler->get(Request::getInt('marqueeid', 0, 'POST'));
206
            if (is_object($marquee)) {
207
                $marquee->setVar('marquee_uid', $xoopsUser->getVar('uid'));
208
                $marquee->setVar('marquee_direction', Request::getString('direction', '', 'POST'));
209
                $marquee->setVar('marquee_scrollamount', Request::getInt('scrollamount', 0, 'POST'));
210
                $marquee->setVar('marquee_behaviour', Request::getInt('behaviour', 0, 'POST'));
211
                $marquee->setVar('marquee_bgcolor', Request::getString('bgcolor', '', 'POST'));
212
                $marquee->setVar('marquee_align', Request::getInt('align', 0, 'POST'));
213
                $marquee->setVar('marquee_height', Request::getInt('height', 0, 'POST'));
214
                $marquee->setVar('marquee_width', Request::getString('width', '', 'POST'));
215
                $marquee->setVar('marquee_hspace', Request::getInt('hspace', 0, 'POST'));
216
                $marquee->setVar('marquee_scrolldelay', Request::getInt('scrolldelay', 0, 'POST'));
217
                $marquee->setVar('marquee_stoponmouseover', Request::getInt('stoponmouseover', 0, 'POST'));
218
                $marquee->setVar('marquee_loop', Request::getInt('loop', 0, 'POST'));
219
                $marquee->setVar('marquee_vspace', Request::getInt('vspace', 0, 'POST'));
220
                $marquee->setVar('marquee_content', Request::getText('content', '', 'POST'));
221
                $marquee->setVar('marquee_source', Request::getString('source', '', 'POST'));
222
                if (!$marqueeHandler->insert($marquee)) {
223
                    redirect_header('main.php', 1, _AM_MARQUEE_ERROR_MODIFY_DB);
0 ignored issues
show
Bug introduced by
The function redirect_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

223
                    /** @scrutinizer ignore-call */ 
224
                    redirect_header('main.php', 1, _AM_MARQUEE_ERROR_MODIFY_DB);
Loading history...
224
                }
225
                redirect_header('main.php', 1, _AM_MARQUEE_DBUPDATED);
226
            } else {
227
                redirect_header('main.php', 3, _ERRORS);
0 ignored issues
show
Bug introduced by
The constant _ERRORS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
228
            }
229
        }
230
        break;
231
232
    // Edit an element
233
    case 'edit':
234
        xoops_cp_header();
0 ignored issues
show
Bug introduced by
The function xoops_cp_header was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

234
        /** @scrutinizer ignore-call */ 
235
        xoops_cp_header();
Loading history...
235
        $adminObject->displayNavigation(basename(__FILE__));
236
237
        echo '<br>';
238
        if (isset($_GET['marqueeid'])) {
239
            $marqueeid = Request::getInt('marqueeid', 0, 'GET');
240
            $marquee   = $marqueeHandler->get($marqueeid);
241
            AddEditMarqueeForm(
242
                $marqueeid,
243
                'verifybeforeedit',
244
                _AM_MARQUEE_CONFIG,
245
                $marquee->getVar('marquee_content', 'e'),
246
                $marquee->getVar('marquee_bgcolor', 'e'),
247
                $marquee->getVar('marquee_width', 'e'),
248
                $marquee->getVar('marquee_height', 'e'),
249
                $marquee->getVar('marquee_scrollamount', 'e'),
250
                               $marquee->getVar('marquee_hspace', 'e'),
251
                $marquee->getVar('marquee_vspace', 'e'),
252
                $marquee->getVar('marquee_scrolldelay', 'e'),
253
                $marquee->getVar('marquee_direction', 'e'),
254
                $marquee->getVar('marquee_behaviour', 'e'),
255
                $marquee->getVar('marquee_align', 'e'),
256
                               $marquee->getVar('marquee_loop', 'e'),
257
                $marquee->getVar('marquee_stoponmouseover', 'e'),
258
                _AM_MARQUEE_UPDATE,
259
                $marquee->getVar('marquee_source', 'e')
260
            );
261
        }
262
        break;
263
264
    // Delete an element
265
    case 'delete':
266
        if ('' !== Request::getString('ok', '', 'POST')) {
267
            xoops_cp_header();
268
            $adminObject->displayNavigation(basename(__FILE__));
269
            // echo '<h4>' . _AM_MARQUEE_CONFIG . '</h4>';
270
            xoops_confirm([
0 ignored issues
show
Bug introduced by
The function xoops_confirm was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

270
            /** @scrutinizer ignore-call */ 
271
            xoops_confirm([
Loading history...
271
                              'op'        => 'delete',
272
                              'marqueeid' => Request::getInt('marqueeid', 0, 'GET'),
273
                              'ok'        => 1
274
                          ], 'main.php', _AM_MARQUEE_RUSUREDEL);
275
        } else {
276
            if (empty($_POST['marqueeid'])) {
277
                redirect_header('main.php', 2, _AM_MARQUEE_ERROR_ADD_MARQUEE);
278
            }
279
            $marqueeid = Request::getInt('marqueeid', 0, 'POST');
280
            $marquee   = $marqueeHandler->deleteAll(new \Criteria('marquee_marqueeid', $marqueeid, '='));
0 ignored issues
show
Bug introduced by
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
281
            redirect_header('main.php', 1, _AM_MARQUEE_DBUPDATED);
282
        }
283
        break;
284
285
    // Verify before to add an element
286
    case 'verifytoadd':
287
        if ('' !== Request::getString('submit', '', 'POST')) {
288
            $vres = $marqueeHandler->quickInsert([
289
                                                     'marquee_uid'             => $xoopsUser->getVar('uid'),
290
                                                     'marquee_direction'       => Request::getString('direction', '', 'POST'),
291
                                                     'marquee_scrollamount'    => Request::getInt('scrollamount', 0, 'POST'),
292
                                                     'marquee_behaviour'       => Request::getInt('behaviour', 0, 'POST'),
293
                                                     'marquee_bgcolor'         => Request::getString('bgcolor', '', 'POST'),
294
                                                     'marquee_align'           => Request::getInt('align', 0, 'POST'),
295
                                                     'marquee_height'          => Request::getInt('height', 0, 'POST'),
296
                                                     'marquee_width'           => Request::getString('width', '', 'POST'),
297
                                                     'marquee_hspace'          => Request::getInt('hspace', 0, 'POST'),
298
                                                     'marquee_scrolldelay'     => Request::getInt('scrolldelay', 0, 'POST'),
299
                                                     'marquee_stoponmouseover' => Request::getInt('stoponmouseover', 0, 'POST'),
300
                                                     'marquee_loop'            => Request::getInt('loop', 0, 'POST'),
301
                                                     'marquee_vspace'          => Request::getInt('vspace', 0, 'POST'),
302
                                                     'marquee_content'         => Request::getText('content', '', 'POST'),
303
                                                     'marquee_source'          => Request::getString('source', '', 'POST')
304
                                                 ]);
305
            if (!$vres) {
306
                redirect_header('main.php', 1, _AM_MARQUEE_ERROR_ADD_MARQUEE);
307
            }
308
            redirect_header('main.php', 1, _AM_MARQUEE_ADDED_OK);
309
        }
310
        break;
311
312
    // Display the form to add an element
313
    case 'addmarquee':
314
        xoops_cp_header();
315
        $adminObject->displayNavigation(basename(__FILE__));
316
317
        echo '<br>';
318
        try {
319
            AddEditMarqueeForm(0, 'verifytoadd', _AM_MARQUEE_CONFIG, '', '', '', '', '', 0, 0, '', 0, 0, 0, 0, 0, _AM_MARQUEE_ADDBUTTON, 'fixed');
320
        } catch (\Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
321
        }
322
        break;
323
324
    // Default action, list all elements
325
    case 'default':
326
        xoops_cp_header();
327
        $adminObject->displayNavigation(basename(__FILE__));
328
329
        //        echo '<h4>' . _AM_MARQUEE_CONFIG . "</h4><br>\n";
330
        echo "<table width='100%' border='0' cellspacing='1' class='outer'>\n";
331
        echo "<tr><th align='center'>"
332
             . _AM_MARQUEE_ID
333
             . "</th><th align='center'>"
334
             . _AM_MARQUEE_CONTENT
335
             . "</th><th align='center'>"
336
             . _AM_MARQUEE_BGCOLOR_SHORT
337
             . "</th><th align='center'>"
338
             . _AM_MARQUEE_BEHAVIOUR
339
             . "</th><th align='center'>"
340
             . _AM_MARQUEE_SOURCE
341
             . "</th><th align='center'>"
342
             . _AM_MARQUEE_STOP
343
             . "</th><th align='center'>"
344
             . _AM_MARQUEE_DIRECTION
345
             . "</th><th align='center'>"
346
             . _AM_MARQUEE_ACTION
347
             . "</th></tr>\n";
348
        $marqueeArray = $marqueeHandler->getObjects();
349
        $class        = 'even';
350
        $baseurl      = XOOPS_URL . '/modules/' . $xoopsModule->getVar('dirname') . '/admin/main.php';
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
351
        $tbldirection = [
352
            _AM_MARQUEE_DIRECTION1,
353
            _AM_MARQUEE_DIRECTION2,
354
            _AM_MARQUEE_DIRECTION3,
355
            _AM_MARQUEE_DIRECTION4
356
        ];
357
        $tblbehaviour = [_AM_MARQUEE_BEHAVIOUR1, _AM_MARQUEE_BEHAVIOUR2, _AM_MARQUEE_BEHAVIOUR3];
358
        if (count($marqueeArray) > 0) {
359
            /** @var Marquee\Marqueex $marquee */
360
            foreach ($marqueeArray as $marquee) {
361
                //              $action_edit="<a href='".$baseurl."?op=edit&marqueeid=".$marquee->getVar('marquee_marqueeid')."'>"._AM_MARQUEE_EDIT."</a>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
362
                //              $action_delete="<a href='".$baseurl."?op=delete&marqueeid=".$marquee->getVar('marquee_marqueeid')."'>"._AM_MARQUEE_DELETE."</a>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% 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...
363
364
                $action_edit   = '<a href=' . $baseurl . '?op=edit&marqueeid=' . $marquee->getVar('marquee_marqueeid') . '><img src=' . $pathIcon16 . '/edit.png title=' . _AM_MARQUEE_EDIT . '></a>';
365
                $action_delete = '<a href=' . $baseurl . '?op=delete&marqueeid=' . $marquee->getVar('marquee_marqueeid') . '><img src=' . $pathIcon16 . '/delete.png title=' . _AM_MARQUEE_DELETE . '></a>';
366
367
                $bgcolorvalue = $marquee->getVar('marquee_bgcolor');
368
                $direction    = $tbldirection[$marquee->getVar('marquee_direction')];
369
                $behaviour    = $tblbehaviour[$marquee->getVar('marquee_behaviour')];
370
                $stop         = _YES;
0 ignored issues
show
Bug introduced by
The constant _YES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
371
                if (0 == $marquee->getVar('marquee_stoponmouseover')) {
372
                    $stop = _NO;
0 ignored issues
show
Bug introduced by
The constant _NO was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
373
                }
374
                $source = $marquee->getVar('marquee_source');
375
                if ('fixed' === $marquee->getVar('marquee_source')) {
376
                    $source = _AM_MARQUEE_SOURCE_FIXED;
377
                }
378
                echo "<tr class='"
379
                     . $class
380
                     . "'><td align='center'>"
381
                     . $marquee->getVar('marquee_marqueeid')
382
                     . "</td><td align='left'>"
383
                     . Marquee\Utility::truncateHtml($marquee->getVar('marquee_content'), 80, '...', false, true)
384
                     . "</td><td align='center'>"
385
                     . "<div style='height:12px; width:12px; background-color:"
386
                     . $bgcolorvalue
387
                     . "; border:1px solid black;float:left; margin-right:5px;'></div>"
388
                     . $bgcolorvalue
389
390
                     . "</td><td align='center'>"
391
                     . $behaviour
392
                     . "</td><td align='center'>"
393
                     . $source
394
                     . "</td><td align='center'>"
395
                     . $stop
396
                     . "</td><td align='center'>"
397
                     . $direction
398
                     . "</td><td align='center'>"
399
                     . $action_edit
400
                     . '&nbsp;&nbsp;'
401
                     . $action_delete
402
                     . "</td></tr>\n";
403
                $class = ('even' === $class) ? 'odd' : 'even';
404
            }
405
        }
406
407
        //      echo "<tr class='".$class."'><td colspan='7' align='center'><form name='faddmarquee' method='post' action='main.php'><input type='hidden' name='op' value='addmarquee'><input type='submit' name='submit' value='"._AM_MARQUEE_ADDMARQUEE."'></td></tr>";
0 ignored issues
show
Unused Code Comprehensibility introduced by
47% 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...
408
        $adminObject->addItemButton(_AM_MARQUEE_ADDMARQUEE, 'main.php?op=addmarquee', 'add', '');
409
        $adminObject->displayButton('left', '');
410
        echo '</table>';
411
        break;
412
}
413
414
require_once __DIR__ . '/admin_footer.php';
415
//xoops_cp_footer();
416