From 0245e8ae0e710531abff0390ba3713e0f1fed900 Mon Sep 17 00:00:00 2001 From: Giuseppe Criscione <18699708+giuscris@users.noreply.github.com> Date: Sat, 27 Apr 2024 12:45:38 +0200 Subject: [PATCH] Avoid failing when there are no backups --- .../src/Panel/Controllers/ToolsController.php | 3 +- formwork/translations/de.yaml | 1 + formwork/translations/en.yaml | 1 + formwork/translations/es.yaml | 1 + formwork/translations/fr.yaml | 1 + formwork/translations/it.yaml | 1 + formwork/translations/pt.yaml | 1 + formwork/translations/ru.yaml | 1 + panel/views/tools/backups.php | 55 ++++++++++--------- 9 files changed, 37 insertions(+), 28 deletions(-) diff --git a/formwork/src/Panel/Controllers/ToolsController.php b/formwork/src/Panel/Controllers/ToolsController.php index 48cb977a..1fe706a0 100644 --- a/formwork/src/Panel/Controllers/ToolsController.php +++ b/formwork/src/Panel/Controllers/ToolsController.php @@ -3,6 +3,7 @@ namespace Formwork\Panel\Controllers; use Formwork\Backupper; +use Formwork\Data\Collection; use Formwork\Http\Response; use Formwork\Router\RouteParams; use Formwork\Utils\Arr; @@ -50,7 +51,7 @@ class ToolsController extends AbstractController 'tabs' => $this->tabs, 'current' => 'backups', ]), - 'backups' => array_values($backups), + 'backups' => Collection::from($backups), ])); } diff --git a/formwork/translations/de.yaml b/formwork/translations/de.yaml index 7991547f..47a3818f 100644 --- a/formwork/translations/de.yaml +++ b/formwork/translations/de.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['Woche', 'Wochen'] date.duration.years: ['Jahr', 'Jahre'] date.months.long: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'] date.months.short: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'] +date.never: nie date.now: jetzt date.today: Heute date.weekdays.long: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'] diff --git a/formwork/translations/en.yaml b/formwork/translations/en.yaml index a42df9b1..d884ad82 100644 --- a/formwork/translations/en.yaml +++ b/formwork/translations/en.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['week', 'weeks'] date.duration.years: ['year', 'years'] date.months.long: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] date.months.short: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] +date.never: never date.now: now date.today: Today date.weekdays.long: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] diff --git a/formwork/translations/es.yaml b/formwork/translations/es.yaml index 13954bf6..a2a849c3 100644 --- a/formwork/translations/es.yaml +++ b/formwork/translations/es.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['semana', 'semanas'] date.duration.years: ['año', 'años'] date.months.long: ['Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'] date.months.short: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'] +date.never: nunca date.now: ahora date.today: Hoy date.weekdays.long: ['Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'] diff --git a/formwork/translations/fr.yaml b/formwork/translations/fr.yaml index 8c243b78..a9e5e43e 100644 --- a/formwork/translations/fr.yaml +++ b/formwork/translations/fr.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['semaine', 'semaines'] date.duration.years: ['an', 'ans'] date.months.long: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'] date.months.short: ['Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Jun', 'Juil', 'Aou', 'Sep', 'Oct', 'Nov', 'Déc'] +date.never: jamais date.now: maintenant date.today: Aujourd’hui date.weekdays.long: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'] diff --git a/formwork/translations/it.yaml b/formwork/translations/it.yaml index 944b8ddf..d9f62710 100644 --- a/formwork/translations/it.yaml +++ b/formwork/translations/it.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['settimana', 'settimane'] date.duration.years: ['anno', 'anni'] date.months.long: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'] date.months.short: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'] +date.never: mai date.now: adesso date.today: Oggi date.weekdays.long: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'] diff --git a/formwork/translations/pt.yaml b/formwork/translations/pt.yaml index c51da545..bcd31b12 100644 --- a/formwork/translations/pt.yaml +++ b/formwork/translations/pt.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['semana', 'semanas'] date.duration.years: ['ano', 'anos'] date.months.long: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'] date.months.short: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'] +date.never: nunca date.now: agora date.today: Hoje date.weekdays.long: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'] diff --git a/formwork/translations/ru.yaml b/formwork/translations/ru.yaml index 22facb3a..e6891835 100644 --- a/formwork/translations/ru.yaml +++ b/formwork/translations/ru.yaml @@ -9,6 +9,7 @@ date.duration.weeks: ['неделя', 'нед'] date.duration.years: ['год', 'г'] date.months.long: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октября', 'Ноябрь', 'Декабрь'] date.months.short: ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'] +date.never: никогда date.now: теперь date.today: Сегодня date.weekdays.long: ['Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'] diff --git a/panel/views/tools/backups.php b/panel/views/tools/backups.php index be3297de..2de4982c 100644 --- a/panel/views/tools/backups.php +++ b/panel/views/tools/backups.php @@ -8,36 +8,37 @@
-

translate('panel.tools.latestBackup') ?> timedistance($backups[0]['timestamp']) ?>

+

translate('panel.tools.latestBackup') ?> isEmpty() ? $this->translate('date.never') : $this->timedistance($backups->first()['timestamp']) ?>

- -
-
-
translate('panel.tools.latestBackups') ?>
-
- - - - - - - - - - - + isEmpty()) : ?> +
+
+
translate('panel.tools.latestBackups') ?>
+
+
translate('panel.tools.backup.file') ?>translate('panel.tools.backup.date') ?>translate('panel.tools.backup.size') ?>translate('panel.tools.backup.actions') ?>
+ - - - - + + + + - - -
icon('file-archive') ?> datetime($backup['timestamp']) ?> - - translate('panel.tools.backup.file') ?>translate('panel.tools.backup.date') ?>translate('panel.tools.backup.size') ?>translate('panel.tools.backup.actions') ?>
-
+ + + + + icon('file-archive') ?> + datetime($backup['timestamp']) ?> + + + + + + + + + +