diff --git a/l18n b/l18n index ead81f6..fcb79d3 160000 --- a/l18n +++ b/l18n @@ -1 +1 @@ -Subproject commit ead81f60198ef43a6914caa7ac879b85933f741f +Subproject commit fcb79d39d7f6bffa1f95684a94bc476b420942e0 diff --git a/src/MDObjectSyndicationSet.php b/src/MDObjectSyndicationSet.php new file mode 100644 index 0000000..f3ae1d2 --- /dev/null +++ b/src/MDObjectSyndicationSet.php @@ -0,0 +1,65 @@ + + */ +declare(strict_types = 1); + +/** + * Class listing syndication sources. + */ +final class MDObjectSyndicationSet extends MDValueSet { + + const REPOSITORIES = [ + + 'ddb' => [ + 'url' => 'https://www.deutsche-digitale-bibliothek.de/', + 'object_prefix' => 'https://www.deutsche-digitale-bibliothek.de/item/', + 'org_prefix' => 'https://www.deutsche-digitale-bibliothek.de/organization/', + 'id_is_int' => false, + ], + 'europeana' => [ + 'url' => 'https://www.europeana.eu/', + 'object_prefix' => 'https://www.europeana.eu/en/item/', + 'org_prefix' => null, + 'id_is_int' => false, + ], + + ]; + + /** + * Returns a correctly formed search URL for a given object in a given + * repository, optionally naming the institution. + * + * @param string $repo Repository to search in. + * @param string $instId Remote ID of the institution to search for. + * @param string $search_value Search string. + * + * @return string + */ + public function getSearchUrlForObject(string $repo, string $instId, string $search_value):string { + + switch ($repo) { + case 'ddb': + return "https://www.deutsche-digitale-bibliothek.de/searchresults?query=" . \urlencode($search_value) . "&facetValues[]=" . \urlencode("provider_id=" . $instId); + default: + throw new MDpageParameterNotFromListException("Search URLs can only be generated for the following repositories: ddb"); + } + + } + + /** + * Gets a sorted list of the entries in a translated version. + * + * @param MDTlLoader $tlLoader Translation loader. + * + * @return array + */ + public static function getSortedList(MDTlLoader $tlLoader):array { + + return parent::getTlSortedList($tlLoader, array_keys(self::REPOSITORIES), "syndication_repos", "syndication_repos"); + + } +}