From 65901ce216c7d2e9d72ebbc462a7830e0405026b Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Thu, 27 Aug 2015 20:11:06 +0930 Subject: [PATCH] Check some requirements before installation --- .../core/src/Install/Actions/IndexAction.php | 25 +++++++++++++++-- framework/core/views/install/app.blade.php | 28 +++++++++++++++++++ framework/core/views/install/errors.blade.php | 8 ++++-- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/framework/core/src/Install/Actions/IndexAction.php b/framework/core/src/Install/Actions/IndexAction.php index a0841c9cc..e257fb5a5 100644 --- a/framework/core/src/Install/Actions/IndexAction.php +++ b/framework/core/src/Install/Actions/IndexAction.php @@ -40,8 +40,29 @@ class IndexAction extends HtmlAction $view->logo = $this->view->make('flarum.install::logo'); - $view->content = $this->view->make('flarum.install::install'); - $view->content->input = []; + $errors = []; + + if (version_compare(PHP_VERSION, '5.5.0', '<')) { + $errors[] = [ + 'message' => 'PHP 5.5+ is required.', + 'detail' => 'You are running version '.PHP_VERSION.'.' + ]; + } + + foreach (['mbstring', 'pdo_mysql'] as $extension) { + if (! extension_loaded($extension)) { + $errors[] = [ + 'message' => 'The '.$extension.' extension is required.' + ]; + } + } + + if (count($errors)) { + $view->content = $this->view->make('flarum.install::errors'); + $view->content->errors = $errors; + } else { + $view->content = $this->view->make('flarum.install::install'); + } return $view; } diff --git a/framework/core/views/install/app.blade.php b/framework/core/views/install/app.blade.php index e1cc4369d..622763f53 100644 --- a/framework/core/views/install/app.blade.php +++ b/framework/core/views/install/app.blade.php @@ -128,6 +128,34 @@ -webkit-animation-name: fadeIn; animation-name: fadeIn; } + + .Errors { + margin-top: 50px; + } + .Errors .Error:first-child { + border-top-left-radius: 4px; + border-top-right-radius: 4px; + } + .Errors .Error:last-child { + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + } + .Error { + background: #EDF2F7; + margin: 0 0 1px; + padding: 20px 25px; + text-align: left; + } + .Error-message { + font-size: 16px; + color: #3C5675; + font-weight: normal; + margin: 0; + } + .Error-detail { + font-size: 13px; + margin: 5px 0 0; + } diff --git a/framework/core/views/install/errors.blade.php b/framework/core/views/install/errors.blade.php index 235a7b47e..3317fa3ff 100644 --- a/framework/core/views/install/errors.blade.php +++ b/framework/core/views/install/errors.blade.php @@ -1,12 +1,14 @@

Hold Up!

-

These errors must be resolved before you can continue the installation.

+

These errors must be resolved before you can continue the installation. If you're having trouble, get help on the Flarum website.

@foreach ($errors as $error)
-

{{ $error['message'] }}

-

{{ $error['detail'] }}

+

{!! $error['message'] !!}

+ @if (! empty($error['detail'])) +

{!! $error['detail'] !!}

+ @endif
@endforeach