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>
This commit is contained in:
parent
f3768e2a2a
commit
1cf3280c8e
|
@ -153,28 +153,34 @@ class Application extends App implements IBootstrap {
|
||||||
private function registerNavigation(IBootContext $context): void {
|
private function registerNavigation(IBootContext $context): void {
|
||||||
/** @var IL10N $l10n */
|
/** @var IL10N $l10n */
|
||||||
$l10n = $context->getAppContainer()->query(IL10N::class);
|
$l10n = $context->getAppContainer()->query(IL10N::class);
|
||||||
\OCA\Files\App::getNavigationManager()->add([
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
||||||
'id' => 'files',
|
return [
|
||||||
'appname' => 'files',
|
'id' => 'files',
|
||||||
'script' => 'list.php',
|
'appname' => 'files',
|
||||||
'order' => 0,
|
'script' => 'list.php',
|
||||||
'name' => $l10n->t('All files')
|
'order' => 0,
|
||||||
]);
|
'name' => $l10n->t('All files')
|
||||||
\OCA\Files\App::getNavigationManager()->add([
|
];
|
||||||
'id' => 'recent',
|
});
|
||||||
'appname' => 'files',
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
||||||
'script' => 'recentlist.php',
|
return [
|
||||||
'order' => 2,
|
'id' => 'recent',
|
||||||
'name' => $l10n->t('Recent')
|
'appname' => 'files',
|
||||||
]);
|
'script' => 'recentlist.php',
|
||||||
\OCA\Files\App::getNavigationManager()->add([
|
'order' => 2,
|
||||||
'id' => 'favorites',
|
'name' => $l10n->t('Recent')
|
||||||
'appname' => 'files',
|
];
|
||||||
'script' => 'simplelist.php',
|
});
|
||||||
'order' => 5,
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
||||||
'name' => $l10n->t('Favorites'),
|
return [
|
||||||
'expandedState' => 'show_Quick_Access'
|
'id' => 'favorites',
|
||||||
]);
|
'appname' => 'files',
|
||||||
|
'script' => 'simplelist.php',
|
||||||
|
'order' => 5,
|
||||||
|
'name' => $l10n->t('Favorites'),
|
||||||
|
'expandedState' => 'show_Quick_Access'
|
||||||
|
];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function registerHooks(): void {
|
private function registerHooks(): void {
|
||||||
|
|
|
@ -161,72 +161,75 @@ class Application extends App {
|
||||||
|
|
||||||
protected function setupSharingMenus() {
|
protected function setupSharingMenus() {
|
||||||
$config = \OC::$server->getConfig();
|
$config = \OC::$server->getConfig();
|
||||||
$l = \OC::$server->getL10N('files_sharing');
|
|
||||||
|
|
||||||
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
|
if ($config->getAppValue('core', 'shareapi_enabled', 'yes') !== 'yes') {
|
||||||
return;
|
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) {
|
$sharingSublistArray = [];
|
||||||
array_push($sharingSublistArray, [
|
|
||||||
'id' => 'sharingout',
|
|
||||||
'appname' => 'files_sharing',
|
|
||||||
'script' => 'list.php',
|
|
||||||
'order' => 16,
|
|
||||||
'name' => $l->t('Shared with others'),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
array_push($sharingSublistArray, [
|
if (\OCP\Util::isSharingDisabledForUser() === false) {
|
||||||
'id' => 'sharingin',
|
$sharingSublistArray[] = [
|
||||||
'appname' => 'files_sharing',
|
'id' => 'sharingout',
|
||||||
'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',
|
|
||||||
'appname' => 'files_sharing',
|
'appname' => 'files_sharing',
|
||||||
'script' => 'list.php',
|
'script' => 'list.php',
|
||||||
'order' => 17,
|
'order' => 16,
|
||||||
'name' => $l->t('Shared by link'),
|
'name' => $l->t('Shared with others'),
|
||||||
]);
|
];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
array_push($sharingSublistArray, [
|
$sharingSublistArray[] = [
|
||||||
'id' => 'deletedshares',
|
'id' => 'sharingin',
|
||||||
'appname' => 'files_sharing',
|
'appname' => 'files_sharing',
|
||||||
'script' => 'list.php',
|
'script' => 'list.php',
|
||||||
'order' => 19,
|
'order' => 15,
|
||||||
'name' => $l->t('Deleted shares'),
|
'name' => $l->t('Shared with you'),
|
||||||
]);
|
];
|
||||||
|
|
||||||
array_push($sharingSublistArray, [
|
if (\OCP\Util::isSharingDisabledForUser() === false) {
|
||||||
'id' => 'pendingshares',
|
// Check if sharing by link is enabled
|
||||||
'appname' => 'files_sharing',
|
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === 'yes') {
|
||||||
'script' => 'list.php',
|
$sharingSublistArray[] = [
|
||||||
'order' => 19,
|
'id' => 'sharinglinks',
|
||||||
'name' => $l->t('Pending shares'),
|
'appname' => 'files_sharing',
|
||||||
]);
|
'script' => 'list.php',
|
||||||
|
'order' => 17,
|
||||||
|
'name' => $l->t('Shared by link'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sharingSublistArray[] = [
|
||||||
|
'id' => 'deletedshares',
|
||||||
|
'appname' => 'files_sharing',
|
||||||
|
'script' => 'list.php',
|
||||||
|
'order' => 19,
|
||||||
|
'name' => $l->t('Deleted shares'),
|
||||||
|
];
|
||||||
|
|
||||||
// show_Quick_Access stored as string
|
$sharingSublistArray[] = [
|
||||||
\OCA\Files\App::getNavigationManager()->add([
|
'id' => 'pendingshares',
|
||||||
'id' => 'shareoverview',
|
'appname' => 'files_sharing',
|
||||||
'appname' => 'files_sharing',
|
'script' => 'list.php',
|
||||||
'script' => 'list.php',
|
'order' => 19,
|
||||||
'order' => 18,
|
'name' => $l->t('Pending shares'),
|
||||||
'name' => $l->t('Shares'),
|
];
|
||||||
'classes' => 'collapsible',
|
|
||||||
'sublist' => $sharingSublistArray,
|
return [
|
||||||
'expandedState' => 'show_sharing_menu'
|
'id' => 'shareoverview',
|
||||||
]);
|
'appname' => 'files_sharing',
|
||||||
|
'script' => 'list.php',
|
||||||
|
'order' => 18,
|
||||||
|
'name' => $l->t('Shares'),
|
||||||
|
'classes' => 'collapsible',
|
||||||
|
'sublist' => $sharingSublistArray,
|
||||||
|
'expandedState' => 'show_sharing_menu'
|
||||||
|
];
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue