Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2021-11-24 16:08:16 +0300
committerCarl Schwan <carl@carlschwan.eu>2022-05-16 23:47:37 +0300
commit046d5451b15d46581cde846676e0b6d631fedbb7 (patch)
treeab0c48dc23940de1b6edbff9f2b1243e1c911b19 /apps/settings/lib
parentab0548e4edb1d2cf47718f752272d68aa6be07e2 (diff)
Improve accessibility of the title of the settings
Before every setting page had the same title and this is causing issues for screenreaders since they can't differenciate the title of page. Now a new variable is available for apps to declare the page subtitle. This new variable is implemented for the settings app and while at it I added a bit more type hinting to the stuff I touched :) Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'apps/settings/lib')
-rw-r--r--apps/settings/lib/Controller/CommonSettingsTrait.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/apps/settings/lib/Controller/CommonSettingsTrait.php b/apps/settings/lib/Controller/CommonSettingsTrait.php
index 2eb7b4ccf99..7cb706bb3a6 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,11 +133,15 @@ trait CommonSettingsTrait {
return ['content' => $html];
}
- private function getIndexResponse($type, $section) {
+ private function getIndexResponse(string $type, string $section): TemplateResponse {
$this->navigationManager->setActiveEntry('settings');
$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);
}