Completed
Push — master ( 141e43...3982f3 )
by Michael
10s
created

ModuleConfigurator::__construct()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 22
nc 1
nop 0
dl 0
loc 31
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(constant($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("XFGBX_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
44% 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 = [
46
    constant($capsDirName . '_UPLOAD_PATH'),
47
    constant($capsDirName . '_UPLOAD_PATH') . '/images',
48
    constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails'
49
];
50
51
52
$copyFiles = [
53
    constant($capsDirName . '_UPLOAD_PATH'),
54
    constant($capsDirName . '_UPLOAD_PATH') . '/images',
55
    constant($capsDirName . '_UPLOAD_PATH') . '/images/thumbnails'
56
];
57
58
$oldFiles = [
59
    '/include/update_functions.php',
60
    '/include/install_functions.php'
61
];
62
63
*/
64
65
/*
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...
66
//Configurator
67
return array(
68
    'name'          => 'Module Configurator',
69
    'uploadFolders' => array(
70
        constant($capsDirName . '_UPLOAD_PATH'),
71
        constant($capsDirName . '_UPLOAD_PATH') . '/XXX'
72
    ),
73
    'blankFiles'     => array(
74
        constant($capsDirName . '_UPLOAD_PATH'),
75
        constant($capsDirName . '_UPLOAD_PATH') . '/XXXX'
76
    ),
77
78
    'templateFolders' => array(
79
        '/templates/',
80
        '/templates/blocks/',
81
        '/templates/admin/'
82
83
    ),
84
    'oldFiles'        => array(
85
        '/include/update_functions.php',
86
        '/include/install_functions.php'
87
    ),
88
    'oldFolders'        => array(
89
        '/images',
90
        '/css',
91
        '/js',
92
        '/tcpdf',
93
        '/images',
94
    ),
95
);
96
*/
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') . '/midsize',
121
            constant($capsDirName . '_UPLOAD_PATH') . '/thumbs',
122
        ];
123
        $this->blankFiles    = [
124
            constant($capsDirName . '_UPLOAD_PATH'),
125
            constant($capsDirName . '_UPLOAD_PATH') . '/midsize',
126
            constant($capsDirName . '_UPLOAD_PATH') . '/thumbs',
127
        ];
128
129
        $this->templateFolders = [
130
            '/templates/',
131
            '/templates/blocks/',
132
            '/templates/admin/'
133
134
        ];
135
        $this->oldFiles        = [
136
            '/admin/admin.css',
137
            '/include/functions.php',
138
        ];
139
        $this->oldFolders      = [
140
            '/images',
141
            '/style',
142
        ];
143
    }
144
}
145
146
// module information
147
$modCopyright = "<a href='http://xoops.org' title='XOOPS Project' target='_blank'>
148
                     <img src='" . constant($capsDirName . '_AUTHOR_LOGOIMG') . '\' alt=\'XOOPS Project\' /></a>';
149