if ($_MG_CONF['usage_tracking']) { MG_updateUsage('MediaGallery', 'Main Menu', '', 0); } // initialize variables $page = isset($_GET['page']) ? COM_applyFilter($_GET['page'], true) : 0; $columns_per_page = $root_album->display_columns; $rows_per_page = $root_album->display_rows; $media_per_page = $columns_per_page * $rows_per_page; if ($page != 0) { $page = $page - 1; } $begin = $media_per_page * $page; $end = $media_per_page; $total_media = 0; $MG_media = array(); $children = $root_album->getChildrenVisible(); $cCount = count($children); $sub_album_id = array(); for ($i = $begin; $i < $begin + $end; $i++) { if ($i >= $cCount) { continue; } $sub_album_id[] = $children[$i]; $total_media++; } $begin = $begin - $cCount; if ($begin < 0) { $begin = 0; } $end = $end - $total_media; $total_items_in_album = $root_album->media_count + $cCount;
} if ($_MG_CONF['usage_tracking']) { MG_updateUsage('album_view', $album->title, '', 0); } // update views counter.... if (!$root_album->owner_id && $page == 0) { $album_views = $album->views + 1; DB_change($_TABLES['mg_albums'], 'album_views', intval($album_views), 'album_id', intval($album_id)); } // initialize variables $begin = $media_per_page * $page; $end = $media_per_page; $total_media = 0; $MG_media = array(); if ($album->albums_first == 1) { $children = $album->getChildrenVisible(); $cCount = count($children); for ($i = $begin; $i < $begin + $end; $i++) { if ($i >= $cCount) { continue; } $MG_media[] = array('type' => 0, 'obj' => $children[$i]); $total_media++; } $begin = $begin - $cCount; if ($begin < 0) { $begin = 0; } $end = $end - $total_media; } else { $cCount = $album->getChildcount();