Completed
Pull Request — master (#65)
by Gino
04:16
created

LanguageModinfo   A

Complexity

Total Complexity 33

Size/Duplication

Total Lines 412
Duplicated Lines 1.94 %

Coupling/Cohesion

Components 2
Dependencies 1
Metric Value
wmc 33
lcom 2
cbo 1
dl 8
loc 412
rs 9.3999

14 Methods

Rating   Name   Duplication   Size   Complexity  
A getLanguageSubmenu() 0 19 4
A __construct() 0 5 1
A getInstance() 0 9 2
A write() 0 7 1
A getLanguageMain() 0 8 1
A getLanguageMenu() 0 21 3
A getLanguageAdmin() 0 8 1
B getLanguageBlocks() 0 32 4
A getLanguageUser() 8 8 1
B getLanguageConfig() 0 50 6
B getLanguageNotifications() 0 44 1
A getLanguagePermissionsGroups() 0 10 1
A getLanguageFooter() 0 6 1
B render() 0 36 6

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 28 and the first side effect is on line 24.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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: LanguageModinfo.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
/**
26
 * Class LanguageModinfo.
27
 */
28
class LanguageModinfo extends LanguageDefines
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
    *  @public function constructor
32
    *  @param null
33
    */
34
    /**
35
     *
36
     */
37
    public function __construct()
38
    {
39
        parent::__construct();
40
        $this->defines = LanguageDefines::getInstance();
41
    }
42
43
    /*
44
    *  @static function &getInstance
45
    *  @param null
46
    */
47
    /**
48
     * @return LanguageModinfo
49
     */
50
    public static function &getInstance()
51
    {
52
        static $instance = false;
53
        if (!$instance) {
54
            $instance = new self();
55
        }
56
57
        return $instance;
58
    }
59
60
    /*
61
    *  @public function write
62
    *  @param string $module
63
    *  @param mixed $table
64
    *  @param mixed $tables
65
    *  @param string $filename
66
    */
67
    /**
68
     * @param $module
69
     * @param $table
70
     * @param $tables
71
     * @param $filename
72
     */
73
    public function write($module, $table, $tables, $filename)
74
    {
75
        $this->setModule($module);
76
        $this->setTable($table);
77
        $this->setTables($tables);
78
        $this->setFileName($filename);
79
    }
80
81
    /*
82
    *  @private function getLanguageMain
83
    *  @param string $language
84
    *  @param string $module
85
    */
86
    /**
87
     * @param $language
88
     * @param $module
89
     *
90
     * @return string
91
     */
92
    private function getLanguageMain($language, $module)
93
    {
94
        $ret = $this->defines->getAboveHeadDefines('Admin Main');
95
        $ret .= $this->defines->getDefine($language, 'NAME', "{$module->getVar('mod_name')}");
96
        $ret .= $this->defines->getDefine($language, 'DESC', "{$module->getVar('mod_description')}");
97
98
        return $ret;
99
    }
100
101
    /*
102
    *  @private function getLanguageMenu
103
    *  @param string $language
104
    *  @param array $table
105
    */
106
    /**
107
     * @param $language
108
     * @param $table
109
     *
110
     * @return string
111
     */
112
    private function getLanguageMenu($module, $language, $table)
0 ignored issues
show
Unused Code introduced by
The parameter $table 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...
113
    {
114
        $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
115
        $menu = 1;
116
        $ret = $this->defines->getAboveHeadDefines('Admin Menu');
117
        $ret .= $this->defines->getDefine($language, "ADMENU{$menu}", 'Dashboard');
118
        foreach (array_keys($tables) as $i) {
119
            ++$menu;
120
            $tablePermissions[] = $tables[$i]->getVar('table_permissions');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$tablePermissions was never initialized. Although not strictly required by PHP, it is generally a good practice to add $tablePermissions = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
121
            $ucfTableName = ucfirst($tables[$i]->getVar('table_name'));
122
            $ret .= $this->defines->getDefine($language, "ADMENU{$menu}", "{$ucfTableName}");
123
        }
124
        if (in_array(1, $tablePermissions)) {
0 ignored issues
show
Bug introduced by
The variable $tablePermissions 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...
125
            ++$menu;
126
            $ret .= $this->defines->getDefine($language, "ADMENU{$menu}", 'Permissions');
127
        }
128
        $ret .= $this->defines->getDefine($language, 'ABOUT', 'About');
129
        unset($menu);
130
131
        return $ret;
132
    }
133
134
    /*
135
    *  @private function getLanguageAdmin
136
    *  @param string $language
137
    */
138
    /**
139
     * @param $language
140
     *
141
     * @return string
142
     */
143
    private function getLanguageAdmin($language)
144
    {
145
        $ret = $this->defines->getAboveHeadDefines('Admin Nav');
146
        $ret .= $this->defines->getDefine($language, 'ADMIN_PAGER', 'Admin pager');
147
        $ret .= $this->defines->getDefine($language, 'ADMIN_PAGER_DESC', 'Admin per page list');
148
149
        return $ret;
150
    }
151
152
    /*
153
    *  @private function getLanguageSubmenu
154
    *  @param string $language
155
    *  @param array $tables
156
    */
157
    /**
158
     * @param $language
159
     * @param $tables
160
     *
161
     * @return string
162
     */
163
    private function getLanguageSubmenu($language, $tables)
164
    {
165
        $ret = $this->defines->getAboveDefines('Submenu');
166
        $i = 1;
167
        foreach (array_keys($tables) as $t) {
168
            $tableName = $tables[$t]->getVar('table_name');
169
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
0 ignored issues
show
Coding Style Comprehensibility introduced by
$tableSubmit was never initialized. Although not strictly required by PHP, it is generally a good practice to add $tableSubmit = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
170
            if (1 == $tables[$t]->getVar('table_submenu')) {
171
                $ret .= $this->defines->getDefine($language, "SMNAME{$i}", "{$tableName}");
172
            }
173
            ++$i;
174
        }
175
        if (in_array(1, $tableSubmit)) {
0 ignored issues
show
Bug introduced by
The variable $tableSubmit 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...
176
            $ret .= $this->defines->getDefine($language, "SMNAME{$i}", 'Submit');
177
        }
178
        unset($i);
179
180
        return $ret;
181
    }
182
183
    /*
184
    *  @private function getLanguageBlocks
185
    *  @param string $language
186
    *  @param array $tables
187
    */
188
    /**
189
     * @param $language
190
     * @param $tables
191
     *
192
     * @return string
193
     */
194
    private function getLanguageBlocks($tables, $language)
195
    {
196
        $ret = $this->defines->getAboveDefines('Blocks');
197
		foreach (array_keys($tables) as $i) {
198
            $tableName = $tables[$i]->getVar('table_name');
199
            $stuTableName = strtoupper($tableName);
200
			$tableSoleName = $tables[$i]->getVar('table_solename');
201
			$stuTableSoleName = strtoupper($tableSoleName);
202
            $ucfTableName = ucfirst($tableName);
203
            if (1 == $tables[$i]->getVar('table_blocks')) {
204
                $ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK", "{$ucfTableName} block");
205
                $ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_DESC", "{$ucfTableName} block description");
206
				if ($tables[$i]->getVar('table_category') == 1) {
207
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}", "{$ucfTableName} block");
208
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", "{$ucfTableName} block description");
209
				} else {	
210
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_LAST", "{$ucfTableName} block last");
211
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_LAST_DESC", "{$ucfTableName} block last description");
212
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_NEW", "{$ucfTableName} block new");
213
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_NEW_DESC", "{$ucfTableName} block new description");
214
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_HITS", "{$ucfTableName} block hits");
215
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_HITS_DESC", "{$ucfTableName} block hits description");
216
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_TOP", "{$ucfTableName} block top");
217
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_TOP_DESC", "{$ucfTableName} block top description");
218
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_RANDOM", "{$ucfTableName} block random");
219
					$ret .= $this->defines->getDefine($language, "{$stuTableName}_BLOCK_RANDOM_DESC", "{$ucfTableName} block random description");					
220
				}
221
            }
222
        }
223
224
        return $ret;
225
    }
226
227
    /*
228
    *  @private function getLanguageUser
229
    *  @param string $language
230
    */
231
    /**
232
     * @param $language
233
     *
234
     * @return string
235
     */
236 View Code Duplication
    private function getLanguageUser($language)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
237
    {
238
        $ret = $this->defines->getAboveDefines('User');
239
        $ret .= $this->defines->getDefine($language, 'USER_PAGER', 'User pager');
240
        $ret .= $this->defines->getDefine($language, 'USER_PAGER_DESC', 'User per page list');
241
242
        return $ret;
243
    }
244
245
    /*
246
    *  @private function getLanguageConfig
247
    *  @param string $language
248
    *  @param string $table
249
    */
250
    /**
251
     * @param $language
252
     * @param $table
253
     *
254
     * @return string
255
     */
256
    private function getLanguageConfig($language, $table)
257
    {
258
        $ret = $this->defines->getAboveDefines('Config');
259
        if (is_object($table) && $table->getVar('table_image') != '') {
260
            $ret .= $this->defines->getDefine($language, 'EDITOR', 'Editor');
261
            $ret .= $this->defines->getDefine($language, 'EDITOR_DESC', 'Select the Editor to use');
262
        }
263
        $ret .= $this->defines->getDefine($language, 'KEYWORDS', 'Keywords');
264
        $ret .= $this->defines->getDefine($language, 'KEYWORDS_DESC', 'Insert here the keywords (separate by comma)');
265
        if (is_object($table)) {
266
            /*if ($table->getVar('table_permissions') != 0) {
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...
267
                $ret .= $this->defines->getDefine($language, "GROUPS", "Groups");
268
                $ret .= $this->defines->getDefine($language, "GROUPS_DESC", "Groups to have permissions");
269
                $ret .= $this->defines->getDefine($language, "ADMIN_GROUPS", "Admin Groups");
270
                $ret .= $this->defines->getDefine($language, "ADMIN_GROUPS_DESC", "Admin Groups to have permissions access");
271
            }*/
272
            if ($table->getVar('table_image') != '') {
273
                $ret .= $this->defines->getDefine($language, 'MAXSIZE', 'Max size');
274
                $ret .= $this->defines->getDefine($language, 'MAXSIZE_DESC', 'Set a number of max size uploads file in byte');
275
                $ret .= $this->defines->getDefine($language, 'MIMETYPES', 'Mime Types');
276
                $ret .= $this->defines->getDefine($language, 'MIMETYPES_DESC', 'Set the mime types selected');
277
            }
278
            if ($table->getVar('table_tag') != 0) {
279
                $ret .= $this->defines->getDefine($language, 'USE_TAG', 'Use TAG');
280
                $ret .= $this->defines->getDefine($language, 'USE_TAG_DESC', 'If you use tag module, check this option to yes');
281
            }
282
        }
283
        $ret .= $this->defines->getDefine($language, 'NUMB_COL', 'Number Columns');
284
        $ret .= $this->defines->getDefine($language, 'NUMB_COL_DESC', 'Number Columns to View.');
285
        $ret .= $this->defines->getDefine($language, 'DIVIDEBY', 'Divide By');
286
        $ret .= $this->defines->getDefine($language, 'DIVIDEBY_DESC', 'Divide by columns number.');
287
        $ret .= $this->defines->getDefine($language, 'TABLE_TYPE', 'Table Type');
288
        $ret .= $this->defines->getDefine($language, 'TABLE_TYPE_DESC', 'Table Type is the bootstrap html table.');
289
        $ret .= $this->defines->getDefine($language, 'PANEL_TYPE', 'Panel Type');
290
        $ret .= $this->defines->getDefine($language, 'PANEL_TYPE_DESC', 'Panel Type is the bootstrap html div.');
291
        $ret .= $this->defines->getDefine($language, 'IDPAYPAL', 'Paypal ID');
292
        $ret .= $this->defines->getDefine($language, 'IDPAYPAL_DESC', 'Insert here your PayPal ID for donactions.');
293
        $ret .= $this->defines->getDefine($language, 'ADVERTISE', 'Advertisement Code');
294
        $ret .= $this->defines->getDefine($language, 'ADVERTISE_DESC', 'Insert here the advertisement code');
295
        $ret .= $this->defines->getDefine($language, 'MAINTAINEDBY', 'Maintained By');
296
        $ret .= $this->defines->getDefine($language, 'MAINTAINEDBY_DESC', 'Allow url of support site or community');
297
        $ret .= $this->defines->getDefine($language, 'BOOKMARKS', 'Social Bookmarks');
298
        $ret .= $this->defines->getDefine($language, 'BOOKMARKS_DESC', 'Show Social Bookmarks in the single page');
299
        $ret .= $this->defines->getDefine($language, 'FACEBOOK_COMMENTS', 'Facebook comments');
300
        $ret .= $this->defines->getDefine($language, 'FACEBOOK_COMMENTS_DESC', 'Allow Facebook comments in the single page');
301
        $ret .= $this->defines->getDefine($language, 'DISQUS_COMMENTS', 'Disqus comments');
302
        $ret .= $this->defines->getDefine($language, 'DISQUS_COMMENTS_DESC', 'Allow Disqus comments in the single page');
303
304
        return $ret;
305
    }
306
307
    /*
308
    *  @private function getLanguageNotifications
309
    *  @param string $language
310
    *  @param mixed $table
311
    */
312
    /**
313
     * @param $language
314
     *
315
     * @return string
316
     */
317
    private function getLanguageNotifications($language)
318
    {
319
        $ret = $this->defines->getAboveDefines('Notifications');
320
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NOTIFY', 'Global notify');
321
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NOTIFY_DESC', 'Global notify desc');
322
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NOTIFY', 'Category notify');
323
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NOTIFY_DESC', 'Category notify desc');
324
        $ret .= $this->defines->getDefine($language, 'FILE_NOTIFY', 'File notify');
325
        $ret .= $this->defines->getDefine($language, 'FILE_NOTIFY_DESC', 'File notify desc');
326
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWCATEGORY_NOTIFY', 'Global newcategory notify');
327
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWCATEGORY_NOTIFY_CAPTION', 'Global newcategory notify caption');
328
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWCATEGORY_NOTIFY_DESC', 'Global newcategory notify desc');
329
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWCATEGORY_NOTIFY_SUBJECT', 'Global newcategory notify subject');
330
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEMODIFY_NOTIFY', 'Global filemodify notify');
331
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEMODIFY_NOTIFY_CAPTION', 'Global filemodify notify caption');
332
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEMODIFY_NOTIFY_DESC', 'Global filemodify notify desc');
333
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEMODIFY_NOTIFY_SUBJECT', 'Global filemodify notify subject');
334
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEBROKEN_NOTIFY', 'Global filebroken notify');
335
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEBROKEN_NOTIFY_CAPTION', 'Global filebroken notify caption');
336
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEBROKEN_NOTIFY_DESC', 'Global filebroken notify desc');
337
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILEBROKEN_NOTIFY_SUBJECT', 'Global filebroken notify subject');
338
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILESUBMIT_NOTIFY', 'Global filesubmit notify');
339
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILESUBMIT_NOTIFY_CAPTION', 'Global filesubmit notify caption');
340
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILESUBMIT_NOTIFY_DESC', 'Global filesubmit notify desc');
341
        $ret .= $this->defines->getDefine($language, 'GLOBAL_FILESUBMIT_NOTIFY_SUBJECT', 'Global filesubmit notify subject');
342
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWFILE_NOTIFY', 'Global newfile notify');
343
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWFILE_NOTIFY_CAPTION', 'Global newfile notify caption');
344
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWFILE_NOTIFY_DESC', 'Global newfile notify desc');
345
        $ret .= $this->defines->getDefine($language, 'GLOBAL_NEWFILE_NOTIFY_SUBJECT', 'Global newfile notify subject');
346
        $ret .= $this->defines->getDefine($language, 'CATEGORY_FILESUBMIT_NOTIFY', 'Category filesubmit notify');
347
        $ret .= $this->defines->getDefine($language, 'CATEGORY_FILESUBMIT_NOTIFY_CAPTION', 'Category filesubmit notify caption');
348
        $ret .= $this->defines->getDefine($language, 'CATEGORY_FILESUBMIT_NOTIFY_DESC', 'Category filesubmit notify desc');
349
        $ret .= $this->defines->getDefine($language, 'CATEGORY_FILESUBMIT_NOTIFY_SUBJECT', 'Category filesubmit notify subject');
350
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NEWFILE_NOTIFY', 'Category newfile notify');
351
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NEWFILE_NOTIFY_CAPTION', 'Category newfile notify caption');
352
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NEWFILE_NOTIFY_DESC', 'Category newfile notify desc');
353
        $ret .= $this->defines->getDefine($language, 'CATEGORY_NEWFILE_NOTIFY_SUBJECT', 'Category newfile notify subject');
354
        $ret .= $this->defines->getDefine($language, 'FILE_APPROVE_NOTIFY', 'File approve notify');
355
        $ret .= $this->defines->getDefine($language, 'FILE_APPROVE_NOTIFY_CAPTION', 'File approve notify caption');
356
        $ret .= $this->defines->getDefine($language, 'FILE_APPROVE_NOTIFY_DESC', 'File approve notify desc');
357
        $ret .= $this->defines->getDefine($language, 'FILE_APPROVE_NOTIFY_SUBJECT', 'File approve notify subject');
358
359
        return $ret;
360
    }
361
362
    /*
363
    *  @private function getLanguagePermissionsGroups
364
    *  @param string $language
365
    */
366
    /**
367
     * @param $language
368
     *
369
     * @return string
370
     */
371
    private function getLanguagePermissionsGroups($language)
372
    {
373
        $ret = $this->defines->getAboveDefines('Permissions Groups');
374
        $ret .= $this->defines->getDefine($language, 'GROUPS', 'Groups access');
375
        $ret .= $this->defines->getDefine($language, 'GROUPS_DESC', 'Select general access permission for groups.');
376
        $ret .= $this->defines->getDefine($language, 'ADMIN_GROUPS', 'Admin Group Permissions');
377
        $ret .= $this->defines->getDefine($language, 'ADMIN_GROUPS_DESC', 'Which groups have access to tools and permissions page');
378
379
        return $ret;
380
    }
381
382
    /*
383
    *  @private function getFooter
384
    *  @param null
385
    */
386
    /**
387
     * @return string
388
     */
389
    private function getLanguageFooter()
390
    {
391
        $ret = $this->defines->getBelowDefines('End');
392
393
        return $ret;
394
    }
395
396
    /*
397
    *  @public function render
398
    *  @param null
399
    */
400
    /**
401
     * @return bool|string
402
     */
403
    public function render()
404
    {
405
        $module = $this->getModule();
406
        $table = $this->getTable();
407
        $tables = $this->getTables();
408
        $filename = $this->getFileName();
409
        $moduleDirname = $module->getVar('mod_dirname');
410
        $language = $this->getLanguage($moduleDirname, 'MI');
411
        $content = $this->getHeaderFilesComments($module, $filename);
412
        $content .= $this->getLanguageMain($language, $module);
413
        $content .= $this->getLanguageMenu($module, $language, $table);
414
        if (1 == $table->getVar('table_admin')) {
415
            $content .= $this->getLanguageAdmin($language);
416
        }
417
        if (1 == $table->getVar('table_user')) {
418
            $content .= $this->getLanguageUser($language);
419
        }
420
        //if (1 == $table->getVar('table_submenu')) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
63% 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...
421
            $content .= $this->getLanguageSubmenu($language, $tables);
422
        //}
423
        if (1 == $table->getVar('table_blocks')) {
424
            $content .= $this->getLanguageBlocks($tables, $language);
425
        }
426
        $content .= $this->getLanguageConfig($language, $table);
427
        if (1 == $table->getVar('table_notifications')) {
428
            $content .= $this->getLanguageNotifications($language);
429
        }
430
        if (1 == $table->getVar('table_permissions')) {
431
            $content .= $this->getLanguagePermissionsGroups($language);
432
        }
433
        $content .= $this->getLanguageFooter();
434
        //
435
        $this->tdmcfile->create($moduleDirname, 'language/english', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
0 ignored issues
show
Bug introduced by
The property tdmcfile does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
436
437
        return $this->tdmcfile->renderFile();
438
    }
439
}
440