diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-09-06 16:56:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-06 16:56:14 +0200 |
commit | ff49fa4415ba5f5cb04e1521c9be0c8daf485e0c (patch) | |
tree | 69b2a8f022dffe81c95e8037e84b990629a0a790 /apps | |
parent | 36b2d3dc2a7978a3f19b9888bb03ecd2f566f59e (diff) | |
parent | 2397ea72196de42a79e2a5873dcbb07db698f348 (diff) | |
download | nextcloud-server-ff49fa4415ba5f5cb04e1521c9be0c8daf485e0c.tar.gz nextcloud-server-ff49fa4415ba5f5cb04e1521c9be0c8daf485e0c.zip |
Merge pull request #29881 from nextcloud/fix/setting/accessibility-title
Improve accessibility of the title of the settings
Diffstat (limited to 'apps')
-rw-r--r-- | apps/settings/lib/Controller/CommonSettingsTrait.php | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php index 4a15b0c7a32..942d07154c4 100644 --- a/apps/settings/lib/Controller/CommonSettingsTrait.php +++ b/apps/settings/lib/Controller/CommonSettingsTrait.php @@ -33,6 +33,7 @@ use OCP\Group\ISubAdmin; use OCP\IGroupManager; use OCP\INavigationManager; use OCP\IUserSession; +use OCP\Settings\IIconSection; use OCP\Settings\IManager as ISettingsManager; use OCP\Settings\ISettings; @@ -54,28 +55,31 @@ trait CommonSettingsTrait { private $subAdmin; /** - * @param string $currentSection - * @return array + * @return array{forms: array{personal: array, admin: array}} */ - private function getNavigationParameters($currentType, $currentSection) { + private function getNavigationParameters(string $currentType, string $currentSection): array { $templateParameters = [ 'personal' => $this->formatPersonalSections($currentType, $currentSection), 'admin' => [] ]; $templateParameters['admin'] = $this->formatAdminSections( - $currentType, - $currentSection - ); + $currentType, + $currentSection + ); return [ 'forms' => $templateParameters ]; } + /** + * @param IIconSection[][] $sections + * @psam-param 'admin'|'personal' $type + * @return list<array{anchor: string, section-name: string, active: bool, icon: string}> + */ protected function formatSections(array $sections, string $currentSection, string $type, string $currentType): array { $templateParameters = []; - /** @var \OCP\Settings\IIconSection[] $prioritizedSections */ foreach ($sections as $prioritizedSections) { foreach ($prioritizedSections as $section) { if ($type === 'admin') { @@ -105,21 +109,17 @@ trait CommonSettingsTrait { protected function formatPersonalSections(string $currentType, string $currentSections): array { $sections = $this->settingsManager->getPersonalSections(); - $templateParameters = $this->formatSections($sections, $currentSections, 'personal', $currentType); - - return $templateParameters; + return $this->formatSections($sections, $currentSections, 'personal', $currentType); } protected function formatAdminSections(string $currentType, string $currentSections): array { $sections = $this->settingsManager->getAdminSections(); - $templateParameters = $this->formatSections($sections, $currentSections, 'admin', $currentType); - - return $templateParameters; + return $this->formatSections($sections, $currentSections, 'admin', $currentType); } /** * @param array<int, list<\OCP\Settings\ISettings>> $settings - * @return array + * @return array{content: string} */ private function formatSettings(array $settings): array { $html = ''; @@ -133,7 +133,7 @@ trait CommonSettingsTrait { return ['content' => $html]; } - private function getIndexResponse($type, $section) { + private function getIndexResponse(string $type, string $section): TemplateResponse { if ($type === 'personal') { $this->navigationManager->setActiveEntry('settings'); } elseif ($type === 'admin') { @@ -143,6 +143,10 @@ trait CommonSettingsTrait { $templateParams = []; $templateParams = array_merge($templateParams, $this->getNavigationParameters($type, $section)); $templateParams = array_merge($templateParams, $this->getSettings($section)); + $activeSection = $this->settingsManager->getSection($type, $section); + if ($activeSection) { + $templateParams['pageTitle'] = $activeSection->getName(); + } return new TemplateResponse('settings', 'settings/frame', $templateParams); } |