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

raeburn raeburn at source.lon-capa.org
Tue Nov 19 23:48:19 EST 2013


raeburn		Wed Nov 20 04:48:19 2013 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	londocs.pm 
  Log:
  - For 2.11
    - Backport 1.567, 1.568, 1.569, 1.570.
  
  
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.42 loncom/interface/londocs.pm:1.484.2.43
--- loncom/interface/londocs.pm:1.484.2.42	Wed Oct 16 20:32:49 2013
+++ loncom/interface/londocs.pm	Wed Nov 20 04:48:18 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.484.2.42 2013/10/16 20:32:49 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.43 2013/11/20 04:48:18 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,6 +41,8 @@
 use Apache::lonnavmaps;
 use Apache::lonnavdisplay();
 use Apache::lonextresedit();
+use Apache::lontemplate();
+use Apache::lonsimplepage();
 use HTML::Entities;
 use HTML::TokeParser;
 use GDBM_File;
@@ -141,8 +143,28 @@
 sub dumpcourse {
     my ($r) = @_;
     my $crstype = &Apache::loncommon::course_type();
-    $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' Content to Authoring Space')."\n".
-              &Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' Content to Authoring Space')."\n");
+    my ($starthash,$js);
+    unless (($env{'form.authorspace'}) && ($env{'form.authorfolder'}=~/\w/)) {
+        $js = <<"ENDJS";
+<script type="text/javascript">
+// <![CDATA[
+
+function hide_searching() {
+    if (document.getElementById('searching')) {
+        document.getElementById('searching').style.display = 'none';
+    }
+    return;
+}
+
+// ]]>
+</script>
+ENDJS
+        $starthash = {
+                         add_entries => {'onload' => "hide_searching();"},
+                     };
+    }
+    $r->print(&Apache::loncommon::start_page('Copy '.$crstype.' Content to Authoring Space',$js,$starthash)."\n".
+              &Apache::lonhtmlcommon::breadcrumbs('Copy '.$crstype.' Content to Authoring Space')."\n");
     $r->print(&startContentScreen('tools'));
     my ($home,$other,%outhash)=&authorhosts();
     unless ($home) {
@@ -161,118 +183,407 @@
 	$r->print('<h3>'.&mt('Copying Files').'</h3>');
 	my $title=$env{'form.authorfolder'};
 	$title=&clean($title);
-	my %replacehash=();
-	foreach my $key (keys(%env)) {
-	    if ($key=~/^form\.namefor\_(.+)/) {
-		$replacehash{$1}=$env{$key};
-	    }
-	}
+        my ($navmap,$errormsg) =
+            &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
+        my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+        my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        my (%maps,%resources,%titles);
+        if (!ref($navmap)) {
+            $r->print($errormsg.
+                      &endContentScreen());
+            return '';
+        } else {
+            &Apache::loncourserespicker::enumerate_course_contents($navmap,\%maps,\%resources,\%titles,
+                                                                   'dumpdocs',$cdom,$cnum);
+        }
+        my @todump = &Apache::loncommon::get_env_multiple('form.archive');
+        my (%tocopy,%replacehash,%lookup,%deps,%display,%result,%depresult,%simpleproblems,%simplepages,
+            %newcontent,%has_simpleprobs);
+        foreach my $item (sort {$a <=> $b} (@todump)) {
+            my $name = $env{'form.namefor_'.$item};
+            if ($resources{$item}) {
+                my ($map,$id,$res) = &Apache::lonnet::decode_symb($resources{$item});
+                if ($res =~ m{^uploaded/$cdom/$cnum/\E((?:docs|supplemental)/.+)$}) {
+                    $tocopy{$1} = $name;
+                    $display{$item} = $1;
+                    $lookup{$1} = $item;
+                } elsif ($res eq 'lib/templates/simpleproblem.problem') {
+                    $simpleproblems{$item} = {
+                                                symb => $resources{$item},
+                                                name => $name,
+                                             };
+                    $display{$item} = 'simpleproblem_'.$name;
+                    if ($map =~ m{^\Quploaded/$cdom/$cnum/\E(.+)$}) {
+                        $has_simpleprobs{$1}{$id} = $item;
+                    }
+                } elsif ($res =~ m{^adm/$match_domain/$match_username/(\d+)/smppg}) {
+                    my $marker = $1;
+                    my $db_name = &Apache::lonsimplepage::get_db_name($res,$marker,$cdom,$cnum);
+                    $simplepages{$item} = {
+                                            res    => $res,
+                                            title  => $titles{$item},
+                                            db     => $db_name,
+                                            marker => $marker,
+                                            symb   => $resources{$item},
+                                            name   => $name,
+                                          };
+                    $display{$item} = '/'.$res;
+                }
+            } elsif ($maps{$item}) {
+                if ($maps{$item} =~ m{^\Quploaded/$cdom/$cnum/\E((?:default|supplemental)_\d+\.(?:sequence|page))$}) {
+                    $tocopy{$1} = $name;
+                    $display{$item} = $1;
+                    $lookup{$1} = $item;
+                }
+            } else {
+                next;
+            }
+        }
 	my $crs='/uploaded/'.$env{'request.course.id'}.'/';
 	$crs=~s/\_/\//g;
-	foreach my $item (keys(%replacehash)) {
-	    my $newfilename=$title.'/'.$replacehash{$item};
-	    $newfilename=~s/\.(\w+)$//;
-	    my $ext=$1;
-	    $newfilename=&clean($newfilename);
-	    $newfilename.='.'.$ext;
-	    my @dirs=split(/\//,$newfilename);
-	    my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
-	    my $makepath=$path;
-	    my $fail=0;
-	    for (my $i=0;$i<$#dirs;$i++) {
-		$makepath.='/'.$dirs[$i];
-		unless (-e $makepath) {
-		    unless(mkdir($makepath,0777)) { $fail=1; }
-		}
-	    }
-	    $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
-	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
-		if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
-		    print $fh &Apache::lonclonecourse::rewritefile(
-         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
-				     (%replacehash,$crs => '')
-								    );
-		} else {
-		    print $fh
-         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
-		       }
-		$fh->close();
-	    } else {
-		$fail=1;
-	    }
-	    if ($fail) {
-		$r->print('<span class="LC_error">'.&mt('fail').'</span>');
-	    } else {
-		$r->print('<span class="LC_success">'.&mt('ok').'</span>');
-	    }
-	}
+        my $mm = new File::MMagic;
+        my $prefix = "/uploaded/$cdom/$cnum/";
+        %replacehash = %tocopy;
+        foreach my $item (sort(keys(%simpleproblems))) {
+            my $content = &Apache::imsexport::simpleproblem($simpleproblems{$item}{'symb'});
+            $newcontent{$display{$item}} = $content;
+        }
+        my $gateway = Apache::lonhtmlgateway->new('web');
+        foreach my $item (sort(keys(%simplepages))) {
+            if (ref($simplepages{$item}) eq 'HASH') {
+                my $pagetitle = $simplepages{$item}{'title'};
+                my %fields = &Apache::lonnet::dump($simplepages{$item}{'db'},$cdom,$cnum);
+                my %contents;
+                foreach my $field (keys(%fields)) {
+                    if ($field =~ /^(?:aaa|bbb|ccc)_(\w+)$/) {
+                        my $name = $1;
+                        my $msg = $fields{$field};
+                        if ($name eq 'webreferences') {
+                            if ($msg =~ m{^https?://}) {
+                                $contents{$name} = '<a href="'.$msg.'"><tt>'.$msg.'</tt></a>';
+                            }
+                        } else {
+                            $msg = &Encode::decode('utf8',$msg);
+                            $msg = $gateway->process_outgoing_html($msg,1);
+                            $contents{$name} = $msg;
+                        }
+                    } elsif ($field eq 'uploaded.photourl') {
+                        my $marker = $simplepages{$item}{marker};
+                        if ($fields{$field} =~ m{^\Q$prefix\E(simplepage/$marker/.+)$}) {
+                            my $filepath = $1;
+                            my ($relpath,$fname) = ($filepath =~ m{^(.+/)([^/]+)$});
+                            if ($fname ne '') {
+                                $fname=~s/\.(\w+)$//;
+                                my $ext=$1;
+                                $fname = &clean($fname);
+                                $fname.='.'.$ext;
+                                $contents{image} = '<img src="'.$relpath.$fname.'" alt="Image" />';
+                                $replacehash{$filepath} = $relpath.$fname;
+                                $deps{$item}{$filepath} = 1;
+                            }
+                        }
+                    }
+                }
+                $replacehash{'/'.$simplepages{$item}{'res'}} = $simplepages{$item}{'name'};
+                $lookup{'/'.$simplepages{$item}{'res'}} = $item;
+                my $content = '
+<html>
+<head>
+<title>'.$pagetitle.'</title>
+</head>
+<body bgcolor="#ffffff">';
+                if ($contents{title}) {
+                    $content .= "\n".'<h2>'.$contents{title}.'</h2>';
+                }
+                if ($contents{image}) {
+                    $content .= "\n".$contents{image};
+                }
+                if ($contents{content}) {
+                    $content .= '
+<div class="LC_Box">
+<h4 class="LC_hcell">Content</h4>'.
+$contents{content}.'
+</div>';
+                }
+                if ($contents{webreferences}) {
+                    $content .= '
+<div class="LC_Box">
+<h4 class="LC_hcell">Web References</h4>'.
+$contents{webreferences}.'
+</div>';
+                }
+                $content .= '
+</body>
+</html>
+';
+                $newcontent{'/'.$simplepages{$item}{res}} = $content;
+            }
+        }
+        foreach my $item (keys(%tocopy)) {
+            unless ($item=~/\.(sequence|page)$/) {
+                my $currurlpath = $prefix.$item;
+                my $currdirpath = &Apache::lonnet::filelocation('',$currurlpath);
+                &recurse_html($mm,$prefix,$currdirpath,$currurlpath,$item,$lookup{$item},\%replacehash,\%deps);
+            }
+        }
+        foreach my $num (sort {$a <=> $b} (@todump)) {
+            my $src = $display{$num};
+            next if ($src eq '');
+            my @needcopy = ();
+            if ($replacehash{$src}) {
+                push(@needcopy,$src);
+                if (ref($deps{$num}) eq 'HASH') {
+                    foreach my $dep (sort(keys(%{$deps{$num}}))) {
+                        if ($replacehash{$dep}) {
+                            push(@needcopy,$dep);
+                        }
+                    }
+                }
+            } elsif ($src =~ /^simpleproblem_/) {
+                push(@needcopy,$src);
+            }
+            next if (@needcopy == 0);
+            my ($result,$depresult);
+            for (my $i=0; $i<@needcopy; $i++) {
+                my $item = $needcopy[$i];
+                my $newfilename;
+                if ($simpleproblems{$num}) {
+                    $newfilename=$title.'/'.$simpleproblems{$num}{'name'};
+                } else {
+                    $newfilename=$title.'/'.$replacehash{$item};
+                }
+                $newfilename=~s/\.(\w+)$//;
+               my $ext=$1;
+                $newfilename=&clean($newfilename);
+                $newfilename.='.'.$ext;
+                my ($newrelpath) = ($newfilename =~ m{^\Q$title/\E(.+)$});
+                if ($newrelpath ne $replacehash{$item}) {
+                    $replacehash{$item} = $newrelpath;
+                }
+                my @dirs=split(/\//,$newfilename);
+                my $path=$r->dir_config('lonDocRoot')."/priv/$cd/$ca";
+                my $makepath=$path;
+                my $fail;
+                my $origin;
+                for (my $i=0;$i<$#dirs;$i++) {
+                    $makepath.='/'.$dirs[$i];
+                    unless (-e $makepath) {
+                        unless(mkdir($makepath,0755)) {
+                            $fail = &mt('Directory creation failed.');
+                        }
+                    }
+                }
+                if ($i == 0) {
+                    $result = '<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ';
+                } else {
+                    $depresult .= '<li><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt> '.
+                                  '<span class="LC_fontsize_small" style="font-weight: bold;">'.
+                                  &mt('(dependency)').'</span>: ';
+                }
+                if (-e $path.'/'.$newfilename) {
+                    $fail = &mt('Destination already exists -- not overwriting.');
+                } else {
+                    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
+                        if (($item =~ m{^/adm/$match_domain/$match_username/\d+/smppg}) ||
+                            ($item =~ /^simpleproblem_/)) {
+                            print $fh $newcontent{$item};
+                        } else {
+                            my $fileloc = &Apache::lonnet::filelocation('',$prefix.$item);
+                            if (-e $fileloc) {
+                                if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
+                                    if ((($1 eq 'sequence') || ($1 eq 'page')) &&
+                                        (ref($has_simpleprobs{$item}) eq 'HASH')) {
+                                        my %changes = %{$has_simpleprobs{$item}};
+                                        my $content = &Apache::lonclonecourse::rewritefile(
+                     &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
+                                                      (%replacehash,$crs => '')
+                                                                                          );
+                                        my $updatedcontent = '';
+                                        my $parser = HTML::TokeParser->new(\$content);
+                                        $parser->attr_encoded(1);
+                                        while (my $token = $parser->get_token) {
+                                            if ($token->[0] eq 'S') {
+                                                if (($token->[1] eq 'resource') &&
+                                                    ($token->[2]->{'src'} eq '/res/lib/templates/simpleproblem.problem') &&
+                                                    ($changes{$token->[2]->{'id'}})) {
+                                                    my $id = $token->[2]->{'id'};
+                                                    $updatedcontent .= '<'.$token->[1];
+                                                    foreach my $attrib (@{$token->[3]}) {
+                                                       next unless ($attrib =~ /^(src|type|title|id)$/);
+                                                        if ($attrib eq 'src') {
+                                                            my ($file) = ($display{$changes{$id}} =~ /^\Qsimpleproblem_\E(.+)$/);
+                                                            if ($file) {
+                                                                $updatedcontent .= ' '.$attrib.'="'.$file.'"';
+                                                            } else {
+                                                                $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
+                                                            }
+                                                        } else {
+                                                            $updatedcontent .= ' '.$attrib.'="'.$token->[2]->{$attrib}.'"';
+                                                        }
+                                                    }
+                                                    $updatedcontent .= ' />'."\n";
+                                                } else {
+                                                    $updatedcontent .= $token->[4]."\n";
+                                                }
+                                             } else {
+                                                 $updatedcontent .= $token->[2];
+                                             }
+                                         }
+                                         print $fh $updatedcontent;
+                                    } else {
+                                        print $fh &Apache::lonclonecourse::rewritefile(
+                     &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
+                                                      (%replacehash,$crs => '')
+                                                                                      );
+                                    }
+                                } else {
+                                    print $fh
+                                        &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
+                                }
+                            } else {
+                                $fail = &mt('Source does not exist.');
+                            }
+                        }
+                        $fh->close();
+                    } else {
+                        $fail = &mt('Could not write to destination.');
+                    }
+                }
+                my $text;
+                if ($fail) {
+                    $text = '<span class="LC_error">'.&mt('fail').(' 'x3).$fail.'</span>';
+                } else {
+                    $text = '<span class="LC_success">'.&mt('ok').'</span>';
+                }
+                if ($i == 0) {
+                    $result .= $text;
+                } else {
+                    $depresult .= $text.'</li>';
+                }
+            }
+            $r->print($result);
+            if ($depresult) {
+                $r->print('<ul>'.$depresult.'</ul>');
+            }
+        }
     } else {
-        $r->print(&mt('Searching ...').'<br />');
-        $r->rflush();
-# Input form
-        $r->print('<form name="dumpdoc" action="" method="post">'."\n");
-	unless ($home==1) {
-	    $r->print('<div class="LC_left_float">'.
-		      '<fieldset><legend>'.
-                      &mt('Select the Authoring Space').
-                      '</legend><select name="authorspace">');
-	}
-	foreach my $key (sort(keys(%outhash))) {
-	    if ($key=~/^home_(.+)$/) {
-		if ($home==1) {
-		    $r->print(
-		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
-		} else {
-		    $r->print('<option value="'.$1.'">'.$1.' - '.
-			      &Apache::loncommon::plainname(split(/\:/,$1)).'</option>');
-		}
-	    }
-	}
-	unless ($home==1) {
-	    $r->print('</select></fieldset></div>'."\n");
-	}
-	my $title=$origcrsdata{'description'};
-	$title=~s/[\/\s]+/\_/gs;
-	$title=&clean($title);
-	$r->print('<div class="LC_left_float">'.
-                  '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
-                  '<input type="text" size="50" name="authorfolder" value="'.
-                  $title.'" />'.
-                  '</fieldset></div><br clear="all" />'."\n");
-	&tiehash();
-	$r->print('<h4>'.&mt('Filenames in Authoring Space').'</h4>'
-                 .&Apache::loncommon::start_data_table()
-                 .&Apache::loncommon::start_data_table_header_row()
-                 .'<th>'.&mt('Internal Filename').'</th>'
-                 .'<th>'.&mt('Title').'</th>'
-                 .'<th>'.&mt('Save as ...').'</th>'
-                 .&Apache::loncommon::end_data_table_header_row());
-	foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
-	    $r->print(&Apache::loncommon::start_data_table_row()
-                     .'<td>'.$file.'</td>');
-	    my ($ext)=($file=~/\.(\w+)$/);
-	    my $title=$hash{'title_'.$hash{
-		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
-	    $r->print('<td>'.($title?$title:' ').'</td>');
-	    if (!$title) {
-		$title=$file;
-	    } else {
-		$title=~s|/|_|g;
-	    }
-	    $title=~s/\.(\w+)$//;
-	    $title=&clean($title);
-	    $title.='.'.$ext;
-	    $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
-                     .&Apache::loncommon::end_data_table_row());
-	}
-	$r->print(&Apache::loncommon::end_data_table());
-	&untiehash();
-	$r->print(
-  '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype Content").'" /></p></form>');
+        my ($navmap,$errormsg) =
+            &Apache::loncourserespicker::get_navmap_object($crstype,'dumpdocs');
+        if (!ref($navmap)) {
+            $r->print($errormsg);
+        } else {
+            $r->print('<div id="searching">'.&mt('Searching ...').'</div>');
+            $r->rflush();
+            my ($preamble,$formname);
+            $formname = 'dumpdoc';
+            unless ($home==1) {
+                $preamble = '<div class="LC_left_float">'.
+                            '<fieldset><legend>'.
+                            &mt('Select the Authoring Space').
+                            '</legend><select name="authorspace">';
+            }
+            my @orderspaces = ();
+            foreach my $key (sort(keys(%outhash))) {
+                if ($key=~/^home_(.+)$/) {
+                    if ($1 eq $env{'user.name'}.':'.$env{'user.domain'}) {
+                        unshift(@orderspaces,$1);
+                    } else {
+                        push(@orderspaces,$1);
+                    }
+                }
+            }
+            if ($home>1) {
+                $preamble .= '<option value="" selected="selected">'.&mt('Select').'</option>';
+            }
+            foreach my $user (@orderspaces) {
+                if ($home==1) {
+                    $preamble .= '<input type="hidden" name="authorspace" value="'.$user.'" />';
+                } else {
+                    $preamble .= '<option value="'.$user.'">'.$user.' - '.
+                                 &Apache::loncommon::plainname(split(/\:/,$user)).'</option>';
+                }
+            }
+            unless ($home==1) {
+                $preamble .= '</select></fieldset></div>'."\n";
+            }
+            my $title=$origcrsdata{'description'};
+            $title=~s/[\/\s]+/\_/gs;
+            $title=&clean($title);
+            $preamble .= '<div class="LC_left_float">'.
+                         '<fieldset><legend>'.&mt('Folder in Authoring Space').'</legend>'.
+                         '<input type="text" size="50" name="authorfolder" value="'.
+                         $title.'" />'.
+                         '</fieldset></div><div style="padding:0;clear:both;margin:0;border:0"></div>'."\n";
+            my %uploadedfiles;
+            &tiehash();
+            foreach my $file (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
+                my ($ext)=($file=~/\.(\w+)$/);
+# FIXME Check supplemental here
+                my $title=$hash{'title_'.$hash{
+                                'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
+                if (!$title) {
+                    $title=$file;
+                } else {
+                    $title=~s|/|_|g;
+                }
+                $title=~s/\.(\w+)$//;
+                $title=&clean($title);
+                $title.='.'.$ext;
+#           $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
+                $uploadedfiles{$file} = $title;
+            }
+            &untiehash();
+            $r->print(&Apache::loncourserespicker::create_picker($navmap,'dumpdocs',$formname,$crstype,undef,
+                                                                 undef,undef,$preamble,$home,\%uploadedfiles));
+        }
     }
     $r->print(&endContentScreen());
 }
 
+sub recurse_html {
+    my ($mm,$prefix,$currdirpath,$currurlpath,$container,$item,$replacehash,$deps) = @_;
+    return unless ((ref($replacehash) eq 'HASH') && (ref($deps) eq 'HASH'));
+    my (%allfiles,%codebase);
+    if (&Apache::lonnet::extract_embedded_items($currdirpath,\%allfiles,\%codebase) eq 'ok') {
+        if (keys(%allfiles)) {
+            foreach my $dependency (keys(%allfiles)) {
+                next if (($dependency =~ m{^/(res|adm)/}) || ($dependency =~ m{^https?://}));
+                my ($depurl,$relfile,$newcontainer);
+                if ($dependency =~ m{^/}) {
+                    if ($dependency =~ m{^\Q$currurlpath/\E(.+)$}) {
+                        $relfile = $1;
+                        if ($dependency =~ m{^\Q$prefix\E(.+)$}) {
+                            $newcontainer = $1;
+                            next if ($replacehash->{$newcontainer});
+                        }
+                        $depurl = $dependency;
+                    } else {
+                        next;
+                    }
+                } else {
+                    $relfile = $dependency;
+                    $depurl = $currurlpath;
+                    $depurl =~ s{[^/]+$}{}; 
+                    $depurl .= $dependency;
+                    ($newcontainer) = ($depurl =~ m{^\Q$prefix\E(.+)$});
+                }
+                next if ($relfile eq '');
+                my $newname = $replacehash->{$container};
+                $newname =~ s{[^/]+$}{};
+                $replacehash->{$newcontainer} = $newname.$relfile;
+                $deps->{$item}{$newcontainer} = 1;
+                my ($newurlpath) = ($depurl =~ m{^(.*)/[^/]+$});
+                my $depfile = &Apache::lonnet::filelocation('',$depurl);
+                my $type = $mm->checktype_filename($depfile);
+                if ($type eq 'text/html') {
+                    &recurse_html($mm,$prefix,$depfile,$newurlpath,$newcontainer,$item,$replacehash,$deps);
+                }
+            }
+        }
+    }
+    return;
+}
+
 sub group_import {
     my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
     my ($donechk,$allmaps,%hierarchy,%titles,%addedmaps,%removefrommap,
@@ -4158,7 +4469,7 @@
       &init_breadcrumbs('versions','Check/Set Resource Versions');
       &checkversions($r);
   } elsif ($allowed && $env{'form.dumpcourse'}) {
-      &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' Content to Authoring Space');
+      &init_breadcrumbs('dumpcourse','Copy '.&Apache::loncommon::course_type().' Content to Authoring Space');
       &dumpcourse($r);
   } elsif ($allowed && $env{'form.exportcourse'}) {
       &init_breadcrumbs('exportcourse','IMS Export');
@@ -4326,9 +4637,11 @@
                 $script .= &dump_switchserver_js(@hosts); 
             }
         } else {
+            my $tid = 1;
             my @tabids;
             if ($supplementalflag) {
                 @tabids = ('002','ee2','ff2');
+                $tid = 2;
             } else {
                 @tabids = ('aa1','bb1','cc1','ff1');
                 unless ($env{'form.folderpath'} =~ /\:1$/) {
@@ -4340,7 +4653,7 @@
 	    $script .= &editing_js($udom,$uname,$supplementalflag).
                        &history_tab_js().
                        &inject_data_js().
-                       &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr).
+                       &Apache::lonhtmlcommon::resize_scrollbox_js('docs',$tabidstr,$tid).
                        &Apache::lonextresedit::extedit_javascript();
             $addentries = {
                             onload   => "javascript:resize_scrollbox('contentscroll','1','1');",
@@ -4635,7 +4948,7 @@
 
 	my $newnavform=(<<NNFORM);
 	<form action="/adm/coursedocs" method="post" name="newnav">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="ee" />
 	$pathitem
 	<input type="hidden" name="importdetail" 
 	value="$lt{'navc'}=/adm/navmaps" />
@@ -4645,7 +4958,7 @@
 NNFORM
 	my $newsmppageform=(<<NSPFORM);
 	<form action="/adm/coursedocs" method="post" name="newsmppg">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="ee" />
 	$pathitem
 	<input type="hidden" name="importdetail" value="" />
 	<a class="LC_menubuttons_link" href="javascript:makesmppage();"> $lt{'sipa'}</a>
@@ -4686,7 +4999,7 @@
 
 	my $newbulform=(<<NBFORM);
 	<form action="/adm/coursedocs" method="post" name="newbul">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="dd" />
 	$pathitem
 	<input type="hidden" name="importdetail" value="" />
 	<a class="LC_menubuttons_link" href="javascript:makebulboard();" >$lt{'bull'}</a>
@@ -4696,7 +5009,7 @@
 
 	my $newaboutmeform=(<<NAMFORM);
 	<form action="/adm/coursedocs" method="post" name="newaboutme">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="dd" />
 	$pathitem
 	<input type="hidden" name="importdetail" 
 	value="$plainname=/adm/$udom/$uname/aboutme" />
@@ -4707,7 +5020,7 @@
 
 	my $newaboutsomeoneform=(<<NASOFORM);
 	<form action="/adm/coursedocs" method="post" name="newaboutsomeone">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="dd" />
 	$pathitem
 	<input type="hidden" name="importdetail" value="" />
 	<a class="LC_menubuttons_link" href="javascript:makeabout();">$lt{'abou'}</a>
@@ -4716,7 +5029,7 @@
 
 	my $newrosterform=(<<NROSTFORM);
 	<form action="/adm/coursedocs" method="post" name="newroster">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="dd" />
 	$pathitem
 	<input type="hidden" name="importdetail" 
 	value="$lt{'rost'}=/adm/viewclasslist" />
@@ -4737,7 +5050,7 @@
         }
         my $newwebpageform =(<<NWEBFORM);
         <form action="/adm/coursedocs" method="post" name="newwebpage">
-        <input type="hidden" name="active" value="cc" />
+        <input type="hidden" name="active" value="ee" />
         $pathitem
         <input type="hidden" name="importdetail" value="$newwebpage" />
         <a class="LC_menubuttons_link" href="javascript:makewebpage();">$lt{'webp'}</a>
@@ -4761,7 +5074,7 @@
 	<form action="/adm/coursedocs" method="post" name="newpage">
 	<input type="hidden" name="folderpath" value="$path" />
 	<input type="hidden" name="importdetail" value="" />
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="ee" />
 	<a class="LC_menubuttons_link" href="javascript:makenewpage(document.newpage,'$pageseq');">$lt{'newp'}</a>
 	$help{'Adding_Pages'}
 	</form>
@@ -4772,14 +5085,14 @@
 	<form action="/adm/coursedocs" method="post" name="newfolder">
 	$pathitem
 	<input type="hidden" name="importdetail" value="" />
-	<input type="hidden" name="active" value="aa" />
+	<input type="hidden" name="active" value="" />
 	<a href="javascript:makenewfolder(document.newfolder,'$folderseq');">$lt{'newf'}</a>$help{'Adding_Folders'}
 	</form>
 NFFORM
 
 	my $newsylform=(<<NSYLFORM);
 	<form action="/adm/coursedocs" method="post" name="newsyl">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="ee" />
 	$pathitem
 	<input type="hidden" name="importdetail" 
 	value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
@@ -4791,7 +5104,7 @@
 
 	my $newgroupfileform=(<<NGFFORM);
 	<form action="/adm/coursedocs" method="post" name="newgroupfiles">
-	<input type="hidden" name="active" value="cc" />
+	<input type="hidden" name="active" value="dd" />
 	$pathitem
 	<input type="hidden" name="importdetail"
 	value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
@@ -4908,7 +5221,7 @@
 
 	my $supnewfolderform=(<<SNFFORM);
 	<form action="/adm/coursedocs" method="post" name="supnewfolder">
-	<input type="hidden" name="active" value="ee" />
+	<input type="hidden" name="active" value="" />
         $pathitem
 	<input type="hidden" name="importdetail" value="" />
 	<a class="LC_menubuttons_link" href="javascript:makenewfolder(document.supnewfolder,'$folderseq');">$lt{'newf'}</a> 
@@ -5185,13 +5498,13 @@
     my ($crstype) = @_;
     my $lc_crstype = lc($crstype);
     my ($home,$other,%outhash)=&authorhosts();
-    my %lt=&Apache::lonlocal::texthash (
+    my %lt= ( # do not translate here
                                          'vc'   => 'Verify Content',
                                          'cv'   => 'Check/Set Resource Versions',
                                          'ls'   => 'List Resource Identifiers',
                                          'imse' => 'Export contents to IMS Archive',
-                                         'dcd'  => "Dump $crstype Content to Authoring Space",
-                                       );
+                                         'dcd'  => "Copy $crstype Content to Authoring Space",
+            );
     my ($candump,$dumpurl);
     if ($home + $other > 0) {
         $candump = 'F';
@@ -5273,7 +5586,7 @@
     my $form;
     my $activetab;
     my $active;
-    if (($env{'form.active'} ne '') && ($env{'form.active'} ne 'aa')) {
+    if (($env{'form.active'} ne '') && ($env{'form.active'} ne '00')) {
         $activetab = $env{'form.active'};
     }
     my $backicon = $iconpath.'clickhere.gif';
@@ -5308,7 +5621,7 @@
             $form .= '<li style="float:right" '.$active
                 .' onclick="javascript:showPage(this, \''.$name.$tid.'\', \'navigation'.$tid.'\',\'content'.$tid.'\');"><a href="javascript:;"><b>'.&mt(${$orderhash{$name}}[0]).'</b></a></li>'."\n";
         } else {
-	    $form .= '<li '.$active.' style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
+	    $form .= '<li style="float:right">'.${$orderhash{$name}}[1].'</li>'."\n";
 
 	}
     }
@@ -5871,10 +6184,12 @@
 
 function hideAll(current, nav, data) {
 unselectInactive(nav);
-if(current.className == 'right'){
+if (current) {
+    if (current.className == 'right'){
 	current.className = 'right active'
-	}else{
+    } else {
 	current.className = 'active';
+    }
 }
 currentData = document.getElementById(data);
 currentDivs = currentData.getElementsByTagName('DIV');
@@ -5905,10 +6220,24 @@
 }
 
 function showPage(current, pageId, nav, data) {
+        currstate = current.className;
 	hideAll(current, nav, data);
 	openTabs(pageId);
 	unselectInactive(nav);
-	current.className = 'active';
+        if ((currstate == 'active') || (currstate == 'right active')) {
+            if (currstate == 'active') {
+                current.className = '';
+            } else {
+                current.className = 'right';
+            }
+            activeTab = '';
+            toggleUpload();
+            toggleMap();
+            resize_scrollbox('contentscroll','1','0');
+            return;
+        } else {
+            current.className = 'active';
+        }
 	currentData = document.getElementById(pageId);
 	currentData.style.display = 'block';
         activeTab = pageId;
@@ -6296,9 +6625,9 @@
 sub dump_switchserver_js {
     my @hosts = @_;
     my %lt = &Apache::lonlocal::texthash(
-        dump => 'Dumping to Authoring Space requires switching server.',
+        dump => 'Copying Content to Authoring Space requires switching server.',
         swit => 'Switch server?',
-        duco => 'Dump content to Authoring Space',
+        duco => 'Copying Content to Authoring Space',
         yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',
         chos => 'Choose server',
     );


More information about the LON-CAPA-cvs mailing list