Skip to content

Commit

Permalink
Fix selected option highlighting in theme menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 9, 2024
1 parent 1bd821b commit b5e419e
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions module/VuFindTheme/src/VuFindTheme/Initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ public function init()
isset($this->event) ? $this->event->getRequest() : null
);

// Determine theme options:
$this->sendThemeOptionsToView($currentTheme);
// Determine theme options (note that we should use the ui cookie rather
// than the raw theme name, since options include aliases, and we want the
// user-selected alias, not the final resolved theme name):
$this->sendThemeOptionsToView($this->cookieManager->get('ui'));

// Make sure the current theme is set correctly in the tools object:
$error = null;
Expand Down Expand Up @@ -303,14 +305,29 @@ protected function getThemeOptions($currentTheme)
$options = [];
if (isset($this->config->selectable_themes)) {
$parts = explode(',', $this->config->selectable_themes);

if (isset($this->config->alternate_themes)) {
$aliases = explode(',', $this->config->alternate_themes);
}

foreach ($parts as $part) {
$subparts = explode(':', $part);
$name = trim($subparts[0]);
$displayName = $name = trim($subparts[0]);
$desc = isset($subparts[1]) ? trim($subparts[1]) : '';
$desc = empty($desc) ? $name : $desc;
$desc = empty($desc) ? $displayName : $desc;

if (!empty($aliases)) {
$key = array_search("{$name}:{$currentTheme}", $aliases);

if ($key !== false) {
$name = $currentTheme;
}
}

if (!empty($name)) {
$options[] = [
'name' => $name, 'desc' => $desc,
'name' => $displayName,
'desc' => $desc,
'selected' => ($currentTheme == $name),
];
}
Expand Down

0 comments on commit b5e419e

Please sign in to comment.