Tweak wording on delete artist page and add some more breadcrumbs

This commit is contained in:
Alex Cabal 2025-03-07 10:37:56 -06:00
parent 1136cfb2af
commit 34fd71e55a
11 changed files with 83 additions and 19 deletions

View file

@ -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]

View file

@ -1,5 +1,11 @@
RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
RewriteRule ^/artworks/([^\./]+?)$ /artists/get.php?artist-url-name=$1 [L] 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$/" RewriteCond expr "tolower(%{REQUEST_METHOD}) =~ /^get$/"
RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L] RewriteRule ^/artworks/([^/\.]+)/([^/\.]+)$ /artworks/get.php?artist-url-name=$1&artwork-url-name=$2 [L]

View file

@ -220,7 +220,6 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites
Include ${conf_rewrite_root}/feeds.conf Include ${conf_rewrite_root}/feeds.conf
Include ${conf_rewrite_root}/ebooks.conf Include ${conf_rewrite_root}/ebooks.conf
Include ${conf_rewrite_root}/newsletters.conf Include ${conf_rewrite_root}/newsletters.conf
Include ${conf_rewrite_root}/artists.conf
Include ${conf_rewrite_root}/artworks.conf Include ${conf_rewrite_root}/artworks.conf
Include ${conf_rewrite_root}/polls.conf Include ${conf_rewrite_root}/polls.conf
Include ${conf_rewrite_root}/users.conf Include ${conf_rewrite_root}/users.conf

View file

@ -202,7 +202,6 @@ Define conf_rewrite_root ${web_root}/config/apache/rewrites
Include ${conf_rewrite_root}/feeds.conf Include ${conf_rewrite_root}/feeds.conf
Include ${conf_rewrite_root}/ebooks.conf Include ${conf_rewrite_root}/ebooks.conf
Include ${conf_rewrite_root}/newsletters.conf Include ${conf_rewrite_root}/newsletters.conf
Include ${conf_rewrite_root}/artists.conf
Include ${conf_rewrite_root}/artworks.conf Include ${conf_rewrite_root}/artworks.conf
Include ${conf_rewrite_root}/polls.conf Include ${conf_rewrite_root}/polls.conf
Include ${conf_rewrite_root}/users.conf Include ${conf_rewrite_root}/users.conf

View file

@ -6,7 +6,8 @@ use Safe\DateTimeImmutable;
* @property ?string $UrlName * @property ?string $UrlName
* @property ?string $Url * @property ?string $Url
* @property string $DeleteUrl * @property string $DeleteUrl
* @property ?array<string> $AlternateNames * @property array<string> $AlternateNames
* @property string $AlternateNamesString
*/ */
class Artist{ class Artist{
use Traits\Accessor; use Traits\Accessor;
@ -23,6 +24,7 @@ class Artist{
protected string $_DeleteUrl; protected string $_DeleteUrl;
/** @var array<string> $_AlternateNames */ /** @var array<string> $_AlternateNames */
protected array $_AlternateNames; protected array $_AlternateNames;
protected string $_AlternateNamesString;
// ******* // *******
@ -47,7 +49,7 @@ class Artist{
} }
protected function GetDeleteUrl(): string{ 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; 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 // METHODS
@ -217,6 +254,13 @@ class Artist{
set ArtistId = ? set ArtistId = ?
where ArtistId = ? where ArtistId = ?
', [$canonicalArtist->ArtistId, $this->ArtistId]); ', [$canonicalArtist->ArtistId, $this->ArtistId]);
Db::Query('
UPDATE
ArtistAlternateNames
set ArtistId = ?
where ArtistId = ?
', [$canonicalArtist->ArtistId, $this->ArtistId]);
} }
/** /**

View file

@ -3,5 +3,5 @@ namespace Exceptions;
class ArtistAlternateNameExistsException extends AppException{ class ArtistAlternateNameExistsException extends AppException{
/** @var string $message */ /** @var string $message */
protected $message = 'Artist already has that alternate name (A.K.A.).'; protected $message = 'Artist already has that alternate name.';
} }

View file

@ -58,6 +58,7 @@ $isEditForm ??= false;
/> />
</label> </label>
<label> <label>
<input type="hidden" name="artwork-completed-year-is-circa" value="false" />
<input <input
type="checkbox" type="checkbox"
name="artwork-completed-year-is-circa" name="artwork-completed-year-is-circa"
@ -103,6 +104,7 @@ $isEditForm ??= false;
<p><strong>or</strong> proof that the artwork was reproduced in a book published before <?= PD_STRING ?>, including the following:</p> <p><strong>or</strong> proof that the artwork was reproduced in a book published before <?= PD_STRING ?>, including the following:</p>
<fieldset> <fieldset>
<label> <label>
<input type="hidden" name="artwork-is-published-in-us" value="false" />
<input <input
type="checkbox" type="checkbox"
name="artwork-is-published-in-us" name="artwork-is-published-in-us"

View file

@ -36,17 +36,17 @@ catch(Exceptions\InvalidPermissionsException){
<main> <main>
<section class="narrow"> <section class="narrow">
<nav class="breadcrumbs"> <nav class="breadcrumbs">
<a href="<?= $artist->Url ?>"><?= $artist->Name ?></a> → <a href="/artworks">Artworks</a> <a href="<?= $artist->Url ?>"><?= $artist->Name ?></a> →
</nav> </nav>
<h1>Delete</h1> <h1>Delete</h1>
<?= Template::Error(exception: $exception) ?> <?= Template::Error(exception: $exception) ?>
<form method="<?= Enums\HttpMethod::Post->value ?>" action="/artists/<?= $artist->UrlName ?>"> <p>Are you sure you want to permanently delete <?= Formatter::EscapeHtml($artist->Name) ?>?</p>
<form method="<?= Enums\HttpMethod::Post->value ?>" action="<?= $artist->Url ?>">
<input type="hidden" name="_method" value="<?= Enums\HttpMethod::Delete->value ?>" /> <input type="hidden" name="_method" value="<?= Enums\HttpMethod::Delete->value ?>" />
<p>Are you sure you want to permanently delete <?= Formatter::EscapeHtml($artist->Name) ?>?</p>
<label class="icon user"> <label class="icon user">
<span>Canonical Artist</span> <span>Canonical artist</span>
<span>Reassign artwork by <?= Formatter::EscapeHtml($artist->Name) ?> to this artist.</span> <span>Reassign artwork by <?= Formatter::EscapeHtml($artist->Name) ?> to this artist.</span>
<datalist id="artist-names-except-this-artist"> <datalist id="artist-names-except-this-artist">
<? foreach(Artist::GetAll() as $a){ ?> <? foreach(Artist::GetAll() as $a){ ?>
@ -67,14 +67,15 @@ catch(Exceptions\InvalidPermissionsException){
</label> </label>
<label> <label>
<input type="hidden" name="add-alternate-name" value="false" />
<input <input
type="checkbox" type="checkbox"
name="add-alternate-name" /> name="add-alternate-name" />
<span>Add <?= Formatter::EscapeHtml($artist->Name) ?> as an alternate name (A.K.A.) to the canonical artist</span> <span>Add <?= Formatter::EscapeHtml($artist->Name) ?> as an alternate name of the canonical artist</span>
</label> </label>
<div class="footer"> <div class="footer">
<button class="delete">Delete and Reassign</button> <button class="delete">Delete artist</button>
</div> </div>
</form> </form>
</section> </section>

View file

@ -41,10 +41,17 @@ catch(Exceptions\ArtistNotFoundException){
?><?= Template::Header(title: 'Artwork by ' . $artist->Name, css: ['/css/artwork.css']) ?> ?><?= Template::Header(title: 'Artwork by ' . $artist->Name, css: ['/css/artwork.css']) ?>
<main class="artworks"> <main class="artworks">
<section class="narrow"> <section class="narrow">
<nav class="breadcrumbs">
<a href="/artworks">Artworks</a>
</nav>
<h1>Artwork by <?= Formatter::EscapeHtml($artist->Name) ?></h1> <h1>Artwork by <?= Formatter::EscapeHtml($artist->Name) ?></h1>
<? if(sizeof($artist->AlternateNames) > 0){ ?>
<p>
<i>Also known as <?= Formatter::EscapeHtml($artist->AlternateNamesString) ?>.</i>
</p>
<? } ?>
<? if($isArtistDeleted && $deletedArtist !== null){ ?> <? if($isArtistDeleted && $deletedArtist !== null){ ?>
<p class="message success">Artist deleted: <?= $deletedArtist->Name ?><? if($isAlternateNameAdded){ ?>. An alternate name (A.K.A.) was added.<? } ?></p> <p class="message success"><?= $deletedArtist->Name ?> has been deleted<? if($isAlternateNameAdded){ ?> and their name has been added as an alternate name of <?= Formatter::EscapeHtml($artist->Name) ?><? } ?>.</p>
<? } ?> <? } ?>
<?= Template::ImageCopyrightNotice() ?> <?= Template::ImageCopyrightNotice() ?>

View file

@ -67,6 +67,10 @@ catch(Exceptions\InvalidPermissionsException){
?><?= Template::Header(title: $artwork->Name, css: ['/css/artwork.css']) ?> ?><?= Template::Header(title: $artwork->Name, css: ['/css/artwork.css']) ?>
<main class="artworks"> <main class="artworks">
<section class="narrow"> <section class="narrow">
<nav class="breadcrumbs">
<a href="/artworks">Artworks</a>
<a href="<?= $artwork->Artist->Url ?>"><?= Formatter::EscapeHtml($artwork->Artist->Name) ?></a> →
</nav>
<h1><?= Formatter::EscapeHtml($artwork->Name) ?></h1> <h1><?= Formatter::EscapeHtml($artwork->Name) ?></h1>
<?= Template::Error(exception: $exception) ?> <?= Template::Error(exception: $exception) ?>

View file

@ -49,10 +49,16 @@ if($exception){
<p>What kind of email would you like to receive?</p> <p>What kind of email would you like to receive?</p>
<ul> <ul>
<li> <li>
<label><input type="checkbox" value="true" name="is-subscribed-to-newsletter"<? if($subscription->IsSubscribedToNewsletter){ ?> checked="checked"<? } ?> />The occasional Standard Ebooks newsletter</label> <label>
<input type="hidden" name="is-subscribed-to-newsletter" value="false" />
<input type="checkbox" value="true" name="is-subscribed-to-newsletter"<? if($subscription->IsSubscribedToNewsletter){ ?> checked="checked"<? } ?> />The occasional Standard Ebooks newsletter
</label>
</li> </li>
<li> <li>
<label><input type="checkbox" value="true" name="is-subscribed-to-summary"<? if($subscription->IsSubscribedToSummary){ ?> checked="checked"<? } ?> />A monthly summary of new ebook releases</label> <label>
<input type="hidden" name="is-subscribed-to-summary" value="false" />
<input type="checkbox" value="true" name="is-subscribed-to-summary"<? if($subscription->IsSubscribedToSummary){ ?> checked="checked"<? } ?> />A monthly summary of new ebook releases
</label>
</li> </li>
</ul> </ul>
</fieldset> </fieldset>