CreateArchitecture   F
last analyzed

Complexity

Total Complexity 84

Size/Duplication

Total Lines 847
Duplicated Lines 0 %

Importance

Changes 3
Bugs 2 Features 0
Metric Value
eloc 524
c 3
b 2
f 0
dl 0
loc 847
rs 2
wmc 84

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 8 2
F setBaseFoldersFiles() 0 113 17
F setFilesToBuilding() 0 573 55
A CopyRatingFiles() 0 14 2
A __construct() 0 6 1
B setCommonFiles() 0 69 7

How to fix   Complexity   

Complex Class

Complex classes like CreateArchitecture often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use CreateArchitecture, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files;
4
5
use XoopsModules\Modulebuilder;
6
7
/*
8
 You may not change or alter any portion of this comment or credits
9
 of supporting developers from this source code or any supporting source code
10
 which is considered copyrighted (c) material of the original comment or credit authors.
11
12
 This program is distributed in the hope that it will be useful,
13
 but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
/**
17
 * modulebuilder module.
18
 *
19
 * @copyright       XOOPS Project (https://xoops.org)
20
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
21
 *
22
 * @since           2.5.0
23
 *
24
 * @author          Txmod Xoops https://xoops.org 
25
 *                  Goffy https://myxoops.org
26
 *
27
 */
28
29
//require \dirname(__DIR__) . '/autoload.php';
30
31
/**
32
 * Class Architecture.
33
 */
34
class CreateArchitecture extends CreateStructure
35
{
36
    /**
37
     * @var mixed
38
     */
39
    private $cf = null;
40
    /**
41
     * @var mixed
42
     */
43
    private $helper = null;
44
    /**
45
     * @var array
46
     */
47
    private $patKeys = [];
48
    /**
49
     * @var array
50
     */
51
    private $patValues = [];
52
53
    /**
54
     * @public function constructor
55
     * @param null
56
     */
57
    public function __construct()
58
    {
59
        parent::__construct();
60
        $this->helper = Modulebuilder\Helper::getInstance();
61
        $this->cf     = Modulebuilder\Files\CreateFile::getInstance();
62
        $this->setUploadPath(TDMC_UPLOAD_REPOSITORY_PATH);
63
    }
64
65
    /**
66
     * @static function getInstance
67
     *
68
     * @param null
69
     *
70
     * @return Modulebuilder\Files\CreateArchitecture
71
     */
72
    public static function getInstance()
73
    {
74
        static $instance = false;
75
        if (!$instance) {
76
            $instance = new self();
77
        }
78
79
        return $instance;
80
    }
81
82
    /**
83
     * @public function setBaseFoldersFiles
84
     *
85
     * @param $module
86
     */
87
    public function setBaseFoldersFiles($module)
88
    {
89
        // Module
90
        $modId = $module->getVar('mod_id');
91
        // Id of tables
92
        $tables = $this->cf->getTableTables($modId);
93
94
        $table = null;
95
        foreach (\array_keys($tables) as $t) {
96
            $tableId   = $tables[$t]->getVar('table_id');
97
            $tableName = $tables[$t]->getVar('table_name');
98
            $table     = $this->helper->getHandler('Tables')->get($tableId);
99
        }
100
101
        $indexFile       = TDMC_PATH . '/index.php';
102
        $stlModuleAuthor = \str_replace(' ', '', \mb_strtolower($module->getVar('mod_author')));
103
        $this->setModuleName($module->getVar('mod_dirname'));
104
        $uploadPath = $this->getUploadPath();
105
        // Creation of "module" folder in the Directory repository
106
        $this->makeDir($uploadPath . '/' . $this->getModuleName());
107
        if (1 != $module->getVar('mod_user')) {
108
            // Copied of index.php file in "root module" folder
109
            $this->copyFile('', $indexFile, 'index.php');
110
        }
111
        if (1 == $module->getVar('mod_admin')) {
112
            // Creation of "admin" folder and index.php file
113
            $this->makeDirInModule('admin');
114
        }
115
        if (1 == $module->getVar('mod_blocks')) {
116
            // Creation of "blocks" folder and index.php file
117
            $this->makeDirAndCopyFile('blocks', $indexFile, 'index.php');
118
        }
119
        $language  = ('english' !== $GLOBALS['xoopsConfig']['language']) ? $GLOBALS['xoopsConfig']['language'] : 'english';
120
        $copyFiles = [
121
            'class'                           => $indexFile,
122
            'include'                         => $indexFile,
123
            'config'                          => $indexFile,
124
            'language'                        => $indexFile,
125
            'assets'                          => $indexFile,
126
            'assets/css'                      => $indexFile,
127
            'assets/css/admin'                => $indexFile,
128
            'assets/icons'                    => $indexFile,
129
            'assets/icons/16'                 => $indexFile,
130
            'assets/icons/32'                 => $indexFile,
131
            'docs'                            => $indexFile,
132
            'assets/images'                   => $indexFile,
133
            'assets/js'                       => $indexFile,
134
            'language/' . $language           => $indexFile,
135
            'language/' . $language . '/help' => $indexFile,
136
            'preloads'                        => $indexFile,
137
        ];
138
        foreach ($copyFiles as $k => $v) {
139
            // Creation of folders and index.php file
140
            $this->makeDirAndCopyFile($k, $v, 'index.php');
141
        }
142
        //Copy the logo of the module
143
        $modImage    = \str_replace(' ', '', $module->getVar('mod_image'));
144
        $targetImage = 'logoModule.png';
145
        $this->copyFile('assets/images', TDMC_UPLOAD_IMGMOD_PATH . '/' . $modImage, $targetImage);
146
147
        //Copy blank files
148
        $targetImage = 'blank.gif';
149
        $this->copyFile('assets/images', TDMC_IMAGE_PATH . '/' . $targetImage, $targetImage);
150
        $targetImage = 'blank.png';
151
        $this->copyFile('assets/images', TDMC_IMAGE_PATH . '/' . $targetImage, $targetImage);
152
153
        // Copy of 'module_author_logo.png' file in uploads dir
154
        $logoPng     = $stlModuleAuthor . '_logo.png';
155
        $logoGifFrom = TDMC_UPLOAD_IMGMOD_PATH . '/' . $logoPng;
156
        // If file exists
157
        if (!\file_exists($logoGifFrom)) {
158
            // Rename file
159
            $copyFile    = TDMC_IMAGES_LOGOS_URL . '/xoopsdevelopmentteam_logo.gif';
160
            $copyNewFile = $logoGifFrom;
161
            \copy($copyFile, $copyNewFile);
162
        } else {
163
            // Copy file
164
            $copyFile    = TDMC_IMAGES_LOGOS_URL . '/' . $logoPng;
165
            $copyNewFile = $logoGifFrom;
166
            \copy($copyFile, $copyNewFile);
167
        }
168
169
        // Creation of 'module_author_logo.gif' file
170
        $this->copyFile('assets/images', $copyNewFile, $logoPng);
171
        $docs = [
172
            '/credits.txt' => 'credits.txt',
173
            '/install.txt' => 'install.txt',
174
            '/lang.diff'   => 'lang.diff',
175
            '/license.txt' => 'license.txt',
176
            '/readme.txt'  => 'readme.txt',
177
        ];
178
        foreach ($docs as $k => $v) {
179
            // Creation of folder docs and .txt files
180
            $this->makeDirAndCopyFile('docs', TDMC_DOCS_PATH . $k, $v);
181
        }
182
        if (!empty($tableName)) {
183
            if (1 == $module->getVar('mod_admin') || 1 == $module->getVar('mod_user')) {
184
                // Creation of "templates" folder and index.php file
185
                $this->makeDirAndCopyFile('templates', $indexFile, 'index.php');
186
            }
187
            if (1 == $module->getVar('mod_admin')) {
188
                // Creation of "templates/admin" folder and index.php file
189
                $this->makeDirAndCopyFile('templates/admin', $indexFile, 'index.php');
190
            }
191
            if ((1 == $module->getVar('mod_blocks')) && (1 == $table->getVar('table_blocks'))) {
192
                // Creation of "templates/blocks" folder and index.php file
193
                $this->makeDirAndCopyFile('templates/blocks', $indexFile, 'index.php');
194
            }
195
            // Creation of "sql" folder and index.php file
196
            $this->makeDirAndCopyFile('sql', $indexFile, 'index.php');
197
            if ((1 == $module->getVar('mod_notifications')) && (1 == $table->getVar('table_notifications'))) {
198
                // Creation of "language/local_language/mail_template" folder and index.php file
199
                $this->makeDirAndCopyFile('language/' . $language . '/mail_template', $indexFile, 'index.php');
200
            }
201
        }
202
    }
203
204
    /**
205
     * @public function setFilesToBuilding
206
     *
207
     * @param string $module
208
     *
209
     * @return array
210
     */
211
    public function setFilesToBuilding($module)
212
    {
213
        // Module
214
        $modId         = $module->getVar('mod_id');
215
        $moduleDirname = $module->getVar('mod_dirname');
216
        $icon32        = 'assets/icons/32';
217
        $tables        = $this->cf->getTableTables($modId);
218
        $files         = $this->cf->getTableMorefiles($modId);
219
        $ret           = [];
220
        $templateType  = 'defstyle';
221
222
        $patterns        = [
223
            \mb_strtolower('modulebuilder')           => \mb_strtolower($moduleDirname),
224
            \mb_strtoupper('modulebuilder')           => \mb_strtoupper($moduleDirname),
225
            \ucfirst(\mb_strtolower('modulebuilder')) => \ucfirst(\mb_strtolower($moduleDirname)),
226
        ];
227
        $this->patKeys   = \array_keys($patterns);
228
        $this->patValues = \array_values($patterns);
229
230
        $table         = null;
231
        $tableCategory = [];
232
        //$tableName          = [];
233
        $tableAdmin         = [];
234
        $tableUser          = [];
235
        $tableBlocks        = [];
236
        $tableSearch        = [];
237
        $tableComments      = [];
238
        $tableNotifications = [];
239
        $permTables         = [];
240
        $tablePermissions   = [];
241
        $tableBroken        = [];
242
        $tablePdf           = [];
243
        $tablePrint         = [];
244
        $tableRate          = [];
245
        $tableRss           = [];
246
        $tableSingle        = [];
247
        $tableSubmit        = [];
248
        $tableVisit         = [];
249
        $tableTag           = [];
250
        foreach (\array_keys($tables) as $t) {
251
            $tableId              = $tables[$t]->getVar('table_id');
252
            $tableName            = $tables[$t]->getVar('table_name');
253
            $tableSoleName        = $tables[$t]->getVar('table_solename');
254
            $tableCategory[]      = $tables[$t]->getVar('table_category');
255
            $tableImage           = $tables[$t]->getVar('table_image');
256
            $tableAdmin[]         = $tables[$t]->getVar('table_admin');
257
            $tableUser[]          = $tables[$t]->getVar('table_user');
258
            $tableBlocks[]        = $tables[$t]->getVar('table_blocks');
259
            $tableSearch[]        = $tables[$t]->getVar('table_search');
260
            $tableComments[]      = $tables[$t]->getVar('table_comments');
261
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
262
            $tablePermissions[]   = $tables[$t]->getVar('table_permissions');
263
            $permTables[]         = $tables[$t]->getVar('table_name');
264
            $tableBroken[]        = $tables[$t]->getVar('table_broken');
265
            $tablePdf[]           = $tables[$t]->getVar('table_pdf');
266
            $tablePrint[]         = $tables[$t]->getVar('table_print');
267
            $tableRate[]          = $tables[$t]->getVar('table_rate');
268
            $tableRss[]           = $tables[$t]->getVar('table_rss');
269
            $tableSingle[]        = $tables[$t]->getVar('table_single');
270
            $tableSubmit[]        = $tables[$t]->getVar('table_submit');
271
            $tableVisit[]         = $tables[$t]->getVar('table_visit');
272
            $tableTag[]           = $tables[$t]->getVar('table_tag');
273
274
            // Get Table Object
275
            $table = $this->helper->getHandler('Tables')->get($tableId);
276
            // Copy of tables images file
277
            if (\file_exists($uploadTableImage = TDMC_UPLOAD_IMGTAB_PATH . '/' . $tableImage)) {
278
                $this->copyFile($icon32, $uploadTableImage, $tableImage);
279
            } elseif (\file_exists($uploadTableImage = \XOOPS_ICONS32_PATH . '/' . $tableImage)) {
280
                $this->copyFile($icon32, $uploadTableImage, $tableImage);
281
            }
282
            // Creation of admin files
283
            if (1 === (int)$tables[$t]->getVar('table_admin')) {
284
                // Admin Pages File
285
                $adminPages = Modulebuilder\Files\Admin\AdminPages::getInstance();
286
                $adminPages->write($module, $table, $tableName . '.php');
287
                $ret[] = $adminPages->render();
288
                // Admin Templates File
289
                $adminTemplatesPages = Modulebuilder\Files\Templates\Admin\TemplatesAdminPages::getInstance();
290
                $adminTemplatesPages->write($module, $table, $moduleDirname . '_admin_' . $tableName . '.tpl');
291
                $ret[] = $adminTemplatesPages->render();
292
            }
293
            // Creation of blocks
294
            if (1 === (int)$tables[$t]->getVar('table_blocks')) {
295
                // Default block
296
                // Blocks Files
297
                $blocksFiles = Modulebuilder\Files\Blocks\BlocksFiles::getInstance();
298
                $blocksFiles->write($module, $table, $tableName . '.php');
299
                $ret[] = $blocksFiles->render();
300
                // Templates Blocks Files
301
                if ($templateType == 'bootstrap') {
302
                    $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Bootstrap\TemplatesBlocks::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...otstrap\TemplatesBlocks was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
303
                } else {
304
                    $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Defstyle\TemplatesBlocks::getInstance();
305
                }
306
                $templatesBlocks->write($module, $table, $moduleDirname . '_block_' . $tableName . '.tpl');
307
                $ret[] = $templatesBlocks->render();
308
                // Spotlight block
309
                // Blocks Files
310
                $blocksFiles = Modulebuilder\Files\Blocks\BlocksFilesSpotlight::getInstance();
311
                $blocksFiles->write($module, $table, $tableName . '_spotlight.php');
312
                $ret[] = $blocksFiles->render();
313
                // Templates Blocks Files
314
                if ($templateType == 'bootstrap') {
315
                    $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Bootstrap\TemplatesBlocksSpotlight::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...emplatesBlocksSpotlight was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
316
                } else {
317
                    $templatesBlocks = Modulebuilder\Files\Templates\Blocks\Defstyle\TemplatesBlocksSpotlight::getInstance();
318
                }
319
                $templatesBlocks->write($module, $table, $moduleDirname . '_block_' . $tableName . '_spotlight.tpl');
320
                $ret[] = $templatesBlocks->render();
321
            }
322
            // Creation of classes
323
            if (1 === (int)$tables[$t]->getVar('table_admin') || 1 === (int)$tables[$t]->getVar('table_user')) {
324
                // Class Files
325
                $classFiles = Modulebuilder\Files\Classes\ClassFiles::getInstance();
326
                $classFiles->write($module, $table, $tables, \ucfirst($tableName) . '.php');
327
                $ret[] = $classFiles->render();
328
            }
329
            // Creation of classhandlers
330
            if (1 === (int)$tables[$t]->getVar('table_admin') || 1 === (int)$tables[$t]->getVar('table_user')) {
331
                // Class Files
332
                $classFiles = Modulebuilder\Files\Classes\ClassHandlerFiles::getInstance();
333
                $classFiles->write($module, $table, $tables, \ucfirst($tableName) . 'Handler.php');
334
                $ret[] = $classFiles->render();
335
            }
336
            // Creation of user files
337
            if (1 === (int)$tables[$t]->getVar('table_user')) {
338
                // User Pages File
339
                $userPages = Modulebuilder\Files\User\UserPages::getInstance();
340
                $userPages->write($module, $table, $tableName . '.php');
341
                $ret[] = $userPages->render();
342
                // User Templates File
343
                if ($templateType == 'bootstrap') {
344
                    $userTemplatesPages = Modulebuilder\Files\Templates\User\Bootstrap\Pages::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...es\User\Bootstrap\Pages was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
345
                } else {
346
                    $userTemplatesPages = Modulebuilder\Files\Templates\User\Defstyle\Pages::getInstance();
347
                }
348
                $userTemplatesPages->write($module, $table, $moduleDirname . '_' . $tableName . '.tpl');
349
                $ret[] = $userTemplatesPages->render();
350
                // User List Templates File
351
                if ($templateType == 'bootstrap') {
352
                    $userTemplatesPagesList = Modulebuilder\Files\Templates\User\Bootstrap\PagesList::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...ser\Bootstrap\PagesList was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
353
                } else {
354
                    $userTemplatesPagesList = Modulebuilder\Files\Templates\User\Defstyle\PagesList::getInstance();
355
                }
356
                $userTemplatesPagesList->write($module, $table, $tables, $moduleDirname . '_' . $tableName . '_list' . '.tpl');
357
                $ret[] = $userTemplatesPagesList->render();
358
                // User Item Templates File
359
                if ($templateType == 'bootstrap') {
360
                    $userTemplatesPagesItem = Modulebuilder\Files\Templates\User\Bootstrap\PagesItem::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...ser\Bootstrap\PagesItem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
361
                } else {
362
                    $userTemplatesPagesItem = Modulebuilder\Files\Templates\User\Defstyle\PagesItem::getInstance();
363
                }
364
                $userTemplatesPagesItem->write($module, $table, $tables, $moduleDirname . '_' . $tableName . '_item' . '.tpl');
365
                $ret[] = $userTemplatesPagesItem->render();
366
                if (1 === (int)$tables[$t]->getVar('table_category')) {
367
                    // User List Templates File
368
                    $userTemplatesCategories = Templates\User\Defstyle\Categories::getInstance();
369
                    $userTemplatesCategories->write($module, $table, $moduleDirname . '_' . $tableName . '_cat.tpl');
370
                    $ret[] = $userTemplatesCategories->render();
371
                    // User List Templates File
372
                    $userTemplatesCategoriesList = Templates\User\Defstyle\CategoriesList::getInstance();
373
                    $userTemplatesCategoriesList->write($module, $table, $moduleDirname . '_' . $tableName . '_cat_list' . '.tpl');
374
                    $ret[] = $userTemplatesCategoriesList->render();
375
                }
376
                // Creation of notifications files
377
                if (1 === (int)$tables[$t]->getVar('table_notifications')) {
378
                    $languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
379
                    // Language Mail Template Modify File
380
                    $languageMailTpl->write($module, $table, $tableSoleName . '_modify_notify.tpl');
381
                    $ret[] = $languageMailTpl->render();
382
                    // Language Mail Template Delete File
383
                    $languageMailTpl->write($module, $table, $tableSoleName . '_delete_notify.tpl');
384
                    $ret[] = $languageMailTpl->render();
385
                    // Language Mail Template Approve File
386
                    $languageMailTpl->write($module, $table, $tableSoleName . '_approve_notify.tpl');
387
                    $ret[] = $languageMailTpl->render();
388
                    if (1 === (int)$tables[$t]->getVar('table_broken')) {
389
                        // Language Mail Template Category File
390
                        $languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
391
                        $languageMailTpl->write($module, $table, $tableSoleName . '_broken_notify.tpl');
392
                        $ret[] = $languageMailTpl->render();
393
                    }
394
                    // Creation of notifications files
395
                    if (1 === (int)$tables[$t]->getVar('table_comments')) {
396
                        // Language Mail Template Category File
397
                        $languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
398
                        $languageMailTpl->write($module, $table, $tableSoleName . '_comment_notify.tpl');
399
                        $ret[] = $languageMailTpl->render();
400
                    }
401
                }
402
            }
403
        }
404
405
        // Creation of constants
406
        $classSpecialFiles = Modulebuilder\Files\Classes\ClassSpecialFiles::getInstance();
407
        $classSpecialFiles->write($module, '', $tables, \ucfirst('constants') . '.php');
408
        $classSpecialFiles->className = 'Constants';
409
        $ret[]                        = $classSpecialFiles->renderConstantsInterface();
410
411
        // Creation of permissions
412
        if (\in_array(1, $tablePermissions)) {
413
            // Creation of classes
414
            $classSpecialFiles = Modulebuilder\Files\Classes\ClassSpecialFiles::getInstance();
415
            $classSpecialFiles->write($module, '', null, \ucfirst('permissions') . '.php');
416
            $classSpecialFiles->className = 'Permissions';
417
            $ret[]                        = $classSpecialFiles->renderClass();
418
419
            // Creation of classhandlers
420
            $classSpecialFiles = Modulebuilder\Files\Classes\ClassSpecialFiles::getInstance();
421
            $classSpecialFiles->write($module, '', $permTables, \ucfirst('PermissionsHandler') . '.php');
422
            $classSpecialFiles->className = 'PermissionsHandler';
423
            $ret[]                        = $classSpecialFiles->renderPermissionsHandler();
424
        }
425
        foreach (\array_keys($files) as $t) {
426
            $fileInfolder = $files[$t]->getVar('file_infolder');
427
            if (Modulebuilder\Constants::MORE_FILES_TYPE_COPY == $files[$t]->getVar('file_type')) {
428
                $src_file = TDMC_UPLOAD_FILES_PATH . '/' . $files[$t]->getVar('file_upload');
429
                $dst_file = TDMC_UPLOAD_REPOSITORY_PATH . '/' . \mb_strtolower($moduleDirname) . '/';
430
                if ('' !== $fileInfolder) {
431
                    if ('/' !== \substr($fileInfolder, -1)) {
432
                        $fileInfolder .= '/';
433
                    }
434
                    $dst_file .= $fileInfolder;
435
                }
436
                $dst_file .= $files[$t]->getVar('file_upload');
437
                Modulebuilder\Files\CreateClone::cloneFile($src_file, $dst_file, true, $this->patKeys, $this->patValues);
438
            } else {
439
                $fileName      = $files[$t]->getVar('file_name');
440
                $fileExtension = $files[$t]->getVar('file_extension');
441
                // More File
442
                $moreFiles = Modulebuilder\Files\CreateMoreFiles::getInstance();
443
                $moreFiles->write($module, $fileName, $fileInfolder, $fileExtension);
444
                $ret[] = $moreFiles->render();
445
            }
446
        }
447
        // Language Modinfo File
448
        $languageModinfo = Modulebuilder\Files\Language\LanguageModinfo::getInstance();
449
        $languageModinfo->write($module, $table, 'modinfo.php');
450
        $ret[] = $languageModinfo->render();
451
        if (1 == $module->getVar('mod_admin')) {
452
            // Admin Header File
453
            $adminHeader = Modulebuilder\Files\Admin\AdminHeader::getInstance();
454
            $adminHeader->write($module, $table, $tables, 'header.php');
455
            $ret[] = $adminHeader->render();
456
            // Admin Index File
457
            $adminIndex = Modulebuilder\Files\Admin\AdminIndex::getInstance();
458
            $adminIndex->write($module, $tables, 'index.php');
459
            $ret[] = $adminIndex->render();
460
            // Admin Menu File
461
            $adminObject = Modulebuilder\Files\Admin\AdminMenu::getInstance();
462
            $adminObject->write($module, 'menu.php');
463
            $ret[] = $adminObject->render();
464
            // Admin About File
465
            $adminAbout = Modulebuilder\Files\Admin\AdminAbout::getInstance();
466
            $adminAbout->write($module, 'about.php');
467
            $ret[] = $adminAbout->render();
468
            // Admin Footer File
469
            $adminFooter = Modulebuilder\Files\Admin\AdminFooter::getInstance();
470
            $adminFooter->write($module, 'footer.php');
471
            $ret[] = $adminFooter->render();
472
            // Templates Admin About File
473
            $adminTemplatesAbout = Modulebuilder\Files\Templates\Admin\TemplatesAdminAbout::getInstance();
474
            $adminTemplatesAbout->write($module, $moduleDirname . '_admin_about.tpl');
475
            $ret[] = $adminTemplatesAbout->render();
476
            // Templates Admin Index File
477
            $adminTemplatesIndex = Modulebuilder\Files\Templates\Admin\TemplatesAdminIndex::getInstance();
478
            $adminTemplatesIndex->write($module, $moduleDirname . '_admin_index.tpl');
479
            $ret[] = $adminTemplatesIndex->render();
480
            // Templates Admin Footer File
481
            $adminTemplatesFooter = Modulebuilder\Files\Templates\Admin\TemplatesAdminFooter::getInstance();
482
            $adminTemplatesFooter->write($module, $moduleDirname . '_admin_footer.tpl');
483
            $ret[] = $adminTemplatesFooter->render();
484
            // Templates Admin Header File
485
            $adminTemplatesHeader = Modulebuilder\Files\Templates\Admin\TemplatesAdminHeader::getInstance();
486
            $adminTemplatesHeader->write($module, $moduleDirname . '_admin_header.tpl');
487
            $ret[] = $adminTemplatesHeader->render();
488
            // Language Admin File
489
            $languageAdmin = Modulebuilder\Files\Language\LanguageAdmin::getInstance();
490
            $languageAdmin->write($module, $table, $tables, 'admin.php');
491
            $ret[] = $languageAdmin->render();
492
        }
493
494
        // Class Helper File ==> setCommonFiles
495
496
        // Include Functions File
497
        $includeFunctions = Modulebuilder\Files\Includes\IncludeFunctions::getInstance();
498
        $includeFunctions->write($module, 'functions.php');
499
        $ret[] = $includeFunctions->render();
500
501
        // Include Install File  ==>  setCommonFiles
502
        // Include Uninstall File  ==>  setCommonFiles
503
        // Include Update File  ==>  setCommonFiles
504
505
        if (\in_array(1, $tableBlocks)) {
506
            // Language Blocks File
507
            $languageBlocks = Modulebuilder\Files\Language\LanguageBlocks::getInstance();
508
            $languageBlocks->write($module, $tables, 'blocks.php');
509
            $ret[] = $languageBlocks->render();
510
        }
511
        // Creation of admin broken files
512
        if (\in_array(1, $tableBroken)) {
513
            // Admin broken File
514
            $adminPermissions = Modulebuilder\Files\Admin\AdminBroken::getInstance();
515
            $adminPermissions->write($module, $tables, 'broken.php');
516
            $ret[] = $adminPermissions->render();
517
            // Templates Admin broken File
518
            $adminTemplatesPermissions = Modulebuilder\Files\Templates\Admin\TemplatesAdminBroken::getInstance();
519
            $adminTemplatesPermissions->write($module, $tables, $moduleDirname . '_admin_broken.tpl');
520
            $ret[] = $adminTemplatesPermissions->render();
521
        }
522
        // Creation of admin permission files
523
        if (\in_array(1, $tablePermissions)) {
524
            // Admin Permissions File
525
            $adminPermissions = Modulebuilder\Files\Admin\AdminPermissions::getInstance();
526
            $adminPermissions->write($module, $tables, 'permissions.php');
527
            $ret[] = $adminPermissions->render();
528
            // Templates Admin Permissions File
529
            $adminTemplatesPermissions = Modulebuilder\Files\Templates\Admin\TemplatesAdminPermissions::getInstance();
530
            $adminTemplatesPermissions->write($module, $moduleDirname . '_admin_permissions.tpl');
531
            $ret[] = $adminTemplatesPermissions->render();
532
        }
533
        // Creation of notifications files
534
        if (\in_array(1, $tableNotifications)) {
535
            // Include Notifications File
536
            $includeNotifications = Modulebuilder\Files\Includes\IncludeNotifications::getInstance();
537
            $includeNotifications->write($module, $tables, 'notification.inc.php');
538
            $ret[]           = $includeNotifications->render();
539
            $languageMailTpl = Modulebuilder\Files\Language\LanguageMailTpl::getInstance();
540
            // Language Mail Template Category File
541
            //$languageMailTpl->write($module, $table, 'category_new_notify.tpl');
542
            //$ret[] = $languageMailTpl->render();
543
            // Language Mail Template New File
544
            $languageMailTpl->write($module, $table, 'global_new_notify.tpl');
545
            $ret[] = $languageMailTpl->render();
546
            // Language Mail Template Modify File
547
            $languageMailTpl->write($module, $table, 'global_modify_notify.tpl');
548
            $ret[] = $languageMailTpl->render();
549
            // Language Mail Template Delete File
550
            $languageMailTpl->write($module, $table, 'global_delete_notify.tpl');
551
            $ret[] = $languageMailTpl->render();
552
            // Language Mail Template Approve File
553
            $languageMailTpl->write($module, $table, 'global_approve_notify.tpl');
554
            $ret[] = $languageMailTpl->render();
555
            if (\in_array(1, $tableBroken)) {
556
                // Language Mail Template Broken File
557
                $languageMailTpl->write($module, $table, 'global_broken_notify.tpl');
558
                $ret[] = $languageMailTpl->render();
559
            }
560
            if (\in_array(1, $tableComments)) {
561
                // Language Mail Template Broken File
562
                $languageMailTpl->write($module, $table, 'global_comment_notify.tpl');
563
                $ret[] = $languageMailTpl->render();
564
            }
565
        }
566
        // Creation of sql file
567
        if (\count($tables) > 0) {
568
            // Sql File
569
            $sqlFile = Modulebuilder\Files\Sql\SqlFile::getInstance();
570
            $sqlFile->write($module, 'mysql.sql');
571
            $ret[] = $sqlFile->render();
572
        }
573
        // Creation of search file
574
        if (\in_array(1, $tableSearch)) {
575
            // Search File
576
            //TODO: UserSearch has to be adapted
577
            /*
578
            $userSearch = Modulebuilder\Files\User\UserSearch::getInstance();
579
            $userSearch->write($module, $table, 'search.php');
580
            $ret[] = $userSearch->render();
581
            */
582
            // Include Search File
583
            $includeSearch = Modulebuilder\Files\Includes\IncludeSearch::getInstance();
584
            $includeSearch->write($module, $tables, 'search.inc.php');
585
            $ret[] = $includeSearch->render();
586
        }
587
        // Creation of comments files
588
        if (\in_array(1, $tableComments)) {
589
            // Include Comments File
590
            $includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
591
            $includeComments->write($module, $table);
592
            $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_edit');
593
            // Include Comments File
594
            $includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
595
            $includeComments->write($module, $table);
596
            $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_delete');
597
            // Include Comments File
598
            $includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
599
            $includeComments->write($module, $table);
600
            $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_post');
601
            // Include Comments File
602
            $includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
603
            $includeComments->write($module, $table);
604
            $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_reply');
605
            // Include Comments File
606
            //$includeComments = Modulebuilder\Files\Includes\IncludeComments::getInstance();
607
            //$includeComments->write($module, $table);
608
            //$ret[] = $includeComments->renderCommentsNew($module, 'comment_new');
609
            // Include Comment Functions File
610
            $includeCommentFunctions = Modulebuilder\Files\Includes\IncludeCommentFunctions::getInstance();
611
            $includeCommentFunctions->write($module, $table, 'comment_functions.php');
612
            $ret[] = $includeCommentFunctions->render();
613
        }
614
615
        if ((1 == $module->getVar('mod_user')) && \in_array(1, $tableUser)) {
616
            // Creation of user template files
617
            // Templates Index File
618
            if ($templateType == 'bootstrap') {
619
                $userTemplatesIndex = Modulebuilder\Files\Templates\User\Bootstrap\Index::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...es\User\Bootstrap\Index was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
620
            } else {
621
                $userTemplatesIndex = Modulebuilder\Files\Templates\User\Defstyle\Index::getInstance();
622
            }
623
            $userTemplatesIndex->write($module, $table, $tables, $moduleDirname . '_index.tpl');
624
            $ret[] = $userTemplatesIndex->render();
625
            // Templates Footer File
626
            if ($templateType == 'bootstrap') {
627
                $userTemplatesFooter = Modulebuilder\Files\Templates\User\Bootstrap\Footer::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...s\User\Bootstrap\Footer was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
628
            } else {
629
                $userTemplatesFooter = Modulebuilder\Files\Templates\User\Defstyle\Footer::getInstance();
630
            }
631
            $userTemplatesFooter->write($module, $table, $moduleDirname . '_footer.tpl');
632
            $ret[] = $userTemplatesFooter->render();
633
            // Templates Header File
634
            if ($templateType == 'bootstrap') {
635
                $userTemplatesHeader = Modulebuilder\Files\Templates\User\Bootstrap\Header::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...s\User\Bootstrap\Header was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
636
            } else {
637
                $userTemplatesHeader = Modulebuilder\Files\Templates\User\Defstyle\Header::getInstance();
638
            }
639
            $userTemplatesHeader->write($module, $moduleDirname . '_header.tpl');
640
            $ret[] = $userTemplatesHeader->render();
641
642
            // Creation of user files
643
            // User Footer File
644
            $userFooter = Modulebuilder\Files\User\UserFooter::getInstance();
645
            $userFooter->write($module, 'footer.php');
646
            $ret[] = $userFooter->render();
647
            // User Header File
648
            $userHeader = Modulebuilder\Files\User\UserHeader::getInstance();
649
            $userHeader->write($module, $table, $tables, 'header.php');
650
            $ret[] = $userHeader->render();
651
            // User Notification Update File
652
            if ((1 == $module->getVar('mod_notifications')) && \in_array(1, $tableNotifications)) {
653
                $userNotificationUpdate = Modulebuilder\Files\User\UserNotificationUpdate::getInstance();
654
                $userNotificationUpdate->write($module, 'notification_update.php');
655
                $ret[] = $userNotificationUpdate->render();
656
            }
657
            // User Pdf File
658
            if (\in_array(1, $tablePdf)) {
659
                foreach ($tables as $table) {
660
                    if ($table->getVar('table_pdf')) {
661
                        $tableName = $table->getVar('table_name');
662
                        $userPdf   = Modulebuilder\Files\User\UserPdf::getInstance();
663
                        $userPdf->write($module, $table, $tableName . '_pdf.php');
664
                        $ret[] = $userPdf->render();
665
                        // User Templates Pdf File
666
                        if ($templateType == 'bootstrap') {
667
                            $userTemplatesPdf = Modulebuilder\Files\Templates\User\Bootstrap\Pdf::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...ates\User\Bootstrap\Pdf was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
668
                        } else {
669
                            $userTemplatesPdf = Modulebuilder\Files\Templates\User\Defstyle\Pdf::getInstance();
670
                        }
671
                        $userTemplatesPdf->write($module, $table, $moduleDirname . '_' . $tableName . '_pdf.tpl');
672
                        $ret[] = $userTemplatesPdf->render();
673
                    }
674
                }
675
            }
676
            // User Print File
677
            if (\in_array(1, $tablePrint)) {
678
                foreach ($tables as $table) {
679
                    if ($table->getVar('table_print')) {
680
                        $tableName = $table->getVar('table_name');
681
                        $userPrint = Modulebuilder\Files\User\UserPrint::getInstance();
682
                        $userPrint->write($module, $table, $tableName . '_print.php');
683
                        $ret[] = $userPrint->render();
684
                        // User Templates Print File
685
                        if ($templateType == 'bootstrap') {
686
                            $userTemplatesPrint = Modulebuilder\Files\Templates\User\Bootstrap\UserPrint::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...ser\Bootstrap\UserPrint was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
687
                        } else {
688
                            $userTemplatesPrint = Modulebuilder\Files\Templates\User\Defstyle\UserPrint::getInstance();
689
                        }
690
                        $userTemplatesPrint->write($module, $table, $moduleDirname . '_' . $tableName . '_print.tpl');
691
                        $ret[] = $userTemplatesPrint->render();
692
                    }
693
                }
694
            }
695
696
            //TODO: UserSearch has to be adapted
697
698
            // User Rate File
699
            if (\in_array(1, $tableRate)) {
700
                $userRate = Modulebuilder\Files\User\UserRate::getInstance();
701
                $userRate->write($module, $tables, 'rate.php');
702
                $ret[] = $userRate->render();
703
704
                $this->CopyRatingFiles($moduleDirname);
705
                $ret[] = \_AM_MODULEBUILDER_BUILDING_RATING;
706
            }
707
708
            // User Rss File
709
            if (\in_array(1, $tableRss)) {
710
                $userRss = Modulebuilder\Files\User\UserRss::getInstance();
711
                $userRss->write($module, $table, 'rss.php');
712
                $ret[] = $userRss->render();
713
                // User Templates Rss File
714
                if ($templateType == 'bootstrap') {
715
                    $userTemplatesRss = Modulebuilder\Files\Templates\User\Bootstrap\Rss::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...ates\User\Bootstrap\Rss was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
716
                } else {
717
                    $userTemplatesRss = Modulebuilder\Files\Templates\User\Defstyle\Rss::getInstance();
718
                }
719
                $userTemplatesRss->write($module, $moduleDirname . '_rss.tpl');
720
                $ret[] = $userTemplatesRss->render();
721
            }
722
723
            // User Tag Files
724
            if (\in_array(1, $tableTag)) {
725
                $userListTag = Modulebuilder\Files\User\UserListTag::getInstance();
726
                $userListTag->write($module, 'list.tag.php');
727
                $ret[]       = $userListTag->render();
728
                $userViewTag = Modulebuilder\Files\User\UserViewTag::getInstance();
729
                $userViewTag->write($module, 'view.tag.php');
730
                $ret[] = $userViewTag->render();
731
            }
732
            // User Index File
733
            $userIndex = Modulebuilder\Files\User\UserIndex::getInstance();
734
            $userIndex->write($module, $table, 'index.php');
735
            $ret[] = $userIndex->render();
736
            // Language Main File
737
            $languageMain = Modulebuilder\Files\Language\LanguageMain::getInstance();
738
            $languageMain->write($module, $tables, 'main.php');
739
            $ret[] = $languageMain->render();
740
            // User Templates Breadcrumbs File
741
            if ($templateType == 'bootstrap') {
742
                $userTemplatesUserBreadcrumbs = Modulebuilder\Files\Templates\User\Bootstrap\Breadcrumbs::getInstance();
0 ignored issues
show
Bug introduced by
The type XoopsModules\Modulebuild...r\Bootstrap\Breadcrumbs was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
743
            } else {
744
                $userTemplatesUserBreadcrumbs = Modulebuilder\Files\Templates\User\Defstyle\Breadcrumbs::getInstance();
745
            }
746
            $userTemplatesUserBreadcrumbs->write($module, $moduleDirname . '_breadcrumbs.tpl');
747
            $ret[] = $userTemplatesUserBreadcrumbs->render();
748
        }
749
        // Css Admin Styles File
750
        $cssStyles = Modulebuilder\Files\Assets\Css\Admin\CssAdminStyles::getInstance();
751
        $cssStyles->write($module, 'style.css');
752
        $ret[] = $cssStyles->render();
753
        // Css Styles File
754
        $cssStyles = Modulebuilder\Files\Assets\Css\CssStyles::getInstance();
755
        $cssStyles->write($module, 'style.css');
756
        $ret[] = $cssStyles->render();
757
        // Include Jquery File
758
        $JavascriptJQuery = Modulebuilder\Files\Assets\Js\JavascriptJQuery::getInstance();
759
        $JavascriptJQuery->write($module, 'functions.js');
760
        $ret[] = $JavascriptJQuery->render();
761
        // Include Common File
762
        $includeCommon = Modulebuilder\Files\Includes\IncludeCommon::getInstance();
763
        $includeCommon->write($module, $table, 'common.php');
764
        $ret[] = $includeCommon->render();
765
        // Common Config File
766
        $includeConfig = Modulebuilder\Files\Config\ConfigConfig::getInstance();
767
        $includeConfig->write($module, $tables, 'config.php');
768
        $ret[] = $includeConfig->render();
769
        // Docs Changelog File
770
        $docsChangelog = Modulebuilder\Files\Docs\DocsChangelog::getInstance();
771
        $docsChangelog->write($module, 'changelog.txt');
772
        $ret[] = $docsChangelog->render();
773
        // Language Help File
774
        $languageHelp = Modulebuilder\Files\Language\LanguageHelp::getInstance();
775
        $languageHelp->write($module, 'help.html');
776
        $ret[] = $languageHelp->render();
777
        // User Xoops Version File
778
        $userXoopsVersion = Modulebuilder\Files\User\UserXoopsVersion::getInstance();
779
        $userXoopsVersion->write($module, $table, $tables, 'xoops_version.php');
780
        $ret[] = $userXoopsVersion->render();
781
782
        // Return Array
783
        return $ret;
784
    }
785
786
    /**
787
     * @public function setCommonFiles
788
     *
789
     * @param $module
790
     */
791
    public function setCommonFiles($module)
792
    {
793
        $moduleName = $module->getVar('mod_dirname');
794
        $upl_path   = TDMC_UPLOAD_REPOSITORY_PATH . '/' . \mb_strtolower($moduleName);
795
796
        /* clone complete missing folders */
797
        $cloneFolders   = [];
798
        $cloneFolders[] = [
799
            'src'   => TDMC_PATH . '/files/commonfiles',
800
            'dst'   => $upl_path,
801
            'rcode' => true,
802
        ];
803
        foreach ($cloneFolders as $folder) {
804
            Modulebuilder\Files\CreateClone::cloneFileFolder($folder['src'], $folder['dst'], $folder['rcode'], $this->patKeys, $this->patValues);
805
        }
806
        unset($cloneFolders);
807
808
        /* create missing folders for common files */
809
        $createFolders[] = $upl_path . '/testdata/' . $GLOBALS['xoopsConfig']['language'];
0 ignored issues
show
Comprehensibility Best Practice introduced by
$createFolders was never initialized. Although not strictly required by PHP, it is generally a good practice to add $createFolders = array(); before regardless.
Loading history...
810
        if ('english' !== $GLOBALS['xoopsConfig']['language']) {
811
            $createFolders[] = $upl_path . '/testdata/english';
812
            $createFolders[] = $upl_path . '/language/english';
813
        }
814
        foreach ($createFolders as $folder) {
815
            @\mkdir($folder);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition for mkdir(). This can introduce security issues, and is generally not recommended. ( Ignorable by Annotation )

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

815
            /** @scrutinizer ignore-unhandled */ @\mkdir($folder);

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
816
        }
817
        unset($createFolders);
818
819
        if ('english' !== $GLOBALS['xoopsConfig']['language']) {
820
            $cloneFolders[] = [
821
                'src'   => TDMC_PATH . '/files/commonfiles/language/english',
822
                'dst'   => $upl_path . '/language/' . $GLOBALS['xoopsConfig']['language'],
823
                'rcode' => true,
824
            ];
825
            //copy back all language files to english language folder
826
            $cloneFolders[] = [
827
                'src'   => $upl_path . '/language/' . $GLOBALS['xoopsConfig']['language'],
828
                'dst'   => $upl_path . '/language/english',
829
                'rcode' => false,
830
            ];
831
            foreach ($cloneFolders as $folder) {
832
                Modulebuilder\Files\CreateClone::cloneFileFolder($folder['src'], $folder['dst'], $folder['rcode'], $this->patKeys, $this->patValues);
833
            }
834
            unset($cloneFolders);
835
        }
836
837
        /* clone single missing files*/
838
        $cloneFiles[] = [
0 ignored issues
show
Comprehensibility Best Practice introduced by
$cloneFiles was never initialized. Although not strictly required by PHP, it is generally a good practice to add $cloneFiles = array(); before regardless.
Loading history...
839
            'src'   => TDMC_PATH . '/config/',
840
            'dst'   => $upl_path . '/config/',
841
            'file'  => 'admin.yml',
842
            'rcode' => true,
843
        ];
844
        $cloneFiles[] = [
845
            'src'   => TDMC_PATH . '/config/',
846
            'dst'   => $upl_path . '/config/',
847
            'file'  => 'icons.php',
848
            'rcode' => true,
849
        ];
850
        $cloneFiles[] = [
851
            'src'   => TDMC_PATH . '/config/',
852
            'dst'   => $upl_path . '/config/',
853
            'file'  => 'paths.php',
854
            'rcode' => true,
855
        ];
856
        foreach ($cloneFiles as $file) {
857
            Modulebuilder\Files\CreateClone::cloneFile($file['src'] . $file['file'], $file['dst'] . $file['file'], $file['rcode'], $this->patKeys, $this->patValues);
858
        }
859
        unset($cloneFiles);
860
    }
861
862
    /**
863
     * @private function CopyRatingFiles
864
     *
865
     * @param $moduleName
866
     */
867
    private function CopyRatingFiles($moduleName)
868
    {
869
        $upl_path = TDMC_UPLOAD_REPOSITORY_PATH . '/' . \mb_strtolower($moduleName);
870
871
        /* clone complete missing folders */
872
        $cloneFolders[] = [
0 ignored issues
show
Comprehensibility Best Practice introduced by
$cloneFolders was never initialized. Although not strictly required by PHP, it is generally a good practice to add $cloneFolders = array(); before regardless.
Loading history...
873
            'src'   => TDMC_PATH . '/files/ratingfiles',
874
            'dst'   => $upl_path,
875
            'rcode' => true,
876
        ];
877
        foreach ($cloneFolders as $folder) {
878
            Modulebuilder\Files\CreateClone::cloneFileFolder($folder['src'], $folder['dst'], $folder['rcode'], $this->patKeys, $this->patValues);
879
        }
880
        unset($cloneFolders);
881
    }
882
}
883