]> BookStack Code Mirror - bookstack/blob - app/Http/Controllers/PageController.php
Added a success message on deletion of revision.
[bookstack] / app / Http / Controllers / PageController.php
1 <?php namespace BookStack\Http\Controllers;
2
3 use Activity;
4 use BookStack\Exceptions\NotFoundException;
5 use BookStack\Exceptions\BadRequestException;
6 use BookStack\Repos\EntityRepo;
7 use BookStack\Repos\UserRepo;
8 use BookStack\Services\ExportService;
9 use Illuminate\Http\Request;
10 use Illuminate\Http\Response;
11 use Views;
12 use GatherContent\Htmldiff\Htmldiff;
13
14 class PageController extends Controller
15 {
16
17     protected $entityRepo;
18     protected $exportService;
19     protected $userRepo;
20
21     /**
22      * PageController constructor.
23      * @param EntityRepo $entityRepo
24      * @param ExportService $exportService
25      * @param UserRepo $userRepo
26      */
27     public function __construct(EntityRepo $entityRepo, ExportService $exportService, UserRepo $userRepo)
28     {
29         $this->entityRepo = $entityRepo;
30         $this->exportService = $exportService;
31         $this->userRepo = $userRepo;
32         parent::__construct();
33     }
34
35     /**
36      * Show the form for creating a new page.
37      * @param string $bookSlug
38      * @param string $chapterSlug
39      * @return Response
40      * @internal param bool $pageSlug
41      * @throws NotFoundException
42      */
43     public function create($bookSlug, $chapterSlug = null)
44     {
45         if ($chapterSlug !== null) {
46             $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
47             $book = $chapter->book;
48         } else {
49             $chapter = null;
50             $book = $this->entityRepo->getBySlug('book', $bookSlug);
51         }
52
53         $parent = $chapter ? $chapter : $book;
54         $this->checkOwnablePermission('page-create', $parent);
55
56         // Redirect to draft edit screen if signed in
57         if ($this->signedIn) {
58             $draft = $this->entityRepo->getDraftPage($book, $chapter);
59             return redirect($draft->getUrl());
60         }
61
62         // Otherwise show the edit view if they're a guest
63         $this->setPageTitle(trans('entities.pages_new'));
64         return view('pages/guest-create', ['parent' => $parent]);
65     }
66
67     /**
68      * Create a new page as a guest user.
69      * @param Request $request
70      * @param string $bookSlug
71      * @param string|null $chapterSlug
72      * @return mixed
73      * @throws NotFoundException
74      */
75     public function createAsGuest(Request $request, $bookSlug, $chapterSlug = null)
76     {
77         $this->validate($request, [
78             'name' => 'required|string|max:255'
79         ]);
80
81         if ($chapterSlug !== null) {
82             $chapter = $this->entityRepo->getBySlug('chapter', $chapterSlug, $bookSlug);
83             $book = $chapter->book;
84         } else {
85             $chapter = null;
86             $book = $this->entityRepo->getBySlug('book', $bookSlug);
87         }
88
89         $parent = $chapter ? $chapter : $book;
90         $this->checkOwnablePermission('page-create', $parent);
91
92         $page = $this->entityRepo->getDraftPage($book, $chapter);
93         $this->entityRepo->publishPageDraft($page, [
94             'name' => $request->get('name'),
95             'html' => ''
96         ]);
97         return redirect($page->getUrl('/edit'));
98     }
99
100     /**
101      * Show form to continue editing a draft page.
102      * @param string $bookSlug
103      * @param int $pageId
104      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
105      */
106     public function editDraft($bookSlug, $pageId)
107     {
108         $draft = $this->entityRepo->getById('page', $pageId, true);
109         $this->checkOwnablePermission('page-create', $draft->parent);
110         $this->setPageTitle(trans('entities.pages_edit_draft'));
111
112         $draftsEnabled = $this->signedIn;
113         return view('pages/edit', [
114             'page' => $draft,
115             'book' => $draft->book,
116             'isDraft' => true,
117             'draftsEnabled' => $draftsEnabled
118         ]);
119     }
120
121     /**
122      * Store a new page by changing a draft into a page.
123      * @param  Request $request
124      * @param  string $bookSlug
125      * @param  int $pageId
126      * @return Response
127      */
128     public function store(Request $request, $bookSlug, $pageId)
129     {
130         $this->validate($request, [
131             'name' => 'required|string|max:255'
132         ]);
133
134         $input = $request->all();
135         $draftPage = $this->entityRepo->getById('page', $pageId, true);
136         $book = $draftPage->book;
137
138         $parent = $draftPage->parent;
139         $this->checkOwnablePermission('page-create', $parent);
140
141         if ($parent->isA('chapter')) {
142             $input['priority'] = $this->entityRepo->getNewChapterPriority($parent);
143         } else {
144             $input['priority'] = $this->entityRepo->getNewBookPriority($parent);
145         }
146
147         $page = $this->entityRepo->publishPageDraft($draftPage, $input);
148
149         Activity::add($page, 'page_create', $book->id);
150         return redirect($page->getUrl());
151     }
152
153     /**
154      * Display the specified page.
155      * If the page is not found via the slug the revisions are searched for a match.
156      * @param string $bookSlug
157      * @param string $pageSlug
158      * @return Response
159      * @throws NotFoundException
160      */
161     public function show($bookSlug, $pageSlug)
162     {
163         try {
164             $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
165         } catch (NotFoundException $e) {
166             $page = $this->entityRepo->getPageByOldSlug($pageSlug, $bookSlug);
167             if ($page === null) {
168                 throw $e;
169             }
170             return redirect($page->getUrl());
171         }
172
173         $this->checkOwnablePermission('page-view', $page);
174
175         $page->html = $this->entityRepo->renderPage($page);
176         $sidebarTree = $this->entityRepo->getBookChildren($page->book);
177         $pageNav = $this->entityRepo->getPageNav($page->html);
178
179         // check if the comment's are enabled
180         $commentsEnabled = !setting('app-disable-comments');
181         if ($commentsEnabled) {
182             $page->load(['comments.createdBy']);
183         }
184
185         Views::add($page);
186         $this->setPageTitle($page->getShortName());
187         return view('pages/show', [
188             'page' => $page,'book' => $page->book,
189             'current' => $page,
190             'sidebarTree' => $sidebarTree,
191             'commentsEnabled' => $commentsEnabled,
192             'pageNav' => $pageNav
193         ]);
194     }
195
196     /**
197      * Get page from an ajax request.
198      * @param int $pageId
199      * @return \Illuminate\Http\JsonResponse
200      */
201     public function getPageAjax($pageId)
202     {
203         $page = $this->entityRepo->getById('page', $pageId);
204         return response()->json($page);
205     }
206
207     /**
208      * Show the form for editing the specified page.
209      * @param string $bookSlug
210      * @param string $pageSlug
211      * @return Response
212      */
213     public function edit($bookSlug, $pageSlug)
214     {
215         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
216         $this->checkOwnablePermission('page-update', $page);
217         $this->setPageTitle(trans('entities.pages_editing_named', ['pageName'=>$page->getShortName()]));
218         $page->isDraft = false;
219
220         // Check for active editing
221         $warnings = [];
222         if ($this->entityRepo->isPageEditingActive($page, 60)) {
223             $warnings[] = $this->entityRepo->getPageEditingActiveMessage($page, 60);
224         }
225
226         // Check for a current draft version for this user
227         if ($this->entityRepo->hasUserGotPageDraft($page, $this->currentUser->id)) {
228             $draft = $this->entityRepo->getUserPageDraft($page, $this->currentUser->id);
229             $page->name = $draft->name;
230             $page->html = $draft->html;
231             $page->markdown = $draft->markdown;
232             $page->isDraft = true;
233             $warnings [] = $this->entityRepo->getUserPageDraftMessage($draft);
234         }
235
236         if (count($warnings) > 0) {
237             session()->flash('warning', implode("\n", $warnings));
238         }
239
240         $draftsEnabled = $this->signedIn;
241         return view('pages/edit', [
242             'page' => $page,
243             'book' => $page->book,
244             'current' => $page,
245             'draftsEnabled' => $draftsEnabled
246         ]);
247     }
248
249     /**
250      * Update the specified page in storage.
251      * @param  Request $request
252      * @param  string $bookSlug
253      * @param  string $pageSlug
254      * @return Response
255      */
256     public function update(Request $request, $bookSlug, $pageSlug)
257     {
258         $this->validate($request, [
259             'name' => 'required|string|max:255'
260         ]);
261         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
262         $this->checkOwnablePermission('page-update', $page);
263         $this->entityRepo->updatePage($page, $page->book->id, $request->all());
264         Activity::add($page, 'page_update', $page->book->id);
265         return redirect($page->getUrl());
266     }
267
268     /**
269      * Save a draft update as a revision.
270      * @param Request $request
271      * @param int $pageId
272      * @return \Illuminate\Http\JsonResponse
273      */
274     public function saveDraft(Request $request, $pageId)
275     {
276         $page = $this->entityRepo->getById('page', $pageId, true);
277         $this->checkOwnablePermission('page-update', $page);
278
279         if (!$this->signedIn) {
280             return response()->json([
281                 'status' => 'error',
282                 'message' => trans('errors.guests_cannot_save_drafts'),
283             ], 500);
284         }
285
286         $draft = $this->entityRepo->updatePageDraft($page, $request->only(['name', 'html', 'markdown']));
287
288         $updateTime = $draft->updated_at->timestamp;
289         return response()->json([
290             'status'    => 'success',
291             'message'   => trans('entities.pages_edit_draft_save_at'),
292             'timestamp' => $updateTime
293         ]);
294     }
295
296     /**
297      * Redirect from a special link url which
298      * uses the page id rather than the name.
299      * @param int $pageId
300      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
301      */
302     public function redirectFromLink($pageId)
303     {
304         $page = $this->entityRepo->getById('page', $pageId);
305         return redirect($page->getUrl());
306     }
307
308     /**
309      * Show the deletion page for the specified page.
310      * @param string $bookSlug
311      * @param string $pageSlug
312      * @return \Illuminate\View\View
313      */
314     public function showDelete($bookSlug, $pageSlug)
315     {
316         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
317         $this->checkOwnablePermission('page-delete', $page);
318         $this->setPageTitle(trans('entities.pages_delete_named', ['pageName'=>$page->getShortName()]));
319         return view('pages/delete', ['book' => $page->book, 'page' => $page, 'current' => $page]);
320     }
321
322
323     /**
324      * Show the deletion page for the specified page.
325      * @param string $bookSlug
326      * @param int $pageId
327      * @return \Illuminate\View\View
328      * @throws NotFoundException
329      */
330     public function showDeleteDraft($bookSlug, $pageId)
331     {
332         $page = $this->entityRepo->getById('page', $pageId, true);
333         $this->checkOwnablePermission('page-update', $page);
334         $this->setPageTitle(trans('entities.pages_delete_draft_named', ['pageName'=>$page->getShortName()]));
335         return view('pages/delete', ['book' => $page->book, 'page' => $page, 'current' => $page]);
336     }
337
338     /**
339      * Remove the specified page from storage.
340      * @param string $bookSlug
341      * @param string $pageSlug
342      * @return Response
343      * @internal param int $id
344      */
345     public function destroy($bookSlug, $pageSlug)
346     {
347         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
348         $book = $page->book;
349         $this->checkOwnablePermission('page-delete', $page);
350         $this->entityRepo->destroyPage($page);
351
352         Activity::addMessage('page_delete', $book->id, $page->name);
353         session()->flash('success', trans('entities.pages_delete_success'));
354         return redirect($book->getUrl());
355     }
356
357     /**
358      * Remove the specified draft page from storage.
359      * @param string $bookSlug
360      * @param int $pageId
361      * @return Response
362      * @throws NotFoundException
363      */
364     public function destroyDraft($bookSlug, $pageId)
365     {
366         $page = $this->entityRepo->getById('page', $pageId, true);
367         $book = $page->book;
368         $this->checkOwnablePermission('page-update', $page);
369         session()->flash('success', trans('entities.pages_delete_draft_success'));
370         $this->entityRepo->destroyPage($page);
371         return redirect($book->getUrl());
372     }
373
374     /**
375      * Shows the last revisions for this page.
376      * @param string $bookSlug
377      * @param string $pageSlug
378      * @return \Illuminate\View\View
379      */
380     public function showRevisions($bookSlug, $pageSlug)
381     {
382         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
383         $this->setPageTitle(trans('entities.pages_revisions_named', ['pageName'=>$page->getShortName()]));
384         return view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page]);
385     }
386
387     /**
388      * Shows a preview of a single revision
389      * @param string $bookSlug
390      * @param string $pageSlug
391      * @param int $revisionId
392      * @return \Illuminate\View\View
393      */
394     public function showRevision($bookSlug, $pageSlug, $revisionId)
395     {
396         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
397         $revision = $page->revisions()->where('id', '=', $revisionId)->first();
398         if ($revision === null) {
399             abort(404);
400         }
401
402         $page->fill($revision->toArray());
403         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName' => $page->getShortName()]));
404
405         return view('pages/revision', [
406             'page' => $page,
407             'book' => $page->book,
408             'revision' => $revision
409         ]);
410     }
411
412     /**
413      * Shows the changes of a single revision
414      * @param string $bookSlug
415      * @param string $pageSlug
416      * @param int $revisionId
417      * @return \Illuminate\View\View
418      */
419     public function showRevisionChanges($bookSlug, $pageSlug, $revisionId)
420     {
421         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
422         $revision = $page->revisions()->where('id', '=', $revisionId)->first();
423         if ($revision === null) {
424             abort(404);
425         }
426
427         $prev = $revision->getPrevious();
428         $prevContent = ($prev === null) ? '' : $prev->html;
429         $diff = (new Htmldiff)->diff($prevContent, $revision->html);
430
431         $page->fill($revision->toArray());
432         $this->setPageTitle(trans('entities.pages_revision_named', ['pageName'=>$page->getShortName()]));
433
434         return view('pages/revision', [
435             'page' => $page,
436             'book' => $page->book,
437             'diff' => $diff,
438             'revision' => $revision
439         ]);
440     }
441
442     /**
443      * Restores a page using the content of the specified revision.
444      * @param string $bookSlug
445      * @param string $pageSlug
446      * @param int $revisionId
447      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
448      */
449     public function restoreRevision($bookSlug, $pageSlug, $revisionId)
450     {
451         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
452         $this->checkOwnablePermission('page-update', $page);
453         $page = $this->entityRepo->restorePageRevision($page, $page->book, $revisionId);
454         Activity::add($page, 'page_restore', $page->book->id);
455         return redirect($page->getUrl());
456     }
457
458
459     /**
460      * Deletes a revision using the id of the specified revision.
461      * @param string $bookSlug
462      * @param string $pageSlug
463      * @param int $revisionId
464      * @throws NotFoundException
465      * @throws BadRequestException
466      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
467      */
468     public function destroyRevision($bookSlug, $pageSlug, $revId)
469     {
470         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
471         $this->checkOwnablePermission('page-update', $page);
472
473         $revision = $page->revisions()->where('id', '=', $revId)->first();
474         if ($revision === null) {
475             throw new NotFoundException("Revision #{$revId} not found");
476         }
477
478         // Get the current revision for the page
479         $current = $revision->getCurrent();
480
481         // Check if its the latest revision, cannot delete latest revision.
482         if (intval($current->id) === intval($revId)) {
483             throw new BadRequestException("Cannot delete the current revision #{$revId}");
484         }
485
486         $revision->delete();
487         session()->flash('success', trans('entities.revision_delete_success'));
488         return view('pages/revisions', ['page' => $page, 'book' => $page->book, 'current' => $page]);
489     }
490
491     /**
492      * Exports a page to a PDF.
493      * https://github.com/barryvdh/laravel-dompdf
494      * @param string $bookSlug
495      * @param string $pageSlug
496      * @return \Illuminate\Http\Response
497      */
498     public function exportPdf($bookSlug, $pageSlug)
499     {
500         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
501         $page->html = $this->entityRepo->renderPage($page);
502         $pdfContent = $this->exportService->pageToPdf($page);
503         return response()->make($pdfContent, 200, [
504             'Content-Type'        => 'application/octet-stream',
505             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.pdf'
506         ]);
507     }
508
509     /**
510      * Export a page to a self-contained HTML file.
511      * @param string $bookSlug
512      * @param string $pageSlug
513      * @return \Illuminate\Http\Response
514      */
515     public function exportHtml($bookSlug, $pageSlug)
516     {
517         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
518         $page->html = $this->entityRepo->renderPage($page);
519         $containedHtml = $this->exportService->pageToContainedHtml($page);
520         return response()->make($containedHtml, 200, [
521             'Content-Type'        => 'application/octet-stream',
522             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.html'
523         ]);
524     }
525
526     /**
527      * Export a page to a simple plaintext .txt file.
528      * @param string $bookSlug
529      * @param string $pageSlug
530      * @return \Illuminate\Http\Response
531      */
532     public function exportPlainText($bookSlug, $pageSlug)
533     {
534         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
535         $containedHtml = $this->exportService->pageToPlainText($page);
536         return response()->make($containedHtml, 200, [
537             'Content-Type'        => 'application/octet-stream',
538             'Content-Disposition' => 'attachment; filename="' . $pageSlug . '.txt'
539         ]);
540     }
541
542     /**
543      * Show a listing of recently created pages
544      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
545      */
546     public function showRecentlyCreated()
547     {
548         $pages = $this->entityRepo->getRecentlyCreatedPaginated('page', 20)->setPath(baseUrl('/pages/recently-created'));
549         return view('pages/detailed-listing', [
550             'title' => trans('entities.recently_created_pages'),
551             'pages' => $pages
552         ]);
553     }
554
555     /**
556      * Show a listing of recently created pages
557      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
558      */
559     public function showRecentlyUpdated()
560     {
561         $pages = $this->entityRepo->getRecentlyUpdatedPaginated('page', 20)->setPath(baseUrl('/pages/recently-updated'));
562         return view('pages/detailed-listing', [
563             'title' => trans('entities.recently_updated_pages'),
564             'pages' => $pages
565         ]);
566     }
567
568     /**
569      * Show the Restrictions view.
570      * @param string $bookSlug
571      * @param string $pageSlug
572      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
573      */
574     public function showRestrict($bookSlug, $pageSlug)
575     {
576         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
577         $this->checkOwnablePermission('restrictions-manage', $page);
578         $roles = $this->userRepo->getRestrictableRoles();
579         return view('pages/restrictions', [
580             'page'  => $page,
581             'roles' => $roles
582         ]);
583     }
584
585     /**
586      * Show the view to choose a new parent to move a page into.
587      * @param string $bookSlug
588      * @param string $pageSlug
589      * @return mixed
590      * @throws NotFoundException
591      */
592     public function showMove($bookSlug, $pageSlug)
593     {
594         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
595         $this->checkOwnablePermission('page-update', $page);
596         return view('pages/move', [
597             'book' => $page->book,
598             'page' => $page
599         ]);
600     }
601
602     /**
603      * Does the action of moving the location of a page
604      * @param string $bookSlug
605      * @param string $pageSlug
606      * @param Request $request
607      * @return mixed
608      * @throws NotFoundException
609      */
610     public function move($bookSlug, $pageSlug, Request $request)
611     {
612         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
613         $this->checkOwnablePermission('page-update', $page);
614
615         $entitySelection = $request->get('entity_selection', null);
616         if ($entitySelection === null || $entitySelection === '') {
617             return redirect($page->getUrl());
618         }
619
620         $stringExploded = explode(':', $entitySelection);
621         $entityType = $stringExploded[0];
622         $entityId = intval($stringExploded[1]);
623
624
625         try {
626             $parent = $this->entityRepo->getById($entityType, $entityId);
627         } catch (\Exception $e) {
628             session()->flash(trans('entities.selected_book_chapter_not_found'));
629             return redirect()->back();
630         }
631
632         $this->checkOwnablePermission('page-create', $parent);
633
634         $this->entityRepo->changePageParent($page, $parent);
635         Activity::add($page, 'page_move', $page->book->id);
636         session()->flash('success', trans('entities.pages_move_success', ['parentName' => $parent->name]));
637
638         return redirect($page->getUrl());
639     }
640
641     /**
642      * Show the view to copy a page.
643      * @param string $bookSlug
644      * @param string $pageSlug
645      * @return mixed
646      * @throws NotFoundException
647      */
648     public function showCopy($bookSlug, $pageSlug)
649     {
650         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
651         $this->checkOwnablePermission('page-update', $page);
652         session()->flashInput(['name' => $page->name]);
653         return view('pages/copy', [
654             'book' => $page->book,
655             'page' => $page
656         ]);
657     }
658
659     /**
660      * Create a copy of a page within the requested target destination.
661      * @param string $bookSlug
662      * @param string $pageSlug
663      * @param Request $request
664      * @return mixed
665      * @throws NotFoundException
666      */
667     public function copy($bookSlug, $pageSlug, Request $request)
668     {
669         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
670         $this->checkOwnablePermission('page-update', $page);
671
672         $entitySelection = $request->get('entity_selection', null);
673         if ($entitySelection === null || $entitySelection === '') {
674             $parent = $page->chapter ? $page->chapter : $page->book;
675         } else {
676             $stringExploded = explode(':', $entitySelection);
677             $entityType = $stringExploded[0];
678             $entityId = intval($stringExploded[1]);
679
680             try {
681                 $parent = $this->entityRepo->getById($entityType, $entityId);
682             } catch (\Exception $e) {
683                 session()->flash(trans('entities.selected_book_chapter_not_found'));
684                 return redirect()->back();
685             }
686         }
687
688         $this->checkOwnablePermission('page-create', $parent);
689
690         $pageCopy = $this->entityRepo->copyPage($page, $parent, $request->get('name', ''));
691
692         Activity::add($pageCopy, 'page_create', $pageCopy->book->id);
693         session()->flash('success', trans('entities.pages_copy_success'));
694
695         return redirect($pageCopy->getUrl());
696     }
697
698     /**
699      * Set the permissions for this page.
700      * @param string $bookSlug
701      * @param string $pageSlug
702      * @param Request $request
703      * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
704      * @throws NotFoundException
705      */
706     public function restrict($bookSlug, $pageSlug, Request $request)
707     {
708         $page = $this->entityRepo->getBySlug('page', $pageSlug, $bookSlug);
709         $this->checkOwnablePermission('restrictions-manage', $page);
710         $this->entityRepo->updateEntityPermissionsFromRequest($request, $page);
711         session()->flash('success', trans('entities.pages_permissions_success'));
712         return redirect($page->getUrl());
713     }
714 }