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;
$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,
]);
}
'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',
<div class="card content-wrap auto-height">
<h1 class="list-heading">{{ $page->draft ? trans('entities.pages_delete_draft') : trans('entities.pages_delete') }}</h1>
+ @if ($times_used_as_template > 0)
+ <p>{{ trans_choice('entities.pages_delete_warning_template', $times_used_as_template) }}</p>
+ @endif
<div class="grid half v-center">
<div>