1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
22: class SystemExtension extends SystemModule
23: {
24:
25: 26: 27: 28: 29: 30: 31:
32: public function getExtension($mod = '')
33: {
34: $ret = array();
35: $extension = self::getExtensionList();
36: foreach ($extension as $list) {
37:
38: if ($list->getInfo('install')) {
39: if (!is_array($list->getInfo('extension_module'))) {
40: $ret[] = $list;
41: } else {
42: if (array_search($mod, $list->getInfo('extension_module')) !== false) {
43: $ret[] = $list;
44:
45: }
46: }
47: unset($list);
48: }
49: }
50:
51: return $ret;
52: }
53:
54: 55: 56: 57: 58:
59: public function getExtensionList()
60: {
61:
62: $xoops = Xoops::getInstance();
63: $module_handler = $xoops->getHandlerModule();
64: $moduleperm_handler = $xoops->getHandlerGroupPermission();
65:
66: $ret = array();
67: $i = 0;
68: foreach ($this->modulesList as $file) {
69: $file = trim($file);
70: if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
71: clearstatcache();
72:
73: $module = $module_handler->create();
74: $module->loadInfoAsVar($file);
75: if ($module->getInfo('extension')) {
76: if (in_array($file, $this->modulesDirnames)) {
77: $module->setInfo('install', true);
78: $extension = $module_handler->getByDirname($module->getInfo('dirname'));
79: $module->setInfo('mid', $extension->getVar('mid'));
80: $module->setInfo(
81: 'update',
82: XoopsLocale::formatTimestamp($extension->getVar('last_update'), 's')
83: );
84: $module->setInfo('hasconfig', $module->getVar('hasconfig'));
85: if (round($module->getInfo('version'), 2) != $extension->getVar('version')) {
86: $module->setInfo('warning_update', true);
87: }
88: $groups = array();
89: if (is_object($xoops->user)) {
90: $groups = $xoops->user->getGroups();
91: }
92: $sadmin = $moduleperm_handler
93: ->checkRight('module_admin', $module->getInfo('mid'), $groups);
94: if ($sadmin && ($module->getVar('hasnotification')
95: || is_array($module->getInfo('config'))
96: || is_array($module->getInfo('comments')))
97: ) {
98: $module->setInfo(
99: 'link_pref',
100: \XoopsBaseConfig::get('url') . '/modules/system/admin.php?fct=preferences&op=showmod&mod='
101: . $module->getInfo('mid')
102: );
103: }
104: } else {
105: $module->setInfo('install', false);
106: }
107: $module->setInfo('version', round($module->getInfo('version'), 2));
108: if (XoopsLoad::fileExists(
109: \XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png'
110: )) {
111: $module->setInfo(
112: 'logo_small',
113: \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_small.png'
114: );
115: } else {
116: $module->setInfo('logo_small', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/16/default.png');
117: }
118: if (XoopsLoad::fileExists(
119: \XoopsBaseConfig::get('root-path') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png'
120: )) {
121: $module->setInfo(
122: 'logo_large',
123: \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/icons/logo_large.png'
124: );
125: } else {
126: $module->setInfo('logo_large', \XoopsBaseConfig::get('url') . '/media/xoops/images/icons/32/default.png');
127: }
128: $module->setInfo(
129: 'link_admin',
130: \XoopsBaseConfig::get('url') . '/modules/' . $module->getInfo('dirname') . '/' . $module->getInfo('adminindex')
131: );
132: $module->setInfo('options', $module->getAdminMenu());
133: $ret[] = $module;
134: unset($module);
135: ++$i;
136: }
137: }
138: }
139: return $ret;
140: }
141:
142: 143: 144: 145: 146:
147: public function getInstalledExtensions()
148: {
149:
150: $xoops = Xoops::getInstance();
151: $module_handler = $xoops->getHandlerModule();
152:
153: $ret = array();
154: $i = 0;
155: foreach ($this->modulesList as $file) {
156: if (XoopsLoad::fileExists(\XoopsBaseConfig::get('root-path') . '/modules/' . $file . '/xoops_version.php')) {
157: clearstatcache();
158: $file = trim($file);
159: if (!in_array($file, $this->modulesDirnames)) {
160:
161: $module = $module_handler->create();
162: $module->loadInfo($file);
163: if ($module->getInfo('extension')) {
164: $module->setInfo('mid', $i);
165: $module->setInfo('version', round($module->getInfo('version'), 2));
166: $ret[] = $module;
167: unset($module);
168: ++$i;
169: }
170: }
171: }
172: }
173: return $ret;
174: }
175: }
176: