diff --git a/src/NodaWikidataFetcher.php b/src/NodaWikidataFetcher.php index 98d9bc7..11e6aa6 100644 --- a/src/NodaWikidataFetcher.php +++ b/src/NodaWikidataFetcher.php @@ -83,9 +83,38 @@ final class NodaWikidataFetcher { '
_retrievalMode = $retrievalMode;
+
+ }
+
/**
* Validates a Wikidata ID. A Wikidata ID must start with a capital Q and be
* numeric otherwise.
@@ -549,25 +578,24 @@ final class NodaWikidataFetcher {
$cinfo = $cergebnis->fetch_assoc();
if (!empty($cinfo['persinst_kurzinfo']) and substr($cinfo['persinst_kurzinfo'], 0, 3) !== 'GND') {
- if (isset($_GET['keep'])) {
- if (!$_GET['keep'] || $_GET['keep'] === 'replace') {
+ switch ($this->_retrievalMode) {
+ case "add":
- $updatePersinstStmt->bind_param("si", $datafromwiki, $persinst_id);
- $updatePersinstStmt->execute();
-
- }
- else if ($_GET['keep'] === 'add') {
-
- $newDesc = $cinfo['persinst_kurzinfo'] . PHP_EOL . PHP_EOL . $datafromwiki;
-
- $updatePersinstStmt->bind_param("si", $newDesc, $persinst_id);
- $updatePersinstStmt->execute();
-
- }
+ $newDesc = $cinfo['persinst_kurzinfo'] . PHP_EOL . PHP_EOL . $datafromwiki;
+ $updatePersinstStmt->bind_param("si", $newDesc, $persinst_id);
+ $updatePersinstStmt->execute();
$output = true;
- }
- else {
+ break;
+
+ case "replace":
+
+ $updatePersinstStmt->bind_param("si", $datafromwiki, $persinst_id);
+ $updatePersinstStmt->execute();
+ $output = true;
+ break;
+
+ default:
$tlLoader = new MDTlLoader("wiki_getter_persinst", $preflang);
echo self::generateHTMLHeadForWikidataFetcher($lang);
@@ -585,7 +613,7 @@ final class NodaWikidataFetcher {
echo '
Replace with new entry';
echo '
Keep old and add new entry
';
- exit;
+ exit;
}
@@ -939,20 +967,14 @@ final class NodaWikidataFetcher {
if (!empty(trim($curPlaceInfo['ort_anmerkung'])) and substr($curPlaceInfo['ort_anmerkung'], 0, 3) !== 'GND') {
- if (isset($_GET['keep'])) {
-
- if ($_GET['keep'] === 'add') {
-
- $datafromwiki = $curPlaceInfo['ort_anmerkung'] . PHP_EOL . PHP_EOL . $datafromwiki;
-
- }
- else if ($_GET['keep'] === 'keep') {
- $datafromwiki = $curPlaceInfo['ort_anmerkung'];
- }
-
- }
- else {
-
+ switch ($this->_retrievalMode) {
+ case "add":
+ $datafromwiki = $curPlaceInfo['ort_anmerkung'] . PHP_EOL . PHP_EOL . $datafromwiki;
+ break;
+ case "keep":
+ $datafromwiki = $curPlaceInfo['ort_anmerkung'];
+ break;
+ default:
$tlLoader = new MDTlLoader("wiki_getter_place", $preflang);
echo self::generateHTMLHeadForWikidataFetcher($lang);
echo self::generateWikidataFetcherHeader($tlLoader);
@@ -1349,25 +1371,24 @@ final class NodaWikidataFetcher {
if (!empty($cinfo['tag_anmerkung']) and substr($cinfo['tag_anmerkung'], 0, 3) !== 'GND') {
- if (isset($_GET['keep'])) {
- if (!$_GET['keep'] || $_GET['keep'] === 'replace') {
+ switch ($this->_retrievalMode) {
+ case "add":
- $updateTagDescStmt->bind_param("si", $datafromwiki, $tag_id);
- $updateTagDescStmt->execute();
-
- }
- else if ($_GET['keep'] === 'add') {
-
- $newDesc = $cinfo['tag_anmerkung'] . PHP_EOL . PHP_EOL . $datafromwiki;
-
- $updateTagDescStmt->bind_param("si", $newDesc, $tag_id);
- $updateTagDescStmt->execute();
-
- }
+ $newDesc = $cinfo['tag_anmerkung'] . PHP_EOL . PHP_EOL . $datafromwiki;
+ $updateTagDescStmt->bind_param("si", $newDesc, $tag_id);
+ $updateTagDescStmt->execute();
$output = true;
- }
- else {
+ break;
+
+ case "replace":
+
+ $updateTagDescStmt->bind_param("si", $datafromwiki, $tag_id);
+ $updateTagDescStmt->execute();
+ $output = true;
+ break;
+
+ default:
$tlLoader = new MDTlLoader("wiki_getter_tag", $preflang);
echo self::generateHTMLHeadForWikidataFetcher($lang);