/** * Function combines multiple actor thumbnail queries into single SQL query */ function get_actor_thumbnails_batched(&$actors) { if (!count($actors)) { return; } $ids = "'" . join("','", array_map('addslashes', array_extract($actors, 'id'))) . "'"; $SQL = 'SELECT actorid, name, imgurl, UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(checked) AS cacheage FROM ' . TBL_ACTORS . ' WHERE actorid IN (' . $ids . ')'; $result = runSQL($SQL); $result = array_associate($result, 'actorid'); // loop over actors from full-text field foreach ($actors as $idx => $actor) { // check for actor thumbnail $batch_result = $result[$actor['id']]; if ($batch_result) { $actors[$idx]['imgurl'] = get_actor_image_from_cache($batch_result, $actor['name'], $actor['id']); } else { $actors[$idx]['imgurl'] = getActorThumbnail($actor['name'], $actor['id'], false); } } }
tpl_page('search', $q); tpl_list($result); $smarty->assign('q', $q); $smarty->assign('q_q', formvar($q)); $smarty->assign('search_fields', $search_fields); $smarty->assign('genreselect', out_genres($genres)); $smarty->assign('genres', out_genres2($genres)); //2015-10-6 Alex ADD start $smarty->assign('studioselect', out_studios($studios)); $smarty->assign('studios', out_studios2($studios)); //2015-10-6 Alex ADD end $smarty->assign('engine', $config['engine']); $smarty->assign('actors', prepare_cast($actors)); // person search? if ($isname && $config['actorpics']) { $smarty->assign('imgurl', getActorThumbnail(urldecode(preg_replace('/"|"/', '', formvar($q))))); } // allow XML export if (isset($q)) { $link = htmlentities($_SERVER['QUERY_STRING']); // encode for XHTML compliance if ($link) { $link .= '&'; } $link = 'search.php?' . $link; if ($config['xls']) { $smarty->assign('xls', $link); } if ($config['xml']) { $smarty->assign('xml', $link); }