diff --git a/config/apache/rewrites/artists.conf b/config/apache/rewrites/artists.conf deleted file mode 100644 index 2391b6b8..00000000 --- a/config/apache/rewrites/artists.conf +++ /dev/null @@ -1,4 +0,0 @@ -RewriteRule ^/artists/(.+?)/delete$ /artists/delete.php?artist-url-name=$1 [L] - -RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/" -RewriteRule ^/artists/([^/\.]+)$ /artists/post.php?artist-url-name=$1 [L] diff --git a/config/apache/rewrites/artworks.conf b/config/apache/rewrites/artworks.conf index a620df06..2cfd39e3 100644 --- a/config/apache/rewrites/artworks.conf +++ b/config/apache/rewrites/artworks.conf @@ -1,5 +1,11 @@ +RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/" RewriteRule ^/artworks/([^\./]+?)$ /artists/get.php?artist-url-name=$1 [L] +RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^post$/" +RewriteRule ^/artworks/([^/\.]+)$ /artists/post.php?artist-url-name=$1 [L] + +RewriteRule ^/artworks/([^/\.]+?)/delete$ /artists/delete.php?artist-url-name=$1 [L] + RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/" RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L] diff --git a/config/apache/standardebooks.org.conf b/config/apache/standardebooks.org.conf index c801cf97..0555af7a 100644 --- a/config/apache/standardebooks.org.conf +++ b/config/apache/standardebooks.org.conf @@ -220,7 +220,6 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites Include ${conf_rewrite_root}/feeds.conf Include ${conf_rewrite_root}/ebooks.conf Include ${conf_rewrite_root}/newsletters.conf - Include ${conf_rewrite_root}/artists.conf Include ${conf_rewrite_root}/artworks.conf Include ${conf_rewrite_root}/polls.conf Include ${conf_rewrite_root}/users.conf diff --git a/config/apache/standardebooks.test.conf b/config/apache/standardebooks.test.conf index 1225ca20..13c1cc89 100644 --- a/config/apache/standardebooks.test.conf +++ b/config/apache/standardebooks.test.conf @@ -202,7 +202,6 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites Include ${conf_rewrite_root}/feeds.conf Include ${conf_rewrite_root}/ebooks.conf Include ${conf_rewrite_root}/newsletters.conf - Include ${conf_rewrite_root}/artists.conf Include ${conf_rewrite_root}/artworks.conf Include ${conf_rewrite_root}/polls.conf Include ${conf_rewrite_root}/users.conf diff --git a/lib/Artist.php b/lib/Artist.php index 4ddc1f82..14a08b17 100644 --- a/lib/Artist.php +++ b/lib/Artist.php @@ -6,7 +6,8 @@ use Safe\DateTimeImmutable; * @property ?string $UrlName * @property ?string $Url * @property string $DeleteUrl - * @property ?array $AlternateNames + * @property array $AlternateNames + * @property string $AlternateNamesString */ class Artist{ use Traits\Accessor; @@ -23,6 +24,7 @@ class Artist{ protected string $_DeleteUrl; /** @var array $_AlternateNames */ protected array $_AlternateNames; + protected string $_AlternateNamesString; // ******* @@ -47,7 +49,7 @@ class Artist{ } protected function GetDeleteUrl(): string{ - return $this->_DeleteUrl ??= '/artists/' . $this->UrlName . '/delete'; + return $this->_DeleteUrl ??= '/artworks/' . $this->UrlName . '/delete'; } /** @@ -71,6 +73,41 @@ class Artist{ return $this->_AlternateNames; } + protected function GetAlternateNamesString(): string{ + if(!isset($this->_AlternateNamesString)){ + $this->_AlternateNamesString = ''; + + $alternateNames = array_slice($this->AlternateNames, 0, -2); + $lastTwoAlternateNames = array_slice($this->AlternateNames, -2); + + foreach($alternateNames as $alternateName){ + $this->_AlternateNamesString .= $alternateName . ', '; + } + + $this->_AlternateNamesString = rtrim($this->_AlternateNamesString, ', '); + + if(sizeof($lastTwoAlternateNames) == 1){ + if(sizeof($alternateNames) > 0){ + $this->_AlternateNamesString .= ', and '; + } + + $this->_AlternateNamesString .= $lastTwoAlternateNames[0]; + } + + if(sizeof($lastTwoAlternateNames) == 2){ + if(sizeof($alternateNames) > 0){ + $this->_AlternateNamesString .= ', '; + $this->_AlternateNamesString .= $lastTwoAlternateNames[0] . ', and ' . $lastTwoAlternateNames[1]; + } + else{ + $this->_AlternateNamesString .= $lastTwoAlternateNames[0] . ' and ' . $lastTwoAlternateNames[1]; + } + } + } + + return $this->_AlternateNamesString; + } + // ******* // METHODS @@ -217,6 +254,13 @@ class Artist{ set ArtistId = ? where ArtistId = ? ', [$canonicalArtist->ArtistId, $this->ArtistId]); + + Db::Query(' + UPDATE + ArtistAlternateNames + set ArtistId = ? + where ArtistId = ? + ', [$canonicalArtist->ArtistId, $this->ArtistId]); } /** diff --git a/lib/Exceptions/ArtistAlternateNameExistsException.php b/lib/Exceptions/ArtistAlternateNameExistsException.php index 54ea9c0e..93a9bdca 100644 --- a/lib/Exceptions/ArtistAlternateNameExistsException.php +++ b/lib/Exceptions/ArtistAlternateNameExistsException.php @@ -3,5 +3,5 @@ namespace Exceptions; class ArtistAlternateNameExistsException extends AppException{ /** @var string $message */ - protected $message = 'Artist already has that alternate name (A.K.A.).'; + protected $message = 'Artist already has that alternate name.'; } diff --git a/templates/ArtworkForm.php b/templates/ArtworkForm.php index e39fc800..3f8268c3 100644 --- a/templates/ArtworkForm.php +++ b/templates/ArtworkForm.php @@ -58,6 +58,7 @@ $isEditForm ??= false; />