Passed
Push — master ( 0cff9c...dfbbd0 )
by Goffy
14:51
created

getXoopsVersionNotificationCategory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

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