|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Epesi\Core\Controllers; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Routing\Controller; |
|
6
|
|
|
use Epesi\Core\System\SystemCore; |
|
7
|
|
|
use Epesi\Core\App as Epesi; |
|
8
|
|
|
use Epesi\Core\System\Integration\Modules\ModuleManager; |
|
9
|
|
|
use Epesi\Core\Layout\LayoutView; |
|
10
|
|
|
|
|
11
|
|
|
class SystemController extends Controller |
|
12
|
|
|
{ |
|
13
|
|
|
public function index() |
|
14
|
|
|
{ |
|
15
|
|
|
return SystemCore::isInstalled()? redirect('home'): redirect('install'); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function install(Epesi $epesi) |
|
19
|
|
|
{ |
|
20
|
|
|
// make sure the installation information is fresh |
|
21
|
|
|
ModuleManager::clearCache(); |
|
22
|
|
|
|
|
23
|
|
|
if (SystemCore::isInstalled()) return redirect('home'); |
|
24
|
|
|
|
|
25
|
|
|
$epesi->title = config('epesi.app.title') . ' > ' . __('Installation'); |
|
26
|
|
|
|
|
27
|
|
|
$epesi->initLayout('Centered'); |
|
28
|
|
|
|
|
29
|
|
|
$epesi->layout->set('logo', url('logo')); |
|
30
|
|
|
$epesi->layout->template->setHTML('copyright', config('epesi.app.copyright')); |
|
31
|
|
|
|
|
32
|
|
|
$epesi->add(new \Epesi\Core\System\SystemInstallWizard()); |
|
33
|
|
|
|
|
34
|
|
|
return $epesi->response(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function home() |
|
38
|
|
|
{ |
|
39
|
|
|
return redirect(SystemCore::isInstalled()? \Epesi\Core\HomePage\HomePageSettings::getUserHomePagePath(): 'install'); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function logo() |
|
43
|
|
|
{ |
|
44
|
|
|
$meta = \Epesi\Core\System\Logo\LogoSettings::getLogoMeta(); |
|
45
|
|
|
|
|
46
|
|
|
return response($meta['contents'], 200, ['Content-type' => $meta['mime']])->setMaxAge(604800)->setPublic(); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function view(Epesi $epesi, $module, $method = 'body', $args = []) |
|
50
|
|
|
{ |
|
51
|
|
|
$epesi->initLayout(new LayoutView()); |
|
|
|
|
|
|
52
|
|
|
|
|
53
|
|
|
$alias = explode(':', $module); |
|
54
|
|
|
|
|
55
|
|
|
$moduleAlias = $alias[0]; |
|
56
|
|
|
$viewAlias = $alias[1]?? null; |
|
57
|
|
|
|
|
58
|
|
|
$view = null; |
|
59
|
|
|
if ($module = ModuleManager::getClass($moduleAlias, true)) { |
|
60
|
|
|
$viewClass = $module::view($viewAlias); |
|
61
|
|
|
|
|
62
|
|
|
if (class_exists($viewClass)) { |
|
63
|
|
|
$view = new $viewClass(); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if (! $view) abort(404); |
|
68
|
|
|
|
|
69
|
|
|
$epesi->add($view)->displayModuleContent($method, $args); |
|
70
|
|
|
|
|
71
|
|
|
$epesi->setLocation($view->location()); |
|
72
|
|
|
|
|
73
|
|
|
return $epesi->response(); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|