mirror of
https://github.com/Yetangitu/ampache
synced 2025-10-06 11:59:56 +02:00
fixed admin prefs, flushed out localplay stuff, tweaked filters on browse
This commit is contained in:
parent
15c56f21f2
commit
f64a2f4d00
17 changed files with 119 additions and 99 deletions
|
@ -41,30 +41,35 @@ echo '<div id="browse_content">';
|
|||
switch($_REQUEST['action']) {
|
||||
case 'file':
|
||||
case 'album':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('album');
|
||||
Browse::set_sort('name','ASC');
|
||||
$album_ids = Browse::get_objects();
|
||||
Browse::show_objects($album_ids);
|
||||
break;
|
||||
case 'artist':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('artist');
|
||||
Browse::set_sort('name','ASC');
|
||||
$artist_ids = Browse::get_objects();
|
||||
Browse::show_objects($artist_ids);
|
||||
break;
|
||||
case 'genre':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('genre');
|
||||
Browse::set_sort('name','ASC');
|
||||
$genre_ids = Browse::get_objects();
|
||||
Browse::show_objects($genre_ids);
|
||||
break;
|
||||
case 'song':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('song');
|
||||
Browse::set_sort('title','ASC');
|
||||
$song_ids = Browse::get_objects();
|
||||
Browse::show_objects($song_ids);
|
||||
break;
|
||||
case 'live_stream':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('live_stream');
|
||||
Browse::set_sort('name','ASC');
|
||||
$live_stream_ids = Browse::get_objects();
|
||||
|
@ -74,6 +79,7 @@ switch($_REQUEST['action']) {
|
|||
|
||||
break;
|
||||
case 'playlist':
|
||||
Browse::reset_filters();
|
||||
Browse::set_type('playlist');
|
||||
Browse::set_sort('name','ASC');
|
||||
$playlist_ids = Browse::get_objects();
|
||||
|
|
|
@ -4,6 +4,12 @@
|
|||
|
||||
--------------------------------------------------------------------------
|
||||
v.3.4-Alpha3
|
||||
- Added reset of filters when switching between browse types this
|
||||
may be removed in the future...
|
||||
- Fixed LastFM submitting even when there was no username/password
|
||||
- Put Catalog 'All' Functions back onto catalog view
|
||||
- Fixed Admin Preferences reverting to user after first update
|
||||
- Fixed Localplay playlist
|
||||
- Updated Ajax Load icon (Thx Spocky)
|
||||
- Replaced Flash Player with Lacy Morrow's (http://blog.lacymorrow.com/)
|
||||
(Thx Hugoh)
|
||||
|
|
|
@ -82,12 +82,6 @@ class Ajax {
|
|||
$source_txt = "'$source'";
|
||||
}
|
||||
|
||||
/*
|
||||
Replaces ampersand with & for w3c conformance.
|
||||
Fixme: ajax doesn't seem to work anymore with this...
|
||||
*/
|
||||
//$url = htmlspecialchars($url);
|
||||
|
||||
if ($post) {
|
||||
$ajax_string = "ajaxPost('$url','$post',$source_txt)";
|
||||
}
|
||||
|
|
|
@ -77,6 +77,20 @@ class Browse {
|
|||
|
||||
} // set_filter
|
||||
|
||||
/**
|
||||
* reset_filter
|
||||
* This is a wrapper function that resets the filters
|
||||
*/
|
||||
public static function reset_filters() {
|
||||
|
||||
if (!is_array($_SESSION['browse']['filter'])) { return true; }
|
||||
|
||||
foreach ($_SESSION['browse']['filter'] AS $key=>$value) {
|
||||
self::set_filter($key,'');
|
||||
}
|
||||
|
||||
} // reset_filters
|
||||
|
||||
/**
|
||||
* get_filter
|
||||
* returns the specified filter value
|
||||
|
|
|
@ -26,7 +26,7 @@ abstract class localplay_controller {
|
|||
|
||||
// Required Functions
|
||||
abstract public function add($objects); // Takes an array of song_ids
|
||||
abstract public function delete($objects); // Takes an array of song_ids
|
||||
abstract public function delete_track($object_id); // Takes a single object_id and removes it from the playlist
|
||||
abstract public function play();
|
||||
abstract public function stop();
|
||||
abstract public function get();
|
||||
|
|
|
@ -119,22 +119,6 @@ class Localplay {
|
|||
|
||||
} // _load_player
|
||||
|
||||
/**
|
||||
* has_function
|
||||
* This is used to check the function map and see if the current
|
||||
* player type supports the indicated function.
|
||||
*/
|
||||
public function has_function($function_name) {
|
||||
|
||||
/* Check the function map, if it's got a value it must
|
||||
* be possible
|
||||
*/
|
||||
if (strlen($this->_function_map[$function_name]) > 0) { return true; }
|
||||
|
||||
return false;
|
||||
|
||||
} // has_function
|
||||
|
||||
/**
|
||||
* format_name
|
||||
* This function takes the track name and checks to see if 'skip'
|
||||
|
@ -144,13 +128,7 @@ class Localplay {
|
|||
public function format_name($name,$id) {
|
||||
|
||||
$name = scrub_out($name);
|
||||
|
||||
if ($this->has_function('skip')) {
|
||||
$url = conf('ajax_url') . "?action=localplay&cmd=skip&value=$id" . conf('ajax_info');
|
||||
|
||||
$name = "<span style=\"cursor:pointer;text-decoration:underline;\" onclick=\"ajaxPut('$url');return true;\">$name</span>";
|
||||
}
|
||||
|
||||
$name = Ajax::text('?page=localplay&action=command&command=skip&id=' . $id,$name,'localplay_skip_' . $id);
|
||||
return $name;
|
||||
|
||||
} // format_name
|
||||
|
@ -385,9 +363,7 @@ class Localplay {
|
|||
*/
|
||||
public function get() {
|
||||
|
||||
$function = $this->_function_map['get'];
|
||||
|
||||
$data = $this->_player->$function();
|
||||
$data = $this->_player->get();
|
||||
|
||||
if (!count($data) OR !is_array($data)) {
|
||||
debug_event('localplay','Error Unable to get song info, check ' . $this->type . ' controller','1');
|
||||
|
@ -481,9 +457,9 @@ class Localplay {
|
|||
* skip
|
||||
* This isn't a required function, it tells the daemon to skip to the specified song
|
||||
*/
|
||||
public function skip($song_id) {
|
||||
public function skip($track_id) {
|
||||
|
||||
if (!$this->_player->$function($song_id)) {
|
||||
if (!$this->_player->skip($track_id)) {
|
||||
debug_event('localplay','Error: Unable to skip to next song, check ' . $this->type . ' controller','1');
|
||||
return false;
|
||||
}
|
||||
|
@ -608,14 +584,13 @@ class Localplay {
|
|||
} // set_active_instance
|
||||
|
||||
/**
|
||||
* delete
|
||||
* This removes songs from the players playlist as defined get function
|
||||
* delete_track
|
||||
* This removes songs from the players playlist it takes a single ID as provided
|
||||
* by the get command
|
||||
*/
|
||||
public function delete($songs) {
|
||||
public function delete_track($object_id) {
|
||||
|
||||
$function = $this->_function_map['delete'];
|
||||
|
||||
if (!$this->_player->$function($songs)) {
|
||||
if (!$this->_player->delete_track($object_id)) {
|
||||
debug_event('localplay','Error: Unable to remove songs, check ' . $this->type . ' controller','1');
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1004,8 +1004,12 @@ function get_user_icon($name,$title='',$id='') {
|
|||
* primarly by the ajax mojo
|
||||
*/
|
||||
function xml_from_array($array,$callback=0,$type='') {
|
||||
switch ($type) {
|
||||
|
||||
// If we weren't passed an array then return a blank string
|
||||
if (!is_array($array)) { return ''; }
|
||||
|
||||
// The type is used for the different XML docs we pass
|
||||
switch ($type) {
|
||||
case 'itunes':
|
||||
foreach ($array as $key=>$value) {
|
||||
if (is_array($value)) {
|
||||
|
@ -1025,7 +1029,7 @@ function xml_from_array($array,$callback=0,$type='') {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // end foreach
|
||||
|
||||
return $string;
|
||||
break;
|
||||
|
@ -1046,7 +1050,7 @@ function xml_from_array($array,$callback=0,$type='') {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
} // end foreach
|
||||
|
||||
return $string;
|
||||
break;
|
||||
|
|
|
@ -54,9 +54,14 @@ switch ($_REQUEST['action']) {
|
|||
$fields = $localplay->get_instance_fields();
|
||||
require_once Config::get('prefix') . '/templates/show_localplay_instances.inc.php';
|
||||
break;
|
||||
case 'show_songs':
|
||||
case 'show_playlist':
|
||||
// Init and then connect to our localplay instance
|
||||
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
|
||||
$localplay->connect();
|
||||
|
||||
// Pull the current playlist and require the template
|
||||
$objects = $localplay->get();
|
||||
require_once Config::get('prefix') . '/templates/show_localplay_playlist.inc.php';
|
||||
break;
|
||||
case 'delete_song':
|
||||
$song_id = scrub_in($_REQUEST['song_id']);
|
||||
|
|
|
@ -277,30 +277,17 @@ class AmpacheMpd extends localplay_controller {
|
|||
} // add_songs
|
||||
|
||||
/**
|
||||
* delete_songs
|
||||
* This must take an array of ID's (as passed by get function) from Ampache
|
||||
* and delete them from MPD
|
||||
* delete_track
|
||||
* This must take a single ID (as passed by get function) from Ampache
|
||||
* and delete it from the current playlist
|
||||
*/
|
||||
public function delete($objects) {
|
||||
public function delete_track($object_id) {
|
||||
|
||||
/* Default to true */
|
||||
$return = true;
|
||||
if (is_null($this->_mpd->PLRemove($object_id))) { return false; }
|
||||
|
||||
/* This should be an array of UID's as returned by
|
||||
* the get function so that we can just call the class based
|
||||
* functions to remove them or if there isn't a uid for
|
||||
* the songs, then however ya'll have stored them
|
||||
* in this controller
|
||||
*/
|
||||
foreach ($songs as $uid) {
|
||||
return true;
|
||||
|
||||
if (is_null($this->_mpd->PLRemove($uid))) { $return = false; }
|
||||
|
||||
} // foreach of songs
|
||||
|
||||
return $return;
|
||||
|
||||
} // delete_songs
|
||||
} // delete_track
|
||||
|
||||
/**
|
||||
* clear_playlist
|
||||
|
@ -456,6 +443,11 @@ class AmpacheMpd extends localplay_controller {
|
|||
*/
|
||||
public function get() {
|
||||
|
||||
// If we don't have the playlist yet, pull it
|
||||
if (!isset($this->_mpd->playlist)) {
|
||||
$this->_mpd->GetPlaylist();
|
||||
}
|
||||
|
||||
/* Get the Current Playlist */
|
||||
$playlist = $this->_mpd->playlist;
|
||||
|
||||
|
@ -474,10 +466,10 @@ class AmpacheMpd extends localplay_controller {
|
|||
|
||||
/* If we don't know it, look up by filename */
|
||||
if (!$song->title) {
|
||||
$filename = sql_escape($entry['file']);
|
||||
$sql = "SELECT id FROM song WHERE file LIKE '%$filename'";
|
||||
$db_results = mysql_query($sql, dbh());
|
||||
if ($r = mysql_fetch_assoc($db_results)) {
|
||||
$filename = Dba::escape($entry['file']);
|
||||
$sql = "SELECT `id` FROM `song` WHERE `file` LIKE '%$filename'";
|
||||
$db_results = Dba::query($sql);
|
||||
if ($r = Dba::fetch_assoc($db_results)) {
|
||||
$song = new Song($r['id']);
|
||||
}
|
||||
else {
|
||||
|
@ -486,7 +478,7 @@ class AmpacheMpd extends localplay_controller {
|
|||
}
|
||||
|
||||
/* Make the name pretty */
|
||||
$song->format_song();
|
||||
$song->format();
|
||||
$data['name'] = $song->f_title . ' - ' . $song->f_album . ' - ' . $song->f_artist;
|
||||
|
||||
/* Optional Elements */
|
||||
|
@ -499,7 +491,7 @@ class AmpacheMpd extends localplay_controller {
|
|||
|
||||
return $results;
|
||||
|
||||
} // get_songs
|
||||
} // get
|
||||
|
||||
/**
|
||||
* get_status
|
||||
|
|
|
@ -467,16 +467,15 @@ class mpd {
|
|||
*
|
||||
* Removes track <id> from the playlist.
|
||||
*/
|
||||
function PLRemove($id) {
|
||||
if ( $this->debugging ) echo "mpd->PLRemove()\n";
|
||||
public function PLRemove($id) {
|
||||
if ( ! is_numeric($id) ) {
|
||||
$this->errStr = "PLRemove() : argument 1 must be a numeric value";
|
||||
return NULL;
|
||||
}
|
||||
if ( ! is_null($resp = $this->SendCommand(MPD_CMD_PLREMOVE,$id))) $this->RefreshInfo();
|
||||
if ( $this->debugging ) echo "mpd->PLRemove() / return\n";
|
||||
debug_event('MPD',"mpd->PLRemove() / return",'5');
|
||||
return $resp;
|
||||
}
|
||||
} // PLRemove
|
||||
|
||||
/* SetRepeat()
|
||||
*
|
||||
|
@ -970,13 +969,14 @@ class mpd {
|
|||
* NOTE: This function really should not be used. Instead, use $this->playlist. The function
|
||||
* will most likely be deprecated in future releases.
|
||||
*/
|
||||
function GetPlaylist() {
|
||||
if ( $this->debugging ) echo "mpd->GetPlaylist()\n";
|
||||
public function GetPlaylist() {
|
||||
|
||||
$resp = $this->SendCommand(MPD_CMD_PLLIST);
|
||||
$playlist = $this->_parseFileListResponse($resp);
|
||||
if ( $this->debugging ) echo "mpd->GetPlaylist() / return ".print_r($playlist)."\n";
|
||||
debug_event('MPD',"mpd->GetPlaylist() / return ".print_r($playlist,1),'5');
|
||||
return $playlist;
|
||||
}
|
||||
|
||||
} // GetPlaylist
|
||||
|
||||
/* ClearPLIfStopped()
|
||||
*
|
||||
|
|
|
@ -102,6 +102,9 @@ class AmpacheLastfm {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Make sure there's actually a username and password before we keep going
|
||||
if (!$this->username || !$this->password) { return false; }
|
||||
|
||||
// Create our scrobbler with everything this time and then queue it
|
||||
$scrobbler = new scrobbler($this->username,$this->password,$this->hostname,$this->port,$this->path,$this->challenge);
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
require 'lib/init.php';
|
||||
|
||||
/* Scrub in the needed mojo */
|
||||
if (!$_REQUEST['tab']) { $_REQUEST['tab'] = 'interface'; }
|
||||
|
||||
// Switch on the action
|
||||
switch($_REQUEST['action']) {
|
||||
case 'update_preferences':
|
||||
|
@ -36,6 +33,7 @@ switch($_REQUEST['action']) {
|
|||
if ($_REQUEST['method'] == 'admin') {
|
||||
$user_id = '-1';
|
||||
$fullname = _('Server');
|
||||
$_REQUEST['action'] = 'admin';
|
||||
}
|
||||
elseif ($_REQUEST['method'] == 'user') {
|
||||
$user_id = $_REQUEST['user_id'];
|
||||
|
|
|
@ -61,12 +61,27 @@ switch ($_REQUEST['action']) {
|
|||
$command = scrub_in($_REQUEST['command']);
|
||||
$localplay->$command();
|
||||
break;
|
||||
case 'skip':
|
||||
$localplay->skip(intval($_REQUEST['id']));
|
||||
break;
|
||||
default:
|
||||
// Nothing
|
||||
break;
|
||||
} // end whitelist
|
||||
|
||||
break;
|
||||
case 'delete_track':
|
||||
// Load Connect... yada yada
|
||||
$localplay = new Localplay($GLOBALS['user']->prefs['localplay_controller']);
|
||||
$localplay->connect();
|
||||
|
||||
// Scrub in the delete request
|
||||
$id = intval($_REQUEST['id']);
|
||||
|
||||
$localplay->delete_track($id);
|
||||
|
||||
$results['localplay_playlist_' . $id] = '';
|
||||
break;
|
||||
case 'delete_instance':
|
||||
// Make sure that you have access to do this... again I really
|
||||
// don't know what that means so I'm just going to do nothing fo now
|
||||
|
|
|
@ -51,5 +51,17 @@
|
|||
<th><?php echo _('Last Add'); ?></th>
|
||||
<th><?php echo _('Actions'); ?></th>
|
||||
</tr>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td colspan="3">
|
||||
|
||||
</td>
|
||||
<td align="right" colspan="2">
|
||||
<a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather All Art'); ?></a>
|
||||
| <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=add_to_all_catalogs"><?php echo _('Add to All'); ?></a>
|
||||
| <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=update_all_catalogs"><?php echo _('Verify All'); ?></a>
|
||||
| <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=clean_all_catalogs"><?php echo _('Clean All'); ?></a>
|
||||
| <a href="<?php echo Config::get('web_path'); ?>/admin/catalog.php?action=full_service"><?php echo _('Update All'); ?></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php require Config::get('prefix') . '/templates/list_header.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,37 +18,34 @@
|
|||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
$songs = $localplay->get();
|
||||
$status = $localplay->status();
|
||||
?>
|
||||
<table cellspacing="0">
|
||||
<?php show_box_top(_('Current Playlist')); ?>
|
||||
<table class="table-data" cellspacing="0">
|
||||
<tr class="table-header">
|
||||
<th><?php echo _('Track'); ?></th>
|
||||
<th><?php echo _('Name'); ?></th>
|
||||
<th><?php echo _('Action'); ?></th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($songs as $song) {
|
||||
foreach ($objects as $object) {
|
||||
$class = '';
|
||||
if ($status['track'] == $song['track']) { $class=' class="lp_current"'; }
|
||||
if ($status['track'] == $object['track']) { $class=' class="lp_current"'; }
|
||||
?>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<tr class="<?php echo flip_class(); ?>" id="localplay_playlist_<?php echo $object['id']; ?>">
|
||||
<td>
|
||||
<?php echo scrub_out($song['track']); ?>
|
||||
<?php echo scrub_out($object['track']); ?>
|
||||
</td>
|
||||
<td<?php echo $class; ?>>
|
||||
<?php echo $localplay->format_name($song['name'],$song['id']); ?>
|
||||
<?php echo $localplay->format_name($object['name'],$object['id']); ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo $web_path; ?>/localplay.php?action=delete_song&song_id=<?php echo scrub_out($song['id']); ?>">
|
||||
<?php echo get_user_icon('delete'); ?>
|
||||
</a>
|
||||
<?php echo Ajax::button('?page=localplay&action=delete_track&id=' . intval($object['id']),'delete',_('Delete'),'localplay_delete_' . intval($object['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } if (!count($songs)) { ?>
|
||||
<?php } if (!count($objects)) { ?>
|
||||
<tr class="<?php echo flip_class(); ?>">
|
||||
<td colspan="3"><span class="error"><?php echo _('No Records Found'); ?></span></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
<?php show_box_bottom(); ?>
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<ul class="sb3" id="sb_admin_ot">
|
||||
<li id="sb_admin_ot_ClearNowPlaying"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a></li>
|
||||
<li id="sb_admin_ot_ClearCatStats"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_stats"><?php echo _('Clear Catalog Stats'); ?></a></li>
|
||||
<li id="sb_admin_ot_GatherArt"><a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather Album Art'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<ul class="sb3" id="sb_localplay_info">
|
||||
<li id="sb_localplay_info_add_instance"><a href="<?php echo $web_path; ?>/localplay.php?action=show_add_instance"><?php echo _('Add Instance'); ?></a></li>
|
||||
<li id="sb_localplay_info_show_instances"><a href="<?php echo $web_path; ?>/localplay.php?action=show_instances"><?php echo _('Show instances'); ?></a></li>
|
||||
<li id="sb_localplay_info_show"><a href="<?php echo $web_path; ?>/localplay.php?action=show_songs"><?php echo _('Show Playlist'); ?></a></li>
|
||||
<li id="sb_localplay_info_show"><a href="<?php echo $web_path; ?>/localplay.php?action=show_playlist"><?php echo _('Show Playlist'); ?></a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<?php } ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue