Passed
Push — master ( c14394...753352 )
by Goffy
04:41
created

LanguageModinfo::render()   C

Complexity

Conditions 9
Paths 192

Size

Total Lines 67
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 51
nc 192
nop 0
dl 0
loc 67
rs 6.9002
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files\Language;
4
5
use XoopsModules\Modulebuilder;
6
use XoopsModules\Modulebuilder\Files;
7
8
/*
9
 You may not change or alter any portion of this comment or credits
10
 of supporting developers from this source code or any supporting source code
11
 which is considered copyrighted (c) material of the original comment or credit authors.
12
13
 This program is distributed in the hope that it will be useful,
14
 but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
/**
18
 * modulebuilder module.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.0
24
 *
25
 * @author          Txmod Xoops http://www.txmodxoops.org
26
 *
27
 */
28
29
/**
30
 * Class LanguageModinfo.
31
 */
32
class LanguageModinfo extends Files\CreateFile
33
{
34
    /**
35
     * @var mixed
36
     */
37
    private $ld = null;
38
39
    /**
40
     * @var mixed
41
     */
42
    private $pc = null;
43
44
    /**
45
     * @public function constructor
46
     * @param null
47
     */
48
    public function __construct()
49
    {
50
        parent::__construct();
51
        $this->ld = LanguageDefines::getInstance();
52
        $this->pc = Modulebuilder\Files\CreatePhpCode::getInstance();
53
    }
54
55
    /**
56
     * @static function getInstance
57
     * @param null
58
     * @return LanguageModinfo
59
     */
60
    public static function getInstance()
61
    {
62
        static $instance = false;
63
        if (!$instance) {
64
            $instance = new self();
65
        }
66
67
        return $instance;
68
    }
69
70
    /**
71
     * @public function write
72
     *
73
     * @param $module
74
     * @param $table
75
     * @param $filename
76
     *
77
     * @return null
78
     */
79
    public function write($module, $table, $filename)
80
    {
81
        $this->setModule($module);
82
        $this->setTable($table);
83
        $this->setFileName($filename);
84
85
        return null;
86
    }
87
88
    /**
89
     * @private function getLanguageMain
90
     *
91
     * @param $language
92
     * @param $module
93
     *
94
     * @return string
95
     */
96
    private function getLanguageMain($language, $module)
97
    {
98
        $ret = $this->ld->getBlankLine();
99
        $ret .= $this->pc->getPhpCodeIncludeDir("'common.php'",'', true, true, 'include');
100
        $ret .= $this->ld->getBlankLine();
101
        $ret .= $this->ld->getAboveHeadDefines('Admin Main');
102
        $ret .= $this->ld->getDefine($language, 'NAME', (string)$module->getVar('mod_name'));
103
        $ret .= $this->ld->getDefine($language, 'DESC', (string)$module->getVar('mod_description'));
104
105
        return $ret;
106
    }
107
108
    /**
109
     * @private function getLanguageMenu
110
     *
111
     * @param $module
112
     * @param $language
113
     *
114
     * @return string
115
     */
116
    private function getLanguageMenu($module, $language)
117
    {
118
        $tables           = $this->getTableTables($module->getVar('mod_id'), 'table_order');
119
        $menu             = 1;
120
        $ret              = $this->ld->getAboveHeadDefines('Admin Menu');
121
        $ret              .= $this->ld->getDefine($language, "ADMENU{$menu}", 'Dashboard');
122
        $tablePermissions = [];
123
        $tableBroken      = [];
124
        foreach (array_keys($tables) as $i) {
125
            ++$menu;
126
            $tablePermissions[] = $tables[$i]->getVar('table_permissions');
127
            $tableBroken[]      = $tables[$i]->getVar('table_broken');
128
            $ucfTableName       = ucfirst($tables[$i]->getVar('table_name'));
129
            $ret                .= $this->ld->getDefine($language, "ADMENU{$menu}", $ucfTableName);
130
        }
131
        if (in_array(1, $tableBroken)) {
132
            ++$menu;
133
            $ret    .= $this->ld->getDefine($language, "ADMENU{$menu}", 'Broken items');
134
        }
135
        if (in_array(1, $tablePermissions)) {
136
            ++$menu;
137
            $ret .= $this->ld->getDefine($language, "ADMENU{$menu}", 'Permissions');
138
        }
139
        ++$menu;
140
        $ret .= $this->ld->getDefine($language, "ADMENU{$menu}", 'Feedback');
141
        $ret .= $this->ld->getDefine($language, 'ABOUT', 'About');
142
        unset($menu, $tablePermissions);
143
144
        return $ret;
145
    }
146
147
    /**
148
     * @private function getLanguageAdmin
149
     * @param $language
150
     *
151
     * @return string
152
     */
153
    private function getLanguageAdmin($language)
154
    {
155
        $ret = $this->ld->getAboveHeadDefines('Admin Nav');
156
        $ret .= $this->ld->getDefine($language, 'ADMIN_PAGER', 'Admin pager');
157
        $ret .= $this->ld->getDefine($language, 'ADMIN_PAGER_DESC', 'Admin per page list');
158
159
        return $ret;
160
    }
161
162
    /**
163
     * @private function getLanguageSubmenu
164
     * @param       $language
165
     * @param array $tables
166
     *
167
     * @return string
168
     */
169
    private function getLanguageSubmenu($language, $tables)
170
    {
171
        $ret         = $this->ld->getAboveDefines('Submenu');
172
        $ret         .= $this->ld->getDefine($language, 'SMNAME1', 'Index page');
173
        $i           = 1;
174
        $tableSubmit = [];
175
        $tableSearch = [];
176
        foreach (array_keys($tables) as $t) {
177
            $tableName     = $tables[$t]->getVar('table_name');
178
            $tableSearch[] = $tables[$t]->getVar('table_search');
179
            $ucfTablename  = ucfirst(mb_strtolower($tableName));
180
            if (1 == $tables[$t]->getVar('table_submenu')) {
181
                $ret .= $this->ld->getDefine($language, "SMNAME{$i}", $ucfTablename);
182
            }
183
            ++$i;
184
            if (1 == $tables[$t]->getVar('table_submit')) {
185
                $ret .= $this->ld->getDefine($language, "SMNAME{$i}", 'Submit ' . $ucfTablename);
186
                ++$i;
187
            }
188
        }
189
190
        if (in_array(1, $tableSearch)) {
191
            $ret .= $this->ld->getDefine($language, "SMNAME{$i}", 'Search');
192
        }
193
        unset($i, $tableSubmit);
194
195
        return $ret;
196
    }
197
198
    /**
199
     * @private function getLanguageBlocks
200
     * @param       $language
201
     * @param array $tables
202
     *
203
     * @return string
204
     */
205
    private function getLanguageBlocks($tables, $language)
206
    {
207
        $ret = $this->ld->getAboveDefines('Blocks');
208
        foreach (array_keys($tables) as $i) {
209
            $tableName        = $tables[$i]->getVar('table_name');
210
            $stuTableName     = mb_strtoupper($tableName);
211
            $tableSoleName    = $tables[$i]->getVar('table_solename');
212
            $stuTableSoleName = mb_strtoupper($tableSoleName);
213
            $ucfTableName     = ucfirst($tableName);
214
            $ucfTableSoleName = ucfirst($stuTableSoleName);
215
216
            $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK", "{$ucfTableName} block");
217
            $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_DESC", "{$ucfTableName} block description");
218
            if (1 == $tables[$i]->getVar('table_category')) {
219
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}", "{$ucfTableName} block {$ucfTableSoleName}");
220
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", "{$ucfTableName} block {$ucfTableSoleName} description");
221
            } else {
222
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}", "{$ucfTableName} block  {$ucfTableSoleName}");
223
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC", "{$ucfTableName} block  {$ucfTableSoleName} description");
224
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_LAST", "{$ucfTableName} block last");
225
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_LAST_DESC", "{$ucfTableName} block last description");
226
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_NEW", "{$ucfTableName} block new");
227
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_NEW_DESC", "{$ucfTableName} block new description");
228
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_HITS", "{$ucfTableName} block hits");
229
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_HITS_DESC", "{$ucfTableName} block hits description");
230
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_TOP", "{$ucfTableName} block top");
231
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_TOP_DESC", "{$ucfTableName} block top description");
232
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_RANDOM", "{$ucfTableName} block random");
233
                $ret .= $this->ld->getDefine($language, "{$stuTableName}_BLOCK_RANDOM_DESC", "{$ucfTableName} block random description");
234
            }
235
        }
236
237
        return $ret;
238
    }
239
240
    /**
241
     * @private function getLanguageUser
242
     * @param $language
243
     *
244
     * @return string
245
     */
246
    private function getLanguageUser($language)
247
    {
248
        $ret = $this->ld->getAboveDefines('User');
249
        $ret .= $this->ld->getDefine($language, 'USER_PAGER', 'User pager');
250
        $ret .= $this->ld->getDefine($language, 'USER_PAGER_DESC', 'User per page list');
251
252
        return $ret;
253
    }
254
255
    /**
256
     * @private function getLanguageConfig
257
     * @param $language
258
     * @param $tables
259
     *
260
     * @return string
261
     */
262
    private function getLanguageConfig($language, $tables)
263
    {
264
        $ret         = $this->ld->getAboveDefines('Config');
265
        $fieldImage  = false;
266
        $fieldFile   = false;
267
        $useTag      = false;
268
        $fieldEditor = false;
269
        // $usePermissions = false;
270
        foreach (array_keys($tables) as $i) {
271
            $fields = $this->getTableFields($tables[$i]->getVar('table_mid'), $tables[$i]->getVar('table_id'));
272
            foreach (array_keys($fields) as $f) {
273
                $fieldElement = $fields[$f]->getVar('field_element');
274
                if (3 == $fieldElement) {
275
                    $fieldEditor = true;
276
                }
277
                if (4 == $fieldElement) {
278
                    $fieldEditor = true;
279
                }
280
                if (13 == $fieldElement) {
281
                    $fieldImage = true;
282
                }
283
				if (14 == $fieldElement) {
284
                    $fieldFile = true;
285
                }
286
            }
287
            if (0 != $tables[$i]->getVar('table_tag')) {
288
                $useTag = true;
289
            }
290
        }
291
        if ($fieldEditor) {
292
            $ret .= $this->ld->getDefine($language, 'EDITOR_ADMIN', 'Editor admin');
293
            $ret .= $this->ld->getDefine($language, 'EDITOR_ADMIN_DESC', 'Select the editor which should be used in admin area for text area fields');
294
            $ret .= $this->ld->getDefine($language, 'EDITOR_USER', 'Editor user');
295
            $ret .= $this->ld->getDefine($language, 'EDITOR_USER_DESC', 'Select the editor which should be used in user area for text area fields');
296
            $ret .= $this->ld->getDefine($language, 'EDITOR_MAXCHAR', 'Text max characters');
297
            $ret .= $this->ld->getDefine($language, 'EDITOR_MAXCHAR_DESC', 'Max characters for showing text of a textarea or editor field in admin area');
298
        }
299
        $ret .= $this->ld->getDefine($language, 'KEYWORDS', 'Keywords');
300
        $ret .= $this->ld->getDefine($language, 'KEYWORDS_DESC', 'Insert here the keywords (separate by comma)');
301
302
        if ($fieldImage || $fieldFile) {
303
            $ret .= $this->ld->getDefine($language, 'SIZE_MB', 'MB');
304
        }
305
        if ($fieldImage) {
306
            $ret .= $this->ld->getDefine($language, 'MAXSIZE_IMAGE', 'Max size image');
307
            $ret .= $this->ld->getDefine($language, 'MAXSIZE_IMAGE_DESC', 'Define the max size for uploading images');
308
            $ret .= $this->ld->getDefine($language, 'MIMETYPES_IMAGE', 'Mime types image');
309
            $ret .= $this->ld->getDefine($language, 'MIMETYPES_IMAGE_DESC', 'Define the allowed mime types for uploading images');
310
            $ret .= $this->ld->getDefine($language, 'MAXWIDTH_IMAGE', 'Max width image');
311
            $ret .= $this->ld->getDefine($language, 'MAXWIDTH_IMAGE_DESC', 'Set the max width which is allowed for uploading images (in pixel)<br>0 means that images keep original size<br>If original image is smaller the image will be not enlarged');
312
            $ret .= $this->ld->getDefine($language, 'MAXHEIGHT_IMAGE', 'Max height image');
313
            $ret .= $this->ld->getDefine($language, 'MAXHEIGHT_IMAGE_DESC', 'Set the max height which is allowed for uploading images (in pixel)<br>0 means that images keep original size<br>If original image is smaller the image will be not enlarged');
314
        }
315
		if ($fieldFile) {
316
            $ret .= $this->ld->getDefine($language, 'MAXSIZE_FILE', 'Max size file');
317
            $ret .= $this->ld->getDefine($language, 'MAXSIZE_FILE_DESC', 'Define the max size for uploading files');
318
            $ret .= $this->ld->getDefine($language, 'MIMETYPES_FILE', 'Mime types file');
319
            $ret .= $this->ld->getDefine($language, 'MIMETYPES_FILE_DESC', 'Define the allowed mime types for uploading files');
320
        }
321
        if ($useTag) {
322
            $ret .= $this->ld->getDefine($language, 'USE_TAG', 'Use TAG');
323
            $ret .= $this->ld->getDefine($language, 'USE_TAG_DESC', 'If you use tag module, check this option to yes');
324
        }
325
        $getDefinesConf = [
326
            'NUMB_COL'               => 'Number Columns',
327
            'NUMB_COL_DESC'          => 'Number Columns to View.',
328
            'DIVIDEBY'               => 'Divide By',
329
            'DIVIDEBY_DESC'          => 'Divide by columns number.',
330
            'TABLE_TYPE'             => 'Table Type',
331
            'TABLE_TYPE_DESC'        => 'Table Type is the bootstrap html table.',
332
            'PANEL_TYPE'             => 'Panel Type',
333
            'PANEL_TYPE_DESC'        => 'Panel Type is the bootstrap html div.',
334
            'IDPAYPAL'               => 'Paypal ID',
335
            'IDPAYPAL_DESC'          => 'Insert here your PayPal ID for donactions.',
336
            'ADVERTISE'              => 'Advertisement Code',
337
            'ADVERTISE_DESC'         => 'Insert here the advertisement code',
338
            'MAINTAINEDBY'           => 'Maintained By',
339
            'MAINTAINEDBY_DESC'      => 'Allow url of support site or community',
340
            'BOOKMARKS'              => 'Social Bookmarks',
341
            'BOOKMARKS_DESC'         => 'Show Social Bookmarks in the single page',
342
            'FACEBOOK_COMMENTS'      => 'Facebook comments',
343
            'FACEBOOK_COMMENTS_DESC' => 'Allow Facebook comments in the single page',
344
            'DISQUS_COMMENTS'        => 'Disqus comments',
345
            'DISQUS_COMMENTS_DESC'   => 'Allow Disqus comments in the single page',
346
        ];
347
        foreach ($getDefinesConf as $defc => $descc) {
348
            $ret .= $this->ld->getDefine($language, $defc, $descc);
349
        }
350
351
        return $ret;
352
    }
353
354
    /**
355
     * @private function getLanguageNotificationsGlobal
356
     * @param       $language
357
     * @param $tableBroken
358
     * @param $tableComment
359
     * @return string
360
     */
361
    private function getLanguageNotificationsGlobal($language, $tableBroken, $tableComment)
362
    {
363
        $ret              = $this->ld->getAboveDefines('Global notifications');
364
        $getDefinesNotif  = [
365
            'NOTIFY_GLOBAL'                  => 'Global notification',
366
            'NOTIFY_GLOBAL_NEW'              => 'Any new item',
367
            'NOTIFY_GLOBAL_NEW_CAPTION'      => 'Notify me about any new item',
368
            'NOTIFY_GLOBAL_NEW_SUBJECT'      => 'Notification about new item',
369
            'NOTIFY_GLOBAL_MODIFY'           => 'Any modified item',
370
            'NOTIFY_GLOBAL_MODIFY_CAPTION'   => 'Notify me about any item modification',
371
            'NOTIFY_GLOBAL_MODIFY_SUBJECT'   => 'Notification about modification',
372
            'NOTIFY_GLOBAL_DELETE'           => 'Any deleted item',
373
            'NOTIFY_GLOBAL_DELETE_CAPTION'   => 'Notify me about any deleted item',
374
            'NOTIFY_GLOBAL_DELETE_SUBJECT'   => 'Notification about deleted item',
375
            'NOTIFY_GLOBAL_APPROVE'          => 'Any item to approve',
376
            'NOTIFY_GLOBAL_APPROVE_CAPTION'  => 'Notify me about any item waiting for approvement',
377
            'NOTIFY_GLOBAL_APPROVE_SUBJECT'  => 'Notification about item waiting for approvement',
378
            //'CATEGORY_NOTIFY'                => 'Category notification',
379
            //'CATEGORY_NOTIFY_DESC'           => 'Category notification desc',
380
            //'CATEGORY_NOTIFY_CAPTION'        => 'Category notification caption',
381
            //'CATEGORY_NOTIFY_SUBJECT'        => 'Category notification Subject',
382
            //'CATEGORY_SUBMIT_NOTIFY'         => 'Category submit notification',
383
            //'CATEGORY_SUBMIT_NOTIFY_CAPTION' => 'Category submit notification caption',
384
            //'CATEGORY_SUBMIT_NOTIFY_DESC'    => 'Category submit notification desc',
385
            //'CATEGORY_SUBMIT_NOTIFY_SUBJECT' => 'Category submit notification subject',
386
        ];
387
        if ($tableBroken) {
388
            $getDefinesNotif['NOTIFY_GLOBAL_BROKEN']         = 'Any broken item';
389
            $getDefinesNotif['NOTIFY_GLOBAL_BROKEN_CAPTION'] = 'Notify me about any broken item';
390
            $getDefinesNotif['NOTIFY_GLOBAL_BROKEN_SUBJECT'] = 'Notification about broken item';
391
        }
392
        if ($tableComment) {
393
            $getDefinesNotif['NOTIFY_GLOBAL_COMMENT']         = 'Any comments';
394
            $getDefinesNotif['NOTIFY_GLOBAL_COMMENT_CAPTION'] = 'Notify me about any comment';
395
            $getDefinesNotif['NOTIFY_GLOBAL_COMMENT_SUBJECT'] = 'Notification about any comment';
396
        }
397
        foreach ($getDefinesNotif as $defn => $descn) {
398
            $ret .= $this->ld->getDefine($language, $defn, $descn);
399
        }
400
401
        return $ret;
402
    }
403
404
    /**
405
     * @private function getLanguageNotificationsTable
406
     * @param       $language
407
     * @param $tableName
408
     * @param mixed $tableSoleName
409
     *
410
     * @param $tableBroken
411
     * @param $tableComment
412
     * @return string
413
     */
414
    private function getLanguageNotificationsTable($language, $tableName, $tableSoleName, $tableBroken, $tableComment)
415
    {
416
        $stuTableSoleName = mb_strtoupper($tableSoleName);
417
        $ucfTableSoleName = ucfirst($tableSoleName);
418
		$ret              = $this->ld->getAboveDefines($ucfTableSoleName . ' notifications');
419
        $getDefinesNotif  = [
420
            'NOTIFY_' . $stuTableSoleName                       => $ucfTableSoleName . ' notification',
421
            'NOTIFY_' . $stuTableSoleName . '_MODIFY'           => "{$ucfTableSoleName} modification",
422
            'NOTIFY_' . $stuTableSoleName . '_MODIFY_CAPTION'   => "Notify me about {$tableSoleName} modification",
423
            'NOTIFY_' . $stuTableSoleName . '_MODIFY_SUBJECT'   => "Notification about modification",
424
            'NOTIFY_' . $stuTableSoleName . '_DELETE'           => "{$ucfTableSoleName} deleted",
425
            'NOTIFY_' . $stuTableSoleName . '_DELETE_CAPTION'   => "Notify me about deleted {$tableName}",
426
            'NOTIFY_' . $stuTableSoleName . '_DELETE_SUBJECT'   => "Notification delete {$tableSoleName}",
427
            'NOTIFY_' . $stuTableSoleName . '_APPROVE'          => "{$ucfTableSoleName} approve",
428
            'NOTIFY_' . $stuTableSoleName . '_APPROVE_CAPTION'  => "Notify me about {$tableName} waiting for approvement",
429
            'NOTIFY_' . $stuTableSoleName . '_APPROVE_SUBJECT'  => "Notification {$tableSoleName} waiting for approvement",
430
        ];
431
        if (1 == $tableBroken) {
432
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_BROKEN']         = "{$ucfTableSoleName} broken";
433
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_BROKEN_CAPTION'] = "Notify me about broken {$tableSoleName}";
434
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_BROKEN_SUBJECT'] = "Notification about broken {$tableSoleName}";
435
        }
436
        if (1 == $tableComment) {
437
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_COMMENT']         = "{$ucfTableSoleName} comment";
438
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_COMMENT_CAPTION'] = "Notify me about comments for {$tableSoleName}";
439
            $getDefinesNotif['NOTIFY_' . $stuTableSoleName . '_COMMENT_SUBJECT'] = "Notification about comments for {$tableSoleName}";
440
        }
441
        foreach ($getDefinesNotif as $defn => $descn) {
442
            $ret .= $this->ld->getDefine($language, $defn, $descn);
443
        }
444
445
        return $ret;
446
    }
447
448
    /**
449
     * @private function getLanguagePermissionsGroups
450
     * @param $language
451
     *
452
     * @return string
453
     */
454
    private function getLanguagePermissionsGroups($language)
455
    {
456
        $ret = $this->ld->getAboveDefines('Permissions Groups');
457
        $ret .= $this->ld->getDefine($language, 'GROUPS', 'Groups access');
458
        $ret .= $this->ld->getDefine($language, 'GROUPS_DESC', 'Select general access permission for groups.');
459
        $ret .= $this->ld->getDefine($language, 'ADMIN_GROUPS', 'Admin Group Permissions');
460
        $ret .= $this->ld->getDefine($language, 'ADMIN_GROUPS_DESC', 'Which groups have access to tools and permissions page');
461
        $ret .= $this->ld->getDefine($language, 'UPLOAD_GROUPS', 'Upload Group Permissions');
462
        $ret .= $this->ld->getDefine($language, 'UPLOAD_GROUPS_DESC', 'Which groups have permissions to upload files');
463
464
        return $ret;
465
    }
466
467
468
    /**
469
     * @private function getLanguagePermissionsGroups
470
     * @param $language
471
     *
472
     * @return string
473
     */
474
    private function getLanguageRatingbars($language)
475
    {
476
        $ret = $this->ld->getAboveDefines('Rating bars');
477
        $ret .= $this->ld->getDefine($language, 'RATINGBAR_GROUPS', 'Groups with rating rights');
478
        $ret .= $this->ld->getDefine($language, 'RATINGBAR_GROUPS_DESC', 'Select groups which should have the right to rate');
479
        $ret .= $this->ld->getDefine($language, 'RATINGBARS', 'Allow rating');
480
        $ret .= $this->ld->getDefine($language, 'RATINGBARS_DESC', 'Define whether rating should be possible and which kind of rating should be used');
481
        $ret .= $this->ld->getDefine($language, 'RATING_NONE', 'Do not use rating');
482
        $ret .= $this->ld->getDefine($language, 'RATING_5STARS', 'Rating with 5 stars');
483
        $ret .= $this->ld->getDefine($language, 'RATING_10STARS', 'Rating with 10 stars');
484
        $ret .= $this->ld->getDefine($language, 'RATING_LIKES', 'Rating with likes and dislikes');
485
        $ret .= $this->ld->getDefine($language, 'RATING_10NUM', 'Rating with 10 points');
486
487
        return $ret;
488
    }
489
490
    /**
491
     * @private function getFooter
492
     * @param null
493
     * @return string
494
     */
495
    private function getLanguageFooter()
496
    {
497
        $df  = LanguageDefines::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $df is dead and can be removed.
Loading history...
498
        $ret = $this->ld->getBelowDefines('End');
499
        $ret .= $this->ld->getBlankLine();
500
501
        return $ret;
502
    }
503
504
    /**
505
     * @public function render
506
     * @param null
507
     * @return bool|string
508
     */
509
    public function render()
510
    {
511
        $module             = $this->getModule();
512
        $tables             = $this->getTableTables($module->getVar('mod_id'));
513
        $filename           = $this->getFileName();
514
        $moduleDirname      = $module->getVar('mod_dirname');
515
        $language           = $this->getLanguage($moduleDirname, 'MI');
516
        $tableAdmin         = [];
517
        $tableUser          = [];
518
        $tableSubmenu       = [];
519
        $tableBlocks        = [];
520
        $tableNotifications = [];
521
        $tablePermissions   = [];
522
        $notifTable         = '';
523
        $tableBrokens       = [];
524
        $tableComments      = [];
525
        foreach (array_keys($tables) as $t) {
526
            $tableName            = $tables[$t]->getVar('table_name');
527
            $tableSoleName        = $tables[$t]->getVar('table_solename');
528
            $tableAdmin[]         = $tables[$t]->getVar('table_admin');
529
            $tableUser[]          = $tables[$t]->getVar('table_user');
530
            $tableSubmenu[]       = $tables[$t]->getVar('table_submenu');
531
            $tableBlocks[]        = $tables[$t]->getVar('table_blocks');
532
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
533
            $tableBroken          = $tables[$t]->getVar('table_broken');
534
            $tableBrokens[]       = $tables[$t]->getVar('table_broken');
535
            $tableComment         = $tables[$t]->getVar('table_comments');
536
            $tableComments[]      = $tables[$t]->getVar('table_comments');
537
            $tableRate[]          = $tables[$t]->getVar('table_rate');
538
            if (1 === (int)$tables[$t]->getVar('table_notifications')) {
539
                $notifTable .= $this->getLanguageNotificationsTable($language, $tableName, $tableSoleName, $tableBroken, $tableComment);
540
            }
541
            $tablePermissions[]   = $tables[$t]->getVar('table_permissions');
542
        }
543
544
        $content       = $this->getHeaderFilesComments($module);
545
        $content       .= $this->getLanguageMain($language, $module);
546
        $content       .= $this->getLanguageMenu($module, $language);
547
        if (in_array(1, $tableAdmin)) {
548
            $content .= $this->getLanguageAdmin($language);
549
        }
550
        if (in_array(1, $tableUser)) {
551
            $content .= $this->getLanguageUser($language);
552
        }
553
        if (in_array(1, $tableSubmenu)) {
554
            $content .= $this->getLanguageSubmenu($language, $tables);
555
        }
556
        if (in_array(1, $tableRate)) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $tableRate seems to be defined by a foreach iteration on line 525. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
557
            $content .= $this->getLanguageRatingbars($language, $tables);
558
        }
559
560
        //if (in_array(1, $tableBlocks)) {
561
        $content .= $this->getLanguageBlocks($tables, $language);
562
        //}
563
        $content .= $this->getLanguageConfig($language, $tables);
564
        if (in_array(1, $tableNotifications)) {
565
            $content .= $this->getLanguageNotificationsGlobal($language, in_array(1, $tableBrokens), in_array(1, $tableComments));
566
            $content .= $notifTable;
567
        }
568
        if (in_array(1, $tablePermissions)) {
569
            $content .= $this->getLanguagePermissionsGroups($language);
570
        }
571
        $content .= $this->getLanguageFooter();
572
573
        $this->create($moduleDirname, 'language/' . $GLOBALS['xoopsConfig']['language'], $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);
574
575
        return $this->renderFile();
576
    }
577
}
578