Location: PHPKode > scripts > AmaroK Web Frontend > obsidianmusic-2.3.0/pages/genre.php
<?php

//
//  ObsidianMusic
//   a.k.a. amaroK Web Frontend 2.0
//
//  Created 12/31/06
//   Copyright (C) Ryan Loebs (ObsidianX) 2005/2006
//   See LICENSE for GPL
//
//  genre.php - Search according to Genre
//
///////////////////////////////////////

if(eregi("genre.php", $_SERVER['PHP_SELF'])){
	die("Cannot access directly.");
}

// Load up the Genres
$gq = getquery("getgenres");
$genres = query($gq);

while($genre = fetch_assoc($genres)){
	if($genre['name'] != ""){
		$genrea[] = array('gid' => $genre['id'],
				  'genre' => $genre['name']);
	}
}

// Set a default genre if none chosen
if(@$_GET['genre']){
	$currentg = $_GET['genre'];
	$currentgn = fetch_assoc(query(getquery("getgname", $sort, $currentg)));
	$currentgn = $currentgn['name'];
}else{
	$currentg = $genrea[0]['gid'];
	$currentgn = $genrea[0]['genre'];
}

foreach($genrea as $key=>$value){
	if($value['gid'] == $currentg){
		$genrea[$key]['selected'] = "SELECTED";
	}
}

// Search
$q = query(getquery("genre", $sort, $currentg));

$rows = getSongArray($q);

$tpl->setAttribute("songs", "src", "genre.tpl");

$tpl->addVar("root", "title", _PG_GENRE);
$tpl->addVar("songs", "page", _PG_GENRE);
$tpl->addVar("songs", "genre_locale", _GENRE);
$tpl->addVar("songs", "select", _SELECT);
$tpl->addVar("songs", "genre", $currentgn);

$tpl->addRows("genres", $genrea);
$tpl->addRows("row", $rows);
Return current item: AmaroK Web Frontend