$v) { if ($v >= $cnt) { $res[] = array('id' => $k); } } // end foreach return $res; } // post_process /** * show_objects * This takes an array of objects * and requires the correct template based on the * type that we are currently browsing */ public static function show_objects($object_ids=false) { if (Query::is_simple()) { $object_ids = Query::get_saved(); } else { $object_ids = is_array($object_ids) ? $object_ids : Query::get_saved(); Query::save_objects($object_ids); } // Reset the total items self::$total_objects = Query::get_total($object_ids); // Limit is based on the users preferences if this is not a simple browse because we've got too much here if (count($object_ids) > Query::get_start() AND !Query::is_simple()) { $object_ids = array_slice($object_ids,Query::get_start(),Query::get_offset(),TRUE); } // Format any matches we have so we can show them to the masses if ($filter_value = Query::get_filter('alpha_match')) { $match = ' (' . $filter_value . ')'; } elseif ($filter_value = Query::get_filter('starts_with')) { $match = ' (' . $filter_value . ')'; } // Set the correct classes based on type $class = "box browse_".self::$type; Ajax::start_container('browse_content'); // Switch on the type of browsing we're doing switch (Query::get_type()) { case 'song': show_box_top(_('Songs') . $match, $class); Song::build_cache($object_ids); require_once Config::get('prefix') . '/templates/show_songs.inc.php'; show_box_bottom(); break; case 'album': show_box_top(_('Albums') . $match, $class); Album::build_cache($object_ids,'extra'); require_once Config::get('prefix') . '/templates/show_albums.inc.php'; show_box_bottom(); break; case 'user': show_box_top(_('Manage Users') . $match, $class); require_once Config::get('prefix') . '/templates/show_users.inc.php'; show_box_bottom(); break; case 'artist': show_box_top(_('Artists') . $match, $class); Artist::build_cache($object_ids,'extra'); require_once Config::get('prefix') . '/templates/show_artists.inc.php'; show_box_bottom(); break; case 'live_stream': require_once Config::get('prefix') . '/templates/show_live_stream.inc.php'; show_box_top(_('Radio Stations') . $match, $class); require_once Config::get('prefix') . '/templates/show_live_streams.inc.php'; show_box_bottom(); break; case 'playlist': Playlist::build_cache($object_ids); show_box_top(_('Playlists') . $match, $class); require_once Config::get('prefix') . '/templates/show_playlists.inc.php'; show_box_bottom(); break; case 'playlist_song': show_box_top(_('Playlist Songs') . $match,$class); require_once Config::get('prefix') . '/templates/show_playlist_songs.inc.php'; show_box_bottom(); break; case 'playlist_localplay': show_box_top(_('Current Playlist')); require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php'; show_box_bottom(); break; case 'catalog': show_box_top(_('Catalogs'), $class); require_once Config::get('prefix') . '/templates/show_catalogs.inc.php'; show_box_bottom(); break; case 'shoutbox': show_box_top(_('Shoutbox Records'),$class); require_once Config::get('prefix') . '/templates/show_manage_shoutbox.inc.php'; show_box_bottom(); break; case 'flagged': show_box_top(_('Flagged Records'),$class); require_once Config::get('prefix') . '/templates/show_flagged.inc.php'; show_box_bottom(); break; case 'tag': Tag::build_cache($tags); show_box_top(_('Tag Cloud'),$class); require_once Config::get('prefix') . '/templates/show_tagcloud.inc.php'; show_box_bottom(); break; case 'video': show_box_top(_('Videos'),$class); require_once Config::get('prefix') . '/templates/show_videos.inc.php'; show_box_bottom(); break; case 'democratic': show_box_top(_('Democratic Playlist'),$class); require_once Config::get('prefix') . '/templates/show_democratic_playlist.inc.php'; show_box_bottom(); default: // Rien a faire break; } // end switch on type Ajax::end_container(); } // show_object /** * get_objects * This really should not be called anymore, but it's here for legacy shit * call the query get objects method. */ public static function get_objects() { return Query::get_objects(); } // get_objects /** * get_start * Returns the current start point */ public static function get_start() { return Query::get_start(); } // get_start /** * get_type * this is a wrapper function just returns the current type */ public static function get_type() { return Query::get_type(); } // get_type /** * set_start * This sets the start of the browse, really calls the query functions */ public static function set_start($value) { Query::set_start($value); } // set_start /** * _auto_init * this function reloads information back from the session * it is called on creation of the class */ public static function _auto_init() { $offset = Config::get('offset_limit') ? Config::get('offset_limit') : '25'; Query::set_offset($offset); } // _auto_init public static function set_filter_from_request($r) { foreach ($r as $k=>$v) { //reinterpret v as a list of int $vl = explode(',', $v); $ok = 1; foreach($vl as $i) { if (!is_numeric($i)) { $ok = 0; break; } } if ($ok) if (sizeof($vl) == 1) self::set_filter($k, $vl[0]); else self::set_filter($k, $vl); } } } // browse