Its a tricky one and will eat as much of server resources (if not more) as the default top.php does...other words it will be twice slower. The speed will depend on how many members you have and how many images they have in their lightboxes.
Step 1Open
top.phpFind:
$site_template->register_vars($register_array);
Insert
above:
// Lightboxes
$sql = "SELECT lightbox_image_ids
FROM ".USERS_TABLE." u
LEFT JOIN ".LIGHTBOXES_TABLE." l ON (l.user_id = u.user_id)
WHERE user_level >= ".USER;
$result = $site_db->query($sql);
$lightbox_array = array();
while ($row = $site_db->fetch_array($result))
{
$row['lightbox_image_ids'] = trim($row['lightbox_image_ids']);
if (!empty($row['lightbox_image_ids']))
{
$image_ids = explode(" ", $row['lightbox_image_ids']);
foreach ($image_ids as $key)
{
$lightbox_array[$key] = isset($lightbox_array[$key]) ? $lightbox_array[$key] + 1 : 1;
}
}
}
arsort($lightbox_array);
$top_list = array();
if (!empty($lightbox_array))
{
$ids = implode(",", array_keys($lightbox_array));
$cat_match_sql = ($cat_id && check_permission("auth_viewcat", $cat_id)) ? " AND i.cat_id = '$cat_id' " : "";
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_thumb_file, i.image_media_file, u.user_name
FROM ".IMAGES_TABLE." i
LEFT JOIN ".USERS_TABLE." u ON (u.user_id = i.user_id)
WHERE i.image_active = 1 AND i.image_id IN ($ids) AND i.cat_id NOT IN ($cat_id_sql)$cat_match_sql
ORDER BY FIELD(i.image_id,$ids), i.image_name
LIMIT 10";
$result = $site_db->query($sql);
$i = 1;
while ($row = $site_db->fetch_array($result))
{
$top_list[$i] = $row;
$i++;
}
}
$site_db->free_result();
for ($i = 1; $i <= 10; $i++)
{
if (isset($top_list[$i]))
{
if (!check_media_type($top_list[$i]['image_thumb_file']))
{
$thumb_file = ICON_PATH."/404.gif";
}
else
{
if (!get_file_path($top_list[$i]['image_thumb_file'], "thumb", $top_list[$i]['cat_id'], 0, 0))
{
$thumb_file = ICON_PATH."/".get_file_extension($top_list[$i]['image_media_file']).".gif";
}
else
{
$thumb_file = (is_remote($top_list[$i]['image_thumb_file'])) ? $top_list[$i]['image_thumb_file'] : get_file_path($top_list[$i]['image_thumb_file'], "thumb", $top_list[$i]['cat_id'], 0, 1);
}
}
$dimension = 48;
if ($thumb_info = getimagesize($thumb_file))
{
$width = $thumb_info[0];
$height = $thumb_info[1];
$ratio = $width / $height;
if ($ratio > 1)
{
$new_width = $dimension;
$new_height = floor(($dimension/$width) * $height);
}
else
{
$new_width = floor(($dimension/$height) * $width);
$new_height = $dimension;
}
}
else
{
$new_width = $new_height = $dimension;
}
$register_array['image_lightbox_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
$register_array['image_lightbox_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".htmlspecialchars($top_list[$i]['image_name'])."</a>" : htmlspecialchars($top_list[$i]['image_name']);
$register_array['image_lightbox_thumb_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\"><img src=\"".$thumb_file."\" width=\"$new_width\" height=\"$new_height\" border=\"1\" align=\"center\" alt=\"".htmlspecialchars($top_list[$i]['image_name'])."\" /></a>" : "<img src=\"".$thumb_file."\" width=\"$new_width\" height=\"$new_height\" border=\"1\" align=\"center\" alt=\"".htmlspecialchars($top_list[$i]['image_name'])." />";
if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] != GUEST)
{
$user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $top_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$top_list[$i]['user_id'];
$register_array['image_lightbox_user_'.$i] = "<a href=\"".$site_sess->url($user_profile_link)."\">".htmlspecialchars($top_list[$i][$user_table_fields['user_name']])."</a>";
}
else
{
$register_array['image_lightbox_user_'.$i] = $lang['userlevel_guest'];
}
$register_array['image_lightbox_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".htmlspecialchars($cat_cache[$top_list[$i]['cat_id']]['cat_name'])."</a>";
$register_array['image_lightbox_number_'.$i] = "<b>".$lightbox_array[$top_list[$i]['image_id']]."</b>";
}
else
{
$register_array['image_lightbox_'.$i] = "--";
$register_array['image_lightbox_user_'.$i] = "--";
$register_array['image_lightbox_cat_'.$i] = "--";
$register_array['image_lightbox_number_'.$i] = "--";
}
}
$register_array['lang_top_image_lightbox'] = $lang['top_image_lightbox'];
//end Lightboxes
Step 2Open
lang/<your language>/main.phpAt the end, just above closing
?> insert:
$lang['top_image_lightbox'] = "Top 10 images added in lightboxes";
Step 3Open
templates/<your template>/top.htmlCopy/Paste the block that displays downloads or other top 10 results
then replace all words
downloads in your new block with
lightboxThat's it.
P.S. this addon also supports
[MOD] Toplist altered P.P.S. No "Lightbox for guest" is supported and never will, because its impossible to do