[LON-CAPA-cvs] cvs: rat / lonratedt.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Wed, 23 Mar 2005 22:54:18 -0000


raeburn		Wed Mar 23 17:54:18 2005 EDT

  Modified files:              
    /rat	lonratedt.pm 
  Log:
  Modify &viewmap() so that links to resources in a map point to resources in RES and also in CSTR.  Designed to facilitate browsing of courses imported from IMS packages, which generate maps containing unpublished resources.
  
  
Index: rat/lonratedt.pm
diff -u rat/lonratedt.pm:1.63 rat/lonratedt.pm:1.64
--- rat/lonratedt.pm:1.63	Wed Nov 17 15:14:23 2004
+++ rat/lonratedt.pm	Wed Mar 23 17:54:18 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Edit Handler for RAT Maps
 #
-# $Id: lonratedt.pm,v 1.63 2004/11/17 20:14:23 raeburn Exp $
+# $Id: lonratedt.pm,v 1.64 2005/03/23 22:54:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1149,6 +1149,14 @@
     if ($adv) {
 	$r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');
     }
+    $r->print( '<table border="0" cellspacing="2" cellpadding="4">'.
+               '<tr bgcolor="#DDDDDD"><th>'.&mt('Type').'</th>'.
+               '<th>'.&mt('Title in map').'</th>'.
+               '<th>'.&mt('Filename of resource').'</th>'.
+               '<th>'.&mt('Link to published resource').'</th>'.
+               '<th>'.&mt('Link to resource in Construction Space').'</th>'.
+               '</tr>');
+    my @backgroundColors = ("#FFFFFF", "#F6F6F6");
     foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
 	if (defined($_)) {
             $idx++;
@@ -1157,15 +1165,36 @@
             $title=~s/\&colon\;/\:/g;
             $url=~s/\&colon\;/\:/g;
             unless ($title) { $title=(split(/\//,$url))[-1] };
-            unless ($title) { $title='<i>Empty</i>'; }
+            unless ($title) { $title='<i>'.&mt('Empty').'</i>'; }
+            my $resurl = &Apache::lonratsrv::qtescape($url);
+            my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl;
+            my $filename; 
+            if ($resurl =~ m#/([^/]+)$#) {
+                $filename = $1;
+            }
+            my $cstrurl = $resurl;
+            $cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#;
+            my $bgcol = $idx%2; 
+            $r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'.
+                      '<img src="'.&Apache::loncommon::icon($resfilepath).
+                      '" /></td><td>'.&Apache::lonratsrv::qtescape($title).
+                      '</td><td>'.$filename.'</td><td>');
+            if ($url) {
+                if (-e $resfilepath) {
+		    $r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>');
+                } else {
+                    $r->print(&mt('unpublished'));
+                }
+            }
+            $r->print('</td><td>');
             if ($url) {
-		$r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');
+               $r->print('<a href="'.$cstrurl.'">'.
+                         &mt('Construction space').'</a>');
             }
-            $r->print(&Apache::lonratsrv::qtescape($title));
-            if ($url) { $r->print('</a>'); }
-	    $r->print("<br />\n");
+            $r->print('</td></tr>'."\n");
         }
     }
+    $r->print('</table>');
     $r->print('</body></html>');
 }