UserXoopsVersion::getXoopsVersionMySQL()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 16
nc 2
nop 3
dl 0
loc 22
rs 9.7333
c 0
b 0
f 0
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
        $xc   = Tdmcreate\Files\CreateXoopsCode::getInstance();
115
        $uxc  = UserXoopsCode::getInstance();
116
        $date = date('Y/m/d');
117
        $ret  = $this->getSimpleString('');
118
        $ret  .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine();
119
        $ret  .= $xc->getXcEqualsOperator('$moduleDirName     ', 'basename(__DIR__)');
120
        $ret  .= $xc->getXcEqualsOperator('$moduleDirNameUpper', 'mb_strtoupper($moduleDirName)');
121
        $ret  .= $this->getDashComment('Informations');
122
        $ha   = (1 == $module->getVar('mod_admin')) ? 1 : 0;
123
        $hm   = (1 == $module->getVar('mod_user')) ? 1 : 0;
124
125
        $descriptions = [
126
            'name'                => "{$language}NAME",
127
            'version'             => (string)$module->getVar('mod_version'),
128
            'description'         => "{$language}DESC",
129
            'author'              => "'{$module->getVar('mod_author')}'",
130
            'author_mail'         => "'{$module->getVar('mod_author_mail')}'",
131
            'author_website_url'  => "'{$module->getVar('mod_author_website_url')}'",
132
            'author_website_name' => "'{$module->getVar('mod_author_website_name')}'",
133
            'credits'             => "'{$module->getVar('mod_credits')}'",
134
            'license'             => "'{$module->getVar('mod_license')}'",
135
            'license_url'         => "'http://www.gnu.org/licenses/gpl-3.0.en.html'",
136
            'help'                => "'page=help'",
137
            'release_info'        => "'{$module->getVar('mod_release_info')}'",
138
            'release_file'        => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_release_file')}'",
139
            'release_date'        => "'{$date}'",
140
            'manual'              => "'{$module->getVar('mod_manual')}'",
141
            'manual_file'         => "XOOPS_URL . '/modules/{$module->getVar('mod_dirname')}/docs/{$module->getVar('mod_manual_file')}'",
142
            'min_php'             => "'{$module->getVar('mod_min_php')}'",
143
            'min_xoops'           => "'{$module->getVar('mod_min_xoops')}'",
144
            'min_admin'           => "'{$module->getVar('mod_min_admin')}'",
145
            'min_db'              => "array('mysql' => '{$module->getVar('mod_min_mysql')}', 'mysqli' => '{$module->getVar('mod_min_mysql')}')",
146
            'image'               => "'assets/images/logoModule.png'",
147
            'dirname'             => 'basename(__DIR__)',
148
            'dirmoduleadmin'      => "'Frameworks/moduleclasses/moduleadmin'",
149
            'sysicons16'          => "'../../Frameworks/moduleclasses/icons/16'",
150
            'sysicons32'          => "'../../Frameworks/moduleclasses/icons/32'",
151
            'modicons16'          => "'assets/icons/16'",
152
            'modicons32'          => "'assets/icons/32'",
153
            'demo_site_url'       => "'{$module->getVar('mod_demo_site_url')}'",
154
            'demo_site_name'      => "'{$module->getVar('mod_demo_site_name')}'",
155
            'support_url'         => "'{$module->getVar('mod_support_url')}'",
156
            'support_name'        => "'{$module->getVar('mod_support_name')}'",
157
            'module_website_url'  => "'{$module->getVar('mod_website_url')}'",
158
            'module_website_name' => "'{$module->getVar('mod_website_name')}'",
159
            'release'             => "'{$module->getVar('mod_release')}'",
160
            'module_status'       => "'{$module->getVar('mod_status')}'",
161
            'system_menu'         => '1',
162
            'hasAdmin'            => $ha,
163
            'hasMain'             => $hm,
164
            'adminindex'          => "'admin/index.php'",
165
            'adminmenu'           => "'admin/menu.php'",
166
            'onInstall'           => "'include/install.php'",
167
            'onUninstall'         => "'include/uninstall.php'",
168
            'onUpdate'            => "'include/update.php'",
169
        ];
170
171
        $ret .= $uxc->getUserModVersionArray(0, $descriptions);
172
173
        return $ret;
174
    }
175
176
    /**
177
     * @private function getXoopsVersionMySQL
178
     * @param $moduleDirname
179
     * @param $table
180
     * @param $tables
181
     * @return string
182
     */
183
    private function getXoopsVersionMySQL($moduleDirname, $table, $tables)
184
    {
185
        $uxc       = UserXoopsCode::getInstance();
186
        $tableName = $table->getVar('table_name');
187
        $n         = 1;
188
        $ret       = '';
189
        $items     = [];
190
        if (!empty($tableName)) {
191
            $ret         .= $this->getDashComment('Mysql');
192
            $description = "'sql/mysql.sql'";
193
            $ret         .= $uxc->getUserModVersionText(2, $description, 'sqlfile', "'mysql'");
194
            $ret         .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Tables');
195
196
            foreach (array_keys($tables) as $t) {
197
                $items[] = "'{$moduleDirname}_{$tables[$t]->getVar('table_name')}'";
198
                ++$n;
199
            }
200
            $ret .= $uxc->getUserModVersionArray(11, $items, 'tables', $n);
201
            unset($n);
202
        }
203
204
        return $ret;
205
    }
206
207
    /**
208
     * @private function getXoopsVersionSearch
209
     * @param $moduleDirname
210
     *
211
     * @return string
212
     */
213
    private function getXoopsVersionSearch($moduleDirname)
214
    {
215
        $uxc   = UserXoopsCode::getInstance();
216
        $ret   = $this->getDashComment('Search');
217
        $ret   .= $uxc->getUserModVersionText(1, 1, 'hasSearch');
218
        $items = ['file' => "'include/search.inc.php'", 'func' => "'{$moduleDirname}_search'"];
219
        $ret   .= $uxc->getUserModVersionArray(1, $items, 'search');
220
221
        return $ret;
222
    }
223
224
    /**
225
     * @private function getXoopsVersionComments
226
     * @param $moduleDirname
227
     *
228
     * @return string
229
     */
230
    private function getXoopsVersionComments($moduleDirname)
231
    {
232
        $uxc = UserXoopsCode::getInstance();
233
        $ret          = $this->getDashComment('Comments');
234
        $ret          .= $uxc->getUserModVersionText(2, "'comments.php'", 'comments', "'pageName'");
235
        $ret          .= $uxc->getUserModVersionText(2, "'com_id'", 'comments', "'itemName'");
236
        $ret          .= Tdmcreate\Files\CreatePhpCode::getInstance()->getPhpCodeCommentLine('Comment callback functions');
237
        $ret          .= $uxc->getUserModVersionText(2, "'include/comment_functions.php'", 'comments', "'callbackFile'");
238
        $descriptions = ['approve' => "'{$moduleDirname}CommentsApprove'", 'update' => "'{$moduleDirname}CommentsUpdate'"];
239
        $ret          .= $uxc->getUserModVersionArray(2, $descriptions, 'comments', "'callback'");
240
241
        return $ret;
242
    }
243
244
    /**
245
     * @private function getXoopsVersionTemplatesAdminUser
246
     * @param $moduleDirname
247
     * @param $tables
248
     *
249
     * @param $admin
250
     * @param $user
251
     * @return string
252
     */
253
    private function getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $admin, $user)
254
    {
255
        $uxc  = UserXoopsCode::getInstance();
256
        $pc   = Tdmcreate\Files\CreatePhpCode::getInstance();
257
        $ret  = $this->getDashComment('Templates');
258
        $item = [];
259
        if ($admin) {
260
            $item[] = $pc->getPhpCodeCommentLine('Admin templates');
261
            $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'about', '', true);
262
            $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '', true);
263
            $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '', true);
264
            $tablePermissions = [];
265
            foreach (array_keys($tables) as $t) {
266
                $tableName          = $tables[$t]->getVar('table_name');
267
                $tablePermissions[] = $tables[$t]->getVar('table_permissions');
268
                $item[]             .= $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '', true);
269
            }
270
            if (in_array(1, $tablePermissions)) {
271
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'permissions', '', true);
272
            }
273
            $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '', true);
274
        }
275
276
        if ($user) {
277
            $item[]      = $pc->getPhpCodeCommentLine('User templates');
278
            $item[]      = $this->getXoopsVersionTemplatesLine($moduleDirname, 'header', '');
279
            $item[]      = $this->getXoopsVersionTemplatesLine($moduleDirname, 'index', '');
280
            $tableBroken = [];
281
            $tablePdf    = [];
282
            $tablePrint  = [];
283
            $tableRate   = [];
284
            $tableRss    = [];
285
            $tableSearch = [];
286
            $tableSingle = [];
287
            $tableSubmit = [];
288
            foreach (array_keys($tables) as $t) {
289
                $tableName     = $tables[$t]->getVar('table_name');
290
                $tableBroken[] = $tables[$t]->getVar('table_broken');
291
                $tablePdf[]    = $tables[$t]->getVar('table_pdf');
292
                $tablePrint[]  = $tables[$t]->getVar('table_print');
293
                $tableRate[]   = $tables[$t]->getVar('table_rate');
294
                $tableRss[]    = $tables[$t]->getVar('table_rss');
295
                $tableSearch[] = $tables[$t]->getVar('table_search');
296
                $tableSingle[] = $tables[$t]->getVar('table_single');
297
                $tableSubmit[] = $tables[$t]->getVar('table_submit');
298
                $item[]        = $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, '');
299
                $item[]        = $this->getXoopsVersionTemplatesLine($moduleDirname, $tableName, 'list');
300
            }
301
            $item[]  = $this->getXoopsVersionTemplatesLine($moduleDirname, 'breadcrumbs', '');
302
            if (in_array(1, $tableBroken)) {
303
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'broken', '');
304
            }
305
            if (in_array(1, $tablePdf)) {
306
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'pdf', '');
307
            }
308
            if (in_array(1, $tablePrint)) {
309
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'print', '');
310
            }
311
            if (in_array(1, $tableRate)) {
312
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'rate', '');
313
            }
314
            if (in_array(1, $tableRss)) {
315
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'rss', '');
316
            }
317
            if (in_array(1, $tableSearch)) {
318
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'search', '');
319
            }
320
            if (in_array(1, $tableSingle)) {
321
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'single', '');
322
            }
323
            if (in_array(1, $tableSubmit)) {
324
                $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'submit', '');
325
            }
326
            $item[] = $this->getXoopsVersionTemplatesLine($moduleDirname, 'footer', '');
327
        }
328
329
        $ret .= $uxc->getUserModVersionArray(11, $item, "templates");
330
331
        return $ret;
332
    }
333
334
    /**
335
     * @private function getXoopsVersionTemplatesLine
336
     * @param        $moduleDirname
337
     * @param        $type
338
     * @param string $extra
339
     * @param bool   $isAdmin
340
     * @return string
341
     */
342
    private function getXoopsVersionTemplatesLine($moduleDirname, $type, $extra = '', $isAdmin = false)
343
    {
344
        $ret         = '';
345
        $desc        = "'description' => ''";
346
        $arrayFile   = "['file' =>";
347
        if ($isAdmin) {
348
            $ret .= "{$arrayFile} '{$moduleDirname}_admin_{$type}.tpl', {$desc}, 'type' => 'admin']";
349
        } else {
350
            if ('' !== $extra) {
351
                $ret .= "{$arrayFile} '{$moduleDirname}_{$type}_{$extra}.tpl', {$desc}]";
352
            } else {
353
                $ret .= "{$arrayFile} '{$moduleDirname}_{$type}.tpl', {$desc}]";
354
            }
355
        }
356
357
        return $ret;
358
    }
359
360
    /**
361
     * @private function getXoopsVersionSubmenu
362
     * @param $language
363
     * @param $tables
364
     * @return string
365
     */
366
    private function getXoopsVersionSubmenu($language, $tables)
367
    {
368
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
369
        $uxc = UserXoopsCode::getInstance();
370
371
        $ret     = $this->getDashComment('Menu');
372
        $xModule = $pc->getPhpCodeGlobals('xoopsModule');
373
        $cond    = 'isset(' . $xModule . ') && is_object(' . $xModule . ')';
374
        $one     =  $pc->getPhpCodeGlobals('xoopsModule') . "->getVar('dirname')";
375
        $ret     .= $pc->getPhpCodeTernaryOperator('currdirname ', $cond, $one, "'system'");
376
377
        $i          = 1;
378
        $descriptions = [
379
            'name' => "{$language}SMNAME{$i}",
380
            'url'  => "'index.php'",
381
        ];
382
        $contentIf  = $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t");
0 ignored issues
show
Bug introduced by
'' of type string is incompatible with the type boolean expected by parameter $num of XoopsModules\Tdmcreate\F...etUserModVersionArray(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

382
        $contentIf  = $uxc->getUserModVersionArray(2, $descriptions, 'sub', '',/** @scrutinizer ignore-type */ '', "\t");
Loading history...
383
384
        $tableSubmit = [];
385
        $tableSearch = [];
386
        foreach (array_keys($tables) as $t) {
387
            $tableName     = $tables[$t]->getVar('table_name');
388
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
389
            $tableSearch[] = $tables[$t]->getVar('table_search');
390
            if (1 == $tables[$t]->getVar('table_submenu')) {
391
                $contentIf .= $pc->getPhpCodeCommentLine('Sub', $tableName, "\t");
392
                $descriptions = [
393
                    'name' => "{$language}SMNAME{$i}",
394
                    'url'  => "'{$tableName}.php'",
395
                ];
396
                $contentIf  .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t");
397
                unset($item);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $item seems to be never defined.
Loading history...
398
            }
399
            ++$i;
400
        }
401
        if (in_array(1, $tableSubmit)) {
402
            $contentIf .= $pc->getPhpCodeCommentLine('Sub', 'Submit', "\t");
403
            $descriptions = [
404
                'name' => "{$language}SMNAME{$i}",
405
                'url'  => "'submit.php'",
406
            ];
407
            $contentIf  .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t");
408
            ++$i;
409
        }
410
        //TODO: after finalizing creation of search.php by User/UserSearch.php this sub menu item can be activated
411
        /*
412
        if (in_array(1, $tableSearch)) {
413
            $contentIf .= $cpc->getPhpCodeCommentLine('Sub', 'Search', "\t");
414
            $descriptions = [
415
                'name' => "{$language}SMNAME{$i}",
416
                'url'  => "'search.php'",
417
            ];
418
            $contentIf  .= $uxc->getUserModVersionArray(2, $descriptions, 'sub', '','', "\t");
419
        }
420
        */
421
        unset($i);
422
423
        $ret .= $pc->getPhpCodeConditions('$moduleDirName', ' == ', '$currdirname', $contentIf);
424
425
        return $ret;
426
    }
427
428
    /**
429
     * @private function getXoopsVersionBlocks
430
     * @param $moduleDirname
431
     * @param $tables
432
     * @param $language
433
     * @return string
434
     */
435
    private function getXoopsVersionBlocks($moduleDirname, $tables, $language)
436
    {
437
        $ret           = $this->getDashComment('Blocks');
438
        $tableCategory = [];
439
        foreach (array_keys($tables) as $i) {
440
            $tableName        = $tables[$i]->getVar('table_name');
441
            $tableCategory[]  = $tables[$i]->getVar('table_category');
442
            if (0 == $tables[$i]->getVar('table_category')) {
443
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'LAST', $language, 'last');
444
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'NEW', $language, 'new');
445
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'HITS', $language, 'hits');
446
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'TOP', $language, 'top');
447
                $ret .= $this->getXoopsVersionTypeBlocks($moduleDirname, $tableName, 'RANDOM', $language, 'random');
448
            }
449
        }
450
451
        return $ret;
452
    }
453
454
    /**
455
     * @private function getXoopsVersionTypeBlocks
456
     * @param $moduleDirname
457
     * @param $tableName
458
     * @param $stuTableSoleName
459
     * @param $language
460
     * @param $type
461
     * @return string
462
     */
463
    private function getXoopsVersionTypeBlocks($moduleDirname, $tableName, $stuTableSoleName, $language, $type)
464
    {
465
        $pc  = Tdmcreate\Files\CreatePhpCode::getInstance();
466
        $uxc = UserXoopsCode::getInstance();
467
        $stuTableName    = mb_strtoupper($tableName);
468
        $ucfTableName    = ucfirst($tableName);
469
        $ret             = $pc->getPhpCodeCommentLine($ucfTableName . ' ' . $type);
470
        $blocks          = [
471
            'file'        => "'{$tableName}.php'",
472
            'name'        => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}",
473
            'description' => "{$language}{$stuTableName}_BLOCK_{$stuTableSoleName}_DESC",
474
            'show_func'   => "'b_{$moduleDirname}_{$tableName}_show'",
475
            'edit_func'   => "'b_{$moduleDirname}_{$tableName}_edit'",
476
            'template'    => "'{$moduleDirname}_block_{$tableName}.tpl'",
477
            'options'     => "'{$type}|5|25|0'",
478
        ];
479
        $ret             .= $uxc->getUserModVersionArray(2, $blocks, 'blocks');
480
481
        return $ret;
482
    }
483
484
    /**
485
     * @private function getXoopsVersionConfig
486
     * @param $module
487
     * @param $tables
488
     * @param $language
489
     *
490
     * @return string
491
     */
492
    private function getXoopsVersionConfig($module, $tables, $language)
493
    {
494
        $pc  = Tdmcreate\Files\CreatePhpCode::getInstance();
495
        $xc  = Tdmcreate\Files\CreateXoopsCode::getInstance();
496
        $uxc = UserXoopsCode::getInstance();
497
        $moduleDirname  = $module->getVar('mod_dirname');
498
        $ret            = $this->getDashComment('Config');
499
500
        $table_permissions = 0;
501
        $table_admin       = 0;
502
        $table_user        = 0;
503
        $table_tag         = 0;
504
        $table_uploadimage = 0;
505
        $table_uploadfile  = 0;
506
        foreach ($tables as $table) {
507
            $fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id'));
508
            foreach (array_keys($fields) as $f) {
509
                $fieldElement = (int)$fields[$f]->getVar('field_element');
510
                switch ($fieldElement) {
511
                    case 3:
512
                    case 4:
513
                        $fieldName    = $fields[$f]->getVar('field_name');
514
                        $rpFieldName  = $this->getRightString($fieldName);
515
                        $ucfFieldName = ucfirst($rpFieldName);
516
                        $stuFieldName = mb_strtoupper($rpFieldName);
517
                        $ret          .= $pc->getPhpCodeCommentLine('Editor', $rpFieldName);
518
                        $ret          .= $xc->getXcXoopsLoad('xoopseditorhandler');
519
                        $ret          .= $xc->getXcEqualsOperator('$editorHandler' . $ucfFieldName, 'XoopsEditorHandler::getInstance()');
520
                        $editor       = [
521
                            'name'        => "'editor_{$rpFieldName}'",
522
                            'title'       => "'{$language}EDITOR_{$stuFieldName}'",
523
                            'description' => "'{$language}EDITOR_{$stuFieldName}_DESC'",
524
                            'formtype'    => "'select'",
525
                            'valuetype'   => "'text'",
526
                            'default'     => "'dhtml'",
527
                            'options'     => 'array_flip($editorHandler' . $ucfFieldName . '->getList())',
528
                        ];
529
                        $ret          .= $uxc->getUserModVersionArray(2, $editor, 'config');
530
                        break;
531
                    case 10:
532
                    case 11:
533
                    case 12:
534
                    case 13:
535
                        $table_uploadimage = 1;
536
                        break;
537
                    case 14:
538
                        $table_uploadfile = 1;
539
                        break;
540
                    case 'else':
541
                    default:
542
                        break;
543
                }
544
            }
545
            if (1 == $table->getVar('table_permissions')) {
546
                $table_permissions = 1;
547
            }
548
            if (1 == $table->getVar('table_admin')) {
549
                $table_admin = 1;
550
            }
551
            if (1 == $table->getVar('table_user')) {
552
                $table_user = 1;
553
            }
554
            if (1 == $table->getVar('table_tag')) {
555
                $table_tag = 1;
556
            }
557
        }
558
559
        if (1 === $table_permissions) {
560
            $ret    .= $pc->getPhpCodeCommentLine('Get groups');
561
            $ret    .= $xc->getXcXoopsHandler('member');
562
            $ret    .= $xc->getXcEqualsOperator('$xoopsGroups ', '$memberHandler->getGroupList()');
563
            $ret    .= $xc->getXcEqualsOperator('$groups', '[]');
564
            $group  = $xc->getXcEqualsOperator('$groups[$group] ', '$key', null, "\t");
565
            $ret    .= $pc->getPhpCodeForeach('xoopsGroups', false, 'key', 'group', $group);
566
            $ret    .= $pc->getPhpCodeCommentLine('General access groups');
567
            $groups = [
568
                'name'        => "'groups'",
569
                'title'       => "'{$language}GROUPS'",
570
                'description' => "'{$language}GROUPS_DESC'",
571
                'formtype'    => "'select_multi'",
572
                'valuetype'   => "'array'",
573
                'default'     => '$groups',
574
                'options'     => '$groups',
575
            ];
576
            $ret .= $uxc->getUserModVersionArray(2, $groups, 'config');
577
            $ret .= $pc->getPhpCodeCommentLine('Upload groups');
578
            $uplgroups  = [
579
                'name'        => "'upload_groups'",
580
                'title'       => "'{$language}UPLOAD_GROUPS'",
581
                'description' => "'{$language}UPLOAD_GROUPS_DESC'",
582
                'formtype'    => "'select_multi'",
583
                'valuetype'   => "'array'",
584
                'default'     => '$groups',
585
                'options'     => '$groups',
586
            ];
587
            $ret         .= $uxc->getUserModVersionArray(2, $uplgroups, 'config');
588
589
            $ret         .= $pc->getPhpCodeCommentLine('Get Admin groups');
590
            $ret         .= $xc->getXcCriteriaCompo('crGroups');
591
            $crit        = $xc->getXcCriteria('', "'group_type'", "'Admin'", '', true);
592
            $ret         .= $xc->getXcCriteriaAdd('crGroups', $crit, '', "\n");
593
            $ret         .= $xc->getXcXoopsHandler('member');
594
            $ret         .= $xc->getXcEqualsOperator('$adminXoopsGroups ', '$memberHandler->getGroupList($crGroups)');
595
            $ret         .= $xc->getXcEqualsOperator('$adminGroups', '[]');
596
            $adminGroup  = $xc->getXcEqualsOperator('$adminGroups[$adminGroup] ', '$key', null, "\t");
597
            $ret         .= $pc->getPhpCodeForeach('adminXoopsGroups', false, 'key', 'adminGroup', $adminGroup);
598
            $adminGroups = [
599
                'name'        => "'admin_groups'",
600
                'title'       => "'{$language}ADMIN_GROUPS'",
601
                'description' => "'{$language}ADMIN_GROUPS_DESC'",
602
                'formtype'    => "'select_multi'",
603
                'valuetype'   => "'array'",
604
                'default'     => '$adminGroups',
605
                'options'     => '$adminGroups',
606
            ];
607
            $ret         .= $uxc->getUserModVersionArray(2, $adminGroups, 'config');
608
			$ret         .= $pc->getPhpCodeUnset('crGroups');
609
        }
610
        $keyword      = implode(', ', $this->getKeywords());
611
        $ret          .= $pc->getPhpCodeCommentLine('Keywords');
612
        $arrayKeyword = [
613
            'name'        => "'keywords'",
614
            'title'       => "'{$language}KEYWORDS'",
615
            'description' => "'{$language}KEYWORDS_DESC'",
616
            'formtype'    => "'textbox'",
617
            'valuetype'   => "'text'",
618
            'default'     => "'{$moduleDirname}, {$keyword}'",
619
        ];
620
        $ret .= $uxc->getUserModVersionArray(2, $arrayKeyword, 'config');
621
        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...
622
623
        if (1 === $table_uploadimage || 1 === $table_uploadfile) {
624
            $ret       .= $this->getXoopsVersionSelectSizeMB($moduleDirname);
625
        }
626
        if (1 === $table_uploadimage) {
627
            $ret .= $pc->getPhpCodeCommentLine('Uploads : maxsize of image');
628
            $maxsize_image    = [
629
                'name'        => "'maxsize_image'",
630
                'title'       => "'{$language}MAXSIZE_IMAGE'",
631
                'description' => "'{$language}MAXSIZE_IMAGE_DESC'",
632
                'formtype'    => "'select'",
633
                'valuetype'   => "'int'",
634
                'default'     => '3145728',
635
                'options'     => '$optionMaxsize',
636
            ];
637
            $ret .= $uxc->getUserModVersionArray(2, $maxsize_image, 'config');
638
            $ret .= $pc->getPhpCodeCommentLine('Uploads : mimetypes of image');
639
            $mimetypes_image  = [
640
                'name'        => "'mimetypes_image'",
641
                'title'       => "'{$language}MIMETYPES_IMAGE'",
642
                'description' => "'{$language}MIMETYPES_IMAGE_DESC'",
643
                'formtype'    => "'select_multi'",
644
                'valuetype'   => "'array'",
645
                'default'     => "['image/gif', 'image/jpeg', 'image/png']",
646
                'options'     => "['bmp' => 'image/bmp','gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png']",
647
            ];
648
            $ret .= $uxc->getUserModVersionArray(2, $mimetypes_image, 'config');
649
            $maxwidth_image   = [
650
                'name'        => "'maxwidth_image'",
651
                'title'       => "'{$language}MAXWIDTH_IMAGE'",
652
                'description' => "'{$language}MAXWIDTH_IMAGE_DESC'",
653
                'formtype'    => "'textbox'",
654
                'valuetype'   => "'int'",
655
                'default'     => '8000',
656
            ];
657
            $ret .= $uxc->getUserModVersionArray(2, $maxwidth_image, 'config');
658
            $maxheight_image   = [
659
                'name'        => "'maxheight_image'",
660
                'title'       => "'{$language}MAXHEIGHT_IMAGE'",
661
                'description' => "'{$language}MAXHEIGHT_IMAGE_DESC'",
662
                'formtype'    => "'textbox'",
663
                'valuetype'   => "'int'",
664
                'default'     => '8000',
665
            ];
666
            $ret .= $uxc->getUserModVersionArray(2, $maxheight_image, 'config');
667
        }
668
        if (1 === $table_uploadfile) {
669
            $ret .= $pc->getPhpCodeCommentLine('Uploads : maxsize of file');
670
            $maxsize_file     = [
671
                'name'        => "'maxsize_file'",
672
                'title'       => "'{$language}MAXSIZE_FILE'",
673
                'description' => "'{$language}MAXSIZE_FILE_DESC'",
674
                'formtype'    => "'select'",
675
                'valuetype'   => "'int'",
676
                'default'     => '3145728',
677
                'options'     => '$optionMaxsize',
678
            ];
679
            $ret .= $uxc->getUserModVersionArray(2, $maxsize_file, 'config');
680
            $ret .= $pc->getPhpCodeCommentLine('Uploads : mimetypes of file');
681
            $mimetypes_file   = [
682
                'name'        => "'mimetypes_file'",
683
                'title'       => "'{$language}MIMETYPES_FILE'",
684
                'description' => "'{$language}MIMETYPES_FILE_DESC'",
685
                'formtype'    => "'select_multi'",
686
                'valuetype'   => "'array'",
687
                'default'     => "['application/pdf', 'application/zip', 'text/comma-separated-values', 'text/plain', 'image/gif', 'image/jpeg', 'image/png']",
688
                'options'     => "['gif' => 'image/gif','pjpeg' => 'image/pjpeg', 'jpeg' => 'image/jpeg','jpg' => 'image/jpg','jpe' => 'image/jpe', 'png' => 'image/png', 'pdf' => 'application/pdf','zip' => 'application/zip','csv' => 'text/comma-separated-values', 'txt' => 'text/plain', 'xml' => 'application/xml', 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']",
689
            ];
690
            $ret .= $uxc->getUserModVersionArray(2, $mimetypes_file, 'config');
691
        }
692
        if (1 === $table_admin) {
693
            $ret .= $pc->getPhpCodeCommentLine('Admin pager');
694
            $adminPager = [
695
                'name'        => "'adminpager'",
696
                'title'       => "'{$language}ADMIN_PAGER'",
697
                'description' => "'{$language}ADMIN_PAGER_DESC'",
698
                'formtype'    => "'textbox'",
699
                'valuetype'   => "'int'",
700
                'default'     => '10',
701
            ];
702
            $ret .= $uxc->getUserModVersionArray(2, $adminPager, 'config');
703
        }
704
        if (1 === $table_user) {
705
            $ret .= $pc->getPhpCodeCommentLine('User pager');
706
            $userPager = [
707
                'name'        => "'userpager'",
708
                'title'       => "'{$language}USER_PAGER'",
709
                'description' => "'{$language}USER_PAGER_DESC'",
710
                'formtype'    => "'textbox'",
711
                'valuetype'   => "'int'",
712
                'default'     => '10',
713
            ];
714
            $ret .= $uxc->getUserModVersionArray(2, $userPager, 'config');
715
        }
716
        if (1 === $table_tag) {
717
            $ret .= $pc->getPhpCodeCommentLine('Use tag');
718
            $useTag = [
719
                'name'        => "'usetag'",
720
                'title'       => "'{$language}USE_TAG'",
721
                'description' => "'{$language}USE_TAG_DESC'",
722
                'formtype'    => "'yesno'",
723
                'valuetype'   => "'int'",
724
                'default'     => '0',
725
            ];
726
            $ret .= $uxc->getUserModVersionArray(2, $useTag, 'config');
727
        }
728
        $ret .= $pc->getPhpCodeCommentLine('Number column');
729
        $numbCol          = [
730
            'name'        => "'numb_col'",
731
            'title'       => "'{$language}NUMB_COL'",
732
            'description' => "'{$language}NUMB_COL_DESC'",
733
            'formtype'    => "'select'",
734
            'valuetype'   => "'int'",
735
            'default'     => '1',
736
            'options'     => "[1 => '1', 2 => '2', 3 => '3', 4 => '4']",
737
        ];
738
        $ret .= $uxc->getUserModVersionArray(2, $numbCol, 'config');
739
740
        $ret .= $pc->getPhpCodeCommentLine('Divide by');
741
        $divideby         = [
742
            'name'        => "'divideby'",
743
            'title'       => "'{$language}DIVIDEBY'",
744
            'description' => "'{$language}DIVIDEBY_DESC'",
745
            'formtype'    => "'select'",
746
            'valuetype'   => "'int'",
747
            'default'     => '1',
748
            'options'     => "[1 => '1', 2 => '2', 3 => '3', 4 => '4']",
749
        ];
750
        $ret .= $uxc->getUserModVersionArray(2, $divideby, 'config');
751
752
        $ret .= $pc->getPhpCodeCommentLine('Table type');
753
        $tableType        = [
754
            'name'        => "'table_type'",
755
            'title'       => "'{$language}TABLE_TYPE'",
756
            'description' => "'{$language}DIVIDEBY_DESC'",
757
            'formtype'    => "'select'",
758
            'valuetype'   => "'int'",
759
            'default'     => "'bordered'",
760
            'options'     => "['bordered' => 'bordered', 'striped' => 'striped', 'hover' => 'hover', 'condensed' => 'condensed']",
761
        ];
762
        $ret              .= $uxc->getUserModVersionArray(2, $tableType, 'config');
763
764
        $ret              .= $pc->getPhpCodeCommentLine('Panel by');
765
        $panelType        = [
766
            'name'        => "'panel_type'",
767
            'title'       => "'{$language}PANEL_TYPE'",
768
            'description' => "'{$language}PANEL_TYPE_DESC'",
769
            'formtype'    => "'select'",
770
            'valuetype'   => "'text'",
771
            'default'     => "'default'",
772
            'options'     => "['default' => 'default', 'primary' => 'primary', 'success' => 'success', 'info' => 'info', 'warning' => 'warning', 'danger' => 'danger']",
773
        ];
774
        $ret              .= $uxc->getUserModVersionArray(2, $panelType, 'config');
775
776
        $ret              .= $pc->getPhpCodeCommentLine('Advertise');
777
        $advertise        = [
778
            'name'        => "'advertise'",
779
            'title'       => "'{$language}ADVERTISE'",
780
            'description' => "'{$language}ADVERTISE_DESC'",
781
            'formtype'    => "'textarea'",
782
            'valuetype'   => "'text'",
783
            'default'     => "''",
784
        ];
785
        $ret              .= $uxc->getUserModVersionArray(2, $advertise, 'config');
786
787
        $ret              .= $pc->getPhpCodeCommentLine('Bookmarks');
788
        $bookmarks        = [
789
            'name'        => "'bookmarks'",
790
            'title'       => "'{$language}BOOKMARKS'",
791
            'description' => "'{$language}BOOKMARKS_DESC'",
792
            'formtype'    => "'yesno'",
793
            'valuetype'   => "'int'",
794
            'default'     => '0',
795
        ];
796
        $ret              .= $uxc->getUserModVersionArray(2, $bookmarks, 'config');
797
798
        /*
799
         * removed, as there are no system templates in xoops core for fb or disqus comments
800
         * tdmcreate currently is also not creatings tpl files for this
801
        $ret              .= $pc->getPhpCodeCommentLine('Facebook Comments');
802
        $facebookComments = [
803
            'name'        => "'facebook_comments'",
804
            'title'       => "'{$language}FACEBOOK_COMMENTS'",
805
            'description' => "'{$language}FACEBOOK_COMMENTS_DESC'",
806
            'formtype'    => "'yesno'",
807
            'valuetype'   => "'int'",
808
            'default'     => '0',
809
        ];
810
        $ret              .= $uxc->getUserModVersion(3, $facebookComments, 'config', '$c');
811
        $ret              .= $this->getSimpleString('++$c;');
812
        $ret              .= $pc->getPhpCodeCommentLine('Disqus Comments');
813
        $disqusComments   = [
814
            'name'        => "'disqus_comments'",
815
            'title'       => "'{$language}DISQUS_COMMENTS'",
816
            'description' => "'{$language}DISQUS_COMMENTS_DESC'",
817
            'formtype'    => "'yesno'",
818
            'valuetype'   => "'int'",
819
            'default'     => '0',
820
        ];
821
        $ret              .= $uxc->getUserModVersion(3, $disqusComments, 'config', '$c');
822
        $ret              .= $this->getSimpleString('++$c;');
823
        */
824
825
        $ret              .= $pc->getPhpCodeCommentLine('Make Sample button visible?');
826
        $maintainedby     = [
827
            'name'        => "'displaySampleButton'",
828
            'title'       => "'CO_' . \$moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON'",
829
            'description' => "'CO_' . \$moduleDirNameUpper . '_' . 'SHOW_SAMPLE_BUTTON_DESC'",
830
            'formtype'    => "'yesno'",
831
            'valuetype'   => "'int'",
832
            'default'     => '1',
833
        ];
834
        $ret              .= $uxc->getUserModVersionArray(2, $maintainedby, 'config');
835
836
        $ret              .= $pc->getPhpCodeCommentLine('Maintained by');
837
        $maintainedby     = [
838
            'name'        => "'maintainedby'",
839
            'title'       => "'{$language}MAINTAINEDBY'",
840
            'description' => "'{$language}MAINTAINEDBY_DESC'",
841
            'formtype'    => "'textbox'",
842
            'valuetype'   => "'text'",
843
            'default'     => "'{$module->getVar('mod_support_url')}'",
844
        ];
845
        $ret              .= $uxc->getUserModVersionArray(2, $maintainedby, 'config');
846
847
        return $ret;
848
    }
849
850
    /**
851
     * @private function getNotificationsType
852
     * @param $language
853
     * @param $type
854
     * @param $tableName
855
     * @param $notifyFile
856
     * @param $item
857
     * @param $typeOfNotify
858
     *
859
     * @return string
860
     */
861
    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...
862
    {
863
        $pc              = Tdmcreate\Files\CreatePhpCode::getInstance();
864
        $uxc             = UserXoopsCode::getInstance();
865
        $stuTableName    = mb_strtoupper($tableName);
866
        $stuTypeOfNotify = mb_strtoupper($typeOfNotify);
867
        $notifyFile      = explode(', ', $notifyFile);
868
        $notifyFile      = implode(', ', $notifyFile);
869
        $ret             = '';
870
        switch ($type) {
871
            case 'category':
872
                $ret      .= $pc->getPhpCodeCommentLine('Category Notify');
873
                $category = [
874
                    'name'             => "'category'",
875
                    'title'            => "'{$language}{$stuTableName}_NOTIFY'",
876
                    'description'      => "'{$language}{$stuTableName}_NOTIFY_DESC'",
877
                    'subscribe_from'   => "['index.php',{$notifyFile}]",
878
                    'item_name'        => "'{$item}'",
879
                    "'allow_bookmark'" => '1',
880
                ];
881
                $ret      .= $uxc->getUserModVersionArray(2, $category, 'notification', "'{$type}'");
882
                break;
883
            case 'event':
884
                $ret   .= $pc->getPhpCodeCommentLine('Event Notify');
885
                $event = [
886
                    'name'          => "'{$typeOfNotify}'",
887
                    'category'      => "'{$tableName}'",
888
                    'admin_only'    => '1',
889
                    "'title'"       => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY'",
890
                    'caption'       => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_CAPTION'",
891
                    'description'   => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_DESC'",
892
                    'mail_template' => "'{$tableName}_{$typeOfNotify}_notify'",
893
                    'mail_subject'  => "'{$language}{$stuTableName}_{$stuTypeOfNotify}_NOTIFY_SUBJECT'",
894
                ];
895
                $ret   .= $uxc->getUserModVersionArray(2, $event, 'notification', "'{$type}'");
896
                break;
897
        }
898
899
        return $ret;
900
    }
901
902
    /**
903
     * @private function getXoopsVersionNotifications
904
     * @param $module
905
     * @param $language
906
     * @return string
907
     */
908
    private function getXoopsVersionNotifications($module, $language)
909
    {
910
        $uxc           = UserXoopsCode::getInstance();
911
        $moduleDirname = $module->getVar('mod_dirname');
912
        $ret           = $this->getDashComment('Notifications');
913
        $ret           .= $uxc->getUserModVersionText(1, 1, 'hasNotification');
914
        $notifications = ['lookup_file' => "'include/notification.inc.php'", 'lookup_func' => "'{$moduleDirname}_notify_iteminfo'"];
915
        $ret           .= $uxc->getUserModVersionArray(1, $notifications, 'notification');
916
917
        $notifyFiles   = [];
918
        $single        = 'single';
919
        $tables        = $this->getTableTables($module->getVar('mod_id'), 'table_order');
920
        $tableCategory = [];
921
        $tableBroken   = [];
922
        $tableSubmit   = [];
923
        $tableId       = null;
924
        $tableMid      = null;
925
        $tableSoleName = '';
926
        foreach (array_keys($tables) as $t) {
927
            $tableId         = $tables[$t]->getVar('table_id');
928
            $tableMid        = $tables[$t]->getVar('table_mid');
929
            $tableName       = $tables[$t]->getVar('table_name');
930
            $tableSoleName   = $tables[$t]->getVar('table_solename');
931
            $tableCategory[] = $tables[$t]->getVar('table_category');
932
            $tableBroken[]   = $tables[$t]->getVar('table_broken');
933
            $tableSubmit[]   = $tables[$t]->getVar('table_submit');
934
            if (1 == $tables[$t]->getVar('table_notifications')) {
935
                //if ($t <= count($tableName)) {
936
                    $notifyFiles[] = $tableName;
937
                //}
938
            }
939
            if (1 == $tables[$t]->getVar('table_single')) {
940
                $single = $tableName;
941
            }
942
        }
943
        $fields      = $this->getTableFields($tableMid, $tableId);
944
        $fieldId     = null;
945
        $fieldParent = null;
946
        foreach (array_keys($fields) as $f) {
947
            $fieldName    = $fields[$f]->getVar('field_name');
948
            $fieldElement = $fields[$f]->getVar('field_element');
949
            if (0 == $f) {
950
                $fieldId = $fieldName;
951
            }
952
            if ($fieldElement > 16) {
953
                $fieldParent = $fieldName;
954
            }
955
        }
956
957
        $num = 1;
958
        $ret .= $this->getXoopsVersionNotificationGlobal($language, 'category', 'global', 'global', $notifyFiles, $num);
959
        ++$num;
960
        $ret .= $this->getXoopsVersionNotificationCategory($language, 'category', 'category', 'category', $notifyFiles, $fieldParent, '1', $num);
961
        ++$num;
962
        $ret .= $this->getXoopsVersionNotificationTableName($language, 'category', $tableSoleName, $tableSoleName, $single, $fieldId, 1, $num);
963
        unset($num);
964
        $num = 1;
965
        if (in_array(1, $tableCategory)) {
966
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'global', 0, 'global_new_category', 'global_newcategory_notify', $num);
967
            ++$num;
968
        }
969
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'modify', 'global', 1, 'global_modify', 'global_' . 'modify_notify', $num);
970
        if (in_array(1, $tableBroken)) {
971
            ++$num;
972
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'broken', 'global', 1, 'global_broken', 'global_' . 'broken_notify', $num);
973
        }
974
        if (in_array(1, $tableSubmit)) {
975
            ++$num;
976
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'global', 1, 'global_submit', 'global_' . 'submit_notify', $num);
977
        }
978
        ++$num;
979
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_' . $tableSoleName, 'global', 0, 'global_new',  'global_new' . $tableSoleName . '_notify', $num);
980
        if (in_array(1, $tableCategory)) {
981
            ++$num;
982
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'submit', 'category', 1, 'category_submit', 'category_' . $tableSoleName . 'submit_notify', $num);
983
            ++$num;
984
            $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'new_category', 'category', 0, 'category', 'category_new' . $tableSoleName . '_notify', $num);
985
        }
986
        ++$num;
987
        $ret .= $this->getXoopsVersionNotificationCodeComplete($language, 'event', 'approve', $tableSoleName, 1, $tableSoleName, $tableSoleName . '_approve_notify', $num);
988
        unset($num);
989
990
        return $ret;
991
    }
992
993
    /**
994
     * @private function getXoopsVersionNotificationGlobal
995
     * @param $language
996
     * @param $type
997
     * @param $name
998
     * @param $title
999
     * @param $from
1000
     *
1001
     * @param $num
1002
     * @return string
1003
     */
1004
    private function getXoopsVersionNotificationGlobal($language, $type, $name, $title, $from, $num)
1005
    {
1006
        $pc          = Tdmcreate\Files\CreatePhpCode::getInstance();
1007
        $uxc         = UserXoopsCode::getInstance();
1008
        $title       = mb_strtoupper($title);
1009
        $implodeFrom = implode(".php', '", $from);
1010
        $ret         = $pc->getPhpCodeCommentLine('Global Notify');
1011
        $global      = [
1012
            'name'           => "'{$name}'",
1013
            'title'          => "{$language}{$title}_NOTIFY",
1014
            'description'    => "{$language}{$title}_NOTIFY_DESC",
1015
            'subscribe_from' => "['index.php', '{$implodeFrom}.php']",
1016
        ];
1017
        $ret         .= $uxc->getUserModVersionArray(3, $global, 'notification', "'{$type}'", $num);
1018
1019
        return $ret;
1020
    }
1021
1022
    /**
1023
     * @private function getXoopsVersionNotificationCategory
1024
     * @param $language
1025
     * @param $type
1026
     * @param $name
1027
     * @param $title
1028
     * @param $file
1029
     * @param $item
1030
     * @param $allow
1031
     * @param $num
1032
     * @return string
1033
     */
1034
    private function getXoopsVersionNotificationCategory($language, $type, $name, $title, $file, $item, $allow, $num)
1035
    {
1036
        $pc     = Tdmcreate\Files\CreatePhpCode::getInstance();
1037
        $uxc    = UserXoopsCode::getInstance();
1038
        $title  = mb_strtoupper($title);
1039
        $impFile = implode(".php', '", $file);
1040
        $ret    = $pc->getPhpCodeCommentLine('Category Notify');
1041
        $global = [
1042
            'name'           => "'{$name}'",
1043
            'title'          => "{$language}{$title}_NOTIFY",
1044
            'description'    => "{$language}{$title}_NOTIFY_DESC",
1045
            'subscribe_from' => "['{$impFile}.php']",
1046
            'item_name'      => "'{$item}'",
1047
            'allow_bookmark' => (string)$allow,
1048
        ];
1049
        $ret .= $uxc->getUserModVersionArray(3, $global, 'notification', "'{$type}'", $num);
1050
1051
        return $ret;
1052
    }
1053
1054
    /**
1055
     * @private function getXoopsVersionNotificationTableName
1056
     * @param $language
1057
     * @param $type
1058
     * @param $name
1059
     * @param $title
1060
     * @param $file
1061
     * @param $item
1062
     * @param $allow
1063
     *
1064
     * @param $num
1065
     * @return string
1066
     */
1067
    private function getXoopsVersionNotificationTableName($language, $type, $name, $title, $file, $item, $allow, $num)
1068
    {
1069
        $pc       = Tdmcreate\Files\CreatePhpCode::getInstance();
1070
        $uxc      = UserXoopsCode::getInstance();
1071
        $stuTitle = mb_strtoupper($title);
1072
        $ucfTitle = ucfirst($title);
1073
        $ret      = $pc->getPhpCodeCommentLine($ucfTitle . ' Notify');
1074
        $table    = [
1075
            'name'           => "'{$name}'",
1076
            'title'          => "{$language}{$stuTitle}_NOTIFY",
1077
            'description'    => "{$language}{$stuTitle}_NOTIFY_DESC",
1078
            'subscribe_from' => "'{$file}.php'",
1079
            'item_name'      => "'{$item}'",
1080
            'allow_bookmark' => (string)$allow,
1081
        ];
1082
        $ret .= $uxc->getUserModVersionArray(3, $table, 'notification', "'{$type}'", $num);
1083
1084
        return $ret;
1085
    }
1086
1087
    /**
1088
     * @private function getXoopsVersionNotifications
1089
     * @param $language
1090
     * @param $type
1091
     * @param $name
1092
     * @param $category
1093
     * @param $admin
1094
     * @param $title
1095
     * @param $mail
1096
     *
1097
     * @param $num
1098
     * @return string
1099
     */
1100
    private function getXoopsVersionNotificationCodeComplete($language, $type, $name, $category, $admin, $title, $mail, $num)
1101
    {
1102
        $pc       = Tdmcreate\Files\CreatePhpCode::getInstance();
1103
        $uxc      = UserXoopsCode::getInstance();
1104
        $title    = mb_strtoupper($title);
1105
        $ucfTitle = ucfirst($title);
1106
        $ret      = $pc->getPhpCodeCommentLine($ucfTitle . ' Notify');
1107
        $event    = [
1108
            'name'          => "'{$name}'",
1109
            'category'      => "'{$category}'",
1110
            'admin_only'    => (string)$admin,
1111
            'title'         => "{$language}{$title}_NOTIFY",
1112
            'caption'       => "{$language}{$title}_NOTIFY_CAPTION",
1113
            'description'   => "{$language}{$title}_NOTIFY_DESC",
1114
            'mail_template' => "'{$mail}'",
1115
            'mail_subject'  => "{$language}{$title}_NOTIFY_SUBJECT",
1116
        ];
1117
        $ret .= $uxc->getUserModVersionArray(3, $event, 'notification', "'{$type}'", $num);
1118
1119
        return $ret;
1120
    }
1121
1122
    /**
1123
     * @private function getXoopsVersionNotifications
1124
     * @param $moduleDirname
1125
     * @param string $t
1126
     * @return string
1127
     */
1128
    private function getXoopsVersionSelectSizeMB($moduleDirname, $t = '')
1129
    {
1130
        $pc = Tdmcreate\Files\CreatePhpCode::getInstance();
1131
        $xc  = Tdmcreate\Files\CreateXoopsCode::getInstance();
1132
        $ucModuleDirname       = mb_strtoupper($moduleDirname);
1133
1134
        $ret  = $pc->getPhpCodeCommentLine('create increment steps for file size');
1135
        $ret  .= $pc->getPhpCodeIncludeDir("__DIR__ . '/include/xoops_version.inc.php'", '',true,true);
1136
        $ret  .= $xc->getXcEqualsOperator('$iniPostMaxSize      ', "{$moduleDirname}ReturnBytes(ini_get('post_max_size'))");
1137
        $ret  .= $xc->getXcEqualsOperator('$iniUploadMaxFileSize', "{$moduleDirname}ReturnBytes(ini_get('upload_max_filesize'))");
1138
        $ret  .= $xc->getXcEqualsOperator('$maxSize             ', "min(\$iniPostMaxSize, \$iniUploadMaxFileSize)");
1139
        $cond = $xc->getXcEqualsOperator('$increment', '500', null, $t . "\t");
1140
        $ret  .= $pc->getPhpCodeConditions('$maxSize', ' > ', '10000 * 1048576', $cond, false, $t);
1141
        $cond = $xc->getXcEqualsOperator('$increment', '200', null, $t . "\t");
1142
        $ret  .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '10000 * 1048576', $cond, false, $t);
1143
        $cond  = $xc->getXcEqualsOperator('$increment', '100', null, $t . "\t");
1144
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '5000 * 1048576', $cond, false, $t);
1145
        $cond  = $xc->getXcEqualsOperator('$increment', '50', null, $t . "\t");
1146
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '2500 * 1048576', $cond, false, $t);
1147
        $cond  = $xc->getXcEqualsOperator('$increment', '10', null, $t . "\t");
1148
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '1000 * 1048576', $cond, false, $t);
1149
        $cond  = $xc->getXcEqualsOperator('$increment', '5', null, $t . "\t");
1150
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '500 * 1048576', $cond, false, $t);
1151
        $cond  = $xc->getXcEqualsOperator('$increment', '2', null, $t . "\t");
1152
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '100 * 1048576', $cond, false, $t);
1153
        $cond  = $xc->getXcEqualsOperator('$increment', '1', null, $t . "\t");
1154
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '50 * 1048576', $cond, false, $t);
1155
        $cond  = $xc->getXcEqualsOperator('$increment', '0.5', null, $t . "\t");
1156
        $ret   .= $pc->getPhpCodeConditions('$maxSize', ' <= ', '25 * 1048576', $cond, false, $t);
1157
        $ret   .= $xc->getXcEqualsOperator('$optionMaxsize', '[]');
1158
        $ret   .= $xc->getXcEqualsOperator('$i', '$increment');
1159
        $while = $xc->getXcEqualsOperator("\$optionMaxsize[\$i . ' ' . _MI_{$ucModuleDirname}_SIZE_MB]", '$i * 1048576', null, $t . "\t");
1160
        $while .= $xc->getXcEqualsOperator('$i', '$increment', '+',$t . "\t");
1161
        $ret   .= $pc->getPhpCodeWhile('i * 1048576', $while, '$maxSize', ' <= ');
1162
1163
        return $ret;
1164
    }
1165
1166
    /**
1167
     * @public function render
1168
     * @param null
1169
     * @return bool|string
1170
     */
1171
    public function render()
1172
    {
1173
        $module        = $this->getModule();
1174
        $table         = $this->getTable();
1175
        $tables        = $this->getTables();
1176
        $filename      = $this->getFileName();
1177
        $moduleDirname = $module->getVar('mod_dirname');
1178
        $language      = $this->getLanguage($moduleDirname, 'MI');
1179
        $content       = $this->getHeaderFilesComments($module);
1180
        $content       .= $this->getXoopsVersionHeader($module, $language);
1181
        $content       .= $this->getXoopsVersionTemplatesAdminUser($moduleDirname, $tables, $module->getVar('mod_admin'), $module->getVar('mod_user'));
1182
        $content       .= $this->getXoopsVersionMySQL($moduleDirname, $table, $tables);
1183
        $tableSearch        = [];
1184
        $tableComments      = [];
1185
        $tableSubmenu       = [];
1186
        $tableBlocks        = [];
1187
        $tableNotifications = [];
1188
        foreach (array_keys($tables) as $t) {
1189
            $tableSearch[]        = $tables[$t]->getVar('table_search');
1190
            $tableComments[]      = $tables[$t]->getVar('table_comments');
1191
            $tableSubmenu[]       = $tables[$t]->getVar('table_submenu');
1192
            $tableBlocks[]        = $tables[$t]->getVar('table_blocks');
1193
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
1194
        }
1195
        if (in_array(1, $tableSearch)) {
1196
            $content .= $this->getXoopsVersionSearch($moduleDirname);
1197
        }
1198
        if (in_array(1, $tableComments)) {
1199
            $content .= $this->getXoopsVersionComments($moduleDirname);
1200
        }
1201
        if (in_array(1, $tableSubmenu)) {
1202
            $content .= $this->getXoopsVersionSubmenu($language, $tables);
1203
        }
1204
        if (in_array(1, $tableBlocks)) {
1205
            $content .= $this->getXoopsVersionBlocks($moduleDirname, $tables, $language);
1206
        }
1207
        $content .= $this->getXoopsVersionConfig($module, $tables, $language);
1208
        if (in_array(1, $tableNotifications)) {
1209
            $content .= $this->getXoopsVersionNotifications($module, $language);
1210
        }
1211
        $this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED);
1212
1213
        return $this->renderFile();
1214
    }
1215
}
1216