mirror of
https://github.com/standardebooks/web.git
synced 2025-07-22 15:24:46 -04:00
Add support for alternate spellings in new artwork form
This commit is contained in:
parent
6c647f7371
commit
51672e7177
3 changed files with 15 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
|||
CREATE TABLE `ArtistAlternateSpellings` (
|
||||
`ArtistId` int(10) unsigned NOT NULL,
|
||||
`AlternateSpelling` varchar(255) NOT NULL,
|
||||
UNIQUE KEY `idxUnique` (`ArtistId`,`AlternateSpelling`)
|
||||
`Name` varchar(255) NOT NULL,
|
||||
`UrlName` varchar(255) NOT NULL,
|
||||
UNIQUE KEY `idxUnique` (`ArtistId`,`Name`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
|
|
@ -46,7 +46,7 @@ class Artist extends PropertiesBase{
|
|||
', [$this->ArtistId]);
|
||||
|
||||
foreach($result as $row){
|
||||
$this->_AlternateSpellings[] = $row->AlternateSpelling;
|
||||
$this->_AlternateSpellings[] = $row->Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,10 +115,12 @@ class Artist extends PropertiesBase{
|
|||
*/
|
||||
public static function GetOrCreate(Artist $artist): Artist{
|
||||
$result = Db::Query('
|
||||
SELECT *
|
||||
from Artists
|
||||
where UrlName = ?
|
||||
', [$artist->UrlName], 'Artist');
|
||||
SELECT a.*
|
||||
from Artists a
|
||||
inner join ArtistAlternateSpellings aas using (ArtistId)
|
||||
where a.UrlName = ?
|
||||
or aas.UrlName = ?
|
||||
', [$artist->UrlName, $artist->UrlName], 'Artist');
|
||||
|
||||
if(isset($result[0])){
|
||||
return $result[0];
|
||||
|
|
|
@ -76,8 +76,11 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
<span>Name</span>
|
||||
<span>For existing artists, leave the year of death blank.</span>
|
||||
<datalist id="artist-names">
|
||||
<? foreach(Library::GetAllArtists() as $existingArtist){ ?>
|
||||
<option value="<?= Formatter::ToPlainText($existingArtist->Name) ?>"><?= Formatter::ToPlainText($existingArtist->Name) ?>, d. <? if($existingArtist->DeathYear !== null){ ?><?= $existingArtist->DeathYear ?><? }else{ ?>unknown<? } ?></option>
|
||||
<? foreach(Library::GetAllArtists() as $artist){ ?>
|
||||
<option value="<?= Formatter::ToPlainText($artist->Name) ?>"><?= Formatter::ToPlainText($artist->Name) ?>, d. <? if($artist->DeathYear !== null){ ?><?= $artist->DeathYear ?><? }else{ ?>unknown<? } ?></option>
|
||||
<? foreach($artist->AlternateSpellings as $alternateSpelling){ ?>
|
||||
<option value="<?= Formatter::ToPlainText($alternateSpelling) ?>"><?= Formatter::ToPlainText($alternateSpelling) ?>, d. <? if($artist->DeathYear !== null){ ?><?= $artist->DeathYear ?><? }else{ ?>unknown<? } ?></option>
|
||||
<? } ?>
|
||||
<? } ?>
|
||||
</datalist>
|
||||
<input
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue