
Update 10-27. Upon further reading about global variables, it seems they are only declared when the string replacement is within a function. After testing deletion of the global intended to encompass if/else replacements occurring within a function file outside of the functions, the pages appear to work normally. The additional global on the function pages is apparently unnecessary, therefore I am removing them. Add variable in bl-kernel/boot/init.php that allows User to rename bl-kernel/admin folder. User can then define variable in bl-kernel/boot/init.php and change the foldername itself to effect the rename. Add global $adminfolder variable as necessary and replace relevant 'admin' strings with $adminfolder. Applies to most of the files in bl-kernel/admin/controllers. Line 15- Reference Admin folder variable within function global $adminfolder; Line 30 - Replace Admin string with folder variable: Redirect::page($adminfolder, 'edit-post/'.$args['slug']); Original: Redirect::page('admin', 'edit-post/'.$args['slug']); Line 44- Reference Admin folder variable within function global $adminfolder; Line 55 - Replace Admin string with folder variable: Redirect::page($adminfolder, 'manage-posts'); Original: Redirect::page('admin', 'manage-posts'); Line 88 - Replace Admin string with folder variable: Redirect::page($adminfolder, 'manage-posts'); Original: Redirect::page('admin', 'manage-pages');
94 lines
2.5 KiB
PHP
94 lines
2.5 KiB
PHP
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
// ============================================================================
|
|
// Check role
|
|
// ============================================================================
|
|
|
|
// ============================================================================
|
|
// Functions
|
|
// ============================================================================
|
|
|
|
function editPost($args)
|
|
{
|
|
global $dbPosts;
|
|
global $Language;
|
|
global $adminfolder;
|
|
|
|
// Add the page, if the $key is FALSE the creation of the post failure.
|
|
$key = $dbPosts->edit($args);
|
|
|
|
if($key)
|
|
{
|
|
// Reindex tags, this function is in 70.posts.php
|
|
reIndexTagsPosts();
|
|
|
|
// Call the plugins after post created.
|
|
Theme::plugins('afterPostModify');
|
|
|
|
// Alert the user
|
|
Alert::set($Language->g('The changes have been saved'));
|
|
Redirect::page($adminfolder, 'edit-post/'.$args['slug']);
|
|
}
|
|
else
|
|
{
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the post.');
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function deletePost($key)
|
|
{
|
|
global $dbPosts;
|
|
global $Language;
|
|
global $adminfolder;
|
|
|
|
if( $dbPosts->delete($key) )
|
|
{
|
|
// Reindex tags, this function is in 70.posts.php
|
|
reIndexTagsPosts();
|
|
|
|
// Call the plugins after post created.
|
|
Theme::plugins('afterPostDelete');
|
|
|
|
Alert::set($Language->g('The post has been deleted successfully'));
|
|
Redirect::page($adminfolder, 'manage-posts');
|
|
}
|
|
else
|
|
{
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the post.');
|
|
}
|
|
}
|
|
|
|
// ============================================================================
|
|
// Main before POST
|
|
// ============================================================================
|
|
|
|
// ============================================================================
|
|
// POST Method
|
|
// ============================================================================
|
|
|
|
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|
{
|
|
if( isset($_POST['delete-post']) ) {
|
|
deletePost($_POST['key']);
|
|
}
|
|
else {
|
|
editPost($_POST);
|
|
}
|
|
}
|
|
|
|
// ============================================================================
|
|
// Main after POST
|
|
// ============================================================================
|
|
|
|
if(!$dbPosts->postExists($layout['parameters']))
|
|
{
|
|
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']);
|
|
Redirect::page($adminfolder, 'manage-posts');
|
|
}
|
|
|
|
$_Post = buildPost($layout['parameters']);
|
|
|
|
$layout['title'] .= ' - '.$Language->g('Edit post').' - '.$_Post->title();
|