protected function _getStackImages()
{
$images = array();
$gallery = $this->_params['gallery'];
// Make sure we have images. We can't go deeper into subgalleries
// since some of them may not have HORDE_PERMS::READ and the
// keyimage-thumbnails are generated by the first user who views
// them, using their perms.
if (!$gallery->countImages() && $gallery->hasSubGalleries()) {
return array();
}
$cnt = min(5, $gallery->countImages());
$default = $gallery->get('default');
if (!empty($default) && $default > 0) {
try {
$img = $gallery->getImage($default);
$img->load('screen');
$images[] = $img->getHordeImage();
$cnt--;
} catch (Ansel_Exception $e) {
Horde::log($e, 'ERR');
}
}
for ($i = 0; $i < $cnt; $i++) {
$rnd = mt_rand(0, $cnt);
try {
$temp = $gallery->getImages($rnd, 1);
if (count($temp)) {
$aimg = array_shift($temp);
$aimg->load('screen');
$images[] = $aimg->getHordeImage();
}
} catch (Ansel_Exception $e) {
Horde::log($e, 'ERR');
}
}
// Reverse the array to ensure the requested key image
// is the last in the array (so it will appear on the top of
// the stack.
return array_reverse($images);
}