@@ -2,17 +2,17 @@ |
||
2 | 2 | |
3 | 3 | <div class="section"> |
4 | 4 | <h2><?php p($l->t('File handling')); ?></h2> |
5 | - <label for="maxUploadSize"><?php p($l->t( 'Maximum upload size' )); ?> </label> |
|
5 | + <label for="maxUploadSize"><?php p($l->t('Maximum upload size')); ?> </label> |
|
6 | 6 | <span id="maxUploadSizeSettingsMsg" class="msg"></span> |
7 | 7 | <br /> |
8 | - <input type="text" name='maxUploadSize' id="maxUploadSize" value='<?php p($_['uploadMaxFilesize']) ?>' <?php if(!$_['uploadChangable']) { p('disabled'); } ?> /> |
|
9 | - <?php if($_['displayMaxPossibleUploadSize']):?> |
|
8 | + <input type="text" name='maxUploadSize' id="maxUploadSize" value='<?php p($_['uploadMaxFilesize']) ?>' <?php if (!$_['uploadChangable']) { p('disabled'); } ?> /> |
|
9 | + <?php if ($_['displayMaxPossibleUploadSize']):?> |
|
10 | 10 | (<?php p($l->t('max. possible: ')); p($_['maxPossibleUploadSize']) ?>) |
11 | - <?php endif;?> |
|
11 | + <?php endif; ?> |
|
12 | 12 | <input type="hidden" value="<?php p($_['requesttoken']); ?>" name="requesttoken" /> |
13 | - <?php if($_['uploadChangable']): ?> |
|
13 | + <?php if ($_['uploadChangable']): ?> |
|
14 | 14 | <input type="submit" id="submitMaxUpload" |
15 | - value="<?php p($l->t( 'Save' )); ?>"/> |
|
15 | + value="<?php p($l->t('Save')); ?>"/> |
|
16 | 16 | <p><em><?php p($l->t('With PHP-FPM it might take 5 minutes for changes to be applied.')); ?></em></p> |
17 | 17 | <?php else: ?> |
18 | 18 | <p><em><?php p($l->t('Missing permissions to edit from here.')); ?></em></p> |
@@ -14,7 +14,10 @@ |
||
14 | 14 | <input type="submit" id="submitMaxUpload" |
15 | 15 | value="<?php p($l->t( 'Save' )); ?>"/> |
16 | 16 | <p><em><?php p($l->t('With PHP-FPM it might take 5 minutes for changes to be applied.')); ?></em></p> |
17 | - <?php else: ?> |
|
18 | - <p><em><?php p($l->t('Missing permissions to edit from here.')); ?></em></p> |
|
17 | + <?php else { |
|
18 | + : ?> |
|
19 | + <p><em><?php p($l->t('Missing permissions to edit from here.')); |
|
20 | +} |
|
21 | +?></em></p> |
|
19 | 22 | <?php endif; ?> |
20 | 23 | </div> |
@@ -32,129 +32,129 @@ |
||
32 | 32 | |
33 | 33 | class Favorites implements IFilter { |
34 | 34 | |
35 | - /** @var IL10N */ |
|
36 | - protected $l; |
|
37 | - |
|
38 | - /** @var IURLGenerator */ |
|
39 | - protected $url; |
|
40 | - |
|
41 | - /** @var IManager */ |
|
42 | - protected $activityManager; |
|
43 | - |
|
44 | - /** @var Helper */ |
|
45 | - protected $helper; |
|
46 | - |
|
47 | - /** @var IDBConnection */ |
|
48 | - protected $db; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param IL10N $l |
|
52 | - * @param IURLGenerator $url |
|
53 | - * @param IManager $activityManager |
|
54 | - * @param Helper $helper |
|
55 | - * @param IDBConnection $db |
|
56 | - */ |
|
57 | - public function __construct(IL10N $l, IURLGenerator $url, IManager $activityManager, Helper $helper, IDBConnection $db) { |
|
58 | - $this->l = $l; |
|
59 | - $this->url = $url; |
|
60 | - $this->activityManager = $activityManager; |
|
61 | - $this->helper = $helper; |
|
62 | - $this->db = $db; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string Lowercase a-z only identifier |
|
67 | - * @since 11.0.0 |
|
68 | - */ |
|
69 | - public function getIdentifier() { |
|
70 | - return 'files_favorites'; |
|
71 | - } |
|
72 | - |
|
73 | - /** |
|
74 | - * @return string A translated string |
|
75 | - * @since 11.0.0 |
|
76 | - */ |
|
77 | - public function getName() { |
|
78 | - return $this->l->t('Favorites'); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * @return int |
|
83 | - * @since 11.0.0 |
|
84 | - */ |
|
85 | - public function getPriority() { |
|
86 | - return 10; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string Full URL to an icon, empty string when none is given |
|
91 | - * @since 11.0.0 |
|
92 | - */ |
|
93 | - public function getIcon() { |
|
94 | - return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * @param string[] $types |
|
99 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
100 | - * @since 11.0.0 |
|
101 | - */ |
|
102 | - public function filterTypes(array $types) { |
|
103 | - return array_intersect([ |
|
104 | - 'file_created', |
|
105 | - 'file_changed', |
|
106 | - 'file_deleted', |
|
107 | - 'file_restored', |
|
108 | - ], $types); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return string[] An array of allowed apps from which activities should be displayed |
|
113 | - * @since 11.0.0 |
|
114 | - */ |
|
115 | - public function allowedApps() { |
|
116 | - return ['files']; |
|
117 | - } |
|
118 | - |
|
119 | - /** |
|
120 | - * @param IQueryBuilder $query |
|
121 | - */ |
|
122 | - public function filterFavorites(IQueryBuilder $query) { |
|
123 | - try { |
|
124 | - $user = $this->activityManager->getCurrentUserId(); |
|
125 | - } catch (\UnexpectedValueException $e) { |
|
126 | - return; |
|
127 | - } |
|
128 | - |
|
129 | - try { |
|
130 | - $favorites = $this->helper->getFavoriteFilePaths($user); |
|
131 | - } catch (\RuntimeException $e) { |
|
132 | - return; |
|
133 | - } |
|
134 | - |
|
135 | - $limitations = []; |
|
136 | - if (!empty($favorites['items'])) { |
|
137 | - $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); |
|
138 | - } |
|
139 | - foreach ($favorites['folders'] as $favorite) { |
|
140 | - $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
|
141 | - $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
142 | - )); |
|
143 | - } |
|
144 | - |
|
145 | - if (empty($limitations)) { |
|
146 | - return; |
|
147 | - } |
|
148 | - |
|
149 | - $function = $query->createFunction(' |
|
35 | + /** @var IL10N */ |
|
36 | + protected $l; |
|
37 | + |
|
38 | + /** @var IURLGenerator */ |
|
39 | + protected $url; |
|
40 | + |
|
41 | + /** @var IManager */ |
|
42 | + protected $activityManager; |
|
43 | + |
|
44 | + /** @var Helper */ |
|
45 | + protected $helper; |
|
46 | + |
|
47 | + /** @var IDBConnection */ |
|
48 | + protected $db; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param IL10N $l |
|
52 | + * @param IURLGenerator $url |
|
53 | + * @param IManager $activityManager |
|
54 | + * @param Helper $helper |
|
55 | + * @param IDBConnection $db |
|
56 | + */ |
|
57 | + public function __construct(IL10N $l, IURLGenerator $url, IManager $activityManager, Helper $helper, IDBConnection $db) { |
|
58 | + $this->l = $l; |
|
59 | + $this->url = $url; |
|
60 | + $this->activityManager = $activityManager; |
|
61 | + $this->helper = $helper; |
|
62 | + $this->db = $db; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string Lowercase a-z only identifier |
|
67 | + * @since 11.0.0 |
|
68 | + */ |
|
69 | + public function getIdentifier() { |
|
70 | + return 'files_favorites'; |
|
71 | + } |
|
72 | + |
|
73 | + /** |
|
74 | + * @return string A translated string |
|
75 | + * @since 11.0.0 |
|
76 | + */ |
|
77 | + public function getName() { |
|
78 | + return $this->l->t('Favorites'); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * @return int |
|
83 | + * @since 11.0.0 |
|
84 | + */ |
|
85 | + public function getPriority() { |
|
86 | + return 10; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string Full URL to an icon, empty string when none is given |
|
91 | + * @since 11.0.0 |
|
92 | + */ |
|
93 | + public function getIcon() { |
|
94 | + return $this->url->getAbsoluteURL($this->url->imagePath('core', 'actions/star-dark.svg')); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * @param string[] $types |
|
99 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
100 | + * @since 11.0.0 |
|
101 | + */ |
|
102 | + public function filterTypes(array $types) { |
|
103 | + return array_intersect([ |
|
104 | + 'file_created', |
|
105 | + 'file_changed', |
|
106 | + 'file_deleted', |
|
107 | + 'file_restored', |
|
108 | + ], $types); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return string[] An array of allowed apps from which activities should be displayed |
|
113 | + * @since 11.0.0 |
|
114 | + */ |
|
115 | + public function allowedApps() { |
|
116 | + return ['files']; |
|
117 | + } |
|
118 | + |
|
119 | + /** |
|
120 | + * @param IQueryBuilder $query |
|
121 | + */ |
|
122 | + public function filterFavorites(IQueryBuilder $query) { |
|
123 | + try { |
|
124 | + $user = $this->activityManager->getCurrentUserId(); |
|
125 | + } catch (\UnexpectedValueException $e) { |
|
126 | + return; |
|
127 | + } |
|
128 | + |
|
129 | + try { |
|
130 | + $favorites = $this->helper->getFavoriteFilePaths($user); |
|
131 | + } catch (\RuntimeException $e) { |
|
132 | + return; |
|
133 | + } |
|
134 | + |
|
135 | + $limitations = []; |
|
136 | + if (!empty($favorites['items'])) { |
|
137 | + $limitations[] = $query->expr()->in('file', $query->createNamedParameter($favorites['items'], IQueryBuilder::PARAM_STR_ARRAY)); |
|
138 | + } |
|
139 | + foreach ($favorites['folders'] as $favorite) { |
|
140 | + $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
|
141 | + $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
142 | + )); |
|
143 | + } |
|
144 | + |
|
145 | + if (empty($limitations)) { |
|
146 | + return; |
|
147 | + } |
|
148 | + |
|
149 | + $function = $query->createFunction(' |
|
150 | 150 | CASE |
151 | 151 | WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 |
152 | 152 | WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' |
153 | 153 | AND (' . implode(' OR ', $limitations) . ') |
154 | 154 | THEN 1 |
155 | 155 | END = 1' |
156 | - ); |
|
156 | + ); |
|
157 | 157 | |
158 | - $query->andWhere($function); |
|
159 | - } |
|
158 | + $query->andWhere($function); |
|
159 | + } |
|
160 | 160 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | } |
139 | 139 | foreach ($favorites['folders'] as $favorite) { |
140 | 140 | $limitations[] = $query->expr()->like('file', $query->createNamedParameter( |
141 | - $this->db->escapeLikeParameter($favorite . '/') . '%' |
|
141 | + $this->db->escapeLikeParameter($favorite.'/').'%' |
|
142 | 142 | )); |
143 | 143 | } |
144 | 144 | |
@@ -148,9 +148,9 @@ discard block |
||
148 | 148 | |
149 | 149 | $function = $query->createFunction(' |
150 | 150 | CASE |
151 | - WHEN ' . $query->getColumnName('app') . ' <> ' . $query->createNamedParameter('files') . ' THEN 1 |
|
152 | - WHEN ' . $query->getColumnName('app') . ' = ' . $query->createNamedParameter('files') . ' |
|
153 | - AND (' . implode(' OR ', $limitations) . ') |
|
151 | + WHEN ' . $query->getColumnName('app').' <> '.$query->createNamedParameter('files').' THEN 1 |
|
152 | + WHEN ' . $query->getColumnName('app').' = '.$query->createNamedParameter('files').' |
|
153 | + AND (' . implode(' OR ', $limitations).') |
|
154 | 154 | THEN 1 |
155 | 155 | END = 1' |
156 | 156 | ); |
@@ -26,60 +26,60 @@ |
||
26 | 26 | use OCP\ITagManager; |
27 | 27 | |
28 | 28 | class Helper { |
29 | - /** If a user has a lot of favorites the query might get too slow and long */ |
|
30 | - const FAVORITE_LIMIT = 50; |
|
29 | + /** If a user has a lot of favorites the query might get too slow and long */ |
|
30 | + const FAVORITE_LIMIT = 50; |
|
31 | 31 | |
32 | - /** @var ITagManager */ |
|
33 | - protected $tagManager; |
|
32 | + /** @var ITagManager */ |
|
33 | + protected $tagManager; |
|
34 | 34 | |
35 | - /** |
|
36 | - * @param ITagManager $tagManager |
|
37 | - */ |
|
38 | - public function __construct(ITagManager $tagManager) { |
|
39 | - $this->tagManager = $tagManager; |
|
40 | - } |
|
35 | + /** |
|
36 | + * @param ITagManager $tagManager |
|
37 | + */ |
|
38 | + public function __construct(ITagManager $tagManager) { |
|
39 | + $this->tagManager = $tagManager; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * Returns an array with the favorites |
|
44 | - * |
|
45 | - * @param string $user |
|
46 | - * @return array |
|
47 | - * @throws \RuntimeException when too many or no favorites where found |
|
48 | - */ |
|
49 | - public function getFavoriteFilePaths($user) { |
|
50 | - $tags = $this->tagManager->load('files', [], false, $user); |
|
51 | - $favorites = $tags->getFavorites(); |
|
42 | + /** |
|
43 | + * Returns an array with the favorites |
|
44 | + * |
|
45 | + * @param string $user |
|
46 | + * @return array |
|
47 | + * @throws \RuntimeException when too many or no favorites where found |
|
48 | + */ |
|
49 | + public function getFavoriteFilePaths($user) { |
|
50 | + $tags = $this->tagManager->load('files', [], false, $user); |
|
51 | + $favorites = $tags->getFavorites(); |
|
52 | 52 | |
53 | - if (empty($favorites)) { |
|
54 | - throw new \RuntimeException('No favorites', 1); |
|
55 | - } else if (isset($favorites[self::FAVORITE_LIMIT])) { |
|
56 | - throw new \RuntimeException('Too many favorites', 2); |
|
57 | - } |
|
53 | + if (empty($favorites)) { |
|
54 | + throw new \RuntimeException('No favorites', 1); |
|
55 | + } else if (isset($favorites[self::FAVORITE_LIMIT])) { |
|
56 | + throw new \RuntimeException('Too many favorites', 2); |
|
57 | + } |
|
58 | 58 | |
59 | - // Can not DI because the user is not known on instantiation |
|
60 | - $rootFolder = \OC::$server->getUserFolder($user); |
|
61 | - $folders = $items = []; |
|
62 | - foreach ($favorites as $favorite) { |
|
63 | - $nodes = $rootFolder->getById($favorite); |
|
64 | - if (!empty($nodes)) { |
|
65 | - /** @var \OCP\Files\Node $node */ |
|
66 | - $node = array_shift($nodes); |
|
67 | - $path = substr($node->getPath(), strlen($user . '/files/')); |
|
59 | + // Can not DI because the user is not known on instantiation |
|
60 | + $rootFolder = \OC::$server->getUserFolder($user); |
|
61 | + $folders = $items = []; |
|
62 | + foreach ($favorites as $favorite) { |
|
63 | + $nodes = $rootFolder->getById($favorite); |
|
64 | + if (!empty($nodes)) { |
|
65 | + /** @var \OCP\Files\Node $node */ |
|
66 | + $node = array_shift($nodes); |
|
67 | + $path = substr($node->getPath(), strlen($user . '/files/')); |
|
68 | 68 | |
69 | - $items[] = $path; |
|
70 | - if ($node instanceof Folder) { |
|
71 | - $folders[] = $path; |
|
72 | - } |
|
73 | - } |
|
74 | - } |
|
69 | + $items[] = $path; |
|
70 | + if ($node instanceof Folder) { |
|
71 | + $folders[] = $path; |
|
72 | + } |
|
73 | + } |
|
74 | + } |
|
75 | 75 | |
76 | - if (empty($items)) { |
|
77 | - throw new \RuntimeException('No favorites', 1); |
|
78 | - } |
|
76 | + if (empty($items)) { |
|
77 | + throw new \RuntimeException('No favorites', 1); |
|
78 | + } |
|
79 | 79 | |
80 | - return [ |
|
81 | - 'items' => $items, |
|
82 | - 'folders' => $folders, |
|
83 | - ]; |
|
84 | - } |
|
80 | + return [ |
|
81 | + 'items' => $items, |
|
82 | + 'folders' => $folders, |
|
83 | + ]; |
|
84 | + } |
|
85 | 85 | } |
@@ -64,7 +64,7 @@ |
||
64 | 64 | if (!empty($nodes)) { |
65 | 65 | /** @var \OCP\Files\Node $node */ |
66 | 66 | $node = array_shift($nodes); |
67 | - $path = substr($node->getPath(), strlen($user . '/files/')); |
|
67 | + $path = substr($node->getPath(), strlen($user.'/files/')); |
|
68 | 68 | |
69 | 69 | $items[] = $path; |
70 | 70 | if ($node instanceof Folder) { |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FileChanged implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'file_changed'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'file_changed'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file or folder has been <strong>changed</strong> or <strong>renamed</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file or folder has been <strong>changed</strong> or <strong>renamed</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 1; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 1; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FileCreated implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'file_created'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'file_created'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A new file or folder has been <strong>created</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A new file or folder has been <strong>created</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 0; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 0; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FavoriteAction implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'favorite'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'favorite'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('A file has been added to or removed from your <strong>favorites</strong>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('A file has been added to or removed from your <strong>favorites</strong>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 5; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 5; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return true; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return true; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return true; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return true; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -27,72 +27,72 @@ |
||
27 | 27 | |
28 | 28 | class FileFavorite implements ISetting { |
29 | 29 | |
30 | - /** @var IL10N */ |
|
31 | - protected $l; |
|
30 | + /** @var IL10N */ |
|
31 | + protected $l; |
|
32 | 32 | |
33 | - /** |
|
34 | - * @param IL10N $l |
|
35 | - */ |
|
36 | - public function __construct(IL10N $l) { |
|
37 | - $this->l = $l; |
|
38 | - } |
|
33 | + /** |
|
34 | + * @param IL10N $l |
|
35 | + */ |
|
36 | + public function __construct(IL10N $l) { |
|
37 | + $this->l = $l; |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * @return string Lowercase a-z and underscore only identifier |
|
42 | - * @since 11.0.0 |
|
43 | - */ |
|
44 | - public function getIdentifier() { |
|
45 | - return 'file_favorite'; |
|
46 | - } |
|
40 | + /** |
|
41 | + * @return string Lowercase a-z and underscore only identifier |
|
42 | + * @since 11.0.0 |
|
43 | + */ |
|
44 | + public function getIdentifier() { |
|
45 | + return 'file_favorite'; |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * @return string A translated string |
|
50 | - * @since 11.0.0 |
|
51 | - */ |
|
52 | - public function getName() { |
|
53 | - return $this->l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'); |
|
54 | - } |
|
48 | + /** |
|
49 | + * @return string A translated string |
|
50 | + * @since 11.0.0 |
|
51 | + */ |
|
52 | + public function getName() { |
|
53 | + return $this->l->t('Limit notifications about creation and changes to your <strong>favorite files</strong> <em>(Stream only)</em>'); |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the filter should be rather on the top or bottom of |
|
58 | - * the admin section. The filters are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * @since 11.0.0 |
|
61 | - */ |
|
62 | - public function getPriority() { |
|
63 | - return 2; |
|
64 | - } |
|
56 | + /** |
|
57 | + * @return int whether the filter should be rather on the top or bottom of |
|
58 | + * the admin section. The filters are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * @since 11.0.0 |
|
61 | + */ |
|
62 | + public function getPriority() { |
|
63 | + return 2; |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * @return bool True when the option can be changed for the stream |
|
68 | - * @since 11.0.0 |
|
69 | - */ |
|
70 | - public function canChangeStream() { |
|
71 | - return true; |
|
72 | - } |
|
66 | + /** |
|
67 | + * @return bool True when the option can be changed for the stream |
|
68 | + * @since 11.0.0 |
|
69 | + */ |
|
70 | + public function canChangeStream() { |
|
71 | + return true; |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @return bool True when the option can be changed for the stream |
|
76 | - * @since 11.0.0 |
|
77 | - */ |
|
78 | - public function isDefaultEnabledStream() { |
|
79 | - return false; |
|
80 | - } |
|
74 | + /** |
|
75 | + * @return bool True when the option can be changed for the stream |
|
76 | + * @since 11.0.0 |
|
77 | + */ |
|
78 | + public function isDefaultEnabledStream() { |
|
79 | + return false; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * @return bool True when the option can be changed for the mail |
|
84 | - * @since 11.0.0 |
|
85 | - */ |
|
86 | - public function canChangeMail() { |
|
87 | - return false; |
|
88 | - } |
|
82 | + /** |
|
83 | + * @return bool True when the option can be changed for the mail |
|
84 | + * @since 11.0.0 |
|
85 | + */ |
|
86 | + public function canChangeMail() { |
|
87 | + return false; |
|
88 | + } |
|
89 | 89 | |
90 | - /** |
|
91 | - * @return bool True when the option can be changed for the stream |
|
92 | - * @since 11.0.0 |
|
93 | - */ |
|
94 | - public function isDefaultEnabledMail() { |
|
95 | - return false; |
|
96 | - } |
|
90 | + /** |
|
91 | + * @return bool True when the option can be changed for the stream |
|
92 | + * @since 11.0.0 |
|
93 | + */ |
|
94 | + public function isDefaultEnabledMail() { |
|
95 | + return false; |
|
96 | + } |
|
97 | 97 | } |
98 | 98 |
@@ -29,23 +29,23 @@ |
||
29 | 29 | use OCP\Util; |
30 | 30 | |
31 | 31 | class SettingsController extends Controller { |
32 | - public function __construct($appName, IRequest $request) { |
|
33 | - parent::__construct($appName, $request); |
|
34 | - } |
|
32 | + public function __construct($appName, IRequest $request) { |
|
33 | + parent::__construct($appName, $request); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * @param string $maxUploadSize |
|
38 | - * @return JSONResponse |
|
39 | - */ |
|
40 | - public function setMaxUploadSize($maxUploadSize) { |
|
41 | - $setMaxSize = \OC_Files::setUploadLimit(Util::computerFileSize($maxUploadSize)); |
|
36 | + /** |
|
37 | + * @param string $maxUploadSize |
|
38 | + * @return JSONResponse |
|
39 | + */ |
|
40 | + public function setMaxUploadSize($maxUploadSize) { |
|
41 | + $setMaxSize = \OC_Files::setUploadLimit(Util::computerFileSize($maxUploadSize)); |
|
42 | 42 | |
43 | - if ($setMaxSize === false) { |
|
44 | - return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
45 | - } else { |
|
46 | - return new JSONResponse([ |
|
47 | - 'maxUploadSize' => Util::humanFileSize($setMaxSize) |
|
48 | - ]); |
|
49 | - } |
|
50 | - } |
|
43 | + if ($setMaxSize === false) { |
|
44 | + return new JSONResponse([], Http::STATUS_BAD_REQUEST); |
|
45 | + } else { |
|
46 | + return new JSONResponse([ |
|
47 | + 'maxUploadSize' => Util::humanFileSize($setMaxSize) |
|
48 | + ]); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | } elseif ($file->isMounted()) { |
76 | 76 | $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external'); |
77 | 77 | } |
78 | - }else{ |
|
78 | + } else{ |
|
79 | 79 | $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype()); |
80 | 80 | } |
81 | 81 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | 'freeSpace' => $storageInfo['free'], |
59 | 59 | 'quota' => $storageInfo['quota'], |
60 | 60 | 'used' => $storageInfo['used'], |
61 | - 'usedSpacePercent' => (int)$storageInfo['relative'], |
|
61 | + 'usedSpacePercent' => (int) $storageInfo['relative'], |
|
62 | 62 | 'owner' => $storageInfo['owner'], |
63 | 63 | 'ownerDisplayName' => $storageInfo['ownerDisplayName'], |
64 | 64 | ]; |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return string icon URL |
72 | 72 | */ |
73 | 73 | public static function determineIcon($file) { |
74 | - if($file['type'] === 'dir') { |
|
74 | + if ($file['type'] === 'dir') { |
|
75 | 75 | $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir'); |
76 | 76 | // TODO: move this part to the client side, using mountType |
77 | 77 | if ($file->isShared()) { |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | } elseif ($file->isMounted()) { |
80 | 80 | $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external'); |
81 | 81 | } |
82 | - }else{ |
|
82 | + } else { |
|
83 | 83 | $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype()); |
84 | 84 | } |
85 | 85 | |
86 | - return substr($icon, 0, -3) . 'svg'; |
|
86 | + return substr($icon, 0, -3).'svg'; |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -39,232 +39,232 @@ |
||
39 | 39 | * Helper class for manipulating file information |
40 | 40 | */ |
41 | 41 | class Helper { |
42 | - /** |
|
43 | - * @param string $dir |
|
44 | - * @return array |
|
45 | - * @throws \OCP\Files\NotFoundException |
|
46 | - */ |
|
47 | - public static function buildFileStorageStatistics($dir) { |
|
48 | - // information about storage capacities |
|
49 | - $storageInfo = \OC_Helper::getStorageInfo($dir); |
|
50 | - $l = \OC::$server->getL10N('files'); |
|
51 | - $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); |
|
52 | - $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); |
|
53 | - $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); |
|
42 | + /** |
|
43 | + * @param string $dir |
|
44 | + * @return array |
|
45 | + * @throws \OCP\Files\NotFoundException |
|
46 | + */ |
|
47 | + public static function buildFileStorageStatistics($dir) { |
|
48 | + // information about storage capacities |
|
49 | + $storageInfo = \OC_Helper::getStorageInfo($dir); |
|
50 | + $l = \OC::$server->getL10N('files'); |
|
51 | + $maxUploadFileSize = \OCP\Util::maxUploadFilesize($dir, $storageInfo['free']); |
|
52 | + $maxHumanFileSize = \OCP\Util::humanFileSize($maxUploadFileSize); |
|
53 | + $maxHumanFileSize = $l->t('Upload (max. %s)', array($maxHumanFileSize)); |
|
54 | 54 | |
55 | - return [ |
|
56 | - 'uploadMaxFilesize' => $maxUploadFileSize, |
|
57 | - 'maxHumanFilesize' => $maxHumanFileSize, |
|
58 | - 'freeSpace' => $storageInfo['free'], |
|
59 | - 'quota' => $storageInfo['quota'], |
|
60 | - 'used' => $storageInfo['used'], |
|
61 | - 'usedSpacePercent' => (int)$storageInfo['relative'], |
|
62 | - 'owner' => $storageInfo['owner'], |
|
63 | - 'ownerDisplayName' => $storageInfo['ownerDisplayName'], |
|
64 | - ]; |
|
65 | - } |
|
55 | + return [ |
|
56 | + 'uploadMaxFilesize' => $maxUploadFileSize, |
|
57 | + 'maxHumanFilesize' => $maxHumanFileSize, |
|
58 | + 'freeSpace' => $storageInfo['free'], |
|
59 | + 'quota' => $storageInfo['quota'], |
|
60 | + 'used' => $storageInfo['used'], |
|
61 | + 'usedSpacePercent' => (int)$storageInfo['relative'], |
|
62 | + 'owner' => $storageInfo['owner'], |
|
63 | + 'ownerDisplayName' => $storageInfo['ownerDisplayName'], |
|
64 | + ]; |
|
65 | + } |
|
66 | 66 | |
67 | - /** |
|
68 | - * Determine icon for a given file |
|
69 | - * |
|
70 | - * @param \OCP\Files\FileInfo $file file info |
|
71 | - * @return string icon URL |
|
72 | - */ |
|
73 | - public static function determineIcon($file) { |
|
74 | - if($file['type'] === 'dir') { |
|
75 | - $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir'); |
|
76 | - // TODO: move this part to the client side, using mountType |
|
77 | - if ($file->isShared()) { |
|
78 | - $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-shared'); |
|
79 | - } elseif ($file->isMounted()) { |
|
80 | - $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external'); |
|
81 | - } |
|
82 | - }else{ |
|
83 | - $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype()); |
|
84 | - } |
|
67 | + /** |
|
68 | + * Determine icon for a given file |
|
69 | + * |
|
70 | + * @param \OCP\Files\FileInfo $file file info |
|
71 | + * @return string icon URL |
|
72 | + */ |
|
73 | + public static function determineIcon($file) { |
|
74 | + if($file['type'] === 'dir') { |
|
75 | + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir'); |
|
76 | + // TODO: move this part to the client side, using mountType |
|
77 | + if ($file->isShared()) { |
|
78 | + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-shared'); |
|
79 | + } elseif ($file->isMounted()) { |
|
80 | + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon('dir-external'); |
|
81 | + } |
|
82 | + }else{ |
|
83 | + $icon = \OC::$server->getMimeTypeDetector()->mimeTypeIcon($file->getMimetype()); |
|
84 | + } |
|
85 | 85 | |
86 | - return substr($icon, 0, -3) . 'svg'; |
|
87 | - } |
|
86 | + return substr($icon, 0, -3) . 'svg'; |
|
87 | + } |
|
88 | 88 | |
89 | - /** |
|
90 | - * Comparator function to sort files alphabetically and have |
|
91 | - * the directories appear first |
|
92 | - * |
|
93 | - * @param \OCP\Files\FileInfo $a file |
|
94 | - * @param \OCP\Files\FileInfo $b file |
|
95 | - * @return int -1 if $a must come before $b, 1 otherwise |
|
96 | - */ |
|
97 | - public static function compareFileNames(FileInfo $a, FileInfo $b) { |
|
98 | - $aType = $a->getType(); |
|
99 | - $bType = $b->getType(); |
|
100 | - if ($aType === 'dir' and $bType !== 'dir') { |
|
101 | - return -1; |
|
102 | - } elseif ($aType !== 'dir' and $bType === 'dir') { |
|
103 | - return 1; |
|
104 | - } else { |
|
105 | - return \OCP\Util::naturalSortCompare($a->getName(), $b->getName()); |
|
106 | - } |
|
107 | - } |
|
89 | + /** |
|
90 | + * Comparator function to sort files alphabetically and have |
|
91 | + * the directories appear first |
|
92 | + * |
|
93 | + * @param \OCP\Files\FileInfo $a file |
|
94 | + * @param \OCP\Files\FileInfo $b file |
|
95 | + * @return int -1 if $a must come before $b, 1 otherwise |
|
96 | + */ |
|
97 | + public static function compareFileNames(FileInfo $a, FileInfo $b) { |
|
98 | + $aType = $a->getType(); |
|
99 | + $bType = $b->getType(); |
|
100 | + if ($aType === 'dir' and $bType !== 'dir') { |
|
101 | + return -1; |
|
102 | + } elseif ($aType !== 'dir' and $bType === 'dir') { |
|
103 | + return 1; |
|
104 | + } else { |
|
105 | + return \OCP\Util::naturalSortCompare($a->getName(), $b->getName()); |
|
106 | + } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Comparator function to sort files by date |
|
111 | - * |
|
112 | - * @param \OCP\Files\FileInfo $a file |
|
113 | - * @param \OCP\Files\FileInfo $b file |
|
114 | - * @return int -1 if $a must come before $b, 1 otherwise |
|
115 | - */ |
|
116 | - public static function compareTimestamp(FileInfo $a, FileInfo $b) { |
|
117 | - $aTime = $a->getMTime(); |
|
118 | - $bTime = $b->getMTime(); |
|
119 | - return ($aTime < $bTime) ? -1 : 1; |
|
120 | - } |
|
109 | + /** |
|
110 | + * Comparator function to sort files by date |
|
111 | + * |
|
112 | + * @param \OCP\Files\FileInfo $a file |
|
113 | + * @param \OCP\Files\FileInfo $b file |
|
114 | + * @return int -1 if $a must come before $b, 1 otherwise |
|
115 | + */ |
|
116 | + public static function compareTimestamp(FileInfo $a, FileInfo $b) { |
|
117 | + $aTime = $a->getMTime(); |
|
118 | + $bTime = $b->getMTime(); |
|
119 | + return ($aTime < $bTime) ? -1 : 1; |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Comparator function to sort files by size |
|
124 | - * |
|
125 | - * @param \OCP\Files\FileInfo $a file |
|
126 | - * @param \OCP\Files\FileInfo $b file |
|
127 | - * @return int -1 if $a must come before $b, 1 otherwise |
|
128 | - */ |
|
129 | - public static function compareSize(FileInfo $a, FileInfo $b) { |
|
130 | - $aSize = $a->getSize(); |
|
131 | - $bSize = $b->getSize(); |
|
132 | - return ($aSize < $bSize) ? -1 : 1; |
|
133 | - } |
|
122 | + /** |
|
123 | + * Comparator function to sort files by size |
|
124 | + * |
|
125 | + * @param \OCP\Files\FileInfo $a file |
|
126 | + * @param \OCP\Files\FileInfo $b file |
|
127 | + * @return int -1 if $a must come before $b, 1 otherwise |
|
128 | + */ |
|
129 | + public static function compareSize(FileInfo $a, FileInfo $b) { |
|
130 | + $aSize = $a->getSize(); |
|
131 | + $bSize = $b->getSize(); |
|
132 | + return ($aSize < $bSize) ? -1 : 1; |
|
133 | + } |
|
134 | 134 | |
135 | - /** |
|
136 | - * Formats the file info to be returned as JSON to the client. |
|
137 | - * |
|
138 | - * @param \OCP\Files\FileInfo $i |
|
139 | - * @return array formatted file info |
|
140 | - */ |
|
141 | - public static function formatFileInfo(FileInfo $i) { |
|
142 | - $entry = array(); |
|
135 | + /** |
|
136 | + * Formats the file info to be returned as JSON to the client. |
|
137 | + * |
|
138 | + * @param \OCP\Files\FileInfo $i |
|
139 | + * @return array formatted file info |
|
140 | + */ |
|
141 | + public static function formatFileInfo(FileInfo $i) { |
|
142 | + $entry = array(); |
|
143 | 143 | |
144 | - $entry['id'] = $i['fileid']; |
|
145 | - $entry['parentId'] = $i['parent']; |
|
146 | - $entry['mtime'] = $i['mtime'] * 1000; |
|
147 | - // only pick out the needed attributes |
|
148 | - $entry['name'] = $i->getName(); |
|
149 | - $entry['permissions'] = $i['permissions']; |
|
150 | - $entry['mimetype'] = $i['mimetype']; |
|
151 | - $entry['size'] = $i['size']; |
|
152 | - $entry['type'] = $i['type']; |
|
153 | - $entry['etag'] = $i['etag']; |
|
154 | - if (isset($i['tags'])) { |
|
155 | - $entry['tags'] = $i['tags']; |
|
156 | - } |
|
157 | - if (isset($i['displayname_owner'])) { |
|
158 | - $entry['shareOwner'] = $i['displayname_owner']; |
|
159 | - } |
|
160 | - if (isset($i['is_share_mount_point'])) { |
|
161 | - $entry['isShareMountPoint'] = $i['is_share_mount_point']; |
|
162 | - } |
|
163 | - $mountType = null; |
|
164 | - $mount = $i->getMountPoint(); |
|
165 | - $mountType = $mount->getMountType(); |
|
166 | - if ($mountType !== '') { |
|
167 | - if ($i->getInternalPath() === '') { |
|
168 | - $mountType .= '-root'; |
|
169 | - } |
|
170 | - $entry['mountType'] = $mountType; |
|
171 | - } |
|
172 | - if (isset($i['extraData'])) { |
|
173 | - $entry['extraData'] = $i['extraData']; |
|
174 | - } |
|
175 | - return $entry; |
|
176 | - } |
|
144 | + $entry['id'] = $i['fileid']; |
|
145 | + $entry['parentId'] = $i['parent']; |
|
146 | + $entry['mtime'] = $i['mtime'] * 1000; |
|
147 | + // only pick out the needed attributes |
|
148 | + $entry['name'] = $i->getName(); |
|
149 | + $entry['permissions'] = $i['permissions']; |
|
150 | + $entry['mimetype'] = $i['mimetype']; |
|
151 | + $entry['size'] = $i['size']; |
|
152 | + $entry['type'] = $i['type']; |
|
153 | + $entry['etag'] = $i['etag']; |
|
154 | + if (isset($i['tags'])) { |
|
155 | + $entry['tags'] = $i['tags']; |
|
156 | + } |
|
157 | + if (isset($i['displayname_owner'])) { |
|
158 | + $entry['shareOwner'] = $i['displayname_owner']; |
|
159 | + } |
|
160 | + if (isset($i['is_share_mount_point'])) { |
|
161 | + $entry['isShareMountPoint'] = $i['is_share_mount_point']; |
|
162 | + } |
|
163 | + $mountType = null; |
|
164 | + $mount = $i->getMountPoint(); |
|
165 | + $mountType = $mount->getMountType(); |
|
166 | + if ($mountType !== '') { |
|
167 | + if ($i->getInternalPath() === '') { |
|
168 | + $mountType .= '-root'; |
|
169 | + } |
|
170 | + $entry['mountType'] = $mountType; |
|
171 | + } |
|
172 | + if (isset($i['extraData'])) { |
|
173 | + $entry['extraData'] = $i['extraData']; |
|
174 | + } |
|
175 | + return $entry; |
|
176 | + } |
|
177 | 177 | |
178 | - /** |
|
179 | - * Format file info for JSON |
|
180 | - * @param \OCP\Files\FileInfo[] $fileInfos file infos |
|
181 | - * @return array |
|
182 | - */ |
|
183 | - public static function formatFileInfos($fileInfos) { |
|
184 | - $files = array(); |
|
185 | - foreach ($fileInfos as $i) { |
|
186 | - $files[] = self::formatFileInfo($i); |
|
187 | - } |
|
178 | + /** |
|
179 | + * Format file info for JSON |
|
180 | + * @param \OCP\Files\FileInfo[] $fileInfos file infos |
|
181 | + * @return array |
|
182 | + */ |
|
183 | + public static function formatFileInfos($fileInfos) { |
|
184 | + $files = array(); |
|
185 | + foreach ($fileInfos as $i) { |
|
186 | + $files[] = self::formatFileInfo($i); |
|
187 | + } |
|
188 | 188 | |
189 | - return $files; |
|
190 | - } |
|
189 | + return $files; |
|
190 | + } |
|
191 | 191 | |
192 | - /** |
|
193 | - * Retrieves the contents of the given directory and |
|
194 | - * returns it as a sorted array of FileInfo. |
|
195 | - * |
|
196 | - * @param string $dir path to the directory |
|
197 | - * @param string $sortAttribute attribute to sort on |
|
198 | - * @param bool $sortDescending true for descending sort, false otherwise |
|
199 | - * @param string $mimetypeFilter limit returned content to this mimetype or mimepart |
|
200 | - * @return \OCP\Files\FileInfo[] files |
|
201 | - */ |
|
202 | - public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') { |
|
203 | - $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter); |
|
192 | + /** |
|
193 | + * Retrieves the contents of the given directory and |
|
194 | + * returns it as a sorted array of FileInfo. |
|
195 | + * |
|
196 | + * @param string $dir path to the directory |
|
197 | + * @param string $sortAttribute attribute to sort on |
|
198 | + * @param bool $sortDescending true for descending sort, false otherwise |
|
199 | + * @param string $mimetypeFilter limit returned content to this mimetype or mimepart |
|
200 | + * @return \OCP\Files\FileInfo[] files |
|
201 | + */ |
|
202 | + public static function getFiles($dir, $sortAttribute = 'name', $sortDescending = false, $mimetypeFilter = '') { |
|
203 | + $content = \OC\Files\Filesystem::getDirectoryContent($dir, $mimetypeFilter); |
|
204 | 204 | |
205 | - return self::sortFiles($content, $sortAttribute, $sortDescending); |
|
206 | - } |
|
205 | + return self::sortFiles($content, $sortAttribute, $sortDescending); |
|
206 | + } |
|
207 | 207 | |
208 | - /** |
|
209 | - * Populate the result set with file tags |
|
210 | - * |
|
211 | - * @param array $fileList |
|
212 | - * @param string $fileIdentifier identifier attribute name for values in $fileList |
|
213 | - * @param ITagManager $tagManager |
|
214 | - * @return array file list populated with tags |
|
215 | - */ |
|
216 | - public static function populateTags(array $fileList, $fileIdentifier = 'fileid', ITagManager $tagManager) { |
|
217 | - $ids = []; |
|
218 | - foreach ($fileList as $fileData) { |
|
219 | - $ids[] = $fileData[$fileIdentifier]; |
|
220 | - } |
|
221 | - $tagger = $tagManager->load('files'); |
|
222 | - $tags = $tagger->getTagsForObjects($ids); |
|
208 | + /** |
|
209 | + * Populate the result set with file tags |
|
210 | + * |
|
211 | + * @param array $fileList |
|
212 | + * @param string $fileIdentifier identifier attribute name for values in $fileList |
|
213 | + * @param ITagManager $tagManager |
|
214 | + * @return array file list populated with tags |
|
215 | + */ |
|
216 | + public static function populateTags(array $fileList, $fileIdentifier = 'fileid', ITagManager $tagManager) { |
|
217 | + $ids = []; |
|
218 | + foreach ($fileList as $fileData) { |
|
219 | + $ids[] = $fileData[$fileIdentifier]; |
|
220 | + } |
|
221 | + $tagger = $tagManager->load('files'); |
|
222 | + $tags = $tagger->getTagsForObjects($ids); |
|
223 | 223 | |
224 | - if (!is_array($tags)) { |
|
225 | - throw new \UnexpectedValueException('$tags must be an array'); |
|
226 | - } |
|
224 | + if (!is_array($tags)) { |
|
225 | + throw new \UnexpectedValueException('$tags must be an array'); |
|
226 | + } |
|
227 | 227 | |
228 | - // Set empty tag array |
|
229 | - foreach ($fileList as $key => $fileData) { |
|
230 | - $fileList[$key]['tags'] = []; |
|
231 | - } |
|
228 | + // Set empty tag array |
|
229 | + foreach ($fileList as $key => $fileData) { |
|
230 | + $fileList[$key]['tags'] = []; |
|
231 | + } |
|
232 | 232 | |
233 | - if (!empty($tags)) { |
|
234 | - foreach ($tags as $fileId => $fileTags) { |
|
233 | + if (!empty($tags)) { |
|
234 | + foreach ($tags as $fileId => $fileTags) { |
|
235 | 235 | |
236 | - foreach ($fileList as $key => $fileData) { |
|
237 | - if ($fileId !== $fileData[$fileIdentifier]) { |
|
238 | - continue; |
|
239 | - } |
|
236 | + foreach ($fileList as $key => $fileData) { |
|
237 | + if ($fileId !== $fileData[$fileIdentifier]) { |
|
238 | + continue; |
|
239 | + } |
|
240 | 240 | |
241 | - $fileList[$key]['tags'] = $fileTags; |
|
242 | - } |
|
243 | - } |
|
244 | - } |
|
241 | + $fileList[$key]['tags'] = $fileTags; |
|
242 | + } |
|
243 | + } |
|
244 | + } |
|
245 | 245 | |
246 | - return $fileList; |
|
247 | - } |
|
246 | + return $fileList; |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * Sort the given file info array |
|
251 | - * |
|
252 | - * @param \OCP\Files\FileInfo[] $files files to sort |
|
253 | - * @param string $sortAttribute attribute to sort on |
|
254 | - * @param bool $sortDescending true for descending sort, false otherwise |
|
255 | - * @return \OCP\Files\FileInfo[] sorted files |
|
256 | - */ |
|
257 | - public static function sortFiles($files, $sortAttribute = 'name', $sortDescending = false) { |
|
258 | - $sortFunc = 'compareFileNames'; |
|
259 | - if ($sortAttribute === 'mtime') { |
|
260 | - $sortFunc = 'compareTimestamp'; |
|
261 | - } else if ($sortAttribute === 'size') { |
|
262 | - $sortFunc = 'compareSize'; |
|
263 | - } |
|
264 | - usort($files, array(Helper::class, $sortFunc)); |
|
265 | - if ($sortDescending) { |
|
266 | - $files = array_reverse($files); |
|
267 | - } |
|
268 | - return $files; |
|
269 | - } |
|
249 | + /** |
|
250 | + * Sort the given file info array |
|
251 | + * |
|
252 | + * @param \OCP\Files\FileInfo[] $files files to sort |
|
253 | + * @param string $sortAttribute attribute to sort on |
|
254 | + * @param bool $sortDescending true for descending sort, false otherwise |
|
255 | + * @return \OCP\Files\FileInfo[] sorted files |
|
256 | + */ |
|
257 | + public static function sortFiles($files, $sortAttribute = 'name', $sortDescending = false) { |
|
258 | + $sortFunc = 'compareFileNames'; |
|
259 | + if ($sortAttribute === 'mtime') { |
|
260 | + $sortFunc = 'compareTimestamp'; |
|
261 | + } else if ($sortAttribute === 'size') { |
|
262 | + $sortFunc = 'compareSize'; |
|
263 | + } |
|
264 | + usort($files, array(Helper::class, $sortFunc)); |
|
265 | + if ($sortDescending) { |
|
266 | + $files = array_reverse($files); |
|
267 | + } |
|
268 | + return $files; |
|
269 | + } |
|
270 | 270 | } |