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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 19 Dec 2005 21:49:12 -0000


albertel		Mon Dec 19 16:49:12 2005 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  - add a navigational method out of the metadata editor
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.145 loncom/interface/lonmeta.pm:1.146
--- loncom/interface/lonmeta.pm:1.145	Mon Dec 19 16:33:54 2005
+++ loncom/interface/lonmeta.pm	Mon Dec 19 16:49:12 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.145 2005/12/19 21:33:54 albertel Exp $
+# $Id: lonmeta.pm,v 1.146 2005/12/19 21:49:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -290,8 +290,21 @@
     return &Apache::lonlocal::texthash(%fields);
 }
 
+sub portfolio_linked_path {
+    my ($path) = @_;
+    my $result = &Apache::portfolio::make_anchor('portfolio','/');
+    my $fullpath = '/';
+    my (undef,@tree) = split('/',$path);
+    foreach my $dir (@tree) {
+	$fullpath .= $dir.'/';
+	$result .= '/';
+	$result .= &Apache::portfolio::make_anchor($dir,$fullpath);
+    }
+    return $result;
+}
+
 sub portfolio_display_uri {
-    my ($uri)=@_;
+    my ($uri,$as_links)=@_;
     $uri =~ s|.*/(portfolio/.*)$|$1|;
     my ($res_uri,$meta_uri) = ($uri,$uri);
 
@@ -300,9 +313,13 @@
     } else {
 	$meta_uri .= '.meta';
     }
-    
+
     my ($path) = ($res_uri =~ m|(.*)/[^/]*$|);
-    
+
+    if ($as_links) {
+	$res_uri = &portfolio_linked_path($res_uri);
+	$meta_uri = &portfolio_linked_path($meta_uri);
+    }
     return ($res_uri,$meta_uri,$path);
 }
 
@@ -337,7 +354,7 @@
     my %courses;
     my $output;
     my $selected;
-    foreach my $key (keys (%env)) { 
+    foreach my $key (keys(%env)) { 
         if ($key =~ m/\.metadata\./) {
             $key =~ m/^course\.(.+)(\.metadata.+$)/;
             my $course = $1;
@@ -346,7 +363,6 @@
             $courses{$coursekey} = $value;
         }
     }
-    &Apache::lonnet::logthis('the restricted is'.$Apache::lonpublisher::metadatafields{'courserestricted'});
     my $meta_not_found = 1;
     if ($Apache::lonpublisher::metadatafields{'courserestricted'} eq 'none') {
         $selected = ' SELECTED ';
@@ -1054,7 +1070,7 @@
     $disuri=~s/\.meta$//;
     my $meta_uri = $disuri;
     if ($disuri =~ m|/portfolio/|) {
-	($disuri, $meta_uri) =  &portfolio_display_uri($disuri);
+	($disuri, $meta_uri) =  &portfolio_display_uri($disuri,1);
     }
     my $target=$uri;
     $target=~s/^\/\~/\/res\/$env{'request.role.domain'}\//;
@@ -1208,7 +1224,6 @@
 		     '<>&"').
 		     '</'.$tag.'>';
 	    }
-	    &Apache::lonnet::logthis(" file ".$file_content);
 	    if ($fn =~ m|/portfolio/|) {
 		my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|);
 		$env{'form.'.$formname}=$file_content."\n";