Rename ArtistAlternateSpellings to ArtistAlternateNames

This commit is contained in:
Alex Cabal 2024-01-17 16:21:40 -06:00
parent f7ff76bf7d
commit f0bdd5596f
5 changed files with 18 additions and 18 deletions

View file

@ -1,4 +1,4 @@
CREATE TABLE `ArtistAlternateSpellings` (
CREATE TABLE `ArtistAlternateNames` (
`ArtistId` int(10) unsigned NOT NULL,
`Name` varchar(255) NOT NULL,
`UrlName` varchar(255) NOT NULL,

View file

@ -4,8 +4,8 @@ use function Safe\date;
/**
* @property string $UrlName
* @property array<string> $AlternateSpellings
* @property array<string> $_AlternateSpellings
* @property array<string> $AlternateNames
* @property array<string> $_AlternateNames
*/
class Artist extends PropertiesBase{
public ?int $ArtistId = null;
@ -14,7 +14,7 @@ class Artist extends PropertiesBase{
public ?datetime $Created = null;
public ?datetime $Updated = null;
protected ?string $_UrlName = null;
protected $_AlternateSpellings;
protected $_AlternateNames;
// *******
// GETTERS
@ -35,22 +35,22 @@ class Artist extends PropertiesBase{
/**
* @return array<string>
*/
protected function GetAlternateSpellings(): array{
if($this->_AlternateSpellings === null){
$this->_AlternateSpellings = [];
protected function GetAlternateNames(): array{
if($this->_AlternateNames === null){
$this->_AlternateNames = [];
$result = Db::Query('
SELECT *
from ArtistAlternateSpellings
from ArtistAlternateNames
where ArtistId = ?
', [$this->ArtistId]);
foreach($result as $row){
$this->_AlternateSpellings[] = $row->Name;
$this->_AlternateNames[] = $row->Name;
}
}
return $this->_AlternateSpellings;
return $this->_AlternateNames;
}
// *******
@ -120,9 +120,9 @@ class Artist extends PropertiesBase{
$result = Db::Query('
SELECT a.*
from Artists a
left outer join ArtistAlternateSpellings aas using (ArtistId)
left outer join ArtistAlternateNames aan using (ArtistId)
where a.UrlName = ?
or aas.UrlName = ?
or aan.UrlName = ?
limit 1
', [$artist->UrlName, $artist->UrlName], 'Artist');
@ -143,7 +143,7 @@ class Artist extends PropertiesBase{
', [$this->ArtistId]);
Db::Query('
DELETE
from ArtistAlternateSpellings
from ArtistAlternateNames
where ArtistId = ?
', [$this->ArtistId]);
}
@ -157,7 +157,7 @@ class Artist extends PropertiesBase{
');
Db::Query('
DELETE
from ArtistAlternateSpellings
from ArtistAlternateNames
where ArtistId NOT IN
(SELECT DISTINCT ArtistId FROM Artworks)
');

View file

@ -822,7 +822,7 @@ class Artwork extends PropertiesBase{
$searchString = $this->Name;
$searchString .= ' ' . $this->Artist->Name;
$searchString .= ' ' . implode(' ', $this->Artist->AlternateSpellings);
$searchString .= ' ' . implode(' ', $this->Artist->AlternateNames);
foreach($this->Tags as $tag){
$searchString .= ' ' . $tag->Name;

View file

@ -21,8 +21,8 @@ $now = new DateTime('now', new DateTimeZone('America/Juneau')); // Latest contin
<datalist id="artist-names">
<? foreach(Library::GetAllArtists() as $artist){ ?>
<option value="<?= Formatter::EscapeHtml($artist->Name) ?>"><?= Formatter::EscapeHtml($artist->Name) ?>, d. <? if($artist->DeathYear !== null){ ?><?= $artist->DeathYear ?><? }else{ ?>unknown<? } ?></option>
<? foreach($artist->AlternateSpellings as $alternateSpelling){ ?>
<option value="<?= Formatter::EscapeHtml($alternateSpelling) ?>"><?= Formatter::EscapeHtml($alternateSpelling) ?>, d. <? if($artist->DeathYear !== null){ ?><?= Formatter::EscapeHtml($artist->DeathYear) ?><? }else{ ?>unknown<? } ?></option>
<? foreach($artist->AlternateNames as $alternateName){ ?>
<option value="<?= Formatter::EscapeHtml($alternateName) ?>"><?= Formatter::EscapeHtml($alternateName) ?>, d. <? if($artist->DeathYear !== null){ ?><?= Formatter::EscapeHtml($artist->DeathYear) ?><? }else{ ?>unknown<? } ?></option>
<? } ?>
<? } ?>
</datalist>

View file

@ -74,7 +74,7 @@ catch(Exceptions\InvalidPermissionsException){
<tr>
<td>Artist</td>
<td>
<?= Formatter::EscapeHtml($artwork->Artist->Name) ?><? if(sizeof($artwork->Artist->AlternateSpellings) > 0){ ?> (A.K.A. <span class="author" typeof="schema:Person" property="schema:name"><?= implode('</span>, <span class="author" typeof="schema:Person" property="schema:name">', array_map('Formatter::EscapeHtml', $artwork->Artist->AlternateSpellings)) ?></span>)<? } ?><? if($artwork->Artist->DeathYear !== null){ ?> (<abbr>d.</abbr> <?= $artwork->Artist->DeathYear ?>)<? } ?>
<?= Formatter::EscapeHtml($artwork->Artist->Name) ?><? if(sizeof($artwork->Artist->AlternateNames) > 0){ ?> (A.K.A. <span class="author" typeof="schema:Person" property="schema:name"><?= implode('</span>, <span class="author" typeof="schema:Person" property="schema:name">', array_map('Formatter::EscapeHtml', $artwork->Artist->AlternateNames)) ?></span>)<? } ?><? if($artwork->Artist->DeathYear !== null){ ?> (<abbr>d.</abbr> <?= $artwork->Artist->DeathYear ?>)<? } ?>
</td>
</tr>
<tr>