Skip to content

Commit 349219a

Browse files
committed
simplify
1 parent 81aee1f commit 349219a

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

src/web/form/AbstractForm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(Module $module)
3737
}
3838

3939
/**
40-
* @return mixed[]
40+
* @return array{form: array<string, string>}
4141
*/
4242
abstract public function getFields(): array;
4343
}

src/web/form/ScannerForm.php

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getFields(): array
4646
[
4747
'type' => 'html',
4848
'label' => '',
49-
'html_content' => $this->infectedFiles(),
49+
'html_content' => $this->render(),
5050
'col' => 12,
5151
'name' => '',
5252
],
@@ -58,9 +58,26 @@ public function getFields(): array
5858
];
5959
}
6060

61-
private function infectedFiles(): string
61+
private function render(): string
6262
{
63-
$sections = [
63+
$result = '';
64+
65+
foreach ($this->getSections() as $section) {
66+
if (!empty($section[0])) {
67+
$result .= View::displayAlertDanger($section[1] . '<br>' . implode('<br>', $section[0]));
68+
} else {
69+
$result .= View::displayAlertSuccess($section[2]);
70+
}
71+
}
72+
73+
$result .= $this->getStyle();
74+
75+
return $result;
76+
}
77+
78+
private function getSections(): array
79+
{
80+
return [
6481
[
6582
$this->getPatchModules(),
6683
$this->module->l('Your website is vulnerable. You must upgrade the following modules manually:', $this->className),
@@ -82,20 +99,6 @@ private function infectedFiles(): string
8299
$this->module->l('No insecure filepermissions was found.', $this->className),
83100
],
84101
];
85-
86-
$result = '';
87-
88-
foreach ($sections as $section) {
89-
if (!empty($section[0])) {
90-
$result .= View::displayAlertDanger($section[1] . '<br>' . implode('<br>', $section[0]));
91-
} else {
92-
$result .= View::displayAlertSuccess($section[2]);
93-
}
94-
}
95-
96-
$result .= '<style>.bootstrap, .form-horizontal, .form-wrapper{max-width: 100% !important;}</style>';
97-
98-
return $result;
99102
}
100103

101104
/**
@@ -161,4 +164,9 @@ private function getInsecureFilepermissions(): array
161164
->scan()
162165
->dryRun();
163166
}
167+
168+
private function getStyle(): string
169+
{
170+
return '<style>.bootstrap, .form-horizontal, .form-wrapper{max-width: 100% !important;}</style>';
171+
}
164172
}

0 commit comments

Comments
 (0)