diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-09-15 06:12:52 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-09-15 06:12:52 +0000 |
commit | 063e67887b48ea9ba5570638dcfaf5439f0337da (patch) | |
tree | 6c8e958435d96505408f9dd63e76e038220f16bc | |
parent | b469b70195a92f7087d3b9c15bbc10797e0411a7 (diff) | |
download | ampache-063e67887b48ea9ba5570638dcfaf5439f0337da.tar.gz ampache-063e67887b48ea9ba5570638dcfaf5439f0337da.tar.bz2 ampache-063e67887b48ea9ba5570638dcfaf5439f0337da.zip |
browse by title and page header hotness
-rw-r--r-- | browse.php | 12 | ||||
-rwxr-xr-x | docs/CHANGELOG | 3 | ||||
-rw-r--r-- | lib/artist.lib.php | 2 | ||||
-rw-r--r-- | lib/class/song.class.php | 48 | ||||
-rw-r--r-- | templates/list_header.inc | 47 | ||||
-rw-r--r-- | templates/show_artists.inc | 2 | ||||
-rw-r--r-- | templates/show_songs.inc | 14 | ||||
-rw-r--r-- | templates/sidebar.inc.php | 1 |
8 files changed, 110 insertions, 19 deletions
@@ -113,8 +113,14 @@ switch($action) { /* Setup the View Object */ $view = new View(); $view->import_session_view(); - - $song->show_match_list($_REQUEST['match']); + + $match = scrub_in($_REQUEST['match']); + + show_alphabet_list('song_title','browse.php',$match,'song_title'); + /* Detect if it's Browse, and if so don't fill it in */ + if ($match == 'Browse') { $match = ''; } + show_alphabet_form($match,_('Show Titles Starting With'),"browse.php?action=song_title&match=$match"); + $sql = $song->get_sql_from_match($_REQUEST['match']); if ($_REQUEST['keep_view']) { @@ -130,7 +136,7 @@ switch($action) { if ($view->base_sql) { $songs = $song->get_songs($view->sql); - show_songs($songs,$view); + show_songs($songs); } break; case 'catalog': diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 8f2411ee..49e1295e 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,9 @@ -------------------------------------------------------------------------- v.3.3.2 + - Page headers now limited to 20 pages with [....] between top + and bottom 10. + - Added Browse by Title functionality (Thx Rubin) - Added Min Album size as preference, defaults to 0 (Thx Rubin) - Fixed a problem with the automatic registration sorting on user lists and admin notification of new users (Thx pb1dft) diff --git a/lib/artist.lib.php b/lib/artist.lib.php index 3e8964c6..f2857921 100644 --- a/lib/artist.lib.php +++ b/lib/artist.lib.php @@ -115,6 +115,8 @@ function show_artists ($match = '') { } if (count($artists)) { + /* Ack horrible hack :( */ + $GLOBALS['view'] = $view; require ( conf('prefix') . "/templates/show_artists.inc"); } diff --git a/lib/class/song.class.php b/lib/class/song.class.php index d85e0a53..b437692a 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -806,6 +806,54 @@ class Song { } // end stream_cmd + /** + * get_sql_from_match + * This is specificly for browsing it takes the match and returns the sql call that we want to use + * @package Song + * @catagory Class + */ + function get_sql_from_match($match) { + + switch ($match) { + case 'Show_All': + case 'show_all': + $sql = "SELECT id FROM song"; + break; + case 'Browse': + case 'show_genres': + $sql = "SELECT id FROM song"; + break; + default: + $sql = "SELECT id FROM song WHERE title LIKE '" . sql_escape($match) . "%'"; + break; + } // end switch on match + + return $sql; + + } // get_sql_from_match + + /** + * get_genres + * this returns an array of songs based on a sql statement that's passed + * @package songs + * @catagory Class + */ + function get_songs($sql) { + + $db_results = mysql_query($sql, dbh()); + + $results = array(); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r['id']; + } + + return $results; + + } // get_genres + + + } // end of song class ?> diff --git a/templates/list_header.inc b/templates/list_header.inc index 488b55f6..1ca08c4c 100644 --- a/templates/list_header.inc +++ b/templates/list_header.inc @@ -31,25 +31,24 @@ if (!$total_items) { $total_items = $_SESSION['view_total_items']; } // do some math here -if ($view->offset >= $view->offset_limit) { - $offset2 = $view->offset - 25; +if ($GLOBALS['view']->offset >= $GLOBALS['view']->offset_limit) { + $offset2 = $GLOBALS['view']->offset - 25; } else { - $offset2 = $view->offset; - if (!$view->offset) { $offset2 = "0"; } + $offset2 = $GLOBALS['view']->offset; + if (!$GLOBALS['view']->offset) { $offset2 = "0"; } } - // Get the prev page offset -$offset1 = $view->offset - $view->offset_limit; +$offset1 = $GLOBALS['view']->offset - $GLOBALS['view']->offset_limit; if ($offset1 < 1) { $offset1 = 0; } // since we have an array of objects, let's build a purdy thingie -$pages = ceil($total_items/$view->offset_limit); +$pages = ceil($total_items/$GLOBALS['view']->offset_limit); $offset4 = ($pages - 1); -$offset4 = ($offset4 * $view->offset_limit); +$offset4 = ($offset4 * $GLOBALS['view']->offset_limit); //We do this one last to make sure we don't go beyond offset4 -$offset3 = $view->offset + $view->offset_limit; +$offset3 = $GLOBALS['view']->offset + $GLOBALS['view']->offset_limit; if ($offset3 >= $offset4) { $offset3 = $offset4; } @@ -68,19 +67,37 @@ if (($pages > 1) && ($_SESSION['view_script'])) { </td> <td align="center"> <?php + $page_limit = '10'; $counter = 1; $offset_pages = 0; while ($counter <= $pages) { - if ($view->offset == $offset_pages) { - ?> <a href="<?php echo $script; ?>?<?php echo $action ; ?>&sort_type=<?php echo $view->sort_type ; ?>&offset=<?php echo $offset_pages ; ?>&keep_view=true"><b><?php echo $counter; ?></b></a> + if ($GLOBALS['view']->offset == $offset_pages) { + ?> <a href="<?php echo $script; ?>?<?php echo $action ; ?>&sort_type=<?php echo $GLOBALS['view']->sort_type ; ?>&offset=<?php echo $offset_pages ; ?>&keep_view=true"><b><?php echo $counter; ?></b></a> <?php } else { ?> - <a href="<?php echo $script; ?>?<?php echo $action; ?>&sort_type=<?php echo $view->sort_type; ?>&offset=<?php echo $offset_pages; ?>&keep_view=true"><?php echo $counter; ?></a> + <a href="<?php echo $script; ?>?<?php echo $action; ?>&sort_type=<?php echo $GLOBALS['view']->sort_type; ?>&offset=<?php echo $offset_pages; ?>&keep_view=true"><?php echo $counter; ?></a> <?php - } // end if ($view->offset == $offset_pages) and else - $offset_pages += $view->offset_limit; + } // end if ($GLOBALS['view']->offset == $offset_pages) and else + $offset_pages += $GLOBALS['view']->offset_limit; + if ($counter == $page_limit AND $pages > ($page_limit*2)) { break; } $counter++; - } // end while ($counter <= $pages) ?> + } // end while ($counter <= $pages) + + if ($counter < $pages) { + echo "[.....]"; + $counter = $pages - $page_limit; + while ($counter <= $pages) { + if ($GLOBALS['view']->offset == $offset_pages) { ?> + <a href="<?php echo $script; ?>?<?php echo $action ; ?>&sort_type=<?php echo $GLOBALS['view']->sort_type ; ?>&offset=<?php echo $offset_pages ; ?>&keep_view=true"><b><?php echo $counter; ?></b></a> + <?php } else { ?> + <a href="<?php echo $script; ?>?<?php echo $action; ?>&sort_type=<?php echo $GLOBALS['view']->sort_type; ?>&offset=<?php echo $offset_pages; ?>&keep_view=true"><?php echo $counter; ?></a> + <?php + } // end if ($GLOBALS['view']->offset == $offset_pages) and else + $offset_pages += $GLOBALS['view']->offset_limit; + $counter++; + } // end while ($counter <= $pages) + } // end while if we had to do a second half + ?> </td> <td align="center" valign="top"> <a href="<?php echo $script; ?>?<?php echo $action; ?>&offset=<?php echo $offset3; ?>&keep_view=true">[ <?php echo _("Next"); ?> ]</a> diff --git a/templates/show_artists.inc b/templates/show_artists.inc index c0bd8510..074bdf5a 100644 --- a/templates/show_artists.inc +++ b/templates/show_artists.inc @@ -32,7 +32,7 @@ $total_items = $view->total_items; <table class="border" cellspacing="0" cellpadding="0" border="0"> <tr class="even" align="center"> <td colspan="5"> - <?php if ($view->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?> + <?php if ($GLOBALS['view']->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?> </td> </tr> <tr class="table-header"> diff --git a/templates/show_songs.inc b/templates/show_songs.inc index 7d2c5620..09ebc31a 100644 --- a/templates/show_songs.inc +++ b/templates/show_songs.inc @@ -30,6 +30,13 @@ if (is_object($playlist) && ($GLOBALS['user']->username == $playlist->user || $G ?> <form id="songs" method="post" enctype="multipart/form-data" action="#" style="Display:inline;"> <table class="border" cellspacing="0" cellpadding="0" border="0"> +<?php if (is_object($GLOBALS['view'])) { ?> +<tr class="even" align="center"> + <td colspan="12"> + <?php if ($GLOBALS['view']->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?> + </td> +</tr> +<?php } ?> <tr class="table-header"> <th> <a href="#" onclick="check_songs(); return false;">Select</a></th> <?php if ($playlist_owner) { ?> @@ -160,6 +167,13 @@ $num = count($song_ids); <td></td> <td colspan="2"></td> </tr> +<?php if (is_object($GLOBALS['view'])) { ?> +<tr class="even" align="center"> + <td colspan="12"> + <?php if ($GLOBALS['view']->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?> + </td> +</tr> +<?php } ?> </table> <p class="header2"><?php echo _('** Indicates flagged songs'); ?></p> <br /> diff --git a/templates/sidebar.inc.php b/templates/sidebar.inc.php index 5449baef..5f5fdde1 100644 --- a/templates/sidebar.inc.php +++ b/templates/sidebar.inc.php @@ -36,6 +36,7 @@ $admin_items[] = array('title'=>_('Modules'),'url'=>'admin/modules.php','active' $browse_items[] = array('title'=>_("Albums"),'url'=>'albums.php','active'=>$location['page']); $browse_items[] = array('title'=>_("Artists"),'url'=>'artists.php','active'=>$location['page']); $browse_items[] = array('title'=>_("Genre"),'url'=>'browse.php?action=genre','active'=>$location['page']); +$browse_items[] = array('title'=>_('Song Title'),'url'=>'browse.php?action=song_title','active'=>$location['page']); $browse_items[] = array('title'=>_("Lists"),'url'=>'browse.php','active'=>$location['page']); //$browse_items[] = array('title'=>'File','url'=>'files.php','active'=>''); <!--pb1dft: this can be cleaned up --> |