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

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

include_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/ArtistO.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 getLastBandList($numBands=10){
	global $db,$prefix;
	$sSql="	SELECT 
			  idartist,
			  name as artistname
			FROM
			  ".$prefix."_topmusic_artist
			ORDER BY idartist desc
			LIMIT ".$numBands;
	//echo "sql=".$sSql."<br>";
	$stmt=$db->sql_query($sSql);
	$i=0;
	while($rs=$db->sql_fetchrow($stmt)){
		$bandO=new ArtistO();
		$bandO->setId($rs['idartist']);
		$bandO->setName($rs['artistname']);
		$bandList[$i]=$bandO;
		$i++;
	}
	$db->sql_freeresult($stmt);
	return $bandList;
}

$bandList=getLastBandList($tmNumBands);
$content="<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";

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($band->getName());
		elseif($TMEasyURLType==1)
			$tm_url="music.php/artist/".$idartist;
		else
			$tm_url="artist".$idartist."-".urlencode($band->getName()).".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></tr>";	
}
$content.="</table>\n";
?>
Return current item: Top Music module