Passed
Pull Request — master (#88)
by Michael
02:56
created

include/common.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
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
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package
17
 * @since
18
 * @author       XOOPS Development Team
19
 */
20
21
use Xmf\Module\Admin;
22
use XoopsModules\Tdmdownloads;
23
use XoopsModules\Tdmdownloads\Helper;
24
25
require dirname(__DIR__) . '/preloads/autoloader.php';
26
27
$moduleDirName      = basename(dirname(__DIR__));
28
$moduleDirNameUpper = mb_strtoupper($moduleDirName); //$capsDirName
29
30
/** @var \XoopsDatabase $db */
31
/** @var \XoopsModules\Tdmdownloads\Helper $helper */
32
/** @var \XoopsModules\Tdmdownloads\Utility $utility */
33
$db      = \XoopsDatabaseFactory::getDatabaseConnection();
34
$debug   = false;
35
$helper  = Helper::getInstance($debug);
36
$utility = new \XoopsModules\Tdmdownloads\Utility();
37
//$configurator = new Tdmdownloads\Common\Configurator();
38
39
$helper->loadLanguage('common');
40
41
//handlers
42
//appel des class
43
$categoryHandler     = Helper::getInstance()->getHandler('Category');
44
$downloadsHandler    = Helper::getInstance()->getHandler('Downloads');
45
$downlimitHandler    = Helper::getInstance()->getHandler('Downlimit');
46
$ratingHandler       = Helper::getInstance()->getHandler('Rating');
47
$fieldHandler        = Helper::getInstance()->getHandler('Field');
48
$fielddataHandler    = Helper::getInstance()->getHandler('Fielddata');
49
$brokenHandler       = Helper::getInstance()->getHandler('Broken');
50
$modifiedHandler     = Helper::getInstance()->getHandler('Modified');
51
$modifieddataHandler = Helper::getInstance()->getHandler('Modifiedfielddata');
52
53
$pathIcon16 = Admin::iconUrl('', 16);
54
$pathIcon32 = Admin::iconUrl('', 32);
55
56
if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
57
    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
58
59
    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
60
61
    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
62
63
    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
64
65
    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
66
67
    define($moduleDirNameUpper . '_ICONS_URL', constant($moduleDirNameUpper . '_URL') . '/assets/icons/');
68
69
    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
70
71
    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
72
73
    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
74
75
    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
76
77
    //    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
78
    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
79
    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
80
    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', $pathIcon32 . '/xoopsmicrobutton.gif');
81
82
    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
83
}
84
85
$icons = [
86
    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
87
    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
88
    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
89
    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
90
    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
91
    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
92
    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
93
    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
94
    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
95
];
96
97
$debug = false;
98
99
// MyTextSanitizer object
100
$myts = \MyTextSanitizer::getInstance();
101
102
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
103
    require $GLOBALS['xoops']->path('class/template.php');
104
105
    $GLOBALS['xoopsTpl'] = new \XoopsTpl();
106
}
107
108
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName);
109
110
// Local icons path
111
if (is_object($helper->getModule())) {
112
    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
113
114
    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
115
116
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
117
118
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon32);
0 ignored issues
show
Are you sure $pathModIcon32 of type array|string can be used in concatenation? ( Ignorable by Annotation )

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

118
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', XOOPS_URL . '/modules/' . $moduleDirName . '/' . /** @scrutinizer ignore-type */ $pathModIcon32);
Loading history...
119
}
120