Added config option for Next image.

This commit is contained in:
green-ponies (jgen) 2012-02-08 16:42:29 -05:00
parent 98e7359c6e
commit 050a9a17df

View File

@ -63,6 +63,7 @@ class Pools extends SimpleExtension {
$config->set_int("poolsUpdatedPerPage", 20); $config->set_int("poolsUpdatedPerPage", 20);
$config->set_bool("poolsInfoOnViewImage", "N"); $config->set_bool("poolsInfoOnViewImage", "N");
$config->set_bool("poolsAdderOnViewImage", "N"); $config->set_bool("poolsAdderOnViewImage", "N");
$config->set_bool("poolsShowNextLink","N");
log_info("pools", "extension installed"); log_info("pools", "extension installed");
} }
@ -76,6 +77,7 @@ class Pools extends SimpleExtension {
$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("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);
} }
@ -223,7 +225,8 @@ class Pools extends SimpleExtension {
/** /**
* When displaying an image, optionally list all the pools that the * When displaying an image, optionally list all the pools that the
* image is currently a member of on a side panel. * image is currently a member of on a side panel, as well as a link
* to the Next image in the pool.
*/ */
public function onDisplayingImage($event) { public function onDisplayingImage($event) {
global $config, $database, $page; global $config, $database, $page;
@ -232,15 +235,21 @@ class Pools extends SimpleExtension {
$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);
$linksPools = array(); $linksPools = array();
foreach($poolsIDs as $poolID) { foreach($poolsIDs as $poolID) {
$pools = $this->get_pool($poolID['pool_id']); $pools = $this->get_pool($poolID['pool_id']);
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>";
// TODO: make a config for this
$next_image_in_pool = get_next_post($pool['id'], $imageID); // Optionally show a link the Next image in the Pool.
if (!empty($next_image_in_pool)) { if ($show_next) {
$linksPools[] = '<a href="'.make_link('post/view/'.$next_image_in_pool).'" class="pools_next_img">Next</a>'; $next_image_in_pool = $this->get_next_post($pool['id'], $imageID);
if (!empty($next_image_in_pool)) {
$linksPools[] = '<a href="'.make_link('post/view/'.$next_image_in_pool).'" class="pools_next_img">Next</a>';
}
} }
} }
} }