Skip to content

Commit 2e4710e

Browse files
authored
Merge pull request #16 from ggoffy/master
- added check quality/inconsistences of module data before building
2 parents f07b541 + 1531a26 commit 2e4710e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+995
-393
lines changed

_TODO.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,17 @@ TODOs:
1111

1212
new xoops_confirm
1313

14-
catch error when notification selected but no status field exists
1514

16-
Broken files:
17-
Notification for broken files in xoops_version adapt?
18-
add initiate event when click on broken file
15+
rate.php:
16+
this file currently is not rating
1917

2018

21-
Notifications:
22-
there are too much notification, which are not needed/working
23-
- reduce xoops_version.php to needed
24-
- adapt language/modinfo.php (make nice text of e.g.: Global newcategory notify caption)
2519

2620

27-
rate.php:
28-
this file currently is not rating
2921

22+
Permissions:
23+
check handling for different groups
24+
implement autoapprove
3025

3126

3227

admin/building.php

Lines changed: 44 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use XoopsModules\Modulebuilder;
4-
53
/*
64
You may not change or alter any portion of this comment or credits
75
of supporting developers from this source code or any supporting source code
@@ -23,17 +21,21 @@
2321
*
2422
*/
2523

24+
use XoopsModules\Modulebuilder;
25+
use XoopsModules\Modulebuilder\Files;
2626
use Xmf\Request;
2727

2828
$templateMain = 'modulebuilder_building.tpl';
2929

3030
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_';
3739
if (!is_dir($cachePath)) {
3840
if (!mkdir($cachePath, 0777) && !is_dir($cachePath)) {
3941
throw new \RuntimeException(sprintf('Directory "%s" was not created', $cachePath));
@@ -47,16 +49,40 @@
4749
if (!file_exists($indexFile = $cachePath . '/index.html')) {
4850
copy('index.html', $indexFile);
4951
}
52+
53+
if ($checkData > 0) {
54+
$op = 'check_data';
55+
}
5056
// Switch option
5157
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;
5275
case 'build':
5376
$GLOBALS['xoopsTpl']->assign('navigation', $adminObject->displayNavigation('building.php'));
5477
$building = Modulebuilder\Building::getInstance();
5578
$structure = Modulebuilder\Files\CreateStructure::getInstance();
5679
$architecture = Modulebuilder\Files\CreateArchitecture::getInstance();
80+
$checkdata = Modulebuilder\Files\CheckData::getInstance();
5781
// Get var module dirname
5882
$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) {
6086
// Directories for copy from
6187
$fromDir = XOOPS_ROOT_PATH . '/modules/' . mb_strtolower($moduleDirname) . '/testdata';
6288
if (is_dir($fromDir)) {
@@ -71,7 +97,7 @@
7197
}
7298
$building->copyDir($fromDir, $toDir);
7399
} else {
74-
$testdata_restore = 0;
100+
$testdataRestore = 0;
75101
}
76102
}
77103

@@ -115,7 +141,7 @@
115141
$building_directory = sprintf(_AM_MODULEBUILDER_BUILDING_DIRECTORY, $moduleDirname);
116142

117143
// Copy this module in root modules
118-
if (1 === $inroot_copy) {
144+
if (1 === $inrootCopy) {
119145
if (isset($moduleDirname)) {
120146
// Clear this module if it's in root/modules
121147
// Warning: If you have an older operating module with the same name,
@@ -128,11 +154,16 @@
128154
$building->copyDir($fromDir, $toDir);
129155
$building_directory .= sprintf(_AM_MODULEBUILDER_BUILDING_DIRECTORY_INROOT, $toDir);
130156
}
131-
if (1 === $testdata_restore) {
157+
if (1 === $testdataRestore) {
132158
// Directories for copy from to
133159
$fromDir = TDMC_UPLOAD_TEMP_PATH . '/' . mb_strtolower($moduleDirname) . '/testdata';
134160
$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+
}
136167
}
137168

138169
$GLOBALS['xoopsTpl']->assign('building_directory', $building_directory);

assets/images/icons/16/error.png

821 Bytes
Loading

assets/images/icons/16/warning.png

543 Bytes
Loading

class/Building.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,15 @@ public function getForm($action = false)
6969
$mod_select->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
7070
}
7171
$form->addElement($mod_select, true);
72-
72+
7373
$form->addElement(new \XoopsFormRadioYN(_AM_MODULEBUILDER_MODULE_INROOT_COPY, 'inroot_copy', $helper->getConfig('inroot_copy')));
7474
$form->addElement(new \XoopsFormRadioYN(_AM_MODULEBUILDER_ADMIN_BUILD_TEST . _AM_MODULEBUILDER_ADMIN_BUILD_TEST_DESC, 'testdata_restore', 0));
7575

7676
$form->addElement(new \XoopsFormHidden('op', 'build'));
77-
$form->addElement(new \XoopsFormButton(_REQUIRED . ' <sup class="red bold">*</sup>', 'submit', _SUBMIT, 'submit'));
77+
$btnTray = new \XoopsFormElementTray(_REQUIRED . ' <sup class="red bold">*</sup>', '&nbsp;');
78+
$btnTray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
79+
$btnTray->addElement(new \XoopsFormButton('', 'check_data', _AM_MODULEBUILDER_ADMIN_BUILD_CHECK, 'submit'));
80+
$form->addElement($btnTray);
7881

7982
return $form;
8083
}

class/Files/Assets/Css/CssSelectors.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function geCssSelector($selector, $content, $t)
7777
} else {
7878
$ret .= $content . ';';
7979
}
80-
$ret = '}';
80+
$ret .= '}';
8181

8282
return $ret;
8383
}

class/Files/Assets/Js/JavascriptJQuery.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public function render()
176176
$filename = $this->getFileName();
177177
$moduleDirname = $module->getVar('mod_dirname');
178178
$content = $this->getHeaderFilesComments($module);
179-
$content = $this->getJavascriptJQueryButtons();
179+
$content .= $this->getJavascriptJQueryButtons();
180180
$content .= $this->getJavascriptJQueryPrint();
181181

182182
$this->create($moduleDirname, 'assets/js', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED);

0 commit comments

Comments
 (0)