Compare commits
7 Commits
579404d498
...
master
Author | SHA1 | Date | |
---|---|---|---|
c4a174eb7b
|
|||
da6d9de888
|
|||
eacfa4544f
|
|||
6a99a112f4
|
|||
5fedbd898e
|
|||
58d795c806 | |||
db0aa0671b
|
@@ -24,6 +24,7 @@ final class NodaBlacklistedTerms {
|
||||
'versch.',
|
||||
'verschiedenes',
|
||||
'unbekannt',
|
||||
'_',
|
||||
'weitere',
|
||||
'weiteres',
|
||||
|
||||
@@ -41,6 +42,7 @@ final class NodaBlacklistedTerms {
|
||||
'BB',
|
||||
'CC',
|
||||
'KK',
|
||||
'K.A',
|
||||
'S',
|
||||
'N) (generell',
|
||||
'DD',
|
||||
|
@@ -10,14 +10,14 @@ declare(strict_types = 1);
|
||||
* Provides functions for easily logging updates to the main noda DB tables.
|
||||
*/
|
||||
final class NodaLogEdit {
|
||||
const ACTION_WHITELIST = [
|
||||
public const ACTION_WHITELIST = [
|
||||
'insert',
|
||||
'update',
|
||||
'merge',
|
||||
'delete',
|
||||
];
|
||||
|
||||
const SECTION_WHITELIST = [
|
||||
public const SECTION_WHITELIST = [
|
||||
'base',
|
||||
'addition',
|
||||
'noda_link',
|
||||
@@ -32,6 +32,7 @@ final class NodaLogEdit {
|
||||
'status',
|
||||
'translation',
|
||||
'group',
|
||||
'note',
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -11,7 +11,7 @@ declare(strict_types = 1);
|
||||
*/
|
||||
final class NodaValidationHelper {
|
||||
|
||||
const ACTOR_DESCRIPTION_REQUIRED_DISTINCT_CHARS = 3;
|
||||
private const ACTOR_DESCRIPTION_REQUIRED_DISTINCT_CHARS = 3;
|
||||
|
||||
/**
|
||||
* Validates an actor description for completeness. Of course, only an informed
|
||||
@@ -120,4 +120,93 @@ final class NodaValidationHelper {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an actor name is valid.
|
||||
* Returns 0 if the actor can be added as a new one / actor name can be used as a new one.
|
||||
* Returns the ID for already known actors.
|
||||
* Throws an exception if the actor is blacklisted.
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda DB connection to vocabulary.
|
||||
* @param string $lang User language.
|
||||
* @param string $persinst_name Actor name.
|
||||
* @param string $persinst_name_en Actor name (short).
|
||||
* @param string $persinst_geburtsjahr Birth year.
|
||||
* @param string $persinst_sterbejahr Death year.
|
||||
* @param string $context_identifier Context / instance identifier.
|
||||
* @param integer $institution_id Institution ID.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function checkPersinstNameIsUsable(MDMysqli $mysqli_noda, string $lang, string $persinst_name, string $persinst_name_en, string $persinst_geburtsjahr, string $persinst_sterbejahr, string $context_identifier, int $institution_id):int {
|
||||
|
||||
if ($storedType = NodaDistinctlyTypedStrings::lookup($mysqli_noda, $lang, $persinst_name_en)) {
|
||||
|
||||
if ($storedType !== 'persinst') {
|
||||
throw new MDpageParameterMissingException("This term is marked to be distinctly a " . $storedType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Special case: ? or "unbekannt" as a given name.
|
||||
if (str_starts_with($persinst_name_en, '? ') || str_starts_with(strtolower($persinst_name_en), 'unbekannt ') ) {
|
||||
throw new MDBlacklistedInputException("Term is blacklisted");
|
||||
}
|
||||
|
||||
// Check if the place name is in the current language's blacklist.
|
||||
if (NodaBlacklistedTerms::checkPersinstBlacklistedInDb($mysqli_noda, $lang, $persinst_name) === true) {
|
||||
throw new MDBlacklistedInputException("Term is blacklisted");
|
||||
}
|
||||
if (NodaBlacklistedTerms::checkPersinstBlacklistedInDb($mysqli_noda, $lang, $persinst_name_en) === true) {
|
||||
throw new MDBlacklistedInputException("Term is blacklisted");
|
||||
}
|
||||
|
||||
if ($existingPersinstId = NodaIDGetter::getPersinstIDByNamesAndRewrites($mysqli_noda, $lang, $persinst_name_en, $persinst_geburtsjahr, $persinst_sterbejahr, $context_identifier, $institution_id)) {
|
||||
return $existingPersinstId;
|
||||
}
|
||||
|
||||
if ($existingPersinstId = NodaIDGetter::getPersinstIDByNamesAndRewrites($mysqli_noda, $lang, $persinst_name, $persinst_geburtsjahr, $persinst_sterbejahr, $context_identifier, $institution_id)) {
|
||||
return $existingPersinstId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if an place name is valid.
|
||||
* Returns 0 if the place can be added as a new one / place name can be used as a new one.
|
||||
* Returns the ID for already known places.
|
||||
* Throws an exception if the place is blacklisted.
|
||||
*
|
||||
* @param MDMysqli $mysqli_noda DB connection to vocabulary.
|
||||
* @param string $lang User language.
|
||||
* @param string $place_name Place name.
|
||||
* @param string $context_identifier Context / instance identifier.
|
||||
* @param integer $institution_id Institution ID.
|
||||
*
|
||||
* @return integer
|
||||
*/
|
||||
public static function checkPlaceNameIsUsable(MDMysqli $mysqli_noda, string $lang, string $place_name, string $context_identifier, int $institution_id):int {
|
||||
|
||||
if ($storedType = NodaDistinctlyTypedStrings::lookup($mysqli_noda, $lang, $place_name)) {
|
||||
|
||||
if ($storedType !== 'orte') {
|
||||
throw new MDpageParameterMissingException("This term is marked to be distinctly a " . $storedType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Check if the place name is in the current language's blacklist.
|
||||
if (NodaBlacklistedTerms::checkPlaceBlacklistedInDb($mysqli_noda, $lang, $place_name) === true) {
|
||||
throw new MDBlacklistedInputException("Term is blacklisted");
|
||||
}
|
||||
|
||||
if ($existingPlaceId = NodaIDGetter::getPlaceIDByNamesAndRewrites($mysqli_noda, $lang, $place_name, $context_identifier, $institution_id)) {
|
||||
return $existingPlaceId;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -138,7 +138,7 @@ final class NodaWikidataFetcher {
|
||||
return '';
|
||||
}
|
||||
$firstPageId = array_keys($json_decoded['query']['pages'])[0];
|
||||
$datafromwiki = strval($json_decoded['query']['pages'][$firstPageId]['extract']);
|
||||
$datafromwiki = strval($json_decoded['query']['pages'][$firstPageId]['extract'] ?? "");
|
||||
|
||||
return self::_cleanInputSimple($datafromwiki);
|
||||
|
||||
|
Reference in New Issue
Block a user