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

/************************************************************************/
/* PHP-NUKE: Top Music New Albums block                                 */
/* ====================================                                 */
/*                                                                      */
/* 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 new albums to show
$tmNumAlbums=3; 

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

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

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

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();

include_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/AlbumO.php");
function getLastAlbumList($numAlbums=10){
	global $db,$prefix;
	$sSql="	SELECT 
			  ".$prefix."_topmusic_album.idalbum,
			  ".$prefix."_topmusic_album.title,
			  ".$prefix."_topmusic_artist.idartist,
			  ".$prefix."_topmusic_artist.name as artistname
			FROM
			  ".$prefix."_topmusic_album
			  LEFT OUTER JOIN ".$prefix."_topmusic_artist ON (".$prefix."_topmusic_album.idartist=".$prefix."_topmusic_artist.idartist)
			ORDER BY idalbum desc
			LIMIT ".$numAlbums;
	//echo "sql=".$sSql."<br>";
	$stmt=$db->sql_query($sSql);
	$i=0;
	while($rs=$db->sql_fetchrow($stmt)){
		$albumO=new AlbumO();
		$albumO->setId($rs['idalbum']);
		$albumO->setTitle($rs['title']);
		$albumO->setIdartist($rs['idartist']);
		$albumO->setArtistname($rs['artistname']);
		$albumList[$i]=$albumO;
		$i++;
	}
	$db->sql_freeresult($stmt);
	return $albumList;
}

$albumList=getLastAlbumList($tmNumAlbums);
$content="<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";

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($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></tr>";	
}
$content.="</table>\n";
?>
Return current item: Top Music module