set_prefilter('picture', 'dlcount_picture_prefilter'); $template->assign( array( 'DOWNLOAD_COUNTER' => $picture['current']['download_counter'], ) ); } function dlcount_picture_prefilter($content, &$smarty) { $search = '{if $display_info.rating_score'; $replace = '
{\'Downloads\'|@translate}
{$DOWNLOAD_COUNTER}
'.$search; $content = str_replace($search, $replace, $content); return $content; } /** * increase counter of each photo inside a batch download */ add_event_handler('batchdownload_end_zip', 'dlcount_batchdownload', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); function dlcount_batchdownload($data, $images) { if (count($images) > 0) { $query = ' UPDATE '.IMAGES_TABLE.' SET download_counter = download_counter + 1 WHERE id IN ('.implode(',', $images).') ;'; pwg_query($query); } } ?>