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

www lon-capa-cvs@mail.lon-capa.org
Sat, 26 Nov 2005 02:42:46 -0000


www		Fri Nov 25 21:42:46 2005 EDT

  Modified files:              
    /loncom/interface	lonsearchcat.pm 
  Log:
  Correctly deal with external URLs
  
  
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.246 loncom/interface/lonsearchcat.pm:1.247
--- loncom/interface/lonsearchcat.pm:1.246	Mon Jun 27 18:01:46 2005
+++ loncom/interface/lonsearchcat.pm	Fri Nov 25 21:42:45 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.246 2005/06/27 22:01:46 albertel Exp $
+# $Id: lonsearchcat.pm,v 1.247 2005/11/26 02:42:45 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3222,9 +3222,11 @@
 sub detailed_citation_view {
     my ($prefix,%values) = @_;
     my $result;
+    my $jumpurl=$values{'url'};
+    $jumpurl=~s/^\/ext\//http\:\/\//;
     $result .= '<b>'.$prefix.
         '<img src="'.&Apache::loncommon::icon($values{'url'}).' " />'.'&nbsp;'.
-        '<a href="http://'.$ENV{'HTTP_HOST'}.$values{'url'}.'" '.
+        '<a href="'.$jumpurl.'" '.
         'target="search_preview">'.$values{'title'}."</a></b>\n";
     $result .= "<p>\n";
     $result .= '<b>'.$values{'author'}.'</b>,'.
@@ -3293,7 +3295,7 @@
             foreach my $item (split(',',$values{$field->{'name'}})){
                 $result .= '<li>'.
                     '<a target="search_preview" '.
-                    'href="/res/'.$item.'">'.$item.'</a></li>';
+                    'href="'.$jumpurl.'">'.$item.'</a></li>';
             }
             $result .= '</ul>';
         } elsif (exists($field->{'format'}) && $field->{'format'} ne ''){
@@ -3304,7 +3306,7 @@
             if ($field->{'special'} eq 'url link') {
                 $result.= 
                      &mt($field->{'translate'},
-                         '<a href="'.$values{'url'}.'" '.
+                         '<a href="'.$jumpurl.'" '.
                          'target="search_preview">'.
                          $values{$field->{'name'}}.
                          '</a>');
@@ -3352,8 +3354,11 @@
         if (! defined($tmp)) { $tmp = 'undefined'; }
         $result .= '&nbsp;'.$tmp.'&nbsp;';
     }
+    my $jumpurl=$values{'url'};
+    $jumpurl=~s/^\/ext\//http\:\/\//;
+
     $result.=<<END;
-<a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
+<a href="$jumpurl" 
    target='search_preview'>$values{'title'}</a><br />
 $values{'author'}, $values{'owner'} -- $values{'lastrevisiondate'}<br />
 $values{'copyrighttag'}<br />
@@ -3377,6 +3382,9 @@
 ######################################################################
 sub compact_view {
     my ($prefix,%values) = @_;
+    my $jumpurl=$values{'url'};
+    $jumpurl=~s/^\/ext\//http\:\/\//;
+
     my $result = 
         $prefix.'<img src="'.&Apache::loncommon::icon($values{'url'}).'">';
     if (exists($env{'form.sortfield'}) && 
@@ -3385,9 +3393,9 @@
         if (! defined($tmp)) { $tmp = 'undefined'; }
         $result .= '&nbsp;'.$tmp.'&nbsp;';
     }
-    $result.='&nbsp;<a href="'.$values{'url'}.'" target="search_preview">'.
+    $result.='&nbsp;<a href="'.$jumpurl.'" target="search_preview">'.
         $values{'title'}.'</a>'.('&nbsp;'x2).
-        '<b>'.$values{'author'}.'</b><br />';
+        '<b>'.$values{'author'}.'</b> ('.$values{'domain'}.')<br />';
     return $result;
 }
 
@@ -3407,11 +3415,14 @@
     my ($prefix,%values) = @_;
     my $icon=&Apache::loncommon::icon($values{'url'});
     my %Translated = &Apache::lonmeta::fieldnames();
+    my $jumpurl=$values{'url'};
+    $jumpurl=~s/^\/ext\//http\:\/\//;
+
     my $result=<<END;
 $prefix <img src="$icon" />
 <dl>
 <dt>URL:</dt>
-    <dd><a href="http://$ENV{'HTTP_HOST'}$values{'url'}" 
+    <dd><a href="$jumpurl" 
          target='search_preview'>$values{'url'}</a></dd>
 END
     foreach my $field ('title','author','domain','subject','keywords','notes',