1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-03 11:47:51 +02:00

Files Manager Improvements - create directory #94

This commit is contained in:
metal_gvc
2014-01-10 20:00:21 +02:00
parent 81b070322e
commit e78f59126a
2 changed files with 73 additions and 34 deletions

View File

@@ -53,31 +53,9 @@ class FilesmanagerAdmin extends Backend
} }
$files_path = ROOT . DS . 'public' . DS . $path; $files_path = ROOT . DS . 'public' . DS . $path;
$files_list = array();
$current = explode('/', $path); $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 // Delete file
// ------------------------------------- // -------------------------------------
if (Request::get('id') == 'filesmanager' && Request::get('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'))) { if (Security::check(Request::get('token'))) {
Dir::delete($files_path.Request::get('delete_dir')); 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.'); } } 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.'); } } 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 // Display view
View::factory('box/filesmanager/views/backend/index') View::factory('box/filesmanager/views/backend/index')
->assign('path', $path) ->assign('path', $path)

View File

@@ -85,7 +85,7 @@
<div class="pull-right"> <div class="pull-right">
<?php echo Html::anchor(__('Delete', 'filesmanager'), <?php echo Html::anchor(__('Delete', 'filesmanager'),
'index.php?id=filesmanager&delete_dir='.$dir.'&path='.$path.'&token='.Security::token(), 'index.php?id=filesmanager&delete_dir='.$dir.'&path='.$path.'&token='.Security::token(),
array('class' => '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))."')"));
?> ?>
<div> <div>
</td> </td>
@@ -149,16 +149,21 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Create New Directory</h4> <h4 class="modal-title" id="myModalLabel">Create New Directory</h4>
</div> </div>
<div class="modal-body"> <form role="form" method="POST">
<form role="form"> <?php echo Form::hidden('csrf', Security::token()); ?>
<div class="modal-body">
<label for="directoryName">Directory Name</label> <label for="directoryName">Directory Name</label>
<input type="text" class="form-control" id="directoryName"> <input type="hidden" name="path" value="<?php echo $path; ?>" />
</form> <input type="text" class="form-control" id="directoryName" name="directory_name" />
</div>
<div class="modal-footer"> </div>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> <div class="modal-footer">
<button type="button" class="btn btn-primary">Create</button> <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div> <button type="submit" class="btn btn-primary">Create</button>
</div>
</form>
</div> </div>
</div> </div>
</div> </div>