XOOPS  2.6.0
Admin.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 
12 namespace Xmf\Module;
13 
30 class Admin
31 {
32 
38  private static $ModuleAdmin = null;
39  private $version26 = null;
40  private $lastInfoBoxTitle = null;
41  private static $paypal = '';
42 
46  private function __construct()
47  {
48  $this->version26 = self::is26();
49  }
50 
66  public static function getInstance()
67  {
68 
69  static $instance;
70 
71  if ($instance === null) {
72  if (class_exists('\Xoops\Module\Admin', true)) {
73  $instance = new \Xoops\Module\Admin;
74  self::$ModuleAdmin = $instance;
75  } else {
77  \XoopsBaseConfig::get('root-path') .
78  '/Frameworks/moduleclasses/moduleadmin/moduleadmin.php'
79  );
80  self::$ModuleAdmin = new \ModuleAdmin;
81  $instance = new \Xmf\Module\Admin;
82  }
83 
84  }
85 
86  return $instance;
87 
88  }
89 
99  public static function is26()
100  {
101  return class_exists('\Xoops', false);
102  }
103 
115  public static function menuIconPath($image)
116  {
117  if (self::is26()) {
118  return($image);
119  } else {
120  $path='../../Frameworks/moduleclasses/icons/32/';
121 
122  return($path.$image);
123  }
124  }
125 
134  public function addConfigBoxLine($value = '', $type = 'default')
135  {
136  return self::$ModuleAdmin->addConfigBoxLine($value, $type);
137  }
138 
148  public function addInfoBox($title, $type = 'default', $extra = '')
149  {
150  $this->lastInfoBoxTitle = $title;
151 
152  return self::$ModuleAdmin->addInfoBox($title);
153  }
154 
164  public function addInfoBoxLine($text = '', $type = 'default', $color = 'inherit')
165  {
166  return self::$ModuleAdmin->addInfoBoxLine(
167  $this->lastInfoBoxTitle,
168  $text,
169  '',
170  $color,
171  $type
172  );
173  }
174 
185  public function addItemButton($title, $link, $icon = 'add', $extra = '')
186  {
187  return self::$ModuleAdmin->addItemButton($title, $link, $icon, $extra);
188  }
189 
198  public function renderButton($position = null, $delimiter = "&nbsp;")
199  {
200  if ($postion==null) {
201  $position = 'right';
202  }
203 
204  return self::$ModuleAdmin->renderButton($position, $delimiter);
205  }
206 
215  public function displayButton($position = null, $delimiter = "&nbsp;")
216  {
217  echo $this->renderButton($position, $delimiter);
218  }
219 
225  public function renderInfoBox()
226  {
227  return self::$ModuleAdmin->renderInfoBox();
228  }
229 
235  public function displayInfoBox()
236  {
237  echo $this->renderInfoBox();
238  }
239 
245  public function renderIndex()
246  {
247  return self::$ModuleAdmin->renderIndex();
248  }
249 
255  public function displayIndex()
256  {
257  echo $this->renderIndex();
258  }
259 
267  public function displayNavigation($menu = '')
268  {
269  echo self::$ModuleAdmin->addNavigation($menu);
270  }
271 
279  public function renderAbout($logo_xoops = true)
280  {
281  return self::$ModuleAdmin->renderAbout(self::$paypal, $logo_xoops);
282  }
283 
291  public static function setPaypal($paypal = '')
292  {
293  self::$paypal = $paypal;
294  }
295 
303  public function displayAbout($logo_xoops = true)
304  {
305  echo $this->renderAbout($logo_xoops);
306  }
307 
308  // not in regular ModuleAdmin
309 
317  public static function addConfigError($value = '')
318  {
319  if (self::is26()) {
320  $type='error';
321  } else {
322  $path=\XoopsBaseConfig::get('url').'/Frameworks/moduleclasses/icons/16/';
323  $line = "";
324  $line .= "<span style='color : red; font-weight : bold;'>";
325  $line .= "<img src='" . $path . "off.png' >";
326  $line .= $value;
327  $line .= "</span>";
328  $value=$line;
329  $type = 'default';
330  }
331 
332  return self::$ModuleAdmin->addConfigBoxLine($value, $type);
333  }
334 
342  public static function addConfigAccept($value = '')
343  {
344  if (self::is26()) {
345  $type='accept';
346  } else {
347  $path=\XoopsBaseConfig::get('url').'/Frameworks/moduleclasses/icons/16/';
348  $line = "";
349  $line .= "<span style='color : green;'>";
350  $line .= "<img src='" . $path . "on.png' >";
351  $line .= $value;
352  $line .= "</span>";
353  $value=$line;
354  $type = 'default';
355  }
356 
357  return self::$ModuleAdmin->addConfigBoxLine($value, $type);
358  }
359 
376  public static function iconUrl($name = '', $size = '32')
377  {
378  switch ($size) {
379  case '16':
380  $path='16/';
381  break;
382  case '/':
383  $path='';
384  break;
385  default:
386  case '32':
387  $path='32/';
388  break;
389  }
390 
391  if (self::is26()) {
392  $path='/media/xoops/images/icons/'.$path;
393  } else {
394  $path='/Frameworks/moduleclasses/icons/'.$path;
395  }
396 
397  return(\XoopsBaseConfig::get('url') . $path . $name);
398  }
399 
408  public static function checkModuleVersion($moddir, $minversion)
409  {
410  \Xmf\Language::load('main', 'xmf');
411  $return=false;
413  if (is_object($helper) && is_object($helper->getModule())) {
414  $mod_modversion=$helper->getModule()->getVar('version');
415  $mod_version_f = $mod_modversion/100;
416  $min_version_f = $minversion/100;
417  $value = sprintf(
419  strtoupper($moddir),
420  $min_version_f,
421  $mod_version_f
422  );
423  if ($mod_modversion>=$minversion) {
424  self::addConfigAccept($value);
425  $return=true;
426  } else {
427  self::addConfigError($value);
428  }
429  } else {
430  $value = sprintf(
432  strtoupper($moddir),
433  $minversion/100
434  );
435  self::addConfigError($value);
436  }
437 
438  return $return;
439  }
440 }
static getHelper($dirname= 'system')
Definition: Helper.php:41
if(empty($image_id)) $image
Definition: image.php:37
$path
Definition: execute.php:31
displayButton($position=null, $delimiter="&nbsp;")
Definition: Admin.php:215
static $paypal
Definition: Admin.php:41
static loadFile($file, $once=true)
Definition: Loader.php:36
$text
Definition: qrrender.php:27
$link
Definition: userinfo.php:84
static getInstance()
Definition: Admin.php:66
addItemButton($title, $link, $icon= 'add', $extra= '')
Definition: Admin.php:185
static addConfigError($value= '')
Definition: Admin.php:317
renderButton($position=null, $delimiter="&nbsp;")
Definition: Admin.php:198
displayAbout($logo_xoops=true)
Definition: Admin.php:303
const _AM_XMF_DEMOMVC_MODULE_VERSION
Definition: main.php:36
static menuIconPath($image)
Definition: Admin.php:115
$menu
static get($name)
const _AM_XMF_DEMOMVC_MODULE_NOTFOUND
Definition: main.php:35
$type
Definition: misc.php:33
addConfigBoxLine($value= '', $type= 'default')
Definition: Admin.php:134
addInfoBox($title, $type= 'default', $extra= '')
Definition: Admin.php:148
$helper
static load($name, $domain= '', $language=null)
Definition: Language.php:54
static iconUrl($name= '', $size= '32')
Definition: Admin.php:376
static addConfigAccept($value= '')
Definition: Admin.php:342
static $ModuleAdmin
Definition: Admin.php:38
renderAbout($logo_xoops=true)
Definition: Admin.php:279
addInfoBoxLine($text= '', $type= 'default', $color= 'inherit')
Definition: Admin.php:164
static checkModuleVersion($moddir, $minversion)
Definition: Admin.php:408
displayNavigation($menu= '')
Definition: Admin.php:267
static setPaypal($paypal= '')
Definition: Admin.php:291
static is26()
Definition: Admin.php:99