Skip to content

Commit

Permalink
Add tab-specific config settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz committed Dec 18, 2024
1 parent 595fb33 commit 57df838
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
8 changes: 8 additions & 0 deletions config/vufind/channels.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ default_home_source = "Solr"
; Should we cache channel results on the Channels/Home screen?
cache_home_channels = true

; This section controls behavior of the Channels record tab.
[RecordTab]
; What text should display in the tab itself?
label = "Channels"

; Should we include the channels search control in the tab?
include_channels_search_box = false

; This section controls which providers are used for Solr searches/records.
; Providers may be followed by a colon and the name of a configuration section
; to use. If no configuration section is provided, the default of
Expand Down
19 changes: 14 additions & 5 deletions module/VuFind/src/VuFind/RecordTab/Channels.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,20 @@
*/
class Channels extends AbstractBase
{
/**
* Config sections in channels.ini to use for loading channel settings.
*
* @var array
*/
protected array $configSections = ['recordTab', 'record'];

/**
* Constructor
*
* @param ChannelLoader $loader Channel loader
* @param ChannelLoader $loader Channel loader
* @param array $options Config settings
*/
public function __construct(protected ChannelLoader $loader)
public function __construct(protected ChannelLoader $loader, protected array $options = [])
{
}

Expand All @@ -58,7 +66,7 @@ public function __construct(protected ChannelLoader $loader)
*/
public function getDescription()
{
return 'Channels';
return $this->options['label'] ?? 'Channels';
}

/**
Expand All @@ -82,12 +90,13 @@ public function getContext()
$request = $this->getRequest() ?: null;
$query = $request?->getQuery();
$driver = $this->getRecordDriver();
return $this->loader->getRecordContext(
$context = ['displaySearchBox' => $this->options['include_channels_search_box'] ?? false];
return $context + $this->loader->getRecordContext(
$driver->getUniqueID(),
$query?->get('channelToken'),
$query?->get('channelProvider'),
$driver->getSearchBackendIdentifier(),
['recordTab', 'record']
$this->configSections
);
}
}
3 changes: 2 additions & 1 deletion module/VuFind/src/VuFind/RecordTab/ChannelsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public function __invoke(
if (!empty($options)) {
throw new \Exception('Unexpected options passed to factory.');
}
return new $requestedName($container->get(ChannelLoader::class));
$config = $container->get(\VuFind\Config\PluginManager::class)->get('channels')->toArray();
return new $requestedName($container->get(ChannelLoader::class), $config['RecordTab'] ?? []);
}
}
2 changes: 1 addition & 1 deletion themes/bootstrap3/templates/channels/channelList.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
?>

<?php if (empty($token)): ?>
<?php if (empty($token) && ($displaySearchBox ?? true)): ?>
<form action="<?=$this->url('channels-search')?>" class="channel-search form-inline">
<?=$this->transEsc('channel_searchbox_label')?>
<input type="text" name="lookfor" class="form-control" value="<?=$this->escapeHtmlAttr($this->lookfor) ?>" aria-label="<?=$this->transEscAttr('search_terms') ?>">
Expand Down
2 changes: 1 addition & 1 deletion themes/bootstrap5/templates/channels/channelList.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
?>

<?php if (empty($token)): ?>
<?php if (empty($token) && ($displaySearchBox ?? true)): ?>
<form action="<?=$this->url('channels-search')?>" class="channel-search form-inline">
<?=$this->transEsc('channel_searchbox_label')?>
<input type="text" name="lookfor" class="form-control" value="<?=$this->escapeHtmlAttr($this->lookfor) ?>" aria-label="<?=$this->transEscAttr('search_terms') ?>">
Expand Down

0 comments on commit 57df838

Please sign in to comment.