aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-04-03 20:57:06 +0200
committerVincent Petry <pvince81@owncloud.com>2014-04-28 17:42:04 +0200
commit688f6162daeec724c537f9c283092f45b29b05f2 (patch)
tree27fd75f137b773b886a5d9a0d4511ff136008133 /apps/files_trashbin
parente055a411ea4b2a32dcf20c910d332867dc91f516 (diff)
downloadnextcloud-server-688f6162daeec724c537f9c283092f45b29b05f2.tar.gz
nextcloud-server-688f6162daeec724c537f9c283092f45b29b05f2.zip
Add sorting to files list, trashbin and public files
Diffstat (limited to 'apps/files_trashbin')
-rw-r--r--apps/files_trashbin/ajax/list.php4
-rw-r--r--apps/files_trashbin/lib/helper.php10
-rw-r--r--apps/files_trashbin/templates/index.php16
3 files changed, 18 insertions, 12 deletions
diff --git a/apps/files_trashbin/ajax/list.php b/apps/files_trashbin/ajax/list.php
index 89a55114524..e1f52e814bb 100644
--- a/apps/files_trashbin/ajax/list.php
+++ b/apps/files_trashbin/ajax/list.php
@@ -4,11 +4,13 @@ OCP\JSON::checkLoggedIn();
// Load the files
$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+$sortAttribute = isset( $_GET['sort'] ) ? $_GET['sort'] : 'name';
+$sortDirection = isset( $_GET['sortdirection'] ) ? ($_GET['sortdirection'] === 'desc') : false;
$data = array();
// make filelist
try {
- $files = \OCA\Files_Trashbin\Helper::getTrashFiles($dir);
+ $files = \OCA\Files_Trashbin\Helper::getTrashFiles($dir, $sortAttribute, $sortDirection);
} catch (Exception $e) {
header("HTTP/1.0 404 Not Found");
exit();
diff --git a/apps/files_trashbin/lib/helper.php b/apps/files_trashbin/lib/helper.php
index e6ca73520a6..c98d57586d3 100644
--- a/apps/files_trashbin/lib/helper.php
+++ b/apps/files_trashbin/lib/helper.php
@@ -8,11 +8,14 @@ class Helper
{
/**
* Retrieves the contents of a trash bin directory.
+ *
* @param string $dir path to the directory inside the trashbin
* or empty to retrieve the root of the trashbin
+ * @param string $sortAttribute attribute to sort on or empty to disable sorting
+ * @param bool $sortDescending true for descending sort, false otherwise
* @return \OCP\Files\FileInfo[]
*/
- public static function getTrashFiles($dir){
+ public static function getTrashFiles($dir, $sortAttribute = '', $sortDescending = false){
$result = array();
$timestamp = null;
$user = \OCP\User::getUser();
@@ -57,8 +60,9 @@ class Helper
closedir($dirContent);
}
- usort($result, array('\OCA\Files\Helper', 'fileCmp'));
-
+ if ($sortAttribute !== '') {
+ return \OCA\Files\Helper::sortFiles($result, $sortAttribute, $sortDescending);
+ }
return $result;
}
diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php
index 323e7495535..ccfcab6ae68 100644
--- a/apps/files_trashbin/templates/index.php
+++ b/apps/files_trashbin/templates/index.php
@@ -12,22 +12,22 @@
<table id="filestable">
<thead>
<tr>
- <th id='headerName'>
+ <th id='headerName' class="hidden column-name">
<div id="headerName-container">
- <input type="checkbox" id="select_all" />
- <label for="select_all"></label>
- <span class='name'><?php p($l->t( 'Name' )); ?></span>
- <span class='selectedActions'>
+ <input type="checkbox" id="select_all" />
+ <label for="select_all"></label>
+ <a class="name sort columntitle" data-sort="name"><span><?php p($l->t( 'Name' )); ?></span><span class="sort-indicator"></span></a>
+ <span id="selectedActionsList" class='selectedActions'>
<a href="" class="undelete">
<img class="svg" alt="<?php p($l->t( 'Restore' )); ?>"
src="<?php print_unescaped(OCP\image_path("core", "actions/history.svg")); ?>" />
<?php p($l->t('Restore'))?>
</a>
- </span>
+ </span>
</div>
</th>
- <th id="headerDate">
- <span id="modified"><?php p($l->t( 'Deleted' )); ?></span>
+ <th id="headerDate" class="hidden column-mtime">
+ <a id="modified" class="columntitle" data-sort="mtime"><span><?php p($l->t( 'Deleted' )); ?></span><span class="sort-indicator"></span></a>
<span class="selectedActions">
<a href="" class="delete-selected">
<?php p($l->t('Delete'))?>