mirror of
https://github.com/getformwork/formwork.git
synced 2025-02-24 09:42:43 +01:00
Redirect to referer in Pages controller when possible
This commit is contained in:
parent
041c10338e
commit
1ceee67b72
@ -74,20 +74,20 @@ class Pages extends AbstractController
|
|||||||
// Ensure no required data is missing
|
// Ensure no required data is missing
|
||||||
if (!$data->has(array('title', 'slug', 'template', 'parent'))) {
|
if (!$data->has(array('title', 'slug', 'template', 'parent'))) {
|
||||||
$this->notify($this->label('pages.page.cannot-create.var-missing'), 'error');
|
$this->notify($this->label('pages.page.cannot-create.var-missing'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->resolveParent($data->get('parent'));
|
$parent = $this->resolveParent($data->get('parent'));
|
||||||
|
|
||||||
if (is_null($parent)) {
|
if (is_null($parent)) {
|
||||||
$this->notify($this->label('pages.page.cannot-create.invalid-parent'), 'error');
|
$this->notify($this->label('pages.page.cannot-create.invalid-parent'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate page slug
|
// Validate page slug
|
||||||
if (!$this->validateSlug($data->get('slug'))) {
|
if (!$this->validateSlug($data->get('slug'))) {
|
||||||
$this->notify($this->label('pages.page.cannot-create.invalid-slug'), 'error');
|
$this->notify($this->label('pages.page.cannot-create.invalid-slug'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$route = $parent->route() . $data->get('slug') . '/';
|
$route = $parent->route() . $data->get('slug') . '/';
|
||||||
@ -95,13 +95,13 @@ class Pages extends AbstractController
|
|||||||
// Ensure there isn't a page with the same route
|
// Ensure there isn't a page with the same route
|
||||||
if ($this->site()->findPage($route)) {
|
if ($this->site()->findPage($route)) {
|
||||||
$this->notify($this->label('pages.page.cannot-create.already-exists'), 'error');
|
$this->notify($this->label('pages.page.cannot-create.already-exists'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate page template
|
// Validate page template
|
||||||
if (!$this->site()->hasTemplate($data->get('template'))) {
|
if (!$this->site()->hasTemplate($data->get('template'))) {
|
||||||
$this->notify($this->label('pages.page.cannot-create.invalid-template'), 'error');
|
$this->notify($this->label('pages.page.cannot-create.invalid-template'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$scheme = $this->scheme($data->get('template'));
|
$scheme = $this->scheme($data->get('template'));
|
||||||
@ -113,7 +113,7 @@ class Pages extends AbstractController
|
|||||||
$newPage = $this->createPage($path, $data->get('template'), $data->get('title'));
|
$newPage = $this->createPage($path, $data->get('template'), $data->get('title'));
|
||||||
} catch (RuntimeException $e) {
|
} catch (RuntimeException $e) {
|
||||||
$this->notify($this->label('pages.page.cannot-create'), 'error');
|
$this->notify($this->label('pages.page.cannot-create'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->notify($this->label('pages.page.created'), 'success');
|
$this->notify($this->label('pages.page.created'), 'success');
|
||||||
@ -132,7 +132,7 @@ class Pages extends AbstractController
|
|||||||
// Ensure the page exists
|
// Ensure the page exists
|
||||||
if (!$page) {
|
if (!$page) {
|
||||||
$this->notify($this->label('pages.page.cannot-edit.page-missing'), 'error');
|
$this->notify($this->label('pages.page.cannot-edit.page-missing'), 'error');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load page fields
|
// Load page fields
|
||||||
@ -271,7 +271,7 @@ class Pages extends AbstractController
|
|||||||
FileSystem::delete($page->path(), true);
|
FileSystem::delete($page->path(), true);
|
||||||
|
|
||||||
$this->notify($this->label('pages.page.deleted'), 'success');
|
$this->notify($this->label('pages.page.deleted'), 'success');
|
||||||
$this->redirect('/pages/');
|
$this->redirectToReferer(302, '/pages/');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user