Passed
Pull Request — master (#38)
by Michael
14:29 queued 11:00
created

include/common.php (1 issue)

Labels
Severity
1
<?php declare(strict_types=1);
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 (https://xoops.org)
14
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author       XOOPS Development Team
16
 */
17
18
use XoopsModules\News;
19
use XoopsModules\News\Utility;
20
21
require_once \dirname(__DIR__) . '/preloads/autoloader.php';
22
23
$moduleDirName      = \basename(\dirname(__DIR__));
24
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
25
26
/** @var \XoopsDatabase $db */
27
/** @var News\Helper $helper */
28
/** @var News\Utility $utility */
29
$db      = \XoopsDatabaseFactory::getDatabaseConnection();
30
$helper  = News\Helper::getInstance();
31
$utility = new Utility();
32
//$configurator = new \XoopsModules\News\Common\Configurator();
33
34
$helper->loadLanguage('common');
35
36
//handlers
37
//$categoryHandler     = new \XoopsModules\News\CategoryHandler($db);
38
//$downloadHandler     = new \XoopsModules\News\DownloadHandler($db);
39
40
if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) {
41
    define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__)));
42
    define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/');
43
    define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName . '/');
44
    define($moduleDirNameUpper . '_IMAGE_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/');
45
    define($moduleDirNameUpper . '_IMAGE_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images');
46
    define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/');
47
    define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/');
48
    define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . constant($moduleDirNameUpper . '_DIRNAME'));
49
    define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php');
50
    define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png');
51
    define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash
52
    define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash
53
    define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1);
54
}
55
56
$pathIcon16 = Xmf\Module\Admin::iconUrl('', '16');
57
$pathIcon32 = Xmf\Module\Admin::iconUrl('', '32');
58
//$pathModIcon16 = $helper->getModule()->getInfo('modicons16');
59
//$pathModIcon32 = $helper->getModule()->getInfo('modicons32');
60
61
$icons = [
62
    'edit'    => "<img src='" . $pathIcon16 . "/edit.png'  alt=" . _EDIT . "' align='middle'>",
63
    'delete'  => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>",
64
    'clone'   => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>",
65
    'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>",
66
    'print'   => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>",
67
    'pdf'     => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>",
68
    'add'     => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>",
69
    '0'       => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>",
70
    '1'       => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>",
71
];
72
73
$debug = false;
74
75
// MyTextSanitizer object
76
$myts = \MyTextSanitizer::getInstance();
77
78
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
79
    require_once $GLOBALS['xoops']->path('class/template.php');
80
    $GLOBALS['xoopsTpl'] = new \XoopsTpl();
81
}
82
83
$GLOBALS['xoopsTpl']->assign('mod_url', $helper->url());
84
// Local icons path
85
if (is_object($helper->getModule())) {
86
    $pathModIcon16 = $helper->getModule()->getInfo('modicons16');
87
    $pathModIcon32 = $helper->getModule()->getInfo('modicons32');
88
89
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16);
90
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
91
}
92
93
xoops_loadLanguage('admin', $moduleDirName);
94
xoops_loadLanguage('main', $moduleDirName);
95
if (class_exists('D3LanguageManager')) {
96
    require_once XOOPS_TRUST_PATH . "/libs/altsys/class/D3LanguageManager.class.php";
97
    $langman = D3LanguageManager::getInstance();
0 ignored issues
show
The type D3LanguageManager 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...
98
    $langman->read('admin.php', $moduleDirName);
99
    $langman->read('main.php', $moduleDirName);
100
}
101
102