[LON-CAPA-cvs] cvs: loncom /interface lonindexer.pm lonsearchcat.pm

www lon-capa-cvs@mail.lon-capa.org
Mon, 06 Mar 2006 18:23:11 -0000


www		Mon Mar  6 13:23:11 2006 EDT

  Modified files:              
    /loncom/interface	lonindexer.pm lonsearchcat.pm 
  Log:
  Bug #563: show preview in Search
  
  
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.139 loncom/interface/lonindexer.pm:1.140
--- loncom/interface/lonindexer.pm:1.139	Thu Mar  2 15:16:10 2006
+++ loncom/interface/lonindexer.pm	Mon Mar  6 13:23:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.139 2006/03/02 20:16:10 www Exp $
+# $Id: lonindexer.pm,v 1.140 2006/03/06 18:23:10 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1062,35 +1062,8 @@
         }
         if ($hash{'display_attrs_7'} == 1) {
 # Show resource
-            my $output='';
-            my $embstyle=&Apache::loncommon::fileembstyle($curfext);
-	    if ($embstyle eq 'ssi') {
-		my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
-		    '.tmp';
-		if ((!$env{'form.updatedisplay'}) &&
-		    (-e $cache)) {
-		    open(FH,$cache);
-		    $output=join("\n",<FH>);
-		    close(FH);
-		} else {
-		    $output=&Apache::lonnet::ssi_body($filelink);
-		    if ($output=~/LONCAPAACCESSCONTROLERRORSCREEN/) {
-			$output='';
-		    } else {
-			open(FH,">$cache");
-			print FH $output;
-			close(FH);
-		    }
-		}
-		$output='<font size="-2">'.$output.'</font>';
-	   } elsif ($embstyle eq 'img') {
-               $output='<img src="'.$filelink.'" />';
-           } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {
-               $output='<img src="http://'.
-		 $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.
-                 '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
-           }
-	   $r->print('<td> '.($output eq '' ? '&nbsp;':$output).
+	   my $output=&showpreview($filelink);
+           $r->print('<td> '.($output eq '' ? '&nbsp;':$output).
 		      " </td>\n");
         }
 	$r->print("</tr>\n");
@@ -1182,6 +1155,40 @@
 
 }
 
+sub showpreview {
+    my ($filelink)=@_;
+    my ($curfext)=($filelink=~/\.(\w+)$/);
+    my $output='';
+    my $embstyle=&Apache::loncommon::fileembstyle($curfext);
+    if ($embstyle eq 'ssi') {
+       my $cache=$Apache::lonnet::perlvar{'lonDocRoot'}.$filelink.
+                    '.tmp';
+       if ((!$env{'form.updatedisplay'}) &&
+                    (-e $cache)) {
+          open(FH,$cache);
+          $output=join("\n",<FH>);
+          close(FH);
+       } else {
+          $output=&Apache::lonnet::ssi_body($filelink);
+          if ($output=~/LONCAPAACCESSCONTROLERRORSCREEN/s) {
+             $output='';
+          } else {
+             open(FH,">$cache");
+             print FH $output;
+             close(FH);
+          }
+       }
+       $output='<font size="-2">'.$output.'</font>';
+    } elsif ($embstyle eq 'img') {
+       $output='<img src="'.$filelink.'" />';
+    } elsif ($filelink=~/^\/res\/(\w+)\/(\w+)\//) {
+       $output='<img src="http://'.
+                 $Apache::lonnet::hostname{&Apache::lonnet::homeserver($2,$1)}.
+                 '/cgi-bin/thumbnail.gif?url='.$filelink.'" />';
+    }
+    return $output;
+}
+
 sub dynmetaprint {
     my ($r,$filelink,$item)=@_;
     if ($dynhash{$filelink}->{$item}) {
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.254 loncom/interface/lonsearchcat.pm:1.255
--- loncom/interface/lonsearchcat.pm:1.254	Wed Feb  8 16:17:58 2006
+++ loncom/interface/lonsearchcat.pm	Mon Mar  6 13:23:10 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.254 2006/02/08 21:17:58 www Exp $
+# $Id: lonsearchcat.pm,v 1.255 2006/03/06 18:23:10 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -77,6 +77,7 @@
 use HTML::Entities();
 use Parse::RecDescent;
 use Apache::lonnavmaps;
+use Apache::lonindexer();
 
 ######################################################################
 ######################################################################
@@ -93,7 +94,9 @@
 # The different view modes and associated functions
 
 my %Views = ("detailed" => \&detailed_citation_view,
+             "detailedpreview" => \&detailed_citation_preview,
 	     "summary"  => \&summary_view,
+             "summarypreview" => \&summary_preview,
 	     "fielded"  => \&fielded_format_view,
 	     "xml"      => \&xml_sgml_view,
 	     "compact"  => \&compact_view);
@@ -1080,7 +1083,9 @@
          'xml' => 'XML/SGML',
          'compact' => 'Compact View',
          'fielded' => 'Fielded Format',
-         'summary' => 'Summary View');
+         'summary' => 'Summary View',
+         'summarypreview' => 'Summary Preview',
+         'detailedpreview' => 'Detailed Citation Preview');
     return $desc{$code};
 }
 
@@ -3333,6 +3338,16 @@
     return $result;
 }
 
+sub detailed_citation_preview {
+    my ($prefix,%values)=@_;
+    return '<table><tr><td>'.
+           &detailed_citation_view($prefix,%values).
+           '</td><td>'.
+           &Apache::lonindexer::showpreview($values{'url'}).
+           '</td></tr></table><hr />';
+}
+
+
 ######################################################################
 ######################################################################
 
@@ -3374,6 +3389,15 @@
     return $result;
 }
 
+sub summary_preview {
+    my ($prefix,%values)=@_;
+    return '<table><tr><td>'.
+           &summary_view($prefix,%values).
+           '</td><td>'.
+           &Apache::lonindexer::showpreview($values{'url'}).
+           '</td></tr></table><hr />';
+}
+
 ######################################################################
 ######################################################################