Passed
Push — master ( 81ba93...c6c854 )
by Michael
03:30
created

include/common.php (1 issue)

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

90
    $GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . /** @scrutinizer ignore-type */ $pathModIcon16);
Loading history...
91
    $GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32);
92
}
93