Passed
Branch timgno (61fada)
by Gino
05:14
created

TDMCreateArchitecture::setBaseFoldersFiles()   F

Complexity

Conditions 15
Paths 1792

Size

Total Lines 125
Code Lines 69

Duplication

Lines 13
Ratio 10.4 %
Metric Value
dl 13
loc 125
rs 2
cc 15
eloc 69
nc 1792
nop 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 29 and the first side effect is on line 24.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
/**
13
 * tdmcreate module.
14
 *
15
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 *
18
 * @since           2.5.0
19
 *
20
 * @author          Txmod Xoops http://www.txmodxoops.org
21
 *
22
 * @version         $Id: TDMCreateArchitecture.php 12258 2014-01-02 09:33:29Z timgno $
23
 */
24
defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
include dirname(__DIR__).'/autoload.php';
26
/**
27
 * Class TDMCreateArchitecture.
28
 */
29
class TDMCreateArchitecture extends TDMCreateStructure
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

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

namespace YourVendor;

class YourClass { }

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

Loading history...
30
{
31
    /*
32
    * @var mixed
33
    */
34
    private $tdmcreate;
35
36
    /*
37
    * @var mixed
38
    */
39
    private $tdmcfile;
40
41
    /*
42
    *  @public function constructor class
43
    *  @param null
44
    */
45
    /**
46
     *
47
     */
48
    public function __construct()
49
    {
50
        parent::__construct();
51
        $this->tdmcreate = TDMCreateHelper::getInstance();
52
        $this->tdmcfile = TDMCreateFile::getInstance();
53
        $this->setUploadPath(TDMC_UPLOAD_REPOSITORY_PATH);
54
    }
55
56
    /*
57
    *  @static function &getInstance
58
    *  @param null
59
    */
60
    /**
61
     * @return TDMCreateArchitecture
62
     */
63
    public static function &getInstance()
64
    {
65
        static $instance = false;
66
        if (!$instance) {
67
            $instance = new self();
68
        }
69
70
        return $instance;
71
    }
72
73
    /*
74
    *  @public function setBaseFoldersFiles
75
    *  @param string $module
76
    */
77
    /**
78
     * @param $module
79
     */
80
    public function setBaseFoldersFiles($module)
81
    {
82
        global $xoopsConfig;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
83
		// Module
84
        $modId = $module->getVar('mod_id');
85
        $language = $xoopsConfig['language'];
86
        // Id of tables
87
        $tables = $this->tdmcfile->getTableTables($modId);
88
        //
89
        $table = null;
90
		$tableName = array();
91
        foreach (array_keys($tables) as $t) {
92
            $tableId = $tables[$t]->getVar('table_id');
93
            $tableName[] = $tables[$t]->getVar('table_name');
94
            $table = $this->tdmcreate->getHandler('tables')->get($tableId);
95
        }
96
        //
97
        $indexFile = XOOPS_UPLOAD_PATH.'/index.html';
98
        $stlModuleAuthor = str_replace(' ', '', strtolower($module->getVar('mod_author')));
99
        $this->setModuleName($module->getVar('mod_dirname'));
100
        $uploadPath = $this->getUploadPath();
101
        // Creation of "module" folder in the Directory repository
102
        $this->makeDir($uploadPath.'/'.$this->getModuleName());
103
        if (1 != $module->getVar('mod_user')) {
104
            // Copied of index.html file in "root module" folder
105
            $this->copyFile('', $indexFile, 'index.html');
106
        }
107
        if (1 == $module->getVar('mod_admin')) {
108
            // Creation of "admin" folder and index.html file
109
            $this->makeDirAndCopyFile('admin', $indexFile, 'index.html');
110
        }
111
        if (1 == $module->getVar('mod_blocks')) {
112
            // Creation of "blocks" folder and index.html file
113
            $this->makeDirAndCopyFile('blocks', $indexFile, 'index.html');
114
        }
115
        // Creation of "class" folder and index.html file
116
        $this->makeDirAndCopyFile('class', $indexFile, 'index.html');
117
        // Creation of "assets" folder and index.html file
118
        $this->makeDirAndCopyFile('assets', $indexFile, 'index.html');
119
        // Creation of "assets/css" folder and index.html file
120
        $this->makeDirAndCopyFile('assets/css', $indexFile, 'index.html');
121
        // Creation of "assets/icons" folder and index.html file
122
        $this->makeDirAndCopyFile('assets/icons', $indexFile, 'index.html');
123
        // Creation of "assets/icons/16" folder and index.html file
124
        $this->makeDirAndCopyFile('assets/icons/16', $indexFile, 'index.html');
125
        // Creation of "assets/icons/32" folder and index.html file
126
        $this->makeDirAndCopyFile('assets/icons/32', $indexFile, 'index.html');
127
        // Creation of "assets/images" folder and index.html file
128
        $this->makeDirAndCopyFile('assets/images', $indexFile, 'index.html');
129
        // Creation of "assets/js" folder and index.html file
130
        $this->makeDirAndCopyFile('assets/js', $indexFile, 'index.html');
131
        //Copy the logo of the module
132
        $modImage = str_replace(' ', '', strtolower($module->getVar('mod_image')));
133
        $this->copyFile('assets/images', TDMC_UPLOAD_IMGMOD_PATH.'/'.$modImage, $modImage);
134
        // Copy of 'module_author_logo.gif' file in uploads dir
135
        $logoGifFrom = TDMC_UPLOAD_IMGMOD_PATH.'/'.$stlModuleAuthor.'_logo.gif';
136
        // If file exists
137
        if (!file_exists($logoGifFrom)) {
138
            // Rename file
139
            $copyFile = TDMC_IMAGES_LOGOS_URL.'/xoopsdevelopmentteam_logo.gif';
140
            $copyNewFile = $logoGifFrom;
141
            copy($copyFile, $copyNewFile);
142
        } else {
143
            // Copy file
144
            $copyFile = TDMC_IMAGES_LOGOS_URL.'/'.$stlModuleAuthor.'_logo.gif';
145
            $copyNewFile = $logoGifFrom;
146
            copy($copyFile, $copyNewFile);
147
        }
148
        // Creation of 'module_author_logo.gif' file
149
        $this->copyFile('assets/images', $copyNewFile, $stlModuleAuthor.'_logo.gif');
150
        // Creation of 'docs' folder and index.html file
151
        $this->makeDirAndCopyFile('docs', $indexFile, 'index.html');
152
        // Creation of 'credits.txt' file
153
        $this->copyFile('docs', TDMC_DOCS_PATH.'/credits.txt', 'credits.txt');
154
        // Creation of 'install.txt' file
155
        $this->copyFile('docs', TDMC_DOCS_PATH.'/install.txt', 'install.txt');
156
        // Creation of 'lang_diff.txt' file
157
        $this->copyFile('docs', TDMC_DOCS_PATH.'/lang_diff.txt', 'lang_diff.txt');
158
        // Creation of 'license.txt' file
159
        $this->copyFile('docs', TDMC_DOCS_PATH.'/license.txt', 'license.txt');
160
        // Creation of 'readme.txt' file
161
        $this->copyFile('docs', TDMC_DOCS_PATH.'/readme.txt', 'readme.txt');
162
        // Creation of "include" folder and index.html file
163
        $this->makeDirAndCopyFile('include', $indexFile, 'index.html');
164
        // Creation of "language" folder and index.html file
165
        $this->makeDirAndCopyFile('language', $indexFile, 'index.html');
166
        // Creation of 'default english' folder
167 View Code Duplication
        if ($language != 'english') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
168
            // Creation of "language/local_language" folder and index.html file
169
            $this->makeDirAndCopyFile('language/'.$language, $indexFile, 'index.html');
170
            // Creation of "language/local_language/help" folder and index.html file
171
            $this->makeDirAndCopyFile('language/'.$language.'/help', $indexFile, 'index.html');
172
        }
173
        // Creation of "english" folder and index.html file
174
        $this->makeDirAndCopyFile('language/english', $indexFile, 'index.html');
175
        // Creation of "language/english/help" folder and index.html file
176
        $this->makeDirAndCopyFile('language/english/help', $indexFile, 'index.html');
177
        // Creation of "preloads" folder and index.html file
178
        $this->makeDirAndCopyFile('preloads', $indexFile, 'index.html');
179
        if (1 == $module->getVar('mod_admin')) {
180
            // Creation of "templates" folder and index.html file
181
            $this->makeDirAndCopyFile('templates', $indexFile, 'index.html');
182
        }
183
        if (1 == $module->getVar('mod_admin')) {
184
            // Creation of "templates/admin" folder and index.html file
185
            $this->makeDirAndCopyFile('templates/admin', $indexFile, 'index.html');
186
        }
187
        if (!empty($tableName)) {
188
            if ((1 == $module->getVar('mod_blocks')) && (1 == $table->getVar('table_blocks'))) {
189
                // Creation of "templates/blocks" folder and index.html file
190
                $this->makeDirAndCopyFile('templates/blocks', $indexFile, 'index.html');
191
            }
192
            // Creation of "sql" folder and index.html file
193
            $this->makeDirAndCopyFile('sql', $indexFile, 'index.html');
194
            if ((1 == $module->getVar('mod_notifications')) && (1 == $table->getVar('table_notifications'))) {
195 View Code Duplication
                if ($language != 'english') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
196
                    // Creation of "language/local_language/mail_template" folder and index.html file
197
                    $this->makeDirAndCopyFile('language/'.$language.'/mail_template', $indexFile, 'index.html');
198
                } else {
199
                    // Creation of "language/english/mail_template" folder and index.html file
200
                    $this->makeDirAndCopyFile('language/english/mail_template', $indexFile, 'index.html');
201
                }
202
            }
203
        }
204
    }
205
206
    /*
207
    *  @public function setFilesToBuilding
208
    *  @param string $module
209
    */
210
    /**
211
     * @param $module
212
     *
213
     * @return array
214
     */
215
    public function setFilesToBuilding($module)
216
    {
217
        // Module
218
        $modId = $module->getVar('mod_id');
219
        $moduleDirname = $module->getVar('mod_dirname');
220
        $icon32 = 'assets/icons/32';
221
        $tables = $this->tdmcfile->getTableTables($modId);
222
        $files = $this->tdmcfile->getTableMoreFiles($modId);
223
        $ret = array();
224
        //
225
        $table = array();
226
        $tableCategory = array();
227
		$tableName = array();
0 ignored issues
show
Unused Code introduced by
$tableName is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
228
        $tableImage = array();
0 ignored issues
show
Unused Code introduced by
$tableImage is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
229
        $tableAdmin = array();
230
        $tableUser = array();
231
        $tableBlocks = array();
232
        $tableSearch = array();
233
        $tableComments = array();
234
        $tableNotifications = array();
235
        $tablePermissions = array();
236
        $tableBroken = array();
237
        $tablePdf = array();
238
        $tablePrint = array();
239
        $tableRate = array();
240
        $tableRss = array();
241
        $tableSingle = array();
242
        $tableSubmit = array();
243
        $tableVisit = array();
244
        $tableTag = array();
245
        foreach (array_keys($tables) as $t) {
246
            $tableMid = $tables[$t]->getVar('table_mid');
0 ignored issues
show
Unused Code introduced by
$tableMid is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
247
            $tableId = $tables[$t]->getVar('table_id');
248
            $tableName = $tables[$t]->getVar('table_name');
249
            $tableCategory[] = $tables[$t]->getVar('table_category');
250
            $tableImage = $tables[$t]->getVar('table_image');
251
            $tableAdmin[] = $tables[$t]->getVar('table_admin');
252
            $tableUser[] = $tables[$t]->getVar('table_user');
253
            $tableBlocks[] = $tables[$t]->getVar('table_blocks');
254
            $tableSearch[] = $tables[$t]->getVar('table_search');
255
            $tableComments[] = $tables[$t]->getVar('table_comments');
256
            $tableNotifications[] = $tables[$t]->getVar('table_notifications');
257
            $tablePermissions[] = $tables[$t]->getVar('table_permissions');
258
            $tableBroken[] = $tables[$t]->getVar('table_broken');
259
            $tablePdf[] = $tables[$t]->getVar('table_pdf');
260
            $tablePrint[] = $tables[$t]->getVar('table_print');
261
            $tableRate[] = $tables[$t]->getVar('table_rate');
262
            $tableRss[] = $tables[$t]->getVar('table_rss');
263
            $tableSingle[] = $tables[$t]->getVar('table_single');
264
            $tableSubmit[] = $tables[$t]->getVar('table_submit');
265
            $tableVisit[] = $tables[$t]->getVar('table_visit');
266
            $tableTag[] = $tables[$t]->getVar('table_tag');
267
            // Get Table Object
268
            $table = $this->tdmcreate->getHandler('tables')->get($tableId);
269
            // Copy of tables images file
270
            if (file_exists($uploadTableImage = TDMC_UPLOAD_IMGTAB_PATH.'/'.$tableImage)) {
271
                $this->copyFile($icon32, $uploadTableImage, $tableImage);
272
            } elseif (file_exists($uploadTableImage = XOOPS_ICONS32_PATH.'/'.$tableImage)) {
273
                $this->copyFile($icon32, $uploadTableImage, $tableImage);
274
            }
275
            // Creation of admin files
276 View Code Duplication
            if (in_array(1, $tableAdmin)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
277
                // Admin Pages File
278
                $adminPages = AdminPages::getInstance();
279
                $adminPages->write($module, $table);
280
                $ret[] = $adminPages->renderFile($tableName.'.php');
281
                // Admin Templates File
282
                $adminTemplatesPages = TemplatesAdminPages::getInstance();
283
                $adminTemplatesPages->write($module, $table);
284
                $ret[] = $adminTemplatesPages->renderFile($moduleDirname.'_admin_'.$tableName.'.tpl');
285
            }
286
            // Creation of blocks
287 View Code Duplication
            if (in_array(1, $tableBlocks)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
288
                // Blocks Files
289
                $blocksFiles = BlocksFiles::getInstance();
290
                $blocksFiles->write($module, $table);
291
                $ret[] = $blocksFiles->renderFile($tableName.'.php');
292
                // Templates Blocks Files
293
                $templatesBlocks = TemplatesBlocks::getInstance();
294
                $templatesBlocks->write($module, $table);
295
                $ret[] = $templatesBlocks->renderFile($moduleDirname.'_block_'.$tableName.'.tpl');
296
            }
297
            // Creation of classes
298
            if (in_array(1, $tableAdmin) || in_array(1, $tableUser)) {
299
                // Class Files
300
                $classFiles = ClassFiles::getInstance();
301
                $classFiles->write($module, $table, $tables);
302
                $ret[] = $classFiles->renderFile($tableName.'.php');
303
            }
304
            // Creation of user files
305
            if (in_array(1, $tableUser)) {
306
                // User Pages File
307
                $userPages = UserPages::getInstance();
308
                $userPages->write($module, $table, $tableName.'.php');
309
                $ret[] = $userPages->renderFile();
310 View Code Duplication
                if (in_array(0, $tableCategory)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
311
                    // User Templates File
312
                    $userTemplatesPages = TemplatesUserPages::getInstance();
313
                    $userTemplatesPages->write($module, $table);
314
                    $ret[] = $userTemplatesPages->renderFile($moduleDirname.'_'.$tableName.'.tpl');
315
                    // User List Templates File
316
                    $userTemplatesPagesList = TemplatesUserPagesList::getInstance();
317
                    $userTemplatesPagesList->write($module, $table, $tables, $moduleDirname.'_'.$tableName.'_list'.'.tpl');
318
                    $ret[] = $userTemplatesPagesList->renderFile();
319
                }
320 View Code Duplication
                if (in_array(1, $tableCategory)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
321
                    // User List Templates File
322
                    $userTemplatesCategories = TemplatesUserCategories::getInstance();
323
                    $userTemplatesCategories->write($module, $table);
324
                    $ret[] = $userTemplatesCategories->renderFile($moduleDirname.'_'.$tableName.'.tpl');
325
                    // User List Templates File
326
                    $userTemplatesCategoriesList = TemplatesUserCategoriesList::getInstance();
327
                    $userTemplatesCategoriesList->write($module, $table);
328
                    $ret[] = $userTemplatesCategoriesList->renderFile($moduleDirname.'_'.$tableName.'_list'.'.tpl');
329
                }
330
            }
331
        }
332
        foreach (array_keys($files) as $t) {
333
            $fileName = $files[$t]->getVar('file_name');
334
            $fileExtension = $files[$t]->getVar('file_extension');
335
            $fileInfolder = $files[$t]->getVar('file_infolder');
336
            // More File
337
            $moreFiles = TDMCreateMoreFiles::getInstance();
338
            $moreFiles->write($module, $fileName, $fileInfolder, $fileExtension);
339
            $ret[] = $moreFiles->render();
340
        }
341
        // Language Modinfo File
342
        $languageModinfo = LanguageModinfo::getInstance();
343
        $languageModinfo->write($module, $table, $tables, 'modinfo.php');
344
        $ret[] = $languageModinfo->render();
345
        if (1 == $module->getVar('mod_admin')) {
346
            // Admin Header File
347
            $adminHeader = AdminHeader::getInstance();
348
            $adminHeader->write($module, $table, $tables, 'header.php');
349
            $ret[] = $adminHeader->render();
350
            // Admin Index File
351
            $adminIndex = AdminIndex::getInstance();
352
            $adminIndex->write($module, $tables, 'index.php');
353
            $ret[] = $adminIndex->render();
354
            // Admin Menu File
355
            $adminMenu = AdminMenu::getInstance();
356
            $adminMenu->write($module, $tables, 'menu.php');
357
            $ret[] = $adminMenu->render();
358
            // Admin About File
359
            $adminAbout = AdminAbout::getInstance();
360
            $adminAbout->write($module, 'about.php');
361
            $ret[] = $adminAbout->render();
362
            // Admin Footer File
363
            $adminFooter = AdminFooter::getInstance();
364
            $adminFooter->write($module, 'footer.php');
365
            $ret[] = $adminFooter->render();
366
            // Templates Admin About File
367
            $adminTemplatesAbout = TemplatesAdminAbout::getInstance();
368
            $adminTemplatesAbout->write($module, $moduleDirname.'_admin_about.tpl');
369
            $ret[] = $adminTemplatesAbout->render();
370
            // Templates Admin Index File
371
            $adminTemplatesIndex = TemplatesAdminIndex::getInstance();
372
            $adminTemplatesIndex->write($module, $moduleDirname.'_admin_index.tpl');
373
            $ret[] = $adminTemplatesIndex->render();
374
            // Templates Admin Footer File
375
            $adminTemplatesFooter = TemplatesAdminFooter::getInstance();
376
            $adminTemplatesFooter->write($module, $moduleDirname.'_admin_footer.tpl');
377
            $ret[] = $adminTemplatesFooter->render();
378
            // Templates Admin Header File
379
            $adminTemplatesHeader = TemplatesAdminHeader::getInstance();
380
            $adminTemplatesHeader->write($module, $moduleDirname.'_admin_header.tpl');
381
            $ret[] = $adminTemplatesHeader->render();
382
            // Language Admin File
383
            $languageAdmin = LanguageAdmin::getInstance();
384
            $languageAdmin->write($module, $table, $tables, 'admin.php');
385
            $ret[] = $languageAdmin->render();
386
        }
387
        // Class Helper File
388
        $classHelper = ClassHelper::getInstance();
389
        $classHelper->write($module, 'helper.php');
390
        $ret[] = $classHelper->render();
391
        // Include Functions File
392
        $includeFunctions = IncludeFunctions::getInstance();
393
        $includeFunctions->write($module, $table, 'functions.php');
394
        $ret[] = $includeFunctions->render();
395
        // Creation of blocks language file
396
        if ($table->getVar('table_name') != null) {
397
            // Include Install File
398
            $includeInstall = IncludeInstall::getInstance();
399
            $includeInstall->write($module, $table, $tables, 'install.php');
400
            $ret[] = $includeInstall->render();
401
            if (in_array(1, $tableBlocks)) {
402
                // Language Blocks File
403
                $languageBlocks = LanguageBlocks::getInstance();
404
                $languageBlocks->write($module, $tables, 'blocks.php');
405
                $ret[] = $languageBlocks->render();
406
            }
407
            // Creation of admin permission files
408
            if (in_array(1, $tablePermissions)) {
409
                // Admin Permissions File
410
                $adminPermissions = AdminPermissions::getInstance();
411
                $adminPermissions->write($module, $tables, 'permissions.php');
412
                $ret[] = $adminPermissions->render();
413
                // Templates Admin Permissions File
414
                $adminTemplatesPermissions = TemplatesAdminPermissions::getInstance();
415
                $adminTemplatesPermissions->write($module, $moduleDirname.'_admin_permissions.tpl');
416
                $ret[] = $adminTemplatesPermissions->render();
417
            }
418
            // Creation of notifications files
419 View Code Duplication
            if (in_array(1, $tableNotifications)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
420
                // Include Notifications File
421
                $includeNotifications = IncludeNotifications::getInstance();
422
                $includeNotifications->write($module, $table, 'notifications.inc.php');
423
                $ret[] = $includeNotifications->render();
424
                // Language Mail Template Category File
425
                $languageMailTpl = LanguageMailTpl::getInstance();
426
                $languageMailTpl->write($module);
427
                $ret[] = $languageMailTpl->renderFile('category_new_notify.tpl');
428
            }
429
            // Creation of sql file
430 View Code Duplication
            if ($table->getVar('table_name') != null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
431
                // Sql File
432
                $sqlFile = SqlFile::getInstance();
433
                $sqlFile->write($module, $tables, 'mysql.sql');
434
                $ret[] = $sqlFile->render();
435
                // Include Update File
436
                $includeUpdate = IncludeUpdate::getInstance();
437
                $includeUpdate->write($module, 'update.php');
438
                $ret[] = $includeUpdate->renderFile();
439
            }
440
            // Creation of search file
441
            if (in_array(1, $tableSearch)) {
442
                // Include Search File
443
                $includeSearch = IncludeSearch::getInstance();
444
                $includeSearch->write($module, $table, 'search.inc.php');
445
                $ret[] = $includeSearch->render();
446
            }
447
            // Creation of comments files
448
            if (in_array(1, $tableComments)) {
449
                // Include Comments File
450
                $includeComments = IncludeComments::getInstance();
451
                $includeComments->write($module, $table);
452
                $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_edit');
453
                // Include Comments File
454
                $includeComments = IncludeComments::getInstance();
455
                $includeComments->write($module, $table);
456
                $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_delete');
457
                // Include Comments File
458
                $includeComments = IncludeComments::getInstance();
459
                $includeComments->write($module, $table);
460
                $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_post');
461
                // Include Comments File
462
                $includeComments = IncludeComments::getInstance();
463
                $includeComments->write($module, $table);
464
                $ret[] = $includeComments->renderCommentsIncludes($module, 'comment_reply');
465
                // Include Comments File
466
                $includeComments = IncludeComments::getInstance();
467
                $includeComments->write($module, $table);
468
                $ret[] = $includeComments->renderCommentsNew($module, 'comment_new');
469
                // Include Comment Functions File
470
                $includeCommentFunctions = IncludeCommentFunctions::getInstance();
471
                $includeCommentFunctions->write($module, $table, 'comment_functions.php');
472
                $ret[] = $includeCommentFunctions->renderFile();
473
            }
474
        }
475
        // Creation of admin files
476
        if (1 == $module->getVar('mod_admin')) {
477
            // Templates Index File
478
            $userTemplatesIndex = TemplatesUserIndex::getInstance();
479
            $userTemplatesIndex->write($module, $table, $tables, $moduleDirname.'_index.tpl');
480
            $ret[] = $userTemplatesIndex->render();
481
            // Templates Footer File
482
            $userTemplatesFooter = TemplatesUserFooter::getInstance();
483
            $userTemplatesFooter->write($module, $table, $moduleDirname.'_footer.tpl');
484
            $ret[] = $userTemplatesFooter->render();
485
            // Templates Header File
486
            $userTemplatesHeader = TemplatesUserHeader::getInstance();
487
            $userTemplatesHeader->write($module, $moduleDirname.'_header.tpl');
488
            $ret[] = $userTemplatesHeader->render();
489
        }
490
        // Creation of user files
491
        if ((1 == $module->getVar('mod_user')) && in_array(1, $tableUser)) {
492
            // User Footer File
493
            $userFooter = UserFooter::getInstance();
494
            $userFooter->write($module, 'footer.php');
495
            $ret[] = $userFooter->render();
496
            // User Header File
497
            $userHeader = UserHeader::getInstance();
498
            $userHeader->write($module, $table, $tables, 'header.php');
499
            $ret[] = $userHeader->render();
500
            // User Notification Update File
501
            if ((1 == $module->getVar('mod_notifications')) && in_array(1, $tableNotifications)) {
502
                $userNotificationUpdate = UserNotificationUpdate::getInstance();
503
                $userNotificationUpdate->write($module, 'notification_update.php');
504
                $ret[] = $userNotificationUpdate->render();
505
            }
506
            // User Broken File
507 View Code Duplication
            if (in_array(1, $tableBroken)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
508
                $userBroken = UserBroken::getInstance();
509
                $userBroken->write($module, $table, 'broken.php');
510
                $ret[] = $userBroken->render();
511
                // User Templates Broken File
512
                $userTemplatesBroken = TemplatesUserBroken::getInstance();
513
                $userTemplatesBroken->write($module, $table);
514
                $ret[] = $userTemplatesBroken->renderFile($moduleDirname.'_broken.tpl');
515
            }
516
            // User Pdf File
517 View Code Duplication
            if (in_array(1, $tablePdf)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
518
                $userPdf = UserPdf::getInstance();
519
                $userPdf->write($module, $table, 'pdf.php');
520
                $ret[] = $userPdf->render();
521
                // User Templates Pdf File
522
                $userTemplatesPdf = TemplatesUserPdf::getInstance();
523
                $userTemplatesPdf->write($module);
524
                $ret[] = $userTemplatesPdf->renderFile($moduleDirname.'_pdf.tpl');
525
            }
526
            // User Print File
527 View Code Duplication
            if (in_array(1, $tablePrint)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
528
                $userPrint = UserPrint::getInstance();
529
                $userPrint->write($module, $table, 'print.php');
530
                $ret[] = $userPrint->render();
531
                // User Templates Print File
532
                $userTemplatesPrint = TemplatesUserPrint::getInstance();
533
                $userTemplatesPrint->write($module, $table);
534
                $ret[] = $userTemplatesPrint->renderFile($moduleDirname.'_print.tpl');
535
            }
536
            // User Rate File
537 View Code Duplication
            if (in_array(1, $tableRate)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
538
                $userRate = UserRate::getInstance();
539
                $userRate->write($module, $table, 'rate.php');
540
                $ret[] = $userRate->render();
541
                // User Templates Rate File
542
                $userTemplatesRate = TemplatesUserRate::getInstance();
543
                $userTemplatesRate->write($module, $table);
544
                $ret[] = $userTemplatesRate->renderFile($moduleDirname.'_rate.tpl');
545
            }
546
            // User Rss File
547 View Code Duplication
            if (in_array(1, $tableRss)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
548
                $userRss = UserRss::getInstance();
549
                $userRss->write($module, $table, 'rss.php');
550
                $ret[] = $userRss->render();
551
                // User Templates Rss File
552
                $userTemplatesRss = TemplatesUserRss::getInstance();
553
                $userTemplatesRss->write($module);
554
                $ret[] = $userTemplatesRss->renderFile($moduleDirname.'_rss.tpl');
555
            }
556
            // User Single File
557 View Code Duplication
            if (in_array(1, $tableSingle)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
558
                $userSingle = UserSingle::getInstance();
559
                $userSingle->write($module, $table, 'single.php');
560
                $ret[] = $userSingle->render();
561
                // User Templates Single File
562
                $userTemplatesSingle = TemplatesUserSingle::getInstance();
563
                $userTemplatesSingle->write($module, $table);
564
                $ret[] = $userTemplatesSingle->renderFile($moduleDirname.'_single.tpl');
565
            }
566
            // User Submit File
567 View Code Duplication
            if (in_array(1, $tableSubmit)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
568
                $userSubmit = UserSubmit::getInstance();
569
                $userSubmit->write($module, $table, 'submit.php');
570
                $ret[] = $userSubmit->render();
571
                // User Templates Submit File
572
                $userTemplatesSubmit = TemplatesUserSubmit::getInstance();
573
                $userTemplatesSubmit->write($module, $table);
574
                $ret[] = $userTemplatesSubmit->renderFile($moduleDirname.'_submit.tpl');
575
            }// User Visit File
576
            if (in_array(1, $tableVisit)) {
577
                $userVisit = UserVisit::getInstance();
578
                $userVisit->write($module, $table, 'visit.php');
579
                $ret[] = $userVisit->render();
580
            }
581
            // User Tag Files
582
            if (in_array(1, $tableTag)) {
583
                $userListTag = UserListTag::getInstance();
584
                $userListTag->write($module, 'list.tag.php');
585
                $ret[] = $userListTag->render();
586
                $userViewTag = UserViewTag::getInstance();
587
                $userViewTag->write($module, 'view.tag.php');
588
                $ret[] = $userViewTag->render();
589
            }
590
            // User Index File
591
            $userIndex = UserIndex::getInstance();
592
            $userIndex->write($module, $table, 'index.php');
593
            $ret[] = $userIndex->render();
594
            // Language Main File
595
            $languageMain = LanguageMain::getInstance();
596
            $languageMain->write($module, $tables, 'main.php');
597
            $ret[] = $languageMain->render();
598
            // User Templates Submit File
599
            $userTemplatesUserBreadcrumbs = TemplatesUserBreadcrumbs::getInstance();
600
            $userTemplatesUserBreadcrumbs->write($module, $moduleDirname.'_breadcrumbs.tpl');
601
            $ret[] = $userTemplatesUserBreadcrumbs->render();
602
        }
603
        // Css Styles File
604
        $cssStyles = CssStyles::getInstance();
605
        $cssStyles->write($module, 'style.css');
606
        $ret[] = $cssStyles->render();
607
        // Include Jquery File
608
        $JavascriptJQuery = JavascriptJQuery::getInstance();
609
        $JavascriptJQuery->write($module, 'functions.js');
610
        $ret[] = $JavascriptJQuery->render();
611
        // Include Common File
612
        $includeCommon = IncludeCommon::getInstance();
613
        $includeCommon->write($module, $table, 'common.php');
614
        $ret[] = $includeCommon->render();
615
        // Docs Changelog File
616
        $docsChangelog = DocsChangelog::getInstance();
617
        $docsChangelog->write($module, 'changelog.txt');
618
        $ret[] = $docsChangelog->render();
619
        // Language Help File
620
        $languageHelp = LanguageHelp::getInstance();
621
        $languageHelp->write($module, 'help.html');
622
        $ret[] = $languageHelp->render();
623
        // User Xoops Version File
624
        $userXoopsVersion = UserXoopsVersion::getInstance();
625
        $userXoopsVersion->write($module, $table, $tables, 'xoops_version.php');
626
        $ret[] = $userXoopsVersion->render();
627
628
        // Return Array
629
        return $ret;
630
    }
631
}
632