Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/blocks/block-TopMusic_Most_Voted-Center.php
<?php

/************************************************************************/
/* PHP-NUKE: Top Music Most Voted Items                                 */
/* =======================================                                 */
/*                                                                      */
/* Copyright (c) 2004-2005 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.       */
/************************************************************************/

/*****************/
/* configuration */
/*****************/
//number of items to show
$tmNumVotedItems=3;

//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";

//photo width
$tmPhotoWidth=80;

//Artist
//show photo? (0=no 1=yes)
$tmShowArtistPhoto=1;
//show text? (0=no 1=yes)
$tmShowArtistText=1;
//show stars? (0=no 1=yes)
$tmShowArtistStars=1;

//Album
//show covers? (0=no 1=yes)
$tmShowAlbumCover=1;
//show text? (0=no 1=yes)
$tmShowAlbumText=1;
//show stars? (0=no 1=yes)
$tmShowAlbumStars=1;

//Song
//show album covers? (0=no 1=yes)
$tmShowSongCover=1;
//show text? (0=no 1=yes)
$tmShowSongText=1;
//show stars? (0=no 1=yes)
$tmShowSongStars=1;

/***************************************************************/
//Don't touch this code please


if (eregi("block-TopMusic_Most_Voted-Center.php",$_SERVER[PHP_SELF])) {
    Header("Location: ../index.php");
    die();
}

global $db,$prefix,$currentlang;

require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/ArtistDAO.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/AlbumDAO.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/SongDAO.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/GenericView.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/ArtistView.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/AlbumView.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/SongView.php");
include_once("modules/".$tmModuleName."/admin/language/lang-".$currentlang.".php");

if(!is_object($tm_config)){
	require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/ConfigDAO.php");
	require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/ConfigO.php");
	$configDAO= new ConfigDAO($db,$prefix);
	$tm_config=$configDAO->load();
}
//use easy URL? (according to settings in Top Music module administration)
$TMEasyURL=$tm_config->getEasyURL();
//Eeasy URL Type (according to settings in Top Music module administration)
$TMEasyURLType=$tm_config->getEasyURLType();

$artistDAO=new ArtistDAO($db,$prefix);
$albumDAO=new AlbumDAO($db,$prefix);
$songDAO=new SongDAO($db,$prefix);
$bandList=$artistDAO->getMostVotedArtists($tmNumVotedItems);
$albumList=$albumDAO->getMostVotedAlbums($tmNumVotedItems);
$songList=$songDAO->getMostVotedSongs($tmNumVotedItems);

$content="<table cellspacing=\"4\" cellpadding=\"0\" border=\"0\" width=\"100%\" align=\"center\">\n";
$content.="<tr>";
$content.="<td align=\"center\" valign=\"top\">";
//artists
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">\n";
$content.="<tr><td colspan=\"2\" align=\"center\"><b>"._TOPMUSIC_ARTISTS."</b></td></tr>";
$content.="<tr><td>&nbsp;</td></tr>";	
if(count($bandList)>0){
	for($i=0;$i<count($bandList);$i++){
		$band=$bandList[$i];
		$name=$band->getName();
		$idartist=$band->getId();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($name);
			elseif($TMEasyURLType==1)
				$tm_url="music.php/artist/".$idartist;
			else
				$tm_url="artist".$idartist."-".urlencode($name).".html";
		}else
			$tm_url="modules.php?name=".$tmModuleName."&op=artist&idartist=".$idartist;
		$content.="<tr><td valign=\"top\" align=\"center\"><a href=\"".$tm_url."\">";
		if($tmShowArtistPhoto){
			$photo_url=ArtistView::getPhotoUrl($band,$tmModuleName);
			$photo_thumburl=ArtistView::getPhotoThumbUrl($band,$tmModuleName,$tmPhotoWidth,0);
			if($photo_thumburl!="")
				$content.="<img src=\"".$photo_thumburl."\" title=\"".$name." (".$band->getBornyear().")\" border=\"0\">";
			else
				$content.="<img src=\"".$photo_url."\" title=\"".$nameBlock." (".$band->getBornyear().")\" border=\"0\" width=\"".$tmPhotoWidth."\">";
		}
		if($tmShowArtistPhoto && $tmShowArtistText)
			$content.="<br>";
		if($tmShowArtistText)
			$content.=$name;
		if($tmShowArtistText && $tmShowArtistStars)
			$content.="<br>";
		if($tmShowArtistStars){
			$genericView=new GenericView();
			$avg=$band->getAvgvotes();
			$tmTheme=$tm_config->getTheme();
			$stars=$genericView->getRateCode($avg,$tmModuleName,$tmTheme);
			$content.=$stars;
		}
		$content.="</a></td>";
		$content.="</tr>";
		$content.="<tr><td>&nbsp;</td></tr>";
	}
} else {
	$content.="<tr><td align=\"center\">"._TOPMUSIC_NOBANDSLISTED."</td></tr>";
}
$content.="</table>\n";
//end artists
$content.="</td>";
$content.="<td width=\"1\" bgcolor=\"#000000\"></td>";
$content.="<td align=\"center\" valign=\"top\">";
//albums
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" align=\"center\">\n";
$content.="<tr><td colspan=\"2\" align=\"center\"><b>"._TOPMUSIC_ALBUMS."</b></td></tr>";
$content.="<tr><td>&nbsp;</td></tr>";	
if(count($albumList)>0){
	for($i=0;$i<count($albumList);$i++){
		$album=$albumList[$i];
		$title=$album->getTitle();
		$idalbum=$album->getId();
		$idartist=$album->getIdartist();
		$artistname=$album->getArtistname();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($artustname)."/album/".urlencode($title);
			elseif($TMEasyURLType==1)
				$tm_url="music.php/artist/".$idartist."/album/".$idalbum;
			else
				$tm_url="album".$idartist."_".$idalbum."-".urlencode($title).".html";
		}else
			$tm_url="modules.php?name=".$tmModuleName."&op=album&idartist=".$idartist."&idalbum=".$idalbum;
		$content.="<tr><td valign=\"top\" align=\"center\"><a href=\"".$tm_url."\"> ";
		if($tmShowAlbumCover){
			if($album->getFrontcoverFile()!=""){
				$frontcover_url=AlbumView::getCoverUrl($tmModuleName,$album,"Front");
				$frontcover_thumburl=AlbumView::getCoverThumbUrl($tmModuleName,$album,"Front",$tmPhotoWidth,0);
				if($frontcover_thumburl!="")
					$content.="<img src=\"".$frontcover_thumburl."\" title=\"".$title." - ".$artistname."\" border=\"0\">";
				else
					$content.="<img src=\"".$frontcover_url."\" title=\"".$title." - ".$artistname."\" border=\"0\" width=\"".$tmPhotoWidth."\">";
			}else
				$content.="<img src=\"".$album->getFrontcoverUrl()."\" alt=\"".$title." - ".$artistname."\" border=\"0\" width=\"".$tmPhotoWidth."\">";
		}
		if($tmShowAlbumCover && $tmShowAlbumText)
			$content.="<br>";
		if($tmShowAlbumText)
			$content.=$title;
		if($tmShowAlbumText && $tmShowAlbumStars)
			$content.="<br>";
		if($tmShowAlbumStars){
			$genericView=new GenericView();
			$avg=$album->getAvgvotes();
			$theme=$tm_config->getTheme();
			$stars=$genericView->getRateCode($avg,$tmModuleName,$theme);
			$content.=$stars;
		}
		$content.="</a></td>";
		$content.="</tr>";	
		$content.="<tr><td>&nbsp;</td></tr>";
	}
} else {
	$content.="<tr><td align=\"center\">"._TOPMUSIC_NOALBUMSLISTED."</td></tr>";
}
$content.="</table>\n";
//end albums
$content.="</td>";
$content.="<td width=\"1\" bgcolor=\"#000000\"></td>";
$content.="<td align=\"center\" valign=\"top\">";
//songs
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\">";
$content.="<tr><td colspan=\"2\" align=\"center\"><b>"._TOPMUSIC_SONGS."</b></td></tr>";
$content.="<tr><td>&nbsp;</td></tr>";	
if(count($songList)>0){
	for($i=0;$i<count($songList);$i++){
		$song=$songList[$i];
		$title=$song->getTitle();
		$idsong=$song->getId();
		$idartist=$song->getIdartist();
		$idalbum=$song->getIdalbum();
		$artistname=$song->getArtistname();
		$albumname=$song->getAlbumname();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($artistname)."/album/".urlencode($albumname)."/song/".urlencode($title);
			elseif($TMEasyURLType==1)
				$tm_url="music.php/artist/".$idartist."/album/".$idalbum."/song/".$idsong;
			else
				$tm_url="song".$idartist."_".$idalbum."_".$idsong."-".urlencode($title).".html";
		}else
			$tm_url="modules.php?name=".$tmModuleName."&op=song&idartist=".$idartist."&idalbum=".$idalbum."&idsong=".$idsong;
		$content.="<tr><td align=\"center\"><a href=\"".$tm_url."\">";
		if($tmShowSongCover){
			if($song->getAlbumcoverFile()!=""){
				$frontcover_url=SongView::getCoverUrl($tmModuleName,$song);
				$frontcover_thumburl=SongView::getCoverThumbUrl($tmModuleName,$song,$tmPhotoWidth,0);
				if($frontcover_thumburl!="")
					$content.="<img src=\"".$frontcover_thumburl."\" title=\"".$title." - ".$artistname."\" border=\"0\">";
				else
					$content.="<img src=\"".$frontcover_url."\" title=\"".$title." - ".$artistname."\" border=\"0\" width=\"".$tmPhotoWidth."\">";
			}else
				$content.="<img src=\"".$song->getAlbumcoverUrl()."\" alt=\"".$title." - ".$artistname."\" border=\"0\" width=\"".$tmPhotoWidth."\">";
		}
		if($tmShowSongCover && $tmShowSongText)
			$content.="<br>";
		if($tmShowSongText)
			$content.=$title;
		if($tmShowSongText && $tmShowSongStars)
			$content.="<br>";
		if($tmShowSongStars){
			$genericView=new GenericView();
			$avg=$song->getAvgvotes();
			$theme=$tm_config->getTheme();
			$stars=$genericView->getRateCode($avg,$tmModuleName,$theme);
			$content.=$stars;
		}
		$content.="</a></td>";
		$content.="</tr>";
		$content.="<tr><td>&nbsp;</td></tr>";	
	}
} else {
	$content.="<tr><td align=\"center\">"._TOPMUSIC_NOSONGSLISTED."</td></tr>";
}
$content.="</table>";
//end songs

$content.="</td>";
$content.="</tr>";
$content.="</table>\n";
?>
Return current item: Top Music module