Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Add "from" URL to various links, see if I can't improve redirections.
James Cole19542974d730
diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.phpindex 864bd12e60..7339838641 100644--- a/app/Exceptions/GracefulNotFoundHandler.php+++ b/app/Exceptions/GracefulNotFoundHandler.php@@ -260,8 +260,10 @@ class GracefulNotFoundHandler extends ExceptionHandler$request->session()->reflash();if (TransactionTypeEnum::RECONCILIATION->value === $type) {+ session()->flash('info', trans('errors.note_not_found_reconciliation', ['description' => $group->title ?? $journal->description]));return redirect(route('accounts.index', ['asset']));}+ session()->flash('info', trans('errors.note_not_found_group', ['description' => $group->title ?? $journal->description]));return redirect(route('transactions.index', [strtolower((string) $type)]));}diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.phpindex cf55743477..70c7411ed4 100644--- a/app/Http/Controllers/Controller.php+++ b/app/Http/Controllers/Controller.php@@ -39,8 +39,8 @@ use Illuminate\Routing\Controller as BaseController;use Illuminate\Support\Facades\Config;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Route;+use Illuminate\Support\Facades\URL;use Illuminate\Support\Facades\View;-use function Safe\ini_get;use function Safe\realpath;@@ -59,13 +59,13 @@ abstract class Controller extends BaseControlleruse ValidatesRequests;// fails on PHP < 8.4- public protected(set) string $name;- protected bool $convertToPrimary = false;- protected string $dateTimeFormat;+ public protected(set) string $name;+ protected bool $convertToPrimary = false;+ protected string $dateTimeFormat;protected ?TransactionCurrency $primaryCurrency;- protected string $monthAndDayFormat;- protected string $monthFormat;- protected string $redirectUrl = '/';+ protected string $monthAndDayFormat;+ protected string $monthFormat;+ protected string $redirectUrl = '/';/*** Controller constructor.@@ -81,20 +81,20 @@ abstract class Controller extends BaseControllerreturn;}- $isDemoSite = (bool) $isDemoSiteConfig->data;+ $isDemoSite = (bool)$isDemoSiteConfig->data;View::share('IS_DEMO_SITE', $isDemoSite);View::share('DEMO_USERNAME', config('firefly.demo_username'));View::share('DEMO_PASSWORD', config('firefly.demo_password'));View::share('FF_VERSION', config('firefly.version'));View::share('FF_BUILD_TIME', config('firefly.build_time'));-+ View::share('FF3_FROM', urlencode($this->getFromUrl()));// this breaks when running < PHP 8.5 and is totally intentional.- $input = ' James is cool';- $output = $input- |> trim(...)- |> (fn (string $string) => str_replace(' ', '-', $string))- |> (fn (string $string) => str_replace(['.', '/', '…'], '', $string))- |> strtolower(...);+ $input = ' James is cool';+ $output = $input+ |> trim(...)+ |> (fn(string $string) => str_replace(' ', '-', $string))+ |> (fn(string $string) => str_replace(['.', '/', '…'], '', $string))+ |> strtolower(...);// is webhooks enabled?View::share(@@ -105,8 +105,8 @@ abstract class Controller extends BaseControllerView::share('featuringCer', true === AppConfiguration::get('enable_exchange_rates', config('cer.enabled'))->data);// share custom auth guard info.- $authGuard = config('firefly.authentication_guard');- $logoutUrl = config('firefly.custom_logout_url');+ $authGuard = config('firefly.authentication_guard');+ $logoutUrl = config('firefly.custom_logout_url');// overrule v2 layout back to v1.@@ -126,17 +126,17 @@ abstract class Controller extends BaseControllerView::share('uploadSize', $uploadSize);// share is alpha, is beta- $isAlpha = false;- $isBeta = false;- $isDevelop = false;- if (str_contains((string) config('firefly.version'), 'alpha')) {+ $isAlpha = false;+ $isBeta = false;+ $isDevelop = false;+ if (str_contains((string)config('firefly.version'), 'alpha')) {$isAlpha = true;}- if (str_contains((string) config('firefly.version'), 'develop') || str_contains((string) config('firefly.version'), 'branch')) {+ if (str_contains((string)config('firefly.version'), 'develop') || str_contains((string)config('firefly.version'), 'branch')) {$isDevelop = true;}- if (str_contains((string) config('firefly.version'), 'beta')) {+ if (str_contains((string)config('firefly.version'), 'beta')) {$isBeta = true;}@@ -145,11 +145,11 @@ abstract class Controller extends BaseControllerView::share('FF_IS_DEVELOP', $isDevelop);$this->middleware(function ($request, $next): mixed {- $locale = Steam::getLocale();+ $locale = Steam::getLocale();// translations for specific strings:- $this->monthFormat = (string) trans('config.month_js', [], $locale);- $this->monthAndDayFormat = (string) trans('config.month_and_day_js', [], $locale);- $this->dateTimeFormat = (string) trans('config.date_time_js', [], $locale);+ $this->monthFormat = (string)trans('config.month_js', [], $locale);+ $this->monthAndDayFormat = (string)trans('config.month_and_day_js', [], $locale);+ $this->dateTimeFormat = (string)trans('config.date_time_js', [], $locale);$darkMode = 'browser';$this->primaryCurrency = null;// get shown-intro-preference:@@ -182,4 +182,20 @@ abstract class Controller extends BaseControllerreturn $next($request);});}++ private function getFromUrl(): string+ {+ $current = parse_url(URL::full());+ $from = '';+ if (array_key_exists('path', $current)) {+ $from = $current['path'];+ }+ if (array_key_exists('query', $current) && strlen($current['query']) > 0) {+ $from .= '?' . $current['query'];+ }+ if (array_key_exists('fragment', $current) && strlen($current['fragment']) > 0) {+ $from .= '#' . $current['fragment'];+ }+ return $from;+ }}diff --git a/resources/lang/en_US/errors.php b/resources/lang/en_US/errors.phpindex c761e37705..1590aba79d 100644--- a/resources/lang/en_US/errors.php+++ b/resources/lang/en_US/errors.php@@ -29,6 +29,9 @@ return ['404_github_link' => 'If you are sure this page should exist, please open a ticket on <strong><a href="https://github.com/firefly-iii/firefly-iii/issues">GitHub</a></strong>.','whoops' => 'Whoops','note_not_found_account' => 'Account ":name" has been deleted and can no longer be viewed. Please enjoy this overview of all other accounts of the same type.',+ 'note_not_found_group' => 'Transaction ":description" has been deleted and can no longer be viewed. Please enjoy this overview of all other transactions of the same type.',+ 'note_not_found_reconciliation' => 'Reconciliation ":description" has been deleted and can no longer be viewed. Here is an overview of the account it belonged to.',+'fatal_error' => 'There was a fatal error. Please check the log files in "storage/logs" or use "docker logs -f [container]" to see what\'s going on.','maintenance_mode' => 'Firefly III is in maintenance mode.','be_right_back' => 'Be right back!',diff --git a/resources/views/components/layout/create-menu.blade.php b/resources/views/components/layout/create-menu.blade.phpindex 43cae3fcde..5fdeb80340 100644--- a/resources/views/components/layout/create-menu.blade.php+++ b/resources/views/components/layout/create-menu.blade.php@@ -4,7 +4,10 @@<em class="bi bi-plus-circle"></em></a><div class="dropdown-menu dropdown-menu-lg dropdown-menu-end">- <a href="{{ route('transactions.create', ['withdrawal']) }}" class="dropdown-item">++++ <a href="{{ route('transactions.create', ['withdrawal']) }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -16,7 +19,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('transactions.create', ['deposit']) }}" class="dropdown-item">+ <a href="{{ route('transactions.create', ['deposit']) }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -28,7 +31,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('transactions.create', ['transfer']) }}" class="dropdown-item">+ <a href="{{ route('transactions.create', ['transfer']) }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -41,7 +44,7 @@</a><div class="dropdown-divider"></div>- <a href="{{ route('accounts.create', ['asset']) }}" class="dropdown-item">+ <a href="{{ route('accounts.create', ['asset']) }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -53,7 +56,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('accounts.create', ['liabilities']) }}" class="dropdown-item">+ <a href="{{ route('accounts.create', ['liabilities']) }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -66,7 +69,7 @@</a><div class="dropdown-divider"></div>- <a href="{{ route('budgets.create') }}" class="dropdown-item">+ <a href="{{ route('budgets.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -78,7 +81,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('categories.create') }}" class="dropdown-item">+ <a href="{{ route('categories.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -90,7 +93,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('piggy-banks.create') }}" class="dropdown-item">+ <a href="{{ route('piggy-banks.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -102,7 +105,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('subscriptions.create') }}" class="dropdown-item">+ <a href="{{ route('subscriptions.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -114,7 +117,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('rules.create') }}" class="dropdown-item">+ <a href="{{ route('rules.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -126,7 +129,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('recurring.create') }}" class="dropdown-item">+ <a href="{{ route('recurring.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">@@ -138,7 +141,7 @@</div></a><div class="dropdown-divider"></div>- <a href="{{ route('webhooks.create') }}" class="dropdown-item">+ <a href="{{ route('webhooks.create') }}?_from={{ $FF3_FROM }}" class="dropdown-item"><div class="d-flex"><div class="grow"><h3 class="dropdown-item-title">