diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:00:32 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-01-26 03:38:46 -0500 |
commit | ef4d3660605efc7f1328d4533b0f4bfb6c1107e2 (patch) | |
tree | e4377fb129a899e65aaaf421f8c97098aecaedd5 /lib/class/browse.class.php | |
parent | 8a750c3e875d590d351c3042570a134fcdf03e5d (diff) | |
download | ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.gz ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.tar.bz2 ampache-ef4d3660605efc7f1328d4533b0f4bfb6c1107e2.zip |
Cosmetics: death to tabs
The refactoring I've been doing has reminded me of my strong preference
for spaces, and I feel inclined to impose my will on the tree.
Diffstat (limited to 'lib/class/browse.class.php')
-rw-r--r-- | lib/class/browse.class.php | 428 |
1 files changed, 214 insertions, 214 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index ce22728e..e747430a 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -1,5 +1,5 @@ <?php -/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */ +/* vim:set softtabstop=4 shiftwidth=4 expandtab: */ /** * * LICENSE: GNU General Public License, version 2 (GPLv2) @@ -31,218 +31,218 @@ */ class Browse extends Query { - /** - * set_simple_browse - * This sets the current browse object to a 'simple' browse method - * which means use the base query provided and expand from there - */ - public function set_simple_browse($value) { - - $this->set_is_simple($value); - - } // set_simple_browse - - /** - * add_supplemental_object - * Legacy function, need to find a better way to do that - */ - public function add_supplemental_object($class, $uid) { - - $_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid); - - return true; - - } // add_supplemental_object - - /** - * get_supplemental_objects - * This returns an array of 'class','id' for additional objects that - * need to be created before we start this whole browsing thing. - */ - public function get_supplemental_objects() { - - $objects = $_SESSION['browse']['supplemental'][$this->id]; - - if (!is_array($objects)) { $objects = array(); } - - return $objects; - - } // get_supplemental_objects - - /** - * show_objects - * This takes an array of objects - * and requires the correct template based on the - * type that we are currently browsing - */ - public function show_objects($object_ids = null) { - - if ($this->is_simple() || ! is_array($object_ids)) { - $object_ids = $this->get_saved(); - } - else { - $this->save_objects($object_ids); - } - - // Limit is based on the user's preferences if this is not a - // simple browse because we've got too much here - if ((count($object_ids) > $this->get_start()) && - ! $this->is_simple() && - ! $this->is_static_content()) { - $object_ids = array_slice( - $object_ids, - $this->get_start(), - $this->get_offset(), - true - ); - } - - // Load any additional object we need for this - $extra_objects = $this->get_supplemental_objects(); - $browse = $this; - - foreach ($extra_objects as $class_name => $id) { - ${$class_name} = new $class_name($id); - } - - $match = ''; - // Format any matches we have so we can show them to the masses - if ($filter_value = $this->get_filter('alpha_match')) { - $match = ' (' . $filter_value . ')'; - } - elseif ($filter_value = $this->get_filter('starts_with')) { - $match = ' (' . $filter_value . ')'; - } elseif ($filter_value = $this->get_filter('catalog')) { - // Get the catalog title - $catalog = new Catalog($filter_value); - $match = ' (' . $catalog->name . ')'; - } - - $type = $this->get_type(); - - // Set the correct classes based on type - $class = "box browse_" . $type; - - Ajax::start_container('browse_content'); - // Switch on the type of browsing we're doing - switch ($type) { - case 'song': - UI::show_box_top(T_('Songs') . $match, $class); - Song::build_cache($object_ids); - require_once Config::get('prefix') . '/templates/show_songs.inc.php'; - UI::show_box_bottom(); - break; - case 'album': - UI::show_box_top(T_('Albums') . $match, $class); - Album::build_cache($object_ids,'extra'); - require_once Config::get('prefix') . '/templates/show_albums.inc.php'; - UI::show_box_bottom(); - break; - case 'user': - UI::show_box_top(T_('Manage Users') . $match, $class); - require_once Config::get('prefix') . '/templates/show_users.inc.php'; - UI::show_box_bottom(); - break; - case 'artist': - UI::show_box_top(T_('Artists') . $match, $class); - Artist::build_cache($object_ids,'extra'); - require_once Config::get('prefix') . '/templates/show_artists.inc.php'; - UI::show_box_bottom(); - break; - case 'live_stream': - require_once Config::get('prefix') . '/templates/show_live_stream.inc.php'; - UI::show_box_top(T_('Radio Stations') . $match, $class); - require_once Config::get('prefix') . '/templates/show_live_streams.inc.php'; - UI::show_box_bottom(); - break; - case 'playlist': - Playlist::build_cache($object_ids); - UI::show_box_top(T_('Playlists') . $match, $class); - require_once Config::get('prefix') . '/templates/show_playlists.inc.php'; - UI::show_box_bottom(); - break; - case 'playlist_song': - UI::show_box_top(T_('Playlist Songs') . $match,$class); - require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php'; - UI::show_box_bottom(); - break; - case 'playlist_localplay': - UI::show_box_top(T_('Current Playlist')); - require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php'; - UI::show_box_bottom(); - break; - case 'smartplaylist': - UI::show_box_top(T_('Smart Playlists') . $match, $class); - require_once Config::get('prefix') . '/templates/show_smartplaylists.inc.php'; - UI::show_box_bottom(); - break; - case 'catalog': - UI::show_box_top(T_('Catalogs'), $class); - require_once Config::get('prefix') . '/templates/show_catalogs.inc.php'; - UI::show_box_bottom(); - break; - case 'shoutbox': - UI::show_box_top(T_('Shoutbox Records'),$class); - require_once Config::get('prefix') . '/templates/show_manage_shoutbox.inc.php'; - UI::show_box_bottom(); - break; - case 'flagged': - UI::show_box_top(T_('Flagged Records'),$class); - require_once Config::get('prefix') . '/templates/show_flagged.inc.php'; - UI::show_box_bottom(); - break; - case 'tag': - Tag::build_cache($tags); - UI::show_box_top(T_('Tag Cloud'),$class); - require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php'; - UI::show_box_bottom(); - break; - case 'video': - Video::build_cache($object_ids); - UI::show_box_top(T_('Videos'),$class); - require_once Config::get('prefix') . '/templates/show_videos.inc.php'; - UI::show_box_bottom(); - break; - case 'democratic': - UI::show_box_top(T_('Democratic Playlist'),$class); - require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php'; - UI::show_box_bottom(); - default: - // Rien a faire - break; - } // end switch on type - echo '<script type="text/javascript">'; - echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id, ''); - echo ';</script>'; - - Ajax::end_container(); - - } // show_object - - /** - * set_filter_from_request - * //FIXME - */ - public function set_filter_from_request($request) { - foreach($request as $key => $value) { - //reinterpret v as a list of int - $list = explode(',', $value); - $ok = true; - foreach($list as $item) { - if (!is_numeric($item)) { - $ok = false; - break; - } - } - if ($ok) { - if (sizeof($list) == 1) { - $this->set_filter($key, $list[0]); - } - } - else { - $this->set_filter($key, $list); - } - } - } // set_filter_from_request + /** + * set_simple_browse + * This sets the current browse object to a 'simple' browse method + * which means use the base query provided and expand from there + */ + public function set_simple_browse($value) { + + $this->set_is_simple($value); + + } // set_simple_browse + + /** + * add_supplemental_object + * Legacy function, need to find a better way to do that + */ + public function add_supplemental_object($class, $uid) { + + $_SESSION['browse']['supplemental'][$this->id][$class] = intval($uid); + + return true; + + } // add_supplemental_object + + /** + * get_supplemental_objects + * This returns an array of 'class','id' for additional objects that + * need to be created before we start this whole browsing thing. + */ + public function get_supplemental_objects() { + + $objects = $_SESSION['browse']['supplemental'][$this->id]; + + if (!is_array($objects)) { $objects = array(); } + + return $objects; + + } // get_supplemental_objects + + /** + * show_objects + * This takes an array of objects + * and requires the correct template based on the + * type that we are currently browsing + */ + public function show_objects($object_ids = null) { + + if ($this->is_simple() || ! is_array($object_ids)) { + $object_ids = $this->get_saved(); + } + else { + $this->save_objects($object_ids); + } + + // Limit is based on the user's preferences if this is not a + // simple browse because we've got too much here + if ((count($object_ids) > $this->get_start()) && + ! $this->is_simple() && + ! $this->is_static_content()) { + $object_ids = array_slice( + $object_ids, + $this->get_start(), + $this->get_offset(), + true + ); + } + + // Load any additional object we need for this + $extra_objects = $this->get_supplemental_objects(); + $browse = $this; + + foreach ($extra_objects as $class_name => $id) { + ${$class_name} = new $class_name($id); + } + + $match = ''; + // Format any matches we have so we can show them to the masses + if ($filter_value = $this->get_filter('alpha_match')) { + $match = ' (' . $filter_value . ')'; + } + elseif ($filter_value = $this->get_filter('starts_with')) { + $match = ' (' . $filter_value . ')'; + } elseif ($filter_value = $this->get_filter('catalog')) { + // Get the catalog title + $catalog = new Catalog($filter_value); + $match = ' (' . $catalog->name . ')'; + } + + $type = $this->get_type(); + + // Set the correct classes based on type + $class = "box browse_" . $type; + + Ajax::start_container('browse_content'); + // Switch on the type of browsing we're doing + switch ($type) { + case 'song': + UI::show_box_top(T_('Songs') . $match, $class); + Song::build_cache($object_ids); + require_once Config::get('prefix') . '/templates/show_songs.inc.php'; + UI::show_box_bottom(); + break; + case 'album': + UI::show_box_top(T_('Albums') . $match, $class); + Album::build_cache($object_ids,'extra'); + require_once Config::get('prefix') . '/templates/show_albums.inc.php'; + UI::show_box_bottom(); + break; + case 'user': + UI::show_box_top(T_('Manage Users') . $match, $class); + require_once Config::get('prefix') . '/templates/show_users.inc.php'; + UI::show_box_bottom(); + break; + case 'artist': + UI::show_box_top(T_('Artists') . $match, $class); + Artist::build_cache($object_ids,'extra'); + require_once Config::get('prefix') . '/templates/show_artists.inc.php'; + UI::show_box_bottom(); + break; + case 'live_stream': + require_once Config::get('prefix') . '/templates/show_live_stream.inc.php'; + UI::show_box_top(T_('Radio Stations') . $match, $class); + require_once Config::get('prefix') . '/templates/show_live_streams.inc.php'; + UI::show_box_bottom(); + break; + case 'playlist': + Playlist::build_cache($object_ids); + UI::show_box_top(T_('Playlists') . $match, $class); + require_once Config::get('prefix') . '/templates/show_playlists.inc.php'; + UI::show_box_bottom(); + break; + case 'playlist_song': + UI::show_box_top(T_('Playlist Songs') . $match,$class); + require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php'; + UI::show_box_bottom(); + break; + case 'playlist_localplay': + UI::show_box_top(T_('Current Playlist')); + require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php'; + UI::show_box_bottom(); + break; + case 'smartplaylist': + UI::show_box_top(T_('Smart Playlists') . $match, $class); + require_once Config::get('prefix') . '/templates/show_smartplaylists.inc.php'; + UI::show_box_bottom(); + break; + case 'catalog': + UI::show_box_top(T_('Catalogs'), $class); + require_once Config::get('prefix') . '/templates/show_catalogs.inc.php'; + UI::show_box_bottom(); + break; + case 'shoutbox': + UI::show_box_top(T_('Shoutbox Records'),$class); + require_once Config::get('prefix') . '/templates/show_manage_shoutbox.inc.php'; + UI::show_box_bottom(); + break; + case 'flagged': + UI::show_box_top(T_('Flagged Records'),$class); + require_once Config::get('prefix') . '/templates/show_flagged.inc.php'; + UI::show_box_bottom(); + break; + case 'tag': + Tag::build_cache($tags); + UI::show_box_top(T_('Tag Cloud'),$class); + require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php'; + UI::show_box_bottom(); + break; + case 'video': + Video::build_cache($object_ids); + UI::show_box_top(T_('Videos'),$class); + require_once Config::get('prefix') . '/templates/show_videos.inc.php'; + UI::show_box_bottom(); + break; + case 'democratic': + UI::show_box_top(T_('Democratic Playlist'),$class); + require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php'; + UI::show_box_bottom(); + default: + // Rien a faire + break; + } // end switch on type + echo '<script type="text/javascript">'; + echo Ajax::action('?page=browse&action=get_filters&browse_id=' . $this->id, ''); + echo ';</script>'; + + Ajax::end_container(); + + } // show_object + + /** + * set_filter_from_request + * //FIXME + */ + public function set_filter_from_request($request) { + foreach($request as $key => $value) { + //reinterpret v as a list of int + $list = explode(',', $value); + $ok = true; + foreach($list as $item) { + if (!is_numeric($item)) { + $ok = false; + break; + } + } + if ($ok) { + if (sizeof($list) == 1) { + $this->set_filter($key, $list[0]); + } + } + else { + $this->set_filter($key, $list); + } + } + } // set_filter_from_request } // browse |