2016-01-08 16:01:21 +01:00
|
|
|
<?php
|
2016-05-20 12:27:31 +02:00
|
|
|
/**
|
|
|
|
* Controller.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-05-20 12:27:31 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:41:58 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-05-20 12:27:31 +02:00
|
|
|
*/
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2016-01-08 16:01:21 +01:00
|
|
|
namespace FireflyIII\Http\Controllers;
|
|
|
|
|
2018-08-09 17:46:14 +02:00
|
|
|
use FireflyIII\Support\Http\Controllers\RequestInformation;
|
2018-08-09 16:07:33 +02:00
|
|
|
use FireflyIII\Support\Http\Controllers\UserNavigation;
|
2016-01-08 16:01:21 +01:00
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
2015-06-13 10:02:36 +02:00
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
2015-02-06 04:39:52 +01:00
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
2015-02-11 07:35:10 +01:00
|
|
|
use Illuminate\Routing\Controller as BaseController;
|
2017-07-15 22:17:24 +02:00
|
|
|
use Route;
|
2015-02-06 04:39:52 +01:00
|
|
|
|
2015-02-11 07:35:10 +01:00
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class Controller.
|
2018-07-17 22:21:03 +02:00
|
|
|
*
|
|
|
|
* @SuppressWarnings(PHPMD.NumberOfChildren)
|
2015-02-11 07:35:10 +01:00
|
|
|
*/
|
2016-01-08 16:01:21 +01:00
|
|
|
class Controller extends BaseController
|
2015-02-11 07:35:10 +01:00
|
|
|
{
|
2018-08-09 17:46:14 +02:00
|
|
|
use AuthorizesRequests, DispatchesJobs, ValidatesRequests, UserNavigation, RequestInformation;
|
2015-05-14 13:41:21 +02:00
|
|
|
|
2018-07-22 08:10:16 +02:00
|
|
|
/** @var string Format for date and time. */
|
2016-03-01 21:31:25 +01:00
|
|
|
protected $dateTimeFormat;
|
2018-07-22 08:10:16 +02:00
|
|
|
/** @var string Format for "23 Feb, 2016". */
|
2016-01-09 07:48:45 +01:00
|
|
|
protected $monthAndDayFormat;
|
2018-07-22 08:10:16 +02:00
|
|
|
/** @var string Format for "March 2018" */
|
2016-01-24 15:58:16 +01:00
|
|
|
protected $monthFormat;
|
2018-07-22 08:10:16 +02:00
|
|
|
/** @var string Redirect user */
|
2017-09-29 16:53:09 +02:00
|
|
|
protected $redirectUri = '/';
|
2016-01-09 07:48:45 +01:00
|
|
|
|
2015-04-28 15:26:30 +02:00
|
|
|
/**
|
2016-01-08 16:01:21 +01:00
|
|
|
* Controller constructor.
|
2015-04-28 15:26:30 +02:00
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
2017-07-22 10:50:30 +02:00
|
|
|
// for transaction lists:
|
2018-07-14 16:08:34 +02:00
|
|
|
app('view')->share('hideBudgets', false);
|
|
|
|
app('view')->share('hideCategories', false);
|
|
|
|
app('view')->share('hideBills', false);
|
|
|
|
app('view')->share('hideTags', false);
|
2017-07-22 10:50:30 +02:00
|
|
|
|
|
|
|
// is site a demo site?
|
2019-02-13 17:38:41 +01:00
|
|
|
$isDemoSite = app('fireflyconfig')->get('is_demo_site', config('firefly.configuration.is_demo_site'))->data;
|
2018-07-14 16:08:34 +02:00
|
|
|
app('view')->share('IS_DEMO_SITE', $isDemoSite);
|
2018-12-15 07:59:02 +01:00
|
|
|
app('view')->share('DEMO_USERNAME', config('firefly.demo_username'));
|
|
|
|
app('view')->share('DEMO_PASSWORD', config('firefly.demo_password'));
|
2018-07-14 16:08:34 +02:00
|
|
|
app('view')->share('FF_VERSION', config('firefly.version'));
|
2016-10-29 07:44:46 +02:00
|
|
|
|
|
|
|
$this->middleware(
|
|
|
|
function ($request, $next) {
|
2017-07-22 10:50:30 +02:00
|
|
|
// translations for specific strings:
|
2016-10-29 07:44:46 +02:00
|
|
|
$this->monthFormat = (string)trans('config.month');
|
|
|
|
$this->monthAndDayFormat = (string)trans('config.month_and_day');
|
|
|
|
$this->dateTimeFormat = (string)trans('config.date_time');
|
|
|
|
|
2017-07-15 21:40:42 +02:00
|
|
|
// get shown-intro-preference:
|
2017-07-15 22:17:24 +02:00
|
|
|
if (auth()->check()) {
|
2018-07-17 22:21:03 +02:00
|
|
|
$language = $this->getLanguage();
|
|
|
|
$page = $this->getPageName();
|
|
|
|
$shownDemo = $this->hasSeenDemo();
|
2018-07-14 16:08:34 +02:00
|
|
|
app('view')->share('language', $language);
|
|
|
|
app('view')->share('shownDemo', $shownDemo);
|
|
|
|
app('view')->share('current_route_name', $page);
|
|
|
|
app('view')->share('original_route_name', Route::currentRouteName());
|
2017-07-15 22:17:24 +02:00
|
|
|
}
|
2017-07-15 21:40:42 +02:00
|
|
|
|
2016-10-29 07:44:46 +02:00
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
);
|
2015-04-28 15:26:30 +02:00
|
|
|
}
|
2015-12-31 17:20:54 +01:00
|
|
|
|
2015-02-06 04:39:52 +01:00
|
|
|
}
|