[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 27 Aug 2004 21:09:22 -0000


albertel		Fri Aug 27 17:09:22 2004 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - gettitle returns the filename now if it can't get a title from anywhere else
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.533 loncom/lonnet/perl/lonnet.pm:1.534
--- loncom/lonnet/perl/lonnet.pm:1.533	Fri Aug 27 14:37:03 2004
+++ loncom/lonnet/perl/lonnet.pm	Fri Aug 27 17:09:22 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.533 2004/08/27 18:37:03 banghart Exp $
+# $Id: lonnet.pm,v 1.534 2004/08/27 21:09:22 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4439,27 +4439,27 @@
 sub gettitle {
     my $urlsymb=shift;
     my $symb=&symbread($urlsymb);
-    unless ($symb) {
-	unless ($urlsymb) { $urlsymb=$ENV{'request.filename'}; }
-        return &metadata($urlsymb,'title'); 
-    }
-    my ($result,$cached)=&is_cached(\%titlecache,$symb,'title',600);
-    if (defined($cached)) { return $result; }
-    my ($map,$resid,$url)=&decode_symb($symb);
-    my $title='';
-    my %bighash;
-    if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
-                            &GDBM_READER(),0640)) {
-        my $mapid=$bighash{'map_pc_'.&clutter($map)};
-        $title=$bighash{'title_'.$mapid.'.'.$resid};
-        untie %bighash;
-    }
-    $title=~s/\&colon\;/\:/gs;
-    if ($title) {
-        return &do_cache(\%titlecache,$symb,$title,'title');
-    } else {
-	return &metadata($urlsymb,'title');
-    }
+    if ($symb) {
+	my ($result,$cached)=&is_cached(\%titlecache,$symb,'title',600);
+	if (defined($cached)) { return $result; }
+	my ($map,$resid,$url)=&decode_symb($symb);
+	my $title='';
+	my %bighash;
+	if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db',
+		&GDBM_READER(),0640)) {
+	    my $mapid=$bighash{'map_pc_'.&clutter($map)};
+	    $title=$bighash{'title_'.$mapid.'.'.$resid};
+	    untie %bighash;
+	}
+	$title=~s/\&colon\;/\:/gs;
+	if ($title) {
+	    return &do_cache(\%titlecache,$symb,$title,'title');
+	}
+	$urlsymb=$url;
+    }
+    my $title=&metadata($urlsymb,'title');
+    if (!$title) { $title=(split('/',$urlsymb))[-1]; }    
+    return $title;
 }
     
 # ------------------------------------------------- Update symbolic store links