diff --git a/ext/pools/main.php b/ext/pools/main.php index 0c14e0a8..66812ac4 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -267,29 +267,19 @@ class Pools extends Extension { $show_nav = $config->get_bool("poolsShowNavLinks", false); - $linksPools = array(); + $navInfo = array(); foreach($poolsIDs as $poolID) { - $pools = $this->get_pool($poolID['pool_id']); - foreach ($pools as $pool){ - $linksPools[] = "".html_escape($pool['title']).""; - - // Optionally show a link the Prev/Next image in the Pool. - if ($show_nav) { - $nav = $this->get_nav_posts($pool, $imageID); - $navlinks = ""; - if (!empty($nav['prev'])) { - $navlinks .= 'Prev'; - } - if (!empty($nav['next'])) { - $navlinks .= 'Next'; - } - if(!empty($navlinks)){ - $linksPools[] = $navlinks; - } - } + $pool = $this->get_single_pool($poolID['pool_id']); + + $navInfo[$pool['id']] = array(); + $navInfo[$pool['id']]['info'] = $pool; + + // Optionally show a link the Prev/Next image in the Pool. + if ($show_nav) { + $navInfo[$pool['id']]['nav'] = $this->get_nav_posts($pool, $imageID); } } - $this->theme->pool_info($linksPools); + $this->theme->pool_info($navInfo); } } diff --git a/ext/pools/theme.php b/ext/pools/theme.php index efa86f94..c42bdbb0 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -3,9 +3,29 @@ class PoolsTheme extends Themelet { /** * Adds a block to the panel with information on the pool(s) the image is in. + * @param array Multidimensional array containing pool id, info & nav IDs. */ - public function pool_info($linksPools) { + public function pool_info(/*array*/ $navIDs) { global $page; + + $linksPools = array(); + foreach($navIDs as $poolID => $pool){ + $linksPools[] = "".html_escape($pool['info']['title']).""; + + if (array_key_exists('nav', $pool)){ + $navlinks = ""; + if (!empty($pool['nav']['prev'])) { + $navlinks .= 'Prev'; + } + if (!empty($pool['nav']['next'])) { + $navlinks .= 'Next'; + } + if(!empty($navlinks)){ + $linksPools[] = $navlinks; + } + } + } + if(count($linksPools) > 0) { $page->add_block(new Block("Pools", implode("
", $linksPools), "left")); }