Skip to content

Commit

Permalink
[ADD] Sortable Table in Manage Files #169.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seiger committed May 23, 2023
1 parent 2ccccc4 commit 5c99f20
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 73 deletions.
124 changes: 52 additions & 72 deletions manager/actions/files.dynamic.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
// settings
$theme_image_path = MODX_MANAGER_URL . 'media/style/' . EvolutionCMS()->getConfig('manager_theme') . '/images/';
$excludes = array(
'.',
'..',
'.svn',
'.git',
'.idea'
'.',
'..',
'.svn',
'.git',
'.idea'
);
$alias_suffix = (!empty($friendly_url_suffix)) ? ',' . ltrim($friendly_url_suffix, '.') : '';
$editablefiles = explode(',', 'txt,php,tpl,less,sass,scss,shtml,html,htm,xml,js,css,pageCache,htaccess,json,ini' . $alias_suffix);
Expand Down Expand Up @@ -100,106 +100,93 @@
$webstart_path = '..' . $webstart_path;
} else {
$webstart_path = '../' . $webstart_path;
}

?>
} ?>
<script type="text/javascript">

var current_path = '<?= $startpath;?>';

function viewfile (url)
{
function viewfile(url) {
var el = document.getElementById('imageviewer');
el.innerHTML = '<img src="' + url + '" />';
el.style.display = 'block'
}

function setColor (o, state)
{
if (!o){return;
}
if (state && o.style){o.style.backgroundColor = '#eeeeee';
}else if (o.style){o.style.backgroundColor = 'transparent';
}
function setColor(o, state) {
if (!o){return;}
if (state && o.style) {
o.style.backgroundColor = '#eeeeee';
} else if (o.style) {
o.style.backgroundColor = 'transparent';
}
}

function confirmDelete ()
{
function confirmDelete() {
return confirm("<?= $_lang['confirm_delete_file'] ?>");
}

function confirmDeleteFolder (status)
{
if (status !== 'file_exists')return confirm("<?= $_lang['confirm_delete_dir'] ?>");else return confirm("<?= $_lang['confirm_delete_dir_recursive'] ?>");
function confirmDeleteFolder(status) {
if (status !== 'file_exists') {
return confirm("<?= $_lang['confirm_delete_dir'] ?>");
} else {
return confirm("<?= $_lang['confirm_delete_dir_recursive'] ?>");
}
}

function confirmUnzip ()
{
function confirmUnzip() {
return confirm("<?= $_lang['confirm_unzip_file'] ?>");
}

function unzipFile (file)
{
function unzipFile(file) {
if (confirmUnzip()) {
window.location.href = "index.php?a=31&mode=unzip&path=" + current_path + '/&file=' + file + "&token=<?= $newToken;?>";
return false;
}
}

function getFolderName (a)
{
function getFolderName(a) {
var f = window.prompt("<?= $_lang['files_dynamic_new_file_name'] ?>", '');
if (f) a.href += encodeURI(f);
return !!(f);
}

function getFileName (a)
{
function getFileName(a) {
var f = window.prompt("<?= $_lang['files_dynamic_new_file_name'] ?>", '');
if (f) a.href += encodeURI(f);
return !!(f);
}

function deleteFolder (folder, status)
{
function deleteFolder(folder, status) {
if (confirmDeleteFolder(status)) {
window.location.href = "index.php?a=31&mode=deletefolder&path=" + current_path + "&folderpath=" + current_path + '/' + folder + "&token=<?= $newToken;?>";
return false;
}
}

function deleteFile (file)
{
function deleteFile(file) {
if (confirmDelete()) {
window.location.href = "index.php?a=31&mode=delete&path=" + current_path + '/' + file + "&token=<?= $newToken;?>";
return false;
}
}

function duplicateFile (file)
{
function duplicateFile(file) {
var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file);
if (newFilename !== null && newFilename !== file) {
window.location.href = "index.php?a=31&mode=duplicate&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>";
}
}

function renameFolder (dir)
{
function renameFolder(dir) {
var newDirname = prompt("<?= $_lang["files_dynamic_new_folder_name"] ?>", dir);
if (newDirname !== null && newDirname !== dir) {
window.location.href = "index.php?a=31&mode=renameFolder&path=" + current_path + '&dirname=' + dir + "&newDirname=" + newDirname + "&token=<?= $newToken;?>";
}
}

function renameFile (file)
{
function renameFile(file) {
var newFilename = prompt("<?= $_lang["files_dynamic_new_file_name"] ?>", file);
if (newFilename !== null && newFilename !== file) {
window.location.href = "index.php?a=31&mode=renameFile&path=" + current_path + '/' + file + "&newFilename=" + newFilename + "&token=<?= $newToken;?>";
}
}

</script>

<h1>
Expand Down Expand Up @@ -294,12 +281,9 @@ function renameFile (file)
$topic_path = implode('/', $pieces);
}

echo $topic_path;

?>
echo $topic_path; ?>
</div>
<?php
// check to see user isn't trying to move below the document_root
<?php // check to see user isn't trying to move below the document_root
if (substr(strtolower(str_replace('//', '/', $startpath . "/")), 0, $len) != strtolower(str_replace('//', '/', $filemanager_path . '/'))) {
EvolutionCMS()->webAlertAndQuit($_lang["files_access_denied"]);
}
Expand All @@ -314,7 +298,6 @@ function renameFile (file)
}
// End Unzip - Raymond


// New Folder & Delete Folder option - Raymond
if (is_writable($startpath)) {
// Delete Folder
Expand Down Expand Up @@ -383,10 +366,10 @@ function renameFile (file)
$old_umask = umask(0);
$dirname = $_REQUEST['path'] . '/' . $_REQUEST['dirname'];
$newDirname = str_replace(array(
'..\\',
'../',
'\\',
'/'
'..\\',
'../',
'\\',
'/'
), '', $_REQUEST['newDirname']);

if (preg_match('@(\\\\|\/|\:|\;|\,|\*|\?|\"|\<|\>|\||\?)@', $newDirname) !== 0) {
Expand All @@ -402,10 +385,10 @@ function renameFile (file)
$path = dirname($_REQUEST['path']);
$filename = $_REQUEST['path'];
$newFilename = str_replace(array(
'..\\',
'../',
'\\',
'/'
'..\\',
'../',
'\\',
'/'
), '', $_REQUEST['newFilename']);

if (!checkExtension($newFilename)) {
Expand All @@ -422,20 +405,18 @@ function renameFile (file)
}
// End New Folder - Raymond


if (strlen(MODX_BASE_PATH) < strlen($filemanager_path)) {
$len--;
}

?>
} ?>
<script type="text/javascript" src="media/script/tablesort.js"></script>
<div class="table-responsive">
<table id="FilesTable" class="table data">
<thead>
<tr>
<th><?= $_lang['files_filename'] ?></th>
<th style="width: 1%;"><?= $_lang['files_modified'] ?></th>
<th style="width: 1%;"><?= $_lang['files_filesize'] ?></th>
<th style="width: 1%;" class="text-nowrap"><?= $_lang['files_fileoptions'] ?></th>
<th class="sortable"><?= $_lang['files_filename'] ?></th>
<th class="sortable" style="width: 1%;"><?= $_lang['files_modified'] ?></th>
<th class="sortable" style="width: 1%;"><?= $_lang['files_filesize'] ?></th>
<th class="sortable" style="width: 1%;" class="text-nowrap"><?= $_lang['files_fileoptions'] ?></th>
</tr>
</thead>
<?php
Expand Down Expand Up @@ -534,16 +515,15 @@ function renameFile (file)
$contentType = 'htmlmixed';
};
$evtOut = EvolutionCMS()->invokeEvent('OnRichTextEditorInit', array(
'editor' => 'Codemirror',
'elements' => array(
'content',
),
'contentType' => $contentType,
'readOnly' => $_REQUEST['mode'] == 'edit' ? false : true
'editor' => 'Codemirror',
'elements' => array(
'content',
),
'contentType' => $contentType,
'readOnly' => $_REQUEST['mode'] == 'edit' ? false : true
));
if (is_array($evtOut)) {
echo implode('', $evtOut);
}

}

2 changes: 1 addition & 1 deletion manager/media/style/default/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ table.actionButtons .searchtext { padding: 5px; height: 24px; width: 150px; }
.table.data thead .sortable.reverseSort a::after, .table.data thead .sortable-text.reverseSort a::after, .table.data thead .sortable-numeric.reverseSort a::after { opacity: 1; content: "\f107"; color: #d9534f }
.table.data thead .sortable:hover a::after, .table.data thead .sortable-text:hover a::after, .table.data thead .sortable-numeric:hover a::after, .table.data thead .sortable-date:hover a::after { opacity: 1 }
.table.data thead .sortable, .table.data thead .sortable-text, .table.data thead .sortable-numeric, .table.data thead .sortable-date { cursor: pointer }
.table.data thead .sortable-text span, .table.data thead .sortable-numeric span, .table.data thead .sortable-date span { display: none }
/*.table.data thead .sortable-text span, .table.data thead .sortable-numeric span, .table.data thead .sortable-date span { display: none }*/
.table.data.table-sortable > tbody > tr { cursor: move; transition-duration: .5s }
.table.data.table-sortable > tbody > tr.ghost { background-color: rgba(93, 109, 202, 0.16); color: #d9534f !important; transition: background-color .5s, color .5s, transform 0s }
/* table-data-sm */
Expand Down

0 comments on commit 5c99f20

Please sign in to comment.