New bootstrap-based layout #30
@ -18,6 +18,9 @@ class EditAlbum extends HTMLController
|
||||
if (empty($id_tag) && !isset($_GET['add']) && $_GET['action'] !== 'addalbum')
|
||||
throw new UnexpectedValueException('Requested album not found or not requesting a new album.');
|
||||
|
||||
if (!empty($id_tag))
|
||||
$album = Tag::fromId($id_tag);
|
||||
|
||||
// Adding an album?
|
||||
if (isset($_GET['add']) || $_GET['action'] === 'addalbum')
|
||||
{
|
||||
@ -29,7 +32,6 @@ class EditAlbum extends HTMLController
|
||||
elseif (isset($_GET['delete']))
|
||||
{
|
||||
// So far so good?
|
||||
$album = Tag::fromId($id_tag);
|
||||
if (Session::validateSession('get') && $album->kind === 'Album' && $album->delete())
|
||||
{
|
||||
header('Location: ' . BASEURL . '/managealbums/');
|
||||
@ -41,7 +43,6 @@ class EditAlbum extends HTMLController
|
||||
// Editing one, then, surely.
|
||||
else
|
||||
{
|
||||
$album = Tag::fromId($id_tag);
|
||||
if ($album->kind !== 'Album')
|
||||
trigger_error('Cannot edit album: not an album.', E_USER_ERROR);
|
||||
|
||||
@ -80,11 +81,6 @@ class EditAlbum extends HTMLController
|
||||
'label' => 'Parent album',
|
||||
'options' => $parentChoices,
|
||||
],
|
||||
'id_asset_thumb' => [
|
||||
'type' => 'numeric',
|
||||
'label' => 'Thumbnail asset ID',
|
||||
'is_optional' => true,
|
||||
],
|
||||
'tag' => [
|
||||
'type' => 'text',
|
||||
'label' => 'Album title',
|
||||
@ -128,6 +124,37 @@ class EditAlbum extends HTMLController
|
||||
$formview = new FormView($form, $form_title ?? '');
|
||||
$this->page->adopt($formview);
|
||||
|
||||
if (!empty($id_tag))
|
||||
{
|
||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||
'direction' => 'desc',
|
||||
'limit' => 500,
|
||||
'id_tag' => $id_tag,
|
||||
], true);
|
||||
|
||||
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0));
|
||||
}
|
||||
|
||||
if (isset($_POST['changeThumbnail']))
|
||||
$this->processThumbnail($album);
|
||||
elseif (!empty($_POST))
|
||||
$this->processTagDetails($form, $id_tag, $album);
|
||||
}
|
||||
|
||||
private function processThumbnail($tag)
|
||||
{
|
||||
if (empty($_POST))
|
||||
return;
|
||||
|
||||
$tag->id_asset_thumb = $_POST['featuredThumbnail'];
|
||||
$tag->save();
|
||||
|
||||
header('Location: ' . BASEURL . '/editalbum/?id=' . $tag->id_tag);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function processTagDetails($form, $id_tag, $album)
|
||||
{
|
||||
if (!empty($_POST))
|
||||
{
|
||||
$form->verify($_POST);
|
||||
|
Loading…
Reference in New Issue
Block a user