bludit/admin/controllers/edit-page.php

77 lines
1.7 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Functions
// ============================================================================
function editPage($args)
{
global $dbPages;
2015-07-20 05:14:12 +02:00
global $Language;
2015-05-05 03:00:01 +02:00
// Page status, published or draft.
if( isset($args['publish']) ) {
$args['status'] = "published";
}
else {
$args['status'] = "draft";
}
if(!isset($args['parent'])) {
$args['parent'] = NO_PARENT_CHAR;
}
// Edit the page.
if( $dbPages->edit($args) )
{
$dbPages->regenerate();
2015-07-20 05:14:12 +02:00
Alert::set($Language->g('the-changes-have-been-saved'));
2015-05-19 01:22:05 +02:00
Redirect::page('admin', 'edit-page/'.$args['key']);
2015-05-05 03:00:01 +02:00
}
else
{
2015-07-20 05:14:12 +02:00
Alert::set($Language->g('an-error-occurred-while-trying-to-edit-the-page'));
2015-05-05 03:00:01 +02:00
}
}
function deletePage($key)
{
global $dbPages;
2015-07-20 05:14:12 +02:00
global $Language;
2015-05-05 03:00:01 +02:00
if( $dbPages->delete($key) )
{
Alert::set('The page has been deleted successfully');
Redirect::page('admin', 'manage-pages');
}
else
{
2015-07-20 05:14:12 +02:00
Alert::set('an-error-occurred-while-trying-to-delete-the-page');
2015-05-05 03:00:01 +02:00
}
}
// ============================================================================
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
if( isset($_POST['delete']) ) {
deletePage($_POST['key']);
}
else {
editPage($_POST);
}
}
// ============================================================================
// Main
// ============================================================================
if(!$dbPages->pageExists($layout['parameters'])) {
Redirect::page('admin', 'manage-pages');
}
$_Page = $pages[$layout['parameters']];