Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/blocks/block-TopMusic_Rank_Songs.php
<?php
/************************************************************************/
/* PHP-NUKE: Top Music Rank 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 bands to show in rank
$tmNumBands=10;

//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";
/***************************************************************/
//Don't touch this code please


if (eregi("block-TopMusic_RankSongs.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 getRankSongLists($numBands=10){
   global $db,$prefix;
   $sSql="   SELECT
           ".$prefix."_topmusic_song.idalbum,
           ".$prefix."_topmusic_album.idartist,
           ".$prefix."_topmusic_artist.name as artistname,
           COUNT(*)
         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)
         GROUP BY ".$prefix."_topmusic_album.idartist
         ORDER BY 'COUNT(*)' 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']);
      $bandO->setCount($rs['COUNT(*)']);
      $bandList[$i]=$bandO;
      $i++;
   }
   $db->sql_freeresult($stmt);
   return $bandList;
}

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

for($i=0;$i<count($bandList);$i++){
   $band=$bandList[$i];
   $idartist=$band->getId();
   $name=$band->getName();
   $count=$band->getCount();
   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><td>(".$count.")</td></tr>";   
}
$content.="</table>\n";
?> 
Return current item: Top Music module