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