<?php
/************************************************************************/
/* PHP-NUKE: Top Music Most Voted 2 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 in each row
$tmNumVotedBands=4;
$tmNumVotedAlbums=4;
$tmNumVotedSongs=4;
//images height
$tmImagesHeight=80;
//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";
/***************************************************************/
//Don't touch this code please
if (eregi("block-TopMusic_Tops-Center.php",$_SERVER[PHP_SELF])) {
Header("Location: ../index.php");
die();
}
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");
global $db,$prefix,$currentlang;
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 config.php in module directory)
$TMEasyURL=$tm_config->getEasyURL();
//EasyURL type (URL content)
$TMEasyURLType=$tm_config->getEasyURLType();
$tmTheme=$tm_config->getTheme();
$genericView=new GenericView();
$artistDAO=new ArtistDAO($db,$prefix);
$albumDAO=new AlbumDAO($db,$prefix);
$songDAO=new SongDAO($db,$prefix);
$bandList=$artistDAO->getMostVotedArtists($tmNumVotedBands);
$albumList=$albumDAO->getMostVotedAlbums($tmNumVotedAlbums);
$songList=$songDAO->getMostVotedSongs($tmNumVotedSongs);
$content="<table cellspacing=\"4\" cellpadding=\"0\" border=\"0\" width=\"100%\" align=\"center\">\n";
$content.="<tr>\n";
$content.="<td align=\"center\" valign=\"top\">\n";
//artists
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
$content.="<tr><td align=\"center\" colspan=\"".count($bandList)."\"><b>"._TOPMUSIC_ARTISTS."</b></td></tr>\n";
if(count($bandList)>0){
for($i=0;$i<count($bandList);$i++){
$band=$bandList[$i];
$name=$band->getName();
$idartist=$band->getId();
$content.="<td valign=\"bottom\" align=\"center\" width=\"".(100/count($bandList))."%\">\n";
$content.="<table>\n";
if($TMEasyURL){
if($TMEasyURLType==1)
$artistURL="music.php/artist/".$idartist;
elseif($TMEasyURLType==2)
$artistURL="artist".$idartist."-".urlencode($band->getName()).".html";
else
$artistURL="music.php/artist/".urlencode($band->getName());
}else
$artistURL="modules.php?name=".$tmModuleName."&op=artist&idartist=".$idartist;
$content.="<tr><td align=\"center\"><a href=\"".$artistURL."\">";
if($band->getPhotoFile()!=""){
$photo_url=ArtistView::getPhotoUrl($band,$tmModuleName);
$photo_thumburl=ArtistView::getPhotoThumbUrl($band,$tmModuleName,0,$tmImagesHeight);
if($photo_thumburl!="")
$content.="<img src=\"".$photo_thumburl."\" title=\"".$name." (".$band->getBornyear().")\" border=\"0\">";
else
$content.="<img src=\"".$photo_url."\" title=\"".$name." (".$band->getBornyear().")\" border=\"0\" height=\"".$tmImagesHeight."\">";
}else
$content.="<img src=\"modules/".$tmModuleName."/photos/".$band->getPhoto()."\" height=\"".$tmImagesHeight."\" border=\"0\" title=\"".$name."\">";
$content.="</a></td></tr>\n";
$content.="<tr><td align=\"center\"><a href=\"".$artistURL."\">".$name."</a><br>".$genericView->getRateCode(round($band->getAvgvotes(),1),$tmModuleName,$tmTheme)."</td>\n";
$content.="</tr>\n";
$content.="</table>\n";
$content.="</td>\n";
}
} else {
$content.="<tr><td align=\"center\">"._TOPMUSIC_NOBANDSLISTED."</td></tr>";
}
$content.="</table>\n";
//end artists
$content.="</td></tr>\n";
$content.="<tr><td height=\"1\" bgcolor=\"#000000\"></td></tr>\n";
$content.="<tr><td align=\"center\" valign=\"top\">\n";
//albums
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
$content.="<tr><td colspan=\"".count($albumList)."\" align=\"center\"><b>"._TOPMUSIC_ALBUMS."</b></td></tr>\n";
if(count($albumList)>0){
for($i=0;$i<count($albumList);$i++){
$album=$albumList[$i];
$title=$album->getTitle();
$idalbum=$album->getId();
$idartist=$album->getIdartist();
$content.="<td valign=\"bottom\" align=\"center\" width=\"".(100/count($albumList))."%\">\n";
$content.="<table>\n";
if($TMEasyURL){
if($TMEasyURLType==1)
$albumURL="music.php/artist/".$idartist."/album/".$idalbum;
elseif($TMEasyURLType==2)
$albumURL="album".$idartist."_".$idalbum."-".urlencode($album->getTitle()).".html";
else
$albumURL="music.php/artist/".urlencode($album->getArtistname())."/album/".urlencode($album->getTitle());
}else
$albumURL="modules.php?name=".$tmModuleName."&op=album&idartist=".$idartist."&idalbum=".$idalbum;
$content.="<tr><td align=\"center\"><a href=\"".$albumURL."\">";
if($album->getFrontcoverFile()!=""){
$frontcover_url=AlbumView::getCoverUrl($tmModuleName,$album,"front");
$frontcover_thumburl=AlbumView::getCoverThumbUrl($tmModuleName,$album,"front",0,$tmImagesHeight);
if($frontcover_thumburl!="")
$content.="<img src=\"".$frontcover_thumburl."\" title=\"".$title." - ".$album->getArtistname()."\" border=\"0\">";
else
$content.="<img src=\"".$frontcover_url."\" title=\"".$title." - ".$album->getArtistname()."\" border=\"0\" height=\"".$tmImagesHeight."\">";
} else
$content.="<img src=\"".$album->getFrontcoverUrl()."\" height=\"".$tmImagesHeight."\" border=\"0\" title=\"".$title."\">";
$content.="</a></td></tr>\n";
$content.="<tr><td align=\"center\"><a href=\"".$albumURL."\">".$title."</a><br>".$genericView->getRateCode(round($album->getAvgvotes(),1),$tmModuleName,$tmTheme)."</td>\n";
$content.="</tr>\n";
$content.="</table>\n";
$content.="</td>\n";
}
} else {
$content.="<tr><td align=\"center\">"._TOPMUSIC_NOALBUMSLISTED."</td></tr>";
}
$content.="</table>\n";
//end albums
$content.="</td></tr>\n";
$content.="<tr><td height=\"1\" bgcolor=\"#000000\"></td></tr>\n";
$content.="<tr><td align=\"center\" valign=\"top\">\n";
//songs
$content.="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" width=\"100%\">\n";
$content.="<tr><td colspan=\"".count($songList)."\" align=\"center\" valign=\"bottom\"><b>"._TOPMUSIC_SONGS."</b></td></tr>\n";
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();
if($TMEasyURL){
if($TMEasyURLType==1)
$songURL="music.php/artist/".$idartist."/album/".$idalbum."/song/".$idsong;
elseif($TMEasyURLType==2)
$songURL="song".$idartist."_".$idalbum."_".$idsong."-".urlencode($title).".html";
else
$songURL="music.php/artist/".urlencode($song->getArtistName())."/album/".urlencode($song->getAlbumname())."/song/".urlencode($title);
}else
$songURL="modules.php?name=".$tmModuleName."&op=song&idartist=".$idartist."&idalbum=".$idalbum."&idsong=".$idsong;
$content.="<td valign=\"bottom\" align=\"center\" width=\"".(100/count($songList))."%\">\n";
$content.="<table>\n";
$content.="<tr><td align=\"center\"><a href=\"".$songURL."\">";
if($song->getAlbumcoverFile()!=""){
$frontcover_url=SongView::getCoverUrl($tmModuleName,$song);
$frontcover_thumburl=SongView::getCoverThumbUrl($tmModuleName,$song,0,$tmImagesHeight);
if($frontcover_thumburl!="")
$content.="<img src=\"".$frontcover_thumburl."\" border=\"0\" title=\"".$title." (".$song->getArtistname().")\">";
else
$content.="<img src=\"".$frontcover_url."\" height=\"".$tmImagesHeight."\" border=\"0\" title=\"".$title." (".$song->getArtistname().")\">";
}else
$content.="<img src=\"".$song->getAlbumcoverUrl()."\" height=\"".$tmImagesHeight."\" border=\"0\" title=\"".$title." (".$song->getArtistname().")\">";
$content.="</a></td></tr>\n";
$content.="<tr><td align=\"center\"><a href=\"".$songURL."\">".$title."</a><br>".$genericView->getRateCode(round($song->getAvgvotes(),1),$tmModuleName,$tmTheme)."</td>\n";
$content.="</tr>\n";
$content.="</table>\n";
$content.="</td>\n";
}
} else {
$content.="<tr><td align=\"center\">"._TOPMUSIC_NOSONGSLISTED."</td></tr>";
}
$content.="</table>\n";
//end songs
$content.="</td>\n";
$content.="</tr>\n";
$content.="</table>\n";
?>