-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add record tab for displaying channels. (#4165)
- Loading branch information
1 parent
6311aa5
commit e186d90
Showing
13 changed files
with
583 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
|
||
/** | ||
* Channels tab | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package RecordTabs | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki | ||
*/ | ||
|
||
namespace VuFind\RecordTab; | ||
|
||
use VuFind\ChannelProvider\ChannelLoader; | ||
|
||
/** | ||
* Channels tab | ||
* | ||
* @category VuFind | ||
* @package RecordTabs | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development:plugins:record_tabs Wiki | ||
*/ | ||
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 array $options Config settings | ||
*/ | ||
public function __construct(protected ChannelLoader $loader, protected array $options = []) | ||
{ | ||
} | ||
|
||
/** | ||
* Get the on-screen description for this tab. | ||
* | ||
* @return string | ||
*/ | ||
public function getDescription() | ||
{ | ||
return $this->options['label'] ?? 'Channels'; | ||
} | ||
|
||
/** | ||
* Can this tab be loaded via AJAX? | ||
* | ||
* @return bool | ||
*/ | ||
public function supportsAjax() | ||
{ | ||
// Due to heavy Javascript in channels, the tab cannot be AJAX-loaded: | ||
return false; | ||
} | ||
|
||
/** | ||
* Return context variables used for rendering the block's template. | ||
* | ||
* @return array | ||
*/ | ||
public function getContext() | ||
{ | ||
$request = $this->getRequest() ?: null; | ||
$query = $request?->getQuery(); | ||
$driver = $this->getRecordDriver(); | ||
$context = ['displaySearchBox' => false]; | ||
return $context + $this->loader->getRecordContext( | ||
$driver->getUniqueID(), | ||
$query?->get('channelToken'), | ||
$query?->get('channelProvider'), | ||
$driver->getSearchBackendIdentifier(), | ||
$this->configSections | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* Factory for building the Channels tab. | ||
* | ||
* PHP version 8 | ||
* | ||
* Copyright (C) Villanova University 2024. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category VuFind | ||
* @package RecordTabs | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
|
||
namespace VuFind\RecordTab; | ||
|
||
use Laminas\ServiceManager\Exception\ServiceNotCreatedException; | ||
use Laminas\ServiceManager\Exception\ServiceNotFoundException; | ||
use Psr\Container\ContainerExceptionInterface as ContainerException; | ||
use Psr\Container\ContainerInterface; | ||
use VuFind\ChannelProvider\ChannelLoader; | ||
|
||
/** | ||
* Factory for building the Channels tab. | ||
* | ||
* @category VuFind | ||
* @package RecordTabs | ||
* @author Demian Katz <[email protected]> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://vufind.org/wiki/development Wiki | ||
*/ | ||
class ChannelsFactory implements \Laminas\ServiceManager\Factory\FactoryInterface | ||
{ | ||
/** | ||
* Create an object | ||
* | ||
* @param ContainerInterface $container Service manager | ||
* @param string $requestedName Service being created | ||
* @param null|array $options Extra options (optional) | ||
* | ||
* @return object | ||
* | ||
* @throws ServiceNotFoundException if unable to resolve the service. | ||
* @throws ServiceNotCreatedException if an exception is raised when | ||
* creating a service. | ||
* @throws ContainerException&\Throwable if any other error occurs | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function __invoke( | ||
ContainerInterface $container, | ||
$requestedName, | ||
?array $options = null | ||
) { | ||
if (!empty($options)) { | ||
throw new \Exception('Unexpected options passed to factory.'); | ||
} | ||
$config = $container->get(\VuFind\Config\PluginManager::class)->get('channels')->toArray(); | ||
return new $requestedName($container->get(ChannelLoader::class), $config['RecordTab'] ?? []); | ||
} | ||
} |
Oops, something went wrong.