diff --git a/app/Http/Controllers/PageController.php b/app/Http/Controllers/PageController.php index 394147ce2..8b131c4f3 100644 --- a/app/Http/Controllers/PageController.php +++ b/app/Http/Controllers/PageController.php @@ -3,6 +3,7 @@ namespace BookStack\Http\Controllers; use BookStack\Actions\View; +use BookStack\Entities\Models\Book; use BookStack\Entities\Models\Page; use BookStack\Entities\Repos\PageRepo; use BookStack\Entities\Tools\BookContents; @@ -265,11 +266,13 @@ class PageController extends Controller $page = $this->pageRepo->getBySlug($bookSlug, $pageSlug); $this->checkOwnablePermission('page-delete', $page); $this->setPageTitle(trans('entities.pages_delete_named', ['pageName' => $page->getShortName()])); + $times_used_as_template = Book::where('default_template', '=', $page->id)->count(); return view('pages.delete', [ 'book' => $page->book, 'page' => $page, 'current' => $page, + 'times_used_as_template' => $times_used_as_template, ]); } diff --git a/resources/lang/en/entities.php b/resources/lang/en/entities.php index 38c2f2ae3..4af6120f8 100644 --- a/resources/lang/en/entities.php +++ b/resources/lang/en/entities.php @@ -192,6 +192,7 @@ return [ 'pages_delete_draft' => 'Delete Draft Page', 'pages_delete_success' => 'Page deleted', 'pages_delete_draft_success' => 'Draft page deleted', + 'pages_delete_warning_template' => '{0}|{1}Be careful: this page is used as a template for :count book.|[2,*]Be careful: this page is used as a template for :count books.', 'pages_delete_confirm' => 'Are you sure you want to delete this page?', 'pages_delete_draft_confirm' => 'Are you sure you want to delete this draft page?', 'pages_editing_named' => 'Editing Page :pageName', diff --git a/resources/views/pages/delete.blade.php b/resources/views/pages/delete.blade.php index 39cd07bbb..9ce50d48b 100644 --- a/resources/views/pages/delete.blade.php +++ b/resources/views/pages/delete.blade.php @@ -19,6 +19,9 @@
{{ trans_choice('entities.pages_delete_warning_template', $times_used_as_template) }}
+ @endif