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