track-menu.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /* GNU FM -- a free network service for sharing your music listening habits
  3. Copyright (C) 2012 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. function track_menu($track, $active_page) {
  16. global $this_user;
  17. $submenu = array(
  18. array('name' => _('Overview'), 'url' => $track->getURL()),
  19. array('name' => _('Tag'), 'url' => $track->getURL('tag')),
  20. );
  21. foreach($submenu as &$item) {
  22. $item['active'] = ($item['name'] == $active_page);
  23. }
  24. return $submenu;
  25. }
  26. // Create Artist, Album and Track objects
  27. try {
  28. $track = new Track($_GET['track'], $_GET['artist']);
  29. $smarty->assign('track', $track);
  30. } catch (Exception $e) {
  31. displayError("Track not found",
  32. "The track {$_GET['track']} by artist {$_GET['artist']} was not found in the database.");
  33. }
  34. try {
  35. $album = new Album($track->album_name, $track->artist_name);
  36. $smarty->assign('album', $album);
  37. } catch (Exception $e) {}
  38. try {
  39. $artist = new Artist($track->artist_name);
  40. $smarty->assign('artist', $artist);
  41. } catch (Exception $e) {
  42. displayError("Artist not found",
  43. "The artist {$track->artist_name} was not found in the database");
  44. }
  45. if (isset($this_user) && $this_user->manages($artist->name)) {
  46. $smarty->assign('edit_link', $track->getEditURL());
  47. }
  48. $smarty->assign('pagetitle', $track->artist_name . ' : ' . $track->name);