|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xoopstube; |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits |
|
7
|
|
|
of supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Xoopstube class |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright The XUUPS Project https://sourceforge.net/projects/xuups/ |
|
19
|
|
|
* @license https://www.fsf.org/copyleft/gpl.html GNU public license |
|
20
|
|
|
* @package Xoopstube |
|
21
|
|
|
* @subpackage Utils |
|
22
|
|
|
* @since 1.0 |
|
23
|
|
|
* @author trabis <[email protected]> |
|
24
|
|
|
*/ |
|
25
|
|
|
|
|
26
|
|
|
use XoopsModules\Xoopstube; |
|
27
|
|
|
use XoopsObject; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Class Videos |
|
32
|
|
|
*/ |
|
33
|
|
|
class Videos extends XoopsObject |
|
34
|
|
|
{ |
|
35
|
|
|
public $dirname; |
|
36
|
|
|
public $module; |
|
37
|
|
|
public $handler; |
|
38
|
|
|
public $config; |
|
39
|
|
|
public $debug; |
|
40
|
|
|
public $debugArray = []; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @param $debug |
|
44
|
|
|
*/ |
|
45
|
|
|
protected function __construct($debug) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->debug = $debug; |
|
48
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
49
|
|
|
parent::__construct($moduleDirName); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @param bool $debug |
|
54
|
|
|
* |
|
55
|
|
|
* @return \XoopsModules\Xoopstube\Videos |
|
56
|
|
|
*/ |
|
57
|
|
|
public static function getInstance($debug = false) |
|
58
|
|
|
{ |
|
59
|
|
|
static $instance; |
|
60
|
|
|
if (null === $instance) { |
|
61
|
|
|
$instance = new static($debug); |
|
62
|
|
|
} |
|
63
|
|
|
//error_log("istance: [" . print_r($istance,true) . "]"); |
|
64
|
|
|
//phpinfo(); |
|
65
|
|
|
//debug_print_backtrace (); |
|
66
|
|
|
return $instance; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public function getModule() |
|
70
|
|
|
{ |
|
71
|
|
|
if (null === $this->module) { |
|
72
|
|
|
$this->initModule(); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
return $this->module; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @param null $name |
|
|
|
|
|
|
80
|
|
|
* @return mixed|null |
|
81
|
|
|
*/ |
|
82
|
|
|
public function getConfig($name = null) |
|
83
|
|
|
{ |
|
84
|
|
|
if (null === $this->config) { |
|
85
|
|
|
$this->initConfig(); |
|
86
|
|
|
} |
|
87
|
|
|
if (!$name) { |
|
|
|
|
|
|
88
|
|
|
$this->addLog('Getting all config'); |
|
89
|
|
|
|
|
90
|
|
|
return $this->config; |
|
91
|
|
|
} |
|
92
|
|
|
if (!isset($this->config[$name])) { |
|
93
|
|
|
$this->addLog("ERROR :: CONFIG '{$name}' does not exist"); |
|
94
|
|
|
|
|
95
|
|
|
return null; |
|
96
|
|
|
} |
|
97
|
|
|
$this->addLog("Getting config '{$name}' : " . \print_r($this->config[$name], true)); |
|
98
|
|
|
|
|
99
|
|
|
return $this->config[$name]; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @param null|string $name |
|
104
|
|
|
* @param mixed $value |
|
105
|
|
|
* |
|
106
|
|
|
* @return mixed |
|
107
|
|
|
*/ |
|
108
|
|
|
public function setConfig($name = null, $value = null) |
|
109
|
|
|
{ |
|
110
|
|
|
if (null === $this->config) { |
|
111
|
|
|
$this->initConfig(); |
|
112
|
|
|
} |
|
113
|
|
|
$this->config[$name] = $value; |
|
114
|
|
|
$this->addLog("Setting config '{$name}' : " . $this->config[$name]); |
|
115
|
|
|
|
|
116
|
|
|
return $this->config[$name]; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param $name |
|
121
|
|
|
* |
|
122
|
|
|
* @return mixed |
|
123
|
|
|
*/ |
|
124
|
|
|
public function getHandler($name) |
|
125
|
|
|
{ |
|
126
|
|
|
if (!isset($this->handler[$name . 'Handler'])) { |
|
127
|
|
|
$this->initHandler($name); |
|
128
|
|
|
} |
|
129
|
|
|
$this->addLog("Getting handler '{$name}'"); |
|
130
|
|
|
|
|
131
|
|
|
return $this->handler[$name . 'Handler']; |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function initModule() |
|
135
|
|
|
{ |
|
136
|
|
|
global $xoopsModule; |
|
137
|
|
|
if (isset($xoopsModule) && \is_object($xoopsModule) && $xoopsModule->getVar('dirname') === $this->dirname) { |
|
138
|
|
|
$this->module = $xoopsModule; |
|
139
|
|
|
} else { |
|
140
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
|
141
|
|
|
$moduleHandler = \xoops_getHandler('module'); |
|
142
|
|
|
$this->module = $moduleHandler->getByDirname($this->dirname); |
|
143
|
|
|
} |
|
144
|
|
|
$this->addLog('INIT MODULE'); |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
public function initConfig() |
|
148
|
|
|
{ |
|
149
|
|
|
$this->addLog('INIT CONFIG'); |
|
150
|
|
|
/** @var \XoopsConfigHandler $configHandler */ |
|
151
|
|
|
$configHandler = \xoops_getHandler('config'); |
|
152
|
|
|
$this->config = $configHandler->getConfigsByCat(0, $this->getModule()->getVar('mid')); |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* @param $name |
|
157
|
|
|
*/ |
|
158
|
|
|
public function initHandler($name) |
|
159
|
|
|
{ |
|
160
|
|
|
$this->addLog('INIT ' . $name . ' HANDLER'); |
|
161
|
|
|
$this->handler[$name . 'Handler'] = \xoops_getModuleHandler($name, $this->dirname); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
/** |
|
165
|
|
|
* @param $log |
|
166
|
|
|
*/ |
|
167
|
|
|
public function addLog($log) |
|
168
|
|
|
{ |
|
169
|
|
|
if ($this->debug && \is_object($GLOBALS['xoopsLogger'])) { |
|
170
|
|
|
$GLOBALS['xoopsLogger']->addExtra($this->module->name(), $log); |
|
171
|
|
|
} |
|
172
|
|
|
} |
|
173
|
|
|
} |
|
174
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.