XOOPS  2.6.0
extension.php
Go to the documentation of this file.
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 
23 {
24 
32  public function getExtension($mod = '')
33  {
34  $ret = array();
35  $extension = self::getExtensionList();
36  foreach ($extension as $list) {
37  /* @var $list XoopsModule */
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  //echo $list->getInfo('name') . is_array( $list->getInfo('extension_module') );
45  }
46  }
47  unset($list);
48  }
49  }
50 
51  return $ret;
52  }
53 
59  public function getExtensionList()
60  {
61  // Get main instance
63  $module_handler = $xoops->getHandlerModule();
64  $moduleperm_handler = $xoops->getHandlerGroupperm();
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  /* @var $module XoopsModule */
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&amp;op=showmod&amp;mod='
101  . $module->getInfo('mid')
102  );
103  }
104  } else {
105  $module->setInfo('install', false);
106  }
107  $module->setInfo('version', round($module->getInfo('version'), 2));
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  }
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 
147  public function getInstalledExtensions()
148  {
149  // Get main instance
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  /* @var $module XoopsModule */
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 }
static formatTimestamp($time, $format= 'l', $timeoffset=null)
Definition: Abstract.php:289
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
getExtension($mod= '')
Definition: extension.php:32
if(!isset($xoops->paths[$path_type])) if($path_type== 'var') $file
Definition: browse.php:55
$xoops
Definition: admin.php:25
static fileExists($file)
Definition: xoopsload.php:506
static get($name)
$module
Definition: main.php:52
$groups
$module_handler
Definition: main.php:55
$moduleperm_handler
Definition: cp_header.php:31