prev link for pools
This commit is contained in:
parent
77607e0c02
commit
1dada97adc
@ -80,6 +80,12 @@ class Pools extends Extension {
|
|||||||
|
|
||||||
$config->set_int("ext_pools_version", 2);
|
$config->set_int("ext_pools_version", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($config->get_int("ext_pools_version") < 3){
|
||||||
|
$config->set_bool("poolsShowNavLinks","N"); //A $config->rename() function would be nice here...
|
||||||
|
|
||||||
|
$config->set_int("ext_pools_version", 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add a block to the Board Config / Setup
|
// Add a block to the Board Config / Setup
|
||||||
@ -90,7 +96,7 @@ class Pools extends Extension {
|
|||||||
$sb->add_int_option("poolsListsPerPage", "<br>Index list items per page: ");
|
$sb->add_int_option("poolsListsPerPage", "<br>Index list items per page: ");
|
||||||
$sb->add_int_option("poolsUpdatedPerPage", "<br>Updated list items per page: ");
|
$sb->add_int_option("poolsUpdatedPerPage", "<br>Updated list items per page: ");
|
||||||
$sb->add_bool_option("poolsInfoOnViewImage", "<br>Show pool info on image: ");
|
$sb->add_bool_option("poolsInfoOnViewImage", "<br>Show pool info on image: ");
|
||||||
$sb->add_bool_option("poolsShowNextLink", "<br>Show 'Next' link when viewing pool images: ");
|
$sb->add_bool_option("poolsShowNavLinks", "<br>Show 'Prev' & 'Next' links when viewing pool images: ");
|
||||||
//$sb->add_bool_option("poolsAdderOnViewImage", "<br>Show pool adder on image: ");
|
//$sb->add_bool_option("poolsAdderOnViewImage", "<br>Show pool adder on image: ");
|
||||||
$event->panel->add_block($sb);
|
$event->panel->add_block($sb);
|
||||||
}
|
}
|
||||||
@ -259,7 +265,7 @@ class Pools extends Extension {
|
|||||||
$imageID = $event->image->id;
|
$imageID = $event->image->id;
|
||||||
$poolsIDs = $this->get_pool_id($imageID);
|
$poolsIDs = $this->get_pool_id($imageID);
|
||||||
|
|
||||||
$show_next = $config->get_bool("poolsShowNextLink", false);
|
$show_nav = $config->get_bool("poolsShowNavLinks", false);
|
||||||
|
|
||||||
$linksPools = array();
|
$linksPools = array();
|
||||||
foreach($poolsIDs as $poolID) {
|
foreach($poolsIDs as $poolID) {
|
||||||
@ -267,11 +273,18 @@ class Pools extends Extension {
|
|||||||
foreach ($pools as $pool){
|
foreach ($pools as $pool){
|
||||||
$linksPools[] = "<a href='".make_link("pool/view/".$pool['id'])."'>".html_escape($pool['title'])."</a>";
|
$linksPools[] = "<a href='".make_link("pool/view/".$pool['id'])."'>".html_escape($pool['title'])."</a>";
|
||||||
|
|
||||||
// Optionally show a link the Next image in the Pool.
|
// Optionally show a link the Prev/Next image in the Pool.
|
||||||
if ($show_next) {
|
if ($show_nav) {
|
||||||
$next_image_in_pool = $this->get_next_post($pool, $imageID);
|
$nav = $this->get_nav_posts($pool, $imageID);
|
||||||
if (!empty($next_image_in_pool)) {
|
$navlinks = "";
|
||||||
$linksPools[] = '<a href="'.make_link('post/view/'.$next_image_in_pool).'" class="pools_next_img">Next</a>';
|
if (!empty($nav['prev'])) {
|
||||||
|
$navlinks .= '<a href="'.make_link('post/view/'.$nav['prev']).'" class="pools_prev_img">Prev</a>';
|
||||||
|
}
|
||||||
|
if (!empty($nav['next'])) {
|
||||||
|
$navlinks .= '<a href="'.make_link('post/view/'.$nav['next']).'" class="pools_next_img">Next</a>';
|
||||||
|
}
|
||||||
|
if(!empty($navlinks)){
|
||||||
|
$linksPools[] = $navlinks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -612,24 +625,47 @@ class Pools extends Extension {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the next successive image from a pool, given a pool ID and an image ID.
|
* Gets the previous and next successive images from a pool, given a pool ID and an image ID.
|
||||||
*
|
*
|
||||||
* @param array $pool Array for the given pool
|
* @param array $pool Array for the given pool
|
||||||
* @param int $imageID Integer
|
* @param int $imageID Integer
|
||||||
* @return int Integer which is the next Image ID or NULL if none.
|
* @return array Array returning two elements (prev, next) in 1 dimension. Each returns ImageID or NULL if none.
|
||||||
*/
|
*/
|
||||||
private function get_next_post(/*array*/ $pool, /*int*/ $imageID) {
|
private function get_nav_posts(/*array*/ $pool, /*int*/ $imageID) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
if (empty($pool) || empty($imageID))
|
if (empty($pool) || empty($imageID))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
$result = $database->get_one("
|
$result = $database->get_row("
|
||||||
|
SELECT (
|
||||||
SELECT image_id
|
SELECT image_id
|
||||||
FROM pool_images
|
FROM pool_images
|
||||||
WHERE pool_id=:pid
|
WHERE pool_id = :pid
|
||||||
AND image_order > (SELECT image_order FROM pool_images WHERE pool_id=:pid AND image_id =:iid LIMIT 1 )
|
AND image_order < (
|
||||||
ORDER BY image_order ASC LIMIT 1",
|
SELECT image_order
|
||||||
|
FROM pool_images
|
||||||
|
WHERE pool_id = :pid
|
||||||
|
AND image_id = :iid
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
ORDER BY image_order DESC LIMIT 1
|
||||||
|
) AS prev,
|
||||||
|
(
|
||||||
|
SELECT image_id
|
||||||
|
FROM pool_images
|
||||||
|
WHERE pool_id = :pid
|
||||||
|
AND image_order > (
|
||||||
|
SELECT image_order
|
||||||
|
FROM pool_images
|
||||||
|
WHERE pool_id = :pid
|
||||||
|
AND image_id = :iid
|
||||||
|
LIMIT 1
|
||||||
|
)
|
||||||
|
ORDER BY image_order ASC LIMIT 1
|
||||||
|
) AS next
|
||||||
|
|
||||||
|
LIMIT 1",
|
||||||
array("pid"=>$pool['id'], "iid"=>$imageID) );
|
array("pid"=>$pool['id'], "iid"=>$imageID) );
|
||||||
|
|
||||||
if (empty($result)) {
|
if (empty($result)) {
|
||||||
|
@ -117,8 +117,15 @@ NAV SELECT {
|
|||||||
display: block;
|
display: block;
|
||||||
font-size: 77%;
|
font-size: 77%;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pools_prev_img {
|
||||||
|
display: block;
|
||||||
|
font-size: 77%;
|
||||||
|
text-align: left;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
* the main part of each page *
|
* the main part of each page *
|
||||||
|
Loading…
x
Reference in New Issue
Block a user