--- loncom/interface/lonmeta.pm 2006/08/08 19:35:53 1.165 +++ loncom/interface/lonmeta.pm 2006/08/16 18:02:01 1.169 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.165 2006/08/08 19:35:53 banghart Exp $ +# $Id: lonmeta.pm,v 1.169 2006/08/16 18:02:01 banghart Exp $ # # Copyright Michigan State University Board of Trustees # @@ -287,8 +287,7 @@ sub portfolio_linked_path { if ($group) { $start = "groups/$group/".$start; } - my %anchor_fields; - %anchor_fields = ( + my %anchor_fields = ( 'selectfile' => $start, 'currentpath' => '/' ); @@ -299,8 +298,7 @@ sub portfolio_linked_path { foreach my $dir (@tree) { $fullpath .= $dir.'/'; $result .= '/'; - my %anchor_fields = (); - %anchor_fields = ( + my %anchor_fields = ( 'selectfile' => $dir, 'currentpath' => $fullpath ); @@ -367,14 +365,20 @@ sub pre_select_course { $r->print('<p>'.&mt('If you would like to associate this resource ([_1]) with a current or previous course, please select one from the list below, otherwise select, \'None\'','<tt>'.$res_uri.'</tt>').'</p>'); $output = &select_course(); $r->print($output.'<br /><input type="submit" name="store" value="'. - &mt('Associate Resource With Selected Course').'">'); + &mt('Associate Resource With Selected Course').'" />'); + $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />'); + $r->print('<input type="hidden" name="associate" value="true" />'); $r->print('</form>'); my ($port_path,$group) = &get_port_path_and_group($uri); - $r->print('<br /><br /><form method="POST" action="'.$port_path.'">'. + my $group_input; + if ($group) { + $group_input = '<input type="hidden" name="group" value="'.$group.'" />'; + } + $r->print('<br /><br /><form method="post" action="'.$port_path.'">'. '<input type="hidden" name="currentpath" value="'.$path.'" />'. - '<input type="hidden" name="group" value="'.$group.'" />'. - '<input type="submit" name="cancel" value="'.&mt('Cancel').'">'. + $group_input. + '<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'. '</form>'); return; @@ -716,6 +720,8 @@ sub prettyinput { sub handler { my $r=shift; # + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['currentpath']); my $uri=$r->uri; # # Set document type @@ -1141,7 +1147,7 @@ sub present_editable_metadata { my $goback=&mt('Back to Source File'); $r->print(<<ENDBOMBS); <h1>$disuri</h1> -<form method="post" name="defaultmeta"> +<form method="post" action="" name="defaultmeta"> ENDBOMBS if ($showdel) { $r->print(<<ENDDEL); @@ -1171,9 +1177,9 @@ ENDDEL } $r->print(<<ENDEDIT); <h1>$displayfile</h1> -<form method="post" name="defaultmeta"> +<form method="post" action="" name="defaultmeta"> ENDEDIT - $r->print('<script language="JavaScript">'. + $r->print('<script type="JavaScript">'. &Apache::loncommon::browser_and_searcher_javascript(). '</script>'); my %lt=&fieldnames($file_type); @@ -1280,10 +1286,18 @@ ENDEDIT if ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/portfolio/|) { my ($path, $new_fn) = ($fn =~ m|/(portfolio.*)/([^/]*)$|); $r->print(&store_portfolio_metadata($formname,$file_content,$path, - $new_fn)); + $new_fn)); + unless ($env{'form.associate'}) { + $r->print(&Apache::portfolio::done("return",'/adm/portfolio')); + return; + } } elsif ($fn =~ m|^$Apache::lonnet::perlvar{'lonDocRoot'}/userfiles/groups/\w+/portfolio/|) { my ($path, $new_fn) = ($fn =~ m|/(groups/\w+/portfolio.*)/([^/]*)$|); $r->print(&store_portfolio_metadata($formname,$file_content,$path,$new_fn)); + unless ($env{'form.associate'}) { + $r->print(&Apache::portfolio::done("return",'/adm/portfolio')); + return; + } } else { if (! ($mfh=Apache::File->new('>'.$fn))) { $r->print('<p><font color="red">'. @@ -1295,22 +1309,27 @@ ENDEDIT ' '.&Apache::lonlocal::locallocaltime(time). '</font></p>'); } + unless ($env{'form.associate'}) { + $r->print(&Apache::portfolio::done("return",'/adm/portfolio')); + return; + } } } $r->print($output.'<br /><input type="submit" name="store" value="'. - &mt('Store Catalog Information').'">'); + &mt('Store Catalog Information').'" />'); if ($file_type eq 'portfolio') { my ($port_path,$group) = &get_port_path_and_group($uri); if ($group) { $r->print('<input type="hidden" name="group" value="'.$group.'" />'); } + $r->print('<input type="hidden" name="currentpath" value="'.$env{'form.currentpath'}.'" />'); $r->print('</form> - <br /><br /><form method="POST" action="'.$port_path.'">'. + <br /><br /><form method="post" action="'.$port_path.'">'. '<input type="hidden" name="group" value="'.$group.'" />'. '<input type="hidden" name="currentpath" value="'.$path.'" />'. - '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'">'); + '<input type="submit" name="cancel" value="'.&mt('Discard Edits and Return to Portfolio').'" />'); } }