From e78f59126a02393b87e9b145c9afe2651841ec52 Mon Sep 17 00:00:00 2001 From: metal_gvc Date: Fri, 10 Jan 2014 20:00:21 +0200 Subject: [PATCH] Files Manager Improvements - create directory #94 --- .../box/filesmanager/filesmanager.admin.php | 82 +++++++++++++------ .../filesmanager/views/backend/index.view.php | 25 +++--- 2 files changed, 73 insertions(+), 34 deletions(-) diff --git a/plugins/box/filesmanager/filesmanager.admin.php b/plugins/box/filesmanager/filesmanager.admin.php index 5dfc910..8ef1833 100755 --- a/plugins/box/filesmanager/filesmanager.admin.php +++ b/plugins/box/filesmanager/filesmanager.admin.php @@ -53,31 +53,9 @@ class FilesmanagerAdmin extends Backend } $files_path = ROOT . DS . 'public' . DS . $path; - $files_list = array(); - + $current = explode('/', $path); - // Get information about current path - $_list = FilesmanagerAdmin::fdir($files_path); - - $files_list = array(); - - // Get files - if (isset($_list['files'])) { - foreach ($_list['files'] as $files) { - $files_list[] = $files; - } - } - - $dir_list = array(); - - // Get dirs - if (isset($_list['dirs'])) { - foreach ($_list['dirs'] as $dirs) { - if (strpos($dirs, '.') === false) $dir_list[] = $dirs; - } - } - // Delete file // ------------------------------------- if (Request::get('id') == 'filesmanager' && Request::get('delete_file')) { @@ -97,8 +75,16 @@ class FilesmanagerAdmin extends Backend if (Security::check(Request::get('token'))) { Dir::delete($files_path.Request::get('delete_dir')); - Request::redirect($site_url.'/admin/index.php?id=filesmanager&path='.$path); + if (!is_dir($files_path.Request::get('delete_dir'))) { + Notification::set('success', __('Directory was deleted', 'system')); + } else { + Notification::set('error', __('Directory was not deleted', 'system')); + } + + Request::redirect($site_url.'/admin/index.php?id=filesmanager&path='.$path); + + } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } @@ -118,6 +104,54 @@ class FilesmanagerAdmin extends Backend } else { die('Request was denied because it contained an invalid security token. Please refresh the page and try again.'); } } + + if (Request::post('directory_name')) { + + if (Security::check(Request::post('csrf'))) { + + $abs_path = $files_path . Security::safeName(Request::post('directory_name')); + + if ( !is_dir($abs_path) ) { + try { + mkdir($abs_path); + } catch(Exception $e) { + $error = true; + } + } else { + $error = true; + } + + if ($error) { + Alert::error(__('Directory was not created', 'system')); + } + + } + + } + + // Get information about current path + $_list = FilesmanagerAdmin::fdir($files_path); + + $files_list = array(); + + // Get files + if (isset($_list['files'])) { + foreach ($_list['files'] as $files) { + $files_list[] = $files; + } + } + + $dir_list = array(); + + // Get dirs + if (isset($_list['dirs'])) { + foreach ($_list['dirs'] as $dirs) { + if (strpos($dirs, '.') === false && strpos($dirs, '..') === false){ + $dir_list[] = $dirs; + } + } + } + // Display view View::factory('box/filesmanager/views/backend/index') ->assign('path', $path) diff --git a/plugins/box/filesmanager/views/backend/index.view.php b/plugins/box/filesmanager/views/backend/index.view.php index 5755cad..9f5ff1c 100755 --- a/plugins/box/filesmanager/views/backend/index.view.php +++ b/plugins/box/filesmanager/views/backend/index.view.php @@ -85,7 +85,7 @@
'btn btn-small', 'onclick' => "return confirmDelete('".__('Delete directory: :dir', 'filesmanager', array(':dir' => $dir))."')")); + array('class' => 'btn btn-danger', 'onclick' => "return confirmDelete('".__('Delete directory: :dir', 'filesmanager', array(':dir' => $dir))."')")); ?>
@@ -149,16 +149,21 @@
- + +