mark current section

This commit is contained in:
Arthur Schiwon 2016-08-12 17:08:32 +02:00
parent 0fdf801c25
commit 90e58b7fb3
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 13 additions and 7 deletions

View File

@ -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,
];
}
}

View File

@ -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("<li><a href='%s'>%s</a></li>", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
$active = $form['active'] ? ' class="active"' : '';
print_unescaped(sprintf("<li%s><a href='%s'>%s</a></li>", $active, \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
}
}?>
</ul>