diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-06-26 00:51:36 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-06-26 00:51:36 +0000 |
commit | 30405b6c9930c5dd23c5ed30bc2276780a46ecbb (patch) | |
tree | ceec5f17237c710e6da3c348abcc22d30b06deee /lib | |
parent | 491eab55d8c581b42bcd0625cb137b6a53911259 (diff) | |
download | ampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.tar.gz ampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.tar.bz2 ampache-30405b6c9930c5dd23c5ed30bc2276780a46ecbb.zip |
start of browse by x mojo
Diffstat (limited to 'lib')
-rw-r--r-- | lib/general.php | 163 | ||||
-rw-r--r-- | lib/log.lib.php (renamed from lib/log.php) | 0 | ||||
-rw-r--r-- | lib/ui.lib.php (renamed from lib/ui.php) | 128 |
3 files changed, 241 insertions, 50 deletions
diff --git a/lib/general.php b/lib/general.php index 1184db45..83bf2bfc 100644 --- a/lib/general.php +++ b/lib/general.php @@ -535,20 +535,169 @@ function get_random_songs( $options, $matchlist) { } // get_random_songs -/*! - @function cleanup_and_exit - @discussion used specificly for the play/index.php file - this functions nukes now playing and then exits -*/ +/** + * cleanup_and_exit + * used specificly for the play/index.php file + * this functions nukes now playing and then exits + * @package Streaming + * @catagory Clean + */ function cleanup_and_exit($playing_id) { /* Clear now playing */ // 900 = 15 min $expire = time() - 900; - $sql = "DELETE FROM now_playing WHERE id='$lastid' OR start_time < $expire"; - $db_results = mysql_query($sql, dbh()); + $sql = "DELETE FROM now_playing WHERE now_playing.id='$lastid' OR now_playing.start_time < $expire"; + + $db_results = @mysql_query($sql, dbh()); + exit(); } // cleanup_and_exit +/** + * get_global_popular + * this function gets the current globally popular items + * from the object_count table, depending on type passed + * @package Web Interface + * @catagory Get + */ +function get_global_popular($type) { + + $dbh = dbh(); + + $sql = "SELECT object_id, SUM(count) as count FROM object_count" . + " WHERE object_type = '$type'" . + " GROUP BY object_id" . + " ORDER BY count DESC LIMIT " . conf('popular_threshold'); + $db_result = mysql_query($sql, $dbh); + + $items = array(); + $web_path = conf('web_path'); + + while ( $r = @mysql_fetch_object($db_result) ) { + /* If Songs */ + if ( $type == 'song' ) { + $song = new Song($r->object_id); + $artist = $song->get_artist_name(); + $text = "$artist - $song->title"; + /* Add to array */ + $items[] = "<li> <a href=\"$web_path/song.php?action=m3u&song=$song->id\" title=\"". htmlspecialchars($text) ."\">" . + htmlspecialchars(truncate_with_ellipse($text, conf('ellipse_threshold_title')+3)) . " ($r->count)</a> </li>"; + } // if it's a song + + /* If Artist */ + elseif ( $type == 'artist' ) { + $artist = get_artist_name($r->object_id); + $items[] = "<li> <a href=\"$web_path/artists.php?action=show&artist=$r->object_id\" title=\"". htmlspecialchars($artist) ."\">" . + htmlspecialchars(truncate_with_ellipse($artist, conf('ellipse_threshold_artist')+3)) . " ($r->count)</a> </li>"; + } // if type isn't artist + + /* If Album */ + elseif ( $type == 'album' ) { + $album = new Album($r->object_id); + $items[] = "<li> <a href=\"$web_path/albums.php?action=show&album=$r->object_id\" title=\"". htmlspecialchars($album->name) ."\">" . + htmlspecialchars(truncate_with_ellipse($album->name,conf('ellipse_threshold_album')+3)) . " ($r->count)</a> </li>"; + } // else not album + + elseif ($type == 'genre') { + $genre = new Genre($r->object_id); + $items[] = "<li> <a href=\"$web_path/browse.php?action=genre&genre=$r->object_id\" title=\"" . htmlspecialchars($genre->name) . "\">" . + htmlspecialchars(truncate_with_ellipse($genre->name,conf('ellipse_threshold_title')+3)) . " ($r->count)</a> </li>"; + } // end if genre + } // end while + + if (count($items) == 0) { + $items[] = "<span class=\"error\">" . _("Not Enough Data") . "</span>\n"; + } + + return $items; + +} // get_global_popular + +/** + * gen_newest + * Get a list of newest $type (which can then be handed to show_info_box + * @package Web Interface + * @catagory Get + * @todo Add Genre + */ +function get_newest ($type = 'artist') { + + $dbh = dbh(); + + if (conf('popular_threshold') < 1) { conf(array('popular_threshold'=>'10'),1); } + + $sql = "SELECT DISTINCT $type FROM song ORDER BY addition_time " . + "DESC LIMIT " . conf('popular_threshold'); + $db_result = mysql_query($sql, $dbh); + + $items = array(); + $web_path = conf('web_path'); + + while ( $item = mysql_fetch_row($db_result) ) { + if ( $type == 'artist' ) { + $artist = new Artist($item[0]); + $artist->format_artist(); + $items[] = "<li>" . $artist->link . "</li>\n"; + } + elseif ( $type == 'album' ) { + $album = new Album($item[0]); + $album->format_album(); + $items[] = "<li>" . $album->f_name . "</li>"; + } + } + return $items; +} // get_newest + +/** + * show_info_box + * This shows the basic box that popular and newest stuff goes into + * @package Web Interface + * @catagory Display + * @todo make this use a template + */ +function show_info_box ($title, $type, $items) { + + $web_path = conf('web_path'); + $popular_threshold = conf('popular_threshold'); + + echo "<table class=\"border\" cellspacing=\"1\" cellpadding=\"3\" width=\"100%\" border=\"0\">"; + echo " <tr class=\"table-header\">"; + + + if ($type == 'your_song') { + echo "<td>$title - <a href=\"$web_path/song.php?action=m3u&your_popular_songs=$popular_threshold\">Play</a></td>\n"; + } + elseif ($type == 'song') { + echo "<td>$title - <a href=\"$web_path/song.php?action=m3u&popular_songs=$popular_threshold\">Play</a></td>\n"; + } + else { + echo "<td>$title</td>\n"; + } + + print <<<ECHO + </tr> + <tr class="even"> + <td align="left"> + <ol> + +ECHO; + + foreach ($items as $item) { + echo "$item\n"; + } + + print <<<ECHO + </ol> + </td> + </tr> +</table> + +ECHO; + +} // show_info_box + + + ?> diff --git a/lib/log.php b/lib/log.lib.php index 7a3d8faf..7a3d8faf 100644 --- a/lib/log.php +++ b/lib/log.lib.php diff --git a/lib/ui.php b/lib/ui.lib.php index fbbdcf8b..6faa0897 100644 --- a/lib/ui.php +++ b/lib/ui.lib.php @@ -19,13 +19,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*! - @header UI Function Library - This contains functions that are generic, and display information - things like a confirmation box, etc and so forth -*/ -/*! +/** + * UI Function Library + * This contains functions that are generic, and display information + * things like a confirmation box, etc and so forth + * @package Web Interface + * @catagory Library + */ + +/** @function show_confirmation @discussion shows a confirmation of an action @param $next_url Where to go next @@ -45,7 +48,7 @@ function show_confirmation($title,$text,$next_url) { } // show_confirmation -/*! +/** @function set_preferences @discussion legacy function... //FIXME: Remove References @@ -57,7 +60,7 @@ function set_preferences() { } // set_preferences -/*! +/** @function get_preferences @discussion reads this users preferences */ @@ -94,7 +97,7 @@ function get_preferences($username=0) { } // get_preferences -/*! +/** @function flip_class @discussion takes an array of 2 class names and flips them back and forth and @@ -114,7 +117,7 @@ function flip_class($array=0) { } // flip_class -/*! +/** @function clear_now_playing @discussion Clears the now playing information incase something has gotten stuck in there @@ -128,7 +131,7 @@ function clear_now_playing() { } // clear_now_playing -/*! +/** @function show_tool_box @discussion shows the toolbox */ @@ -138,7 +141,7 @@ function show_tool_box ($title, $items) { }// show_tool_box -/*! +/** @function show_box @discussion shows a generic box */ @@ -148,7 +151,7 @@ function show_box($title,$items) { } // show_box -/*! +/** @function show_menu_items @discussion shows menu items */ @@ -158,7 +161,7 @@ function show_menu_items ($high) { } // show_menu_items -/*! +/** @function _ @discussion checks to see if the alias _ is defined if it isn't it defines it as a simple return @@ -171,7 +174,7 @@ if (!function_exists('_')) { } // _ } // if _ isn't defined -/*! +/** @function show_playlist_menu @discussion playlist functions */ @@ -184,7 +187,7 @@ function show_playlist_menu () { } // show_playlist_menu -/*! +/** @function show_admin_menu @discussion shows the admin menu */ @@ -192,7 +195,7 @@ function show_admin_menu ($admin_highlight) { include(conf('prefix') . "/templates/admin_menu.inc"); } // show_admin_menu -/*! +/** @function access_denied @discussion throws an error if they try to do something that they aren't allowed to @@ -208,7 +211,7 @@ function access_denied() { } // access_denied -/*! +/** @function show_users @discussion shows all users (admin function) */ @@ -240,7 +243,7 @@ function show_users () { } // show_users() -/*! +/** @function return_referer @discussion returns the script part of the referer address passed by the web browser @@ -261,7 +264,7 @@ function return_referer() { } // return_referer -/*! +/** @function show_alphabet_list @discussion shows the A-Z,0-9 lists for albums and artist pages @@ -289,7 +292,7 @@ function show_alphabet_list ($type,$script="artist.php",$selected="false") { echo "</div>\n"; } // show_alphabet_list -/*! +/** @function show_local_control @discussion shows the controls for localplay @@ -300,7 +303,7 @@ function show_local_control () { } // show_local_control -/*! +/** @function truncate_with_ellipse @discussion truncates a text file to specified length by adding thre dots (ellipse) to the end @@ -328,7 +331,7 @@ function truncate_with_ellipse($text, $max=27) { return $text; } // truncate_with_ellipse -/*! +/** @function show_footer @discussion shows the footer of the page */ @@ -337,7 +340,7 @@ function show_footer() { echo "<br /><br /><br /><div class=\"$class\" style=\"border: solid thin black;\"> </div>"; } // show_footer -/*! +/** @function show_now_playing @discussion shows the now playing template */ @@ -350,7 +353,7 @@ function show_now_playing() { } // show_now_playing -/*! +/** @function show_user_registration @discussion this function is called for a new user registration @@ -364,7 +367,7 @@ function show_user_registration ($values=array()) { } // show_user_registration -/*! +/** @function show_edit_profile @discussion shows a single user profile for editing */ @@ -376,7 +379,7 @@ function show_edit_profile($username) { } // show_edit_profile -/*! +/** @function show_playlist @discussion this shows the current playlist */ @@ -395,7 +398,7 @@ function show_playlist($playlist_id) { } // show_playlist -/*! +/** @function show_play_selected @discussion this shows the playselected/add to playlist box, which includes a little javascript @@ -406,7 +409,7 @@ function show_play_selected() { } // show_play_selected -/*! +/** @function get_now_playing @discussion gets the now playing information */ @@ -424,7 +427,7 @@ function get_now_playing() { } // get_now_playing -/*! +/** @function show_clear @discussion this is a hack because of the float mojo */ @@ -434,23 +437,62 @@ function show_clear() { } // show_clear -/*! - @function show_page_footer - @discussion adds page footer including html and body end tags - @param $menu menu item to highlight - @param $admin_menu admin menu item to highlight - @param $display_menu display menu or not (1 on 0 off) -*/ -function show_page_footer ($menu="Home", $admin_menu='', $display_menu=0) { +/** + * show_page_footer + * adds page footer including html and body end tags + * @param $menu menu item to highlight + * @param $admin_menu admin menu item to highlight + * @param $display_menu display menu or not (1 on 0 off) + * @package Web Interface + * @catagory Display + */ +function show_page_footer($menu="Home", $admin_menu='', $display_menu=0) { + if ($display_menu){ - if($menu =="Admin"){ + if($menu == 'Admin'){ show_admin_menu($admin_menu); - } + } // end if admin show_menu_items($menu); - - } + + } // end if + echo "<br /><br />\n</body>\n"; echo "</html>\n"; -} + +} // show_page_footer + +/** + * Show All Popular + * This functions shows all of the possible global popular tables, this is basicly a top X where X is + * set on a per user basis + * @package Web Interface + * @catagory Display + * @author Karl Vollmer + */ +function show_all_popular() { + + $artists = get_global_popular('artist'); + $albums = get_global_popular('album'); + $songs = get_global_popular('song'); + $genres = get_global_popular('genre'); + + require_once(conf('prefix') . '/templates/show_all_popular.inc.php'); + +} // show_all_popular + +/** + * Show All Recent + * This function shows all of the possible "Newest" tables. The number of newest is pulled from the users + * popular threshold + * @package Web Interface + * @catagory Display + * @author Karl Vollmer + */ +function show_all_recent() { + + + +} // show_all_recent + ?> |