diff --git a/modules/backend/classes/BackendController.php b/modules/backend/classes/BackendController.php index 04e2420a8..25ea66815 100644 --- a/modules/backend/classes/BackendController.php +++ b/modules/backend/classes/BackendController.php @@ -3,6 +3,9 @@ use Str; use App; use File; +use View; +use Config; +use Response; use Illuminate\Routing\Controller as ControllerBase; use October\Rain\Router\Helper as RouterHelper; use Closure; @@ -61,6 +64,15 @@ class BackendController extends ControllerBase { $params = RouterHelper::segmentizeUrl($url); + /* + * Database check + */ + if (!App::hasDatabase()) { + return Config::get('app.debug', false) + ? Response::make(View::make('backend::no_database'), 200) + : App::make('Cms\Classes\Controller')->run($url); + } + /* * Look for a Module controller */ diff --git a/modules/backend/controllers/Index.php b/modules/backend/controllers/Index.php index 4b449c56d..c04b9f5fa 100644 --- a/modules/backend/controllers/Index.php +++ b/modules/backend/controllers/Index.php @@ -32,10 +32,6 @@ class Index extends Controller BackendMenu::setContextOwner('October.Backend'); $this->addCss('/modules/backend/assets/css/dashboard/dashboard.css', 'core'); - - if (BackendAuth::check()) { - new ReportContainer($this, 'config_dashboard.yaml'); - } } public function index() @@ -44,15 +40,30 @@ class Index extends Controller return $redirect; } + $this->initReportContainer(); + $this->pageTitle = 'backend::lang.dashboard.menu_label'; + BackendMenu::setContextMainMenu('dashboard'); } public function index_onInitReportContainer() { + $this->initReportContainer(); + return ['#dashReportContainer' => $this->widget->reportContainer->render()]; } + /** + * Prepare the report widget used by the dashboard + * @param Model $model + * @return void + */ + protected function initReportContainer() + { + new ReportContainer($this, 'config_dashboard.yaml'); + } + /** * Custom permissions check that will redirect to the next * available menu item, if permission to this page is denied. diff --git a/modules/backend/lang/en/lang.php b/modules/backend/lang/en/lang.php index f8a3ac5c0..8874ebc36 100644 --- a/modules/backend/lang/en/lang.php +++ b/modules/backend/lang/en/lang.php @@ -19,6 +19,11 @@ return [ 'help' => "You don't have the required permissions to view this page.", 'cms_link' => 'Return to the back-end' ], + 'no_database' => [ + 'label' => 'Database missing', + 'help' => "A database is required to access the back-end. Check the database is configured and migrated before trying again.", + 'cms_link' => 'Return to the homepage' + ], 'invalid_token' => [ 'label' => 'Invalid security token' ] diff --git a/modules/backend/views/access_denied.php b/modules/backend/views/access_denied.php index fa1fbfd15..07b386ab4 100644 --- a/modules/backend/views/access_denied.php +++ b/modules/backend/views/access_denied.php @@ -12,4 +12,4 @@ - \ No newline at end of file + diff --git a/modules/backend/views/no_database.php b/modules/backend/views/no_database.php new file mode 100644 index 000000000..f23f84390 --- /dev/null +++ b/modules/backend/views/no_database.php @@ -0,0 +1,15 @@ + + + + + <?= Lang::get('backend::lang.page.no_database.label') ?> + + + +
+

+

+ +
+ +