diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 41e8fe63810..3d48b0b59e5 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1114,8 +1114,8 @@ noCoverAvailableImage = images/noCover2.gif ; the description tab. ;summaries = Syndetics:MySyndeticsId,SyndeticsPlus:MySyndeticsId -; You can select from Syndetics or SyndeticsPlus to load Tables of Contents -;toc = Syndetics:MySyndeticsId,SyndeticsPlus:MySyndeticsId +; You can select from Syndetics, SyndeticsPlus or ObalkyKnih to load Tables of Contents +;toc = Syndetics:MySyndeticsId,SyndeticsPlus:MySyndeticsId,ObalkyKnih ; You can select from Syndetics or SyndeticsPlus ;authorNotes = Syndetics:MySyndeticsId,SyndeticsPlus:MySyndeticsId diff --git a/module/VuFind/src/VuFind/Content/Loader.php b/module/VuFind/src/VuFind/Content/Loader.php index b96fa2bfbab..11e58fabe86 100644 --- a/module/VuFind/src/VuFind/Content/Loader.php +++ b/module/VuFind/src/VuFind/Content/Loader.php @@ -87,7 +87,7 @@ protected function getIsbnObject($isbn) * * @param string $isbn ISBN to use for lookup * - * @return array + * @return array|string */ public function loadByIsbn($isbn) { @@ -95,7 +95,6 @@ public function loadByIsbn($isbn) if (!($isbnObj = $this->getIsbnObject($isbn))) { return $results; } - // Fetch from provider $providers = explode(',', $this->providers); foreach ($providers as $provider) { diff --git a/module/VuFind/src/VuFind/Content/ObalkyKnihContentFactory.php b/module/VuFind/src/VuFind/Content/ObalkyKnihContentFactory.php index 141dfb84f35..6d47d71de36 100644 --- a/module/VuFind/src/VuFind/Content/ObalkyKnihContentFactory.php +++ b/module/VuFind/src/VuFind/Content/ObalkyKnihContentFactory.php @@ -72,7 +72,6 @@ public function __invoke( } $service = $container->get(\VuFind\Content\ObalkyKnihService::class); - $covers = new $requestedName($service); - return $covers; + return new $requestedName($service); } } diff --git a/module/VuFind/src/VuFind/Content/ObalkyKnihService.php b/module/VuFind/src/VuFind/Content/ObalkyKnihService.php index 754372eb494..2c4ea2b0c78 100644 --- a/module/VuFind/src/VuFind/Content/ObalkyKnihService.php +++ b/module/VuFind/src/VuFind/Content/ObalkyKnihService.php @@ -142,7 +142,7 @@ protected function getHttpClient(string $url = null) */ protected function createCacheKey(array $ids) { - $key = $ids['recordid']; + $key = $ids['recordid'] ?? ''; $key = !empty($key) ? $key : (isset($ids['isbn']) ? $ids['isbn']->get13() : null); $key = !empty($key) ? $key : sha1(json_encode($ids)); diff --git a/module/VuFind/src/VuFind/Content/TOC/ObalkyKnih.php b/module/VuFind/src/VuFind/Content/TOC/ObalkyKnih.php new file mode 100644 index 00000000000..9bf41286be3 --- /dev/null +++ b/module/VuFind/src/VuFind/Content/TOC/ObalkyKnih.php @@ -0,0 +1,80 @@ + + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ + +declare(strict_types=1); + +namespace VuFind\Content\TOC; + +use VuFind\Content\ObalkyKnihService; + +/** + * Class ObalkyKnih + * + * @category VuFind + * @package Content + * @author Josef Moravec + * @license https://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link https://vufind.org/wiki/development Wiki + */ +class ObalkyKnih extends \VuFind\Content\AbstractBase +{ + /** + * Constructor + * + * @param ObalkyKnihService $service Service for getting metadata from obalkyknih.cz + */ + public function __construct(protected ObalkyKnihService $service) + { + } + + /** + * This method is responsible for generating fake TOC data for testing + * purposes. + * + * @param string $key API key + * @param \VuFindCode\ISBN $isbnObj ISBN object + * + * @throws \Exception + * @return array|string Returns html string with preview image and link to TOC PDF file + */ + public function loadByIsbn($key, \VuFindCode\ISBN $isbnObj) + { + $ids = [ + 'isbn' => $isbnObj, + ]; + $data = $this->service->getData($ids); + $toc = ''; + if (isset($data->toc_thumbnail_url)) { + $toc = "

"; + } + return $toc; + } +} diff --git a/module/VuFind/src/VuFind/Content/TOC/PluginManager.php b/module/VuFind/src/VuFind/Content/TOC/PluginManager.php index c49fb1d8220..4d3d2678a77 100644 --- a/module/VuFind/src/VuFind/Content/TOC/PluginManager.php +++ b/module/VuFind/src/VuFind/Content/TOC/PluginManager.php @@ -47,6 +47,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager */ protected $aliases = [ 'demo' => Demo::class, + 'obalkyknih' => ObalkyKnih::class, 'syndetics' => Syndetics::class, 'syndeticsplus' => SyndeticsPlus::class, ]; @@ -58,6 +59,7 @@ class PluginManager extends \VuFind\ServiceManager\AbstractPluginManager */ protected $factories = [ Demo::class => \Laminas\ServiceManager\Factory\InvokableFactory::class, + ObalkyKnih::class => \VuFind\Content\ObalkyKnihContentFactory::class, Syndetics::class => \VuFind\Content\AbstractSyndeticsFactory::class, SyndeticsPlus::class => \VuFind\Content\AbstractSyndeticsFactory::class, ]; diff --git a/module/VuFind/src/VuFind/RecordTab/AbstractContent.php b/module/VuFind/src/VuFind/RecordTab/AbstractContent.php index e026c7d04c7..4312dabbce1 100644 --- a/module/VuFind/src/VuFind/RecordTab/AbstractContent.php +++ b/module/VuFind/src/VuFind/RecordTab/AbstractContent.php @@ -96,7 +96,7 @@ public function isActive() /** * Get content for ISBN. * - * @return array + * @return array|string */ public function getContent() {