From 90e58b7fb3aae0db4d5017a93e04e37387c4fb30 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 12 Aug 2016 17:08:32 +0200 Subject: [PATCH] mark current section --- settings/Controller/AdminSettingsController.php | 17 +++++++++++------ settings/templates/admin/frame.php | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/settings/Controller/AdminSettingsController.php b/settings/Controller/AdminSettingsController.php index 271aa05265b..3efe481ca9e 100644 --- a/settings/Controller/AdminSettingsController.php +++ b/settings/Controller/AdminSettingsController.php @@ -72,7 +72,7 @@ class AdminSettingsController extends Controller { $this->navigationManager->setActiveEntry('admin'); $templateParams = []; - $templateParams = array_merge($templateParams, $this->getNavigationParameters()); + $templateParams = array_merge($templateParams, $this->getNavigationParameters($section)); $templateParams = array_merge($templateParams, $this->getSettings($section)); return new TemplateResponse('settings', 'admin/frame', $templateParams); @@ -126,15 +126,20 @@ class AdminSettingsController extends Controller { return ['content' => $out->fetchPage()]; } - private function getNavigationParameters() { - $a = 'anchor'; - $name = 'section-name'; - + /** + * @param string $currentSection + * @return array + */ + private function getNavigationParameters($currentSection) { $sections = $this->settingsManager->getAdminSections(); $templateParameters = []; foreach($sections as $prioritizedSections) { foreach ($prioritizedSections as $section) { - $templateParameters[] = [$a => $section->getID(), $name => $section->getName()]; + $templateParameters[] = [ + 'anchor' => $section->getID(), + 'section-name' => $section->getName(), + 'active' => $section->getID() === $currentSection, + ]; } } diff --git a/settings/templates/admin/frame.php b/settings/templates/admin/frame.php index e0fee1555a3..1d9f6dc7a78 100644 --- a/settings/templates/admin/frame.php +++ b/settings/templates/admin/frame.php @@ -36,7 +36,8 @@ vendor_style('select2/select2'); if (isset($form['anchor'])) { $anchor = \OC::$server->getURLGenerator()->linkToRoute('settings.AdminSettings.index', ['section' => $form['anchor']]); $sectionName = $form['section-name']; - print_unescaped(sprintf("
  • %s
  • ", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName))); + $active = $form['active'] ? ' class="active"' : ''; + print_unescaped(sprintf("%s", $active, \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName))); } }?> -- 2.39.5