<?php
/************************************************************************/
/* PHP-NUKE: Top Music Top Albums Mosaic */
/* ===================================== */
/* */
/* 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 albums per row
$tmNumAlbumsRow=9;
//number of rows
$tmNumRows=2;
//images size (pixels)
$tmImageSize=70;
//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";
//what to show (1=>Most voted, 2=>Most visited, 3 =>Newest)
$tmWhattoshow=3;
/***************************************************************/
//Don't touch this code please
if (eregi("block-TMTopAlbumsMosaic.php",$_SERVER[PHP_SELF])) {
Header("Location: ../index.php");
die();
}
//global $prefix, $db;
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/AlbumO.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/AlbumDAO.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/GenericView.php");
require_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/AlbumView.php");
global $db,$prefix,$currentlang;
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();
$albumDAO=new AlbumDAO($db,$prefix);
switch($tmWhattoshow){
default:
case 1:
$albumList=$albumDAO->getMostVotedAlbums($tmNumAlbumsRow*$tmNumRows);
break;
case 2:
$albumList=$albumDAO->getMostVisitedAlbums($tmNumAlbumsRow*$tmNumRows);
break;
case 3:
$albumList=$albumDAO->getLastAlbumList($tmNumAlbumsRow*$tmNumRows);
break;
}
$content="<table cellspacing=\"2\" cellpadding=\"0\" border=\"0\" align=\"center\">\n";
$content.="<tr>\n";
//echo "count=".count($albumList);
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($album->getArtistname())."/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.="<td align=\"center\"><a href=\"".$tm_url."\">";
if($album->getFrontcoverFile()!=""){
$frontcover_url=AlbumView::getCoverUrl($tmModuleName,$album,"Front");
$frontcover_thumburl=AlbumView::getCoverThumbUrl($tmModuleName,$album,"Front",$tmImageSize,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=\"".$tmImageSize."\">";
}else
$content.="<img src=\"".$album->getFrontcoverUrl()."\" title=\"".$title." - ".$artistname."\" border=\"0\" width=\"".$tmImageSize."\">";
$content.="</a></td>";
if((($i+1)%$tmNumAlbumsRow)==0 && $i<(count($albumList)-1) && $i>0){
$content.="</tr>";
$content.="<tr>\n";
}elseif($i==(count($albumList)-1) && (($i+1)%$tmNumAlbumsRow)!=0){
//echo "i=".$i."<br>";
//echo "i%tmNumAlbumsRow=".$i+1%$tmNumAlbumsRow."<br>";
$content.="<td colspan=\"".($tmNumAlbumsRow-(($i+1)%$tmNumAlbumsRow))."\"> </td>";
}
}
$content.="</tr></table>\n";
?>