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
|
|
|
use Xoops\Core\PreloadItem; |
13
|
|
|
use Xoops\Core\Kernel\Handlers\XoopsModule; |
|
|
|
|
14
|
|
|
use Xoops\Module\Plugin; |
15
|
|
|
use Xoops\Module\Plugin\ConfigCollector; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Comments core preloads |
20
|
|
|
* |
21
|
|
|
* @copyright XOOPS Project (http://xoops.org) |
22
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
23
|
|
|
* @author trabis <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class CommentsPreload extends PreloadItem |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* listen for core.include.common.classmaps |
29
|
|
|
* add any module specific class map entries |
30
|
|
|
* |
31
|
|
|
* @param mixed $args not used |
32
|
|
|
* |
33
|
|
|
* @return void |
34
|
|
|
*/ |
35
|
|
|
public static function eventCoreIncludeCommonClassmaps($args) |
|
|
|
|
36
|
|
|
{ |
37
|
|
|
$path = dirname(__DIR__); |
38
|
|
|
XoopsLoad::addMap(array( |
39
|
|
|
'comments' => $path . '/class/helper.php', |
40
|
|
|
'commentscommentrenderer' => $path . '/class/commentrenderer.php' |
41
|
|
|
)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public static function eventCoreFooterStart($args) |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$helper = \Xoops::getModuleHelper('comments'); |
47
|
|
|
$helper->renderView(); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
View Code Duplication |
public static function eventSystemModuleUpdateConfigs(ConfigCollector $collector) |
51
|
|
|
{ |
52
|
|
|
$helper = \Xoops::getModuleHelper('comments'); |
53
|
|
|
if ($plugin = Plugin::getPlugin( |
|
|
|
|
54
|
|
|
$collector->module()->getVar('dirname'), |
55
|
|
|
'comments', |
56
|
|
|
true |
57
|
|
|
)) { |
58
|
|
|
$pluginConfigs = $helper->getPluginableConfigs(); |
59
|
|
|
$collector->add($pluginConfigs); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
63
|
|
View Code Duplication |
public static function eventSystemModuleInstall(XoopsModule $module) |
64
|
|
|
{ |
65
|
|
|
$helper = \Xoops::getModuleHelper('comments'); |
66
|
|
|
if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments', true)) { |
|
|
|
|
67
|
|
|
$helper::getInstance()->insertModuleRelations($module); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* remove any comeents for module being uninstalled |
73
|
|
|
* |
74
|
|
|
* @param XoopsModule $module module object |
75
|
|
|
* |
76
|
|
|
* @return void |
77
|
|
|
*/ |
78
|
|
View Code Duplication |
public static function eventSystemModuleUninstall(XoopsModule $module) |
79
|
|
|
{ |
80
|
|
|
$helper = \Xoops::getModuleHelper('comments'); |
81
|
|
|
if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) { |
|
|
|
|
82
|
|
|
$helper->deleteModuleRelations($module); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
View Code Duplication |
public static function eventSystemPreferencesForm(XoopsModule $module) |
87
|
|
|
{ |
88
|
|
|
$helper = \Xoops::getModuleHelper('comments'); |
89
|
|
|
|
90
|
|
|
if ($plugin = Plugin::getPlugin($module->getVar('dirname'), 'comments')) { |
|
|
|
|
91
|
|
|
$helper->loadLanguage('main'); |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|
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: