Compare commits

...

2 Commits

2 changed files with 32 additions and 24 deletions

View File

@ -134,7 +134,7 @@ final class NodaWikidataFetcher {
$doc->loadXML('<section>' . trim($input) . '</section>');
}
catch (Exception $e) {
throw new Exception("Failed to load DOMDocument." . PHP_EOL . $e->getMessage() . PHP_EOL . PHP_EOL . $input);
throw new Exception("Failed to load DOMDocument." . PHP_EOL . $e->getMessage() . PHP_EOL . PHP_EOL . '---' . $input . '---');
}
$list = $doc->getElementsByTagName("style");
@ -224,7 +224,6 @@ final class NodaWikidataFetcher {
$input = str_replace("\t", " ", $input);
return $input;
// Remove newlines with ensuing spaces
while (strpos($input, PHP_EOL . " ") !== false) {
$input = str_replace(PHP_EOL . " ", PHP_EOL, $input);
@ -629,7 +628,7 @@ final class NodaWikidataFetcher {
$output = [];
$descs = [];
# $descs = [];
foreach ($checkagainstLanguage as $lang) {
if (!empty($languagesToFetch[$lang]) && !empty($data['sitelinks'][$lang . 'wiki']) && !empty($wikilinks[$lang])) {
@ -650,7 +649,7 @@ final class NodaWikidataFetcher {
}
if ($tDescription !== '') {
$descs[$lang] = $tDescription;
# $descs[$lang] = $tDescription;
$desc_cleaned = self::_cleanWikidataInput($tDescription);
if ($desc_cleaned !== '') {
$output[$lang] = [
@ -672,7 +671,6 @@ final class NodaWikidataFetcher {
];
}
# print_r($descs);
}
@ -1007,7 +1005,7 @@ final class NodaWikidataFetcher {
}
/**
* Gets the current description of a place.
* Returns the current description of a place.
*
* @param integer $onum Place ID.
*
@ -1029,6 +1027,29 @@ final class NodaWikidataFetcher {
}
/**
* Returns the current description of a tag.
*
* @param integer $tag_id Tag ID.
*
* @return string
*/
private function getTagDescription(int $tag_id):string {
$result = $this->_mysqli_noda->query_by_stmt("SELECT `tag_anmerkung`
FROM `tag`
WHERE `tag_id` = ?", "i", $tag_id);
if (!($cur = $result->fetch_row())) {
$result->close();
return '';
}
$result->close();
return $cur[0];
}
/**
* Function for entering base information about a place from wikidata.
*
@ -1239,14 +1260,14 @@ final class NodaWikidataFetcher {
}
if (isset($data['claims']['P625'])) {
$latitude_wd = $data['claims']['P625'][0]['mainsnak']['datavalue']['value']['latitude'];
$longitude_wd = $data['claims']['P625'][0]['mainsnak']['datavalue']['value']['longitude'];
$latitude_wd = \filter_var($data['claims']['P625'][0]['mainsnak']['datavalue']['value']['latitude'], FILTER_VALIDATE_FLOAT);
$longitude_wd = \filter_var($data['claims']['P625'][0]['mainsnak']['datavalue']['value']['longitude'], FILTER_VALIDATE_FLOAT);
}
NodaBatchInserter::linkNodaForPlace($this->_mysqli_noda, $onum, $nodaLinks, $erfasst_von);
$this->_mysqli_noda->autocommit(false);
if (!empty($tgn_id)) {
if (!empty($tgn_id) and is_numeric($tgn_id)) {
$updateStmt = $this->_mysqli_noda->do_prepare("UPDATE `orte`
SET `ort_land` = ?
@ -1257,7 +1278,7 @@ final class NodaWikidataFetcher {
unset($updateStmt);
}
if (!empty($geonames_id)) {
if (!empty($geonames_id) and is_numeric($geonames_id)) {
$updateStmt = $this->_mysqli_noda->do_prepare("UPDATE `orte`
SET `ort_geonames` = ?
@ -1342,17 +1363,7 @@ final class NodaWikidataFetcher {
$datafromwiki = '"' . $datafromwiki . '" - (Wikipedia (' . $lang . ') ' . date("d.m.Y") . ')';
$datafromwiki = str_replace("'", "´", MD_STD::preg_replace_str("/\&\#91\;[0-9]\&\#93\;/", '', $datafromwiki));
$cergebnis = $this->_mysqli_noda->query_by_stmt("SELECT `tag_anmerkung`
FROM `tag`
WHERE `tag_id` = ?", "i", $tag_id);
if (!($cinfo = $cergebnis->fetch_row())) {
$cergebnis->close();
return $output;
}
$cergebnis->close();
$tag_anmerkung = $cinfo[0];
$tag_anmerkung = $this->getTagDescription($tag_id);
$this->_mysqli_noda->autocommit(false);

View File

@ -255,9 +255,6 @@ Transclusion expansion time report (%,ms,calls,template)
"Start of parsed Wikipedia text should be:" . PHP_EOL . PHP_EOL . $expected . PHP_EOL . PHP_EOL . 'Real start text is: ' . PHP_EOL . PHP_EOL . substr($output, 0, 250)
);
}
/**