|
1 | 1 | <?php |
2 | 2 |
|
3 | | -use XoopsModules\Modulebuilder; |
4 | | - |
5 | 3 | /* |
6 | 4 | You may not change or alter any portion of this comment or credits |
7 | 5 | of supporting developers from this source code or any supporting source code |
|
23 | 21 | * |
24 | 22 | */ |
25 | 23 |
|
| 24 | +use XoopsModules\Modulebuilder; |
| 25 | +use XoopsModules\Modulebuilder\Files; |
26 | 26 | use Xmf\Request; |
27 | 27 |
|
28 | 28 | $templateMain = 'modulebuilder_building.tpl'; |
29 | 29 |
|
30 | 30 | include __DIR__ . '/header.php'; |
31 | | -$op = Request::getString('op', 'default'); |
32 | | -$mid = Request::getInt('mod_id'); |
33 | | -$inroot_copy = Request::getInt('inroot_copy'); |
34 | | -$testdata_restore = Request::getInt('testdata_restore'); |
35 | | -$moduleObj = $helper->getHandler('Modules')->get($mid); |
36 | | -$cachePath = XOOPS_VAR_PATH . '/caches/modulebuilder_cache'; |
| 31 | +$op = Request::getString('op', 'default'); |
| 32 | +$mid = Request::getInt('mod_id'); |
| 33 | +$inrootCopy = Request::getInt('inroot_copy'); |
| 34 | +$testdataRestore = Request::getInt('testdata_restore'); |
| 35 | +$checkData = Request::hasVar('check_data'); |
| 36 | +$moduleObj = $helper->getHandler('Modules')->get($mid); |
| 37 | + |
| 38 | +$cachePath = XOOPS_VAR_PATH . '/caches/modulebuilder_cache_'; |
37 | 39 | if (!is_dir($cachePath)) { |
38 | 40 | if (!mkdir($cachePath, 0777) && !is_dir($cachePath)) { |
39 | 41 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $cachePath)); |
|
47 | 49 | if (!file_exists($indexFile = $cachePath . '/index.html')) { |
48 | 50 | copy('index.html', $indexFile); |
49 | 51 | } |
| 52 | + |
| 53 | +if ($checkData > 0) { |
| 54 | + $op = 'check_data'; |
| 55 | +} |
50 | 56 | // Switch option |
51 | 57 | switch ($op) { |
| 58 | + case 'check_data': |
| 59 | + $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php')); |
| 60 | + $GLOBALS['xoopsTpl']->assign('modPathIcon16', TDMC_URL . '/' . $modPathIcon16); |
| 61 | + $checkdata = Modulebuilder\Files\CheckData::getInstance(); |
| 62 | + |
| 63 | + // check data for inconsistences |
| 64 | + $checkResults = []; |
| 65 | + $checkResults = $checkdata->getCheckPreBuilding($moduleObj); |
| 66 | + |
| 67 | + if (count($checkResults) > 0) { |
| 68 | + //$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php')); |
| 69 | + $GLOBALS['xoopsTpl']->assign('checkResults', $checkResults); |
| 70 | + } else { |
| 71 | + $GLOBALS['xoopsTpl']->assign('checkResultsNice', true); |
| 72 | + } |
| 73 | + |
| 74 | + break; |
52 | 75 | case 'build': |
53 | 76 | $GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php')); |
54 | 77 | $building = Modulebuilder\Building::getInstance(); |
55 | 78 | $structure = Modulebuilder\Files\CreateStructure::getInstance(); |
56 | 79 | $architecture = Modulebuilder\Files\CreateArchitecture::getInstance(); |
| 80 | + $checkdata = Modulebuilder\Files\CheckData::getInstance(); |
57 | 81 | // Get var module dirname |
58 | 82 | $moduleDirname = $moduleObj->getVar('mod_dirname'); |
59 | | - if (1 === $testdata_restore) { |
| 83 | + |
| 84 | + //save test data of selected module before building new version |
| 85 | + if (1 === $testdataRestore) { |
60 | 86 | // Directories for copy from |
61 | 87 | $fromDir = XOOPS_ROOT_PATH . '/modules/' . mb_strtolower($moduleDirname) . '/testdata'; |
62 | 88 | if (is_dir($fromDir)) { |
|
71 | 97 | } |
72 | 98 | $building->copyDir($fromDir, $toDir); |
73 | 99 | } else { |
74 | | - $testdata_restore = 0; |
| 100 | + $testdataRestore = 0; |
75 | 101 | } |
76 | 102 | } |
77 | 103 |
|
|
115 | 141 | $building_directory = sprintf(_AM_MODULEBUILDER_BUILDING_DIRECTORY, $moduleDirname); |
116 | 142 |
|
117 | 143 | // Copy this module in root modules |
118 | | - if (1 === $inroot_copy) { |
| 144 | + if (1 === $inrootCopy) { |
119 | 145 | if (isset($moduleDirname)) { |
120 | 146 | // Clear this module if it's in root/modules |
121 | 147 | // Warning: If you have an older operating module with the same name, |
|
128 | 154 | $building->copyDir($fromDir, $toDir); |
129 | 155 | $building_directory .= sprintf(_AM_MODULEBUILDER_BUILDING_DIRECTORY_INROOT, $toDir); |
130 | 156 | } |
131 | | - if (1 === $testdata_restore) { |
| 157 | + if (1 === $testdataRestore) { |
132 | 158 | // Directories for copy from to |
133 | 159 | $fromDir = TDMC_UPLOAD_TEMP_PATH . '/' . mb_strtolower($moduleDirname) . '/testdata'; |
134 | 160 | $toDir = XOOPS_ROOT_PATH . '/modules/' . mb_strtolower($moduleDirname) . '/testdata'; |
135 | | - $building->copyDir($fromDir, $toDir); |
| 161 | + if (is_dir($toDir)) { |
| 162 | + $building->clearDir($toDir); |
| 163 | + } |
| 164 | + if (is_dir($fromDir)) { |
| 165 | + $building->copyDir($fromDir, $toDir); |
| 166 | + } |
136 | 167 | } |
137 | 168 |
|
138 | 169 | $GLOBALS['xoopsTpl']->assign('building_directory', $building_directory); |
|
0 commit comments