<?php
/************************************************************************/
/* PHP-NUKE: Top Music New Bands 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 new bands to show
$tmNumBands=30;
//number of bands per row
$tmNumAlbumsRow=5;
//number of rows
$tmNumRows=3;
//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";
/***************************************************************/
//Don't touch this code please
if (eregi("block-TMNewBandsMosaic.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 a.idartist, a.name as artistname
FROM ".$prefix."_topmusic_artist as a
ORDER BY a.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";
require_once("modules/$tmModuleName/lib/com/sergids/topmusic/model/ArtistDAO.php");
require_once("modules/$tmModuleName/lib/com/sergids/topmusic/view/ArtistView.php");
require_once("modules/$tmModuleName/lib/com/sergids/topmusic/view/GenericView.php");
// Set avatar size
$Avsize = "width=\"110\" height=\"137\" align=\"absmiddle\"";
for($i=0;$i<count($bandList);$i++){
$band=$bandList[$i];
$name=$band->getName();
$idartist=$band->getId();
$bio = substr($band->getBiography(), 0, 100). "... ";
$artistDAO=new ArtistDAO($db,$prefix);
$artistDAO->addView($idartist);
$artistO=$artistDAO->getArtist($idartist,$currentlang);
$photo_url=ArtistView::getPhotoUrl($artistO,$tmModuleName);
$photothumb_url=ArtistView::getPhotoThumbUrl($artistO,$tmModuleName,200,0);
$bio_url=ArtistView::getBioUrl($tmModuleName,$tm_config,$artistO);
$tm_url="modules.php?name=".$tmModuleName."&op=artist&idartist=".$idartist;
$content .="<a href=\"".$tm_url."\">";
$content .="<img src=\"".$photothumb_url."\" cellspacing=\"2\" cellpadding=\"2\" border=\"0\" hspace=\"6\"></a></td>";
if((($i+1)%$tmNumAlbumsRow)==0 && $i<(count($bandList)-1) && $i>0){
$content .= "</tr>";
$content .= "<tr>\n";
}elseif($i==(count($bandList)-1) && (($i+1)%$tmNumAlbumsRow)!=0){
// $content .= "i=".$i."<br>";
// $content .= "i%tmNumAlbumsRow=".$i+1%$tmNumAlbumsRow."<br>";
$content .= "<td colspan=\"".($tmNumAlbumsRow-(($i+1)%$tmNumAlbumsRow))."\"> </td>";
}
}
$content .= "</tr></table>\n";
?>