mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-04 20:27:40 +02:00
Pages Plugin: Update add action logic.
This commit is contained in:
@@ -98,7 +98,7 @@
|
|||||||
|
|
||||||
if (Security::check(Request::post('csrf'))) {
|
if (Security::check(Request::post('csrf'))) {
|
||||||
|
|
||||||
// Get pages parent
|
// Get parent page
|
||||||
if (Request::post('pages') == '0') {
|
if (Request::post('pages') == '0') {
|
||||||
$parent_page = '';
|
$parent_page = '';
|
||||||
} else {
|
} else {
|
||||||
@@ -106,15 +106,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Validate
|
// Validate
|
||||||
//--------------
|
//--------------
|
||||||
if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('This field should not be empty', 'pages');
|
if (trim(Request::post('page_name')) == '') $errors['pages_empty_name'] = __('Required field', 'pages');
|
||||||
|
if (trim(Request::post('page_title')) == '') $errors['pages_empty_title'] = __('Required field', 'pages');
|
||||||
|
if (count($pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]')) != 0) $errors['pages_exists'] = __('This page already exists', 'pages');
|
||||||
|
|
||||||
$page = $pages->select('[slug="'.Security::safeName(Request::post('page_name'), '-', true).'"]');
|
|
||||||
|
|
||||||
if (count($page) != 0) $errors['pages_exists'] = __('This page already exists', 'pages');
|
|
||||||
if (trim(Request::post('page_title')) == '') $errors['pages_empty_title'] = __('This field should not be empty', 'pages');
|
|
||||||
|
|
||||||
// Prepare date
|
// Prepare date
|
||||||
if (Valid::date(Request::post('page_date'))) {
|
if (Valid::date(Request::post('page_date'))) {
|
||||||
@@ -181,27 +178,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save fields
|
// Save fields
|
||||||
if (Request::post('pages')) $parent_page = Request::post('pages'); else $parent_page = '';
|
|
||||||
if (Request::post('page_name')) $post_name = Request::post('page_name'); else $post_name = '';
|
if (Request::post('page_name')) $post_name = Request::post('page_name'); else $post_name = '';
|
||||||
if (Request::post('page_title')) $post_title = Request::post('page_title'); else $post_title = '';
|
if (Request::post('page_title')) $post_title = Request::post('page_title'); else $post_title = '';
|
||||||
if (Request::post('page_keywords')) $post_keywords = Request::post('page_keywords'); else $post_keywords = '';
|
if (Request::post('page_keywords')) $post_keywords = Request::post('page_keywords'); else $post_keywords = '';
|
||||||
if (Request::post('page_description')) $post_description = Request::post('page_description'); else $post_description = '';
|
if (Request::post('page_description')) $post_description = Request::post('page_description'); else $post_description = '';
|
||||||
if (Request::post('editor')) $post_content = Request::post('editor'); else $post_content = '';
|
if (Request::post('editor')) $post_content = Request::post('editor'); else $post_content = '';
|
||||||
if (Request::post('templates')) $post_template = Request::post('templates'); else $post_template = 'index';
|
if (Request::post('templates')) $post_template = Request::post('templates'); else $post_template = 'index';
|
||||||
|
if (Request::post('pages')) $parent_page = Request::post('pages'); else $parent_page = '';
|
||||||
if (Request::post('robots_index')) $post_robots_index = true; else $post_robots_index = false;
|
if (Request::post('robots_index')) $post_robots_index = true; else $post_robots_index = false;
|
||||||
if (Request::post('robots_follow')) $post_robots_follow = true; else $post_robots_follow = false;
|
if (Request::post('robots_follow')) $post_robots_follow = true; else $post_robots_follow = false;
|
||||||
if (Request::post('parent_page')) {
|
|
||||||
$post_template = Request::post('pages');
|
|
||||||
} else {
|
|
||||||
if(Request::get('parent_page')) {
|
|
||||||
$parent_page = trim(Request::get('parent_page'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//--------------
|
//--------------
|
||||||
|
|
||||||
// Generate date
|
// Generate date
|
||||||
$date = Date::format(time(), 'Y-m-d H:i:s');
|
$date = Date::format(time(), 'Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// Set Tabs State - page
|
||||||
Notification::setNow('page', 'page');
|
Notification::setNow('page', 'page');
|
||||||
|
|
||||||
// Display view
|
// Display view
|
||||||
|
Reference in New Issue
Block a user