|
1
|
|
|
<?php namespace XoopsModules\Smartobject; |
|
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
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
|
15
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
|
16
|
|
|
* @package |
|
17
|
|
|
* @since |
|
18
|
|
|
* @author XOOPS Development Team |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
use XoopsLists; |
|
22
|
|
|
use XoopsModules\Smartobject; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class SmartPluginHandler |
|
27
|
|
|
*/ |
|
28
|
|
|
class PluginHandler |
|
29
|
|
|
{ |
|
30
|
|
|
public $pluginPatterns = false; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* @param $dirname |
|
34
|
|
|
* @return bool|Plugin |
|
35
|
|
|
*/ |
|
36
|
|
|
public function getPlugin($dirname) |
|
37
|
|
|
{ |
|
38
|
|
|
$pluginName = SMARTOBJECT_ROOT_PATH . 'plugins/' . $dirname . '.php'; |
|
39
|
|
|
if (file_exists($pluginName)) { |
|
40
|
|
|
require_once $pluginName; |
|
41
|
|
|
$function = 'smartobject_plugin_' . $dirname; |
|
42
|
|
|
if (function_exists($function)) { |
|
43
|
|
|
$array = $function(); |
|
44
|
|
|
$ret = new Plugin($array); |
|
45
|
|
|
|
|
46
|
|
|
return $ret; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
return false; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return array |
|
55
|
|
|
*/ |
|
56
|
|
|
public function getPluginsArray() |
|
57
|
|
|
{ |
|
58
|
|
|
require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
|
59
|
|
|
|
|
60
|
|
|
$moduleHandler = xoops_getHandler('module'); |
|
61
|
|
|
$criteria = new \CriteriaCompo(); |
|
62
|
|
|
$criteria->add(new \Criteria('isactive', 1)); |
|
63
|
|
|
$tempModulesObj = $moduleHandler->getObjects($criteria); |
|
64
|
|
|
$modulesObj = []; |
|
65
|
|
|
foreach ($tempModulesObj as $moduleObj) { |
|
66
|
|
|
$modulesObj[$moduleObj->getVar('dirname')] = $moduleObj; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$aFiles = XoopsLists::getFileListAsArray(SMARTOBJECT_ROOT_PATH . 'plugins/'); |
|
70
|
|
|
$ret = []; |
|
71
|
|
|
foreach ($aFiles as $file) { |
|
72
|
|
|
if ('.php' === substr($file, strlen($file) - 4, 4)) { |
|
73
|
|
|
$pluginName = str_replace('.php', '', $file); |
|
74
|
|
|
$module_xoops_version_file = XOOPS_ROOT_PATH . "/modules/$pluginName/xoops_version.php"; |
|
75
|
|
|
if (file_exists($module_xoops_version_file) && isset($modulesObj[$pluginName])) { |
|
76
|
|
|
$ret[$pluginName] = $modulesObj[$pluginName]->getVar('name'); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
return $ret; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|