Passed
Push — master ( 4674d5...c94053 )
by Goffy
40s queued 13s
created

UserXoopsVersion::getXoopsVersionConfig()   F

Complexity

Conditions 27
Paths 8736

Size

Total Lines 292
Code Lines 256

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 27
eloc 256
nc 8736
nop 3
dl 0
loc 292
rs 0
c 0
b 0
f 0

How to fix   Long Method    Complexity   

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\Tdmcreate\Files\User;
4
5
use XoopsModules\Tdmcreate;
6
use XoopsModules\Tdmcreate\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
 * tdmcreate 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 UserXoopsVersion.
31
 */
32
class UserXoopsVersion extends Files\CreateFile
33
{
34
    /**
35
     * @var array
36
     */
37
    private $kw = [];
38
39
    /**
40
     * @public function constructor
41
     * @param null
42
     */
43
    public function __construct()
44
    {
45
        parent::__construct();
46
    }
47
48
    /**
49
     * @static function getInstance
50
     * @param null
51
     * @return UserXoopsVersion
52
     */
53
    public static function getInstance()
54
    {
55
        static $instance = false;
56
        if (!$instance) {
57
            $instance = new self();
58
        }
59
60
        return $instance;
61
    }
62
63
    /**
64
     * @public function write
65
     * @param       $module
66
     * @param mixed $table
67
     * @param mixed $tables
68
     * @param       $filename
69
     */
70
    public function write($module, $table, $tables, $filename)
71
    {
72
        $this->setModule($module);
73
        $this->setTable($table);
74
        $this->setTables($tables);
75
        $this->setFileName($filename);
76
        foreach (array_keys($tables) as $t) {
77
            $tableName = $tables[$t]->getVar('table_name');
78
            $this->setKeywords($tableName);
79
        }
80
    }
81
82
    /**
83
     * @public function setKeywords
84
     * @param mixed $keywords
85
     */
86
    public function setKeywords($keywords)
87
    {
88
        if (is_array($keywords)) {
89
            $this->kw = $keywords;
90
        } else {
91
            $this->kw[] = $keywords;
92
        }
93
    }
94
95
    /**
96
     * @public function getKeywords
97
     * @param null
98
     * @return array
99
     */
100
    public function getKeywords()
101
    {
102
        return $this->kw;
103
    }
104
105
    /**
106
     * @private function getXoopsVersionHeader
107
     * @param $module
108
     * @param $language
109
     *
110
     * @return string
111
     */
112
    private function getXoopsVersionHeader($module, $language)
113
    {
114
        $xCodeVHeader = Tdmcreate\Files\CreateXoopsCode::getInstance();
115
        $uCodeVHeader = UserXoopsCode::getInstance();
116
        $date         = date('Y/m/d');
117
        $ret          = $this->getSimpleString('');
118
        $ret          .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine();
119
        $ret          .= $xCodeVHeader->getXcEqualsOperator('$dirname ', 'basename(__DIR__)');
120
        $ret          .= $this->getDashComment('Informations');
121
        $ha           = (1 == $module->getVar('mod_admin')) ? 1 : 0;
122
        $hm           = (1 == $module->getVar('mod_user')) ? 1 : 0;
123
124
        $descriptions = [
125
            'name'                => "{$language}NAME",
126
            'version'             => (string)$module->getVar('mod_version'),
127
            'description'         => "{$language}DESC",
128
            'author'              => "'{$module->getVar('mod_author')}'",
129
            'author_mail'         => "'{$module->getVar('mod_author_mail')}'",
130
            'author_website_url'  => "'{$module->getVar('mod_author_website_url')}'",
131
            'author_website_name' => "'{$module->getVar('mod_author_website_name')}'",
132
            'credits'             => "'{$module->getVar('mod_credits')}'",
133
            'license'             => "'{$module->getVar('mod_license')}'",
134
            'license_url'         => "'http://www.gnu.org/licenses/gpl-3.0.en.html'",
135
            'help'                => "'page=help'",
136
            'release_info'        => "'{$module->getVar('mod_release_info')}'",
137
            'release_file'        => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'",
138
            'release_date'        => "'{$date}'",
139
            'manual'              => "'{$module->getVar('mod_manual')}'",
140
            'manual_file'         => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'",
141
            'min_php'             => "'{$module->getVar('mod_min_php')}'",
142
            'min_xoops'           => "'{$module->getVar('mod_min_xoops')}'",
143
            'min_admin'           => "'{$module->getVar('mod_min_admin')}'",
144
            'min_db'              => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')",
145
            'image'               => "'assets/images/logoModule.png'",
146
            'dirname'             => 'basename(__DIR__)',
147
            'dirmoduleadmin'      => "'Frameworks/moduleclasses/moduleadmin'",
148
            'sysicons16'          => "'../../Frameworks/moduleclasses/icons/16'",
149
            'sysicons32'          => "'../../Frameworks/moduleclasses/icons/32'",
150
            'modicons16'          => "'assets/icons/16'",
151
            'modicons32'          => "'assets/icons/32'",
152
            'demo_site_url'       => "'{$module->getVar('mod_demo_site_url')}'",
153
            'demo_site_name'      => "'{$module->getVar('mod_demo_site_name')}'",
154
            'support_url'         => "'{$module->getVar('mod_support_url')}'",
155
            'support_name'        => "'{$module->getVar('mod_support_name')}'",
156
            'module_website_url'  => "'{$module->getVar('mod_website_url')}'",
157
            'module_website_name' => "'{$module->getVar('mod_website_name')}'",
158
            'release'             => "'{$module->getVar('mod_release')}'",
159
            'module_status'       => "'{$module->getVar('mod_status')}'",
160
            'system_menu'         => '1',
161
            'hasAdmin'            => $ha,
162
            'hasMain'             => $hm,
163
            'adminindex'          => "'admin/index.php'",
164
            'adminmenu'           => "'admin/menu.php'",
165
            'onInstall'           => "'include/install.php'",
166
            'onUpdate'            => "'include/update.php'",
167
        ];
168
169
        $ret .= $uCodeVHeader->getUserModVersion(1, $descriptions);
170
171
        return $ret;
172
    }
173
174
    /**
175
     * @private function getXoopsVersionMySQL
176
     * @param $moduleDirname
177
     * @param $table
178
     * @param $tables
179
     * @return string
180
     */
181
    private function getXoopsVersionMySQL($moduleDirname, $table, $tables)
182
    {
183
        $uCodeVMySQL = UserXoopsCode::getInstance();
184
        $tableName   = $table->getVar('table_name');
185
        $n           = 1;
186
        $ret         = '';
187
        if (!empty($tableName)) {
188
            $ret .= $this->getDashComment('Mysql');
189
            $ret .= $uCodeVMySQL->getUserModVersion(2, "'sql/mysql.sql'", 'sqlfile', "'mysql'");
190
            $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables');
191
192
            foreach (array_keys($tables) as $t) {
193
                $ret .= $uCodeVMySQL->getUserModVersion(2, "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'", 'tables', $n);
194
                ++$n;
195
            }
196
            unset($n);
197
        }
198
199
        return $ret;
200
    }
201
202
    /**
203
     * @private function getXoopsVersionSearch
204
     * @param $moduleDirname
205
     *
206
     * @return string
207
     */
208
    private function getXoopsVersionSearch($moduleDirname)
209
    {
210
        $uCodeVSearch = UserXoopsCode::getInstance();
211
        $ret          = $this->getDashComment('Search');
212
        $ret          .= $uCodeVSearch->getUserModVersion(1, 1, 'hasSearch');
213
        $ret          .= $uCodeVSearch->getUserModVersion(2, "'include/search.inc.php'", 'search', "'file'");
214
        $ret          .= $uCodeVSearch->getUserModVersion(2, "'{$moduleDirname}_search'", 'search', "'func'");
215
216
        return $ret;
217
    }
218
219
    /**
220
     * @private function getXoopsVersionComments
221
     * @param $moduleDirname
222
     *
223
     * @return string
224
     */
225
    private function getXoopsVersionComments($moduleDirname)
226
    {
227
        $uCodeVComments = UserXoopsCode::getInstance();
228
        $ret            = $this->getDashComment('Comments');
229
        $ret            .= $uCodeVComments->getUserModVersion(2, "'comments.php'", 'comments', "'pageName'");
230
        $ret            .= $uCodeVComments->getUserModVersion(2, "'com_id'", 'comments', "'itemName'");
231
        $ret            .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions');
232
        $ret            .= $uCodeVComments->getUserModVersion(2, "'include/comment_functions.php'", 'comments', "'callbackFile'");
233
        $descriptions   = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"];
234
        $ret            .= $uCodeVComments->getUserModVersion(3, $descriptions, 'comments', "'callback'");
235
236
        return $ret;
237
    }
238
239
    /**
240
     * @private function getXoopsVersionTemplatesAdmin
241
     * @param $moduleDirname
242
     * @param $tables
243
     *
244
     * @return string
245
     */
246
    private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables)
247
    {
248
        $ret = $this->getDashComment('Templates');
249
        $ret .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Admin');
250
251
        $ret              .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true);
252
        $ret              .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true);
253
        $ret              .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true);
254
        $tablePermissions = [];
255
        foreach (array_keys($tables) as $t) {
256
            $tableName          = $tables[$t]->getVar('table_name');
257
            $tablePermissions[] = $tables[$t]->getVar('table_permissions');
258
            $ret                .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true);
259
        }
260
        if (in_array(1, $tablePermissions)) {
261
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true);
262
        }
263
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true);
264
265
        return $ret;
266
    }
267
268
    /**
269
     * @private function getXoopsVersionTemplatesLine
270
     * @param        $moduleDirname
271
     * @param        $type
272
     * @param string $extra
273
     * @param bool   $isAdmin
274
     * @return string
275
     */
276
    private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false)
277
    {
278
        $uCodeVTLine = UserXoopsCode::getInstance();
279
        $ret         = '';
280
        $desc        = "'description' => ''";
281
        $arrayFile   = "array('file' =>";
282
        if ($isAdmin) {
283
            $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin')", 'templates', '');
284
        } else {
285
            if ('' !== $extra) {
286
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc})", 'templates', '');
287
            } else {
288
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc})", 'templates', '');
289
            }
290
        }
291
292
        return $ret;
293
    }
294
295
    /**
296
     * @private function getXoopsVersionTemplatesUser
297
     * @param $moduleDirname
298
     * @param $tables
299
     * @return string
300
     */
301
    private function getXoopsVersionTemplatesUser($moduleDirname, $tables)
302
    {
303
        $ret = Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('User');
304
305
        $ret         .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '');
306
        $ret         .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '');
307
        $tableBroken = [];
308
        $tablePdf    = [];
309
        $tablePrint  = [];
310
        $tableRate   = [];
311
        $tableRss    = [];
312
        $tableSearch = [];
313
        $tableSingle = [];
314
        $tableSubmit = [];
315
        foreach (array_keys($tables) as $t) {
316
            $tableName     = $tables[$t]->getVar('table_name');
317
            $tableBroken[] = $tables[$t]->getVar('table_broken');
318
            $tablePdf[]    = $tables[$t]->getVar('table_pdf');
319
            $tablePrint[]  = $tables[$t]->getVar('table_print');
320
            $tableRate[]   = $tables[$t]->getVar('table_rate');
321
            $tableRss[]    = $tables[$t]->getVar('table_rss');
322
            $tableSearch[] = $tables[$t]->getVar('table_search');
323
            $tableSingle[] = $tables[$t]->getVar('table_single');
324
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
325
            $ret           .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '');
326
            $ret           .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list');
327
        }
328
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs', '');
329
        if (in_array(1, $tableBroken)) {
330
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken', '');
331
        }
332
        if (in_array(1, $tablePdf)) {
333
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf', '');
334
        }
335
        if (in_array(1, $tablePrint)) {
336
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'print', '');
337
        }
338
        if (in_array(1, $tableRate)) {
339
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate', '');
340
        }
341
        if (in_array(1, $tableRss)) {
342
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss', '');
343
        }
344
        if (in_array(1, $tableSearch)) {
345
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'search', '');
346
        }
347
        if (in_array(1, $tableSingle)) {
348
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'single', '');
349
        }
350
        if (in_array(1, $tableSubmit)) {
351
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit', '');
352
        }
353
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '');
354
355
        return $ret;
356
    }
357
358
    /**
359
     * @private function getXoopsVersionSubmenu
360
     * @param $language
361
     * @param $tables
362
     * @return string
363
     */
364
    private function getXoopsVersionSubmenu($language, $tables)
365
    {
366
        $phpCodeVSubmenu = Tdmcreate\Files\CreatePhpCode::getInstance();
367
        $uCodeVSubmenu   = UserXoopsCode::getInstance();
368
        $ret             = $this->getDashComment('Submenu');
369
        $i               = 1;
370
        $tableSubmit     = [];
371
        foreach (array_keys($tables) as $t) {
372
            $tableName     = $tables[$t]->getVar('table_name');
373
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
374
            if (1 == $tables[$t]->getVar('table_submenu')) {
375
                $ret   .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', $tableName);
376
                $tname = ['name' => "{$language}SMNAME{$i}", 'url' => "'{$tableName}.php'"];
377
                $ret   .= $uCodeVSubmenu->getUserModVersion(3, $tname, 'sub', $i);
378
            }
379
            ++$i;
380
        }
381
        if (in_array(1, $tableSubmit)) {
382
            $ret    .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', 'Submit');
383
            $submit = ['name' => "{$language}SMNAME{$i}", 'url' => "'submit.php'"];
384
            $ret    .= $uCodeVSubmenu->getUserModVersion(3, $submit, 'sub', $i);
385
        }
386
        unset($i);
387
388
        return $ret;
389
    }
390
391
    /**
392
     * @private function getXoopsVersionBlocks
393
     * @param $moduleDirname
394
     * @param $tables
395
     * @param $language
396
     * @return string
397
     */
398
    private function getXoopsVersionBlocks($moduleDirname, $tables, $language)
399
    {
400
        $ret           = $this->getDashComment('Blocks');
401
        $ret           .= $this->getSimpleString('$b = 1;');
402
        $tableCategory = [];
403
        foreach (array_keys($tables) as $i) {
404
            $tableName        = $tables[$i]->getVar('table_name');
405
            $tableFieldName   = $tables[$i]->getVar('table_fieldname');
406
            $tableSoleName    = $tables[$i]->getVar('table_solename');
407
            $stuTableSoleName = mb_strtoupper($tableSoleName);
408
            $tableCategory[]  = $tables[$i]->getVar('table_category');
409
            if (in_array(1, $tableCategory)) {
410
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $tableFieldName);
411
            } else {
412
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last');
413
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new');
414
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits');
415
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top');
416
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random');
417
            }
418
        }
419
        $ret .= $this->getSimpleString('unset($b);');
420
421
        return $ret;
422
    }
423
424
    /**
425
     * @private function getXoopsVersionTypeBlocks
426
     * @param $moduleDirname
427
     * @param $tableName
428
     * @param $stuTableSoleName
429
     * @param $language
430
     * @param $type
431
     * @return string
432
     */
433
    private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type)
434
    {
435
        $phpCodeVTBlocks = Tdmcreate\Files\CreatePhpCode::getInstance();
436
        $uCodeVTBlocks   = UserXoopsCode::getInstance();
437
        $stuTableName    = mb_strtoupper($tableName);
438
        $ucfTableName    = ucfirst($tableName);
439
        $ret             = $phpCodeVTBlocks->getPhpCodeCommentLine($ucfTableName);
440
        $blocks          = [
441
            'file'        => "'{$tableName}.php'",
442
            'name'        => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}",
443
            'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC",
444
            'show_func'   => "'b_{$moduleDirname}_{$tableName}_show'",
445
            'edit_func'   => "'b_{$moduleDirname}_{$tableName}_edit'",
446
            'template'    => "'{$moduleDirname}_block_{$tableName}.tpl'",
447
            'options'     => "'{$type}|5|25|0'",
448
        ];
449
        $ret             .= $uCodeVTBlocks->getUserModVersion(3, $blocks, 'blocks', '$b');
450
        $ret             .= $this->getSimpleString('++$b;');
451
452
        return $ret;
453
    }
454
455
    /**
456
     * @private function getXoopsVersionConfig
457
     * @param $module
458
     * @param $tables
459
     * @param $language
460
     *
461
     * @return string
462
     */
463
    private function getXoopsVersionConfig($module, $tables, $language)
464
    {
465
        $phpCodeVConfig = Tdmcreate\Files\CreatePhpCode::getInstance();
466
        $xCodeVConfig   = Tdmcreate\Files\CreateXoopsCode::getInstance();
467
        $uCodeVConfig   = UserXoopsCode::getInstance();
468
        $moduleDirname  = $module->getVar('mod_dirname');
469
        $ret            = $this->getDashComment('Config');
470
        $ret            .= $this->getSimpleString('$c = 1;');
471
472
        $table_permissions = 0;
473
        $table_admin       = 0;
474
        $table_user        = 0;
475
        $table_tag         = 0;
476
        $field_images      = 0;
477
        foreach ($tables as $table) {
478
            $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
479
            foreach (array_keys($fields) as $f) {
480
                $fieldElement = $fields[$f]->getVar('field_element');
481
                switch ($fieldElement) {
482
                    case '3':
483
                    case '4':
484
                    case 3:
485
                    case 4:
486
                        $fieldName    = $fields[$f]->getVar('field_name');
487
                        $rpFieldName  = $this->getRightString($fieldName);
488
                        $ucfFieldName = ucfirst($rpFieldName);
489
                        $stuFieldName = mb_strtoupper($rpFieldName);
490
                        $ret          .= $phpCodeVConfig->getPhpCodeCommentLine('Editor', $rpFieldName);
491
                        $ret          .= $xCodeVConfig->getXcLoad('xoopseditorhandler');
492
                        $ret          .= $xCodeVConfig->getXcEqualsOperator('$editorHandler' . $ucfFieldName, 'XoopsEditorHandler::getInstance()');
493
                        $editor       = [
494
                            'name'        => "'editor_{$rpFieldName}'",
495
                            'title'       => "'{$language}EDITOR_{$stuFieldName}'",
496
                            'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'",
497
                            'formtype'    => "'select'",
498
                            'valuetype'   => "'text'",
499
                            'default'     => "'dhtml'",
500
                            'options'     => 'array_flip($editorHandler' . $ucfFieldName . '->getList())',
501
                        ];
502
                        $ret          .= $uCodeVConfig->getUserModVersion(3, $editor, 'config', '$c');
503
                        $ret          .= $this->getSimpleString('++$c;');
504
                        break;
505
                    case '10':
506
                    case '11':
507
                    case '12':
508
                    case '13':
509
                    case '14':
510
                    case 10:
511
                    case 11:
512
                    case 12:
513
                    case 13:
514
                    case 14:
515
                        $field_images = 1;
516
                        break;
517
                    case 'else':
518
                    default:
519
                        break;
520
                }
521
            }
522
            if (1 == $table->getVar('table_permissions')) {
523
                $table_permissions = 1;
524
            }
525
            if (1 == $table->getVar('table_admin')) {
526
                $table_admin = 1;
527
            }
528
            if (1 == $table->getVar('table_user')) {
529
                $table_user = 1;
530
            }
531
            if (1 == $table->getVar('table_tag')) {
532
                $table_tag = 1;
533
            }
534
        }
535
536
        if (1 === $table_permissions) {
537
            $ret         .= $phpCodeVConfig->getPhpCodeCommentLine('Get groups');
538
            $ret         .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false);
539
            $ret         .= $xCodeVConfig->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()');
540
            $group       = $xCodeVConfig->getXcEqualsOperator('$groups[$group] ', '$key', null, false, "\t");
541
            $ret         .= $phpCodeVConfig->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group);
542
            $groups      = [
543
                'name'        => "'groups'",
544
                'title'       => "'{$language}GROUPS'",
545
                'description' => "'{$language}GROUPS_DESC'",
546
                'formtype'    => "'select_multi'",
547
                'valuetype'   => "'array'",
548
                'default'     => '$groups',
549
                'options'     => '$groups',
550
            ];
551
            $ret         .= $uCodeVConfig->getUserModVersion(3, $groups, 'config', '$c');
552
            $ret         .= $this->getSimpleString('++$c;');
553
            $ret         .= $phpCodeVConfig->getPhpCodeCommentLine('Get Admin groups');
554
            $ret         .= $xCodeVConfig->getXcEqualsOperator('$criteria ', 'new \CriteriaCompo()');
555
            $ret         .= $this->getSimpleString("\$criteria->add( new \Criteria( 'group_type', 'Admin' ) );");
556
            $ret         .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_getHandler('member')", '', false);
557
            $ret         .= $xCodeVConfig->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)');
558
            $adminGroup  = $xCodeVConfig->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, false, "\t");
559
            $ret         .= $phpCodeVConfig->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup);
560
            $adminGroups = [
561
                'name'        => "'admin_groups'",
562
                'title'       => "'{$language}GROUPS'",
563
                'description' => "'{$language}GROUPS_DESC'",
564
                'formtype'    => "'select_multi'",
565
                'valuetype'   => "'array'",
566
                'default'     => '$adminGroups',
567
                'options'     => '$adminGroups',
568
            ];
569
            $ret         .= $uCodeVConfig->getUserModVersion(3, $adminGroups, 'config', '$c');
570
            $ret         .= $this->getSimpleString('++$c;');
571
        }
572
        $keyword      = implode(', ', $this->getKeywords());
573
        $ret          .= $phpCodeVConfig->getPhpCodeCommentLine('Keywords');
574
        $arrayKeyword = [
575
            'name'        => "'keywords'",
576
            'title'       => "'{$language}KEYWORDS'",
577
            'description' => "'{$language}KEYWORDS_DESC'",
578
            'formtype'    => "'textbox'",
579
            'valuetype'   => "'text'",
580
            'default'     => "'{$moduleDirname}, {$keyword}'",
581
        ];
582
        $ret          .= $uCodeVConfig->getUserModVersion(3, $arrayKeyword, 'config', '$c');
583
        $ret          .= $this->getSimpleString('++$c;');
584
        unset($this->keywords);
0 ignored issues
show
Bug Best Practice introduced by
The property keywords does not exist on XoopsModules\Tdmcreate\Files\User\UserXoopsVersion. Did you maybe forget to declare it?
Loading history...
585
586
        if (1 === $field_images) {
587
            $ret       .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : maxsize of image');
588
            $maxsize   = [
589
                'name'        => "'maxsize'",
590
                'title'       => "'{$language}MAXSIZE'",
591
                'description' => "'{$language}MAXSIZE_DESC'",
592
                'formtype'    => "'textbox'",
593
                'valuetype'   => "'int'",
594
                'default'     => '5000000',
595
            ];
596
            $ret       .= $uCodeVConfig->getUserModVersion(3, $maxsize, 'config', '$c');
597
            $ret       .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : mimetypes of image');
598
            $ret       .= $this->getSimpleString('++$c;');
599
            $mimetypes = [
600
                'name'        => "'mimetypes'",
601
                'title'       => "'{$language}MIMETYPES'",
602
                'description' => "'{$language}MIMETYPES_DESC'",
603
                'formtype'    => "'select_multi'",
604
                'valuetype'   => "'array'",
605
                'default'     => "array('image/gif', 'image/jpeg', 'image/png')",
606
                'options'     => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png')",
607
            ];
608
            $ret       .= $uCodeVConfig->getUserModVersion(3, $mimetypes, 'config', '$c');
609
            $ret       .= $this->getSimpleString('++$c;');
610
        }
611
        if (1 === $table_admin) {
612
            $ret        .= $phpCodeVConfig->getPhpCodeCommentLine('Admin pager');
613
            $adminPager = [
614
                'name'        => "'adminpager'",
615
                'title'       => "'{$language}ADMIN_PAGER'",
616
                'description' => "'{$language}ADMIN_PAGER_DESC'",
617
                'formtype'    => "'textbox'",
618
                'valuetype'   => "'int'",
619
                'default'     => '10',
620
            ];
621
            $ret        .= $uCodeVConfig->getUserModVersion(3, $adminPager, 'config', '$c');
622
            $ret        .= $this->getSimpleString('++$c;');
623
        }
624
        if (1 === $table_user) {
625
            $ret       .= $phpCodeVConfig->getPhpCodeCommentLine('User pager');
626
            $userPager = [
627
                'name'        => "'userpager'",
628
                'title'       => "'{$language}USER_PAGER'",
629
                'description' => "'{$language}USER_PAGER_DESC'",
630
                'formtype'    => "'textbox'",
631
                'valuetype'   => "'int'",
632
                'default'     => '10',
633
            ];
634
            $ret       .= $uCodeVConfig->getUserModVersion(3, $userPager, 'config', '$c');
635
            $ret       .= $this->getSimpleString('++$c;');
636
        }
637
        if (1 === $table_tag) {
638
            $ret    .= $phpCodeVConfig->getPhpCodeCommentLine('Use tag');
639
            $useTag = [
640
                'name'        => "'usetag'",
641
                'title'       => "'{$language}USE_TAG'",
642
                'description' => "'{$language}USE_TAG_DESC'",
643
                'formtype'    => "'yesno'",
644
                'valuetype'   => "'int'",
645
                'default'     => '0',
646
            ];
647
            $ret    .= $uCodeVConfig->getUserModVersion(3, $useTag, 'config', '$c');
648
            $ret    .= $this->getSimpleString('++$c;');
649
        }
650
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Number column');
651
        $numbCol          = [
652
            'name'        => "'numb_col'",
653
            'title'       => "'{$language}NUMB_COL'",
654
            'description' => "'{$language}NUMB_COL_DESC'",
655
            'formtype'    => "'select'",
656
            'valuetype'   => "'int'",
657
            'default'     => '1',
658
            'options'     => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
659
        ];
660
        $ret              .= $uCodeVConfig->getUserModVersion(3, $numbCol, 'config', '$c');
661
        $ret              .= $this->getSimpleString('++$c;');
662
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Divide by');
663
        $divideby         = [
664
            'name'        => "'divideby'",
665
            'title'       => "'{$language}DIVIDEBY'",
666
            'description' => "'{$language}DIVIDEBY_DESC'",
667
            'formtype'    => "'select'",
668
            'valuetype'   => "'int'",
669
            'default'     => '1',
670
            'options'     => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
671
        ];
672
        $ret              .= $uCodeVConfig->getUserModVersion(3, $divideby, 'config', '$c');
673
        $ret              .= $this->getSimpleString('++$c;');
674
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Table type');
675
        $tableType        = [
676
            'name'        => "'table_type'",
677
            'title'       => "'{$language}TABLE_TYPE'",
678
            'description' => "'{$language}DIVIDEBY_DESC'",
679
            'formtype'    => "'select'",
680
            'valuetype'   => "'int'",
681
            'default'     => "'bordered'",
682
            'options'     => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')",
683
        ];
684
        $ret              .= $uCodeVConfig->getUserModVersion(3, $tableType, 'config', '$c');
685
        $ret              .= $this->getSimpleString('++$c;');
686
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Panel by');
687
        $panelType        = [
688
            'name'        => "'panel_type'",
689
            'title'       => "'{$language}PANEL_TYPE'",
690
            'description' => "'{$language}PANEL_TYPE_DESC'",
691
            'formtype'    => "'select'",
692
            'valuetype'   => "'text'",
693
            'default'     => "'default'",
694
            'options'     => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')",
695
        ];
696
        $ret              .= $uCodeVConfig->getUserModVersion(3, $panelType, 'config', '$c');
697
        $ret              .= $this->getSimpleString('++$c;');
698
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Advertise');
699
        $advertise        = [
700
            'name'        => "'advertise'",
701
            'title'       => "'{$language}ADVERTISE'",
702
            'description' => "'{$language}ADVERTISE_DESC'",
703
            'formtype'    => "'textarea'",
704
            'valuetype'   => "'text'",
705
            'default'     => "''",
706
        ];
707
        $ret              .= $uCodeVConfig->getUserModVersion(3, $advertise, 'config', '$c');
708
        $ret              .= $this->getSimpleString('++$c;');
709
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Bookmarks');
710
        $bookmarks        = [
711
            'name'        => "'bookmarks'",
712
            'title'       => "'{$language}BOOKMARKS'",
713
            'description' => "'{$language}BOOKMARKS_DESC'",
714
            'formtype'    => "'yesno'",
715
            'valuetype'   => "'int'",
716
            'default'     => '0',
717
        ];
718
        $ret              .= $uCodeVConfig->getUserModVersion(3, $bookmarks, 'config', '$c');
719
        $ret              .= $this->getSimpleString('++$c;');
720
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Facebook Comments');
721
        $facebookComments = [
722
            'name'        => "'facebook_comments'",
723
            'title'       => "'{$language}FACEBOOK_COMMENTS'",
724
            'description' => "'{$language}FACEBOOK_COMMENTS_DESC'",
725
            'formtype'    => "'yesno'",
726
            'valuetype'   => "'int'",
727
            'default'     => '0',
728
        ];
729
        $ret              .= $uCodeVConfig->getUserModVersion(3, $facebookComments, 'config', '$c');
730
        $ret              .= $this->getSimpleString('++$c;');
731
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Disqus Comments');
732
        $disqusComments   = [
733
            'name'        => "'disqus_comments'",
734
            'title'       => "'{$language}DISQUS_COMMENTS'",
735
            'description' => "'{$language}DISQUS_COMMENTS_DESC'",
736
            'formtype'    => "'yesno'",
737
            'valuetype'   => "'int'",
738
            'default'     => '0',
739
        ];
740
        $ret              .= $uCodeVConfig->getUserModVersion(3, $disqusComments, 'config', '$c');
741
        $ret              .= $this->getSimpleString('++$c;');
742
        $ret              .= $phpCodeVConfig->getPhpCodeCommentLine('Maintained by');
743
        $maintainedby     = [
744
            'name'        => "'maintainedby'",
745
            'title'       => "'{$language}MAINTAINEDBY'",
746
            'description' => "'{$language}MAINTAINEDBY_DESC'",
747
            'formtype'    => "'textbox'",
748
            'valuetype'   => "'text'",
749
            'default'     => "'{$module->getVar('mod_support_url')}'",
750
        ];
751
        $ret              .= $uCodeVConfig->getUserModVersion(3, $maintainedby, 'config', '$c');
752
        $ret              .= $this->getSimpleString('unset($c);');
753
754
        return $ret;
755
    }
756
757
    /**
758
     * @private function getNotificationsType
759
     * @param $language
760
     * @param $type
761
     * @param $tableName
762
     * @param $notifyFile
763
     * @param $item
764
     * @param $typeOfNotify
765
     *
766
     * @return string
767
     */
768
    private function getNotificationsType($language, $type, $tableName, $notifyFile, $item, $typeOfNotify)
0 ignored issues
show
Unused Code introduced by
The method getNotificationsType() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
769
    {
770
        $phpCodeNType    = Tdmcreate\Files\CreatePhpCode::getInstance();
771
        $uCodeNType      = UserXoopsCode::getInstance();
772
        $stuTableName    = mb_strtoupper($tableName);
773
        $stuTypeOfNotify = mb_strtoupper($typeOfNotify);
774
        $notifyFile      = explode(', ', $notifyFile);
775
        $notifyFile      = implode(', ', $notifyFile);
776
        $ret             = '';
777
        switch ($type) {
778
            case 'category':
779
                $ret      .= $phpCodeNType->getPhpCodeCommentLine('Category Notify');
780
                $category = [
781
                    'name'             => "'category'",
782
                    'title'            => "'{$language}{$stuTableName}_NOTIFY'",
783
                    'description'      => "'{$language}{$stuTableName}_NOTIFY_DESC'",
784
                    'subscribe_from'   => "array('index.php',{$notifyFile})",
785
                    'item_name'        => "'{$item}'",
786
                    "'allow_bookmark'" => '1',
787
                ];
788
                $ret      .= $uCodeNType->getUserModVersion(3, $category, 'notification', "'{$type}'");
789
                break;
790
            case 'event':
791
                $ret   .= $phpCodeNType->getPhpCodeCommentLine('Event Notify');
792
                $event = [
793
                    'name'          => "'{$typeOfNotify}'",
794
                    'category'      => "'{$tableName}'",
795
                    'admin_only'    => '1',
796
                    "'title'"       => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'",
797
                    'caption'       => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'",
798
                    'description'   => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'",
799
                    'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'",
800
                    'mail_subject'  => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'",
801
                ];
802
                $ret   .= $uCodeNType->getUserModVersion(3, $event, 'notification', "'{$type}'");
803
                break;
804
        }
805
806
        return $ret;
807
    }
808
809
    /**
810
     * @private function getXoopsVersionNotifications
811
     * @param $module
812
     * @param $language
813
     * @return string
814
     */
815
    private function getXoopsVersionNotifications($module, $language)
816
    {
817
        $uCodeVN       = UserXoopsCode::getInstance();
818
        $moduleDirname = $module->getVar('mod_dirname');
819
        $ret           = $this->getDashComment('Notifications');
820
        $ret           .= $uCodeVN->getUserModVersion(1, 1, 'hasNotification');
821
        $notifications = ["'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"];
822
        $ret           .= $uCodeVN->getUserModVersion(2, $notifications, 'notification');
823
824
        $notifyFiles   = [];
825
        $single        = 'single';
826
        $tables        = $this->getTableTables($module->getVar('mod_id'), 'table_order');
827
        $tableCategory = [];
828
        $tableBroken   = [];
829
        $tableSubmit   = [];
830
        $tableId       = null;
831
        $tableMid      = null;
832
        foreach (array_keys($tables) as $t) {
833
            $tableId         = $tables[$t]->getVar('table_id');
834
            $tableMid        = $tables[$t]->getVar('table_mid');
835
            $tableName       = $tables[$t]->getVar('table_name');
836
            $tableSoleName   = $tables[$t]->getVar('table_solename');
837
            $tableCategory[] = $tables[$t]->getVar('table_category');
838
            $tableBroken[]   = $tables[$t]->getVar('table_broken');
839
            $tableSubmit[]   = $tables[$t]->getVar('table_submit');
840
            if (1 == $tables[$t]->getVar('table_notifications')) {
841
                if ($t <= count($tableName)) {
842
                    $notifyFiles[] = $tables[$t]->getVar('table_name');
843
                }
844
            }
845
            if (1 == $tables[$t]->getVar('table_single')) {
846
                $single = $tableName;
847
            }
848
        }
849
        $fields      = $this->getTableFields($tableMid, $tableId);
850
        $fieldId     = null;
851
        $fieldParent = null;
852
        foreach (array_keys($fields) as $f) {
853
            $fieldName    = $fields[$f]->getVar('field_name');
854
            $fieldElement = $fields[$f]->getVar('field_element');
855
            if (0 == $f) {
856
                $fieldId = $fieldName;
857
            }
858
            if ($fieldElement > 15) {
859
                $fieldParent = $fieldName;
860
            }
861
        }
862
863
        $num = 1;
864
        $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num);
865
        ++$num;
866
        $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num);
867
        ++$num;
868
        $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableSoleName, $tableSoleName, $single, $fieldId, 1, $num);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $tableSoleName seems to be defined by a foreach iteration on line 832. Are you sure the iterator is never empty, otherwise this variable is not defined?
Loading history...
869
        unset($num);
870
        $num = 1;
871
        if (in_array(1, $tableCategory)) {
872
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global_new_category', $tableSoleName, 'global_newcategory_notify', $num);
873
            ++$num;
874
        }
875
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'modify', 'global', 1, 'global_modify', $tableSoleName, 'global_' . 'modify_notify', $num);
876
        if (in_array(1, $tableBroken)) {
877
            ++$num;
878
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'broken', 'global', 1, 'global_broken', $tableSoleName, 'global_' . 'broken_notify', $num);
879
        }
880
        if (in_array(1, $tableSubmit)) {
881
            ++$num;
882
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'global', 1, 'global_submit', $tableSoleName, 'global_' . 'submit_notify', $num);
883
        }
884
        ++$num;
885
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'global', 0, 'global_new', $tableSoleName, 'global_new' . $tableSoleName . '_notify', $num);
886
        if (in_array(1, $tableCategory)) {
887
            ++$num;
888
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'category', 1, 'category_submit', $tableSoleName, 'category_' . $tableSoleName . 'submit_notify', $num);
889
            ++$num;
890
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'category', 0, 'category', $tableSoleName, 'category_new' . $tableSoleName . '_notify', $num);
891
        }
892
        ++$num;
893
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, $tableSoleName, $tableSoleName . '_approve_notify', $num);
894
        unset($num);
895
896
        return $ret;
897
    }
898
899
    /**
900
     * @private function getXoopsVersionNotificationGlobal
901
     * @param $language
902
     * @param $type
903
     * @param $name
904
     * @param $title
905
     * @param $from
906
     *
907
     * @param $num
908
     * @return string
909
     */
910
    private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num)
911
    {
912
        $phpCodeVNG  = Tdmcreate\Files\CreatePhpCode::getInstance();
913
        $uCodeVNG    = UserXoopsCode::getInstance();
914
        $title       = mb_strtoupper($title);
915
        $implodeFrom = implode(".php', '", $from);
916
        $ret         = $phpCodeVNG->getPhpCodeCommentLine('Global Notify');
917
        $global      = [
918
            'name'           => "'{$name}'",
919
            'title'          => "{$language}{$title}_NOTIFY",
920
            'description'    => "{$language}{$title}_NOTIFY_DESC",
921
            'subscribe_from' => "array('index.php', '{$implodeFrom}.php')",
922
        ];
923
        $ret         .= $uCodeVNG->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
924
925
        return $ret;
926
    }
927
928
    /**
929
     * @private function getXoopsVersionNotificationCategory
930
     * @param $language
931
     * @param $type
932
     * @param $name
933
     * @param $title
934
     * @param $file
935
     * @param $item
936
     * @param $allow
937
     * @param $num
938
     * @return string
939
     */
940
    private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num)
941
    {
942
        $phpCodeVNC = Tdmcreate\Files\CreatePhpCode::getInstance();
943
        $uCodeVNC   = UserXoopsCode::getInstance();
944
        $title      = mb_strtoupper($title);
945
        $impFile    = implode(".php', '", $file);
946
        $ret        = $phpCodeVNC->getPhpCodeCommentLine('Category Notify');
947
        $global     = [
948
            'name'           => "'{$name}'",
949
            'title'          => "{$language}{$title}_NOTIFY",
950
            'description'    => "{$language}{$title}_NOTIFY_DESC",
951
            'subscribe_from' => "array('{$impFile}.php')",
952
            'item_name'      => "'{$item}'",
953
            'allow_bookmark' => (string)$allow,
954
        ];
955
        $ret        .= $uCodeVNC->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
956
957
        return $ret;
958
    }
959
960
    /**
961
     * @private function getXoopsVersionNotificationTableName
962
     * @param $language
963
     * @param $type
964
     * @param $name
965
     * @param $title
966
     * @param $file
967
     * @param $item
968
     * @param $allow
969
     *
970
     * @param $num
971
     * @return string
972
     */
973
    private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow, $num)
974
    {
975
        $phpCodeVNTN = Tdmcreate\Files\CreatePhpCode::getInstance();
976
        $uCodeVNTN   = UserXoopsCode::getInstance();
977
        $stuTitle    = mb_strtoupper($title);
978
        $ucfTitle    = ucfirst($title);
979
        $ret         = $phpCodeVNTN->getPhpCodeCommentLine($ucfTitle . ' Notify');
980
        $table       = [
981
            'name'           => "'{$name}'",
982
            'title'          => "{$language}{$stuTitle}_NOTIFY",
983
            'description'    => "{$language}{$stuTitle}_NOTIFY_DESC",
984
            'subscribe_from' => "'{$file}.php'",
985
            'item_name'      => "'{$item}'",
986
            'allow_bookmark' => (string)$allow,
987
        ];
988
        $ret         .= $uCodeVNTN->getUserModVersion(4, $table, 'notification', "'{$type}'", $num);
989
990
        return $ret;
991
    }
992
993
    /**
994
     * @private function getXoopsVersionNotifications
995
     * @param $language
996
     * @param $type
997
     * @param $name
998
     * @param $category
999
     * @param $admin
1000
     * @param $title
1001
     * @param $table
1002
     * @param $mail
1003
     *
1004
     * @param $num
1005
     * @return string
1006
     */
1007
    private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $table, $mail, $num)
1008
    {
1009
        $phpCodeVNCC = Tdmcreate\Files\CreatePhpCode::getInstance();
1010
        $uCodeVNCC   = UserXoopsCode::getInstance();
1011
        $title       = mb_strtoupper($title);
1012
        $table       = mb_strtoupper($table);
0 ignored issues
show
Unused Code introduced by
The assignment to $table is dead and can be removed.
Loading history...
1013
        $ucfTitle    = ucfirst($title);
1014
        $ret         = $phpCodeVNCC->getPhpCodeCommentLine($ucfTitle . ' Notify');
1015
        $event       = [
1016
            'name'          => "'{$name}'",
1017
            'category'      => "'{$category}'",
1018
            'admin_only'    => (string)$admin,
1019
            'title'         => "{$language}{$title}_NOTIFY",
1020
            'caption'       => "{$language}{$title}_NOTIFY_CAPTION",
1021
            'description'   => "{$language}{$title}_NOTIFY_DESC",
1022
            'mail_template' => "'{$mail}'",
1023
            'mail_subject'  => "{$language}{$title}_NOTIFY_SUBJECT",
1024
        ];
1025
        $ret         .= $uCodeVNCC->getUserModVersion(4, $event, 'notification', "'{$type}'", $num);
1026
1027
        return $ret;
1028
    }
1029
1030
    /**
1031
     * @public function render
1032
     * @param null
1033
     * @return bool|string
1034
     */
1035
    public function render()
1036
    {
1037
        $module        = $this->getModule();
1038
        $table         = $this->getTable();
1039
        $tables        = $this->getTables();
1040
        $filename      = $this->getFileName();
1041
        $moduleDirname = $module->getVar('mod_dirname');
1042
        $language      = $this->getLanguage($moduleDirname, 'MI');
1043
        $content       = $this->getHeaderFilesComments($module, $filename);
1044
        $content       .= $this->getXoopsVersionHeader($module, $language);
1045
        if (1 == $module->getVar('mod_admin')) {
1046
            $content .= $this->getXoopsVersionTemplatesAdmin($moduleDirname, $tables);
1047
        }
1048
        if (1 == $module->getVar('mod_user')) {
1049
            $content .= $this->getXoopsVersionTemplatesUser($moduleDirname, $tables);
1050
        }
1051
        $content            .= $this->getXoopsVersionMySQL($moduleDirname, $table, $tables);
1052
        $tableSearch        = [];
1053
        $tableComments      = [];
1054
        $tableSubmenu       = [];
1055
        $tableBlocks        = [];
1056
        $tableNotifications = [];
1057
        foreach (array_keys($tables) as $t) {
1058
            $tableSearch[]        = $tables[$t]->getVar('table_search');
1059
            $tableComments[]      = $tables[$t]->getVar('table_comments');
1060
            $tableSubmenu[]       = $tables[$t]->getVar('table_submenu');
1061
            $tableBlocks[]        = $tables[$t]->getVar('table_blocks');
1062
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
1063
        }
1064
        if (in_array(1, $tableSearch)) {
1065
            $content .= $this->getXoopsVersionSearch($moduleDirname);
1066
        }
1067
        if (in_array(1, $tableComments)) {
1068
            $content .= $this->getXoopsVersionComments($moduleDirname);
1069
        }
1070
        if (in_array(1, $tableSubmenu)) {
1071
            $content .= $this->getXoopsVersionSubmenu($language, $tables);
1072
        }
1073
        if (in_array(1, $tableBlocks)) {
1074
            $content .= $this->getXoopsVersionBlocks($moduleDirname, $tables, $language);
1075
        }
1076
        $content .= $this->getXoopsVersionConfig($module, $tables, $language);
1077
        if (in_array(1, $tableNotifications)) {
1078
            $content .= $this->getXoopsVersionNotifications($module, $language);
1079
        }
1080
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
1081
1082
        return $this->renderFile();
1083
    }
1084
}
1085