function view($id, $params) { global $my, $mainframe, $database, $option, $priTask, $subTask; global $WBG_CONFIG, $wbGalleryDB_cat; if (!$id) { $id = $params->get('id', 0); } // Load Image $row = new wbGalleryDB_img($database); $row->load($id); if (!$row->id) { echo "<script> alert('Image Not Found'); window.history.go(-1); </script>\n"; exit; } // Track Hit $row->hit(); // Load Category if ($row->cat_id != '0') { $cat = new wbGalleryDB_cat($database); $cat->load($row->cat_id); if (!$cat->id) { echo "<script> alert('Category Not Found'); window.history.go(-1); </script>\n"; exit; } if ($cat->access > $my->gid) { mosNotAuth(); exit; } } // Load Prev / Next $neighbors = $row->getNeighbors(); // Load Related Images $database->setQuery("\r\r\n SELECT i.*\r\r\n FROM #__wbgallery_img AS i\r\r\n WHERE i.cat_id = " . (int) $row->cat_id . "\r\r\n AND i.id != " . (int) $row->id . "\r\r\n AND i.published = 1\r\r\n ORDER BY i.hits DESC\r\r\n , i.ordering ASC\r\r\n LIMIT 0, " . $params->get('related_list_limit', $mainframe->getCfg('list_limit', 15)) . "\r\r\n "); $related = $database->loadObjectList(); echo $database->getErrorMsg(); wbGallery_img_html::view($row, $cat, $neighbors, $related, $params); }