2015-08-27 01:40:18 +02:00
|
|
|
<?php
|
2015-08-26 16:18:58 +09:30
|
|
|
/*
|
|
|
|
* This file is part of Flarum.
|
|
|
|
*
|
|
|
|
* (c) Toby Zerner <toby.zerner@gmail.com>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Flarum\Install\Actions;
|
2015-08-17 14:12:02 +09:30
|
|
|
|
|
|
|
use Flarum\Support\HtmlAction;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
use Illuminate\Contracts\View\Factory;
|
|
|
|
|
|
|
|
class IndexAction extends HtmlAction
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var Factory
|
|
|
|
*/
|
|
|
|
protected $view;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Factory $view
|
|
|
|
*/
|
|
|
|
public function __construct(Factory $view)
|
|
|
|
{
|
|
|
|
$this->view = $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Request $request
|
|
|
|
* @param array $routeParams
|
|
|
|
* @return \Psr\Http\Message\ResponseInterface|EmptyResponse
|
|
|
|
*/
|
|
|
|
public function render(Request $request, array $routeParams = [])
|
|
|
|
{
|
|
|
|
$view = $this->view->make('flarum.install::app');
|
|
|
|
|
|
|
|
$view->logo = $this->view->make('flarum.install::logo');
|
|
|
|
|
2015-08-27 20:11:06 +09:30
|
|
|
$errors = [];
|
|
|
|
|
|
|
|
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
|
|
|
|
$errors[] = [
|
|
|
|
'message' => '<strong>PHP 5.5+</strong> is required.',
|
|
|
|
'detail' => 'You are running version '.PHP_VERSION.'.'
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2015-08-27 20:37:20 +09:30
|
|
|
foreach (['mbstring', 'pdo_mysql', 'json', 'gd'] as $extension) {
|
2015-08-27 20:11:06 +09:30
|
|
|
if (! extension_loaded($extension)) {
|
|
|
|
$errors[] = [
|
|
|
|
'message' => 'The <strong>'.$extension.'</strong> 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');
|
|
|
|
}
|
2015-08-17 14:12:02 +09:30
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
}
|