1 | <?php |
||
23 | class Userlog_Module_Plugin |
||
|
|||
24 | { |
||
25 | /** |
||
26 | * @param string $dirname |
||
27 | * @param string $pluginName |
||
28 | * @param bool $force |
||
29 | * |
||
30 | * @return bool|Xoops_Module_Plugin_Abstract false if plugin does not exist |
||
31 | */ |
||
32 | public static function getPlugin($dirname, $pluginName = 'system', $force = false) |
||
33 | { |
||
34 | $inactiveModules = false; |
||
35 | if ($force) { |
||
36 | $inactiveModules = [$dirname]; |
||
37 | } |
||
38 | $available = self::getPlugins($pluginName, $inactiveModules); |
||
39 | if (!in_array($dirname, array_keys($available))) { |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | return $available[$dirname]; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param string $pluginName |
||
48 | * @param array|bool $inactiveModules |
||
49 | * |
||
50 | * @return mixed |
||
51 | */ |
||
52 | public static function getPlugins($pluginName = 'system', $inactiveModules = false) |
||
53 | { |
||
54 | static $plugins = []; |
||
55 | if (!isset($plugins[$pluginName])) { |
||
56 | $plugins[$pluginName] = []; |
||
57 | //$xoops = Xoops::getInstance(); |
||
58 | |||
59 | //Load interface for this plugin |
||
60 | if (!self::loadFile($GLOBALS['xoops']->path("modules/{$pluginName}/class/plugin/interface.php"))) { |
||
61 | return $plugins[$pluginName]; |
||
62 | } |
||
63 | |||
64 | $dirnames = xoops_getActiveModules(); |
||
65 | if (is_array($inactiveModules)) { |
||
66 | $dirnames = array_merge($dirnames, $inactiveModules); |
||
67 | } |
||
68 | foreach ($dirnames as $dirname) { |
||
69 | if (self::loadFile($GLOBALS['xoops']->path("modules/{$dirname}/class/plugin/{$pluginName}.php")) |
||
70 | || self::loadFile($GLOBALS['xoops']->path("modules/{$pluginName}/class/plugin/{$dirname}.php"))) { |
||
71 | $className = ucfirst($dirname) . ucfirst($pluginName) . 'Plugin'; |
||
72 | $interface = ucfirst($pluginName) . 'PluginInterface'; |
||
73 | $class = new $className($dirname); |
||
74 | if ($class instanceof Userlog_Module_Plugin_Abstract && $class instanceof $interface) { |
||
75 | $plugins[$pluginName][$dirname] = $class; |
||
76 | } |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | |||
81 | return $plugins[$pluginName]; |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param $file |
||
86 | * @param bool $once |
||
87 | * |
||
88 | * @return bool |
||
89 | */ |
||
90 | |||
91 | public static function loadFile($file, $once = true) |
||
106 | |||
107 | /** |
||
108 | * @param $file |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | |||
113 | public static function fileExists($file) |
||
122 | |||
123 | /** |
||
124 | * @param $filename |
||
125 | */ |
||
126 | protected static function _securityCheck($filename) |
||
135 | } |
||
136 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.