Use wikidata description as fallback if wikipedia description is not

parsable in Wikidata fetcher

Close #16
This commit is contained in:
Joshua Ramon Enslin 2023-09-01 12:43:24 +02:00
parent 12a7937218
commit 835da05c38
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -648,16 +648,23 @@ final class NodaWikidataFetcher {
$tDescription = ""; $tDescription = "";
} }
if ($tDescription !== '') { if ($tDescription !== '' && !empty($desc_cleaned = self::_cleanWikidataInput($tDescription))) {
# $descs[$lang] = $tDescription; # $descs[$lang] = $tDescription;
$desc_cleaned = self::_cleanWikidataInput($tDescription);
if ($desc_cleaned !== '') {
$output[$lang] = [ $output[$lang] = [
'label' => self::_cleanWikidataInput((string)$data['labels'][$lang]['value']), 'label' => self::_cleanWikidataInput((string)$data['labels'][$lang]['value']),
'description' => '"' . $desc_cleaned . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')', 'description' => '"' . $desc_cleaned . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')',
'link' => $wikilink, 'link' => $wikilink,
]; ];
} }
// Fallback: Use Wikidata description
else if (!empty($data['labels'][$lang]['value']) and !empty($data['descriptions'][$lang])) {
$output[$lang] = [
'label' => self::_cleanWikidataInput($data['labels'][$lang]['value']),
'description' => self::_cleanWikidataInput($data['descriptions'][$lang]['value']),
'link' => "",
];
} }
} }