XOOPS  2.6.0
Helper.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 Xoops\Module;
20 class Helper
21 {
27  public static function getHelper($dirname = 'system')
28  {
29  static $modules = array();
30 
31  $dirname = strtolower($dirname);
32  if (!isset($modules[$dirname])) {
33  $modules[$dirname] = false;
35  if ($xoops->isActiveModule($dirname)) {
36  //Load Module helper if available
37  if (\XoopsLoad::loadFile($xoops->path("modules/{$dirname}/class/helper.php"))) {
38  $className = '\\' . ucfirst($dirname);
39  if (class_exists($className)) {
40  $class = new $className();
41  if ($class instanceof \Xoops\Module\Helper\HelperAbstract) {
42  $modules[$dirname] = $class::getInstance();
43  }
44  }
45  } else {
46  //Create Module Helper
47  $xoops->registry()->set('module_helper_id', $dirname);
48  $class = \Xoops\Module\Helper\Dummy::getInstance();
49  $class->setDirname($dirname);
50  $modules[$dirname] = $class;
51  }
52  }
53  }
54  return $modules[$dirname];
55  }
56 }
static getInstance()
Definition: Xoops.php:160
$xoops
Definition: admin.php:25
static getHelper($dirname= 'system')
Definition: Helper.php:27
$modules
Definition: userinfo.php:185
$dirname
Definition: backend.php:38
static loadFile($file, $once=true)
Definition: xoopsload.php:454