mirror of
https://github.com/flextype/flextype.git
synced 2025-08-16 18:14:04 +02:00
Admin Panel: Entries Manager - cleanup and refactoring
This commit is contained in:
@@ -36,28 +36,10 @@ class EntriesManager
|
||||
EntriesManager::addEntry();
|
||||
break;
|
||||
case 'delete':
|
||||
if (Http::get('entry') != '') {
|
||||
if (Token::check((Http::get('token')))) {
|
||||
Filesystem::deleteDir(PATH['entries'] . '/' . Http::get('entry'));
|
||||
Notification::set('success', __('admin_message_entry_deleted'));
|
||||
Http::redirect(Http::getBaseUrl() . '/admin/entries/?entry=' . Http::get('entry_current'));
|
||||
} else {
|
||||
throw new \RuntimeException("Request was denied because it contained an invalid security token. Please refresh the page and try again.");
|
||||
}
|
||||
}
|
||||
EntriesManager::deleteEntry();
|
||||
break;
|
||||
case 'duplicate':
|
||||
if (Http::get('entry') != '') {
|
||||
if (Token::check((Http::get('token')))) {
|
||||
Filesystem::copy(PATH['entries'] . '/' . Http::get('entry'),
|
||||
PATH['entries'] . '/' . Http::get('entry') . '-duplicate-' . date("Ymd_His"),
|
||||
true);
|
||||
Notification::set('success', __('admin_message_entry_duplicated'));
|
||||
Http::redirect(Http::getBaseUrl() . '/admin/entries/?entry=' . implode('/', array_slice(explode("/", Http::get('entry')), 0, -1)));
|
||||
} else {
|
||||
throw new \RuntimeException("Request was denied because it contained an invalid security token. Please refresh the page and try again.");
|
||||
}
|
||||
}
|
||||
EntriesManager::duplicateEntry();
|
||||
break;
|
||||
case 'rename':
|
||||
EntriesManager::renameEntry();
|
||||
@@ -404,6 +386,42 @@ class EntriesManager
|
||||
}
|
||||
}
|
||||
|
||||
protected static function duplicateEntry()
|
||||
{
|
||||
if (Http::get('entry') != '') {
|
||||
if (Token::check((Http::get('token')))) {
|
||||
|
||||
if (Entries:copy( Http::get('entry'), Http::get('entry') . '-duplicate-' . date("Ymd_His"), true)) {
|
||||
Notification::set('success', __('admin_message_entry_duplicated'));
|
||||
} else {
|
||||
Notification::set('error', __('admin_message_entry_was_not_duplicated'));
|
||||
}
|
||||
|
||||
Http::redirect(Http::getBaseUrl() . '/admin/entries/?entry=' . implode('/', array_slice(explode("/", Http::get('entry')), 0, -1)));
|
||||
} else {
|
||||
throw new \RuntimeException("Request was denied because it contained an invalid security token. Please refresh the page and try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function deleteEntry()
|
||||
{
|
||||
if (Http::get('entry') != '') {
|
||||
if (Token::check((Http::get('token')))) {
|
||||
|
||||
if (Entries::delete(Http::get('entry'))) {
|
||||
Notification::set('success', __('admin_message_entry_deleted'));
|
||||
} else {
|
||||
Notification::set('error', __('admin_message_entry_was_not_deleted'));
|
||||
}
|
||||
|
||||
Http::redirect(Http::getBaseUrl() . '/admin/entries/?entry=' . Http::get('entry_current'));
|
||||
} else {
|
||||
throw new \RuntimeException("Request was denied because it contained an invalid security token. Please refresh the page and try again.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected static function renameEntry()
|
||||
{
|
||||
$entry = Entries::fetch(Http::get('entry'));
|
||||
|
Reference in New Issue
Block a user