Completed
Push — master ( 8e4f41...38ab27 )
by Goffy
03:18
created

UserXoopsVersion::getXoopsVersionConfig()   F

Complexity

Conditions 27
Paths 8736

Size

Total Lines 207
Code Lines 174

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 27
eloc 174
nc 8736
nop 3
dl 0
loc 207
rs 2
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
/*
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       XOOPS Project (https://xoops.org)
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: UserXoopsVersion.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
25
/**
26
 * Class UserXoopsVersion.
27
 */
28
class UserXoopsVersion extends TDMCreateFile
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

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

namespace YourVendor;

class YourClass { }

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

Loading history...
29
{
30
    /**
31
    * @var array
32
    */
33
    private $kw = [];
34
35
    /**
36
    *  @public function constructor
37
    *  @param null
38
    */
39
40
    public function __construct()
41
    {
42
        parent::__construct();
43
    }
44
45
    /**
46
    *  @static function getInstance
47
    *  @param null
48
     * @return UserXoopsVersion
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 $module
63
    *  @param mixed $table
64
    *  @param mixed $tables
65
    *  @param $filename
66
     */
67
    public function write($module, $table, $tables, $filename)
68
    {
69
        $this->setModule($module);
70
        $this->setTable($table);
71
        $this->setTables($tables);
72
        $this->setFileName($filename);
73
        foreach (array_keys($tables) as $t) {
74
            $tableName = $tables[$t]->getVar('table_name');
75
            $this->setKeywords($tableName);
76
        }
77
    }
78
79
    /**
80
    *  @public function setKeywords
81
    *  @param mixed $keywords
82
     */
83
    public function setKeywords($keywords)
84
    {
85
        if (is_array($keywords)) {
86
            $this->kw = $keywords;
87
        } else {
88
            $this->kw[] = $keywords;
89
        }
90
    }
91
92
    /**
93
    *  @public function getKeywords
94
    *  @param null
95
     * @return array
96
     */
97
    public function getKeywords()
98
    {
99
        return $this->kw;
100
    }
101
102
    /**
103
     * @private function getXoopsVersionHeader
104
     * @param $module
105
     * @param $language
106
     *
107
     * @return string
108
     */
109
    private function getXoopsVersionHeader($module, $language)
110
    {
111
        $xCodeVHeader = TDMCreateXoopsCode::getInstance();
112
        $uCodeVHeader = UserXoopsCode::getInstance();
113
        $date = date('Y/m/d');
114
        $ret = $this->getSimpleString('');
115
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine();
116
        $ret .= $xCodeVHeader->getXcEqualsOperator('$dirname ', 'basename(__DIR__)');
117
        $ret .= $this->getDashComment('Informations');
118
        $ha = (1 == $module->getVar('mod_admin')) ? 1 : 0;
119
        $hm = (1 == $module->getVar('mod_user')) ? 1 : 0;
120
121
        $descriptions = [
122
            'name'                                                                            => "{$language}NAME", 'version' => "{$module->getVar('mod_version')}", 'description' => "{$language}DESC",
123
            'author'                                                                          => "'{$module->getVar('mod_author')}'", 'author_mail' => "'{$module->getVar('mod_author_mail')}'", 'author_website_url' => "'{$module->getVar('mod_author_website_url')}'",
124
            'author_website_name'                                                             => "'{$module->getVar('mod_author_website_name')}'", 'credits' => "'{$module->getVar('mod_credits')}'", 'license' => "'{$module->getVar('mod_license')}'",
125
            'license_url' => "'http://www.gnu.org/licenses/gpl-3.0.en.html'", 'help' => "'page=help'", 'release_info' => "'{$module->getVar('mod_release_info')}'",
126
            'release_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'", 'release_date' => "'{$date}'",
127
            'manual' => "'{$module->getVar('mod_manual')}'", 'manual_file' => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'",
128
            'min_php' => "'{$module->getVar('mod_min_php')}'", 'min_xoops' => "'{$module->getVar('mod_min_xoops')}'", 'min_admin' => "'{$module->getVar('mod_min_admin')}'",
129
            'min_db' => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')", 'image' => "'assets/images/{$module->getVar('mod_image')}'",
130
            'dirname' => 'basename(__DIR__)', 'dirmoduleadmin' => "'Frameworks/moduleclasses/moduleadmin'", 'sysicons16' => "'../../Frameworks/moduleclasses/icons/16'",
131
            'sysicons32' => "'../../Frameworks/moduleclasses/icons/32'", 'modicons16' => "'assets/icons/16'", 'modicons32' => "'assets/icons/32'",
132
            'demo_site_url' => "'{$module->getVar('mod_demo_site_url')}'", 'demo_site_name' => "'{$module->getVar('mod_demo_site_name')}'", 'support_url' => "'{$module->getVar('mod_support_url')}'",
133
            'support_name' => "'{$module->getVar('mod_support_name')}'", 'module_website_url' => "'{$module->getVar('mod_website_url')}'", 'module_website_name' => "'{$module->getVar('mod_website_name')}'", 'release' => "'{$module->getVar('mod_release')}'", 'module_status' => "'{$module->getVar('mod_status')}'",
134
            'system_menu'                                                                     => '1', 'hasAdmin' => $ha, 'hasMain' => $hm, 'adminindex' => "'admin/index.php'", 'adminmenu' => "'admin/menu.php'",
135
            'onInstall'                                                                       => "'include/install.php'", 'onUpdate' => "'include/update.php'",
136
        ];
137
138
        $ret .= $uCodeVHeader->getUserModVersion(1, $descriptions);
139
140
        return $ret;
141
    }
142
143
    /**
144
    *  @private function getXoopsVersionMySQL
145
    *  @param $moduleDirname
146
    *  @param $table
147
     * @param $tables
148
     * @return string
149
     */
150
    private function getXoopsVersionMySQL($moduleDirname, $table, $tables)
151
    {
152
        $uCodeVMySQL = UserXoopsCode::getInstance();
153
        $tableName = $table->getVar('table_name');
154
        $n = 1;
155
        $ret = '';
156
        if (!empty($tableName)) {
157
            $ret .= $this->getDashComment('Mysql');
158
            $ret .= $uCodeVMySQL->getUserModVersion(2, "'sql/mysql.sql'", 'sqlfile', "'mysql'");
159
            $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables');
160
161
            foreach (array_keys($tables) as $t) {
162
                $ret .= $uCodeVMySQL->getUserModVersion(2, "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'", 'tables', $n);
163
                ++$n;
164
            }
165
            unset($n);
166
        }
167
168
        return $ret;
169
    }
170
171
    /**
172
    *  @private function getXoopsVersionSearch
173
     * @param $moduleDirname
174
     *
175
     * @return string
176
     */
177
    private function getXoopsVersionSearch($moduleDirname)
178
    {
179
        $uCodeVSearch = UserXoopsCode::getInstance();
180
        $ret = $this->getDashComment('Search');
181
        $ret .= $uCodeVSearch->getUserModVersion(1, 1, 'hasSearch');
182
        $ret .= $uCodeVSearch->getUserModVersion(2, "'include/search.inc.php'", 'search', "'file'");
183
        $ret .= $uCodeVSearch->getUserModVersion(2, "'{$moduleDirname}_search'", 'search', "'func'");
184
185
        return $ret;
186
    }
187
188
    /**
189
    *  @private function getXoopsVersionComments
190
    *  @param $moduleDirname
191
     *
192
     * @return string
193
     */
194
    private function getXoopsVersionComments($moduleDirname)
195
    {
196
        $uCodeVComments = UserXoopsCode::getInstance();
197
        $ret = $this->getDashComment('Comments');
198
        $ret .= $uCodeVComments->getUserModVersion(2, "'comments.php'", 'comments', "'pageName'");
199
        $ret .= $uCodeVComments->getUserModVersion(2, "'com_id'", 'comments', "'itemName'");
200
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions');
201
        $ret .= $uCodeVComments->getUserModVersion(2, "'include/comment_functions.php'", 'comments', "'callbackFile'");
202
        $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"];
203
        $ret .= $uCodeVComments->getUserModVersion(3, $descriptions, 'comments', "'callback'");
204
205
        return $ret;
206
    }
207
208
    /**
209
    *  @private function getXoopsVersionTemplatesAdmin
210
    *  @param $moduleDirname
211
     * @param $tables
212
     *
213
     * @return string
214
     */
215
    private function getXoopsVersionTemplatesAdmin($moduleDirname, $tables)
216
    {
217
        $ret = $this->getDashComment('Templates');
218
        $ret .= TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('Admin');
219
220
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true);
221
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true);
222
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true);
223
        $tablePermissions = [];
224
        foreach (array_keys($tables) as $t) {
225
            $tableName = $tables[$t]->getVar('table_name');
226
            $tablePermissions[] = $tables[$t]->getVar('table_permissions');
227
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true);
228
        }
229
        if (in_array(1, $tablePermissions)) {
230
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true);
231
        }
232
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true);
233
234
        return $ret;
235
    }
236
237
    /**
238
    *  @private function getXoopsVersionTemplatesLine
239
     * @param        $moduleDirname
240
     * @param        $type
241
     * @param string $extra
242
     * @param bool   $isAdmin
243
     * @return string
244
     */
245
    private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false)
246
    {
247
        $uCodeVTLine = UserXoopsCode::getInstance();
248
        $ret = '';
249
        $desc = "'description' => ''";
250
        $arrayFile = "array('file' =>";
251
        if ($isAdmin) {
252
            $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin')", 'templates', '');
253
        } else {
254
            if ('' !== $extra) {
255
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc})", 'templates', '');
256
            } else {
257
                $ret .= $uCodeVTLine->getUserModVersion(2, "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc})", 'templates', '');
258
            }
259
        }
260
261
        return $ret;
262
    }
263
264
    /**
265
    *  @private function getXoopsVersionTemplatesUser
266
    *  @param $moduleDirname
267
     * @param $tables
268
     * @return string
269
     */
270
    private function getXoopsVersionTemplatesUser($moduleDirname, $tables)
271
    {
272
        $ret = TDMCreatePhpCode::getInstance()->getPhpCodeCommentLine('User');
273
274
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '');
275
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '');
276
        $tableBroken = [];
277
        $tablePdf = [];
278
        $tablePrint = [];
279
        $tableRate = [];
280
        $tableRss = [];
281
        $tableSearch = [];
282
        $tableSingle = [];
283
        $tableSubmit = [];
284
        foreach (array_keys($tables) as $t) {
285
            $tableName = $tables[$t]->getVar('table_name');
286
            $tableBroken[] = $tables[$t]->getVar('table_broken');
287
            $tablePdf[] = $tables[$t]->getVar('table_pdf');
288
            $tablePrint[] = $tables[$t]->getVar('table_print');
289
            $tableRate[] = $tables[$t]->getVar('table_rate');
290
            $tableRss[] = $tables[$t]->getVar('table_rss');
291
            $tableSearch[] = $tables[$t]->getVar('table_search');
292
            $tableSingle[] = $tables[$t]->getVar('table_single');
293
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
294
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '');
295
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list');
296
        }
297
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs', '');
298
        if (in_array(1, $tableBroken)) {
299
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken', '');
300
        }
301
        if (in_array(1, $tablePdf)) {
302
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf', '');
303
        }
304
        if (in_array(1, $tablePrint)) {
305
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'print', '');
306
        }
307
        if (in_array(1, $tableRate)) {
308
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate', '');
309
        }
310
        if (in_array(1, $tableRss)) {
311
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss', '');
312
        }
313
        if (in_array(1, $tableSearch)) {
314
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'search', '');
315
        }
316
        if (in_array(1, $tableSingle)) {
317
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'single', '');
318
        }
319
        if (in_array(1, $tableSubmit)) {
320
            $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit', '');
321
        }
322
        $ret .= $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '');
323
324
        return $ret;
325
    }
326
327
    /**
328
    *  @private function getXoopsVersionSubmenu
329
       * @param $language
330
     * @param $tables
331
     * @return string
332
     */
333
    private function getXoopsVersionSubmenu($language, $tables)
334
    {
335
        $phpCodeVSubmenu = TDMCreatePhpCode::getInstance();
336
        $uCodeVSubmenu = UserXoopsCode::getInstance();
337
        $ret = $this->getDashComment('Submenu');
338
        $i = 1;
339
        $tableSubmit = [];
340
        foreach (array_keys($tables) as $t) {
341
            $tableName = $tables[$t]->getVar('table_name');
342
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
343
            if (1 == $tables[$t]->getVar('table_submenu')) {
344
                $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', $tableName);
345
                $tname = ['name' => "{$language}SMNAME{$i}", 'url' => "'{$tableName}.php'"];
346
                $ret .= $uCodeVSubmenu->getUserModVersion(3, $tname, 'sub', $i);
347
            }
348
            ++$i;
349
        }
350
        if (in_array(1, $tableSubmit)) {
351
            $ret .= $phpCodeVSubmenu->getPhpCodeCommentLine('Sub', 'Submit');
352
            $submit = ['name' => "{$language}SMNAME{$i}", 'url' => "'submit.php'"];
353
            $ret .= $uCodeVSubmenu->getUserModVersion(3, $submit, 'sub', $i);
354
        }
355
        unset($i);
356
357
        return $ret;
358
    }
359
360
    /**
361
    *  @private function getXoopsVersionBlocks
362
      * @param $moduleDirname
363
     * @param $tables
364
     * @param $language
365
     * @return string
366
     */
367
    private function getXoopsVersionBlocks($moduleDirname, $tables, $language)
368
    {
369
        $ret = $this->getDashComment('Blocks');
370
        $ret .= $this->getSimpleString('$b = 1;');
371
        $tableCategory = [];
372
        foreach (array_keys($tables) as $i) {
373
            $tableName = $tables[$i]->getVar('table_name');
374
            $tableFieldName = $tables[$i]->getVar('table_fieldname');
375
            $tableSoleName = $tables[$i]->getVar('table_solename');
376
            $stuTableSoleName = strtoupper($tableSoleName);
377
            $tableCategory[] = $tables[$i]->getVar('table_category');
378
            if (in_array(1, $tableCategory)) {
379
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $tableFieldName);
380
            } else {
381
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last');
382
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new');
383
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits');
384
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top');
385
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random');
386
            }
387
        }
388
        $ret .= $this->getSimpleString('unset($b);');
389
390
        return $ret;
391
    }
392
393
    /**
394
    *  @private function getXoopsVersionTypeBlocks
395
     * @param $moduleDirname
396
     * @param $tableName
397
     * @param $stuTableSoleName
398
     * @param $language
399
     * @param $type
400
     * @return string
401
     */
402
    private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type)
403
    {
404
        $phpCodeVTBlocks = TDMCreatePhpCode::getInstance();
405
        $uCodeVTBlocks = UserXoopsCode::getInstance();
406
        $stuTableName = strtoupper($tableName);
407
        $ucfTableName = ucfirst($tableName);
408
        $ret = $phpCodeVTBlocks->getPhpCodeCommentLine("{$ucfTableName}");
409
        $blocks = [
410
            'file'      => "'{$tableName}.php'", 'name' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}", 'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC",
411
            'show_func' => "'b_{$moduleDirname}_{$tableName}_show'", 'edit_func' => "'b_{$moduleDirname}_{$tableName}_edit'",
412
            'template'  => "'{$moduleDirname}_block_{$tableName}.tpl'", 'options' => "'{$type}|5|25|0'",
413
        ];
414
        $ret .= $uCodeVTBlocks->getUserModVersion(3, $blocks, 'blocks', '$b');
415
        $ret .= $this->getSimpleString('++$b;');
416
417
        return $ret;
418
    }
419
420
    /**
421
    *  @private function getXoopsVersionConfig
422
     * @param $module
423
     * @param $table
424
     * @param $language
425
     *
426
     * @return string
427
     */
428
    private function getXoopsVersionConfig($module, $tables, $language)
429
    {
430
        $phpCodeVConfig = TDMCreatePhpCode::getInstance();
431
        $xCodeVConfig = TDMCreateXoopsCode::getInstance();
432
        $uCodeVConfig = UserXoopsCode::getInstance();
433
        $moduleDirname = $module->getVar('mod_dirname');
434
        $ret = $this->getDashComment('Config');
435
        $ret .= $this->getSimpleString('$c = 1;');
436
		
437
		$table_permissions = 0;
438
		$table_admin = 0;
439
		$table_user = 0;
440
		$table_tag = 0;
441
		$field_images = 0;
442
		foreach ($tables as $table) {
443
			$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
444
			foreach (array_keys($fields) as $f) {
445
				$fieldElement = $fields[$f]->getVar('field_element');
446
				switch ($fieldElement) {
447
					case '3':
448
					case '4':
449
					case 3:
450
					case 4:	
451
						$fieldName = $fields[$f]->getVar('field_name');
452
						$rpFieldName = $this->getRightString($fieldName);
453
						$ucfFieldName = ucfirst($rpFieldName);
454
						$stuFieldName = strtoupper($rpFieldName);
455
						$ret .= $phpCodeVConfig->getPhpCodeCommentLine('Editor', $rpFieldName);
456
						$ret .= $xCodeVConfig->getXcLoad('xoopseditorhandler');
457
						$ret .= $xCodeVConfig->getXcEqualsOperator('$editorHandler'.$ucfFieldName, 'XoopsEditorHandler::getInstance()');
458
						$editor = [
459
							'name'     => "'editor_{$rpFieldName}'", 'title' => "'{$language}EDITOR_{$stuFieldName}'", 'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'",
460
							'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'dhtml'", 'options' => 'array_flip($editorHandler'.$ucfFieldName.'->getList())',
461
						];
462
						$ret .= $uCodeVConfig->getUserModVersion(3, $editor, 'config', '$c');
463
						$ret .= $this->getSimpleString('++$c;');
464
					break;
465
					
466
					case '10':
467
					case '11':
468
					case '12':
469
					case '13':
470
					case '14':
471
					case 10:
472
					case 11:
473
					case 12:
474
					case 13:
475
					case 14:
476
						$field_images = 1;
477
					break;
478
					case 'else':
479
					default:
480
					break;
481
				}
482
			}
483
			if (1 == $table->getVar('table_permissions')) { $table_permissions = 1;}
484
			if (1 == $table->getVar('table_admin')) { $table_admin = 1;}
485
			if (1 == $table->getVar('table_user')) { $table_user = 1;}
486
			if (1 == $table->getVar('table_tag')) { $table_tag = 1;}
487
		}
488
489
        if (1 === $table_permissions) {
490
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get groups');
491
            $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_gethandler('member')", '', false);
492
            $ret .= $xCodeVConfig->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()');
493
            $group = $xCodeVConfig->getXcEqualsOperator('$groups[$group] ', '$key', null, false, "\t");
494
            $ret .= $phpCodeVConfig->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group);
495
            $groups = [
496
                'name'     => "'groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'",
497
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$groups', 'options' => '$groups',
498
            ];
499
            $ret .= $uCodeVConfig->getUserModVersion(3, $groups, 'config', '$c');
500
            $ret .= $this->getSimpleString('++$c;');
501
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Get Admin groups');
502
            $ret .= $xCodeVConfig->getXcEqualsOperator('$criteria ', 'new CriteriaCompo()');
503
            $ret .= $this->getSimpleString("\$criteria->add( new Criteria( 'group_type', 'Admin' ) );");
504
            $ret .= $xCodeVConfig->getXcEqualsOperator('$memberHandler ', "xoops_gethandler('member')", '', false);
505
            $ret .= $xCodeVConfig->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($criteria)');
506
            $adminGroup = $xCodeVConfig->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, false, "\t");
507
            $ret .= $phpCodeVConfig->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup);
508
            $adminGroups = [
509
                'name'     => "'admin_groups'", 'title' => "'{$language}GROUPS'", 'description' => "'{$language}GROUPS_DESC'",
510
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => '$adminGroups', 'options' => '$adminGroups',
511
            ];
512
            $ret .= $uCodeVConfig->getUserModVersion(3, $adminGroups, 'config', '$c');
513
            $ret .= $this->getSimpleString('++$c;');
514
        }
515
        $keyword = implode(', ', $this->getKeywords());
516
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Keywords');
517
        $arrayKeyword = [
518
            'name'     => "'keywords'", 'title' => "'{$language}KEYWORDS'", 'description' => "'{$language}KEYWORDS_DESC'",
519
            'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$moduleDirname}, {$keyword}'",
520
        ];
521
        $ret .= $uCodeVConfig->getUserModVersion(3, $arrayKeyword, 'config', '$c');
522
        $ret .= $this->getSimpleString('++$c;');
523
        unset($this->keywords);
524
525
        if ( 1 === $field_images) {
526
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : maxsize of image');
527
            $maxsize = [
528
                'name'     => "'maxsize'", 'title' => "'{$language}MAXSIZE'", 'description' => "'{$language}MAXSIZE_DESC'",
529
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '5000000',
530
            ];
531
            $ret .= $uCodeVConfig->getUserModVersion(3, $maxsize, 'config', '$c');
532
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Uploads : mimetypes of image');
533
            $ret .= $this->getSimpleString('++$c;');
534
            $mimetypes = [
535
                'name'     => "'mimetypes'", 'title' => "'{$language}MIMETYPES'", 'description' => "'{$language}MIMETYPES_DESC'",
536
                'formtype' => "'select_multi'", 'valuetype' => "'array'", 'default' => "array('image/gif', 'image/jpeg', 'image/png')",
537
                'options'  => "array('bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png')",
538
            ];
539
            $ret .= $uCodeVConfig->getUserModVersion(3, $mimetypes, 'config', '$c');
540
            $ret .= $this->getSimpleString('++$c;');
541
        }
542
        if (1 === $table_admin) {
543
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Admin pager');
544
            $adminPager = [
545
                'name'     => "'adminpager'", 'title' => "'{$language}ADMIN_PAGER'", 'description' => "'{$language}ADMIN_PAGER_DESC'",
546
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10',
547
            ];
548
            $ret .= $uCodeVConfig->getUserModVersion(3, $adminPager, 'config', '$c');
549
            $ret .= $this->getSimpleString('++$c;');
550
        }
551
        if (1 === $table_user) {
552
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('User pager');
553
            $userPager = [
554
                'name'     => "'userpager'", 'title' => "'{$language}USER_PAGER'", 'description' => "'{$language}USER_PAGER_DESC'",
555
                'formtype' => "'textbox'", 'valuetype' => "'int'", 'default' => '10',
556
            ];
557
            $ret .= $uCodeVConfig->getUserModVersion(3, $userPager, 'config', '$c');
558
            $ret .= $this->getSimpleString('++$c;');
559
        }
560
        if (1 === $table_tag) {
561
            $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Use tag');
562
            $useTag = [
563
                'name'     => "'usetag'", 'title' => "'{$language}USE_TAG'", 'description' => "'{$language}USE_TAG_DESC'",
564
                'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
565
            ];
566
            $ret .= $uCodeVConfig->getUserModVersion(3, $useTag, 'config', '$c');
567
            $ret .= $this->getSimpleString('++$c;');
568
        }
569
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Number column');
570
        $numbCol = [
571
            'name'     => "'numb_col'", 'title' => "'{$language}NUMB_COL'", 'description' => "'{$language}NUMB_COL_DESC'",
572
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
573
        ];
574
        $ret .= $uCodeVConfig->getUserModVersion(3, $numbCol, 'config', '$c');
575
        $ret .= $this->getSimpleString('++$c;');
576
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Divide by');
577
        $divideby = [
578
            'name'     => "'divideby'", 'title' => "'{$language}DIVIDEBY'", 'description' => "'{$language}DIVIDEBY_DESC'",
579
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => '1', 'options' => "array(1 => '1', 2 => '2', 3 => '3', 4 => '4')",
580
        ];
581
        $ret .= $uCodeVConfig->getUserModVersion(3, $divideby, 'config', '$c');
582
        $ret .= $this->getSimpleString('++$c;');
583
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Table type');
584
        $tableType = [
585
            'name'     => "'table_type'", 'title' => "'{$language}TABLE_TYPE'", 'description' => "'{$language}DIVIDEBY_DESC'",
586
            'formtype' => "'select'", 'valuetype' => "'int'", 'default' => "'bordered'", 'options' => "array('bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed')",
587
        ];
588
        $ret .= $uCodeVConfig->getUserModVersion(3, $tableType, 'config', '$c');
589
        $ret .= $this->getSimpleString('++$c;');
590
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Panel by');
591
        $panelType = [
592
            'name'     => "'panel_type'", 'title' => "'{$language}PANEL_TYPE'", 'description' => "'{$language}PANEL_TYPE_DESC'",
593
            'formtype' => "'select'", 'valuetype' => "'text'", 'default' => "'default'", 'options' => "array('default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger')",
594
        ];
595
        $ret .= $uCodeVConfig->getUserModVersion(3, $panelType, 'config', '$c');
596
        $ret .= $this->getSimpleString('++$c;');
597
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Advertise');
598
        $advertise = [
599
            'name'     => "'advertise'", 'title' => "'{$language}ADVERTISE'", 'description' => "'{$language}ADVERTISE_DESC'",
600
            'formtype' => "'textarea'", 'valuetype' => "'text'", 'default' => "''",
601
        ];
602
        $ret .= $uCodeVConfig->getUserModVersion(3, $advertise, 'config', '$c');
603
        $ret .= $this->getSimpleString('++$c;');
604
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Bookmarks');
605
        $bookmarks = [
606
            'name'     => "'bookmarks'", 'title' => "'{$language}BOOKMARKS'", 'description' => "'{$language}BOOKMARKS_DESC'",
607
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
608
        ];
609
        $ret .= $uCodeVConfig->getUserModVersion(3, $bookmarks, 'config', '$c');
610
        $ret .= $this->getSimpleString('++$c;');
611
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Facebook Comments');
612
        $facebookComments = [
613
            'name'     => "'facebook_comments'", 'title' => "'{$language}FACEBOOK_COMMENTS'", 'description' => "'{$language}FACEBOOK_COMMENTS_DESC'",
614
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
615
        ];
616
        $ret .= $uCodeVConfig->getUserModVersion(3, $facebookComments, 'config', '$c');
617
        $ret .= $this->getSimpleString('++$c;');
618
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Disqus Comments');
619
        $disqusComments = [
620
            'name'     => "'disqus_comments'", 'title' => "'{$language}DISQUS_COMMENTS'", 'description' => "'{$language}DISQUS_COMMENTS_DESC'",
621
            'formtype' => "'yesno'", 'valuetype' => "'int'", 'default' => '0',
622
        ];
623
        $ret .= $uCodeVConfig->getUserModVersion(3, $disqusComments, 'config', '$c');
624
        $ret .= $this->getSimpleString('++$c;');
625
        $ret .= $phpCodeVConfig->getPhpCodeCommentLine('Maintained by');
626
        $maintainedby = [
627
            'name'     => "'maintainedby'", 'title' => "'{$language}MAINTAINEDBY'", 'description' => "'{$language}MAINTAINEDBY_DESC'",
628
            'formtype' => "'textbox'", 'valuetype' => "'text'", 'default' => "'{$module->getVar('mod_support_url')}'",
629
        ];
630
        $ret .= $uCodeVConfig->getUserModVersion(3, $maintainedby, 'config', '$c');
631
        $ret .= $this->getSimpleString('unset($c);');
632
633
        return $ret;
634
    }
635
636
    /**
637
    *  @private function getNotificationsType
638
     * @param $language
639
     * @param $type
640
     * @param $tableName
641
     * @param $notifyFile
642
     * @param $item
643
     * @param $typeOfNotify
644
     *
645
     * @return string
646
     */
647
    private function getNotificationsType($language, $type, $tableName, $notifyFile, $item, $typeOfNotify)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
648
    {
649
        $phpCodeNType = TDMCreatePhpCode::getInstance();
650
        $uCodeNType = UserXoopsCode::getInstance();
651
        $stuTableName = strtoupper($tableName);
652
        $stuTypeOfNotify = strtoupper($typeOfNotify);
653
        $notifyFile = explode(', ', $notifyFile);
654
        $notifyFile = implode(', ', $notifyFile);
655
        $ret = '';
656
        switch ($type) {
657
            case 'category':
658
                $ret .= $phpCodeNType->getPhpCodeCommentLine('Category Notify');
659
                $category = [
660
                    'name'           => "'category'", 'title' => "'{$language}{$stuTableName}_NOTIFY'", 'description' => "'{$language}{$stuTableName}_NOTIFY_DESC'",
661
                    'subscribe_from' => "array('index.php',{$notifyFile})", 'item_name' => "'{$item}'", "'allow_bookmark'" => '1',
662
                ];
663
                $ret .= $uCodeNType->getUserModVersion(3, $category, 'notification', "'{$type}'");
664
                break;
665
            case 'event':
666
                $ret .= $phpCodeNType->getPhpCodeCommentLine('Event Notify');
667
                $event = [
668
                    'name'          => "'{$typeOfNotify}'", 'category' => "'{$tableName}'", 'admin_only' => '1', "'title'" => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'",
669
                    'caption'       => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'", 'description' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'",
670
                    'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'", 'mail_subject' => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'",
671
                ];
672
                $ret .= $uCodeNType->getUserModVersion(3, $event, 'notification', "'{$type}'");
673
                break;
674
        }
675
676
        return $ret;
677
    }
678
679
    /**
680
    *  @private function getXoopsVersionNotifications
681
     * @param $module
682
     * @param $language
683
     * @return string
684
     */
685
    private function getXoopsVersionNotifications($module, $language)
686
    {
687
        $uCodeVN = UserXoopsCode::getInstance();
688
        $moduleDirname = $module->getVar('mod_dirname');
689
        $ret = $this->getDashComment('Notifications');
690
        $ret .= $uCodeVN->getUserModVersion(1, 1, 'hasNotification');
691
        $notifications = ["'lookup_file'" => "'include/notification.inc.php'", "'lookup_func'" => "'{$moduleDirname}_notify_iteminfo'"];
692
        $ret .= $uCodeVN->getUserModVersion(2, $notifications, 'notification');
693
694
        $notifyFiles = [];
695
        $single = 'single';
696
        $tables = $this->getTableTables($module->getVar('mod_id'), 'table_order');
697
        $tableCategory = [];
698
        $tableBroken = [];
699
        $tableSubmit = [];
700
        $tableId = null;
701
        $tableMid = null;
702
        foreach (array_keys($tables) as $t) {
703
            $tableId = $tables[$t]->getVar('table_id');
704
            $tableMid = $tables[$t]->getVar('table_mid');
705
            $tableName = $tables[$t]->getVar('table_name');
706
            $tableSoleName = $tables[$t]->getVar('table_solename');
707
            $tableCategory[] = $tables[$t]->getVar('table_category');
708
            $tableBroken[] = $tables[$t]->getVar('table_broken');
709
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
710
            if (1 == $tables[$t]->getVar('table_notifications')) {
711
                if ($t <= count($tableName)) {
712
                    $notifyFiles[] = $tables[$t]->getVar('table_name');
713
                }
714
            }
715
            if (1 == $tables[$t]->getVar('table_single')) {
716
                $single = $tableName;
717
            }
718
        }
719
        $fields = $this->getTableFields($tableMid, $tableId);
720
        $fieldId = null;
721
        $fieldParent = null;
722
        foreach (array_keys($fields) as $f) {
723
            $fieldName = $fields[$f]->getVar('field_name');
724
            $fieldElement = $fields[$f]->getVar('field_element');
725
            if (0 == $f) {
726
                $fieldId = $fieldName;
727
            }
728
            if ($fieldElement > 15) {
729
                $fieldParent = $fieldName;
730
            }
731
        }
732
733
        $num = 1;
734
        $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num);
735
        ++$num;
736
        $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num);
737
        ++$num;
738
        $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableSoleName, $tableSoleName, $single, $fieldId, 1, $num);
0 ignored issues
show
Bug introduced by
The variable $tableSoleName 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...
739
        unset($num);
740
        $num = 1;
741
        if (in_array(1, $tableCategory)) {
742
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global', 'newcategory', 'global_newcategory_notify', $num);
743
            ++$num;
744
        }
745
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName.'_modify', 'global', 1, 'global', $tableSoleName.'modify', 'global_'.$tableSoleName.'modify_notify', $num);
746
        if (in_array(1, $tableBroken)) {
747
            ++$num;
748
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName.'_broken', 'global', 1, 'global', $tableSoleName.'broken', 'global_'.$tableSoleName.'broken_notify', $num);
749
        }
750
        if (in_array(1, $tableSubmit)) {
751
            ++$num;
752
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName.'_submit', 'global', 1, 'global', $tableSoleName.'submit', 'global_'.$tableSoleName.'submit_notify', $num);
753
        }
754
        ++$num;
755
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_'.$tableSoleName, 'global', 0, 'global', 'new'.$tableSoleName, 'global_new'.$tableSoleName.'_notify', $num);
756
        if (in_array(1, $tableCategory)) {
757
            ++$num;
758
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', $tableSoleName.'_submit', 'category', 1, 'category', $tableSoleName.'submit', 'category_'.$tableSoleName.'submit_notify', $num);
759
            ++$num;
760
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_'.$tableSoleName, 'category', 0, 'category', 'new'.$tableSoleName, 'category_new'.$tableSoleName.'_notify', $num);
761
        }
762
        ++$num;
763
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, 'approve', $tableSoleName.'_approve_notify', $num);
764
        unset($num);
765
766
        return $ret;
767
    }
768
769
    /**
770
    *  @private function getXoopsVersionNotificationGlobal
771
     * @param $language
772
     * @param $type
773
     * @param $name
774
     * @param $title
775
     * @param $from
776
     *
777
     * @param $num
778
     * @return string
779
     */
780
    private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num)
781
    {
782
        $phpCodeVNG = TDMCreatePhpCode::getInstance();
783
        $uCodeVNG = UserXoopsCode::getInstance();
784
        $title = strtoupper($title);
785
        $implodeFrom = implode(".php', '", $from);
786
        $ret = $phpCodeVNG->getPhpCodeCommentLine('Global Notify');
787
        $global = [
788
            'name'           => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC",
789
            'subscribe_from' => "array('index.php', '{$implodeFrom}.php')",
790
        ];
791
        $ret .= $uCodeVNG->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
792
793
        return $ret;
794
    }
795
796
    /**
797
    *  @private function getXoopsVersionNotificationCategory
798
     * @param $language
799
     * @param $type
800
     * @param $name
801
     * @param $title
802
     * @param $file
803
     * @param $item
804
     * @param $allow
805
     * @param $num
806
     * @return string
807
     */
808
    private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num)
809
    {
810
        $phpCodeVNC = TDMCreatePhpCode::getInstance();
811
        $uCodeVNC = UserXoopsCode::getInstance();
812
        $title = strtoupper($title);
813
        $impFile = implode(".php', '", $file);
814
        $ret = $phpCodeVNC->getPhpCodeCommentLine('Category Notify');
815
        $global = [
816
            'name'           => "'{$name}'", 'title' => "{$language}{$title}_NOTIFY", 'description' => "{$language}{$title}_NOTIFY_DESC",
817
            'subscribe_from' => "array('{$impFile}.php')", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}",
818
        ];
819
        $ret .= $uCodeVNC->getUserModVersion(4, $global, 'notification', "'{$type}'", $num);
820
821
        return $ret;
822
    }
823
824
    /**
825
    *  @private function getXoopsVersionNotificationTableName
826
     * @param $language
827
     * @param $type
828
     * @param $name
829
     * @param $title
830
     * @param $file
831
     * @param $item
832
     * @param $allow
833
     *
834
     * @param $num
835
     * @return string
836
     */
837
    private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow, $num)
838
    {
839
        $phpCodeVNTN = TDMCreatePhpCode::getInstance();
840
        $uCodeVNTN = UserXoopsCode::getInstance();
841
        $stuTitle = strtoupper($title);
842
        $ucfTitle = ucfirst($title);
843
        $ret = $phpCodeVNTN->getPhpCodeCommentLine($ucfTitle.' Notify');
844
        $table = [
845
            'name'           => "'{$name}'", 'title' => "{$language}{$stuTitle}_NOTIFY", 'description' => "{$language}{$stuTitle}_NOTIFY_DESC",
846
            'subscribe_from' => "'{$file}.php'", 'item_name' => "'{$item}'", 'allow_bookmark' => "{$allow}",
847
        ];
848
        $ret .= $uCodeVNTN->getUserModVersion(4, $table, 'notification', "'{$type}'", $num);
849
850
        return $ret;
851
    }
852
853
    /**
854
    *  @private function getXoopsVersionNotifications
855
     * @param $language
856
     * @param $type
857
     * @param $name
858
     * @param $category
859
     * @param $admin
860
     * @param $title
861
     * @param $table
862
     * @param $mail
863
     *
864
     * @param $num
865
     * @return string
866
     */
867
    private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $table, $mail, $num)
868
    {
869
        $phpCodeVNCC = TDMCreatePhpCode::getInstance();
870
        $uCodeVNCC = UserXoopsCode::getInstance();
871
        $title = strtoupper($title);
872
        $table = strtoupper($table);
873
        $ucfTitle = ucfirst($title);
874
        $ret = $phpCodeVNCC->getPhpCodeCommentLine($ucfTitle.' Notify');
875
        $event = [
876
            'name'          => "'{$name}'", 'category' => "'{$category}'", 'admin_only' => "{$admin}", 'title' => "{$language}{$title}_{$table}_NOTIFY",
877
            'caption'       => "{$language}{$title}_{$table}_NOTIFY_CAPTION", 'description' => "{$language}{$title}_{$table}_NOTIFY_DESC",
878
            'mail_template' => "'{$mail}'", 'mail_subject' => "{$language}{$title}_{$table}_NOTIFY_SUBJECT",
879
        ];
880
        $ret .= $uCodeVNCC->getUserModVersion(4, $event, 'notification', "'{$type}'", $num);
881
882
        return $ret;
883
    }
884
885
    /**
886
    *  @public function render
887
    *  @param null
888
     * @return bool|string
889
     */
890
    public function render()
891
    {
892
        $module = $this->getModule();
893
        $table = $this->getTable();
894
        $tables = $this->getTables();
895
        $filename = $this->getFileName();
896
        $moduleDirname = $module->getVar('mod_dirname');
897
        $language = $this->getLanguage($moduleDirname, 'MI');
898
        $content = $this->getHeaderFilesComments($module, $filename);
899
        $content .= $this->getXoopsVersionHeader($module, $language);
900
        if (1 == $module->getVar('mod_admin')) {
901
            $content .= $this->getXoopsVersionTemplatesAdmin($moduleDirname, $tables);
902
        }
903
        if (1 == $module->getVar('mod_user')) {
904
            $content .= $this->getXoopsVersionTemplatesUser($moduleDirname, $tables);
905
        }
906
        $content .= $this->getXoopsVersionMySQL($moduleDirname, $table, $tables);
907
        $tableSearch = [];
908
        $tableComments = [];
909
        $tableSubmenu = [];
910
        $tableBlocks = [];
911
        $tableNotifications = [];
912
        foreach (array_keys($tables) as $t) {
913
            $tableSearch[] = $tables[$t]->getVar('table_search');
914
            $tableComments[] = $tables[$t]->getVar('table_comments');
915
            $tableSubmenu[] = $tables[$t]->getVar('table_submenu');
916
            $tableBlocks[] = $tables[$t]->getVar('table_blocks');
917
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
918
        }
919
        if (in_array(1, $tableSearch)) {
920
            $content .= $this->getXoopsVersionSearch($moduleDirname);
921
        }
922
        if (in_array(1, $tableComments)) {
923
            $content .= $this->getXoopsVersionComments($moduleDirname);
924
        }
925
        if (in_array(1, $tableSubmenu)) {
926
            $content .= $this->getXoopsVersionSubmenu($language, $tables);
927
        }
928
        if (in_array(1, $tableBlocks)) {
929
            $content .= $this->getXoopsVersionBlocks($moduleDirname, $tables, $language);
930
        }
931
		$content .= $this->getXoopsVersionConfig($module, $tables, $language);
932
        if (in_array(1, $tableNotifications)) {
933
            $content .= $this->getXoopsVersionNotifications($module, $language);
934
        }
935
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
936
937
        return $this->renderFile();
938
    }
939
}
940