Index: Slim/Utils/Favorites.pm =================================================================== --- Slim/Utils/Favorites.pm (revision 4156) +++ Slim/Utils/Favorites.pm (working copy) @@ -76,6 +76,7 @@ return undef; } } + sub findByClientAndURL { my $class = shift; my $client = shift; @@ -93,6 +94,29 @@ } } +sub moveItem { + my $client = shift; + my $from = shift; + my $to = shift; + + if (defined $to && $to =~ /^[\+-]/) { + $to = $from + $to; + } + + my @titles = Slim::Utils::Prefs::getArray('favorite_titles'); + my @urls = Slim::Utils::Prefs::getArray('favorite_urls'); + + if (defined $from && defined $to && + $from < scalar @titles && + $to < scalar @titles && $from >= 0 && $to >= 0) { + + Slim::Utils::Prefs::set('favorite_titles',$titles[$from],$to); + Slim::Utils::Prefs::set('favorite_urls',$urls[$from],$to); + Slim::Utils::Prefs::set('favorite_titles',$titles[$to],$from); + Slim::Utils::Prefs::set('favorite_urls',$urls[$to],$from); + } +} + sub deleteByClientAndURL { my $class = shift; my $client = shift; @@ -106,6 +130,18 @@ } +sub deleteByClientAndId { + my $class = shift; + my $client = shift; + my $i = shift; + + if (defined($i)) { + Slim::Utils::Prefs::delete('favorite_titles', $i); + Slim::Utils::Prefs::delete('favorite_urls', $i); + } + +} + # creates a read-only list of favorites. # if you need to modify the list, use add then call new again. sub new { Index: Plugins/Favorites/HTML/EN/plugins/Favorites/favorites_list.html =================================================================== --- Plugins/Favorites/HTML/EN/plugins/Favorites/favorites_list.html (revision 0) +++ Plugins/Favorites/HTML/EN/plugins/Favorites/favorites_list.html (revision 0) @@ -0,0 +1,42 @@ +[% pagetitle = 'PLUGIN_FAVORITES_MODULE_NAME' | string %] +[% PROCESS pageheader.html %] +

[% "PLUGIN_FAVORITES_MODULE_NAME" | string %]

+ +

[% "HOME" | string %] + / [% "PLUGIN_FAVORITES_MODULE_NAME" | string %] +

+ +
+ + + + [% odd = 1 %] + [% FOREACH fav = titles %] + + + + + + + + + + + + [% odd = (not odd) %] + [% END %] +
+ [% fav %] + + [% "MOVEUP" | string %] + + [% "MOVEDOWN" | string %] + + [% "DELETE" | string %] + + [% "PLAY" | string %] +
+ +[% PROCESS pageheader.html %] + + Property changes on: Plugins/Favorites/HTML/EN/plugins/Favorites/favorites_list.html ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/html Name: svn:keywords + "Id Author LastChangedDate LastChangedBy" Name: svn:eol-style + native Index: Plugins/Favorites/HTML/Default/plugins/Favorites/favorites_list.html =================================================================== --- Plugins/Favorites/HTML/Default/plugins/Favorites/favorites_list.html (revision 0) +++ Plugins/Favorites/HTML/Default/plugins/Favorites/favorites_list.html (revision 0) @@ -0,0 +1,65 @@ +[% pageicon = 'RADIO' %] +[% pagetitle = 'PLUGIN_FAVORITES_MODULE_NAME' | string %] +[% PROCESS pageheader.html %] + + + + + + + + + + + + + + + + + + + +
+ [% "HOME" | string %] + / [% "PLUGIN_FAVORITES_MODULE_NAME" | string %] +
+ + + + + + + + + + [% odd = 1 %] + [% FOREACH fav = titles %] + + + + + + + + + [% odd = (not odd) %] + [% END %] +
+ [% fav %] + + + [% + + [% + + [% + + [% +
+ + + + + +[% PROCESS pagefooter.html %] Property changes on: Plugins/Favorites/HTML/Default/plugins/Favorites/favorites_list.html ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/html Name: svn:keywords + "Id Author LastChangedDate LastChangedBy" Name: svn:eol-style + native Index: Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/favorites_list.html =================================================================== --- Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/favorites_list.html (revision 0) +++ Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/favorites_list.html (revision 0) @@ -0,0 +1,42 @@ +[% PROCESS pageheader.html %] +

[% "PLUGIN_FAVORITES_MODULE_NAME" | string %]

+ +

/[% "PLUGIN_FAVORITES_MODULE_NAME" | string %]

+
+ + + + [% IF titles %] + [% FOREACH fav = titles %] + + + + + + + + [% END %] + [% END %] +
  + [% fav %] + + + [% "MOVEUP" | string %] + + + [% "MOVEDOWN" | string %] + + + [% "DELETE" | string %] + + + [% "PLAY" | string %] +
+ + + + Property changes on: Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/favorites_list.html ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/html Name: svn:keywords + "Id Author LastChangedDate LastChangedBy" Name: svn:eol-style + native Index: Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/._favorites_list.html =================================================================== --- Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/._favorites_list.html (revision 0) +++ Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/._favorites_list.html (revision 0) @@ -0,0 +1 @@ + 2 RTEXT \ No newline at end of file Property changes on: Plugins/Favorites/HTML/Default/Fishbone/plugins/Favorites/._favorites_list.html ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/html Name: svn:keywords + "Id Author LastChangedDate LastChangedBy" Name: svn:eol-style + native Index: Plugins/Favorites/HTML/Fishbone/plugins/Favorites/favorites_list.html =================================================================== --- Plugins/Favorites/HTML/Fishbone/plugins/Favorites/favorites_list.html (revision 0) +++ Plugins/Favorites/HTML/Fishbone/plugins/Favorites/favorites_list.html (revision 0) @@ -0,0 +1,42 @@ +[% PROCESS pageheader.html %] +

[% "PLUGIN_FAVORITES_MODULE_NAME" | string %]

+ +

/[% "PLUGIN_FAVORITES_MODULE_NAME" | string %]

+
+ + + + [% IF titles %] + [% FOREACH fav = titles %] + + + + + + + + [% END %] + [% END %] +
  + [% fav %] + + + [% "MOVEUP" | string %] + + + [% "MOVEDOWN" | string %] + + + [% "DELETE" | string %] + + + [% "PLAY" | string %] +
+ + + + Property changes on: Plugins/Favorites/HTML/Fishbone/plugins/Favorites/favorites_list.html ___________________________________________________________________ Name: svn:executable + * Name: svn:mime-type + text/html Name: svn:keywords + "Id Author LastChangedDate LastChangedBy" Name: svn:eol-style + native Index: Plugins/Favorites/Plugin.pm =================================================================== --- Plugins/Favorites/Plugin.pm (revision 4156) +++ Plugins/Favorites/Plugin.pm (working copy) @@ -76,6 +76,50 @@ return "PLUGINS"; } +# Web pages + +sub webPages { + my %pages = ("favorites_list\.htm" => \&handleWebIndex); + + if (grep {$_ eq 'Favorites::Plugin'} Slim::Utils::Prefs::getArray('disabledplugins')) { + Slim::Web::Pages::addLinks("browse", { 'PLUGIN_FAVORITES_MODULE_NAME' => undef }); + } else { + Slim::Web::Pages::addLinks("browse", { 'PLUGIN_FAVORITES_MODULE_NAME' => "plugins/Favorites/favorites_list.html" }); + } + + return (\%pages); +} + +sub handleWebIndex { + my ($client, $params) = @_; + + my $now = Time::HiRes::time(); + + if (defined $params->{'p0'}) { + if ($params->{'p0'} eq 'move') { + Slim::Utils::Favorites::moveItem($client, $params->{'p1'}, $params->{'p2'}); + } elsif ($params->{'p0'} eq 'delete') { + Slim::Utils::Favorites->deleteByClientAndId($client, $params->{'p1'}); + } + } + + $params->{'favList'} = {}; + + my $favs = Slim::Utils::Favorites->new($client); + my @titles = $favs->titles(); + my @urls = $favs->urls(); + my $i = 0; + + $params->{'titles'}= \@titles; + $params->{'urls'}= \@urls; + foreach (@titles) { + $params->{'faves'}{$_} = $urls[$i]; + $i++; + } + + return Slim::Web::HTTP::filltemplatefile('plugins/Favorites/favorites_list.html', $params); +} + sub listFavorites { my $client = shift; @@ -109,12 +153,6 @@ Slim::Buttons::Common::pushMode($client,'INPUT.List',\%params); } - - - - - - # the routines sub setMode { my $client = shift; @@ -130,7 +168,6 @@ listFavorites($client); } - sub mainModeCallback { my ($client,$exittype) = @_; $exittype = uc($exittype); @@ -170,8 +207,6 @@ return \%mainModeFunctions; } - - #################################################################### # Adds a mapping for 'playFavorite' function in all modes #################################################################### @@ -228,7 +263,6 @@ Slim::Buttons::Common::setFunction('playFavorite', \&playFavorite); Slim::Buttons::Common::setFunction('addFavorite', \&addFavorite); - }