Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/lib/com/sergids/topmusic/view/ArtistView.php
<?php
require_once("modules/topMusic/lib/com/sergids/topmusic/view/GenericView.php");
require_once("modules/topMusic/lib/com/sergids/common/Image.php");
require_once("modules/topMusic/lib/com/sergids/common/ArrayUtils.php");
class ArtistView{
	function getArtistAZ($listAZ,$letters,$modulename,$config){
		$easyURL=$config->getEasyURL();
		$easyURLtype=$config->getEasyURLType();
		$tm_BaseURL=$config->getBaseURL();
		$tm_advanced=$config->getAZAdvanced();
		$i=0;
		if(count($letters)>0){
			foreach($letters as $letter){
				${"a".$letter}="<table cellspacing=\"4\" cellspadding=\"0\" border=\"0\" align=\"center\">\n";
				${"a".$letter}.="	<tr><th><a name=\"".$letter."\">".$letter."</th></tr>\n";
				if(count($listAZ)>0){
					$i=0;
					foreach($listAZ as $key => $item){ //$key = artistname  $item = artistO
						if(strtoupper(substr($key,0,1))==strtoupper($letter)){
							//print "** &nbsp;".$key." ".strtoupper(substr($key,0,1))."<br>";
							${"a".$letter}.="	<tr><td>";
							$id=$item->getId();
							$name=$item->getName();
							if(!$easyURL)
								${"a".$letter}.="<a href=\"modules.php?name=".$modulename."&op=artist&idartist=".$id."\">".$name."</a>";
							elseif(!$easyURLtype)
								${"a".$letter}.="<a href=\"".$tm_BaseURL."/music.php/artist/".urlencode($name)."\">".$name."</a>";
							elseif($easyURLtype==2)
								${"a".$letter}.="<a href=\"artist".$id.".html\">".$name."</a>";
							else
								${"a".$letter}.="<a href=\"".$tm_BaseURL."/music.php/artist/".$id."\">".$name."</a>";
							${"a".$letter}.="</td></tr>\n";	
							//ArrayUtils::replaceItem(&$listAZ,$i);
						}
						$i++;
					}
				}
				${"a".$letter}.="</table>\n";
				$array[$letter]=${"a".$letter};
			}
		}
		return $array;
	}

	function getDiscographyUrl($module_name,$config,$artistO){
		if(!$config->getEasyURL())
			$url_albumlist="modules.php?name=".$module_name."&op=albumlist&idartist=".$artistO->getId();
		elseif(!$config->getEasyURLType())
			$url_albumlist=$config->getBaseURL()."/music.php/artist/".urlencode($artistO->getName())."/discography";
		elseif($config->getEasyURLType()==2)
			$url_albumlist="discography".$artistO->getId().".html";
		else
			$url_albumlist=$config->getBaseURL()."/music.php/artist/".$artistO->getId()."/discography";
		return $url_albumlist;
	}
	function getForumUrl($forum){
		if($forum!=""){
        	if(is_numeric($forum))
        		$forum_url="modules.php?name=Forums&file=viewforum&f=$forum";
			else
				$forum_url=$forum;
		}
		return $forum_url;
	}
	function getArtistUrl($module_name,$config,$artistO){
		if(!$config->getEasyURL())
			$url_artist="modules.php?name=".$module_name."&op=artist&idartist=".$artistO->getId();
		elseif(!$config->getEasyURLType())
			$url_artist=$config->getBaseURL()."/music.php/artist/".urlencode($artistO->getName());
		elseif($config->getEasyURLType()==2)
			$url_artist="artist".$artistO->getId().".html";
		else
			$url_artist=$config->getBaseURL()."/music.php/artist/".$artistO->getId();
		return "<a href=\"".$url_artist."\">";
	}
	function getDeadYear($dead_year){
		$dead_year2=($dead_year!="")?" - ".$dead_year:"";
		return $dead_year2;
	}
	function setRatesCode($artistlist,$module_name,$theme){
    	if(count($artistlist)){
	    	foreach($artistlist as $artist){
	    		$avg=$artist->getAvgvotes();
	    		$rate_code=GenericView::getRateCode(round($avg,1),$module_name,$theme);
	    		$artist->setAvgvotes($rate_code);
	    		$artistlist2[]=$artist;
	    	}
    	}
    	return $artistlist2;
    }
    function getBioUrl($module_name,$config,$artistO){
		if(!$config->getEasyURL())
			$url_artist="modules.php?name=".$module_name."&op=bio&idartist=".$artistO->getId();
		elseif(!$config->getEasyURLType())
			$url_artist=$config->getBaseURL()."/music.php/biography/".urlencode($artistO->getName());
		elseif($config->getEasyURLType()==2)
			$url_artist="biography".$artistO->getId().".html";
		else
			$url_artist=$config->getBaseURL()."/music.php/biography/".$artistO->getId();
		return $url_artist;
	}
    function getPhotoUrl($artistO,$module_name){
    	if($artistO->getPhotoFile()!="")
    		$url_photo="modules/$module_name/photos/".$artistO->getPhotoFile();
    	else
    		$url_photo=$artistO->getPhotoUrl();
		return $url_photo;
	}
    function getPhotoThumbUrl($artistO,$module_name,$width,$height){
    	if($artistO->getPhotoFile()!=""){
    		$url_photo="modules/$module_name/photos/".$artistO->getPhotoFile();
    		if($thumb=Image::createThumbnail($url_photo,$width,$height))
				$url_photo=$thumb;
			else
				$url_photo=null;
    	}else
    		$url_photo=null;
		return $url_photo;
	}
	function parseThumbs($module_name,&$artistList,$width,$height){
		for($i=0;count($artistList)>$i;$i++){
			$thumb=ArtistView::getPhotoThumbUrl($artistList[$i],$module_name,$width,$height);
			if($thumb!="")
				$artistList[$i]->photo_thumbfile=$thumb;
		}
	}
	function getLettersUrl($module_name,$config,$letter){
		if(!$config->getAZAdvanced()){
			if(!$config->getEasyURL())
				$letters_url="modules.php?name=".$module_name."#".$letter;
			else{
				if($config->getEasyURLType()==2)
					$letters_url="az.html#".$letter;
				else
					$letters_url=$config->getBaseURL()."/music.php/AZ#".$letter;
			}
		}else{
			if(!$config->getEasyURL())
				$letters_url="modules.php?name=".$module_name."&letter=".$letter;
			else{
				if($config->getEasyURLType()==2)
					$letters_url="az-".$letter.".html";
				else
					$letters_url=$config->getBaseURL()."/music.php/AZ/".$letter;
			}
		}
		return $letters_url;
	}
}
?>
Return current item: Top Music module