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
|
|
|
/** |
13
|
|
|
* @copyright XOOPS Project http://xoops.org/ |
14
|
|
|
* @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @package |
16
|
|
|
* @since |
17
|
|
|
* @author XOOPS Development Team |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
use Xmf\Language; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* |
24
|
|
|
* Prepares system prior to attempting to install module |
25
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
26
|
|
|
* |
27
|
|
|
* @return bool true if ready to install, false if not |
28
|
|
|
*/ |
29
|
|
|
function xoops_module_pre_install_soapbox(XoopsModule $module) |
|
|
|
|
30
|
|
|
{ |
31
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
32
|
|
|
$classUtility = ucfirst($moduleDirName) . 'Utility'; |
33
|
|
|
if (!class_exists($classUtility)) { |
34
|
|
|
xoops_load('utility', $moduleDirName); |
35
|
|
|
} |
36
|
|
|
//check for minimum XOOPS version |
37
|
|
|
if (!$classUtility::checkVerXoops($module)) { |
38
|
|
|
return false; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
// check for minimum PHP version |
42
|
|
|
if (!$classUtility::checkVerPhp($module)) { |
43
|
|
|
return false; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
$mod_tables =& $module->getInfo('tables'); |
47
|
|
|
foreach ($mod_tables as $table) { |
48
|
|
|
$GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return true; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* |
56
|
|
|
* Performs tasks required during installation of the module |
57
|
|
|
* @param XoopsModule $module {@link XoopsModule} |
58
|
|
|
* |
59
|
|
|
* @return bool true if installation successful, false if not |
60
|
|
|
*/ |
61
|
|
|
function xoops_module_install_soapbox(XoopsModule $module) |
62
|
|
|
{ |
63
|
|
|
require_once dirname(dirname(dirname(__DIR__))) . '/mainfile.php'; |
64
|
|
|
require_once __DIR__ . '/../include/config.php'; |
65
|
|
|
|
66
|
|
|
if (!isset($moduleDirName)) { |
|
|
|
|
67
|
|
|
$moduleDirName = basename(dirname(__DIR__)); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
|
|
|
71
|
|
|
} else { |
72
|
|
|
$moduleHelper = Xmf\Module\Helper::getHelper('system'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
// Load language files |
76
|
|
|
$moduleHelper->loadLanguage('admin'); |
77
|
|
|
$moduleHelper->loadLanguage('modinfo'); |
78
|
|
|
|
79
|
|
|
$configurator = new ModuleConfigurator(); |
80
|
|
|
$classUtility = ucfirst($moduleDirName) . 'Utility'; |
81
|
|
|
if (!class_exists($classUtility)) { |
82
|
|
|
xoops_load('utility', $moduleDirName); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
// --- CREATE FOLDERS --------------- |
86
|
|
View Code Duplication |
if (count($configurator->uploadFolders) > 0) { |
|
|
|
|
87
|
|
|
// foreach (array_keys($GLOBALS['uploadFolders']) as $i) { |
|
|
|
|
88
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
89
|
|
|
$classUtility::createFolder($configurator->uploadFolders[$i]); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
// --- COPY blank.png FILES --------------- |
94
|
|
View Code Duplication |
if (count($configurator->blankFiles) > 0) { |
|
|
|
|
95
|
|
|
$file = __DIR__ . '/../assets/images/blank.png'; |
96
|
|
|
foreach (array_keys($configurator->blankFiles) as $i) { |
97
|
|
|
$dest = $configurator->blankFiles[$i] . '/blank.png'; |
98
|
|
|
$classUtility::copyFile($file, $dest); |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: