|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use XoopsModules\Tdmcreate; |
|
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
|
|
|
* tdmcreate module. |
|
16
|
|
|
* |
|
17
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
18
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
19
|
|
|
* |
|
20
|
|
|
* @since 2.5.0 |
|
21
|
|
|
* |
|
22
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
23
|
|
|
* |
|
24
|
|
|
* @version $Id: building.php 12258 2014-01-02 09:33:29Z timgno $ |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'tdmcreate_building.tpl'; |
|
28
|
|
|
|
|
29
|
|
|
include __DIR__ . '/header.php'; |
|
30
|
|
|
$op = \Xmf\Request::getString('op', 'default'); |
|
31
|
|
|
$mid = \Xmf\Request::getInt('mod_id'); |
|
32
|
|
|
$moduleObj = $helper->getHandler('Modules')->get($mid); |
|
33
|
|
|
$cachePath = XOOPS_VAR_PATH . '/caches/tdmcreate_cache'; |
|
34
|
|
|
// Clear cache |
|
35
|
|
|
if (file_exists($cache = $cachePath . '/classpaths.cache')) { |
|
36
|
|
|
unlink($cache); |
|
37
|
|
|
} |
|
38
|
|
|
if (!file_exists($indexFile = $cachePath . '/index.html')) { |
|
39
|
|
|
copy('index.html', $indexFile); |
|
40
|
|
|
} |
|
41
|
|
|
// Switch option |
|
42
|
|
|
switch ($op) { |
|
43
|
|
|
case 'build': |
|
44
|
|
|
// $templateMain = 'tdmcreate_building.tpl'; |
|
45
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php')); |
|
46
|
|
|
// Get var module dirname |
|
47
|
|
|
$moduleDirname = $moduleObj->getVar('mod_dirname'); |
|
48
|
|
|
// Directories for copy from to |
|
49
|
|
|
$fromDir = TDMC_UPLOAD_REPOSITORY_PATH . '/' . mb_strtolower($moduleDirname); |
|
50
|
|
|
$toDir = XOOPS_ROOT_PATH . '/modules/' . mb_strtolower($moduleDirname); |
|
51
|
|
|
// include_once TDMC_CLASS_PATH . '/building.php'; |
|
52
|
|
|
if (isset($moduleDirname)) { |
|
53
|
|
|
// Clear this module if it's in repository |
|
54
|
|
|
$building = Tdmcreate\Building::getInstance(); |
|
55
|
|
|
if (is_dir($fromDir)) { |
|
56
|
|
|
$building->clearDir($fromDir); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
// Structure |
|
60
|
|
|
// include_once TDMC_CLASS_PATH . '/files/Architecture.php'; |
|
61
|
|
|
$handler = Tdmcreate\Files\CreateArchitecture::getInstance(); |
|
62
|
|
|
// Creation of the structure of folders and files |
|
63
|
|
|
$baseArchitecture = $handler->setBaseFoldersFiles($moduleObj); |
|
|
|
|
|
|
64
|
|
|
if (false !== $baseArchitecture) { |
|
|
|
|
|
|
65
|
|
|
$GLOBALS['xoopsTpl']->assign('base_architecture', true); |
|
66
|
|
|
} else { |
|
67
|
|
|
$GLOBALS['xoopsTpl']->assign('base_architecture', false); |
|
68
|
|
|
} |
|
69
|
|
|
// Get files |
|
70
|
|
|
$build = []; |
|
71
|
|
|
$files = $handler->setFilesToBuilding($moduleObj); |
|
72
|
|
|
foreach ($files as $file) { |
|
73
|
|
|
if ($file) { |
|
74
|
|
|
$build['list'] = $file; |
|
75
|
|
|
} |
|
76
|
|
|
$GLOBALS['xoopsTpl']->append('builds', $build); |
|
77
|
|
|
} |
|
78
|
|
|
unset($build); |
|
79
|
|
|
// Directory to saved all files |
|
80
|
|
|
$GLOBALS['xoopsTpl']->assign('building_directory', sprintf(_AM_TDMCREATE_BUILDING_DIRECTORY, $moduleDirname)); |
|
81
|
|
|
// Copy this module in root modules |
|
82
|
|
|
if (1 == $moduleObj->getVar('mod_inroot_copy')) { |
|
83
|
|
|
$building = Tdmcreate\Building::getInstance(); |
|
84
|
|
|
if (isset($moduleDirname)) { |
|
85
|
|
|
// Clear this module if it's in root/modules |
|
86
|
|
|
// Warning: If you have an older operating module with the same name, |
|
87
|
|
|
// it's good to make a copy in another safe folder, |
|
88
|
|
|
// otherwise it will be deleted irreversibly. |
|
89
|
|
|
if (is_dir($fromDir)) { |
|
90
|
|
|
$building->clearDir($toDir); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
$building->copyDir($fromDir, $toDir); |
|
94
|
|
|
} |
|
95
|
|
|
break; |
|
96
|
|
|
case 'default': |
|
97
|
|
|
default: |
|
98
|
|
|
// $templateMain = 'tdmcreate_building.tpl'; |
|
99
|
|
|
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php')); |
|
100
|
|
|
// Redirect if there aren't modules |
|
101
|
|
|
$nbModules = $helper->getHandler('Modules')->getCount(); |
|
102
|
|
|
if (0 == $nbModules) { |
|
103
|
|
|
redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES); |
|
104
|
|
|
} |
|
105
|
|
|
unset($nbModules); |
|
106
|
|
|
// include_once TDMC_CLASS_PATH . '/building.php'; |
|
107
|
|
|
$building = Tdmcreate\Building::getInstance(); |
|
108
|
|
|
$form = $building->getForm(); |
|
109
|
|
|
$GLOBALS['xoopsTpl']->assign('form', $form->render()); |
|
110
|
|
|
break; |
|
111
|
|
|
} |
|
112
|
|
|
include __DIR__ . '/footer.php'; |
|
113
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.