<?php
class ArtistAdminView{
function printArtistAZ($listAZ){
$cols=4;
$aLetters=$listAZ[0];
for($i=0;$i<count($aLetters);$i++){
$letter=$aLetters[$i];
$list=$listAZ[$letter];
${"a".$letter}="<table cellspacing=\"4\" cellspadding=\"0\" border=\"0\" align=\"center\">\n";
${"a".$letter}.=" <tr><th><a name=\"".$letter."\">".$letter."</th><tr>\n";
while(list($id,$name)=each($list)){
${"a".$letter}.=" <tr><td>";
${"a".$letter}.="<a href=\"admin.php?op=topmusic&action=editArtist&idartist=".$id."\">".$name."</a>";
${"a".$letter}.="</td></tr>\n";
}
${"a".$letter}.="</table>\n";
$letter_ant=$letter;
}
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" align=\"center\">\n";
if(is_array($aLetters)){
$aLetters=array_unique($aLetters);
sort($aLetters);
for($i=0;$i<count($aLetters);$i++){
if($i==0 || $i%$cols==0)
echo " <tr>\n";
echo " <td valign=\"top\">".${"a".$aLetters[$i]}."</td>\n";
if($i>0 && ($i+1)%$cols==0)
echo " </tr>\n";
}
}
echo "</table>\n";
}
function printArtistResult($artistList,$page=1) {
echo "<script language=\"javascript\" type=\"text/javascript\">\n";
echo "function changePage(page){\n";
echo " document.searchForm.page.value=page;\n";
echo " document.searchForm.method='post';\n";
echo " document.searchForm.action='admin.php?op=topmusic&action=search';\n";
echo " document.searchForm.submit();\n";
echo "}\n";
echo "function delItem(idartist){\n";
echo " if(confirm('"._TOPMUSIC_SUREARTIST."')){\n";
echo " document.searchForm.action='admin.php?op=topmusic&action=delArtist&idartist='+idartist;\n";
echo " document.searchForm.submit();\n";
echo " }\n";
echo "}\n";
echo "</script>\n";
echo "<table cellspacing=\"0\" cellpadding=\"2\" border=\"0\">\n";
echo " <tr><td><b>"._TOPMUSIC_NAME."</b></td><td> </td><td><b>"._TOPMUSIC_YEARS."</b></td><td> </td><td></td><td> </td><td> </td></tr>\n";
for($i=0;$i<count($artistList);$i++){
$artistO=$artistList[$i];
echo " <tr>\n";
echo " <td>".$artistO->getName()."</td><td> </td>\n";
echo " <td>".$artistO->getBornyear();
if($artistO->getDeadyear()!="")
echo " - ".$artistO->getDeadyear();
echo "</td><td> </td>\n";
echo " <td><a href=\"admin.php?op=topmusic&action=editArtist&idartist=".$artistO->getId()."\">"._TOPMUSIC_EDIT."</td>\n";
echo " <td> </td>";
echo " <td><a href=\"javascript:delItem(".$artistO->getId().")\">"._TOPMUSIC_DELETE."</td>\n";
echo " </tr>\n";
}
echo "</table>\n<br>\n";
$num=$artistO->getCount();
if($page>1){
echo " <a href=\"javascript:changePage(".($page-1).")\">< "._TOPMUSIC_PREVIOUS."</a> ";
}
if($page>0)
echo " ". $page." ";
else
echo " 1 ";
echo " "._TOPMUSIC_OF." ";
echo " ".(ceil($num/10))." ";
if($page<ceil($num/10))
echo " <a href=\"javascript:changePage(".($page+1).")\"> "._TOPMUSIC_NEXT." ></a> ";
}
}
?>