Fix bug in MDNodaRepository's fromString and toDbName

This commit is contained in:
Joshua Ramon Enslin 2023-04-16 02:45:56 +02:00
parent 25f6694a92
commit 82a8805363
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -82,7 +82,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
'ulan' => self::ulan,
'viaf' => self::viaf,
'wikidata' => self::wikidata,
'Wikidata' => self::wikipedia,
'Wikipedia' => self::wikipedia,
default => throw new MDpageParameterNotFromListException("Unknown noda repository: " . $input),
};
@ -125,7 +125,7 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
self::ulan => 'ulan',
self::viaf => 'viaf',
self::wikidata => 'wikidata',
self::wikipedia => 'Wikidata',
self::wikipedia => 'Wikipedia',
};
}
@ -174,6 +174,50 @@ enum MDNodaRepository implements MDValueEnumInterface, JsonSerializable {
}
/**
* Returns a link to search for a given search term.
*
* @param string $searchTerm Search term.
*
* @return string
*/
public function getSearchLink(string $searchTerm):string {
return match($this) {
self::allgemein => 'https://www.google.de/search?q=' . urlencode($searchTerm),
self::aat => 'https://www.getty.edu/vow/AATServlet?english=N&find=' . urlencode($searchTerm) . '&page=1&note=',
self::ackerbau => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|ackerbau',
self::bne => 'http://datos.bne.es/persona/' . urlencode($searchTerm),
self::bnf => 'https://catalogue.bnf.fr/resultats-auteur.do?nomAuteur=' . urlencode($searchTerm) . '+&filtre=1&pageRech=rau',
self::cona => 'https://vocab.getty.edu/page/cona/' . $id,
self::editionhumboldtdigital => 'https://edition-humboldt.de/register/personen/detail.xql?normid=http://d-nb.info/gnd/' . $id,
self::gnd => 'https://portal.dnb.de/opac.htm?method=moveDown&currentResultId=' . urlencode((string)str_replace(' ', ' and ', $searchTerm)) . '%26any&categoryId=subjects',
self::grobsystematik => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|grobsystematik',
self::iconclass => 'http://iconclass.org/rkd/48C51/?q=' . urlencode($searchTerm) . '&q_s=1',
self::lcsh => 'https://id.loc.gov/search/?q=cs:http://id.loc.gov/authorities/subjects&q=' . urlencode($searchTerm),
self::loc => 'https://id.loc.gov/search/?q=cs:http://id.loc.gov/authorities/subjects&q=' . urlencode($searchTerm),
self::mbl => 'http://www.uni-magdeburg.de/mbl/PHP_Skripte/mbl_verwaltung/mbl_verw_anzeige_biog.php?auswahl=3&liste_biog_name=' . $id,
self::mindatorg => 'https://www.mindat.org/search.php?search=' . urlencode($searchTerm) . '&q_s=1',
self::moebeltypologie => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|moebel',
self::ndb_adb => 'https://www.deutsche-biographie.de/pnd' . $id . '.html',
self::ndl => 'https://id.ndl.go.jp/auth/ndlna/' . urlencode($searchTerm),
self::ndp_ikmk => 'https://ikmk.smb.museum/ndp/land/' . $id,
self::nomisma => 'https://nomisma.org/browse?q=' . urlencode($searchTerm),
self::npg => 'https://www.npg.org.uk/collections/search/person/' . urlencode($searchTerm),
self::oberbegriffsdatei => 'https://term.museum-digital.de/redir.php?search=' . urlencode($searchTerm) . '&kind=tag|oberbegriffsdatei',
self::orcid => 'https://orcid.org/' . $id,
self::osm => 'https://www.openstreetmap.org/relation/' . $id,
self::pim => 'https://opac-nevter.pim.hu/en/record/-/record/' . $id,
self::pleiades => 'https://pleiades.stoa.org/places/' . $id,
self::rkd => 'https://rkd.nl/en/explore#query=' . urlencode($searchTerm),
self::ulan => 'https://vocab.getty.edu/page/ulan/' . $id,
self::viaf => 'https://viaf.org/viaf/search?query=local.names+all+' . urlencode('"' . $searchTerm . '"') . '"&sortKeys=holdingscount&recordSchema=BriefVIAF',
self::wikidata => 'https://www.wikidata.org/w/index.php?search=&search=' . urlencode($searchTerm) . '&ns0=1&ns120=1',
self::wikipedia => 'https://en.wikipedia.org/w/index.php?search=' . urlencode($searchTerm),
};
}
/**
* Validates a numeric ID, returning a string or false.
*