|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Epesi\Core\System; |
|
4
|
|
|
|
|
5
|
|
|
use Epesi\Core\System\Seeds\Form; |
|
6
|
|
|
use atk4\ui\jsExpression; |
|
7
|
|
|
use atk4\ui\Wizard; |
|
8
|
|
|
use Illuminate\Support\Facades\Artisan; |
|
9
|
|
|
use Epesi\Core\System\Integration\Modules\Concerns\HasAdminMode; |
|
10
|
|
|
use Illuminate\Support\Facades\App; |
|
11
|
|
|
use Epesi\Core\System\Integration\Modules\ModuleManager; |
|
12
|
|
|
|
|
13
|
|
|
class SystemInstallWizard extends Wizard |
|
14
|
|
|
{ |
|
15
|
|
|
use HasAdminMode; |
|
16
|
|
|
|
|
17
|
|
|
public function init() |
|
18
|
|
|
{ |
|
19
|
|
|
parent::init(); |
|
20
|
|
|
|
|
21
|
|
|
$this->setAdminMode()->performInstallationSteps(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function performInstallationSteps() |
|
25
|
|
|
{ |
|
26
|
|
|
$this->addStep(__('Welcome'), [__CLASS__, 'stepWelcome']); |
|
27
|
|
|
|
|
28
|
|
|
$this->addStep([__('License'), 'icon'=>'id card', 'description'=>__('Accept license conditions')], [__CLASS__, 'stepLicense']); |
|
29
|
|
|
|
|
30
|
|
|
$this->addStep([__('Database'), 'icon'=>'database', 'description'=>__('Database connection settings')], [__CLASS__, 'stepDatabase']); |
|
31
|
|
|
|
|
32
|
|
|
$this->addStep([__('Environment'), 'icon'=>'configure', 'description'=>__('Check environment')], [__CLASS__, 'stepEnvironment']); |
|
33
|
|
|
|
|
34
|
|
|
$this->addFinish([__CLASS__, 'stepInstallationCompleted']); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function addRequiredNote() |
|
38
|
|
|
{ |
|
39
|
|
|
$this->add(['View', __('denotes required field'), 'class' => ['required-note']])->setStyle(['float' => 'right']); |
|
40
|
|
|
|
|
41
|
|
|
eval_css(' |
|
42
|
|
|
.required-note::before { |
|
43
|
|
|
margin: 0 .2em 0 0; |
|
44
|
|
|
content: \'*\'; |
|
45
|
|
|
color: #db2828; |
|
46
|
|
|
} |
|
47
|
|
|
'); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function setForm($form) |
|
51
|
|
|
{ |
|
52
|
|
|
$this->buttonNext->on('click', $form->js()->submit()); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
public static function stepWelcome($wizard) |
|
56
|
|
|
{ |
|
57
|
|
|
$columns = $wizard->add('Columns'); |
|
58
|
|
|
|
|
59
|
|
|
$column = $columns->addColumn(); |
|
60
|
|
|
$column->add(['Message', __('Thank you for downloading EPESI!')])->text |
|
61
|
|
|
->addParagraph(__('This wizard will guide you though the process of setting up your new installation')) |
|
62
|
|
|
->addParagraph(__('Select the installation language and click NEXT button to proceed to next step')); |
|
63
|
|
|
|
|
64
|
|
|
$column = $columns->addColumn(); |
|
65
|
|
|
|
|
66
|
|
|
if (! function_exists('locale_get_display_language')) { |
|
67
|
|
|
$column->addClass('middle aligned'); |
|
68
|
|
|
$column->add(['Label', __('Install php-intl extension to enable language selection!'), 'class' => ['red']]); |
|
69
|
|
|
|
|
70
|
|
|
return; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$languages = app()->make(\JoeDixon\Translation\Drivers\Translation::class)->allLanguages()->toArray(); |
|
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
$values = array_map(function($language) { |
|
76
|
|
|
return [ |
|
77
|
|
|
locale_get_display_language($language), |
|
78
|
|
|
'icon' => "$language flag" |
|
79
|
|
|
]; |
|
80
|
|
|
}, $languages); |
|
81
|
|
|
|
|
82
|
|
|
$form = $column->add(new Form()); |
|
83
|
|
|
|
|
84
|
|
|
$form->addField('language', ['DropDown', 'values' => $values, 'caption' => __('Select Language')], ['required'=>true])->set($wizard->recall('language', 'en')); |
|
85
|
|
|
|
|
86
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
|
87
|
|
|
$wizard->memorize('language', $form->model['language']); |
|
88
|
|
|
|
|
89
|
|
|
App::setLocale($form->model['language']); |
|
90
|
|
|
|
|
91
|
|
|
return $wizard->jsNext(); |
|
92
|
|
|
}); |
|
93
|
|
|
|
|
94
|
|
|
$wizard->setForm($form); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public static function stepLicense($wizard) |
|
98
|
|
|
{ |
|
99
|
|
|
$columns = $wizard->add('Columns'); |
|
100
|
|
|
$column = $columns->addColumn(); |
|
101
|
|
|
|
|
102
|
|
|
$column->add(['View', 'defaultTemplate' => 'license.html'])->setStyle(['max-height' => '500px', 'overflow' => 'auto', 'padding' => '5px']); |
|
103
|
|
|
|
|
104
|
|
|
$column = $columns->addColumn(); |
|
105
|
|
|
|
|
106
|
|
|
$form = $column->add(new Form()); |
|
107
|
|
|
$form->addField('copyright', ['Checkbox', 'caption' => __('I will not remove the Copyright notice as required by the MIT license.')], ['required'=>true]); |
|
108
|
|
|
$form->addField('logo', ['Checkbox', 'caption' => __('I will not remove "EPESI powered" logo and the link from the application login screen or the toolbar.')], ['required'=>true]); |
|
109
|
|
|
$form->addField('support', ['Checkbox', 'caption' => __('I will not remove "Support -> About" credit page from the application menu.')], ['required'=>true]); |
|
110
|
|
|
$form->addField('store', ['Checkbox', 'caption' => __('I will not remove or rename "EPESI Store" links from the application.')], ['required'=>true]); |
|
111
|
|
|
|
|
112
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
|
|
|
|
|
|
113
|
|
|
return $wizard->jsNext(); |
|
114
|
|
|
}); |
|
115
|
|
|
|
|
116
|
|
|
$wizard->setForm($form); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public static function stepDatabase($wizard) |
|
120
|
|
|
{ |
|
121
|
|
|
$wizard->addRequiredNote(); |
|
122
|
|
|
|
|
123
|
|
|
$form = $wizard->add('Form'); |
|
124
|
|
|
|
|
125
|
|
|
$form->addField('host', __('Database Host'), ['required'=>true])->placeholder = __('e.g. localhost'); |
|
126
|
|
|
$form->addField('port', __('Database Port')); |
|
127
|
|
|
|
|
128
|
|
|
$form->addField('driver', ['DropDown', 'values' => [ |
|
129
|
|
|
'mysql' => 'MySQL', |
|
130
|
|
|
'postgre' => 'PostgeSQL', |
|
131
|
|
|
], 'caption' => __('Database Engine')], ['required'=>true]); |
|
132
|
|
|
|
|
133
|
|
|
$form->addField('database', __('Database Name')); |
|
134
|
|
|
$form->addField('username', __('Database Server User'), ['required'=>true]); |
|
135
|
|
|
$form->addField('password', ['Password', 'caption' => __('Database Server Password')], ['required'=>true]); |
|
136
|
|
|
|
|
137
|
|
|
$form->addField('create', ['Checkbox', 'caption' => __('Create New Database')])->on('change', new jsExpression('if ($(event.target).is(":checked")) alert([])', [__('WARNING: Make sure you have CREATE access level to do this!')])); |
|
138
|
|
|
|
|
139
|
|
|
foreach ($wizard->recall('connection', []) as $name => $value) { |
|
140
|
|
|
if (! $field = $form->fields[$name]?? null) continue; |
|
141
|
|
|
|
|
142
|
|
|
$field->set($value); |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
$form->onSubmit(function ($form) use ($wizard) { |
|
146
|
|
|
$connection = $form->model->get(); |
|
147
|
|
|
|
|
148
|
|
|
$wizard->memorize('connection', $connection); |
|
149
|
|
|
|
|
150
|
|
|
Artisan::call('epesi:database-connection', ['--connection' => $connection]); |
|
151
|
|
|
|
|
152
|
|
|
if ($connection['create']) { |
|
153
|
|
|
Artisan::call('epesi:database-create', ['name' => $connection['database'], '--connection' => $connection]); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
Artisan::call('migrate'); |
|
157
|
|
|
|
|
158
|
|
|
ModuleManager::install('system'); |
|
159
|
|
|
|
|
160
|
|
|
return $wizard->jsNext(); |
|
161
|
|
|
}); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public static function stepEnvironment($wizard) |
|
165
|
|
|
{ |
|
166
|
|
|
$wizard->add(new SystemEnvironmentOverview()); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public static function stepInstallationCompleted($wizard) |
|
170
|
|
|
{ |
|
171
|
|
|
$wizard->add(['Header', 'You are DONE', 'huge centered']); |
|
172
|
|
|
} |
|
173
|
|
|
} |
|
174
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths