diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2020-07-09 10:48:09 +0300 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2020-07-09 11:12:53 +0300 |
commit | 1cf3280c8e7efb4d9072ce4b57e99581cdeec744 (patch) | |
tree | 66aac12b15c1d9ece8b83655b55160d85d0d8d86 /apps/files_sharing/lib | |
parent | f3768e2a2a3b4dc898d1760ff7bba1e9ef743fa2 (diff) |
Lazy register the navigation
This makes sure that we do not translate unneeded strings on for example
webdav requests.
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r-- | apps/files_sharing/lib/AppInfo/Application.php | 109 |
1 files changed, 56 insertions, 53 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php index 98515409186..34cde50c438 100644 --- a/apps/files_sharing/lib/AppInfo/Application.php +++ b/apps/files_sharing/lib/AppInfo/Application.php @@ -161,72 +161,75 @@ class Application extends App { protected function setupSharingMenus() { $config = \OC::$server->getConfig(); - $l = \OC::$server->getL10N('files_sharing'); if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') { return; } - $sharingSublistArray = []; + // show_Quick_Access stored as string + \OCA\Files\App::getNavigationManager()->add(function () { + $config = \OC::$server->getConfig(); + $l = \OC::$server->getL10N('files_sharing'); - if (\OCP\Util::isSharingDisabledForUser() === false) { - array_push($sharingSublistArray, [ - 'id' => 'sharingout', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 16, - 'name' => $l->t('Shared with others'), - ]); - } + $sharingSublistArray = []; - array_push($sharingSublistArray, [ - 'id' => 'sharingin', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 15, - 'name' => $l->t('Shared with you'), - ]); - - if (\OCP\Util::isSharingDisabledForUser() === false) { - // Check if sharing by link is enabled - if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { - array_push($sharingSublistArray, [ - 'id' => 'sharinglinks', + if (\OCP\Util::isSharingDisabledForUser() === false) { + $sharingSublistArray[] = [ + 'id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', - 'order' => 17, - 'name' => $l->t('Shared by link'), - ]); + 'order' => 16, + 'name' => $l->t('Shared with others'), + ]; } - } - array_push($sharingSublistArray, [ - 'id' => 'deletedshares', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 19, - 'name' => $l->t('Deleted shares'), - ]); + $sharingSublistArray[] = [ + 'id' => 'sharingin', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 15, + 'name' => $l->t('Shared with you'), + ]; + + if (\OCP\Util::isSharingDisabledForUser() === false) { + // Check if sharing by link is enabled + if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') { + $sharingSublistArray[] = [ + 'id' => 'sharinglinks', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 17, + 'name' => $l->t('Shared by link'), + ]; + } + } - array_push($sharingSublistArray, [ - 'id' => 'pendingshares', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 19, - 'name' => $l->t('Pending shares'), - ]); + $sharingSublistArray[] = [ + 'id' => 'deletedshares', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 19, + 'name' => $l->t('Deleted shares'), + ]; + $sharingSublistArray[] = [ + 'id' => 'pendingshares', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 19, + 'name' => $l->t('Pending shares'), + ]; - // show_Quick_Access stored as string - \OCA\Files\App::getNavigationManager()->add([ - 'id' => 'shareoverview', - 'appname' => 'files_sharing', - 'script' => 'list.php', - 'order' => 18, - 'name' => $l->t('Shares'), - 'classes' => 'collapsible', - 'sublist' => $sharingSublistArray, - 'expandedState' => 'show_sharing_menu' - ]); + return [ + 'id' => 'shareoverview', + 'appname' => 'files_sharing', + 'script' => 'list.php', + 'order' => 18, + 'name' => $l->t('Shares'), + 'classes' => 'collapsible', + 'sublist' => $sharingSublistArray, + 'expandedState' => 'show_sharing_menu' + ]; + }); } } |