forked from Public/pics
FeaturedThumbnailManager: add pager widget; show only 20 thumbs per page
This commit is contained in:
parent
b48c8ea820
commit
ea4983e967
@ -12,6 +12,8 @@ class EditAlbum extends HTMLController
|
|||||||
private $form;
|
private $form;
|
||||||
private $formview;
|
private $formview;
|
||||||
|
|
||||||
|
const THUMBS_PER_PAGE = 20;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Ensure it's just admins at this point.
|
// Ensure it's just admins at this point.
|
||||||
@ -143,15 +145,34 @@ class EditAlbum extends HTMLController
|
|||||||
|
|
||||||
if (!empty($id_tag))
|
if (!empty($id_tag))
|
||||||
{
|
{
|
||||||
|
$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||||
|
|
||||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||||
'direction' => 'desc',
|
'direction' => 'desc',
|
||||||
'limit' => 500,
|
'limit' => self::THUMBS_PER_PAGE,
|
||||||
|
'page' => $current_page,
|
||||||
'id_tag' => $id_tag,
|
'id_tag' => $id_tag,
|
||||||
], true);
|
], true);
|
||||||
|
|
||||||
// If we have asset images, show the thumbnail manager
|
// If we have asset images, show the thumbnail manager
|
||||||
if ($num_assets > 0)
|
if ($num_assets > 0)
|
||||||
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0));
|
{
|
||||||
|
$manager = new FeaturedThumbnailManager($assets, $id_tag ? $album->id_asset_thumb : 0);
|
||||||
|
$this->page->adopt($manager);
|
||||||
|
|
||||||
|
// Make a page index as needed, while we're at it.
|
||||||
|
if ($num_assets > self::THUMBS_PER_PAGE)
|
||||||
|
{
|
||||||
|
$index = new PageIndex([
|
||||||
|
'recordCount' => $num_assets,
|
||||||
|
'items_per_page' => self::THUMBS_PER_PAGE,
|
||||||
|
'start' => ($current_page - 1) * self::THUMBS_PER_PAGE,
|
||||||
|
'base_url' => BASEURL . '/editalbum/?id=' . $id_tag,
|
||||||
|
'page_slug' => '&page=%PAGE%',
|
||||||
|
]);
|
||||||
|
$manager->adopt(new PageIndexWidget($index));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['changeThumbnail']))
|
if (isset($_POST['changeThumbnail']))
|
||||||
|
@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
class EditTag extends HTMLController
|
class EditTag extends HTMLController
|
||||||
{
|
{
|
||||||
|
const THUMBS_PER_PAGE = 20;
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$id_tag = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
$id_tag = isset($_GET['id']) ? (int) $_GET['id'] : 0;
|
||||||
@ -117,14 +119,34 @@ class EditTag extends HTMLController
|
|||||||
|
|
||||||
if (!empty($id_tag))
|
if (!empty($id_tag))
|
||||||
{
|
{
|
||||||
|
$current_page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
|
||||||
|
|
||||||
list($assets, $num_assets) = AssetIterator::getByOptions([
|
list($assets, $num_assets) = AssetIterator::getByOptions([
|
||||||
'direction' => 'desc',
|
'direction' => 'desc',
|
||||||
'limit' => 500,
|
'limit' => self::THUMBS_PER_PAGE,
|
||||||
|
'page' => $current_page,
|
||||||
'id_tag' => $id_tag,
|
'id_tag' => $id_tag,
|
||||||
], true);
|
], true);
|
||||||
|
|
||||||
|
// If we have asset images, show the thumbnail manager
|
||||||
if ($num_assets > 0)
|
if ($num_assets > 0)
|
||||||
$this->page->adopt(new FeaturedThumbnailManager($assets, $id_tag ? $tag->id_asset_thumb : 0));
|
{
|
||||||
|
$manager = new FeaturedThumbnailManager($assets, $id_tag ? $tag->id_asset_thumb : 0);
|
||||||
|
$this->page->adopt($manager);
|
||||||
|
|
||||||
|
// Make a page index as needed, while we're at it.
|
||||||
|
if ($num_assets > self::THUMBS_PER_PAGE)
|
||||||
|
{
|
||||||
|
$index = new PageIndex([
|
||||||
|
'recordCount' => $num_assets,
|
||||||
|
'items_per_page' => self::THUMBS_PER_PAGE,
|
||||||
|
'start' => ($current_page - 1) * self::THUMBS_PER_PAGE,
|
||||||
|
'base_url' => BASEURL . '/edittag/?id=' . $id_tag,
|
||||||
|
'page_slug' => '&page=%PAGE%',
|
||||||
|
]);
|
||||||
|
$manager->adopt(new PageIndexWidget($index));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_POST['changeThumbnail']))
|
if (isset($_POST['changeThumbnail']))
|
||||||
|
@ -21,8 +21,21 @@ class FeaturedThumbnailManager extends SubTemplate
|
|||||||
{
|
{
|
||||||
echo '
|
echo '
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
<button class="btn btn-primary float-end" type="submit" name="changeThumbnail">Save thumbnail selection</button>
|
<div class="row">
|
||||||
<h2>Select thumbnail</h2>
|
<div class="col-lg">
|
||||||
|
<h2>Select thumbnail</h2>
|
||||||
|
</div>
|
||||||
|
<div class="col-lg">';
|
||||||
|
|
||||||
|
foreach ($this->_subtemplates as $template)
|
||||||
|
$template->html_main();
|
||||||
|
|
||||||
|
echo '
|
||||||
|
</div>
|
||||||
|
<div class="col-lg-auto">
|
||||||
|
<button class="btn btn-primary" type="submit" name="changeThumbnail">Save thumbnail selection</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<ul id="featuredThumbnail">';
|
<ul id="featuredThumbnail">';
|
||||||
|
|
||||||
foreach ($this->iterator as $asset)
|
foreach ($this->iterator as $asset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user