SEARCH


## Function to do searchs on gallery pics from NextGen Gallery plugin
##
## 2 vars : 	(1) $keywords (usually coming from the standard search query from wordpress)
##		(2) $numberPicCol (number of pic by row, if null it takes 4 )
function ngg_get_search_pictures ($keywords, $numberPicRow = NULL) {
	global $wpdb;
	$count=1; 
	if (!$numberPicRow) { $numberPicRow = "4"; }

	$nngquery = "
				SELECT pid,description,alttext
				FROM wp_ngg_pictures 
				WHERE MATCH (description, filename, alttext) AGAINST ('*$keywords*' IN BOOLEAN MODE)
				AND exclude = '0'
				";
	$pictures = $wpdb->get_results($nngquery, ARRAY_A);

	if ($pictures) foreach($pictures as $pic) { 
				
		$out .= '<a href="'.nggallery::get_image_url($pic[pid]).'" title="'.stripslashes($pic[description]).'" class="thickbox" rel="singlepic'.$pic[pid].'">';
		$out .=  '<img class="ngg-singlepic" src="'.nggallery::get_thumbnail_url($pic[pid]).'" alt="'.stripslashes($pic[alttext]).'" title="'.stripslashes($pic[alttext]).'" />';
		$out .=  "</a>\n"; 
				if ($count == 0) {
				$out .= "<br />";
				}
				++$count;
				$count%=$numberPicRow;
	}
	return $out;
};