Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/index.php
<?php
/************************************************************************/
/* Top Music PHP-Nuke module v2.0                                       */
/* ===============================                                      */
/*                                                                      */
/* Copyright (c) 2004 by SergiDs                                		*/
/* http://www.sergids.com                                               */
/*                                                                      */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF']) && !eregi("music.php", $_SERVER['PHP_SELF']) && !eregi("index.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}
if (!defined('MODULE_FILE')) {
	die ("You can't access this file directly...");
}

$module_name = basename(dirname(__FILE__));

if(!eregi("music.php",$_SERVER['PHP_SELF'])){
	require_once("mainfile.php");
	include_once("modules/$module_name/lib/config.php");
	require_once("modules/$module_name/lib/net/php/smarty/Smarty.class.php");
}

get_lang($module_name);

if($config->theme=="")
	$tm_theme="default";
else
	$tm_theme=$config->theme;

$op=$_GET['op'];
if($op=="") $op=$_POST['op'];
if($op=="") $op=$config->main_page;

$smarty = new Smarty;
$smarty->template_dir ="modules/".$module_name."/themes/".$tm_theme."/";
$smarty->compile_dir = "modules/".$module_name."/themes_c/".$tm_theme."/";
$smarty->cache_dir = $smarty->compile_dir;
$smarty->config_dir = "modules/".$module_name."/language/";
$smarty->caching = false;

$smarty->assign("op",$op);
$smarty->assign("module_name",$module_name);
$smarty->assign("id_artist",$_GET['idartist']);
$smarty->assign("id_album",$_GET['idalbum']);
$smarty->assign("id_song",$_GET['idsong']);
$smarty->assign("tm_BaseURL",$config->getBaseURL());
$smarty->assign("tm_rateartists",$config->getRateArtists());
$smarty->assign("tm_ratealbums",$config->getRateAlbums());
$smarty->assign("tm_ratesongs",$config->getRateSongs());
$smarty->assign("tm_easyURL",$config->getEasyURL());
$smarty->assign("tm_easyURLtype",$config->getEasyURLType());
$smarty->assign("tm_theme",$tm_theme);
$smarty->assign("configfile","templates-".$currentlang.".conf");
$smarty->assign("tm_config",$config);

$index=$config->ind;
if($config->ind)
	define('INDEX_FILE', true);

require_once("modules/$module_name/lib/com/sergids/common/StringUtils.php");
include("header.php");
include("modules/$module_name/includes/path.php");
if($config->getTopMenu())
	include("modules/$module_name/includes/menu.php");
	
//GenericView
require_once("modules/$module_name/lib/com/sergids/topmusic/view/GenericView.php");
$genericView=new GenericView();
$smarty->assign("genericView",$genericView);

switch($op) {
	case "voteArtist":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
		$artistDAO=new ArtistDAO($db,$prefix);
		$artistO=new ArtistO();
		if(!$artistDAO->voteArtist($idartist,$_POST['rate'],$_SERVER['REMOTE_ADDR']))
			$message=_TOPMUSIC_ARTIST_ALREADYVOTED;
		$artistO=$artistDAO->getArtist($idartist,$currentlang);
		$artistVoted=1;
		$smarty->assign("message",$message);
    case "artist":
    	require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
	 	require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
	 	require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
	  	require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
	  	require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
	  	require_once("modules/$module_name/lib/com/sergids/common/File.php");
		if(!$artistVoted || $artistVoted==""){
			$artistDAO=new ArtistDAO($db,$prefix);
			if(!isset($admin) || $admin != $_COOKIE['admin'])
				$artistDAO->addView($idartist);
			$artistO=$artistDAO->getArtist($idartist,$currentlang);
	  	}
	  	$songDAO=new SongDAO($db,$prefix);
	  	$albumDAO=new AlbumDAO($db,$prefix);
	  	$discography=$albumDAO->getAlbumList($_GET['idartist'],$currentlang,$prefix."_topmusic_album.yeardate",6);
	  	//print_r($discography);
	  	AlbumView::parseThumbs($module_name,&$discography,75,0);
	  	//print_r($discography);
	  	$related_artists=$artistDAO->getRelated($_GET['idartist']);
	  	ArtistView::parseThumbs($module_name,&$related_artists,75,0);
	  	$top_songs=$songDAO->getMostVotedSongs(10,$_GET['idartist']);
	  	$custom_fields=$artistDAO->getCustomFields($_GET['idartist']);
	  
	  	$rate_code=GenericView::getRateCode($artistO->avgvotes,$module_name,$tm_theme);
	  	$discography_url=ArtistView::getDiscographyUrl($module_name,$config,$artistO,$discography_url);
	  	$forum_url=ArtistView::getForumUrl($artistO->forum);
	  	
	  	$photo_url=ArtistView::getPhotoUrl($artistO,$module_name);
	  	$photothumb_url=ArtistView::getPhotoThumbUrl($artistO,$module_name,200,0);
	  	$bio_url=ArtistView::getBioUrl($module_name,$config,$artistO);
	  	$dead_year=$artistO->deadyear;
	  	$dead_year=ArtistView::getDeadYear($dead_year);
	  
	  	$smarty->assign("dead_year",$dead_year);
	  	$smarty->assign("artistVoted",$artistVoted);
	  	$smarty->assign("rate_code",$rate_code);
	  	$smarty->assign("discography_url",$discography_url);
	  	$smarty->assign("photo_url",$photo_url);
	  	$smarty->assign("photothumb_url",$photothumb_url);
	  	$smarty->assign("forum_url",$forum_url);
	  	$smarty->assign("bio_url",$bio_url);
	  	$smarty->assign("artist",$artistO);
	  	$smarty->assign("tm_rateartists",$config->getRateArtists());
	  	$smarty->assign("discography",$discography);
	  	$smarty->assign("related_artists",$related_artists);
	  	$smarty->assign("top_songs",$top_songs);
	  	$smarty->assign("custom_fields",$custom_fields);
	  	$tm_content=$smarty->fetch("artist.tpl");
    	break;
    case "bio":
    	require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
		$artistDAO=new ArtistDAO($db,$prefix);
		$artistO=$artistDAO->getArtist($idartist,$currentlang);
		$artist_url=ArtistView::getArtistUrl($module_name,$config,$artistO);
		$photo_url=ArtistView::getPhotoUrl($artistO,$module_name);
		$photothumb_url=ArtistView::getPhotoThumbUrl($artistO,$module_name,200,0);
		$dead_year=$artistO->deadyear;
	  	$dead_year=ArtistView::getDeadYear($dead_year);
		$smarty->assign("artist",$artistO);
		$smarty->assign("artist_url",$artist_url);
		$smarty->assign("photo_url",$photo_url);
		$smarty->assign("photothumb_url",$photothumb_url);
		$smarty->assign("dead_year",$dead_year);
		$tm_content=$smarty->fetch("artist_bio.tpl");
    	break;
	case "voteAlbum":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
		$albumDAO=new AlbumDAO($db,$prefix);
		$album=new AlbumO();
		if(!$albumDAO->voteAlbum($idalbum,$_POST['rate'],$_SERVER['REMOTE_ADDR']))
			$message=_TOPMUSIC_ALBUM_ALREADYVOTED;
		$album=$albumDAO->getAlbum($idalbum,$currentlang);
		$albumVoted=1;
		$smarty->assign("message",$message);
    case "album":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
		if(!$albumVoted){
			$albumDAO=new AlbumDAO($db,$prefix);
			if(!isset($admin) || $admin != $_COOKIE['admin'])
				$albumDAO->addView($_GET['idalbum']);
			$album=$albumDAO->getAlbum($_GET['idalbum'],$currentlang);
		}
		if($album->idartist!=""){
			$artist=$artistDAO->getArtist($album->idartist,$currentlang);
			$artist_url=ArtistView::getArtistUrl($module_name,$config,$artist);
		}else{
			$artist=new ArtistO();
			$artist->setName(_TOPMUSIC_NA);
			$artist_url="";
		}
		$songDAO=new SongDAO($db,$prefix);
		$song_list=$songDAO->getSongList($_GET['idalbum'],$currentlang);
		$related_albums=$albumDAO->getRelated($album->id);
		$custom_fields=$albumDAO->getCustomFields($_GET['idalbum']);
		$rate_code=GenericView::getRateCode($album->avgvotes,$module_name,$tm_theme);
		$songlist_url=AlbumView::getSonglistUrl($module_name,$config,$album);
		$frontcover_url=AlbumView::getCoverUrl($module_name,$album,"front");
		$frontcover_thumburl=AlbumView::getCoverThumbUrl($module_name,$album,"Front",100,0);
		$backcover_url=AlbumView::getCoverUrl($module_name,$album,"Back");
		$backcover_thumburl=AlbumView::getCoverThumbUrl($module_name,$album,"Back",100,0);
		$shop_url=AlbumView::getShopUrl($album);
		$smarty->assign("albumVoted",$albumVoted);
		$smarty->assign("rate_code",$rate_code);
		$smarty->assign("album",$album);
		$smarty->assign("artist",$artist);
		$smarty->assign("songlist_url",$songlist_url);
		$smarty->assign("artist_url",$artist_url);
		$smarty->assign("frontcover_url",$frontcover_url);
		$smarty->assign("frontcover_thumburl",$frontcover_thumburl);
		$smarty->assign("backcover_url",$backcover_url);
		$smarty->assign("backcover_thumburl",$backcover_thumburl);
		$smarty->assign("song_list",$song_list);
		$smarty->assign("related_albums",$related_albums);
		$smarty->assign("custom_fields",$custom_fields);
		$smarty->assign("shop_url",$shop_url);
		$tm_content=$smarty->fetch("album.tpl");
    	break;

	case "albumlist":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
		$artistDAO=new ArtistDAO($db,$prefix);
		$artistO=$artistDAO->getArtist($_GET['idartist'],$currentlang);
		$albumDAO=new AlbumDAO($db,$prefix);
		$albumList=$albumDAO->getAlbumList($_GET['idartist'],$currentlang);
		$top_albums=$albumDAO->getMostVotedAlbums(10,$_GET['idartist']);
	
	 	$artist_url=ArtistView::getArtistUrl($module_name,$config,$artistO);
	 	$photo_url=ArtistView::getPhotoUrl($artistO,$module_name);
	 	$photothumb_url=ArtistView::getPhotoThumbUrl($artistO,$module_name,100,0);
	 	AlbumView::parseThumbs($module_name,&$top_albums,75,0);
	 	AlbumView::parseThumbs($module_name,&$albumList,75,0);
	  	
	  	$smarty->assign("artist",$artistO);
	  	$smarty->assign("albumList",$albumList);
	  	$smarty->assign("artist_url",$artist_url);
	  	$smarty->assign("photo_url",$photo_url);
	  	$smarty->assign("photothumb_url",$photothumb_url);
	  	$smarty->assign("top_albums",$top_albums);
	  	
		$tm_content=$smarty->fetch("albumlist.tpl");

    	break;
    	
	case "voteSong":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongOO.php");
		$songDAO=new SongDAO($db,$prefix);
		$song=new SongO();
		if(!$songDAO->voteSong($idsong,$_POST['rate'],$_SERVER['REMOTE_ADDR']))
			$message=_TOPMUSIC_SONG_ALREADYVOTED;
		$song=$songDAO->getSong($idsong,$currentlang);
		$songVoted=1;
		$smarty->assign("message",$message);
    case "song":
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
		 require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
		 if(!$songVoted){
			 $songDAO=new SongDAO($db,$prefix);
			 if(!isset($admin) || $admin != $_COOKIE['admin'])
				 $songDAO->addView($_GET['idsong']);
			 $song=new SongO();
			 $song=$songDAO->getSong($_GET['idsong'],$currentlang);
		 }
		 if($song->idalbum!=""){
		 	$albumDAO=new AlbumDAO($db,$prefix);
		 	$album=$albumDAO->getAlbum($song->getIdalbum(),$currentlang);
		 	//die(var_dump($album));
		 	$album_url=AlbumView::getAlbumUrl($module_name,$config,$album);
		 	if($album->idartist!=""){
		 		$artistDAO=new ArtistDAO($db,$prefix);
				$artist=$artistDAO->getArtist($album->getIdartist(),$currentlang);
				$artist_url=ArtistView::getArtistUrl($module_name,$config,$artist);
			}else{
				$artist=new ArtistO();
				$artist->setName(_TOPMUSIC_NA);
				$artist_url="";
			}
		 }else{
		 	$album=new AlbumO();
		 	$album->setTitle(_TOPMUSIC_NA);
		 	$album_url="";
		 	$artist=new ArtistO();
			$artist->setName(_TOPMUSIC_NA);
		 	$artist_url="";
		 }
		 $songlist_url=AlbumView::getSongListUrl($module_name,$config,$album);
		 $albumcover_url=AlbumView::getCoverUrl($module_name,$album,"front");
		 $albumcover_thumburl=AlbumView::getCoverThumbUrl($module_name,$album,"Front",200,0);
		 $rate_code=GenericView::getRateCode($song->avgvotes,$module_name,$tm_theme);
		 $related_songs=$songDAO->getRelated($song->id);
		 $custom_fields=$songDAO->getCustomFields($_GET['idsong']);
		 
		 $smarty->assign("song",$song);
		 $smarty->assign("iniTitle",substr($song->track,0,4));
		 $smarty->assign("extension",substr($song->track,-3));
		 $smarty->assign("rate_code",$rate_code);
		 $smarty->assign("songVoted",$songVoted);
		 $smarty->assign("album",$album);
		 $smarty->assign("artist",$artist);
		 $smarty->assign("album_url",$album_url);
		 $smarty->assign("artist_url",$artist_url);
		 $smarty->assign("songlist_url",$songlist_url);
		 $smarty->assign("albumcover_url",$albumcover_url);
		 $smarty->assign("albumcover_thumburl",$albumcover_thumburl);
		 $smarty->assign("related_songs",$related_songs);
		 $smarty->assign("custom_fields",$custom_fields);
		 $tm_content=$smarty->fetch('song.tpl');

    	 break;
    	
	case "search":
		require_once("modules/$module_name/lib/com/sergids/topmusic/model/GenreDAO.php");
		if($_POST['page']!="" && $_POST['page']>0)
			$searchPage=$_POST['page'];
		else
			$searchPage=1;
		if($_POST['what']!=""){
			switch($_POST['what']){
			 	case "artists":
			 		require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
			 		require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
			  		$artistO=new ArtistO();
			  		$artistView=new ArtistView();
			  		$artistO->setName($_POST['artistname']);
			  		$artistO->setBornyear($_POST['year']);
			  		$artistO->setGenreid($_POST['genre']);
			  		$artistO->setSongtitle($_POST['songname']);
			  		$artistO->setAlbumname($_POST['albumname']);
				    $artistDAO=new ArtistDAO($db,$prefix);
				    $artistList=$artistDAO->searchArtist(&$artistO,$_POST['content'],$currentlang,$searchPage,$config->getResultItems());
			  	    break;
	    	  	case "albums":
	    	  		require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
	    	  		require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
	    	  		$albumO=new AlbumO();
	    	  		$albumView=new AlbumView();
	    	  		$albumO->setArtistname($_POST['artistname']);
	    	  		$albumO->setTitle($_POST['albumname']);
	    	  		$albumO->setSongtitle($_POST['songname']);
	    	  		$albumO->setYeardate($_POST['year']);
	    	  		$albumO->setGenreid($_POST['genre']);
				    $albumDAO=new AlbumDAO($db,$prefix);
				    $albumList=$albumDAO->searchAlbum(&$albumO,$_POST['content'],$currentlang,$searchPage,$config->getResultItems());
			  	    break;
			  	case "songs":
			  	default:
			  		require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
	    	  		require_once("modules/$module_name/lib/com/sergids/topmusic/view/SongView.php");
			  		$songO=new SongO();
			  		$songView=new SongView();
	    	  		$songO->setTitle($_POST['songname']);
	    	  		$songO->setAlbumname($_POST['albumname']);
	    	  		$songO->setArtistname($_POST['artistname']);
	    	  		$songO->setGenreid($_POST['genre']);
			  		$songDAO=new SongDAO($db,$prefix);
				    $songList=$songDAO->searchSong(&$songO,$_POST['content'],$currentlang,$searchPage,$config->getResultItems());
	   	  			if($_POST['page']!="" && $_POST['page']==1)
	   	  				$numSongs=count($songList);
	   	  	}
		}
		$genreDAO=new GenreDAO($db,$prefix);
		$genreList=$genreDAO->getGenreList($currentlang);

		if($_GET["hide"]==1)
			$hide_form=true;
		else
			$hide_form=false;
			
		$smarty->assign("what",$_POST['what']);
		$smarty->assign("artistname",$_POST['artistname']);
		$smarty->assign("albumname",$_POST['albumname']);
		$smarty->assign("songname",$_POST['songname']);
		$smarty->assign("year",$_POST['year']);
		$smarty->assign("genreList",$genreList);
		$smarty->assign("genre",$_POST['genre']);
		$smarty->assign("content",$_POST['content']);
		$smarty->assign("hide",$hide_form);
		$smarty->assign("easyURL",$config->getEasyURL());
		$smarty->assign("easyURLtype",$config->getEasyURLType());
		
		$tm_content=$smarty->fetch("search.tpl");
		
		if($_POST['what']!=""){
			
			$smarty->assign("artistList",$artistList);
			$smarty->assign("albumList",$albumList);
			$smarty->assign("songList",$songList);
			$smarty->assign("searchPage",$searchPage);
			$tm_content.=$smarty->fetch("results.tpl");
		}
    	break; //case search
    
    case "ranking":
 
	    switch($_GET['what']){
	    	default:
	    	case "votedsongs":
	    		require_once("lib/com/sergids/topmusic/model/SongO.php");
	    		require_once("lib/com/sergids/topmusic/model/SongDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/SongView.php");
	    		$songDAO=new SongDAO($db,$prefix);
	    		$songView=new SongView();
	    		$songRankList=$songDAO->getMostVotedSongs($config->getRankItems());
	    		break;
	    	case "votedalbums":
	    		require_once("lib/com/sergids/topmusic/model/AlbumO.php");
	    		require_once("lib/com/sergids/topmusic/model/AlbumDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/AlbumView.php");
	    		$albumDAO=new AlbumDAO($db,$prefix);
	    		$albumView=new AlbumView();
	    		$albumRankList=$albumDAO->getMostVotedAlbums($config->getRankItems());
	    		break;
	    	case "votedartists":
	    		require_once("lib/com/sergids/topmusic/model/ArtistO.php");
	    		require_once("lib/com/sergids/topmusic/model/ArtistDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/ArtistView.php");
	    		$artistDAO=new ArtistDAO($db,$prefix);
	    		$artistView=new ArtistView();
	    		$artistRankList=$artistDAO->getMostVotedArtists($config->getRankItems());
	    		break;
	    	case "visitedsongs":
	    		require_once("lib/com/sergids/topmusic/model/SongO.php");
	    		require_once("lib/com/sergids/topmusic/model/SongDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/SongView.php");
	    		$songDAO=new SongDAO($db,$prefix);
	    		$songView=new SongView();
	    		$songVisitedList=$songDAO->getMostVisitedSongs($config->getRankItems());
	    		break;
	    	case "visitedalbums":
	    		require_once("lib/com/sergids/topmusic/model/AlbumO.php");
	    		require_once("lib/com/sergids/topmusic/model/AlbumDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/AlbumView.php");
	    		$albumDAO=new AlbumDAO($db,$prefix);
	    		$albumView=new AlbumView();
	    		$albumVisitedList=$albumDAO->getMostVisitedAlbums($config->getRankItems());
	    		break;
	    	case "visitedartists":
	    		require_once("lib/com/sergids/topmusic/model/ArtistO.php");
	    		require_once("lib/com/sergids/topmusic/model/ArtistDAO.php");
	    		require_once("lib/com/sergids/topmusic/view/ArtistView.php");
	    		$artistDAO=new ArtistDAO($db,$prefix);
	    		$artistView=new ArtistView();
	    		$artistVisitedList=$artistDAO->getMostVisitedBands($config->getRankItems());
	    }
    	if(!$config->getEasyURL() || $config->getEasyURLType()==2)
    		$on_change="'modules.php?name=".$module_name."&op=ranking&what='+this.options[selectedIndex].value";
    	elseif($config->getEasyURLType()<2)
    		$on_change="'".$tm_BaseURL."/music.php/ranking/'+this.options[selectedIndex].value";
    	$what=$_GET['what'];
    	$smarty->assign("on_change",$on_change);
    	$smarty->assign("rank_options",array(
    						"votedsongs"=>_TOPMUSIC_MOSTRATEDSONGS,
    						"votedalbums"=>_TOPMUSIC_MOSTRATEDALBUMS,
    						"votedartists"=>_TOPMUSIC_MOSTRATEDARTISTS,
    						"visitedsongs"=>_TOPMUSIC_MOSTVISITEDSONGS,
    						"visitedalbums"=>_TOPMUSIC_MOSTVISITEDALBUMS,
    						"visitedartists"=>_TOPMUSIC_MOSTVISITEDARTISTS
    						));
    	$smarty->assign("what",$what);
      	$tm_content=$smarty->fetch("ranking.tpl");
    	

		switch($what){
			default:
			case "votedsongs":
				$songRankList=SongView::setRatesCode($songRankList,$module_name,$tm_theme);
				$smarty->assign("songRankList",$songRankList);
				$tm_content.=$smarty->fetch("songrank_list.tpl");
				break;
			case "votedalbums":
				$albumRankList=AlbumView::setRatesCode($albumRankList,$module_name,$tm_theme);
				$smarty->assign("albumRankList",$albumRankList);
				$tm_content.=$smarty->fetch("albumrank_list.tpl");
				break;
			case "votedartists":
				$artistRankList=ArtistView::setRatesCode($artistRankList,$module_name,$tm_theme);
				$smarty->assign("artistRankList",$artistRankList);
				$tm_content.=$smarty->fetch("artistrank_list.tpl");
				break;
			case "visitedsongs":
				$smarty->assign("songVisitedList",$songVisitedList);
				$tm_content.=$smarty->fetch("songvisited_list.tpl");
				break;
			case "visitedalbums":
				$smarty->assign("albumVisitedList",$albumVisitedList);
				$tm_content.=$smarty->fetch("albumvisited_list.tpl");
				break;
			case "visitedartists":
				$smarty->assign("artistVisitedList",$artistVisitedList);
				$tm_content.=$smarty->fetch("artistvisited_list.tpl");
		}
	    break;//ranking

	    case "charts":
			require_once("modules/$module_name/lib/com/sergids/topmusic/model/ChartDAO.php");
	    	require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumDAO.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongDAO.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/model/AlbumO.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/model/SongO.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/view/SongView.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/view/AlbumView.php");
			require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
			
			$chartDAO=new ChartDAO($db,$prefix);
			$chartList=$chartDAO->getChartList($currentlang); 
			//print_r($chartList);
			$idchart=$_GET['idchart'];
			$chart=$chartDAO->getChart($idchart,$currentlang);
			$smarty->assign("chart",$chart);
			$smarty->assign("idchart",$chart->id);
		    $smarty->assign("chartlist",$chartList);
		    $smarty->assign("on_change","'modules.php?name=$module_name&op=charts&idchart='+this[this.selectedIndex].value");
		    $tm_content=$smarty->fetch("chart.tpl");
			switch($chart->type){
				case "song":
					$tm_content.=$smarty->fetch("songchart_list.tpl");
					break;
				case "album":
					$tm_content.=$smarty->fetch("albumchart_list.tpl");
					break;
				case "artist":
					$tm_content.=$smarty->fetch("artistchart_list.tpl");
					break;
			}
			//$frontcover_url=AlbumView::getCoverUrl($module_name,$albumO,"Front");
			//$backcover_url=AlbumView::getCoverUrl($module_name,$albumO,"Back");
			
		
	    	break;
	    
	case "AZ":
	  require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistDAO.php");
	  require_once("modules/$module_name/lib/com/sergids/topmusic/model/ArtistO.php");
	  require_once("modules/$module_name/lib/com/sergids/topmusic/model/Artist.php");
	  require_once("modules/$module_name/lib/com/sergids/topmusic/view/ArtistView.php");
	  $artistDAO=new ArtistDAO($db,$prefix);
	  $artistOO=new Artist();
	  $letter = $_GET['letter'];
	  $letters=$artistDAO->getArtistIndexLetters();
	  if($letter=="" && $config->getAZAdvanced())
	  	$letter=$letters[0];

  	  $artistList=$artistDAO->getArtistIndex($letter);
  	  $artistOO->orderAZ(&$artistList);
      
	  //include("modules/$module_name/includes/AZ.php");
	  if(!$config->getAZAdvanced())
	  	$az_array=ArtistView::getArtistAZ($artistList,$letters,$module_name,$config);
	  else
	  	$az_array=ArtistView::getArtistAZ($artistList,$letter,$module_name,$config);
	  //$letters_url = ArtistView::getLettersUrl($letters,$module_name,$config,$letter);
		
	  $smarty->assign("artistView",new ArtistView());
	  $smarty->assign("config",$config);
	  $smarty->assign("module_name",$module_name);
	  $smarty->assign("aLetters",$letters);
	  $smarty->assign("az_array",$az_array);
	  $smarty->assign("tm_azcolumns",$config->getAZColumns());
	  $smarty->assign("include_menu","az_menu.tpl");
	  $smarty->assign("include_list","az_list.tpl");
	  $tm_content=$smarty->fetch("az.tpl");
	  break;
	case "getFile":
		require_once("modules/$module_name/lib/com/sergids/common/File.php");
		File::getFile($_GET['path']);
		break;
	default:
		die("This is not a valid parameter");
}

$smarty_main=new Smarty;
$smarty_main->template_dir = "modules/$module_name/themes/".$tm_theme."/";
$smarty_main->compile_dir = "modules/$module_name/themes_c/".$tm_theme."/";
$smarty_main->cache_dir = $smarty->compile_dir;
$smarty_main->caching = false;
$smarty_main->assign("module_name",$module_name);
$smarty_main->assign("tm_theme",$tm_theme);
$smarty_main->assign("tm_content",$tm_content);
$smarty_main->assign("tm_showtopmenu",$config->getTopMenu());
$smarty_main->assign("tm_content_menu",$tm_content_menu);
$smarty_main->assign("tm_content_path",$tm_content_path);
$smarty_main->display("main.tpl");
include("footer.php");
?>
Return current item: Top Music module