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

/************************************************************************/
/* PHP-NUKE: Top Music Most Visited 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
$tmNumVisitedItems=3;

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

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


if (eregi("block-TopMusic_Most_Visited-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");

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 config.php in module directory)
$TMEasyURL=$tm_config->getEasyURL();
//EasyURL type (URL content)
$TMEasyURLType=$tm_config->getEasyURLType();


$artistDAO=new ArtistDAO($db,$prefix);
$albumDAO=new AlbumDAO($db,$prefix);
$songDAO=new SongDAO($db,$prefix);
$bandList=$artistDAO->getMostVisitedBands($tmNumVisitedItems);
$albumList=$albumDAO->getMostVisitedAlbums($tmNumVisitedItems);
$songList=$songDAO->getMostVisitedSongs($tmNumVisitedItems);

$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>";
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\">".($i+1).".-</td><td><a href=\"".$tm_url."\">".$name."</a></td>";
		$content.="<td> (".$band->getCount().") </td>";
		$content.="</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\">\n";
$content.="<tr><td colspan=\"2\" align=\"center\"><b>"._TOPMUSIC_ALBUMS."</b></td></tr>";
if(count($albumList)>0){
	for($i=0;$i<count($albumList);$i++){
		$album=$albumList[$i];
		$title=$album->getTitle();
		$artistname=$album->getArtistname();
		$idalbum=$album->getId();
		$idartist=$album->getIdartist();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($artistname)."/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\">".($i+1).".-</td><td><a href=\"".$tm_url."\">".$title."</a></td>";
		$content.="<td> (".$album->getCount().") </td>";
		$content.="</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>";
if(count($songList)>0){
	for($i=0;$i<count($songList);$i++){
		$song=$songList[$i];
		$artistname=$song->getArtistname();
		$albumtitle=$song->getAlbumname();
		$title=$song->getTitle();
		$idsong=$song->getId();
		$idartist=$song->getIdartist();
		$idalbum=$song->getIdalbum();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($artistname)."/album/".urlencode($albumtitle)."/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 valign=\"top\">".($i+1).".-</td><td><a href=\"".$tm_url."\">".$title."</a></td>";
		$content.="<td> (".$song->getCount().") </td>";
		$content.="</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