XoopsModules25x /
xoopstube
| 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 http://sourceforge.net/projects/xuups/ |
||||||
| 19 | * @license http://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 | |||||||
| 32 | |||||||
| 33 | |||||||
| 34 | |||||||
| 35 | /** |
||||||
| 36 | * Class Videos |
||||||
| 37 | */ |
||||||
| 38 | class Videos extends XoopsObject |
||||||
| 39 | { |
||||||
| 40 | public $dirname; |
||||||
| 41 | public $module; |
||||||
| 42 | public $handler; |
||||||
| 43 | public $config; |
||||||
| 44 | public $debug; |
||||||
| 45 | public $debugArray = []; |
||||||
| 46 | |||||||
| 47 | /** |
||||||
| 48 | * @param $debug |
||||||
| 49 | */ |
||||||
| 50 | protected function __construct($debug) |
||||||
| 51 | { |
||||||
| 52 | $this->debug = $debug; |
||||||
| 53 | $moduleDirName = basename(dirname(__DIR__)); |
||||||
| 54 | parent::__construct($moduleDirName); |
||||||
|
0 ignored issues
–
show
|
|||||||
| 55 | } |
||||||
| 56 | |||||||
| 57 | /** |
||||||
| 58 | * @param bool $debug |
||||||
| 59 | * |
||||||
| 60 | * @return \XoopsModules\Xoopstube\Videos |
||||||
| 61 | */ |
||||||
| 62 | public static function getInstance($debug = false) |
||||||
| 63 | { |
||||||
| 64 | static $instance; |
||||||
| 65 | if (null === $instance) { |
||||||
| 66 | $instance = new static($debug); |
||||||
| 67 | } |
||||||
| 68 | //error_log("istance: [" . print_r($istance,true) . "]"); |
||||||
| 69 | //phpinfo(); |
||||||
| 70 | //debug_print_backtrace (); |
||||||
| 71 | return $instance; |
||||||
| 72 | } |
||||||
| 73 | |||||||
| 74 | public function getModule() |
||||||
| 75 | { |
||||||
| 76 | if (null === $this->module) { |
||||||
| 77 | $this->initModule(); |
||||||
| 78 | } |
||||||
| 79 | |||||||
| 80 | return $this->module; |
||||||
| 81 | } |
||||||
| 82 | |||||||
| 83 | /** |
||||||
| 84 | * @param null $name |
||||||
|
0 ignored issues
–
show
|
|||||||
| 85 | * @return mixed|null |null |
||||||
| 86 | */ |
||||||
| 87 | public function getConfig($name = null) |
||||||
| 88 | { |
||||||
| 89 | if (null === $this->config) { |
||||||
| 90 | $this->initConfig(); |
||||||
| 91 | } |
||||||
| 92 | if (!$name) { |
||||||
|
0 ignored issues
–
show
|
|||||||
| 93 | $this->addLog('Getting all config'); |
||||||
| 94 | |||||||
| 95 | return $this->config; |
||||||
| 96 | } |
||||||
| 97 | if (!isset($this->config[$name])) { |
||||||
| 98 | $this->addLog("ERROR :: CONFIG '{$name}' does not exist"); |
||||||
| 99 | |||||||
| 100 | return null; |
||||||
| 101 | } |
||||||
| 102 | $this->addLog("Getting config '{$name}' : " . print_r($this->config[$name], true)); |
||||||
| 103 | |||||||
| 104 | return $this->config[$name]; |
||||||
| 105 | } |
||||||
| 106 | |||||||
| 107 | /** |
||||||
| 108 | * @param null $name |
||||||
|
0 ignored issues
–
show
|
|||||||
| 109 | * @param null $value |
||||||
|
0 ignored issues
–
show
|
|||||||
| 110 | * |
||||||
| 111 | * @return mixed |
||||||
| 112 | */ |
||||||
| 113 | public function setConfig($name = null, $value = null) |
||||||
| 114 | { |
||||||
| 115 | if (null === $this->config) { |
||||||
| 116 | $this->initConfig(); |
||||||
| 117 | } |
||||||
| 118 | $this->config[$name] = $value; |
||||||
| 119 | $this->addLog("Setting config '{$name}' : " . $this->config[$name]); |
||||||
| 120 | |||||||
| 121 | return $this->config[$name]; |
||||||
| 122 | } |
||||||
| 123 | |||||||
| 124 | /** |
||||||
| 125 | * @param $name |
||||||
| 126 | * |
||||||
| 127 | * @return mixed |
||||||
| 128 | */ |
||||||
| 129 | public function getHandler($name) |
||||||
| 130 | { |
||||||
| 131 | if (!isset($this->handler[$name . 'Handler'])) { |
||||||
| 132 | $this->initHandler($name); |
||||||
| 133 | } |
||||||
| 134 | $this->addLog("Getting handler '{$name}'"); |
||||||
| 135 | |||||||
| 136 | return $this->handler[$name . 'Handler']; |
||||||
| 137 | } |
||||||
| 138 | |||||||
| 139 | public function initModule() |
||||||
| 140 | { |
||||||
| 141 | global $xoopsModule; |
||||||
| 142 | if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') === $this->dirname) { |
||||||
| 143 | $this->module = $xoopsModule; |
||||||
| 144 | } else { |
||||||
| 145 | $moduleHandler = xoops_getHandler('module'); |
||||||
| 146 | $this->module = $moduleHandler->getByDirname($this->dirname); |
||||||
|
0 ignored issues
–
show
The method
getByDirname() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsModuleHandler or XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 147 | } |
||||||
| 148 | $this->addLog('INIT MODULE'); |
||||||
| 149 | } |
||||||
| 150 | |||||||
| 151 | public function initConfig() |
||||||
| 152 | { |
||||||
| 153 | $this->addLog('INIT CONFIG'); |
||||||
| 154 | $hModConfig = xoops_getHandler('config'); |
||||||
| 155 | $this->config = $hModConfig->getConfigsByCat(0, $this->getModule()->getVar('mid')); |
||||||
|
0 ignored issues
–
show
The method
getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||||
| 156 | } |
||||||
| 157 | |||||||
| 158 | /** |
||||||
| 159 | * @param $name |
||||||
| 160 | */ |
||||||
| 161 | public function initHandler($name) |
||||||
| 162 | { |
||||||
| 163 | $this->addLog('INIT ' . $name . ' HANDLER'); |
||||||
| 164 | $this->handler[$name . 'Handler'] = xoops_getModuleHandler($name, $this->dirname); |
||||||
| 165 | } |
||||||
| 166 | |||||||
| 167 | /** |
||||||
| 168 | * @param $log |
||||||
| 169 | */ |
||||||
| 170 | public function addLog($log) |
||||||
| 171 | { |
||||||
| 172 | if ($this->debug && is_object($GLOBALS['xoopsLogger'])) { |
||||||
| 173 | $GLOBALS['xoopsLogger']->addExtra($this->module->name(), $log); |
||||||
| 174 | } |
||||||
| 175 | } |
||||||
| 176 | } |
||||||
| 177 |
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.