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

www lon-capa-cvs@mail.lon-capa.org
Wed, 16 Oct 2002 19:15:55 -0000


www		Wed Oct 16 15:15:55 2002 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
  Log:
  Can now recursively check.
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.28 loncom/interface/londocs.pm:1.29
--- loncom/interface/londocs.pm:1.28	Wed Oct 16 14:48:12 2002
+++ loncom/interface/londocs.pm	Wed Oct 16 15:15:55 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.28 2002/10/16 18:48:12 www Exp $
+# $Id: londocs.pm,v 1.29 2002/10/16 19:15:55 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -42,6 +42,7 @@
 my %hash;
 
 my $hashtied;
+my %alreadyseen=();
 
 # Mapread read maps into lonratedt::global arrays 
 # @order and @resources, determines status
@@ -240,6 +241,43 @@
     $hashtied=0;
 }
 
+# --------------------------------------------------------------- check on this
+
+sub checkonthis {
+    my ($r,$url,$level,$title)=@_;
+    $alreadyseen{$url}=1;
+    $r->rflush();
+    if ($url) {
+       $r->print('<br />');
+       for (my $i=0;$i<=$level*5;$i++) {
+           $r->print('&nbsp;');
+       }
+       $r->print('<a href="'.$url.'" target="cat">'.
+		 ($title?$title:$url).'</a> ');
+       if ($url=~/^\/res\//) {
+	  my $result=&Apache::lonnet::repcopy(
+                              &Apache::lonnet::filelocation('',$url));
+          if ($result==OK) {
+             $r->print('<font color="green">ok</font>');
+             $r->rflush();
+	     my $dependencies=
+                &Apache::lonnet::metadata($url,'dependencies');
+             foreach (split(/\,/,$dependencies)) {
+		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
+                    &checkonthis($r,$_,$level+1);
+                 }
+             }
+          } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
+             $r->print('<font color="red"><b>connection down</b></font>');
+          } elsif ($result==HTTP_NOT_FOUND) {
+             $r->print('<font color="red"><b>not found</b></font>');
+          } else {
+             $r->print('<font color="red"><b>access denied</b></font>');
+          }
+      }
+   }
+}
+
 # ================================================================ Main Handler
 sub handler {
     my $r = shift;
@@ -256,37 +294,10 @@
    $r->print('<html><head><title>Verify Content</title></head>'.
               &Apache::loncommon::bodytag('Verify Course Documents'));
    $hashtied=0;
-   my %alreadyseen=();
    &tiehash();
    foreach (keys %hash) {
        if (($_=~/^src\_(.+)$/) && (!$alreadyseen{$hash{$_}})) {
-           $alreadyseen{$hash{$_}}=1;
-           my $resid=$1;
-           $r->rflush();
-	   if ($hash{$_}) {
-               my $fn=$hash{$_};
-               $r->print('<br /><a href="'.$fn.'" target="cat">'.
-		 ($hash{'title_'.$resid}?$hash{'title_'.$resid}:$fn).'</a> ');
- 	       if ($fn=~/^\/res\//) {
-		   my $result=&Apache::lonnet::repcopy(
-                              &Apache::lonnet::filelocation('',$fn));
-                   if ($result==OK) {
-                       $r->print('<font color="green">ok</font>');
-                       $r->rflush();
-		       my $dependencies=
-                          &Apache::lonnet::metadata($hash{$_},'dependencies');
-                       $r->print('Dependencies: '.$dependencies.'<br />');
-                   } elsif ($result==HTTP_SERVICE_UNAVAILABLE) {
-                       $r->print(
-                         '<font color="red"><b>connection down</b></font>');
-                   } elsif ($result==HTTP_NOT_FOUND) {
-                       $r->print('<font color="red"><b>not found</b></font>');
-                   } else {
-                       $r->print(
-                             '<font color="red"><b>access denied</b></font>');
-                   }
-               }
-           }
+           &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
        }
    }
    &untiehash();