album-menu.php 1.7 KB

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