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

/************************************************************************/
/* PHP-NUKE: Top Music New Songs 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 songs to show
$tmNumSongs=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_New_Songs.php", $_SERVER['PHP_SELF'])) 
{
    Header("Location: index.php");
    die();
}

include_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/SongO.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();

function getLastSongList($numSongs=10){
	global $db,$prefix;
	$sSql="	SELECT 
			  ".$prefix."_topmusic_song.idsong,
			  ".$prefix."_topmusic_song.title,
			  ".$prefix."_topmusic_song.idalbum,
			  ".$prefix."_topmusic_artist.idartist,
			  ".$prefix."_topmusic_artist.name as artistname,
			  ".$prefix."_topmusic_album.title as albumname
			FROM
			  ".$prefix."_topmusic_song
			  LEFT OUTER JOIN ".$prefix."_topmusic_album ON (".$prefix."_topmusic_song.idalbum=".$prefix."_topmusic_album.idalbum)
			  LEFT OUTER JOIN ".$prefix."_topmusic_artist ON (".$prefix."_topmusic_album.idartist=".$prefix."_topmusic_artist.idartist)
			ORDER BY idsong desc
			LIMIT ".$numSongs;
	//echo "sql=".$sSql."<br>";
	$stmt=$db->sql_query($sSql);
	$i=0;
	while($rs=$db->sql_fetchrow($stmt)){
		$songO=new SongO();
		$songO->setId($rs['idsong']);
		$songO->setTitle($rs['title']);
		$songO->setIdalbum($rs['idalbum']);
		$songO->setAuthor($rs['idartist']);
		$songO->setArtistname($rs['artistname']);
		$songO->setAlbumname($rs['albumname']);
		$songList[$i]=$songO;
		$i++;
	}
	$db->sql_freeresult($stmt);
	return $songList;
}

$songList=getLastSongList($tmNumSongs);
$content="<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";

if(count($songList)>0){
	for($i=0;$i<count($songList);$i++){
		$song=$songList[$i];
		$title=$song->getTitle();
		$idsong=$song->getId();
		$idartist=$song->getAuthor();
		$idalbum=$song->getIdalbum();
		if($TMEasyURL){
			if(!$TMEasyURLType)
				$tm_url="music.php/artist/".urlencode($song->getArtistname())."/album/".urlencode($song->getAlbumname())."/song/".urlencode($song->getTitle());
			elseif($TMEasyURLType==1)
				$tm_url="music.php/artist/".$idartist."/album/".$idalbum."/song/".$idsong;
			else
				$tm_url="song".$idartist."_".$idalbum."_".$idsong."-".urlencode($song->getTitle()).".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></tr>";	
	}
} else {
	$content.="<tr><td align=\"center\">"._TOPMUSIC_NOSONGSLISTED."</td></tr>";
}
$content.="</table>\n";
?>
Return current item: Top Music module