Completed
Push — master ( 937117...931dfe )
by Michael
05:45 queued 02:42
created

ModuleConfigurator::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 40
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 40
rs 8.8571
c 0
b 0
f 0
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 27 and the first side effect is on line 20.

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
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    XOOPS Project http://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package
16
 * @since
17
 * @author       XOOPS Development Team
18
 */
19
20
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php';
21
22
$moduleDirName = basename(dirname(__DIR__));
23
$capsDirName   = strtoupper($moduleDirName);
24
25
//if (!defined($moduleDirName . '_DIRNAME')) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
if (!defined($capsDirName . '_DIRNAME')) {
27
    define($capsDirName . '_DIRNAME', $GLOBALS['xoopsModule']->dirname());
28
    define($capsDirName . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
29
    define($capsDirName . '_URL', XOOPS_URL . '/modules/' . constant($capsDirName . '_DIRNAME'));
30
    define($capsDirName . '_ADMIN', constant($capsDirName . '_URL') . '/admin/index.php');
31
    define($capsDirName . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($capsDirName . '_DIRNAME'));
32
    define($capsDirName . '_AUTHOR_LOGOIMG', constant($capsDirName . '_URL') . '/assets/images/logoModule.png');
33
}
34
35
// Define here the place where main upload path
36
37
//$img_dir = $GLOBALS['xoopsModuleConfig']['uploaddir'];
0 ignored issues
show
Unused Code Comprehensibility introduced by
75% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
39
define($capsDirName . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
//define("SOAPBOX_UPLOAD_PATH", $img_dir); // WITHOUT Trailing slash
41
define($capsDirName . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
42
43
//constant($cloned_lang . '_CATEGORY_NOTIFY')
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
44
45
$uploadFolders = array(
46
    constant($capsDirName . '_UPLOAD_PATH'),
47
    constant($capsDirName . '_UPLOAD_PATH') . '/images',
48
    constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails'
49
);
50
51
$copyFiles = array(
52
    constant($capsDirName . '_UPLOAD_PATH'),
53
    constant($capsDirName . '_UPLOAD_PATH') . '/images',
54
    constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails'
55
);
56
57
$oldFiles = array(
58
    '/include/update_functions.php',
59
    '/include/install_functions.php'
60
);
61
62
//Configurator
0 ignored issues
show
Unused Code Comprehensibility introduced by
51% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
63
/*
64
return array(
65
    'name'           => 'Module Configurator',
66
    'uploadFolders'  => array(
67
        constant($capsDirName . '_UPLOAD_PATH'),
68
        constant($capsDirName . '_UPLOAD_PATH') . '/XXX'
69
    ),
70
    'blankFiles' => array(
71
        constant($capsDirName . '_UPLOAD_PATH'),
72
        constant($capsDirName . '_UPLOAD_PATH') . '/XXXX'
73
    ),
74
75
    'templateFolders' => array(
76
        '/templates/',
77
        '/templates/blocks/',
78
        '/templates/admin/'
79
80
    ),
81
    'oldFiles'        => array(
82
        '/include/update_functions.php',
83
        '/include/install_functions.php'
84
    ),
85
    'oldFolders'      => array(
86
        '/images',
87
        '/css',
88
        '/js',
89
        '/tcpdf',
90
        '/images',
91
    ),
92
);
93
*/
94
// module information
95
$modCopyright = "<a href='http://xoops.org' title='XOOPS Project' target='_blank'>
96
                     <img src='" . constant($capsDirName . '_AUTHOR_LOGOIMG') . "' alt='XOOPS Project' /></a>";
97
98
/**
99
 * Class ModuleConfigurator
100
 */
101
class ModuleConfigurator
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...
102
{
103
    public $uploadFolders   = [];
104
    public $blankFiles      = [];
105
    public $templateFolders = [];
106
    public $oldFiles        = [];
107
    public $oldFolders      = [];
108
    public $name;
109
110
    /**
111
     * ModuleConfigurator constructor.
112
     */
113
    public function __construct()
114
    {
115
        $moduleDirName       = basename(dirname(__DIR__));
116
        $capsDirName         = strtoupper($moduleDirName);
117
        $this->name          = 'Module Configurator';
118
        $this->uploadFolders = [
119
            constant($capsDirName . '_UPLOAD_PATH'),
120
            //            constant($capsDirName . '_UPLOAD_PATH') . '/content',
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
121
            constant($capsDirName . '_UPLOAD_PATH') . '/images',
122
            constant($capsDirName . '_UPLOAD_PATH') . '/images/authors',
123
            constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
124
        ];
125
        $this->blankFiles    = [
126
            constant($capsDirName . '_UPLOAD_PATH'),
127
            constant($capsDirName . '_UPLOAD_PATH') . '/images/authors',
128
            constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails',
129
        ];
130
131
        $this->templateFolders = [
132
            '/templates/',
133
            '/templates/blocks/',
134
            '/templates/admin/'
135
136
        ];
137
        $this->oldFiles        = [
138
            //            '/class/request.php',
139
            //            '/class/registry.php',
140
            //            '/class/utilities.php',
141
            //            '/class/util.php',
142
            //            '/include/constants.php',
143
            //            '/include/functions.php',
144
            //            '/ajaxrating.txt'
145
        ];
146
        $this->oldFolders      = [
147
            '/images',
148
            '/css',
149
            '/js',
150
            //            '/tcpdf',
151
        ];
152
    }
153
}
154