Changes the ConfirmDelete page and updates database code.

The ConfirmDelete page now uses parts of the photopage. The
Confirmation dialog is its own template which is based on Alert.

The database now updates the album thumb to the most recent
addition to the album, when the album thumb asset is being deleted.
When there are no pictures left in the album 0 will be set.
This commit is contained in:
2018-07-08 08:19:37 +00:00
parent e40c05c1f8
commit 16ec547064
12 changed files with 197 additions and 113 deletions

View File

@@ -19,6 +19,13 @@ class Alert extends SubTemplate
{
echo '
<div class="alert', $this->_type != 'alert' ? ' alert-' . $this->_type : '', '">', (!empty($this->_title) ? '
<strong>' . $this->_title . '</strong><br>' : ''), $this->_message, '</div>';
<strong>' . $this->_title . '</strong><br>' : ''), '<p>', $this->_message, '</p>';
$this->additional_alert_content();
echo '</div>';
}
protected function additional_alert_content()
{}
}

27
templates/Button.php Normal file
View File

@@ -0,0 +1,27 @@
<?php
/*****************************************************************************
* Button.php
* Defines the Button template.
*
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
*****************************************************************************/
class Button extends SubTemplate
{
private $content = '';
private $href = '';
private $class = '';
public function __construct($content = '', $href = '', $class = '')
{
$this->content = $content;
$this->href = $href;
$this->class = $class;
}
protected function html_content()
{
echo '
<a class="', $this->class, '" href="', $this->href, '">', $this->content, '</a>';
}
}

View File

@@ -6,13 +6,11 @@
* Kabuki CMS (C) 2013-2016, Aaron van Geffen
*****************************************************************************/
class ConfirmDeletePage extends SubTemplate
class ConfirmDeletePage extends PhotoPage
{
private $photo;
public function __construct(Image $photo)
{
$this->photo = $photo;
parent::__construct($photo);
}
protected function html_content()
@@ -23,30 +21,15 @@ class ConfirmDeletePage extends SubTemplate
private function confirm()
{
echo '
<div id=confirm_box>
<h1>Confirm deletion</h1>
<p>You are about to permanently delete the following photo.</p>
<a class="btn btn-red" href="', BASEURL, '/confirmdelete?slug=', $this->photo->getSlug(), '&confirmed">Delete</a>
<a class="btn" href="', $this->photo->getPageUrl(), '"> Cancel</a>
</div>';
}
$buttons = [];
$buttons[] = new Button("Delete", BASEURL . '/' . $this->photo->getSlug() . '?delete_confirmed', "btn btn-red");
$buttons[] = new Button("Cancel", $this->photo->getPageUrl(), "btn");
private function photo()
{
echo '
<div id="photo_frame">
<a href="', $this->photo->getUrl(), '">';
if ($this->photo->isPortrait())
echo '
<img src="', $this->photo->getThumbnailUrl(null, 960), '" alt="">';
else
echo '
<img src="', $this->photo->getThumbnailUrl(1280, null), '" alt="">';
echo '
</a>
</div>';
$alert = new WarningDialog(
"Confirm deletion.",
"You are about to permanently delete the following photo.",
$buttons
);
$alert->html_content();
}
}

View File

@@ -23,7 +23,7 @@ class EditAssetForm extends SubTemplate
<form id="asset_form" action="" method="post" enctype="multipart/form-data">
<div class="boxed_content" style="margin-bottom: 2%">
<div style="float: right">
<a class="btn btn-red" href="', BASEURL, '/confirmdelete?slug=', $this->asset->getSlug(), '>Delete asset</a>
<a class="btn btn-red" href="', BASEURL, '/', $this->asset->getSlug(), '?delete_confirmed">Delete asset</a>
<input type="submit" value="Save asset data">
</div>
<h2>Edit asset \'', $this->asset->getTitle(), '\' (', $this->asset->getFilename(), ')</h2>

View File

@@ -8,7 +8,7 @@
class PhotoPage extends SubTemplate
{
private $photo;
protected $photo;
private $exif;
private $previous_photo_url = '';
private $next_photo_url = '';
@@ -29,7 +29,8 @@ class PhotoPage extends SubTemplate
$this->next_photo_url = $url;
}
public function setIsAssetOwner($flag) {
public function setIsAssetOwner($flag)
{
$this->is_asset_owner = $flag;
}
@@ -50,15 +51,14 @@ class PhotoPage extends SubTemplate
$this->photoMeta();
if($this->is_asset_owner) {
if($this->is_asset_owner)
$this->addUserActions();
}
echo '
<script type="text/javascript" src="', BASEURL, '/js/photonav.js"></script>';
}
private function photo()
protected function photo()
{
echo '
<div id="photo_frame">
@@ -198,7 +198,7 @@ class PhotoPage extends SubTemplate
echo '
<div id=user_actions_box>
<h3>Actions</h3>
<a class="btn btn-red" href="', BASEURL, '/confirmdelete?slug=', $this->photo->getSlug(), '">Delete</a>
<a class="btn btn-red" href="', BASEURL, '/', $this->photo->getSlug(), '?confirm_delete">Delete</a>
</div>';
}
}

View File

@@ -0,0 +1,29 @@
<?php
/*****************************************************************************
* WarningDialog.php
* Defines the WarningDialog template.
*
* Kabuki CMS (C) 2013-2015, Aaron van Geffen
*****************************************************************************/
class WarningDialog extends Alert
{
protected $buttons;
public function __construct($title = '', $message = '', $buttons = [])
{
parent::__construct($title, $message);
$this->buttons = $buttons;
}
protected function additional_alert_content()
{
$this->addButtons();
}
private function addButtons()
{
foreach ($this->buttons as $button)
$button->html_content();
}
}