[LON-CAPA-cvs] cvs: modules /gerd/harvesting recommender.pl

www www at source.lon-capa.org
Sat Oct 8 14:25:32 EDT 2011


www		Sat Oct  8 18:25:32 2011 EDT

  Modified files:              
    /modules/gerd/harvesting	recommender.pl 
  Log:
  Browsing
  
  
Index: modules/gerd/harvesting/recommender.pl
diff -u modules/gerd/harvesting/recommender.pl:1.2 modules/gerd/harvesting/recommender.pl:1.3
--- modules/gerd/harvesting/recommender.pl:1.2	Fri Oct  7 01:52:50 2011
+++ modules/gerd/harvesting/recommender.pl	Sat Oct  8 18:25:32 2011
@@ -161,7 +161,7 @@
    print("\n<h3>Current Basket</h3>\n");
    my %baskettaxos=();
    foreach my $key (sort(keys(%basket))) {
-      &outputlink($key,'edit');
+      &outputlink($url[$key],'edit',$key);
       $baskettaxos{$taxo[$key]}++;
    }
 
@@ -202,32 +202,47 @@
       }
       for (my $i=0; $i<=20; $i++) {
          if ($results[$i]) {
-            &outputlink($results[$i],'view');
+            &outputlink($url[$results[$i]],'view',$i);
          }
       }
    }
+# Browse
+   if ($env{'form.browse'}) {
+      print("<h3>Browse</h3>");
+      my %results=();
+      for (my $i=0;$i<=$#url;$i++) {
+         if ($url[$i]=~/^\Q$env{'form.browse'}\E([^\/]+)(\/*)/) {
+            $results{$env{'form.browse'}.$1.$2}=$i;
+         }
+      }
+      foreach my $path (sort(keys(%results))) {
+         &outputlink($path,'view',$results{$path});
+      }
+   }
 }
 print("</body></html>");
 exit;
 
 sub outputlink {
-   my ($i,$mode)=@_;
-   my (@parts)=split(/\//,$url[$i]);
+   my ($path,$mode,$i)=@_;
+   my $dirflag=($path=~/\/$/);
+   my (@parts)=split(/\//,$path);
    my $build='/';
    print("<br /><tt>");
-   for (my $j=1;$j<=$#parts-1;$j++) {
+   for (my $j=1;$j<=$#parts-($dirflag?0:1);$j++) {
        $build.=$parts[$j].'/';
        print("/<a href='/cgi-bin/recommender.pl?browse=".&escape($build)."' target='_top'>$parts[$j]</a>");
    }
    print("</tt>");
-   print("/<a href='/cgi-bin/recommender.pl?preview=".$url[$i]."' target='_top'>$parts[-1]</a>");
-   if ($mode eq 'view') {
-      print("&nbsp<a href='/cgi-bin/recommender.pl?add=$i'>Add</a>");
-   }
-   if ($mode eq 'edit') {
-      print("&nbsp<a href='/cgi-bin/recommender.pl?del=$i'>Remove</a>");
+   unless ($dirflag) {
+      print("/<a href='/cgi-bin/recommender.pl?preview=".&escape($path)."' target='_top'>$parts[-1]</a>");
+      if ($mode eq 'view') {
+         print("&nbsp<a href='/cgi-bin/recommender.pl?add=$i'>Add</a>");
+      }
+      if ($mode eq 'edit') {
+         print("&nbsp<a href='/cgi-bin/recommender.pl?del=$i'>Remove</a>");
+      }
    }
-
 } 
 
 sub taxolink {




More information about the LON-CAPA-cvs mailing list