Index: /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm
===================================================================
--- /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm (revision 12732)
+++ /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/LiveSearch.pm (working copy)
@@ -26,6 +26,7 @@
my $query = shift;
my $rsList = shift;
my $player = shift;
+ my $params = shift;
my @xml = (
'',
@@ -43,9 +44,34 @@
if ($count <= MAXRESULTS) {
- my $rowType = $count % 2 ? 'even' : 'odd';
+ my %form = (
+ 'hreftype' => 'browseDb',
+ 'odd' => ($count+1) % 2,
+ 'player' => $player,
+ 'itemobj' => $item,
+ 'level' => 1,
+ 'descend' => $type ne 'track',
+ 'artwork' => 0,
+ 'attributes' => sprintf('&%s.id=%d', $type, $item->id)
+ );
+
+ if ($type eq 'contributor') {
+
+ $form{'attributes'} .= '&contributor.role=ALL';
+ $form{'hierarchy'} = 'contributor,album,track';
+
+ } elsif ($type eq 'album') {
+
+ $form{'hierarchy'} = 'album,track';
+ }
+
+ $item->displayAsHTML(\%form, $type ne 'track');
+
+ my $anchor = substr($item->namesort, 0, 1);
+
+ $params->{item} = \%form;
- push @output, renderItem($rowType, $type, $item, $player);
+ push @output, ${Slim::Web::HTTP::filltemplatefile("browsedbitems_list.html", $params)};
}
$count++;
@@ -71,6 +97,7 @@
return \join('', @xml);
}
+
sub outputAsXML {
my $class = shift;
my $query = shift;
@@ -91,8 +118,6 @@
while (my $item = $rs->next) {
- my $rowType = $count % 2 ? 'even' : 'odd';
-
if ($count <= MAXRESULTS) {
push @output, sprintf('%s', $item->id, $item->name);
@@ -120,98 +145,6 @@
return \join('', @xml);
}
-
-sub renderItem {
- my ($rowType, $type, $item, $player) = @_;
-
- my $id = $item->id,
- my @xml = ();
- my $name = '';
- my $showExtra = '';
-
- # Track case, followed by album & artist.
- if (blessed($item) eq 'Slim::Schema::Track') {
-
- $name = Slim::Music::Info::standardTitle(undef, $item) || '';
-
- # Starting work on the standard track list format, but its a work in progress.
- my $webFormat = $prefs->get('titleFormat')->[ $prefs->get('titleFormatWeb') ] || '';
-
- # This is rather redundant from Pages.pm
- if ($webFormat !~ /ARTIST/ && $item->can('artist') && $item->artist) {
-
- $showExtra .= sprintf(
- ' %s %s',
- string('BY'), $item->artist->id, $player, $item->artist->name,
- );
- }
-
- if ($webFormat !~ /ALBUM/ && $item->can('album') && $item->album) {
-
- $showExtra .= sprintf(
- ' %s %s',
- string('FROM'), $item->album->id, $player, $item->album->title,
- );
- }
-
- } elsif (blessed($item) eq 'Slim::Schema::Album') {
-
- $name = $item->name;
-
- # This is rather redundant from the Album displayAsHTML Schema
- if ($prefs->get('showYear') && $item->can('year') && $item->year) {
-
- $showExtra .= sprintf(
- ' %s%s%s ',
- '(', $item->year, $player, $item->year, ')',
- );
- }
-
- # This is rather redundant from the Album displayAsHTML Schema
- if ($prefs->get('showArtist') && $item->can('artists') && $item->artists) {
- my @artists = $item->artists;
-
- $showExtra .= sprintf(
- ' %s %s',
- string('BY'), $artists[0]->id, $player, $artists[0]->name,
- );
- }
-
- } else {
-
- $name = $item->name;
- }
-
- # We need to handle the different urls that are needed for different result types
- my $url;
-
- if ($type eq 'track') {
-
- $url = "songinfo.html?item=$id";
-
- } elsif ($type eq 'album') {
-
- $url = "browsedb.html?hierarchy=album,track&level=1&album.id=$id";
-
- } elsif ($type eq 'contributor') {
-
- $url = "browsedb.html?hierarchy=contributor,album,track&level=1&contributor.id=$id&contributor.role=ALL";
- }
-
- push @xml,"\n
\n
-
$name$showExtra";
-
- push @xml,"
\n
\n
\n";
-
- return join('', @xml);
-}
1;
__END__
Index: /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm
===================================================================
--- /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm (revision 12732)
+++ /Users/mh/Documents/workspace/slimpy/Slim/Web/Pages/Search.pm (working copy)
@@ -94,7 +94,7 @@
# do it live - and send back the div
# this should be replaced with a call to filltemplatefile()
- return Slim::Web::Pages::LiveSearch->outputAsXHTML($query, \@rsList, $player);
+ return Slim::Web::Pages::LiveSearch->outputAsXHTML($query, \@rsList, $player, $params);
}
}