ThemeForm   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 51
dl 0
loc 81
rs 10
c 0
b 0
f 0
ccs 0
cts 50
cp 0
wmc 11

2 Methods

Rating   Name   Duplication   Size   Complexity  
B render() 0 51 8
A insertBreak() 0 12 3
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
12
namespace Xoops\Form;
13
14
/**
15
 * ThemeForm - Form that will output as a theme-enabled HTML table
16
 *
17
 * Also adds JavaScript to validate required fields
18
 *
19
 * @category  Xoops\Form\ThemeForm
20
 * @package   Xoops\Form
21
 * @author    Xoops Team
22
 * @copyright 2001-2016 XOOPS Project (http://xoops.org)
23
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
24
 * @link      http://xoops.org
25
 */
26
class ThemeForm extends Form
27
{
28
    /**
29
     * Insert an empty row in the table to serve as a separator.
30
     *
31
     * @param string $extra HTML to be displayed in the empty row.
32
     * @param string $class CSS class name for <td> tag
33
     *
34
     * @return void
35
     */
36
    public function insertBreak($extra = '', $class = '')
37
    {
38
        $class = ($class != '' ? " class=\"" . $class . "\"" : " class=\"break\"");
39
        // Fix for $extra tag not showing
40
        if ($extra) {
41
            $value = '<div' . $class . '>' . $extra . '</div>';
42
            $ele = new Raw($value);
43
            $this->addElement($ele);
44
        } else {
45
            $value = '<div' . $class . '>&nbsp;</div>';
46
            $ele = new Raw($value);
47
            $this->addElement($ele);
48
        }
49
    }
50
51
    /**
52
     * create HTML to output the form as a theme-enabled table with validation.
53
     *
54
     * @return string rendered form
55
     */
56
    public function render()
57
    {
58
        $xoops = \Xoops::getInstance();
59
        $xoops->theme()->addStylesheet('media/xoops/css/form.css');
60
        switch ($this->getDisplay()) {
61
            case '':
62
            case 'horizontal':
63
            default:
64
                $xoops->tpl()->assign('type', 'horizontal');
65
                break;
66
67
            case 'vertical':
68
                $xoops->tpl()->assign('type', 'vertical');
69
                break;
70
71
            case 'inline':
72
                $xoops->tpl()->assign('type', 'inline');
73
                break;
74
75
            case 'personalized':
76
                $xoops->tpl()->assign('type', 'personalized');
77
                break;
78
        }
79
        $xoops->tpl()->assign('title', $this->getTitle());
80
        $xoops->tpl()->assign('name', $this->getName());
81
        $xoops->tpl()->assign('action', $this->getAction());
82
        $xoops->tpl()->assign('method', $this->getMethod());
83
        $xoops->tpl()->assign('extra', $this->getExtra());
84
        $hidden = '';
85
        foreach ($this->getElements() as $ele) {
86
            /* @var $ele Element */
87
            if (!$ele->isHidden()) {
88
                $input['name'] = $ele->getName();
89
                $input['caption'] = $ele->getCaption();
90
                $input['description'] = $ele->getDescription();
91
                $input['ele'] = $ele->render();
92
                $input['required'] = $ele->isRequired();
93
                $input['pattern_description'] = $ele->getPatternDescription();
94
                $input['datalist'] = $ele->renderDatalist();
95
                $xoops->tpl()->appendByRef('xo_input', $input);
0 ignored issues
show
Bug introduced by
The method appendByRef() does not exist on Xoops\Core\XoopsTpl. Did you maybe mean append()? ( Ignorable by Annotation )

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

95
                $xoops->tpl()->/** @scrutinizer ignore-call */ appendByRef('xo_input', $input);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
Comprehensibility Best Practice introduced by
The variable $input seems to be defined later in this foreach loop on line 88. Are you sure it is defined here?
Loading history...
96
                unset($input);
97
            } else {
98
                $hidden .= $ele->render(). "\n";
99
            }
100
101
        }
102
        $xoops->tpl()->assign('hidden', $hidden);
103
        $xoops->tpl()->assign('validationJS', $this->renderValidationJS(true));
104
        $ret = $xoops->tpl()->fetch('module:system/system_form.tpl');
105
        $xoops->tpl()->clearAssign('xo_input');
0 ignored issues
show
Bug introduced by
The method clearAssign() does not exist on Xoops\Core\XoopsTpl. Did you maybe mean clear_assign()? ( Ignorable by Annotation )

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

105
        $xoops->tpl()->/** @scrutinizer ignore-call */ clearAssign('xo_input');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
106
        return $ret;
107
108
    }
109
}
110