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

TemplatesUserPages::renderFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 12
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: TemplatesUserPages.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class TemplatesUserPages.
27
 */
28
class TemplatesUserPages 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 TemplatesUserPages
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
    *  @param string $filename
71
    */
72
    /**
73
     * @param $module
74
     * @param $table
75
     */
76
    public function write($module, $table)
77
    {
78
        $this->setModule($module);
79
        $this->setTable($table);
80
    }
81
82
    /*
83
    *  @private function getTemplatesUserPagesHeader
84
    *  @param string $moduleDirname
85
    */
86
    /**
87
     * @param $moduleDirname
88
     *
89
     * @return string
90
     */
91
    private function getTemplatesUserPagesHeader($moduleDirname)
92
    {
93
        return $this->htmlcode->getSmartyIncludeFile($moduleDirname, 'header').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...
94
    }
95
96
    /*
97
    *  @private function getTemplatesUserPagesTable
98
    *  @param string $moduleDirname
99
    *  @param string $tableName
100
    *  @param string $fields
0 ignored issues
show
Bug introduced by
There is no parameter named $fields. 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...
101
    *  @param string $language
102
    *  @return string
103
    */
104
    private function getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSolename, $language)
105
    {
106
        $tbody = $this->getTemplatesUserPagesTableThead($tableName, $language);
107
        $tbody .= $this->getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSolename, $language);
108
        $tbody .= $this->getTemplatesUserPagesTableTfoot();
109
        $single = $this->htmlcode->getSmartySingleVar('table_type');
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...
110
111
        return $this->htmlcode->getHtmlTable($tbody, 'table table-'.$single).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...
112
    }
113
114
    /*
115
    *  @private function getTemplatesUserPagesThead
116
    *  @param string $language
117
    */
118
    /**
119
     * @param $language
120
     *
121
     * @return string
122
     */
123
    private function getTemplatesUserPagesTableThead($tableName, $language)
124
    {
125
        $stuTableName = strtoupper($tableName);
126
        $single = $this->htmlcode->getSmartySingleVar('divideby');
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...
127
        $lang = $this->htmlcode->getSmartyConst($language, $stuTableName.'_TITLE');
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...
128
        $th = $this->htmlcode->getHtmlTableHead($lang, '', $single).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableHead 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...
129
        $tr = $this->htmlcode->getHtmlTableRow($th, 'head').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableRow 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...
130
131
        return $this->htmlcode->getHtmlTableThead($tr).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableThead 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...
132
    }
133
134
    /*
135
    *  @private function getTemplatesUserPagesTbody
136
    *  @param string $moduleDirname
137
    *  @param string $table
138
    *  @param string $language
139
    */
140
    /**
141
     * @param $moduleDirname
142
     * @param $table
143
     * @param $language
144
     *
145
     * @return string
146
     */
147
    private function getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSolename, $language)
0 ignored issues
show
Unused Code introduced by
The parameter $language is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
148
    {
149
        $single = $this->htmlcode->getSmartySingleVar('panel_type');
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...
150
        $include = $this->htmlcode->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSolename);
0 ignored issues
show
Bug introduced by
The method getSmartyIncludeFileListForeach 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...
151
        $div = $this->htmlcode->getHtmlDiv($include, 'panel panel-'.$single);
0 ignored issues
show
Bug introduced by
The method getHtmlDiv 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...
152
        $cont = $this->htmlcode->getHtmlTableData($div).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...
153
        $html = $this->htmlcode->getHtmlEmpty('</tr><tr>').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlEmpty 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
        $cont   .= $this->htmlcode->getSmartyConditions($tableSolename.'.count', ' is div by ', '$divideby', $html).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...
155
        $foreach = $this->htmlcode->getSmartyForeach($tableSolename, $tableName, $cont).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...
156
        $tr = $this->htmlcode->getHtmlTableRow($foreach).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableRow 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...
157
158
        return $this->htmlcode->getHtmlTableTbody($tr).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableTbody 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...
159
    }
160
161
    /*
162
    *  @private function getTemplatesUserPagesTfoot
163
    *  @param string $moduleDirname
164
    *  @param string $table
165
    *  @param string $language
166
    */
167
    /**
168
     * @param $moduleDirname
169
     * @param $table
170
     * @param $language
171
     *
172
     * @return string
173
     */
174
    private function getTemplatesUserPagesTableTfoot()
175
    {
176
        $td = $this->htmlcode->getHtmlTableData('&nbsp;').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...
177
        $tr = $this->htmlcode->getHtmlTableRow($td).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableRow 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...
178
179
        return $this->htmlcode->getHtmlTableTfoot($tr).PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlTableTfoot 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...
180
    }
181
182
    /*
183
    *  @private function getTemplatesUserPages
184
    *  @param string $language
185
    */
186
    /**
187
     * @param $language
188
     *
189
     * @return string
190
     */
191
    private function getTemplatesUserPages($moduleDirname, $tableName, $tableSolename, $language)
192
    {
193
        $table = $this->getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSolename, $language).PHP_EOL;
194
        $div = $this->htmlcode->getHtmlDiv($table, 'table-responsive').PHP_EOL;
0 ignored issues
show
Bug introduced by
The method getHtmlDiv 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, ' gt ', '0', $div, false, true).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 getTemplatesUserPagesFooter
201
    *  @param string $moduleDirname
202
    */
203
    /**
204
     * @param $moduleDirname
205
     *
206
     * @return string
207
     */
208
    private function getTemplatesUserPagesFooter($moduleDirname)
209
    {
210
        return $this->htmlcode->getSmartyIncludeFile($moduleDirname, 'footer');
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...
211
    }
212
213
    /*
214
    *  @public function renderFile
215
    *  @param string $filename
216
    */
217
    /**
218
     * @param $filename
219
     *
220
     * @return bool|string
221
     */
222
    public function renderFile($filename)
223
    {
224
        $module = $this->getModule();
225
        $table = $this->getTable();
226
        $moduleDirname = $module->getVar('mod_dirname');
227
        $tableName = $table->getVar('table_name');
228
        $tableSolename = $table->getVar('table_solename');
229
        $language = $this->getLanguage($moduleDirname, 'MA');
230
        $content = $this->getTemplatesUserPagesHeader($moduleDirname);
231
        $content .= $this->getTemplatesUserPages($moduleDirname, $tableName, $tableSolename, $language);
232
        $content .= $this->getTemplatesUserPagesFooter($moduleDirname);
233
        //
234
        $this->tdmcfile->create($moduleDirname, 'templates', $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...
235
236
        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...
237
    }
238
}
239