Passed
Push — master ( 0f0f99...fb91d6 )
by Michael
17s
created

TemplatesAdminPages::renderFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.4285
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: TemplatesAdminPages.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TemplatesAdminPages.
27
 */
28
class TemplatesAdminPages extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
29
{
30
    /*
31
    * @var string
32
    */
33
    private $tdmcfile = null;
34
35
    /*
36
    *  @public function constructor
37
    *  @param null
38
    */
39
    /**
40
     *
41
     */
42
    public function __construct()
43
    {
44
        parent::__construct();
45
        $this->tdmcfile = TDMCreateFile::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateFile::getInstance() of type object<TDMCreateFile> is incompatible with the declared type string of property $tdmcfile.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
46
        $this->htmlcode = TDMCreateHtmlSmartyCodes::getInstance();
0 ignored issues
show
Documentation Bug introduced by
It seems like \TDMCreateHtmlSmartyCodes::getInstance() of type object<TDMCreateHtmlSmartyCodes> is incompatible with the declared type string of property $htmlcode.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
47
    }
48
49
    /*
50
    *  @static function &getInstance
51
    *  @param null
52
    */
53
    /**
54
     * @return TemplatesAdminPages
55
     */
56
    public static function &getInstance()
57
    {
58
        static $instance = false;
59
        if (!$instance) {
60
            $instance = new self();
61
        }
62
63
        return $instance;
64
    }
65
66
    /*
67
    *  @public function write
68
    *  @param string $module
69
    *  @param string $table
70
    */
71
    public function write($module, $table)
72
    {
73
        $this->setModule($module);
74
        $this->setTable($table);
75
    }
76
77
    /*
78
    *  @private function getTemplatesAdminPagesHeader
79
    *  @param string $moduleDirname
80
    *  @return string
81
    */
82
    private function getTemplatesAdminPagesHeader($moduleDirname)
83
    {
84
        $ret = $this->htmlcode->getHtmlComment('Header').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlComment cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
85
        $ret .= $this->htmlcode->getSmartyIncludeFile($moduleDirname, 'header', true).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyIncludeFile cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
86
87
        return $ret;
88
    }
89
90
    /*
91
    *  @private function getTemplatesAdminPagesTableThead
92
    *  @param string $moduleDirname
0 ignored issues
show
Bug introduced by
There is no parameter named $moduleDirname. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
93
    *  @param string $tableName
0 ignored issues
show
Bug introduced by
There is no parameter named $tableName. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
94
    *  @param string $fields
95
    *  @param string $language
96
    *  @return string
97
    */
98
    private function getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language)
99
    {
100
        $th = '';
101
        $langHeadId = strtoupper($tableSoleName).'_ID';
102
        if (1 == $tableAutoincrement) {
103
            $lang = $this->htmlcode->getSmartyConst($language, $langHeadId);
0 ignored issues
show
Bug introduced by
The method getSmartyConst cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
104
            $th  .= $this->htmlcode->getHtmlTag('th', array('class' => 'center'), $lang).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
105
        }
106
        foreach (array_keys($fields) as $f) {
107
            $fieldName = $fields[$f]->getVar('field_name');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
108
            $rpFieldName = $this->tdmcfile->getRightString($fieldName);
0 ignored issues
show
Bug introduced by
The method getRightString cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
109
            $langFieldName = strtoupper($tableSoleName).'_'.strtoupper($rpFieldName);
110
            if (1 == $fields[$f]->getVar('field_inlist')) {
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
111
                $lang = $this->htmlcode->getSmartyConst($language, $langFieldName);
0 ignored issues
show
Bug introduced by
The method getSmartyConst cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
112
                $th  .= $this->htmlcode->getHtmlTag('th', array('class' => 'center'), $lang).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
113
            }
114
        }
115
116
        $lang = $this->htmlcode->getSmartyConst($language, 'FORM_ACTION');
0 ignored issues
show
Bug introduced by
The method getSmartyConst cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
117
        $th  .= $this->htmlcode->getHtmlTag('th', array('class' => 'center width5'), $lang).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
118
        $tr = $this->htmlcode->getHtmlTag('tr', array('class' => 'head'), $th).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
119
        $ret = $this->htmlcode->getHtmlTag('thead', array(), $tr).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
120
121
        return $ret;
122
    }
123
124
    /*
125
    *  @private function getTemplatesAdminPagesTableTBody
126
    *  @param string $moduleDirname
127
    *  @param string $tableName
128
    *  @param string $fields
129
    *  @param string $language
0 ignored issues
show
Bug introduced by
There is no parameter named $language. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
130
    *  @return string
131
    */
132
    private function getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields)
133
    {
134
        $td = '';
135
        if (1 == $tableAutoincrement) {
136
            $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, 'id');
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
137
            $td    .= $this->htmlcode->getHtmlTableData($double, 'center').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableData cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
138
        }
139
        foreach (array_keys($fields) as $f) {
140
            $fieldName = $fields[$f]->getVar('field_name');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
141
            $fieldElement = $fields[$f]->getVar('field_element');
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
142
            $rpFieldName = $this->tdmcfile->getRightString($fieldName);
0 ignored issues
show
Bug introduced by
The method getRightString cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
143
            if (0 == $f) {
144
                $fieldId = $fieldName;
145
            }
146
            if (1 == $fields[$f]->getVar('field_inlist')) {
0 ignored issues
show
Bug introduced by
The method getVar cannot be called on $fields[$f] (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
147
                switch ($fieldElement) {
148
                    case 9:
149
                        // This is to be reviewed, as it was initially to style = "backgroung-color: #"
150
                        // Now with HTML5 is not supported inline style in the parameters of the HTML tag
151
                        // Old code was <span style="background-color: #<{\$list.{$rpFieldName}}>;">...
152
                        $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, $rpFieldName);
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
153
                        $span = $this->htmlcode->getHtmlTag('span', array(), $double);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
154
                        $td .= $this->htmlcode->getHtmlTag('td', array('class' => 'center'), $span).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
155
                        /*$ret .= <<<EOT
156
                    <td class="center"><span style="background-color: #<{\$list.{$rpFieldName}}>;">&nbsp;&nbsp;&nbsp;&nbsp;</span></td>\n
157
EOT;*/
158
                        break;
159
                    case 10:
160
                        $src = $this->htmlcode->getSmartyNoSimbol('xoModuleIcons32');
0 ignored issues
show
Bug introduced by
The method getSmartyNoSimbol cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
161
                        $src .= $this->htmlcode->getSmartyDoubleVar($tableSoleName, $rpFieldName);
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
162
                        $img = $this->htmlcode->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', false);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
163
                        $td  .= $this->htmlcode->getHtmlTag('td', array('class' => 'center'), $img).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
164
                        break;
165
                    case 13:
166
                        $single = $this->htmlcode->getSmartySingleVar($moduleDirname.'_upload_url');
0 ignored issues
show
Bug introduced by
The method getSmartySingleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
167
                        $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, $rpFieldName);
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
168
                        $img = $this->htmlcode->getHtmlTag('img', array('src' => $single."/images/{$tableName}/".$double, 'alt' => $tableName, 'style' => 'max-width:100px'), '', false);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
169
                        $td    .= $this->htmlcode->getHtmlTag('td', array('class' => 'center'), $img).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
170
                        break;
171
                    default:
172
                        if (0 != $f) {
173
                            $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, $rpFieldName);
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
174
                            $td    .= $this->htmlcode->getHtmlTag('td', array('class' => 'center'), $double).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
175
                        }
176
                        break;
177
                }
178
            }
179
        }
180
        $lang = $this->htmlcode->getSmartyConst('', '_EDIT');
0 ignored issues
show
Bug introduced by
The method getSmartyConst cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
181
        $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, 'id');
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
182
        $src = $this->htmlcode->getSmartyNoSimbol('xoModuleIcons16 edit.png');
0 ignored issues
show
Bug introduced by
The method getSmartyNoSimbol cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
183
        $img = $this->htmlcode->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', false);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
184
        $anchor = $this->htmlcode->getHtmlTag('a', array('href' => $tableName.".php?op=edit&amp;{$fieldId}=".$double, 'title' => $lang), $img).PHP_EOL;
0 ignored issues
show
Bug introduced by
The variable $fieldId does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
185
        $lang = $this->htmlcode->getSmartyConst('', '_DELETE');
0 ignored issues
show
Bug introduced by
The method getSmartyConst cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
186
        $double = $this->htmlcode->getSmartyDoubleVar($tableSoleName, 'id');
0 ignored issues
show
Bug introduced by
The method getSmartyDoubleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
187
        $src = $this->htmlcode->getSmartyNoSimbol('xoModuleIcons16 delete.png');
0 ignored issues
show
Bug introduced by
The method getSmartyNoSimbol cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
188
        $img = $this->htmlcode->getHtmlTag('img', array('src' => $src, 'alt' => $tableName), '', false);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
189
        $anchor .= $this->htmlcode->getHtmlTag('a', array('href' => $tableName.".php?op=delete&amp;{$fieldId}=".$double, 'title' => $lang), $img).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
190
        $td     .= $this->htmlcode->getHtmlTag('td', array('class' => 'center  width5'), "\n".$anchor).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
191
        $cycle = $this->htmlcode->getSmartyNoSimbol('cycle values="odd, even"');
0 ignored issues
show
Bug introduced by
The method getSmartyNoSimbol cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
192
        $tr = $this->htmlcode->getHtmlTag('tr', array('class' => $cycle), $td).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
193
        $foreach = $this->htmlcode->getSmartyForeach($tableSoleName, $tableName.'_list', $tr).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyForeach cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
194
        $tbody = $this->htmlcode->getHtmlTag('tbody', array(), $foreach).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
195
196
        return $this->htmlcode->getSmartyConditions($tableName.'_count', '', '', $tbody).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
197
    }
198
199
    /*
200
    *  @private function getTemplatesAdminPagesTable
201
    *  @param string $moduleDirname
202
    *  @param string $tableName
203
    *  @param string $fields
204
    *  @param string $language
205
    *  @return string
206
    */
207
    private function getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language)
208
    {
209
        $tbody = $this->getTemplatesAdminPagesTableThead($tableSoleName, $tableAutoincrement, $fields, $language);
210
        $tbody .= $this->getTemplatesAdminPagesTableTBody($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields);
211
212
        return $this->htmlcode->getHtmlTable($tbody, 'table table-bordered').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTable cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
213
    }
214
215
    /*
216
    *  @private function getTemplatesAdminPages
217
    *  @param string $moduleDirname
218
    *  @param string $tableName
219
    *  @param string $fields
220
    *  @param string $language
221
    *  @return string
222
    */
223
    private function getTemplatesAdminPages($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language)
224
    {
225
        $htmlTable = $this->getTemplatesAdminPagesTable($moduleDirname, $tableName, $tableSoleName, $tableAutoincrement, $fields, $language);
226
        $htmlTable .= $this->htmlcode->getHtmlTag('div', array('class' => 'clear'), '&nbsp;').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
227
        $single = $this->htmlcode->getSmartySingleVar('pagenav');
0 ignored issues
show
Bug introduced by
The method getSmartySingleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
228
        $div = $this->htmlcode->getHtmlTag('div', array('class' => 'xo-pagenav floatright'), $single);
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
229
        $div       .= $this->htmlcode->getHtmlTag('div', array('class' => 'clear spacer'), '').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
230
        $htmlTable .= $this->htmlcode->getSmartyConditions('pagenav', '', '', $div).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
231
        $ifList = $this->htmlcode->getSmartyConditions($tableName.'_list', '', '', $htmlTable).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
232
        $single = $this->htmlcode->getSmartySingleVar('form');
0 ignored issues
show
Bug introduced by
The method getSmartySingleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
233
        $divComm = $this->htmlcode->getHtmlComment('Display navigation').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlComment cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
Unused Code introduced by
$divComm is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
234
        //$divComm .= $this->htmlcode->getHtmlTag('div', array('class' => 'errorMsg'), $single).PHP_EOL;
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% 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...
235
        $ifList .= $this->htmlcode->getSmartyConditions('form', '', '', $single).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
236
        $single = $this->htmlcode->getSmartySingleVar('error');
0 ignored issues
show
Bug introduced by
The method getSmartySingleVar cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
237
        $strong = $this->htmlcode->getHtmlTag('strong', array(), $single).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
238
        $div = $this->htmlcode->getHtmlTag('div', array('class' => 'errorMsg'), $strong).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
239
        $ifList .= $this->htmlcode->getSmartyConditions('error', '', '', $div).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getSmartyConditions cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
240
241
        return $ifList;
242
    }
243
244
    /*
245
    *  @private function getTemplatesAdminPagesFooter
246
    *  @param string $moduleDirname
247
    *  @return string
248
    */
249
    private function getTemplatesAdminPagesFooter($moduleDirname)
250
    {
251
        $ret = $this->htmlcode->getHtmlTag('br', array(), '', false).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTag cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
252
        $ret .= $this->htmlcode->getHtmlComment('Footer').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlComment cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
253
        $ret .= $this->htmlcode->getSmartyIncludeFile($moduleDirname, 'footer', true);
0 ignored issues
show
Bug introduced by
The method getSmartyIncludeFile cannot be called on $this->htmlcode (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
254
255
        return $ret;
256
    }
257
258
    /*
259
    *  @public function render
260
    *  @param $filename
261
    *  @return bool|string
262
    */
263
    public function renderFile($filename)
264
    {
265
        $module = $this->getModule();
266
        $table = $this->getTable();
267
        $moduleDirname = $module->getVar('mod_dirname');
268
        $language = $this->getLanguage($moduleDirname, 'AM');
269
        $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'), 'field_order');
270
        $content = $this->getTemplatesAdminPagesHeader($moduleDirname);
271
        $content .= $this->getTemplatesAdminPages($moduleDirname, $table->getVar('table_name'), $table->getVar('table_solename'), $table->getVar('table_autoincrement'), $fields, $language);
272
        $content .= $this->getTemplatesAdminPagesFooter($moduleDirname);
273
        //
274
        $this->tdmcfile->create($moduleDirname, 'templates/admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
0 ignored issues
show
Bug introduced by
The method create cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
275
276
        return $this->tdmcfile->renderFile();
0 ignored issues
show
Bug introduced by
The method renderFile cannot be called on $this->tdmcfile (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
277
    }
278
}
279