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:
14: use Xmf\Module\Helper\GenericHelper;
15:
16: /**
17: * Helper gets an instance of module helper for the specified module.
18: * The helper is defined by the Xoops 2.6 Xoops\Module\Helper\HelperAbstract
19: * and in pre 2.6 systems we mimic that definition with using an
20: * instance of Xmf\Module\GenericHelper.
21: *
22: * @category Xmf\Module\Helper
23: * @package Xmf
24: * @author trabis <lusopoemas@gmail.com>
25: * @author Richard Griffith <richard@geekwright.com>
26: * @copyright 2011-2016 XOOPS Project (http://xoops.org)
27: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
28: * @link http://xoops.org
29: */
30: class Helper extends GenericHelper
31: {
32: /**
33: * Get an instance of a module helper for the module identified by $dirname
34: *
35: * @param string $dirname module directory
36: *
37: * @return \Xmf\Module\Helper|\Xoops\Module\Helper|false a Helper object of false on error
38: */
39: public static function getHelper($dirname = 'system')
40: {
41: static $instance = array();
42:
43: //$dirname = strtolower($dirname);
44:
45: if (!isset($instance[$dirname])) {
46: $instance[$dirname] = false;
47:
48: // if this is a 2.6 system turn everything over to the core
49: if (class_exists('Xoops', false)) {
50: $instance[$dirname] = \Xoops\Module\Helper::getHelper($dirname);
51: } else {
52: // otherwise get a GenericHelper instance for dirname
53: if (xoops_isActiveModule($dirname)) {
54: $instance[$dirname] = new static($dirname);
55: }
56: }
57: }
58:
59: return $instance[$dirname];
60: }
61: }
62: