Use strict comparisons in NodaWikidataFetcher in remaining places

This commit is contained in:
Joshua Ramon Enslin 2022-01-16 15:18:04 +01:00
parent 03330a933c
commit e7f1515227
Signed by: jrenslin
GPG Key ID: 46016F84501B70AE

View File

@ -850,7 +850,7 @@ final class NodaWikidataFetcher {
if ($descFromWiki !== null) $tDescription = self::_cleanWikidataInput((string)$descFromWiki);
else $tDescription = "";
if (substr($tDescription, -1) == chr(10)) $tDescription = substr($tDescription, 0, strlen($tDescription) - 1);
if (substr($tDescription, -1) === chr(10)) $tDescription = substr($tDescription, 0, strlen($tDescription) - 1);
$tDescription = '"' . $tDescription . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')';
// Inhalt erster Absatz jeweilige Wikipedia: ' . $tDescription
@ -1236,7 +1236,7 @@ final class NodaWikidataFetcher {
$tDescription = self::_cleanWikidataInput((string)$descFromWiki);
if (substr($tDescription, -1) == chr(10)) $tDescription = substr($tDescription, 0, strlen($tDescription) - 1);
if (substr($tDescription, -1) === chr(10)) $tDescription = substr($tDescription, 0, strlen($tDescription) - 1);
$tDescription = '"' . $tDescription . '" - (' . $data['labels'][$lang]['language'] . '.wikipedia.org ' . date('d.m.Y') . ')';
$tDescription = str_replace("'", "´", MD_STD::preg_replace_str("/\&\#91\;[0-9]\&\#93\;/", '', $tDescription));
// echo '<br>Inhalt erster Absatz jeweilige Wikipedia: ' . $tDescription; // dies enthält den ersten Absatz der jeweiligen Wikipedia
@ -1557,7 +1557,7 @@ final class NodaWikidataFetcher {
# Process data retrieved from wikipedia
$tDescription = self::_cleanWikidataInput((string)$descFromWiki);
if (substr($tDescription, -1) == chr(10)) {
if (substr($tDescription, -1) === chr(10)) {
$tDescription = substr($tDescription, 0, strlen($tDescription) - 1);
}
@ -1675,7 +1675,7 @@ final class NodaWikidataFetcher {
*/
public static function generateWikidataResultsListEntry(string $link, string $searchTerm, string $lang, array $result):string {
if ((isset($result['label']) and $result['label'] == '') or !isset($result['label']) or (isset($result['description']) and $result['description'] === 'Wikipedia disambiguation page') or (isset($result['description']) and $result['description'] === 'Wikimedia disambiguation page')) {
if (empty($result['label']) or (isset($result['description']) and in_array($result['description'], ['Wikipedia disambiguation page', 'Wikimedia disambiguation page'], true))) {
return '';
}