Skip to content

Commit

Permalink
Fix sidebar config
Browse files Browse the repository at this point in the history
  • Loading branch information
UnniKohonen committed Aug 30, 2023
1 parent b72a828 commit 391fa21
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/model/VocabularyConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,21 @@ public function getPropertyLabelOverrides()
public function getDefaultSidebarView()
{
$defview = $this->resource->getLiteral('skosmos:defaultSidebarView');
$sidebarViews = $this->getSidebarViews();
if ($defview) {
$value = $defview->getValue();
if (in_array($value, ['hierarchy', 'alphabetical', 'fullalphabetical', 'changes', 'groups'])) {
if (in_array($value, $sidebarViews)) {
return $value;
} else {
return $sidebarViews[0]; // if not in sidebarViews, displaying first provided view
}
}
return 'alphabetical'; // if not defined displaying alphabetical index

if (in_array('alphabetical', $sidebarViews)) {
return 'alphabetical'; // if not defined, displaying alphabetical index
} else {
return $sidebarViews[0]; // if no alphabetical index, displaying first provided view
}
}

/**
Expand All @@ -565,13 +573,21 @@ public function getDefaultSidebarView()
public function getDefaultConceptSidebarView()
{
$defview = $this->resource->getLiteral('skosmos:defaultConceptSidebarView');
$sidebarViews = $this->getSidebarViews();
if ($defview) {
$value = $defview->getValue();
if (in_array($value, ['hierarchy', 'alphabetical', 'fullalphabetical', 'changes', 'groups'])) {
if (in_array($value, $sidebarViews)) {
return $value;
} else {
return $sidebarViews[0]; // if not in sidebarViews, displaying first provided view
}
}
return 'hierarchy'; // if not defined displaying hierachy

if (in_array('hierarchy', $sidebarViews)) {
return 'hierarchy'; // if not defined, displaying hierarchy
} else {
return $sidebarViews[0]; // if no hierarchy, displaying first provided view
}
}

/**
Expand All @@ -584,11 +600,13 @@ public function getSidebarViews()
if ($views) {
$viewsArray = array();
foreach ($views as $view) {
$viewsArray[] = $view->getValue();
if (in_array($view, array('hierarchy', 'alphabetical', 'fullalphabetical', 'changes', 'groups'))) {
$viewsArray[] = $view->getValue();
}
}
return $viewsArray;
}
return array("alphabetical", "hierarchy", "groups", "changes"); // if not defined using all views in default order
return array('alphabetical', 'hierarchy', 'groups', 'changes'); // if not defined, using all views in default order

}

Expand Down

0 comments on commit 391fa21

Please sign in to comment.