2020-09-20 22:40:40 +02:00
|
|
|
<?PHP
|
|
|
|
/**
|
|
|
|
* Contains class NodaIDGetter.
|
|
|
|
*
|
|
|
|
* @author Joshua Ramon Enslin <joshua@museum-digital.de>
|
|
|
|
*/
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Contains static functions for getting IDs for noda entries by various means.
|
|
|
|
*/
|
|
|
|
final class NodaIDGetter {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns persinst ID by entry in persinst name rewriting table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $lang Language to check in.
|
|
|
|
* @param string $name Name of the persinst to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getPersinstIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):int {
|
|
|
|
|
|
|
|
if (empty($name)) return 0;
|
|
|
|
|
|
|
|
$persinstRewriteResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `persinst_id`
|
|
|
|
FROM `persinst_rewriting`
|
|
|
|
WHERE `language` = ?
|
|
|
|
AND `input_name` = ?
|
|
|
|
LIMIT 1", "ss", $lang, $name);
|
|
|
|
|
|
|
|
if ($persinstRewriteData = $persinstRewriteResult->fetch_row()) {
|
|
|
|
$output = $persinstRewriteData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$persinstRewriteResult->close();
|
|
|
|
$persinstRewriteResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns persinst ID by entry in persinst translations table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $lang Language to check in.
|
|
|
|
* @param string $name Name of the persinst to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getPersinstIDByTransName(MDMysqli $mysqli_noda, string $lang, string $name):int {
|
|
|
|
|
|
|
|
if (empty($name)) return 0;
|
|
|
|
|
|
|
|
$persinstByTLNameResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `persinst_id`
|
|
|
|
FROM `persinst_translation`
|
|
|
|
WHERE `trans_name` = ?
|
|
|
|
AND `trans_language` = ?
|
|
|
|
LIMIT 2", "ss", $name, $lang);
|
|
|
|
|
|
|
|
if ($persinstByTlData = $persinstByTLNameResult->fetch_row()) {
|
|
|
|
$output = $persinstByTlData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$persinstByTLNameResult->close();
|
|
|
|
$persinstByTLNameResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns place ID by entry in place name rewriting table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $lang Language to check in.
|
|
|
|
* @param string $name Name of the place to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getPlaceIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):int {
|
|
|
|
|
|
|
|
if (empty($name)) return 0;
|
|
|
|
|
|
|
|
$placeRewriteResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `ort_id`
|
|
|
|
FROM `ort_rewriting`
|
|
|
|
WHERE `language` = ?
|
|
|
|
AND `input_name` = ?
|
|
|
|
LIMIT 1", "ss", $lang, $name);
|
|
|
|
|
|
|
|
if ($placeRewriteData = $placeRewriteResult->fetch_row()) {
|
|
|
|
$output = $placeRewriteData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$placeRewriteResult->close();
|
|
|
|
$placeRewriteResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns place ID by entry in place translations table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $lang Language to check in.
|
|
|
|
* @param string $name Name of the place to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getPlaceIDByTransName(MDMysqli $mysqli_noda, string $lang, string $name):int {
|
|
|
|
|
|
|
|
if (empty($name)) return 0;
|
|
|
|
|
|
|
|
$placeByTLNameResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `ort_id`
|
|
|
|
FROM `ort_translation`
|
|
|
|
WHERE `trans_name` = ?
|
|
|
|
AND `trans_language` = ?
|
|
|
|
LIMIT 2", "ss", $name, $lang);
|
|
|
|
|
|
|
|
if ($placeByTlData = $placeByTLNameResult->fetch_row()) {
|
|
|
|
$output = $placeByTlData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$placeByTLNameResult->close();
|
|
|
|
$placeByTLNameResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-10-01 12:53:27 +02:00
|
|
|
/**
|
|
|
|
* Returns place ID by entry in place noda table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $noda_source Language to check in.
|
|
|
|
* @param string $noda_nrinsource Name of the place to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getPlaceIDByNodaLink(MDMysqli $mysqli_noda, string $noda_source, string $noda_nrinsource):int {
|
|
|
|
|
2020-10-05 12:05:48 +02:00
|
|
|
if (empty($noda_nrinsource)) return 0;
|
2020-10-01 12:53:27 +02:00
|
|
|
|
|
|
|
$placeByNodaResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `ort_id`
|
|
|
|
FROM `noda_orte`
|
|
|
|
WHERE `noda_source` = ?
|
|
|
|
AND `noda_nrinsource` = ?
|
|
|
|
LIMIT 2", "ss", $noda_source, $noda_nrinsource);
|
|
|
|
|
|
|
|
if ($placeByNodaData = $placeByNodaResult->fetch_row()) {
|
|
|
|
$output = $placeByNodaData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$placeByNodaResult->close();
|
|
|
|
$placeByNodaResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-09-20 22:40:40 +02:00
|
|
|
/**
|
|
|
|
* Returns tag ID by entry in tag name rewriting table.
|
|
|
|
*
|
|
|
|
* @param MDMysqli $mysqli_noda Database connection.
|
|
|
|
* @param string $lang Language to check in.
|
|
|
|
* @param string $name Name of the tag to search for.
|
|
|
|
*
|
|
|
|
* @return integer
|
|
|
|
*/
|
|
|
|
public static function getTagIDByRewrite(MDMysqli $mysqli_noda, string $lang, string $name):int {
|
|
|
|
|
|
|
|
if (empty($name)) return 0;
|
|
|
|
|
|
|
|
$tagRewriteResult = $mysqli_noda->query_by_stmt("
|
|
|
|
SELECT `tag_id`
|
|
|
|
FROM `tag_rewriting`
|
|
|
|
WHERE `tag_language` = ?
|
|
|
|
AND `input_name` = ?
|
|
|
|
LIMIT 1", "ss", $lang, $name);
|
|
|
|
|
|
|
|
if ($tagRewriteData = $tagRewriteResult->fetch_row()) {
|
|
|
|
$output = $tagRewriteData[0];
|
|
|
|
}
|
|
|
|
else $output = 0;
|
|
|
|
|
|
|
|
$tagRewriteResult->close();
|
|
|
|
$tagRewriteResult = null;
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|