Location: PHPKode > projects > Axis Groupware > musiclib/searches.php
<?
$phpgw_info["flags"] = array ("currentapp" => "musiclib",
							  "enable_nextmatchs_class" => True);

$GLOBALS['phpgw_info']['cursor_focus'] = "document.defaultsearch.searchFor.focus();
										  document.defaultsearch.searchFor.select();";

include ("../header.inc.php"); #PHP Groupware header

$artist = urldecode($artist);
$album  = urldecode($album);

if ($_POST['searchFor'])
{
	$searchFor = $_POST['searchFor'];
}
else
{
	$searchFor = $_GET['searchFor'];
}
$searchFor = htmlentities(urldecode($searchFor));

include ("inc/config.inc.php");
include ("inc/functions.inc.php");
include ("inc/sidebar.inc.php");

$title = "Search Results";
include ("inc/header.inc.php");

if ($action=="doSearch") 
{
  
  switch ( $search ) 
  {
	# browse
	case "songalbumid":
		$mode = 'song';
		echo "<BR><b>Songs found on \"".$album."\" by \"".$artist."\"...</b><BR><BR>";
		$query = construct_song_select("WHERE album_id='".$id."' ORDER BY track");

		break;
	case "songartistid":
		$mode = 'song';
		echo "<BR><b>Songs found by artist \"".$artist."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE ".$musiclib['tables']['albums'].".artist_id=".$id.
									" ORDER BY artist_name, album_title, track");
		break;
	case "albumartistid":
		$mode = 'album';
		echo "<BR><b>Albums found by artist \"".$artist."\"...</b><BR><BR>";
		$query=construct_album_select("WHERE artist_id=".$id. 
									 " ORDER BY artist_name, album_title");
		break;

	# search
	case "songkey":
		$mode = 'song';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE (artist_name LIKE '%".urldecode($searchFor)."%'"
		      						." OR song_title LIKE '%".urldecode($searchFor)."%'"
		      						." OR album_title LIKE '%".urldecode($searchFor)."%')" 
		      						." ORDER BY artist_name, album_title, track");
		break;
	case "albumkey":
		$mode = 'album';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_albumkey_select("WHERE (album_title LIKE '%".urldecode($searchFor)
										."%' OR artist_name LIKE '%".urldecode($searchFor)
										."%' OR song_title LIKE '%".urldecode($searchFor)
										."%') GROUP BY album_title"
		   	  						    ." ORDER BY artist_name, album_title");

		break;
	case "misckey":
		$mode = 'misc';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE (path LIKE '%".urldecode($searchFor)."%'"
		      						." OR filename LIKE '%".urldecode($searchFor)."%')" 
		      						." AND repository=2 ORDER BY path, filename");
		break;
	case "songsong":
		$mode = 'song';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE song_title LIKE '%".urldecode($searchFor)."%' 
									  ORDER BY artist_name, album_title, track");
		break;
	case "songartist":
		$mode = 'song';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE artist_name LIKE '%$searchFor%' 
									  ORDER BY artist_name, album_title, track");
		break;
	case "albumartist":
		$mode = 'album';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_album_select("WHERE artist_name LIKE '%".urldecode($searchFor)."%' 
									   ORDER BY artist_name, album_title");
		break;
	case "albumalbum":
		$mode = 'album';
		echo "<BR><b>Following records found containing \"".stripslashes($searchFor)."\"...</b><BR><BR>";
		$query=construct_album_select("WHERE album_title LIKE '%".urldecode($searchFor)."%' 
									   ORDER BY artist_name, album_title");
		break;
	case "miscfile":
		$mode = 'misc';
		echo "<BR><b>Following misc filenames found containing \"".urldecode($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE filename LIKE '%".urldecode($searchFor)."%'"
								   ." AND repository=2 ORDER BY path,filename");
		break;
	case "miscpath":
		$mode = 'misc';
		echo "<BR><b>Following misc songs found in directory \"".urldecode($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE path='".urldecode($searchFor)."'"
								   ." AND repository=2 ORDER BY filename");
		break;
	case "miscpathsearch":
		$mode = 'misc';
		echo "<BR><b>Following misc paths found containing \"".urldecode($searchFor)."\"...</b><BR><BR>";
		$query=construct_song_select("WHERE path LIKE '%".urldecode($searchFor)."%'"
								   ." AND repository=2 ORDER BY filename");
  }
  
  list_music($mode,$table,$query, "no", "yes");
  
}

#include("inc/footer.inc.php");

?>
Return current item: Axis Groupware