Skip to content

Commit b172eca

Browse files
authored
Merge pull request #174 from ggoffy/master
update modulbuilder itself based on PHPStorm Inspect Code
2 parents 3ae8275 + a3c097b commit b172eca

41 files changed

Lines changed: 504 additions & 479 deletions

Some content is hidden

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

admin/building.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
$cachePath = \XOOPS_VAR_PATH . '/caches/modulebuilder_cache_';
4040
if (!\is_dir($cachePath)) {
41-
if (!\mkdir($cachePath, 0777) && !\is_dir($cachePath)) {
41+
if (!\mkdir($cachePath) && !\is_dir($cachePath)) {
4242
throw new \RuntimeException(\sprintf('Directory "%s" was not created', $cachePath));
4343
}
4444
\chmod($cachePath, 0777);

admin/devtools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@
8585
$regexFiles = new RegexIterator($Iterator, '/^.+\.(php|tpl)$/i', RecursiveRegexIterator::GET_MATCH);
8686
//$files = new RegexIterator($flattened, '#^(?:[A-Z]:)?(?:/(?!\.Trash)[^/]+)+/[^/]+\.(?:php|html)$#Di');
8787
$modfiles = [];
88-
foreach ($regexFiles as $regexFiles) {
89-
$file = str_replace('\\', '/', $regexFiles[0]);
88+
foreach ($regexFiles as $regexFile) {
89+
$file = str_replace('\\', '/', $regexFile[0]);
9090
if (!\in_array($file, $langfiles)) {
9191
$modfiles[] = $file;
9292
}

admin/fields.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,21 +201,29 @@
201201
$GLOBALS['xoopsTpl']->assign('form', $form->render());
202202
break;
203203
case 'order':
204+
$error = false;
204205
// Initialize fields handler
205-
$fieldsObj = $helper->getHandler('Fields');
206+
$fieldsHandler = $helper->getHandler('Fields');
206207
if (isset($_POST['forder'])) {
207208
$i = 0;
208209
foreach ($_POST['forder'] as $order) {
209210
if ($order > 0) {
210-
$fieldOrder = $fieldsObj->get($order);
211-
$fieldOrder->setVar('field_order', $i);
212-
if (!$fieldsObj->insert($fieldOrder)) {
211+
$fieldsObj = $fieldsHandler->get((int)$order);
212+
if ($fieldsObj instanceof \XoopsObject) {
213+
$fieldsObj->setVar('field_order', $i);
214+
if (!$fieldsHandler->insert($fieldsObj)) {
215+
$error = true;
216+
}
217+
} else {
213218
$error = true;
219+
continue;
214220
}
215221
++$i;
216222
}
217223
}
218-
\redirect_header('fields.php', 5, \_AM_MODULEBUILDER_FIELD_ORDER_ERROR);
224+
if ($error) {
225+
\redirect_header('fields.php', 5, \_AM_MODULEBUILDER_FIELD_ORDER_ERROR);
226+
}
219227
unset($i);
220228
}
221229
exit;

admin/logo.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@
2727
$caption = \Xmf\Request::getString('caption', '', 'GET');
2828
if (\function_exists($funct)) {
2929
$ret = Modulebuilder\Logo::getInstance()->createLogo($iconName, $caption);
30-
phpFunction($ret);
30+
if (false !== $ret) {
31+
phpFunction($ret);
32+
}
3133
} else {
3234
\redirect_header('logo.php', 3, 'Method Not Exist');
3335
}
3436
// phpFunction
3537
/**
3638
* @param string $val
3739
*/
38-
function phpFunction($val = ''): void
40+
function phpFunction(string $val = ''): void
3941
{
4042
// create php function here
4143
echo $val;

admin/modules.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
'mod_subversion' => Request::getString('mod_subversion', '', 'POST'),
168168
]
169169
);
170-
$moduleOption = Request::getArray('module_option', []);
170+
$moduleOption = Request::getArray('module_option');
171171
$modulesObj->setVar('mod_admin', \in_array('admin', $moduleOption));
172172
$modulesObj->setVar('mod_user', \in_array('user', $moduleOption));
173173
$modulesObj->setVar('mod_blocks', \in_array('blocks', $moduleOption));

admin/settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
'set_subversion' => \Xmf\Request::getString('set_subversion', '', 'POST'),
124124
]
125125
);
126-
$settingOption = \Xmf\Request::getArray('setting_option', []);
126+
$settingOption = \Xmf\Request::getArray('setting_option');
127127
$settingsObj->setVar('set_admin', \in_array('admin', $settingOption));
128128
$settingsObj->setVar('set_user', \in_array('user', $settingOption));
129129
$settingsObj->setVar('set_blocks', \in_array('blocks', $settingOption));

admin/tables.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@
163163
}
164164
$tablesObj->setVar('table_autoincrement', (1 == $_REQUEST['table_autoincrement']) ? 1 : 0);
165165
// Options
166-
$tableOption = \Xmf\Request::getArray('table_option', []);
166+
$tableOption = \Xmf\Request::getArray('table_option');
167167
$tablesObj->setVar('table_install', \in_array('install', $tableOption));
168168
$tablesObj->setVar('table_index', \in_array('index', $tableOption));
169169
$tablesObj->setVar('table_blocks', \in_array('blocks', $tableOption));
@@ -237,21 +237,29 @@
237237
$GLOBALS['xoopsTpl']->assign('form', $form->render());
238238
break;
239239
case 'order':
240+
$error = false;
240241
// Initialize tables handler
241-
$tablesObj = $helper->getHandler('Tables');
242+
$tablesHandler = $helper->getHandler('Tables');
242243
if (isset($_POST['torder'])) {
243244
$i = 0;
244245
foreach ($_POST['torder'] as $order) {
245246
if ($order > 0) {
246-
$tableOrder = $tablesObj->get($order);
247-
$tableOrder->setVar('table_order', $i);
248-
if (!$tablesObj->insert($tableOrder)) {
247+
$tablesObj = $tablesHandler->get((int)$order);
248+
if ($tablesObj instanceof \XoopsObject) {
249+
$tablesObj->setVar('table_order', $i);
250+
if (!$tablesHandler->insert($tablesObj)) {
251+
$error = true;
252+
}
253+
} else {
249254
$error = true;
255+
continue;
250256
}
251257
++$i;
252258
}
253259
}
254-
\redirect_header('tables.php', 5, \_AM_MODULEBUILDER_TABLE_ORDER_ERROR);
260+
if ($error) {
261+
\redirect_header('tables.php', 5, \_AM_MODULEBUILDER_TABLE_ORDER_ERROR);
262+
}
255263
unset($i);
256264
}
257265
exit;

assets/css/admin/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ img.imageToggle {
183183
.portlet {
184184
margin: 0 0.1em 1em 0;
185185
padding: 0 0.3em;
186+
min-width: 250px;
186187
}
187188

188189
.portlet-header {

class/Common/Confirm.php

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*
1818
* @copyright 2020 XOOPS Project (https://xoops.org)
1919
* @license GPL 2.0 or later
20+
* @package Modulebuilder
2021
* @since 1.0
2122
* @min_xoops 2.5.9
2223
* @author Goffy - Email:<goffy@myxoops.org> - Website:<https://xoops.org>
@@ -39,21 +40,21 @@
3940
*/
4041
class Confirm
4142
{
42-
private $hiddens = [];
43-
private $action = '';
44-
private $title = '';
45-
private $label = '';
46-
private $object = '';
43+
private array $hiddens = [];
44+
private string $action = '';
45+
private string $title = '';
46+
private string $label = '';
47+
private string $object = '';
4748

4849
/**
4950
* @public function constructor class
50-
* @param $hiddens
51-
* @param $action
52-
* @param $object
51+
* @param array $hiddens
52+
* @param string $action
53+
* @param string $object
5354
* @param string $title
5455
* @param string $label
5556
*/
56-
public function __construct($hiddens, $action, $object, string $title = '', string $label = '')
57+
public function __construct(array $hiddens, string $action, string $object, string $title = '', string $label = '')
5758
{
5859
$this->hiddens = $hiddens;
5960
$this->action = $action;
@@ -66,9 +67,9 @@ public function __construct($hiddens, $action, $object, string $title = '', stri
6667
* @public function getFormConfirm
6768
* @return \XoopsThemeForm
6869
*/
69-
public function getFormConfirm()
70+
public function getFormConfirm(): \XoopsThemeForm
7071
{
71-
$moduleDirName = \basename(__DIR__);
72+
$moduleDirName = \basename(\dirname(__DIR__, 2));
7273
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
7374
//in order to be accessable from user and admin area this should be place in language common.php
7475
if (!\defined('CO_' . $moduleDirNameUpper . '_DELETE_CONFIRM')) {

class/Common/FileChecker.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class FileChecker
4343
*
4444
* @return bool|string
4545
*/
46-
public static function getFileStatus(string $file_path, string $redirectFile, string $original_file_path = null)
46+
public static function getFileStatus(string $file_path, string $redirectFile, ?string $original_file_path = null)
4747
{
4848
$pathIcon16 = \Xmf\Module\Admin::iconUrl('', '16');
4949

@@ -151,9 +151,9 @@ public static function setFilePermissions($target, int $mode = 0777)
151151
|| !\Xmf\Request::hasVar('redirect', 'POST')) {
152152
return;
153153
}
154-
$original_file_path = $_POST['original_file_path'];
155-
$file_path = $_POST['file_path'];
156-
$redirect = $_POST['redirect'];
154+
$original_file_path = \Xmf\Request::getString('original_file_path');
155+
$file_path = \Xmf\Request::getString('file_path');
156+
$redirect =\Xmf\Request::getString('redirect');
157157
$msg = FileChecker::copyFile($original_file_path, $file_path) ? \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILECOPIED') : \constant('CO_' . $moduleDirNameUpper . '_' . 'FC_FILENOTCOPIED');
158158
\redirect_header($redirect, 2, $msg . ': ' . $file_path);
159159
}

0 commit comments

Comments
 (0)