[LON-CAPA-cvs] cvs: loncom /interface groupsort.pm loncommon.pm londocs.pm lonindexer.pm lonnavmaps.pm

albertel lon-capa-cvs@mail.lon-capa.org
Tue, 30 Dec 2003 20:47:24 -0000


albertel		Tue Dec 30 15:47:24 2003 EDT

  Modified files:              
    /loncom/interface	groupsort.pm loncommon.pm londocs.pm 
                     	lonindexer.pm lonnavmaps.pm 
  Log:
  - was getting broken images on .rights files
  - now all of the icons are genetarted in the same place &Apache::loncommon::icon($file or $url)
  - BUG#2531
  
  
  
Index: loncom/interface/groupsort.pm
diff -u loncom/interface/groupsort.pm:1.24 loncom/interface/groupsort.pm:1.25
--- loncom/interface/groupsort.pm:1.24	Tue Oct  7 16:30:13 2003
+++ loncom/interface/groupsort.pm	Tue Dec 30 15:47:23 2003
@@ -2,7 +2,7 @@
 # The LON-CAPA group sort handler
 # Allows for sorting prior to import into RAT.
 #
-# $Id: groupsort.pm,v 1.24 2003/10/07 20:30:13 matthew Exp $
+# $Id: groupsort.pm,v 1.25 2003/12/30 20:47:23 albertel Exp $
 # 
 # Copyright Michigan State University Board of Trustees
 #
@@ -351,13 +351,7 @@
     foreach (sort {$shash{$a}<=>$shash{$b}} (keys %shash)) {
 	my $key=$_;
 	$ctr++;
-	my @file_ext = split(/\./,$key);
-	my $curfext = $file_ext[scalar(@file_ext)-1];
-	my $iconname="unknown.gif";
-	my $embstyle = &Apache::loncommon::fileembstyle($curfext);
-	# The unless conditional that follows is a bit of overkill
-	$iconname = $curfext.".gif" unless
-	    (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');
+	my $iconname=&Apache::loncommon::icon($key);
 	if ($clen > 1) {
 	    $r->print("<tr><td bgcolor='$fileclr'>");
 	    $r->print(&movers($clen,$ctr));
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.167 loncom/interface/loncommon.pm:1.168
--- loncom/interface/loncommon.pm:1.167	Mon Dec 29 16:17:00 2003
+++ loncom/interface/loncommon.pm	Tue Dec 30 15:47:23 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.167 2003/12/29 21:17:00 www Exp $
+# $Id: loncommon.pm,v 1.168 2003/12/30 20:47:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3284,14 +3284,18 @@
 
 sub icon {
     my ($file)=@_;
-    my @file_ext = split(/\./,$file);
-    my $curfext = $file_ext[-1];
-    my $iconname="unknown.gif";
+    my $curfext = (split(/\./,$file))[-1];
+    my $iconname=$Apache::lonnet::perlvar{'lonIconsURL'}.'/unknown.gif';
     my $embstyle = &Apache::loncommon::fileembstyle($curfext);
-    # The unless conditional that follows is a bit of overkill
-    $iconname = $curfext.".gif" unless
-	(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');
-    return $Apache::lonnet::perlvar{'lonIconsURL'}."/$iconname";
+    if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) {
+	if (-e  $Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
+	          $Apache::lonnet::perlvar{'lonIconsURL'}.'/'.
+	            $curfext.".gif") {
+	    $iconname=$Apache::lonnet::perlvar{'lonIconsURL'}.'/'.
+		$curfext.".gif";
+	}
+    }
+    return $iconname;
 } 
 
 =pod
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.96 loncom/interface/londocs.pm:1.97
--- loncom/interface/londocs.pm:1.96	Tue Dec  9 14:48:51 2003
+++ loncom/interface/londocs.pm	Tue Dec 30 15:47:23 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.96 2003/12/09 19:48:51 sakharuk Exp $
+# $Id: londocs.pm,v 1.97 2003/12/30 20:47:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -425,14 +425,11 @@
 # Figure out what kind of a resource this is
     my ($extension)=($url=~/\.(\w+)$/);
     my $uploaded=($url=~/^\/*uploaded\//);
-    my $icon='unknown';
-    if (-e "/home/httpd/html/adm/lonIcons/$extension.gif") {
-	$icon=$extension;
-    }
+    my $icon=&Apache::loncommon::icon($url);
     my $isfolder=0;
     if ($uploaded) {
        if ($extension eq 'sequence') {
-	  $icon='folder_closed';
+	  $icon=$iconpath.'/folder_closed.gif';
           $url=~/\/(\w+)\.sequence/;
           $url='/adm/coursedocs?folder='.$1;
           $isfolder=1;
@@ -454,8 +451,7 @@
     if ($isfolder) { $url.='&foldername='.
        &Apache::lonnet::escape($foldertitle); }
     $line.='<td bgcolor="#FFFFBB"><a href="'.$url.'" target="cat_'.$folder.
-'"><img src="/adm/lonIcons/'.
-        $icon.'.gif" border="0"></a></td>'.
+	'"><img src="'.$icon.'" border="0"></a></td>'.
         "<td bgcolor='#FFFFBB'><a href='$url' target='cat_$folder'>$title</a></td></tr>";
     return $line;
 }
Index: loncom/interface/lonindexer.pm
diff -u loncom/interface/lonindexer.pm:1.83 loncom/interface/lonindexer.pm:1.84
--- loncom/interface/lonindexer.pm:1.83	Mon Dec 22 14:30:25 2003
+++ loncom/interface/lonindexer.pm	Tue Dec 30 15:47:23 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Directory Indexer
 #
-# $Id: lonindexer.pm,v 1.83 2003/12/22 19:30:25 www Exp $
+# $Id: lonindexer.pm,v 1.84 2003/12/30 20:47:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -793,12 +793,7 @@
             return OK if ($skip > 0);
         }
 	# Set the icon for the file
-	my $iconname = "unknown.gif";
-	my $embstyle = &Apache::loncommon::fileembstyle($curfext);
-	# The unless conditional that follows is a bit of overkill
-	$iconname = $curfext.".gif" unless
-	    (!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn');
-	#
+	my $iconname = &Apache::loncommon::icon($listname);
 	$r->print("<tr valign='$valign' bgcolor=$fileclr><td nowrap>");
 	my $metafile = grep /^\Q$filecom[0]\E\.meta\&/, @list;
 	my $title;
@@ -854,7 +849,7 @@
 		      ".gif border='0' />\n") if $rem > 0;
 	}
 
-	$r->print("<img src=$iconpath$iconname border='0' />\n");
+	$r->print("<img src='$iconname' border='0' />\n");
 	$r->print (" <a href=\"javascript:openWindow('".$filelink.
 		   "', 'previewfile', '450', '500', 'no', 'yes','yes')\";".
 		   " TARGET=_self>$listname</a> ");
@@ -930,8 +925,6 @@
 
 # -- display directory
     if ($fnptr == $dirptr) {
-	my @file_ext = split (/\./,$listname);
-	my $curfext = $file_ext[scalar(@file_ext)-1];
 	my $curdir = $startdir.$filecom[0].'/';
 	my $anchor = $curdir;
 	$anchor =~ s/\///g;
Index: loncom/interface/lonnavmaps.pm
diff -u loncom/interface/lonnavmaps.pm:1.242 loncom/interface/lonnavmaps.pm:1.243
--- loncom/interface/lonnavmaps.pm:1.242	Mon Dec  1 09:38:25 2003
+++ loncom/interface/lonnavmaps.pm	Tue Dec 30 15:47:23 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Navigate Maps Handler
 #
-# $Id: lonnavmaps.pm,v 1.242 2003/12/01 14:38:25 matthew Exp $
+# $Id: lonnavmaps.pm,v 1.243 2003/12/30 20:47:23 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -895,12 +895,8 @@
             $icon = $params->{'indentString'};
         }
     } else {
-	my $curfext= (split (/\./,$resource->src))[-1];
-	my $embstyle = &Apache::loncommon::fileembstyle($curfext);
-	# The unless conditional that follows is a bit of overkill
-	if (!(!defined($embstyle) || $embstyle eq 'unk' || $embstyle eq 'hdn')) {
-	    $icon = "<img src='/adm/lonIcons/$curfext.gif' alt='' border='0' />";
-	}
+	$icon = "<img src='".&Apache::loncommon::icon($resource->src).
+	    "' alt='' border='0' />";
     }
 
     # Display the correct map icon to open or shut map