From d2bbfbe8ce4c80a4950683ed3300da15f6bb0f21 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 19 Jun 2020 16:57:45 +0200
Subject: [PATCH 1/3] Added 2 extra columns + sortability to files list
Added 2 extra columns (type, aka extension, and size) to files list, and chance to sort them by clicking on column header, as for Items browse list.
TODO: it would be nice to manage number format localization (line 101)
---
views/admin/index/dropboxlist.php | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/views/admin/index/dropboxlist.php b/views/admin/index/dropboxlist.php
index be1c012..cd32e04 100644
--- a/views/admin/index/dropboxlist.php
+++ b/views/admin/index/dropboxlist.php
@@ -55,7 +55,23 @@ function dropboxNoEnter(e) {
jQuery('.dropbox-js').show();
jQuery('#dropbox-show-all').hide();
+
+ jQuery('th').click(function(){
+ var table = jQuery(this).parents('table').eq(0)
+ var rows = table.find('tr:gt(0)').toArray().sort(comparer(jQuery(this).index()))
+ this.asc = !this.asc
+ if (!this.asc){rows = rows.reverse()}
+ for (var i = 0; i < rows.length; i++){table.append(rows[i])}
+ })
});
+
+ function comparer(index) {
+ return function(a, b) {
+ var valA = getCellValue(a, index), valB = getCellValue(b, index)
+ return jQuery.isNumeric(valA) && jQuery.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB)
+ }
+ }
+ function getCellValue(row, index){ return jQuery(row).children('td').eq(index).text() }
@@ -71,12 +87,19 @@ function dropboxNoEnter(e) {
|
- |
+ ' . __('File Name') . ''; ?> |
+ ' . __('File Type'). ''; ?> |
+ ' . __('File Size'). ''; ?> |
- | |
+ |
+ |
+ |
+
+
+ |
From dc8c90146a6cafaf10033c00f845ad723fb7236b Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Fri, 19 Jun 2020 17:00:17 +0200
Subject: [PATCH 2/3] Added extra info to $filenames array
---
helpers/DropboxFunctions.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/helpers/DropboxFunctions.php b/helpers/DropboxFunctions.php
index e8c52ef..3603eb2 100644
--- a/helpers/DropboxFunctions.php
+++ b/helpers/DropboxFunctions.php
@@ -47,7 +47,11 @@ function dropbox_dir_list($directory)
foreach ($iter as $fileEntry) {
if ($fileEntry->isFile()) {
- $filenames[] = $fileEntry->getFilename();
+ $filenames[] = array(
+ $fileEntry->getFilename(),
+ $fileEntry->getExtension(),
+ $fileEntry->getSize()
+ );
}
}
From d443622bb3185ed9f2f9e036d32bcfffcd35cba6 Mon Sep 17 00:00:00 2001
From: DBinaghi <39097246+DBinaghi@users.noreply.github.com>
Date: Tue, 23 Jun 2020 19:37:13 +0200
Subject: [PATCH 3/3] Added localization of file size + lowercased file
extension
---
views/admin/index/dropboxlist.php | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/views/admin/index/dropboxlist.php b/views/admin/index/dropboxlist.php
index cd32e04..63dea15 100644
--- a/views/admin/index/dropboxlist.php
+++ b/views/admin/index/dropboxlist.php
@@ -86,20 +86,22 @@ function getCellValue(row, index){ return jQuery(row).children('td').eq(index).t
- |
- ' . __('File Name') . ''; ?> |
- ' . __('File Type'). ''; ?> |
- ' . __('File Size'). ''; ?> |
+ |
+ ' . __('File Name') . ''; ?> |
+ ' . __('File Type'). ''; ?> |
+ ' . __('File Size'). ''; ?> |
- |
- |
- |
-
-
- |
+
+ |
+ |
+ |
+
+
+ |
+