Passed
Push — master ( 320868...856304 )
by Goffy
03:48
created

XoopsConfirm::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Common;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
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
15
/**
16
 * My Module module for xoops
17
 *
18
 * @copyright     2020 XOOPS Project (https://xooops.org)
19
 * @license        GPL 2.0 or later
20
 * @package        Modulebuilder
21
 * @since          1.0
22
 * @min_xoops      2.5.9
23
 * @author         Goffy - Email:<[email protected]> - Website:<http://xoops.org>
24
 */
25
26
use XoopsModules\Modulebuilder;
27
28
defined('XOOPS_ROOT_PATH') || die('Restricted access');
29
30
/**
31
 * Class Object XoopsConfirm
32
 */
33
class XoopsConfirm extends \XoopsObject
34
{
35
    public $hiddens  = [];
36
    public $action   = '';
37
    public $title    = '';
38
    public $label    = '';
39
    public $object   = '';
40
41
    /**
42
     * @public function constructor class
43
     *
44
     * @param null
45
     */
46
    public function __construct()
47
    {
48
    }
49
50
    /**
51
     * @static function &getInstance
52
     *
53
     * @param null
54
     */
55
    public static function getInstance()
56
    {
57
        static $instance = false;
58
        if (!$instance) {
59
            $instance = new self();
60
        }
61
    }
62
63
64
    /**
65
     * @public function getXoopsConfirm
66
     * @param bool $action
67
     * @return \XoopsThemeForm
68
     */
69
    public function getFormXoopsConfirm()
70
    {
71
        //in order to be accessable from user and admin area this should be place in language common.php
72
        define('CO__MODULEBUILDER_DELETE_CONFIRM', 'Confirm delete');
73
        define('CO__MODULEBUILDER_DELETE_LABEL', 'Do you really want to delete:');
74
75
        // Get Theme Form
76
        if ('' === $this->action) {
77
            $this->action = \Xmf\Request::getString('REQUEST_URI', '', 'SERVER');
78
        }
79
        if ('' === $this->title) {
80
            $this->title = CO__MODULEBUILDER_DELETE_CONFIRM;
81
        }
82
        if ('' === $this->label) {
83
84
            $this->label = CO__MODULEBUILDER_DELETE_LABEL;
85
        }
86
87
        xoops_load('XoopsFormLoader');
88
        $form = new \XoopsThemeForm($this->title, 'form', $this->action, 'post', true);
89
        $form->setExtra('enctype="multipart/form-data"');
90
        $form->addElement(new \XoopsFormLabel($this->label, $this->object));
91
        //hiddens
92
        foreach ($this->hiddens as $key => $value) {
93
            $form->addElement(new \XoopsFormHidden($key, $value));
94
        }
95
        $form->addElement(new \XoopsFormHidden('ok', 1));
96
        $buttonTray = new \XoopsFormElementTray('');
97
        $buttonTray->addElement(new \XoopsFormButton('', 'confirm_submit', _YES, 'submit', false));
0 ignored issues
show
Unused Code introduced by
The call to XoopsFormButton::__construct() has too many arguments starting with false. ( Ignorable by Annotation )

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

97
        $buttonTray->addElement(/** @scrutinizer ignore-call */ new \XoopsFormButton('', 'confirm_submit', _YES, 'submit', false));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
98
        $buttonBack = new \XoopsFormButton('', 'confirm_back', _NO, 'button', false);
99
        $buttonBack->setExtra('onclick="history.go(-1);return true;"');
100
        $buttonTray->addElement($buttonBack);
101
        $form->addElement($buttonTray);
102
        return $form;
103
    }
104
}