diff --git a/src/NodaWikidataFetcher.php b/src/NodaWikidataFetcher.php index daded34..dd26cef 100644 --- a/src/NodaWikidataFetcher.php +++ b/src/NodaWikidataFetcher.php @@ -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' => "", + ]; + } }