1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace XoopsModules\Tdmdownloads; |
6
|
|
|
|
7
|
|
|
/* |
8
|
|
|
* You may not change or alter any portion of this comment or credits |
9
|
|
|
* of supporting developers from this source code or any supporting source code |
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
15
|
|
|
*/ |
16
|
|
|
/** |
17
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
18
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
19
|
|
|
* @package |
20
|
|
|
* @since |
21
|
|
|
* @author XOOPS Development Team |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class Helper |
26
|
|
|
*/ |
27
|
|
|
class Helper extends \Xmf\Module\Helper |
28
|
|
|
{ |
29
|
|
|
public $debug; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Constructor |
33
|
|
|
* |
34
|
|
|
* @param bool $debug |
35
|
|
|
*/ |
36
|
|
|
public function __construct($debug = false) |
37
|
|
|
{ |
38
|
|
|
$this->debug = $debug; |
39
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
40
|
|
|
parent::__construct($moduleDirName); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Get instance |
45
|
|
|
* @param bool $debug |
46
|
|
|
* @return \XoopsModules\Tdmdownloads\Helper |
47
|
|
|
*/ |
48
|
|
|
public static function getInstance($debug = false) |
49
|
|
|
{ |
50
|
|
|
static $instance; |
51
|
|
|
if (null === $instance) { |
52
|
|
|
$instance = new static($debug); |
53
|
|
|
} |
54
|
|
|
return $instance; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
public function getDirname() |
61
|
|
|
{ |
62
|
|
|
return $this->dirname; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Get an Object Handler |
67
|
|
|
* |
68
|
|
|
* @param string $name name of handler to load |
69
|
|
|
* |
70
|
|
|
* @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler |
71
|
|
|
*/ |
72
|
|
|
public function getHandler($name) |
73
|
|
|
{ |
74
|
|
|
$ret = false; |
|
|
|
|
75
|
|
|
$class = __NAMESPACE__ . '\\' . \ucfirst($name) . 'Handler'; |
76
|
|
|
if (!\class_exists($class)) { |
77
|
|
|
throw new \RuntimeException("Class '$class' not found"); |
78
|
|
|
} |
79
|
|
|
/** @var \XoopsMySQLDatabase $db */ |
80
|
|
|
$db = \XoopsDatabaseFactory::getDatabaseConnection(); |
81
|
|
|
$helper = self::getInstance(); |
82
|
|
|
$ret = new $class($db, $helper); |
83
|
|
|
$this->addLog("Getting handler '{$name}'"); |
84
|
|
|
return $ret; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @function getStateText |
90
|
|
|
* @param string $state |
91
|
|
|
* @return string text for state |
92
|
|
|
*/ |
93
|
|
|
// public function getStateText($state) |
94
|
|
|
// { |
95
|
|
|
// switch ($state) { |
96
|
|
|
// case Constants::STATE_ONLINE_VAL: |
97
|
|
|
// return _CO_WGGALLERY_STATE_ONLINE; |
98
|
|
|
// break; |
99
|
|
|
// case Constants::STATE_APPROVAL_VAL: |
100
|
|
|
// return _CO_WGGALLERY_STATE_APPROVAL; |
101
|
|
|
// break; |
102
|
|
|
// case Constants::STATE_OFFLINE_VAL: |
103
|
|
|
// return _CO_WGGALLERY_STATE_OFFLINE; |
104
|
|
|
// break; |
105
|
|
|
// default: |
106
|
|
|
// return 'invalid state in getStateText in Class/Helper.php'; //should never happen |
107
|
|
|
// break; |
108
|
|
|
// } |
109
|
|
|
// } |
110
|
|
|
} |
111
|
|
|
|