protected function _content()
{
global $registry;
if ($this->_params['gallery'] == 'all') {
$threads = $registry->call('forums/list', array(0, 'ansel'));
$image_ids = array();
foreach ($threads as $thread) {
$image_ids[] = $thread['forum_name'];
}
} else {
try {
$gallery = $this->_getGallery();
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$results = array();
$image_ids = $gallery->listImages();
}
$results = array();
$threads = $registry->call('forums/getThreadsBatch', array($image_ids, 'message_timestamp', 1, false, 'ansel', null, 0, 10));
foreach ($threads as $image_id => $messages) {
foreach ($messages as $message) {
$message['image_id'] = $image_id;
$results[] = $message;
}
}
$results = $this->_asortbyindex($results, 'message_timestamp');
$html = '<div id="ansel_preview"></div>' . '<script type="text/javascript">' . 'function previewImage(e, image_id) {$(\'ansel_preview\').style.left = Event.pointerX(e) + \'px\'; $(\'ansel_preview\').style.top = Event.pointerY(e) + \'px\';new Ajax.Updater({success:\'ansel_preview\'}, \'' . Horde::url('preview.php') . '\', {method: \'post\', parameters:\'?image=\' + image_id, onsuccess:$(\'ansel_preview\').show()});}' . '</script>' . '<table class="linedRow" cellspacing="0" style="width:100%"><thead><tr class="item nowrap"><th class="item leftAlign">' . _("Date") . '</th><th class="item leftAlign">' . _("Image") . '</th><th class="item leftAlign">' . _("Subject") . '</th><th class="item leftAlign">' . _("By") . '</th></tr></thead><tbody>';
foreach ($results as $comment) {
try {
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($comment['image_id']);
$url = Ansel::getUrlFor('view', array('view' => 'Image', 'gallery' => abs($image->gallery), 'image' => $comment['image_id']), true);
$caption = substr($image->caption, 0, 30);
if (strlen($image->caption) > 30) {
$caption .= '...';
}
$html .= '<tr><td>' . strftime('%x', $comment['message_timestamp']) . '</td><td class="nowrap">' . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");', 'onmouseover' => 'previewImage(event, ' . $comment['image_id'] . ');')) . ($image->caption == '' ? $image->filename : $caption) . '</a></td><td class="nowrap">' . $comment['message_subject'] . '</td><td class="nowrap">' . $comment['message_author'] . '</td></tr>';
} catch (Ansel_Exception $e) {
}
}
$html .= '</tbody></table>';
return $html;
}