|
1
|
|
|
<?php |
|
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
|
|
|
* Module: randomquote |
|
15
|
|
|
* |
|
16
|
|
|
* @category Module |
|
17
|
|
|
* @package randomquote |
|
18
|
|
|
* @author XOOPS Development Team <[email protected]> - <https://xoops.org> |
|
19
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
20
|
|
|
* @license GPL 2.0 or later |
|
21
|
|
|
* @link https://xoops.org/ |
|
22
|
|
|
* @since 1.0.0 |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
use Xoopsmodules\randomquote; |
|
|
|
|
|
|
26
|
|
|
|
|
27
|
|
|
include __DIR__ . '/../preloads/autoloader.php'; |
|
28
|
|
|
|
|
29
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
|
30
|
|
|
$moduleDirNameUpper = strtoupper($moduleDirName); |
|
31
|
|
|
|
|
32
|
|
|
/** @var \XoopsDatabase $db */ |
|
33
|
|
|
/** @var randomquote\Helper $helper */ |
|
34
|
|
|
/** @var randomquote\Utility $utility */ |
|
35
|
|
|
|
|
36
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
37
|
|
|
$helper = randomquote\Helper::getInstance(); |
|
38
|
|
|
$utility = new randomquote\Utility(); |
|
39
|
|
|
|
|
40
|
|
|
$helper->loadLanguage('common'); |
|
41
|
|
|
|
|
42
|
|
|
//handlers |
|
43
|
|
|
/** @var \XoopsPersistableObjectHandler $quotesHandler */ |
|
44
|
|
|
$quotesHandler = new randomquote\QuotesHandler($db); |
|
45
|
|
|
/** @var \XoopsPersistableObjectHandler $categoryHandler */ |
|
46
|
|
|
$categoryHandler = new randomquote\CategoryHandler($db); |
|
47
|
|
|
|
|
48
|
|
|
if (!defined($moduleDirNameUpper . '_CONSTANTS_DEFINED')) { |
|
49
|
|
|
define($moduleDirNameUpper . '_DIRNAME', basename(dirname(__DIR__))); |
|
50
|
|
|
define($moduleDirNameUpper . '_ROOT_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
51
|
|
|
define($moduleDirNameUpper . '_PATH', XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/'); |
|
52
|
|
|
define($moduleDirNameUpper . '_URL', XOOPS_URL . '/modules/' . $moduleDirName); |
|
53
|
|
|
define($moduleDirNameUpper . '_IMAGES_URL', constant($moduleDirNameUpper . '_URL') . '/assets/images/'); |
|
54
|
|
|
define($moduleDirNameUpper . '_IMAGES_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/assets/images/'); |
|
55
|
|
|
define($moduleDirNameUpper . '_ADMIN_URL', constant($moduleDirNameUpper . '_URL') . '/admin/'); |
|
56
|
|
|
define($moduleDirNameUpper . '_ADMIN_PATH', constant($moduleDirNameUpper . '_ROOT_PATH') . '/admin/'); |
|
57
|
|
|
define($moduleDirNameUpper . '_ADMIN', constant($moduleDirNameUpper . '_URL') . '/admin/index.php'); |
|
58
|
|
|
define($moduleDirNameUpper . '_AUTHOR_LOGOIMG', constant($moduleDirNameUpper . '_URL') . '/assets/images/logoModule.png'); |
|
59
|
|
|
define($moduleDirNameUpper . '_UPLOAD_URL', XOOPS_UPLOAD_URL . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
60
|
|
|
define($moduleDirNameUpper . '_UPLOAD_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName); // WITHOUT Trailing slash |
|
61
|
|
|
define($moduleDirNameUpper . '_CAT_IMAGES_URL', XOOPS_UPLOAD_URL . ' / ' . constant($moduleDirNameUpper . '_DIRNAME') . '/images/category'); |
|
62
|
|
|
define($moduleDirNameUpper . '_CAT_IMAGES_PATH', XOOPS_UPLOAD_PATH . '/' . constant($moduleDirNameUpper . '_DIRNAME') . ' / images / category'); |
|
63
|
|
|
define($moduleDirNameUpper . '_CACHE_PATH', XOOPS_UPLOAD_PATH . '/' . $moduleDirName . '/'); |
|
64
|
|
|
define($moduleDirNameUpper . '_CONSTANTS_DEFINED', 1); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
|
|
68
|
|
|
|
|
69
|
|
|
$pathIcon16 = Xmf\Module\Admin::iconUrl('', 16); |
|
70
|
|
|
$pathIcon32 = Xmf\Module\Admin::iconUrl('', 32); |
|
71
|
|
|
|
|
72
|
|
|
$icons = [ |
|
73
|
|
|
'edit' => "<img src='" . $pathIcon16 . "/edit.png' alt=" . _EDIT . "' align='middle'>", |
|
74
|
|
|
'delete' => "<img src='" . $pathIcon16 . "/delete.png' alt='" . _DELETE . "' align='middle'>", |
|
75
|
|
|
'clone' => "<img src='" . $pathIcon16 . "/editcopy.png' alt='" . _CLONE . "' align='middle'>", |
|
76
|
|
|
'preview' => "<img src='" . $pathIcon16 . "/view.png' alt='" . _PREVIEW . "' align='middle'>", |
|
77
|
|
|
'print' => "<img src='" . $pathIcon16 . "/printer.png' alt='" . _CLONE . "' align='middle'>", |
|
78
|
|
|
'pdf' => "<img src='" . $pathIcon16 . "/pdf.png' alt='" . _CLONE . "' align='middle'>", |
|
79
|
|
|
'add' => "<img src='" . $pathIcon16 . "/add.png' alt='" . _ADD . "' align='middle'>", |
|
80
|
|
|
'0' => "<img src='" . $pathIcon16 . "/0.png' alt='" . 0 . "' align='middle'>", |
|
81
|
|
|
'1' => "<img src='" . $pathIcon16 . "/1.png' alt='" . 1 . "' align='middle'>", |
|
82
|
|
|
]; |
|
83
|
|
|
|
|
84
|
|
|
$debug = false; |
|
85
|
|
|
|
|
86
|
|
|
// MyTextSanitizer object |
|
87
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
|
88
|
|
|
|
|
89
|
|
|
if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) { |
|
|
|
|
|
|
90
|
|
|
require_once $GLOBALS['xoops']->path('class/template.php'); |
|
91
|
|
|
$GLOBALS['xoopsTpl'] = new \XoopsTpl(); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
$GLOBALS['xoopsTpl']->assign('mod_url', XOOPS_URL . '/modules/' . $moduleDirName); |
|
95
|
|
|
// Local icons path |
|
96
|
|
|
if (is_object($helper->getModule())) { |
|
97
|
|
|
$pathModIcon16 = $helper->getModule()->getInfo('modicons16'); |
|
98
|
|
|
$pathModIcon32 = $helper->getModule()->getInfo('modicons32'); |
|
99
|
|
|
|
|
100
|
|
|
$GLOBALS['xoopsTpl']->assign('pathModIcon16', XOOPS_URL . '/modules/' . $moduleDirName . '/' . $pathModIcon16); |
|
101
|
|
|
$GLOBALS['xoopsTpl']->assign('pathModIcon32', $pathModIcon32); |
|
102
|
|
|
} |
|
103
|
|
|
|
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: