Passed
Push — master ( a796fe...97ee4c )
by Goffy
03:08
created

ThemeForm::render()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 4
eloc 15
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 22
rs 9.7666
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Form;
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
 * modulebuilder module.
16
 *
17
 * @copyright       XOOPS Project (https://xoops.org)
18
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
19
 *
20
 * @since           2.5.5
21
 *
22
 * @author          Txmod Xoops <[email protected]>
23
 *
24
 */
25
defined('XOOPS_ROOT_PATH') || die('Restricted access');
26
27
\XoopsLoad::load('XoopsFormLoader');
28
29
/**
30
 * Form that will output as a theme-enabled HTML table.
31
 *
32
 * Also adds JavaScript to validate required fields
33
 */
34
class ThemeForm extends \XoopsForm
35
{
36
    /**
37
     * create HTML to output the form as a theme-enabled table with validation.
38
     *
39
     * YOU SHOULD AVOID TO USE THE FOLLOWING Nocolspan METHOD, IT WILL BE REMOVED
40
     *
41
     * To use the noColspan simply use the following example:
42
     *
43
     * $colspan = new \XoopsFormDhtmlTextArea( '', 'key', $value, '100%', '100%' );
44
     * $colspan->setNocolspan();
45
     * $form->addElement( $colspan );
46
     *
47
     * @return string
48
     */
49
    public function render()
50
    {
51
        $ele_name = $this->getName();
52
        //$ret = ($this->getTitle() ? '<div class=" center head ">' . $this->getTitle() . '</div>' : '');
53
        $ret    = NWLINE . '<form name="' . $ele_name . '" id="' . $ele_name . '" action="' . $this->getAction() . '" method="' . $this->getMethod() . '" onsubmit="return xoopsFormValidate_' . $ele_name . '();"' . $this->getExtra() . '>' . NWLINE;
54
        $hidden = '';
55
        $class  = 'even';
0 ignored issues
show
Unused Code introduced by
The assignment to $class is dead and can be removed.
Loading history...
56
        foreach ($this->getElements() as $ele) {
57
            if (!is_object($ele)) {
58
                $ret .= $ele;
59
            } else {
60
                if (!$ele->isHidden()) {
61
                    $ret .= $ele->render();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $ele->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
62
                } else {
63
                    $hidden .= $ele->render();
0 ignored issues
show
Bug introduced by
Are you sure the usage of $ele->render() targeting XoopsFormElement::render() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
64
                }
65
            }
66
        }
67
        $ret .= NWLINE . ' ' . $hidden . NWLINE . '</form>';
68
        $ret .= $this->renderValidationJS(true);
69
70
        return $ret;
71
    }
72
}
73