Use wikidata description as fallback if wikipedia description is not
parsable in Wikidata fetcher Close #16
This commit is contained in:
parent
12a7937218
commit
835da05c38
@ -648,16 +648,23 @@ final class NodaWikidataFetcher {
|
||||
$tDescription = "";
|
||||
}
|
||||
|
||||
if ($tDescription !== '') {
|
||||
if ($tDescription !== '' && !empty($desc_cleaned = self::_cleanWikidataInput($tDescription))) {
|
||||
# $descs[$lang] = $tDescription;
|
||||
$desc_cleaned = self::_cleanWikidataInput($tDescription);
|
||||
if ($desc_cleaned !== '') {
|
||||
$output[$lang] = [
|
||||
'label' => self::_cleanWikidataInput((string)$data['labels'][$lang]['value']),
|
||||
'description' => '"' . $desc_cleaned . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')',
|
||||
'link' => $wikilink,
|
||||
];
|
||||
}
|
||||
$output[$lang] = [
|
||||
'label' => self::_cleanWikidataInput((string)$data['labels'][$lang]['value']),
|
||||
'description' => '"' . $desc_cleaned . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')',
|
||||
'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' => "",
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user