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-2013 XOOPS Project (http://xoops.org)
27:  * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
28:  * @version   Release: 1.0
29:  * @link      http://xoops.org
30:  * @since     1.0
31:  */
32: class Helper
33: {
34:     /**
35:      * Get an instance to a module helper for a module directory
36:      *
37:      * @param string $dirname module direcory
38:      *
39:      * @return bool|Xoops\Module\Helper\HelperAbstract
40:      */
41:     public static function getHelper($dirname = 'system')
42:     {
43:         // if this is a 2.6 system turn everything over to the core
44:         if (class_exists('Xoops', false)) {
45:             return \Xoops\Module\Helper::getHelper($dirname);
46:         }
47: 
48:         // otherwise get a GenericHelper instance for dirname
49:         $dirname = strtolower($dirname);
50:         if (xoops_isActiveModule($dirname)) {
51:             return GenericHelper::getInstance($dirname);
52:         }
53: 
54:         // not an active installed module
55:         return false;
56:     }
57: }
58: