diff options
author | Vincent Petry <pvince81@owncloud.com> | 2014-11-18 18:53:45 +0100 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2014-12-15 12:10:54 +0100 |
commit | a5bb66f4a723bce5c5fbe919a48cd5133204ef62 (patch) | |
tree | b2e067bde8aaa1de6973adc7760fafb1e37e9084 /apps/files/lib | |
parent | c6be491a89a4eebe15bcb20f6e0b01f23a093761 (diff) | |
download | nextcloud-server-a5bb66f4a723bce5c5fbe919a48cd5133204ef62.tar.gz nextcloud-server-a5bb66f4a723bce5c5fbe919a48cd5133204ef62.zip |
Added favorites feature to the files app
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/helper.php | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index 97b9d8e7044..7adca3ffa6d 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -122,6 +122,9 @@ class Helper $entry['size'] = $i['size']; $entry['type'] = $i['type']; $entry['etag'] = $i['etag']; + if (isset($i['tags'])) { + $entry['tags'] = $i['tags']; + } if (isset($i['displayname_owner'])) { $entry['shareOwner'] = $i['displayname_owner']; } @@ -171,11 +174,33 @@ class Helper */ public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false) { $content = \OC\Files\Filesystem::getDirectoryContent($dir); + $content = self::populateTags($content); return self::sortFiles($content, $sortAttribute, $sortDescending); } /** + * Populate the result set with file tags + * + * @param array file list + * @return file list populated with tags + */ + public static function populateTags($fileList) { + $filesById = array(); + foreach ($fileList as $fileData) { + $filesById[$fileData['fileid']] = $fileData; + } + $tagger = \OC::$server->getTagManager()->load('files'); + $tags = $tagger->getTagsForObjects(array_keys($filesById)); + if ($tags) { + foreach ($tags as $fileId => $fileTags) { + $filesById[$fileId]['tags'] = $fileTags; + } + } + return $fileList; + } + + /** * Sort the given file info array * * @param \OCP\Files\FileInfo[] $files files to sort |