track.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2009 Free Software Foundation, Inc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU Affero General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Affero General Public License for more details.
  12. You should have received a copy of the GNU Affero General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. require_once('database.php');
  16. require_once('templating.php');
  17. require_once('data/sanitize.php');
  18. require_once('data/Server.php');
  19. require_once('data/TagCloud.php');
  20. require_once('track-menu.php');
  21. $smarty->assign('flattr_uid', $artist->flattr_uid);
  22. $smarty->assign('url', $track->getURL());
  23. if ($track->duration) {
  24. // Give the duration in MM:SS
  25. $mins = floor($track->duration / 60);
  26. $sec = floor($track->duration % 60);
  27. if (strlen($sec) == 1) {
  28. $sec = '0' . $sec;
  29. }
  30. $duration = $mins . ':' . $sec;
  31. $smarty->assign('duration', $duration);
  32. }
  33. $smarty->assign('extra_head_links', array(
  34. array(
  35. 'rel' => 'meta',
  36. 'type' => 'application/rdf+xml',
  37. 'title' => 'Track Metadata',
  38. 'href' => $base_url . '/rdf.php?fmt=xml&page=' . rawurlencode(str_replace($base_url, '', $track->getURL()))
  39. )
  40. ));
  41. try {
  42. $tagCloud = TagCloud::generateTagCloud('tags', 'tag', 10, 'track', array($track->name, $track->artist_name));
  43. } catch ( Exception $e) {
  44. $tagCloud = array();
  45. }
  46. $smarty->assign('tagcloud', $tagCloud);
  47. if ($logged_in) {
  48. if($_POST['love']) {
  49. $track->love($this_user->uniqueid);
  50. }
  51. if($_POST['unlove']) {
  52. $track->unlove($this_user->uniqueid);
  53. }
  54. $smarty->assign('isloved', $track->isLoved($this_user->uniqueid));
  55. }
  56. $submenu = track_menu($track, 'Overview');
  57. $smarty->assign('submenu', $submenu);
  58. $smarty->display('track.tpl');