/** * Displays a table of the given tracks. * * @author Ross Carlson * @version 11/30/04 * @since 01/11/05 * @param array $tracks The array of objects of each track * @param $purpose The type of this track table. One of: * generic|album|search|sample|sample-all */ function trackTable($tracks, $purpose = false) { global $media_dir, $jinzora_skin, $hierarchy, $album_name_truncate, $row_colors, $img_more, $img_email, $img_rate, $img_discuss, $num_other_albums, $enable_ratings, $this_site, $root_dir; if (sizeof($tracks) == 0) { return; } // Let's setup the new display object $display =& new jzDisplay(); // Let's figure out our settings: // First, set the defaults. $showNumbers = true; $showArtist = false; $showAlbum = false; $showCheck = false; $showInfo = false; $showEmail = false; $showRate = false; $showDisc = false; $albumArtThumbs = false; $showAlbumNames = false; $trackTruncate = false; $showPlayCount = false; // Now adjust as needed: switch ($purpose) { case "generic": $showNumbers = false; break; case "album": $showCheck = true; $showNumbers = false; $showInfo = true; $showPlayCount = true; $showEmail = true; break; case "search": $showArtist = true; break; case "sample": // We only want to show album thumbs IF this artist has more than 1 album $parent = $tracks[0]->getParent(); $gParent = $parent->getParent(); $nodes = $gParent->getSubNodes("nodes"); if (count($nodes) > 1) { $albumArtThumbs = true; } $showNumbers = false; $showAlbum = true; break; case "sample-all": $showNumbers = false; $showCheck = true; $showAlbumNames = true; $trackTruncate = 20; break; } // Do we need to start the form if ($showCheck) { $node = $tracks[0]->getParent(); ?> <form name="albumForm" action="<?php echo urlize(); ?> " method="POST"> <input type="hidden" name="<?php echo jz_encode("action"); ?> " value="<?php echo jz_encode("mediaAction"); ?> "> <input type="hidden" name="<?php echo jz_encode("jz_path"); ?> " value="<?php echo htmlentities(jz_encode($node->getPath("String"))); ?> "> <input type="hidden" name="<?php echo jz_encode("jz_list_type"); ?> " value="<?php echo jz_encode("tracks"); ?> "> <?php } // Now let's setup the big table to display everything $i = 0; ?> <table class="jz_track_table" width="100%" cellpadding="3" cellspacing="0" border="0"> <?php foreach ($tracks as $child) { // First let's grab all the tracks meta data $metaData = $child->getMeta(); $album = $child->getParent(); if (findPType($album) == "disk") { $album = $album->getParent(); } $gParent = $album->getParent(); $artist = getInformation($album, "artist"); ?> <tr class="<?php echo $row_colors[$i]; ?> "> <?php if ($showCheck) { ?> <td width="1%" valign="top" class="jz_track_table_songs_td"> <input type="checkbox" name="jz_list[]" value="<?php echo jz_encode($child->getPath("String")); ?> "> </td> <td width="1%" valign="top" class="jz_track_table_songs_td"> <?php echo $display->playButton($child); ?> </td> <td width="1%" valign="top" class="jz_track_table_songs_td"> <?php echo $display->downloadButton($child); ?> </td> <?php } // Do they want ratings? if ($enable_ratings == "true") { echo '<td width="1%" valign="top" class="jz_track_table_songs_td">'; $display->rateButton($child); echo '</td>'; } ?> <?php if ($showInfo) { $arr = array(); $arr['action'] = "popup"; $arr['ptype'] = "trackinfo"; $arr['jz_path'] = $child->getPath("String"); $link = urlize($arr); ?> <td width="1%" valign="top" class="jz_track_table_songs_td"> <a href="<?php echo $link; ?> " target="_blank" onclick="openPopup(this, 375, 650); return false;"><?php echo $img_more; ?> </a> </td> <?php } ?> <?php if ($showEmail) { ?> <td width="1%" valign="top" class="jz_track_table_songs_td"> <?php $arr = array(); $arr['action'] = "playlist"; $arr['jz_path'] = $child->getPath("String"); $arr['type'] = "track"; $link = $this_site . $root_dir . "/" . str_replace("&", "%26", urlize($arr)); $mailLink = "mailto:?subject=" . $artist . " - " . $album->getName() . "&body=Click to play " . $artist . " - " . $album->getName() . ":%0D%0A%0D%0A" . $link . "%0D%0A%0D%0APowered%20by%20Jinzora%20%0D%0AJinzora%20::%20Free%20Your%20Media%0D%0Ahttp://www.jinzora.org"; ?> <a class="jz_track_table_songs_href" href="<?php echo $mailLink; ?> "><?php echo $img_email; ?> </a> </td> <?php } ?> <?php if ($showDisc) { ?> <td width="1%" valign="top" class="jz_track_table_songs_td"> <a class="jz_track_table_songs_href" href=""><?php echo $img_discuss; ?> </a> </td> <?php } ?> <td nowrap width="100%" valign="top" class="jz_track_table_songs_td"> <?php // Do they want tiny thumbnails? if ($albumArtThumbs) { if (($art = $album->getMainArt()) !== false) { $display->link($album, $display->returnImage($art, $album->getName(), 25, 25, "limit", false, false, "left", "2", "2"), $album->getName(), "jz_track_table_songs_href"); } } if ($showArtist !== false) { $j = 0; while ($j < sizeof($hierarchy) && $hierarchy[$j] != 'artist') { $j++; } if ($j < sizeof($hierarchy)) { $parent = $child; while ($parent->getLevel() > $j + 1) { $parent = $parent->getParent(); } $display->link($parent, $parent->getName(), $parent->getName(), "jz_track_table_songs_href"); echo " / "; } } if (!$trackTruncate) { $tName = $child->getName(); } else { $tName = returnItemShortName($child->getName(), $trackTruncate); } $display->link($child, $tName, $child->getName(), "jz_track_table_songs_href"); if ($showAlbum) { echo "<br>From: "; $display->link($album, returnItemShortName($album->getName(), 20), $album->getName(), "jz_track_table_songs_href"); } // Do they want ratings? if ($enable_ratings == "true") { $rating = $display->displayRating($child, true); if ($rating) { echo "<br>" . $rating; } unset($rating); } ?> </td> <?php $lyricsSearch = false; if (isset($_POST['search_type'])) { if ($_POST['search_type'] == "lyrics") { $lyricsSearch = $_POST['search_query']; } } if (isset($_GET['search_type'])) { if ($_GET['search_type'] == "lyrics") { $lyricsSearch = $_GET['search_query']; } } if ($lyricsSearch) { // Now let's get the lyrics back $lyrics = $child->getLyrics(); // Now let's parse it out $lyrics = str_replace("Lyrics Provided by: Leo's Lyrics\nhttp://www.leoslyrics.com", "", $lyrics); $start = strpos(strtolower($lyrics), strtolower($lyricsSearch)) - 20; if ($start < 0) { $start = 0; } $lyrics = " (..." . substr($lyrics, $start, strlen($lyricsSearch) + 40) . "...)"; $lyrics = highlight($lyrics, $lyricsSearch); echo '<td width="6%" align="center" valign="top" class="jz_track_table_songs_td">'; echo "<nobr>" . $lyrics . "</nobr>"; echo '</td>'; } ?> <?php if ($showAlbumNames) { echo '<td width="1%" align="center" valign="top" class="jz_track_table_songs_td"><nobr>'; $display->link($gParent, returnItemShortName($gParent->getName(), 20), $gParent->getName(), "jz_track_table_songs_href"); echo '</nobr></td>'; } ?> <?php if ($showPlayCount) { echo '<td width="1%" align="center" valign="top" class="jz_track_table_songs_td">'; echo $child->getPlayCount(); echo '</td>'; } ?> <td width="6%" align="center" valign="top" class="jz_track_table_songs_td"> <nobr> <?php echo convertSecMins($metaData['length']); ?> </nobr> </td> </tr> <?php $i = 1 - $i; unset($gParent); unset($album); } // Now let's set a field with the number of checkboxes that were here echo "</table>"; // Now let's show the playlist bar if we should if ($showCheck) { $blocks = new jzBlocks(); $blocks->blockSpacer(); $blocks->playlistBar(); echo "</form>"; } }