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 Xmf\Request; |
26
|
|
|
use Xoopsmodules\randomquote; |
|
|
|
|
27
|
|
|
use Xoopsmodules\randomquote\common; |
28
|
|
|
|
29
|
|
|
require_once __DIR__ . '/admin_header.php'; |
30
|
|
|
xoops_cp_header(); |
31
|
|
|
|
32
|
|
|
//count "total Quotes" |
33
|
|
|
/** @var XoopsPersistableObjectHandler $quotesHandler */ |
34
|
|
|
$totalQuotes = $quotesHandler->getCount(); |
35
|
|
|
//count "total Category" |
36
|
|
|
/** @var XoopsPersistableObjectHandler $categoryHandler */ |
37
|
|
|
$totalCategory = $categoryHandler->getCount(); |
38
|
|
|
// InfoBox Statistics |
39
|
|
|
$adminObject->addInfoBox(AM_RANDOMQUOTE_STATISTICS); |
40
|
|
|
|
41
|
|
|
// InfoBox quotes |
42
|
|
|
$adminObject->addInfoBoxLine(sprintf(AM_RANDOMQUOTE_THEREARE_QUOTE, $totalQuotes)); |
43
|
|
|
|
44
|
|
|
// InfoBox category |
45
|
|
|
$adminObject->addInfoBoxLine(sprintf(AM_RANDOMQUOTE_THEREARE_CATEGORY, $totalCategory)); |
46
|
|
|
// Render Index |
47
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
48
|
|
|
|
49
|
|
|
//------------- Test Data ---------------------------- |
50
|
|
|
|
51
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
52
|
|
|
xoops_loadLanguage('admin/modulesadmin', 'system'); |
53
|
|
|
require_once __DIR__ . '/../testdata/index.php'; |
54
|
|
|
$adminObject->addItemButton(_AM_SYSTEM_MODULES_INSTALL_TESTDATA, '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
55
|
|
|
$adminObject->displayButton('left', ''); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
require_once __DIR__ . '/../testdata/index.php'; |
59
|
|
|
$adminObject->addItemButton(AM_RANDOMQUOTE_ADD_SAMPLEDATA, '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
60
|
|
|
$adminObject->displayButton('left', ''); |
61
|
|
|
|
62
|
|
|
//------------- End Test Data ---------------------------- |
63
|
|
|
|
64
|
|
|
$adminObject->displayIndex(); |
65
|
|
|
|
66
|
|
|
echo $utility::getServerStats(); |
67
|
|
|
|
68
|
|
|
//codeDump(__FILE__); |
69
|
|
|
require_once __DIR__ . '/admin_footer.php'; |
70
|
|
|
|
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are 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.php
However, as
OtherDir/Foo.php
does 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: