summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-05-07 08:00:05 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2007-05-07 08:00:05 +0000
commitc0455678c1f6644801e5c25cb07510e49db7b28d (patch)
treec32edccb9386316c8b6ff1f885efa8a66ac0d067
parent0dcbad80cde204cfda078b5fc16a92c41d74c87d (diff)
downloadampache-c0455678c1f6644801e5c25cb07510e49db7b28d.tar.gz
ampache-c0455678c1f6644801e5c25cb07510e49db7b28d.tar.bz2
ampache-c0455678c1f6644801e5c25cb07510e49db7b28d.zip
started work on the sorting, and added in album viewing that kinda works
-rw-r--r--browse.php32
-rw-r--r--lib/class/browse.class.php89
-rw-r--r--server/ajax.server.php10
-rw-r--r--templates/show_albums.inc.php84
-rw-r--r--templates/show_songs.inc.php4
-rw-r--r--templates/sidebar_browse.inc.php2
6 files changed, 115 insertions, 106 deletions
diff --git a/browse.php b/browse.php
index 69454c2e..ea594156 100644
--- a/browse.php
+++ b/browse.php
@@ -42,34 +42,9 @@ echo '<div id="browse_content">';
switch($_REQUEST['action']) {
case 'file':
case 'album':
- show_alphabet_list('albums','albums.php',$match);
- show_alphabet_form($match,_("Show Albums starting with"),"albums.php?action=match");
-
- /* Get the results and show them */
- $sql = "SELECT id FROM album WHERE name LIKE '$match%'";
-
- $view = new View();
- $view->import_session_view();
-
- // if we are returning
- if ($_REQUEST['keep_view']) {
- $view->initialize();
- }
-
- // If we aren't keeping the view then initlize it
- elseif ($sql) {
- $db_results = mysql_query($sql, dbh());
- $total_items = mysql_num_rows($db_results);
- if ($match != "Show_all") { $offset_limit = $user->prefs['offset_limit']; }
- $view = new View($sql, 'albums.php','name',$total_items,$offset_limit);
- }
-
- else { $view = false; }
-
- if ($view->base_sql) {
- $albums = get_albums($view->sql);
- show_albums($albums,$view);
- }
+ Browse::set_type('album');
+ $album_ids = Browse::get_objects();
+ Browse::show_objects($album_ids);
break;
case 'artist':
show_alphabet_list('artists','artists.php');
@@ -107,6 +82,7 @@ switch($_REQUEST['action']) {
Browse::set_type('song');
$song_ids = Browse::get_objects();
Browse::show_objects($song_ids);
+
break;
case 'catalog':
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 531ccc26..8cfb27d6 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -65,6 +65,9 @@ class Browse {
$_SESSION['browse']['filter'][$key] = 1;
}
break;
+ case 'alpha_match':
+ $_SESSION['browse']['filter'][$key] = $value;
+ break;
default:
// Rien a faire
break;
@@ -95,6 +98,22 @@ class Browse {
} // set_type
/**
+ * set_sort
+ * This sets the current sort(s)
+ */
+ public static function set_sort($sort) {
+
+ if ($_SESSION['browse']['type'] == 'song') {
+ switch ($sort) {
+ case'title':
+ $_SESSION['browse']['sort']['title'] = 'ASC';
+ break;
+ }
+ }
+
+ } // set_sort
+
+ /**
* get_objects
* This gets an array of the ids of the objects that we are
* currently browsing by it applies the sql and logic based
@@ -134,13 +153,13 @@ class Browse {
// Get our base SQL must always return ID
switch ($_SESSION['browse']['type']) {
case 'album':
-
+ $sql = "SELECT `album`.`id` FROM `album` ";
break;
case 'artist':
-
+ $sql = "SELECT `artist`.`id` FROM `artist` ";
break;
case 'genre':
-
+ $sql = "SELECT `genre`.`id` FROM `genre` ";
break;
case 'song':
default:
@@ -163,7 +182,18 @@ class Browse {
$sql .= $where_sql;
- self::$sql = $sql;
+ // Now Add the Order
+ $order_sql = "ORDER BY ";
+
+ foreach ($_SESSION['browse']['sort'] as $key=>$value) {
+ $order_sql .= self::sql_sort($value);
+ }
+
+ // Clean her up
+ $order_sql = rtrim($order_sql,"ORDER BY ");
+ $order_sql = rtrim($order_sql,",");
+
+ self::$sql = $sql . $order_sql;
return $sql;
@@ -194,10 +224,17 @@ class Browse {
} // if it is a song
if ($_SESSION['browse']['type'] == 'album') {
+ switch($filter) {
+ case 'alpha_match':
+ $filter_sql = " `album`.`name` LIKE '" . Dba::escape($value) . "%' AND ";
+ break;
+ case 'min_count':
-
-
-
+ break;
+ default:
+ // Rien a faire
+ break;
+ }
} // end album
return $filter_sql;
@@ -218,6 +255,36 @@ class Browse {
} // logic_filter
/**
+ * sql_sort
+ * This builds any order bys we need to do
+ * to sort the results as best we can, there is also
+ * a logic based sort that will come later as that's
+ * a lot more complicated
+ */
+ private static function sql_sort($field,$order) {
+
+ if ($order != 'DESC') { $order == 'ASC'; }
+
+
+ if ($_SESSION['browse']['type'] == 'song') {
+ switch($field) {
+ case 'title';
+ $sql = "`song`.`title`";
+ break;
+ case 'year':
+ $sql = "`song`.`year`";
+ break;
+ default:
+ // Rien a faire
+ break;
+ } // end switch
+ } // end if song
+
+ return $sql . "$order,";
+
+ } // sql_sort
+
+ /**
* show_objects
* This takes an array of objects
* and requires the correct template based on the
@@ -231,6 +298,14 @@ class Browse {
require_once Config::get('prefix') . '/templates/show_songs.inc.php';
show_box_bottom();
break;
+ case 'album':
+ show_box_top();
+ require_once Config::get('prefix') . '/templates/show_albums.inc.php';
+ show_box_bottom();
+ break;
+ default:
+ // Rien a faire
+ break;
} // end switch on type
} // show_object
diff --git a/server/ajax.server.php b/server/ajax.server.php
index 5afb6b61..b815029f 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -195,8 +195,14 @@ switch ($action) {
break;
// Used to change filter/settings on browse
case 'browse':
- // Set any new filters we've just added
- Browse::set_filter($_REQUEST['key'],$_REQUEST['value']);
+ if ($_REQUEST['key'] && $_REQUEST['value']) {
+ // Set any new filters we've just added
+ Browse::set_filter($_REQUEST['key'],$_REQUEST['value']);
+ }
+ if ($_REQUEST['sort']) {
+ // Set the new sort value
+ Browse::set_sort($_REQUEST['sort']);
+ }
// Refresh the browse div with our new filter options
$object_ids = Browse::get_objects();
diff --git a/templates/show_albums.inc.php b/templates/show_albums.inc.php
index b24804b1..588c88b6 100644
--- a/templates/show_albums.inc.php
+++ b/templates/show_albums.inc.php
@@ -1,7 +1,7 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 Ampache.org
All rights reserved.
This program is free software; you can redistribute it and/or
@@ -18,81 +18,31 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-/*!
- @header Show Albums
- @discussion shows a list of albums
-*/
-$web_path = conf('web_path');
-// Build array of the table classes we are using
-$total_items = $view->total_items;
+$web_path = Config::get('web_path');
+$ajax_url = Config::get('ajax_url');
?>
-<?php require(conf('prefix') . '/templates/show_box_top.inc.php'); ?>
<table class="tabledata" cellspacing="0" cellpadding="0" border="0">
<tr class="table-header">
<td colspan="5">
- <?php if ($view->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?>
</td>
</tr>
<tr class="table-header">
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=album.name&amp;sort_order=0"><?php echo _("Album"); ?></a>
- </td>
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=artist.name&amp;type=album_sort&amp;sort_order=0"><?php echo _('Artist'); ?></a>
- </td>
- <td> <?php echo _('Songs'); ?> </td>
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=album.year&amp;sort_order=0"><?php echo _("Year"); ?></a>
- </td>
- <td> <?php echo _("Action"); ?> </td>
+ <th><?php echo _('Add'); ?></th>
+ <th><?php echo _('Album'); ?></th>
+ <th><?php echo _('Artist'); ?></th>
+ <th><?php echo _('Year'); ?></th>
</tr>
-
<?php
-/* Foreach through the albums */
-foreach ($albums as $album) {
+ /* Foreach through the albums */
+ foreach ($object_ids as $album_id) {
+ $album = new Album($album_id);
+ $album->format();
?>
- <tr class="<?php echo flip_class(); ?>">
- <td><?php echo $album->f_name; ?></td>
- <td><?php echo $album->f_artist; ?></td>
- <td><?php echo $album->songs; ?></td>
- <td><?php echo $album->year; ?></td>
- <td nowrap="nowrap">
- <a href="<?php echo $web_path; ?>/song.php?action=album&amp;album_id=<?php echo $album->id; ?>">
- <?php echo get_user_icon('all'); ?>
- </a>
- <a href="<?php echo $web_path; ?>/song.php?action=album_random&amp;album_id=<?php echo $album->id; ?>">
- <?php echo get_user_icon('random'); ?>
- </a>
- <?php if (batch_ok()) { ?>
- <a href="<?php echo $web_path; ?>/batch.php?action=alb&amp;id=<?php echo $album->id; ?>">
- <?php echo get_user_icon('batch_download'); ?>
- </a>
- <?php } ?>
- <?php if ($GLOBALS['user']->has_access('50')) { ?>
- <a href="<?php echo $web_path; ?>/admin/flag.php?action=show_edit_album&amp;album_id=<?php echo $album->id; ?>">
- <?php echo get_user_icon('edit'); ?>
- </a>
- <?php } ?>
- </td>
- </tr>
-<?php } //end foreach ($albums as $album) ?>
-<tr class="table-header">
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=album.name&amp;sort_order=0"><?php echo _("Album"); ?></a>
- </td>
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=artist.name&amp;type=album_sort"><?php echo _('Artist'); ?></a>
- </td>
- <td><?php echo _('Songs'); ?></td>
- <td>
- <a href="<?php echo $web_path; ?>/<?php echo $_SESSION['view_script']; ?>?action=<?php echo $_REQUEST['action']; ?>&amp;keep_view=true&amp;sort_type=album.year&amp;sort_order=0"><?php echo _("Year"); ?></a>
- </td>
- <td><?php echo _('Action'); ?></td>
-</tr>
-<tr class="even" align="center">
- <td colspan="5">
- <?php if ($view->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?>
- </td>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php echo $album->f_name; ?></td>
+ <td><?php echo $album->f_artist; ?></td>
+ <td><?php echo $album->songs; ?></td>
+ <td><?php echo $album->year; ?></td>
</tr>
+<?php } //end foreach ($albums as $album) ?>
</table>
-<?php require(conf('prefix') . '/templates/show_box_bottom.inc.php'); ?>
diff --git a/templates/show_songs.inc.php b/templates/show_songs.inc.php
index e0fa49be..00a8decd 100644
--- a/templates/show_songs.inc.php
+++ b/templates/show_songs.inc.php
@@ -32,7 +32,9 @@ $ajax_url = Config::get('ajax_url');
</tr>
<tr class="table-header">
<th><?php echo _('Add'); ?></th>
- <th><?php echo _('Song Title'); ?></th>
+ <th onclick="ajaxPut('<?php echo $ajax_url; ?>?action=browse&amp;sort=title');return true;" >
+ <?php echo _('Song Title'); ?>
+ </th>
<th><?php echo _('Artist'); ?></th>
<th><?php echo _('Album'); ?></th>
</tr>
diff --git a/templates/sidebar_browse.inc.php b/templates/sidebar_browse.inc.php
index 949d174e..d7cada27 100644
--- a/templates/sidebar_browse.inc.php
+++ b/templates/sidebar_browse.inc.php
@@ -10,9 +10,9 @@
</select>
</form>
<hr />
+<h4><?php echo _('Filters'); ?></h4>
<?php show_alphabet_list($_REQUEST['alpha_match'],$_REQUEST['action']); ?>
<hr />
-<h4><?php echo _('Filters'); ?></h4>
<input type="checkbox" onclick="ajaxPut('<?php echo $ajax_info; ?>?action=browse&amp;key=show_art&amp;value=1');return true;" value="1" />
<?php echo _('Show Art'); ?><br />
<input type="checkbox" onclick="ajaxPut('<?php echo $ajax_info; ?>?action=browse&amp;key=min_count&amp;value=1');return true;" value="1" />