diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index d11462dc02..09fe795a2d 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -46,8 +46,16 @@ class AccountController extends Controller public function __construct() { parent::__construct(); - View::share('mainTitleIcon', 'fa-credit-card'); - View::share('title', trans('firefly.accounts')); + + // translations: + $this->middleware( + function ($request, $next) { + View::share('mainTitleIcon', 'fa-credit-card'); + View::share('title', trans('firefly.accounts')); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/Admin/ConfigurationController.php b/app/Http/Controllers/Admin/ConfigurationController.php index 147dfe31c6..33753166d2 100644 --- a/app/Http/Controllers/Admin/ConfigurationController.php +++ b/app/Http/Controllers/Admin/ConfigurationController.php @@ -37,8 +37,15 @@ class ConfigurationController extends Controller { parent::__construct(); - View::share('title', strval(trans('firefly.administration'))); - View::share('mainTitleIcon', 'fa-hand-spock-o'); + + $this->middleware( + function ($request, $next) { + View::share('title', strval(trans('firefly.administration'))); + View::share('mainTitleIcon', 'fa-hand-spock-o'); + + return $next($request); + } + ); } diff --git a/app/Http/Controllers/AttachmentController.php b/app/Http/Controllers/AttachmentController.php index 05e71a9a8f..e68a40ad8b 100644 --- a/app/Http/Controllers/AttachmentController.php +++ b/app/Http/Controllers/AttachmentController.php @@ -42,8 +42,16 @@ class AttachmentController extends Controller public function __construct() { parent::__construct(); - View::share('mainTitleIcon', 'fa-paperclip'); - View::share('title', trans('firefly.attachments')); + + // translations: + $this->middleware( + function ($request, $next) { + View::share('mainTitleIcon', 'fa-paperclip'); + View::share('title', trans('firefly.attachments')); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index d6095d8360..31de91d724 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -38,8 +38,16 @@ class BillController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.bills')); - View::share('mainTitleIcon', 'fa-calendar-o'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.bills')); + View::share('mainTitleIcon', 'fa-calendar-o'); + + return $next($request); + } + ); } /** @@ -140,7 +148,7 @@ class BillController extends Controller // paid in this period? $bill->paidDates = $repository->getPaidDatesInRange($bill, $start, $end); - $bill->payDates = $repository->getPayDatesInRange($bill, $start, $end); + $bill->payDates = $repository->getPayDatesInRange($bill, $start, $end); $lastDate = clone $start; if ($bill->paidDates->count() >= $bill->payDates->count()) { $lastDate = $end; diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 439dfb6d8b..fdbe4bfe7d 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -47,9 +47,17 @@ class BudgetController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.budgets')); - View::share('mainTitleIcon', 'fa-tasks'); + View::share('hideBudgets', true); + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.budgets')); + View::share('mainTitleIcon', 'fa-tasks'); + + return $next($request); + } + ); } /** @@ -359,8 +367,8 @@ class BudgetController extends Controller */ public function store(BudgetFormRequest $request, BudgetRepositoryInterface $repository) { - $data = $request->getBudgetData(); - $budget = $repository->store($data); + $data = $request->getBudgetData(); + $budget = $repository->store($data); Session::flash('success', strval(trans('firefly.stored_new_budget', ['name' => e($budget->name)]))); Preferences::mark(); diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 342c581440..f80d3a16bc 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -43,8 +43,16 @@ class CategoryController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.categories')); - View::share('mainTitleIcon', 'fa-bar-chart'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.categories')); + View::share('mainTitleIcon', 'fa-bar-chart'); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index 6101c947f6..58917455dc 100755 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -46,10 +46,18 @@ class Controller extends BaseController View::share('hideBills', false); View::share('hideTags', false); - // save some formats: - $this->monthFormat = (string)trans('config.month'); - $this->monthAndDayFormat = (string)trans('config.month_and_day'); - $this->dateTimeFormat = (string)trans('config.date_time'); + + // translations: + + $this->middleware( + function ($request, $next) { + $this->monthFormat = (string)trans('config.month'); + $this->monthAndDayFormat = (string)trans('config.month_and_day'); + $this->dateTimeFormat = (string)trans('config.date_time'); + + return $next($request); + } + ); } diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index 1b3e817aa7..e1abc73e27 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -39,8 +39,16 @@ class CurrencyController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.currencies')); - View::share('mainTitleIcon', 'fa-usd'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.currencies')); + View::share('mainTitleIcon', 'fa-usd'); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/ExportController.php b/app/Http/Controllers/ExportController.php index f8c20bc747..7deaae0f59 100644 --- a/app/Http/Controllers/ExportController.php +++ b/app/Http/Controllers/ExportController.php @@ -41,8 +41,16 @@ class ExportController extends Controller public function __construct() { parent::__construct(); - View::share('mainTitleIcon', 'fa-file-archive-o'); - View::share('title', trans('firefly.export_data')); + + + $this->middleware( + function ($request, $next) { + View::share('mainTitleIcon', 'fa-file-archive-o'); + View::share('title', trans('firefly.export_data')); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 08a1153e5d..05f3daa755 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -26,7 +26,7 @@ use Log; use Preferences; use Route; use Session; - +use View; /** * Class HomeController @@ -41,6 +41,8 @@ class HomeController extends Controller public function __construct() { parent::__construct(); + View::share('title', 'Firefly III'); + View::share('mainTitleIcon', 'fa-fire'); } /** @@ -128,11 +130,9 @@ class HomeController extends Controller return redirect(route('new-user.index')); } - $title = 'Firefly'; - $subTitle = trans('firefly.welcomeBack'); - $mainTitleIcon = 'fa-fire'; - $transactions = []; - $frontPage = Preferences::get( + $subTitle = trans('firefly.welcomeBack'); + $transactions = []; + $frontPage = Preferences::get( 'frontPageAccounts', $repository->getAccountsByType([AccountType::DEFAULT, AccountType::ASSET])->pluck('id')->toArray() ); /** @var Carbon $start */ @@ -166,7 +166,7 @@ class HomeController extends Controller // these routes are not relevant for the help pages: $ignore = ['login', 'registe', 'logout', 'two-fac', 'lost-two', 'confirm', 'resend', 'do_confirm', 'testFla', 'json.', 'piggy-banks.add', 'piggy-banks.remove', 'preferences.', 'rules.rule.up', 'rules.rule.down', 'rules.rule-group.up', 'rules.rule-group.down', 'popup.report', - 'admin.users.domains.block-','import.json','help.' + 'admin.users.domains.block-', 'import.json', 'help.', ]; $routes = Route::getRoutes(); @@ -178,7 +178,7 @@ class HomeController extends Controller $methods = $route->getMethods(); if (!is_null($name) && strlen($name) > 0 && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) { - echo sprintf('touch %s.md', $name)."\n"; + echo sprintf('touch %s.md', $name) . "\n"; } } diff --git a/app/Http/Controllers/ImportController.php b/app/Http/Controllers/ImportController.php index 05047e0e81..bbf09436c2 100644 --- a/app/Http/Controllers/ImportController.php +++ b/app/Http/Controllers/ImportController.php @@ -41,8 +41,15 @@ class ImportController extends Controller public function __construct() { parent::__construct(); - View::share('mainTitleIcon', 'fa-archive'); - View::share('title', trans('firefly.import_data_full')); + + $this->middleware( + function ($request, $next) { + View::share('mainTitleIcon', 'fa-archive'); + View::share('title', trans('firefly.import_data_full')); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 1fe99c6918..870b8ac966 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -32,6 +32,13 @@ class NewUserController extends Controller public function __construct() { parent::__construct(); + + $this->middleware( + function ($request, $next) { + + return $next($request); + } + ); } diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 70c3ae8487..15c98f6e5e 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -45,8 +45,16 @@ class PiggyBankController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.piggyBanks')); - View::share('mainTitleIcon', 'fa-sort-amount-asc'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.piggyBanks')); + View::share('mainTitleIcon', 'fa-sort-amount-asc'); + + return $next($request); + } + ); } /** @@ -364,7 +372,7 @@ class PiggyBankController extends Controller */ public function store(PiggyBankFormRequest $request, PiggyBankRepositoryInterface $repository) { - $data = $request->getPiggyBankData(); + $data = $request->getPiggyBankData(); $piggyBank = $repository->store($data); Session::flash('success', strval(trans('firefly.stored_piggy_bank', ['name' => e($piggyBank->name)]))); @@ -390,7 +398,7 @@ class PiggyBankController extends Controller */ public function update(PiggyBankRepositoryInterface $repository, PiggyBankFormRequest $request, PiggyBank $piggyBank) { - $data = $request->getPiggyBankData(); + $data = $request->getPiggyBankData(); $piggyBank = $repository->update($piggyBank, $data); Session::flash('success', strval(trans('firefly.updated_piggy_bank', ['name' => e($piggyBank->name)]))); diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index ae371c7e98..a0ec6288b3 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -35,8 +35,16 @@ class PreferencesController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.preferences')); - View::share('mainTitleIcon', 'fa-gear'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.preferences')); + View::share('mainTitleIcon', 'fa-gear'); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 5d368c09f5..23c42d3c1e 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -36,8 +36,15 @@ class ProfileController extends Controller { parent::__construct(); - View::share('title', trans('firefly.profile')); - View::share('mainTitleIcon', 'fa-user'); + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.profile')); + View::share('mainTitleIcon', 'fa-user'); + + return $next($request); + } + ); } /** @@ -45,9 +52,11 @@ class ProfileController extends Controller */ public function changePassword() { - return view('profile.change-password')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.change_your_password'))->with( - 'mainTitleIcon', 'fa-user' - ); + $title = auth()->user()->email; + $subTitle = strval(trans('firefly.change_your_password')); + $subTitleIcon = 'fa-key'; + + return view('profile.change-password', compact('title', 'subTitle', 'subTitleIcon')); } /** @@ -55,9 +64,11 @@ class ProfileController extends Controller */ public function deleteAccount() { - return view('profile.delete-account')->with('title', auth()->user()->email)->with('subTitle', trans('firefly.delete_account'))->with( - 'mainTitleIcon', 'fa-user' - ); + $title = auth()->user()->email; + $subTitle = strval(trans('firefly.delete_account')); + $subTitleIcon = 'fa-trash'; + + return view('profile.delete-account', compact('title', 'subTitle', 'subTitleIcon')); } /** diff --git a/app/Http/Controllers/Report/AccountController.php b/app/Http/Controllers/Report/AccountController.php index 582ff0bf83..85da130558 100644 --- a/app/Http/Controllers/Report/AccountController.php +++ b/app/Http/Controllers/Report/AccountController.php @@ -53,6 +53,7 @@ class AccountController extends Controller $result = view('reports.partials.accounts', compact('accountReport'))->render(); $cache->store($result); + return $result; } } diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 3bdeaf7f44..ab3833555a 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -49,8 +49,18 @@ class ReportController extends Controller { parent::__construct(); - View::share('title', trans('firefly.reports')); - View::share('mainTitleIcon', 'fa-line-chart'); + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.reports')); + View::share('mainTitleIcon', 'fa-line-chart'); + + $this->helper = app(ReportHelperInterface::class); + $this->budgetHelper = app(BudgetReportHelperInterface::class); + + return $next($request); + } + ); } @@ -61,7 +71,7 @@ class ReportController extends Controller */ public function index(AccountRepositoryInterface $repository) { - $this->createRepositories(); + /** @var Carbon $start */ $start = clone session('first'); $months = $this->helper->listOfMonths($start); @@ -92,7 +102,6 @@ class ReportController extends Controller */ public function report(string $reportType, Carbon $start, Carbon $end, Collection $accounts) { - $this->createRepositories(); // throw an error if necessary. if ($end < $start) { throw new FireflyException('End date cannot be before start date, silly!'); @@ -200,15 +209,6 @@ class ReportController extends Controller return view('reports.audit.report', compact('start', 'end', 'reportType', 'accountIds', 'accounts', 'auditData', 'hideable', 'defaultShow')); } - /** - * - */ - private function createRepositories() - { - $this->helper = app(ReportHelperInterface::class); - $this->budgetHelper = app(BudgetReportHelperInterface::class); - } - /** * @param $reportType * @param Carbon $start diff --git a/app/Http/Controllers/RuleController.php b/app/Http/Controllers/RuleController.php index 4b0687a559..3f55f44e35 100644 --- a/app/Http/Controllers/RuleController.php +++ b/app/Http/Controllers/RuleController.php @@ -42,8 +42,16 @@ class RuleController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.rules')); - View::share('mainTitleIcon', 'fa-random'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.rules')); + View::share('mainTitleIcon', 'fa-random'); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/RuleGroupController.php b/app/Http/Controllers/RuleGroupController.php index af62ca2085..f1ab10422b 100644 --- a/app/Http/Controllers/RuleGroupController.php +++ b/app/Http/Controllers/RuleGroupController.php @@ -41,8 +41,16 @@ class RuleGroupController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.rules')); - View::share('mainTitleIcon', 'fa-random'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.rules')); + View::share('mainTitleIcon', 'fa-random'); + + return $next($request); + } + ); } /** @@ -204,8 +212,8 @@ class RuleGroupController extends Controller */ public function store(RuleGroupFormRequest $request, RuleGroupRepositoryInterface $repository) { - $data = $request->getRuleGroupData(); - $ruleGroup = $repository->store($data); + $data = $request->getRuleGroupData(); + $ruleGroup = $repository->store($data); Session::flash('success', strval(trans('firefly.created_new_rule_group', ['title' => $ruleGroup->title]))); Preferences::mark(); diff --git a/app/Http/Controllers/SearchController.php b/app/Http/Controllers/SearchController.php index 2066537371..bb602229d3 100644 --- a/app/Http/Controllers/SearchController.php +++ b/app/Http/Controllers/SearchController.php @@ -29,6 +29,13 @@ class SearchController extends Controller public function __construct() { parent::__construct(); + + $this->middleware( + function ($request, $next) { + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 8459a12af8..fc7013d41a 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -50,15 +50,22 @@ class TagController extends Controller public function __construct() { parent::__construct(); - View::share('title', 'Tags'); - View::share('mainTitleIcon', 'fa-tags'); View::share('hideTags', true); - $this->tagOptions = [ - 'nothing' => trans('firefly.regular_tag'), - 'balancingAct' => trans('firefly.balancing_act'), - 'advancePayment' => trans('firefly.advance_payment'), - ]; - View::share('tagOptions', $this->tagOptions); + + $this->middleware( + function ($request, $next) { + View::share('title', 'Tags'); + View::share('mainTitleIcon', 'fa-tags'); + $this->tagOptions = [ + 'nothing' => trans('firefly.regular_tag'), + 'balancingAct' => trans('firefly.balancing_act'), + 'advancePayment' => trans('firefly.advance_payment'), + ]; + View::share('tagOptions', $this->tagOptions); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 2d9140ce1d..f32e8df053 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -41,8 +41,16 @@ class MassController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.transactions')); - View::share('mainTitleIcon', 'fa-repeat'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.transactions')); + View::share('mainTitleIcon', 'fa-repeat'); + + return $next($request); + } + ); } /** diff --git a/app/Http/Controllers/Transaction/SingleController.php b/app/Http/Controllers/Transaction/SingleController.php index f6e9a4d22c..dc005002ad 100644 --- a/app/Http/Controllers/Transaction/SingleController.php +++ b/app/Http/Controllers/Transaction/SingleController.php @@ -59,8 +59,6 @@ class SingleController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.transactions')); - View::share('mainTitleIcon', 'fa-repeat'); $maxFileSize = Steam::phpBytes(ini_get('upload_max_filesize')); $maxPostSize = Steam::phpBytes(ini_get('post_max_size')); @@ -75,11 +73,13 @@ class SingleController extends Controller $this->piggyBanks = app(PiggyBankRepositoryInterface::class); $this->attachments = app(AttachmentHelperInterface::class); + View::share('title', trans('firefly.transactions')); + View::share('mainTitleIcon', 'fa-repeat'); + return $next($request); } ); - } /** diff --git a/app/Http/Controllers/Transaction/SplitController.php b/app/Http/Controllers/Transaction/SplitController.php index 2247c30fd3..d1f3504670 100644 --- a/app/Http/Controllers/Transaction/SplitController.php +++ b/app/Http/Controllers/Transaction/SplitController.php @@ -63,8 +63,7 @@ class SplitController extends Controller public function __construct() { parent::__construct(); - View::share('mainTitleIcon', 'fa-share-alt'); - View::share('title', trans('firefly.split-transactions')); + // some useful repositories: $this->middleware( @@ -74,6 +73,8 @@ class SplitController extends Controller $this->tasker = app(JournalTaskerInterface::class); $this->attachments = app(AttachmentHelperInterface::class); $this->currencies = app(CurrencyRepositoryInterface::class); + View::share('mainTitleIcon', 'fa-share-alt'); + View::share('title', trans('firefly.split-transactions')); return $next($request); } diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 8cd732a617..bd2a3d4c1e 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -35,8 +35,16 @@ class TransactionController extends Controller public function __construct() { parent::__construct(); - View::share('title', trans('firefly.transactions')); - View::share('mainTitleIcon', 'fa-repeat'); + + + $this->middleware( + function ($request, $next) { + View::share('title', trans('firefly.transactions')); + View::share('mainTitleIcon', 'fa-repeat'); + + return $next($request); + } + ); } diff --git a/resources/lang/en_US/firefly.php b/resources/lang/en_US/firefly.php index 961567281a..609d08c0a2 100644 --- a/resources/lang/en_US/firefly.php +++ b/resources/lang/en_US/firefly.php @@ -619,7 +619,6 @@ return [ 'more_info_help' => 'More information about these types of reports can be found in the help pages. Press the (?) icon in the top right corner.', 'report_included_accounts' => 'Included accounts', 'report_date_range' => 'Date range', - 'report_include_help' => 'In all cases, transfers to shared accounts count as expenses, and transfers from shared accounts count as income.', 'report_preset_ranges' => 'Pre-set ranges', 'shared' => 'Shared', 'fiscal_year' => 'Fiscal year', diff --git a/resources/views/layout/default.twig b/resources/views/layout/default.twig index 376add29e6..921138dd81 100644 --- a/resources/views/layout/default.twig +++ b/resources/views/layout/default.twig @@ -4,13 +4,12 @@ - Firefly - {% if title != "Firefly" %} - // {{ title }} + <title>Firefly III + {% if title != "Firefly III" %} + » {{ title }} {% endif %} - {% if subTitle %} - // {{ subTitle }} + » {{ subTitle }} {% endif %} diff --git a/resources/views/reports/index.twig b/resources/views/reports/index.twig index c895ca4a9c..0fe5cfbbc7 100644 --- a/resources/views/reports/index.twig +++ b/resources/views/reports/index.twig @@ -45,9 +45,6 @@ {% endfor %} -

- {{ 'report_include_help'|_ }} -