bludit/bl-kernel/admin/controllers/new-page.php

69 lines
1.8 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-08-03 02:49:12 +02:00
// ============================================================================
// Check role
// ============================================================================
2015-07-14 06:41:32 +02:00
// ============================================================================
// Functions
// ============================================================================
2015-05-05 03:00:01 +02:00
function addPage($args)
{
global $dbPages;
2015-07-20 05:14:12 +02:00
global $Language;
2017-05-19 00:45:14 +02:00
global $Syslog;
2015-08-03 02:49:12 +02:00
2016-01-08 00:43:09 +01:00
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPages->add($args);
2017-05-16 00:46:20 +02:00
if($key) {
// Re-index categories
reindexCategories();
2017-04-26 18:56:10 +02:00
2017-05-16 00:46:20 +02:00
// Re-index tags
reindextags();
// Call the plugins after page created
2016-01-08 00:43:09 +01:00
Theme::plugins('afterPageCreate');
2017-05-19 00:45:14 +02:00
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-page-created',
'notes'=>$args['title']
));
2017-05-16 00:46:20 +02:00
// Create an alert
Alert::set( $Language->g('Page added successfully') );
// Redirect
Redirect::page('pages');
return true;
2015-05-05 03:00:01 +02:00
}
2017-05-16 00:46:20 +02:00
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page');
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
$dbPages->delete($key);
2015-05-05 03:00:01 +02:00
}
2017-05-16 00:46:20 +02:00
return false;
2015-05-05 03:00:01 +02:00
}
2015-08-03 02:49:12 +02:00
// ============================================================================
// Main before POST
// ============================================================================
2015-07-14 06:41:32 +02:00
// ============================================================================
// POST Method
// ============================================================================
2015-05-05 03:00:01 +02:00
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
addPage($_POST);
2015-05-31 03:06:55 +02:00
}
2015-08-03 02:49:12 +02:00
// ============================================================================
// Main after POST
// ============================================================================