<?php
/************************************************************************/
/* PHP-NUKE: Top Music Charts block */
/* ==================================== */
/* */
/* Copyright (c) 2004-2008 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 */
/*****************/
//if you have changed the Top Music Module name, reflect it here:
$tmModuleName="topMusic";
//if you want to show only one chart, specify its id here
$tm_chartblock_idchart="";
//topmusic theme,. You can change it in Top Music Settings Administration
$tm_chartblock_theme="sergids";
//show/hide track player. Set this option true/false in order to show/hide the player (song charts)
$tm_chartblock_player=true;
/***************************************************************/
//Don't touch this code below please
if (eregi("block-TM_Chart.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/ChartO.php");
include_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/model/ChartDAO.php");
include_once("modules/".$tmModuleName."/lib/com/sergids/topmusic/view/GenericView.php");
$tm_chartblock_chartDAO=new ChartDAO($db,$prefix);
$tm_chartblock_chart=$tm_chartblock_chartDAO->getChart($tm_chartblock_idchart,$currentlang);
$content='<LINK REL="StyleSheet" HREF="modules/'.$tmModuleName.'/themes/'.$tm_chartblock_theme.'/css/charts.css" TYPE="text/css">';
$content.="\n";
$content.="<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\">\n";
foreach($tm_chartblock_chart->elements as $tm_chartblock_element){
$tm_chartblock_elementO=$tm_chartblock_element->element;
$content.='<tr>
<td class="position">'.$tm_chartblock_element->position.'</td>
<td class="position_ant">';
if($tm_chartblock_element->chartsince==0)
$content.='<img src="modules/'.$tmModuleName.'/themes/'.$tm_chartblock_theme.'/images/new.gif" align="absmiddle" title="New" width="10">';
elseif(($tm_chartblock_element->position_ant-$tm_chartblock_element->position)>0)
$content.='<img src="modules/'.$tmModuleName.'/themes/'.$tm_chartblock_theme.'/images/up.gif" align="absmiddle" title="Up" width="10">';
elseif($tm_chartblock_element->position_ant-$tm_chartblock_element->position<0)
$content.='<img src="modules/'.$tmModuleName.'/themes/'.$tm_chartblock_theme.'/images/down.gif" align="absmiddle" title="Down" width="10">';
if($tm_chartblock_element->position_ant-$tm_chartblock_element->position!=0){
if($tm_chartblock_element->position_ant-$tm_chartblock_element->position>0)$content.='+';
$content.=$tm_chartblock_element->position_ant-$tm_chartblock_element->position;
}elseif($tm_chartblock_element->chartsince>0)
$content.='<img src="modules/'.$tmModuleName.'/themes/'.$tm_chartblock_theme.'/images/equal.gif" align="absmiddle" title="Same" width="10">';
$content.='</td>';
switch($tm_chartblock_chart->type){
case "song":
if(!$TMEasyURL)
$content.='<td><a href="modules.php?name='.$tmModuleName.'&op=song&idartist='.$tm_chartblock_elementO->idartist.'&idalbum='.$tm_chartblock_elementO->idalbum.'&idsong='.$tm_chartblock_elementO->id.'">'.$tm_chartblock_elementO->title.'</a></td>';
elseif(!$TMEasyURLType)
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.urlencode($tm_chartblock_elementO->artistname).'/album/'.urlencode($tm_chartblock_elementO->albumname).'/song/'.urlencode($tm_chartblock_elementO->title).'">'.$tm_chartblock_elementO->title.'</a></td>';
elseif($TMEasyURLType==2)
$content.='<td><a href="song'.$tm_chartblock_elementO->getIdartist().'_'.$tm_chartblock_elementO->getIdalbum().'_'.$tm_chartblock_elementO->getId().'.html">'.$tm_chartblock_elementO->title.'</a></td>';
else
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.$tm_chartblock_elementO->idartist.'/album/'.$tm_chartblock_elementO->idalbum.'/song/'.$tm_chartblock_elementO->getId().'">'.$tm_chartblock_elementO->title.'</a></td>';
break;
case "album":
if(!$TMEasyURL)
$content.='<td><a href="modules.php?name='.$tmModuleName.'&op=album&idartist='.$tm_chartblock_elementO->idartist.'&idalbum='.$tm_chartblock_elementO->id.'">'.$tm_chartblock_elementO->title.'</a></td>';
elseif(!$TMEasyURLType)
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.urlencode($tm_chartblock_elementO->artistname).'/album/'.urlencode($tm_chartblock_elementO->title).'">'.$tm_chartblock_elementO->title.'</a></td>';
elseif($TMEasyURLType==2)
$content.='<td><a href="album'.$tm_chartblock_elementO->idartist.'_'.$tm_chartblock_elementO->id.'.html">'.$tm_chartblock_elementO->title.'</a></td>';
else
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.$tm_chartblock_elementO->idartist.'/album/'.$tm_chartblock_elementO->id.'">'.$tm_chartblock_elementO->title.'</a></td>';
break;
case "artist":
if(!$TMEasyURL)
$content.='<td><a href="modules.php?name='.$tmModuleName.'&op=artist&idartist='.$tm_chartblock_elementO->id.'">'.$tm_chartblock_elementO->name.'</a></td>';
elseif(!$TMEasyURLType)
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.urlencode($tm_chartblock_elementO->name).'">'.$tm_chartblock_elementO->name.'</a></td>';
elseif($TMEasyURLType==2)
$content.='<td><a href="artist'.$tm_chartblock_elementO->id.'.html">'.$tm_chartblock_elementO->name.'</a></td>';
else
$content.='<td><a href="'.$tm_BaseURL.'/music.php/artist/'.$tm_chartblock_elementO->id.'">'.$tm_chartblock_elementO->name.'</a></td>';
break;
}
if($tm_chartblock_chart->type=="song" && $tm_chartblock_player)
$content.='<td>'.GenericView::generatePlayer($tm_chartblock_elementO,"block",$tmModuleName,$tm_config).'</td>';
$content.="</tr>\n";
}
$content.="<tr><td colspan='4'> </td></tr>\n";
$content.="<tr><td colspan='4' align='center'><a href=\"modules.php?name=".$tmModuleName."&op=charts\">Top Music Charts</a></td></tr>\n";
$content.="<tr><td colspan='4'> </td></tr>\n";
$content.="</table>\n";
?>