forked from Public/pics
EditAlbum: allow specifying a thumbnail ID manually if none are present
This commit is contained in:
parent
5cff62836e
commit
5b8551a726
@ -72,37 +72,58 @@ class EditAlbum extends HTMLController
|
|||||||
$parentChoices[$parent['id_tag']] = $parent['tag'];
|
$parentChoices[$parent['id_tag']] = $parent['tag'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fields = [
|
||||||
|
'id_parent' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'label' => 'Parent album',
|
||||||
|
'options' => $parentChoices,
|
||||||
|
],
|
||||||
|
'id_asset_thumb' => [
|
||||||
|
'type' => 'numeric',
|
||||||
|
'label' => 'Thumbnail asset ID',
|
||||||
|
'is_optional' => true,
|
||||||
|
],
|
||||||
|
'tag' => [
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => 'Album title',
|
||||||
|
'size' => 50,
|
||||||
|
'maxlength' => 255,
|
||||||
|
],
|
||||||
|
'slug' => [
|
||||||
|
'type' => 'text',
|
||||||
|
'label' => 'URL slug',
|
||||||
|
'size' => 50,
|
||||||
|
'maxlength' => 255,
|
||||||
|
],
|
||||||
|
'description' => [
|
||||||
|
'type' => 'textbox',
|
||||||
|
'label' => 'Description',
|
||||||
|
'size' => 50,
|
||||||
|
'maxlength' => 255,
|
||||||
|
'is_optional' => true,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
// Fetch image assets for this album
|
||||||
|
if (!empty($id_tag))
|
||||||
|
{
|
||||||
|
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||||
|
'direction' => 'desc',
|
||||||
|
'limit' => 500,
|
||||||
|
'id_tag' => $id_tag,
|
||||||
|
], true);
|
||||||
|
|
||||||
|
if ($num_assets > 0)
|
||||||
|
unset($fields['id_asset_thumb']);
|
||||||
|
}
|
||||||
|
|
||||||
$form = new Form([
|
$form = new Form([
|
||||||
'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
|
'request_url' => BASEURL . '/editalbum/?' . ($id_tag ? 'id=' . $id_tag : 'add'),
|
||||||
'content_below' => $after_form,
|
'content_below' => $after_form,
|
||||||
'fields' => [
|
'fields' => $fields,
|
||||||
'id_parent' => [
|
|
||||||
'type' => 'select',
|
|
||||||
'label' => 'Parent album',
|
|
||||||
'options' => $parentChoices,
|
|
||||||
],
|
|
||||||
'tag' => [
|
|
||||||
'type' => 'text',
|
|
||||||
'label' => 'Album title',
|
|
||||||
'size' => 50,
|
|
||||||
'maxlength' => 255,
|
|
||||||
],
|
|
||||||
'slug' => [
|
|
||||||
'type' => 'text',
|
|
||||||
'label' => 'URL slug',
|
|
||||||
'size' => 50,
|
|
||||||
'maxlength' => 255,
|
|
||||||
],
|
|
||||||
'description' => [
|
|
||||||
'type' => 'textbox',
|
|
||||||
'label' => 'Description',
|
|
||||||
'size' => 50,
|
|
||||||
'maxlength' => 255,
|
|
||||||
'is_optional' => true,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// Add defaults for album if none present
|
||||||
if (empty($_POST) && isset($_GET['tag']))
|
if (empty($_POST) && isset($_GET['tag']))
|
||||||
{
|
{
|
||||||
$parentTag = Tag::fromId($_GET['tag']);
|
$parentTag = Tag::fromId($_GET['tag']);
|
||||||
@ -124,17 +145,9 @@ class EditAlbum extends HTMLController
|
|||||||
$formview = new FormView($form, $form_title ?? '');
|
$formview = new FormView($form, $form_title ?? '');
|
||||||
$this->page->adopt($formview);
|
$this->page->adopt($formview);
|
||||||
|
|
||||||
if (!empty($id_tag))
|
// If we have asset images, show the thumbnail manager
|
||||||
{
|
if (!empty($id_tag) && $num_assets > 0)
|
||||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0));
|
||||||
'direction' => 'desc',
|
|
||||||
'limit' => 500,
|
|
||||||
'id_tag' => $id_tag,
|
|
||||||
], true);
|
|
||||||
|
|
||||||
if ($num_assets > 0)
|
|
||||||
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_POST['changeThumbnail']))
|
if (isset($_POST['changeThumbnail']))
|
||||||
$this->processThumbnail($album);
|
$this->processThumbnail($album);
|
||||||
|
Loading…
Reference in New Issue
Block a user