1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
use Xmf\Request; |
4
|
|
|
|
5
|
|
|
require_once __DIR__ . '/common/traitversionchecks.php'; |
6
|
|
|
require_once __DIR__ . '/common/traitserverstats.php'; |
7
|
|
|
require_once __DIR__ . '/common/traitfilesmgmt.php'; |
8
|
|
|
|
9
|
|
|
//require_once __DIR__ . '/../include/common.php'; |
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class ExtgalleryUtility |
12
|
|
|
*/ |
13
|
|
|
class ExtgalleryUtility extends XoopsObject |
|
|
|
|
14
|
|
|
{ |
15
|
|
|
use VersionChecks; //checkVerXoops, checkVerPhp Traits |
16
|
|
|
|
17
|
|
|
use ServerStats; // getServerStats Trait |
18
|
|
|
|
19
|
|
|
use FilesManagement; // Files Management Trait |
20
|
|
|
|
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param $option |
24
|
|
|
* @return bool|mixed |
25
|
|
|
*/ |
26
|
|
|
public static function getModuleOption($option) |
27
|
|
|
{ |
28
|
|
|
global $xoopsModuleConfig, $xoopsModule; |
|
|
|
|
29
|
|
|
static $tbloptions = []; |
30
|
|
|
if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) { |
31
|
|
|
return $tbloptions[$option]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$retval = false; |
35
|
|
|
if (isset($xoopsModuleConfig) |
36
|
|
|
&& (is_object($xoopsModule) && 'extgallery' === $xoopsModule->getVar('dirname') |
37
|
|
|
&& $xoopsModule->getVar('isactive'))) { |
38
|
|
|
if (isset($xoopsModuleConfig[$option])) { |
39
|
|
|
$retval = $xoopsModuleConfig[$option]; |
40
|
|
|
} |
41
|
|
|
} else { |
42
|
|
|
/** @var XoopsModuleHandler $moduleHandler */ |
43
|
|
|
$moduleHandler = xoops_getHandler('module'); |
44
|
|
|
$module = $moduleHandler->getByDirname('extgallery'); |
45
|
|
|
|
46
|
|
|
/** @var XoopsModuleHandler $moduleHandler */ |
47
|
|
|
$configHandler = xoops_getHandler('config'); |
48
|
|
|
if ($module) { |
49
|
|
|
$configurator = $configHandler->getConfigsByCat(0, $module->getVar('mid')); |
50
|
|
|
if (isset($configurator[$option])) { |
51
|
|
|
$retval = $configurator[$option]; |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
$tbloptions[$option] = $retval; |
56
|
|
|
|
57
|
|
|
return $retval; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @param $caption |
62
|
|
|
* @param $name |
63
|
|
|
* @param $value |
64
|
|
|
* @param $rows |
65
|
|
|
* @param $cols |
66
|
|
|
* @param $width |
67
|
|
|
* @param $height |
68
|
|
|
* @param $supplemental |
69
|
|
|
* |
70
|
|
|
* @return bool|XoopsFormEditor |
71
|
|
|
*/ |
72
|
|
|
public static function getWysiwygForm($caption, $name, $value, $rows, $cols, $width, $height, $supplemental) |
73
|
|
|
{ |
74
|
|
|
$editor_option = strtolower(static::getModuleOption('form_options')); |
75
|
|
|
$editor = false; |
|
|
|
|
76
|
|
|
$editor_configs = []; |
77
|
|
|
$editor_configs['name'] = $name; |
78
|
|
|
$editor_configs['value'] = $value; |
79
|
|
|
$editor_configs['rows'] = $rows; |
80
|
|
|
$editor_configs['cols'] = $cols; |
81
|
|
|
$editor_configs['width'] = $width; |
82
|
|
|
$editor_configs['height'] = $height; |
83
|
|
|
$editor_configs['editor'] = $editor_option; |
84
|
|
|
|
85
|
|
|
$editor = new XoopsFormEditor($caption, $name, $editor_configs); |
86
|
|
|
|
87
|
|
|
return $editor; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.