--- loncom/interface/londocs.pm	2008/01/20 05:46:34	1.303
+++ loncom/interface/londocs.pm	2010/02/02 01:30:46	1.325.2.7
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.303 2008/01/20 05:46:34 raeburn Exp $
+# $Id: londocs.pm,v 1.325.2.7 2010/02/02 01:30:46 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -26,6 +26,8 @@
 # http://www.lon-capa.org/
 #
 
+
+
 package Apache::londocs;
 
 use strict;
@@ -53,15 +55,10 @@ my %alreadyseen=();
 
 my $hadchanges;
 
-# Available help topics
 
 my %help=();
 
-# Mapread read maps into LONCAPA::map:: global arrays 
-# @order and @resources, determines status
-# sets @order - pointer to resources in right order
-# sets @resources - array with the resources with correct idx
-#
+
 
 sub mapread {
     my ($coursenum,$coursedom,$map)=@_;
@@ -81,20 +78,20 @@ sub storemap {
     return ($errtext,0);
 }
 
-# ----------------------------------------- Return hash with valid author names
+
 
 sub authorhosts {
     my %outhash=();
     my $home=0;
     my $other=0;
-    foreach (keys %env) {
-	if ($_=~/^user\.role\.(au|ca)\.(.+)$/) {
+    foreach my $key (keys(%env)) {
+	if ($key=~/^user\.role\.(au|ca)\.(.+)$/) {
 	    my $role=$1;
 	    my $realm=$2;
-	    my ($start,$end)=split(/\./,$env{$_});
+	    my ($start,$end)=split(/\./,$env{$key});
 	    if (($start) && ($start>time)) { next; }
 	    if (($end) && (time>$end)) { next; }
-	    my $ca; my $cd;
+	    my ($ca,$cd);
 	    if ($1 eq 'au') {
 		$ca=$env{'user.name'};
 		$cd=$env{'user.domain'};
@@ -116,21 +113,21 @@ sub authorhosts {
     }
     return ($home,$other,%outhash);
 }
-# ------------------------------------------------------ Generate "dump" button
+
 
 sub dumpbutton {
     my ($home,$other,%outhash)=&authorhosts();
-    my $type = &Apache::loncommon::course_type();
+    my $crstype = &Apache::loncommon::course_type();
     if ($home+$other==0) { return ''; }
     if ($home) {
 	return '<div>'.
 	    '<input type="submit" name="dumpcourse" value="'.
-	    &mt('Dump '.$type.' DOCS to Construction Space').'" />'.
+	    &mt('Dump '.$crstype.' DOCS to Construction Space').'" />'.
 	    &Apache::loncommon::help_open_topic('Docs_Dump_Course_Docs').
 	    '</div>';
     } else {
 	return '<div>'.
-     &mt('Dump '.$type.
+     &mt('Dump '.$crstype.
 	 ' DOCS to Construction Space: available on other servers').
 	 '</div>';
     }
@@ -141,14 +138,15 @@ sub clean {
     $title=~s/[^\w\/\!\$\%\^\*\-\_\=\+\;\:\,\\\|\`\~]+/\_/gs;
     return $title;	
 }
-# -------------------------------------------------------- Actually dump course
+
+
 
 sub dumpcourse {
     my ($r) = @_;
-    my $type = &Apache::loncommon::course_type();
-    $r->print(&Apache::loncommon::start_page('Dump '.$type.' DOCS to Construction Space').
-	      '<form name="dumpdoc" method="post">');
-    $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$type.' DOCS to Construction Space'));
+    my $crstype = &Apache::loncommon::course_type();
+    $r->print(&Apache::loncommon::start_page('Dump '.$crstype.' DOCS to Construction Space').
+	      '<form name="dumpdoc" action="" method="post">');
+    $r->print(&Apache::lonhtmlcommon::breadcrumbs('Dump '.$crstype.' DOCS to Construction Space'));
     my ($home,$other,%outhash)=&authorhosts();
     unless ($home) { return ''; }
     my $origcrsid=$env{'request.course.id'};
@@ -161,15 +159,15 @@ sub dumpcourse {
 	my $title=$env{'form.authorfolder'};
 	$title=&clean($title);
 	my %replacehash=();
-	foreach (keys %env) {
-	    if ($_=~/^form\.namefor\_(.+)/) {
-		$replacehash{$1}=$env{$_};
+	foreach my $key (keys(%env)) {
+	    if ($key=~/^form\.namefor\_(.+)/) {
+		$replacehash{$1}=$env{$key};
 	    }
 	}
 	my $crs='/uploaded/'.$env{'request.course.id'}.'/';
 	$crs=~s/\_/\//g;
-	foreach (keys %replacehash) {
-	    my $newfilename=$title.'/'.$replacehash{$_};
+	foreach my $item (keys(%replacehash)) {
+	    my $newfilename=$title.'/'.$replacehash{$item};
 	    $newfilename=~s/\.(\w+)$//;
 	    my $ext=$1;
 	    $newfilename=&clean($newfilename);
@@ -184,16 +182,16 @@ sub dumpcourse {
 		    unless(mkdir($makepath,0777)) { $fail=1; } 
 		}
 	    }
-	    $r->print('<br /><tt>'.$_.'</tt> => <tt>'.$newfilename.'</tt>: ');
+	    $r->print('<br /><tt>'.$item.'</tt> => <tt>'.$newfilename.'</tt>: ');
 	    if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) {
-		if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
+		if ($item=~/\.(sequence|page|html|htm|xml|xhtml)$/) {
 		    print $fh &Apache::lonclonecourse::rewritefile(
-         &Apache::lonclonecourse::readfile($env{'request.course.id'},$_),
+         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item),
 				     (%replacehash,$crs => '')
 								    );
 		} else {
 		    print $fh
-         &Apache::lonclonecourse::readfile($env{'request.course.id'},$_);
+         &Apache::lonclonecourse::readfile($env{'request.course.id'},$item);
 		       }
 		$fh->close();
 	    } else {
@@ -211,8 +209,8 @@ sub dumpcourse {
 	    $r->print(
 		      '<h3>'.&mt('Select the Construction Space').'</h3><select name="authorspace">');
 	}
-	foreach (sort keys %outhash) {
-	    if ($_=~/^home_(.+)$/) {
+	foreach my $key (sort(keys(%outhash))) {
+	    if ($key=~/^home_(.+)$/) {
 		if ($home==1) {
 		    $r->print(
 		  '<input type="hidden" name="authorspace" value="'.$1.'" />');
@@ -228,49 +226,79 @@ sub dumpcourse {
 	my $title=$origcrsdata{'description'};
 	$title=~s/[\/\s]+/\_/gs;
 	$title=&clean($title);
-	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3><input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
+	$r->print('<h3>'.&mt('Folder in Construction Space').'</h3>'
+                 .'<input type="text" size="50" name="authorfolder" value="'.$title.'" /><br />');
 	&tiehash();
-	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3><table border="2"><tr><th>'.&mt('Internal Filename').'</th><th>'.&mt('Title').'</th><th>'.&mt('Save as ...').'</th></tr>');
-	foreach (&Apache::lonclonecourse::crsdirlist($origcrsid,'userfiles')) {
-	    $r->print('<tr><td>'.$_.'</td>');
-	    my ($ext)=($_=~/\.(\w+)$/);
+	$r->print('<h3>'.&mt('Filenames in Construction Space').'</h3>'
+                 .&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'}.'/'.$_}};
+		'ids_/uploaded/'.$origcrsdata{'domain'}.'/'.$origcrsdata{'num'}.'/'.$file}};
 	    $r->print('<td>'.($title?$title:'&nbsp;').'</td>');
 	    if (!$title) {
-		$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_".$_."' value='".$title."' /></td></tr>\n");
+	    $r->print("\n<td><input type='text' size='60' name='namefor_".$file."' value='".$title."' /></td>"
+                     .&Apache::loncommon::end_data_table_row());
 	}
-	$r->print("</table>\n");
+	$r->print(&Apache::loncommon::end_data_table());
 	&untiehash();
 	$r->print(
-  '<p><input type="submit" name="dumpcourse" value="'.&mt('Dump [_1] DOCS',$type).'" /></p></form>');
+  '<p><input type="submit" name="dumpcourse" value="'.&mt("Dump $crstype DOCS").'" /></p></form>');
     }
 }
 
-# ------------------------------------------------------ Generate "export" button
+
 
 sub exportbutton {
-    my $type = &Apache::loncommon::course_type();
-    return '<div>'.
-            '<input type="submit" name="exportcourse" value="'.
-            &mt('Export '.$type.' to IMS').'" />'.
-    &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'</div>';
+    my $crstype = &Apache::loncommon::course_type();
+    return '<input type="submit" name="exportcourse"'
+          .' value="'.&mt('IMS Export').'"'
+          .' title="'.&mt('Export '.$crstype.' to IMS Package').'" />'.
+    &Apache::loncommon::help_open_topic('Docs_Export_Course_Docs').'<br />';
 }
 
+
+
 sub exportcourse {
     my $r=shift;
-    my $type = &Apache::loncommon::course_type();
+    my $crstype = &Apache::loncommon::course_type();
     my %discussiontime = &Apache::lonnet::dump('discussiontimes',
                                                $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'});
-    my $numdisc = keys %discussiontime;
+    my $numdisc = keys(%discussiontime);
     my $navmap = Apache::lonnavmaps::navmap->new();
+    if (!defined($navmap)) {
+        $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package').
+                  '<h2>'.&mt('IMS Export Failed').'</h2>'.
+                  '<div class="LC_error">');
+        if ($crstype eq 'Community') {
+            $r->print(&mt('Unable to retrieve information about community contents'));
+        } else {
+            $r->print(&mt('Unable to retrieve information about course contents'));
+        }
+        $r->print('</div><a href="/adm/coursedocs">');
+        if ($crstype eq 'Community') {
+            $r->print(&mt('Return to Community Editor'));
+        } else {
+            $r->print(&mt('Return to Course Editor'));
+        }
+        $r->print('</a>');
+        &Apache::lonnet::logthis('IMS export failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+        return;
+    }
     my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef);
     my $curRes;
     my $outcome;
@@ -284,7 +312,17 @@ sub exportcourse {
         my @exportitems = &Apache::loncommon::get_env_multiple('form.archive');
         my @discussions = &Apache::loncommon::get_env_multiple('form.discussion');
         if (@exportitems == 0 && @discussions == 0) {
-            $outcome = '<br />As you did not select any content items or discussions for export, an IMS package has not been created.  Please <a href="javascript:history.go(-1)">go back</a> to select either content items or discussions for export';
+            $outcome = 
+                '<p class="LC_warning">'
+               .&mt('As you did not select any content items or discussions'
+                   .' for export, an IMS package has not been created.')
+               .'</p>'
+               .'<p>'
+               .&mt('Please [_1]go back[_2] to select either content items'
+                   .' or discussions for export.'
+                       ,'<a href="javascript:history.go(-1)">'
+                       ,'</a>')
+               .'</p>';
         } else {
             my $now = time;
             my %symbs;
@@ -307,35 +345,53 @@ sub exportcourse {
                 open(OUTPUT, "zip -r $imszip *  2> /dev/null |");
                 close(OUTPUT);
                 chdir $cwd;
-                $outcome .= &mt('Download the zip file from <a href="[_1]">IMS '.lc($type).' archive</a><br />',$imszipfile,);
+                $outcome .= '<p>'
+                           .&mt('[_1]Your IMS package[_2] is ready for download.'
+                               ,'<a href="'.$imszipfile.'">','</a>')
+                           .'</p>';
                 if ($copyresult) {
-                    $outcome .= 'The following errors occurred during export - '.$copyresult;
+                    $outcome .= '<p class="LC_error">'
+                               .&mt('The following errors occurred during export - [_1]'
+                                   ,$copyresult)
+                               .'</p>';
                 }
             } else {
-                $outcome = '<br />Unfortunately you will not be able to retrieve an IMS archive of this posts at this time, because there was a problem creating a manifest file.<br />';
+                $outcome = '<p class="LC_error">'
+                          .&mt('Unfortunately you will not be able to retrieve'
+                              .' an IMS archive of this posts at this time,'
+                              .' because there was a problem creating a'
+                              .' manifest file.')
+                          .'</p>'
+                          .'<p><a href="javascript:history.go(-1)">'
+                          .&mt('Go Back')
+                          .'</a></p>';
             }
         }
-        $r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package'));
-	$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
+        $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package'));
+        $r->print(&Apache::lonhtmlcommon::breadcrumbs('IMS Export'));
         $r->print($outcome);
         $r->print(&Apache::loncommon::end_page());
     } else {
-        my $display;
-        $display = '<form name="exportdoc" method="post">'."\n";
-        $display .= &mt('Choose which items you wish to export from your '.$type.'.<br /><br />');
-        $display .= '<table border="0" cellspacing="0" cellpadding="3">'.
-                    '<tr><td><fieldset><legend>&nbsp;<b>Content items</b></legend>'.
-                    '<input type="button" value="check all" '.
+        my $display='<form name="exportdoc" action="" method="post">'."\n".
+                    '<p>'.
+                    &mt('Choose which items you wish to export from your '.$crstype.'.').
+                    '</p>'.
+                    '<div class="LC_columnSection"><fieldset>'.
+                    '<legend>'.&mt('Content items').'</legend>'.
+                    '<input type="button" value="'.&mt('check all').'" '.
                     'onclick="javascript:checkAll(document.exportdoc.archive)" />'.
-                    '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
-                    ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset></td>'.
-                    '<td>&nbsp;</td><td>&nbsp;</td>'.
-                    '<td align="right"><fieldset><legend>&nbsp;<b>Discussion posts'.
-                    '</b></legend><input type="button" value="check all"'.
-                    ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
-                    '&nbsp;&nbsp;<input type="button" value="uncheck all"'.
-                    ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" /></fieldset></td>'.
-                    '</tr></table>';
+                    '&nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"'.
+                    ' onclick="javascript:uncheckAll(document.exportdoc.archive)" /></fieldset>';
+        if ($numdisc > 0) {
+            $display .= '<fieldset>'.
+                        '<legend>'.&mt('Discussion posts').'</legend>'.
+                        '<input type="button" value="'.&mt('check all').'"'.
+                        ' onclick="javascript:checkAll(document.exportdoc.discussion)" />'.
+                        '&nbsp;&nbsp;<input type="button" value="'.&mt('uncheck all').'"'.
+                        ' onclick="javascript:uncheckAll(document.exportdoc.discussion)" />'.
+                        '</fieldset>';
+        }
+        $display .= '</div>';
         my $curRes;
         my $depth = 0;
         my $count = 0;
@@ -344,13 +400,13 @@ sub exportcourse {
         my %parent = ();
         my %children = ();
         my $lastcontainer = $startcount;
-        my @bgcolors = ('#F6F6F6','#FFFFFF');
-        $display .= '<table cellspacing="0"><tr>'.
-            '<td><b>Export content item?<br /></b></td><td>&nbsp;</td><td align="right">'."\n";
+        $display .= &Apache::loncommon::start_data_table()
+                   .&Apache::loncommon::start_data_table_header_row()
+                   .'<th>'.&mt('Export content item?').'</th>';
         if ($numdisc > 0) {
-            $display.='<b>Export&nbsp;discussion posts?</b>'."\n";
+            $display .= '<th>'.&mt('Export discussion posts?').'</th>';
         }
-        $display.='&nbsp;</td></tr>';
+        $display .= &Apache::loncommon::end_data_table_header_row();
         while ($curRes = $it->next()) {
             if (ref($curRes)) {
                 $count ++;
@@ -371,38 +427,43 @@ sub exportcourse {
                         $ressymb = 'bulletin___'.$3.'___adm/wrapper/adm/'.$1.'/'.$2.'/'.$3.'/bulletinboard';
                     }
                 }
-                my $color = $count%2;
-                $display .='<tr bgcolor='.$bgcolors[$color].'><td>'."\n".
-                    '<input type="checkbox" name="archive" value="'.$count.'" ';
+                my $currelem = $count+$boards+$startcount;
+                $display .= &Apache::loncommon::start_data_table_row()
+                           .'<td>'."\n"
+                           .'<input type="checkbox" name="archive" value="'.$count.'" ';
                 if (($curRes->is_sequence()) || ($curRes->is_page())) {
-                    my $checkitem = $count + $boards + $startcount;
-                    $display .= 'onClick="javascript:propagateCheck('."'$checkitem'".')"';
+                    $lastcontainer = $currelem;
+                    $display .= 'onclick="javascript:propagateCheck('."'$currelem'".')"';
                 }
                 $display .= ' />'."\n";
                 for (my $i=0; $i<$depth; $i++) {
-                    $display .= '<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" /><img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />'."\n";
+                    $display .= ('<img src="/adm/lonIcons/whitespace1.gif" class="LC_docs_spacer" />' x2)."\n";
                 }
                 if ($curRes->is_sequence()) {
-                    $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif">&nbsp;'."\n";
-                    $lastcontainer = $count + $startcount + $boards;
+                    $display .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />&nbsp;'."\n";
                 } elsif ($curRes->is_page()) {
-                    $display .= '<img src="/adm/lonIcons/navmap.page.open.gif">&nbsp;'."\n";
-                    $lastcontainer = $count + $startcount + $boards;
+                    $display .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" />&nbsp;'."\n";
                 }
-                my $currelem = $count+$boards+$startcount;
                 $children{$parent{$depth}} .= $currelem.':';
-                $display .= '&nbsp;'.$curRes->title().'</td>';
+                $display .= '&nbsp;'.$curRes->title().'</td>'."\n";
+
+                # Existing discussion posts?
+
                 if ($discussiontime{$ressymb} > 0) {
                     $boards ++;
-                    $currelem = $count+$boards+$startcount;
-                    $display .= '<td>&nbsp;</td><td align="right"><input type="checkbox" name="discussion" value="'.$count.'" />&nbsp;</td>'."\n";
+                    $display .= '<td align="right">'
+                               .'<input type="checkbox" name="discussion" value="'.$count.'" />'
+                               .'</td>'."\n";
                 } else {
-                    $display .= '<td colspan="2">&nbsp;</td>'."\n";
+                    $display .= '<td>&nbsp;</td>'."\n";
                 }
+                $display .= &Apache::loncommon::end_data_table_row();
             }
         }
+        $display .= &Apache::loncommon::end_data_table();
         my $scripttag = qq|
-<script>
+<script type="text/javascript">
+// <![CDATA[
 
 function checkAll(field) {
     if (field.length > 0) {
@@ -439,8 +500,8 @@ function containerCheck(item) {
     }
         |;
 
-        foreach my $container (sort { $a <=> $b } keys %children) {
-            my @contents = split/:/,$children{$container};
+        foreach my $container (sort { $a <=> $b } (keys(%children))) {
+            my @contents = split(/:/,$children{$container});
             for (my $i=0; $i<@contents; $i ++) {
                 $scripttag .= '    parents['.$container.']['.$i.'] = '.$contents[$i]."\n";
             }
@@ -454,16 +515,16 @@ function containerCheck(item) {
      }   
 }
 
+// ]]>
 </script>
         |;
-	$r->print(&Apache::loncommon::start_page('Export '.lc($type).' to IMS content package',
-						 $scripttag));
-	$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($type).' to IMS content package'));
-	$r->print($display.'</table>'.
-                  '<p><input type="hidden" name="finishexport" value="1">'.
+        $r->print(&Apache::loncommon::start_page('Export '.$crstype.' to IMS Package',
+ 						 $scripttag));
+	$r->print(&Apache::lonhtmlcommon::breadcrumbs('Export '.lc($crstype).' to IMS content package'));
+	$r->print($display.
+                  '<p><input type="hidden" name="finishexport" value="1" />'.
                   '<input type="submit" name="exportcourse" value="'.
-                  &mt('Export '.$type.' DOCS').'" /></p></form>'.
-		  &Apache::loncommon::end_page());
+                  &mt('Export').'" /></p></form>');
     }
 }
 
@@ -490,7 +551,7 @@ sub create_ims_store {
     my $manifestfilename = $$tempexport.$manifest;
     if ($ims_manifest = Apache::File->new('>'.$manifestfilename)) {
         $$manifestok=1;
-        print $ims_manifest
+        print $ims_manifest 
 '<?xml version="1.0" encoding="UTF-8"?>'."\n".
 '<manifest xmlns="http://www.imsglobal.org/xsd/imscp_v1p1"'.
 ' xmlns:imsmd="http://www.imsglobal.org/xsd/imsmd_v1p2"'.
@@ -548,7 +609,7 @@ sub build_package {
             if ($curRes->is_sequence() || $curRes->is_page()) {
                 $lastcontainer = $count;
             }
-            if (grep/^$count$/,@$exportitems) {
+            if (grep(/^$count$/,@$exportitems)) {
                 &get_dependencies($exportitems,\%parent,$depth,\@dependencies);
             }
         }
@@ -572,7 +633,7 @@ sub build_package {
 
         if (ref($curRes)) {
             $count ++;
-            if ((grep/^$count$/,@$exportitems) || (grep/^$count$/,@dependencies)) {
+            if ((grep(/^$count$/,@$exportitems)) || (grep(/^$count$/,@dependencies))) {
                 my $symb = $curRes->symb();
                 my $isvisible = 'true';
                 my $resourceref;
@@ -606,11 +667,11 @@ sub build_package {
                      '   <resource identifier="RES-'.$env{'request.course.id'}.'-'.$count.
                      '" type="webcontent" href="'.$content_file.'">'."\n".
                      '       <file href="'.$content_file.'" />'."\n";
-                        foreach (@hrefs) {
+                        foreach my $item (@hrefs) {
                             $imsresources .=
-                     '        <file href="'.$_.'" />'."\n";
+                     '        <file href="'.$item.'" />'."\n";
                         }
-                        if (grep/^$count$/,@$discussions) {
+                        if (grep(/^$count$/,@$discussions)) {
                             my $ressymb = $symb;
                             my $mode;
                             if ($ressymb =~ m|adm/($match_domain)/($match_username)/(\d+)/bulletinboard$|) {
@@ -651,8 +712,8 @@ sub build_package {
 sub get_dependencies {
     my ($exportitems,$parent,$depth,$dependencies) = @_;
     if ($depth > 1) {
-        if ((!grep/^$$parent{$depth}$/,@$exportitems) && (!grep/^$$parent{$depth}$/,@$dependencies)) {
-            push @$dependencies, $$parent{$depth};
+        if ((!grep(/^$$parent{$depth}$/,@$exportitems)) && (!grep(/^$$parent{$depth}$/,@$dependencies))) {
+            push(@{$dependencies},$$parent{$depth});
             if ($depth > 2) {
                 &get_dependencies($exportitems,$parent,$depth-1,$dependencies);
             }
@@ -818,7 +879,7 @@ sub extract_media {
         $dirpath = $url;
         $container = '';
     }
-    &Apache::lonnet::extract_embedded_items(undef,undef,\%allfiles,\%codebase,$content);
+    &Apache::lonnet::extract_embedded_items(undef,\%allfiles,\%codebase,$content);
     foreach my $embed_file (keys(%allfiles)) {
         my $filename;
         if ($embed_file =~ m#([^/]+)$#) {
@@ -858,7 +919,7 @@ sub extract_media {
             my $copiedfile;
             if ($copiedfile = Apache::File->new('>'.$destination)) {
                 print $copiedfile $embed_content;
-                push @{$href}, 'resources/'.$count.'/res/'.$filename;
+                push(@{$href},'resources/'.$count.'/res/'.$filename);
                 my $attrib_regexp = '';
                 if (@{$allfiles{$embed_file}} > 1) {
                     $attrib_regexp = join('|',@{$allfiles{$embed_file}});
@@ -902,8 +963,7 @@ sub store_template {
     }
 }
 
-# Imports the given (name, url) resources into the course
-# coursenum, coursedom, and folder must precede the list
+
 sub group_import {
     my ($coursenum, $coursedom, $folder, $container, $caller, @files) = @_;
 
@@ -924,7 +984,7 @@ sub group_import {
             my $result=&Apache::lonnet::finishuserfileupload($coursenum,$coursedom,
                                                 'output',$1.$2);
             if ($result != m|^/uploaded/|) {
-                $errtext.='Map not saved: A network error occured when trying to save the new map. ';
+                $errtext.='Map not saved: A network error occurred when trying to save the new map. ';
                 $fatal = 2;
             }
             if ($fatal) {
@@ -949,7 +1009,7 @@ sub group_import {
 }
 
 sub breadcrumbs {
-    my ($where)=@_;
+    my ($allowed,$crstype)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     my (@folders);
     if ($env{'form.pagepath'}) {
@@ -966,7 +1026,7 @@ sub breadcrumbs {
     my $is_random_order=0;
     while (@folders) {
 	my $folder=shift(@folders);
-	my $foldername=shift(@folders);
+    	my $foldername=shift(@folders);
 	if ($folderpath) {$folderpath.='&';}
 	$folderpath.=$folder.'&'.$foldername;
 	my $url='/adm/coursedocs?folderpath='.
@@ -982,6 +1042,13 @@ sub breadcrumbs {
             if ($2) { $ishidden=1; }
             if ($3) { $isencrypted=1; }
 	    if ($4 ne '') { $is_random_order = 1; }
+            if ($folder eq 'supplemental') {
+                if ($allowed) {
+                    $name = &mt('Supplemental '.$crstype.' Documents');
+                } else {
+                    $name = &mt($crstype.' Documents');
+                }
+            }
 	    &Apache::lonhtmlcommon::add_breadcrumb(
 		      {'href'=>$url.$cpinfo,
 		       'title'=>$name,
@@ -1031,7 +1098,7 @@ sub log_docs {
                        'currentfolder' => $env{'form.folder'});
         if ($parmidx) {
            $storehash{'parameter_res'}=$oldresources[$parmidx];
-           foreach my $parm (keys %parmaction) {
+           foreach my $parm (keys(%parmaction)) {
               $storehash{'parameter_action_'.$parm}=$parmaction{$parm};
               $storehash{'parameter_value_'.$parm}=$parmvalue{$parm};
            }
@@ -1058,9 +1125,9 @@ sub log_docs {
 }
 
 
-#
-# Docs Change Log
-#
+
+
+
 sub docs_change_log {
     my ($r)=@_;
     my $folder=$env{'form.folder'};
@@ -1201,12 +1268,15 @@ sub update_paste_buffer {
 # Mark for copying
     my ($title,$url)=split(':',$LONCAPA::map::resources[$LONCAPA::map::order[$env{'form.markcopy'}]]);
     if (&is_supplemental_title($title)) {
+        &Apache::lonnet::appenv({'docs.markedcopy_supplemental' => $title});
 	($title) = &parse_supplemental_title($title);
+    } elsif ($env{'docs.markedcopy_supplemental'}) {
+        &Apache::lonnet::delenv('docs.markedcopy_supplemental');
     }
     $url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
 
-    &Apache::lonnet::appenv('docs.markedcopy_title' => $title,
-			    'docs.markedcopy_url'   => $url);
+    &Apache::lonnet::appenv({'docs.markedcopy_title' => $title,
+			    'docs.markedcopy_url'   => $url});
     delete($env{'form.markcopy'});
 }
 
@@ -1250,9 +1320,11 @@ ENDPASTE
 }
 
 sub do_paste_from_buffer {
-    my ($coursenum,$coursedom) = @_;
+    my ($coursenum,$coursedom,$folder) = @_;
 
-    return 0 if (!$env{'form.pastemarked'});
+    if (!$env{'form.pastemarked'}) {
+        return;
+    }
 
 # paste resource to end of list
     my $url=&LONCAPA::map::qtescape($env{'docs.markedcopy_url'});
@@ -1260,18 +1332,50 @@ sub do_paste_from_buffer {
 # Maps need to be copied first
     if (($url=~/\.(page|sequence)$/) && ($url=~/^\/uploaded\//)) {
 	$title=&mt('Copy of').' '.$title;
-	my $newid=$$.time;
-	$url=~/^(.+)\.(\w+)$/;
-	my $newurl=$1.$newid.'.'.$2;
+	my $newid=$$.int(rand(100)).time;
+	my ($oldid,$ext) = ($url=~/^(.+)\.(\w+)$/);
+        if ($oldid =~ m{^(/uploaded/\Q$coursedom\E/\Q$coursenum\E/)(\D+)(\d+)$}) {
+            my $path = $1;
+            my $prefix = $2;
+            my $ancestor = $3;
+            if (length($ancestor) > 10) {
+                $ancestor = substr($ancestor,-10,10);
+            }
+            $oldid = $path.$prefix.$ancestor;
+        }
+        my $counter = 0;
+        my $newurl=$oldid.$newid.'.'.$ext;
+        my $is_unique = &uniqueness_check($newurl);
+        while (!$is_unique && $counter < 100) {
+            $counter ++;
+            $newid ++;
+            $newurl = $oldid.$newid;
+            $is_unique = &uniqueness_check($newurl);
+        }
+        if (!$is_unique) {
+            if ($url=~/\.page$/) {
+                return &mt('Paste failed: an error occurred creating a unique URL for the composite page');
+            } else {
+                return &mt('Paste failed: an error occurred creating a unique URL for the folder');
+            }
+        }
 	my $storefn=$newurl;
 	$storefn=~s{^/\w+/$match_domain/$match_username/}{};
-	&Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
-					   &Apache::lonnet::getfile($url));
+	my $paste_map_result =
+            &Apache::lonclonecourse::writefile($env{'request.course.id'},$storefn,
+					       &Apache::lonnet::getfile($url));
+        if ($paste_map_result eq '/adm/notfound.html') {
+            if ($url=~/\.page$/) {
+                return &mt('Paste failed: an error occurred saving the composite page');
+            } else {
+                return &mt('Paste failed: an error occurred saving the folder');
+            }
+        }
 	$url = $newurl;
     }
 # published maps can only exists once, so remove it from paste buffer when done
     if (($url=~/\.(page|sequence)$/) && ($url=~m {^/res/})) {
-	&Apache::lonnet::delenv('docs\\.markedcopy');
+	&Apache::lonnet::delenv('docs.markedcopy');
     }
     if ($url=~ m{/smppg$}) {
 	my $db_name = &Apache::lonsimplepage::get_db_name($url);
@@ -1292,11 +1396,40 @@ sub do_paste_from_buffer {
     $url       = &LONCAPA::map::qtunescape($url);
 # Now insert the URL at the bottom
     my $newidx = &LONCAPA::map::getresidx($url);
+    if ($env{'docs.markedcopy_supplemental'}) {
+        if ($folder =~ /^supplemental/) {
+            $title = $env{'docs.markedcopy_supplemental'};
+        } else {
+            (undef,undef,$title) = 
+                &parse_supplemental_title($env{'docs.markedcopy_supplemental'});
+        }
+    } else {
+        if ($folder=~/^supplemental/) {
+           $title=time.'___&&&___'.$env{'user.name'}.'___&&&___'.
+                  $env{'user.domain'}.'___&&&___'.$title;
+        }
+    }
+
     $LONCAPA::map::resources[$newidx]= 	$title.':'.$url.':'.$ext.':normal:res';
     push(@LONCAPA::map::order, $newidx);
+    return 'ok';
 # Store the result
 }
 
+sub uniqueness_check {
+    my ($newurl) = @_;
+    my $unique = 1;
+    foreach my $res (@LONCAPA::map::order) {
+        my ($name,$url)=split(/\:/,$LONCAPA::map::resources[$res]);
+        $url=&LONCAPA::map::qtescape($url);
+        if ($newurl eq $url) {
+            $unique = 0;
+            last;    
+        }
+    }
+    return $unique;
+}
+
 my %parameter_type = ( 'randompick'     => 'int_pos',
 		       'hiddenresource' => 'string_yesno',
 		       'encrypturl'     => 'string_yesno',
@@ -1370,7 +1503,7 @@ sub handle_edit_cmd {
 }
 
 sub editor {
-    my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$which)=@_;
+    my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype)=@_;
 
     my $container= ($env{'form.pagepath'}) ? 'page'
 		                           : 'sequence';
@@ -1387,7 +1520,7 @@ sub editor {
     }
     
     my ($breadcrumbtrail,$randompick,$ishidden,$isencrypted,$plain,$is_random_order)=
-	&breadcrumbs($folder);
+	&breadcrumbs($allowed,$crstype);
     $r->print($breadcrumbtrail);
     
 # ------------------------------------------------------------ Process commands
@@ -1412,9 +1545,14 @@ sub editor {
 	}
 	    
 	if ($env{'form.pastemarked'}) {
-	    &do_paste_from_buffer($coursenum,$coursedom);
-	    ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
-	    return $errtext if ($fatal);
+            my $paste_res = 
+                &do_paste_from_buffer($coursenum,$coursedom,$folder);
+            if ($paste_res eq 'ok') {
+                ($errtext,$fatal) = &storemap($coursenum,$coursedom,$folder.'.'.$container);
+                return $errtext if ($fatal);
+            } elsif ($paste_res ne '') {
+                $r->print('<p><span class="LC_error">'.$paste_res.'</span></p>');
+            }
 	}
 
 	$r->print($upload_output);
@@ -1426,10 +1564,10 @@ sub editor {
 # Group import/search
 	if ($env{'form.importdetail'}) {
 	    my @imports;
-	    foreach (split(/\&/,$env{'form.importdetail'})) {
-		if (defined($_)) {
+	    foreach my $item (split(/\&/,$env{'form.importdetail'})) {
+		if (defined($item)) {
 		    my ($name,$url,$residx)=
-			map {&unescape($_)} split(/\=/,$_);
+			map {&unescape($_)} split(/\=/,$item);
 		    push(@imports, [$name, $url, $residx]);
 		}
 	    }
@@ -1481,7 +1619,7 @@ sub editor {
 	unless ($name) {  $name=(split(/\//,$url))[-1]; }
 	unless ($name) { $idx++; next; }
 	$r->print(&entryline($idx,$name,$url,$folder,$allowed,$res,
-			     $coursenum));
+			     $coursenum,$crstype));
 	$idx++;
 	$shown++;
     }
@@ -1489,8 +1627,9 @@ sub editor {
 	$r->print('<tr><td>'.&mt('Currently no documents.').'</td></tr>');
     }
     $r->print("\n</table>\n");
-    
-    &print_paste_buffer($r,$container);
+    if ($allowed) {
+        &print_paste_buffer($r,$container);
+    }
     return;
 }
 
@@ -1558,7 +1697,7 @@ sub process_file_upload {
             return 'failed';
         } else {
             if ($parseaction eq 'parse') {
-                my $total_embedded = keys(%{$allfiles});
+                my $total_embedded = scalar(keys(%{$allfiles}));
                 if ($total_embedded > 0) {
                     my $num = 0;
 		    my $state = '
@@ -1571,8 +1710,8 @@ sub process_file_upload {
 
                     $$upload_output .= 
 			'This file contains embedded multimedia objects, which need to be uploaded to LON-CAPA.<br />'.
-			&ask_for_embedded_content('/adm/coursedocs',
-						  $state,$allfiles,$codebase);
+			&Apache::loncommon::ask_for_embedded_content(
+                            '/adm/coursedocs',$state,$allfiles,$codebase);
                 } else {
                     $$upload_output .= 'No embedded items identified<br />';
                 }
@@ -1582,55 +1721,6 @@ sub process_file_upload {
     return $phase_status;
 }
 
-sub ask_for_embedded_content {
-    my ($actionurl,$state,$allfiles,$codebase,$args)=@_;
-    my $upload_output = '
-   <form name="upload_embedded" action="'.$actionurl.'"
-                  method="post" enctype="multipart/form-data">';
-    $upload_output .= $state;
-    $upload_output .= '<b>Upload embedded files</b>:<br />'.
-	&Apache::loncommon::start_data_table();
-
-    my $num = 0;
-    foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%{$allfiles})) {
-	$upload_output .= &Apache::loncommon::start_data_table_row().
-	    '<td>'.$embed_file.'</td><td>';
-	if ($args->{'ignore_remote_references'}
-	    && $embed_file =~ m{^\w+://}) {
-	    $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';
-	} elsif ($args->{'error_on_invalid_names'}
-	    && $embed_file ne &Apache::lonnet::clean_filename($embed_file,{'keep_path' => 1,})) {
-	    
-	    $upload_output.='<span class="LC_warning">'.&mt("Invalid characters").'</span>';
-	    
-	} else {
-
-	    $upload_output .='
-           <input name="embedded_item_'.$num.'" type="file" value="bob" />
-           <input name="embedded_orig_'.$num.'" type="hidden" value="'.&escape($embed_file).'" />';
-	    my $attrib = join(':',@{$$allfiles{$embed_file}});
-	    $upload_output .=
-		"\n\t\t".
-		'<input name="embedded_attrib_'.$num.'" type="hidden" value="'.
-		$attrib.'" />';
-	    if (exists($$codebase{$embed_file})) {
-		$upload_output .= 
-		    "\n\t\t".
-		    '<input name="codebase_'.$num.'" type="hidden" value="'.
-		    &escape($$codebase{$embed_file}).'" />';
-	    }
-	}
-	$upload_output .= '</td>'.&Apache::loncommon::end_data_table_row();
-	$num++;
-    }
-    $upload_output .= &Apache::loncommon::end_data_table().'<br />
-   <input type ="hidden" name="number_embedded_items" value="'.$num.'" />
-   <input type ="submit" value="'.&mt('Upload Listed Files').'" />
-   '.&mt('(only files for which a location has been provided will be uploaded)').'
-   </form>';
-    return $upload_output;
-}
-
 sub process_secondary_uploads {
     my ($upload_output,$coursedom,$coursenum,$formname,$num,$newidx) = @_;
     my $folder=$env{'form.folder'};
@@ -1668,6 +1758,7 @@ sub parse_supplemental_title {
 	$foldertitle=&Apache::lontexconvert::msgtexconverted($4);
 	my $name =  &Apache::loncommon::plainname($uname,$udom);
 	$name = &HTML::Entities::encode($name,'"<>&\'');
+        $renametitle = &HTML::Entities::encode($renametitle,'"<>&\'');
 	$title='<i>'.&Apache::lonlocal::locallocaltime($time).'</i> '.
 	    $name.': <br />'.$foldertitle;
     }
@@ -1680,7 +1771,7 @@ sub parse_supplemental_title {
 # --------------------------------------------------------------- An entry line
 
 sub entryline {
-    my ($index,$title,$url,$folder,$allowed,$residx,$coursenum)=@_;
+    my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
 
     my ($foldertitle,$pagetitle,$renametitle);
     if (&is_supplemental_title($title)) {
@@ -1733,7 +1824,7 @@ sub entryline {
 		'<select name="newpos" onChange="this.form.submit()">';
 	    for (my $i=1;$i<=$#LONCAPA::map::order+1;$i++) {
 		if ($i==$incindex) {
-		    $selectbox.='<option value="" selected="1">('.$i.')</option>';
+		    $selectbox.='<option value="" selected="selected">('.$i.')</option>';
 		} else {
 		    $selectbox.='<option value="'.$i.'">'.$i.'</option>';
 		}
@@ -1754,8 +1845,8 @@ sub entryline {
 		# no copy for published maps
 		$nocopy = 1;
 	    } else {
-		foreach (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
-		    my ($title,$url,$ext,$type)=split(/\:/,$_);
+		foreach my $item (&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$url),1)) {
+		    my ($title,$url,$ext,$type)=split(/\:/,$item);
 		    if (($url=~/\.(page|sequence)/) && ($type ne 'zombie')) {
 			$nocopy=1;
 			last;
@@ -1857,6 +1948,7 @@ END
     }
     
     my $orig_url = $url;
+    $orig_url=~s{http(&colon;|:)//https(&colon;|:)//}{https$2//};
     my $external = ($url=~s{^http(|s)(&colon;|:)//}{/adm/wrapper/ext/});
     if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
 	my $symb=&Apache::lonnet::symbclean(
@@ -1919,7 +2011,7 @@ END
     	my $ro_set=
 	    ((&LONCAPA::map::getparameter($orderidx,'parameter_randomorder'))[0]=~/^yes$/i?' checked="checked"':'');
 	$rand_order_text ='
-<nobr><label><input type="checkbox" name="randomorder_'.$orderidx.'" onClick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></nobr>';   
+<span class="LC_nobreak"><label><input type="checkbox" name="randomorder_'.$orderidx.'" onclick="this.form.changeparms.value=\'randomorder\';this.form.submit()" '.$ro_set.' /> '.&mt('Random Order').' </label></span>';   
     }
     if ($ispage) {
         my $pagename=&escape($pagetitle);
@@ -1945,30 +2037,36 @@ END
     } else {
 	undef($external);
     }
+    my $reinit;
+    if ($crstype eq 'Community') {
+        $reinit = &mt('(re-initialize community to access)');
+    } else {
+        $reinit = &mt('(re-initialize course to access)');
+    }  
     $line.='
   <td class="LC_docs_entry_icon">
     '.($url?'<a href="'.$url.'">':'').'<img src="'.$icon.'" alt="" class="LC_icon" />'.($url?'</a>':'').'
   </td>
   <td class="LC_docs_entry_title">
-    '.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.&mt('(re-initialize course to access)').'</span>').$external."
+    '.($url?"<a href=\"$url\">":'').$title.($url?'</a>':' <span class="LC_docs_reinit_warn">'.$reinit.'</span>').$external."
   </td>";
     if (($allowed) && ($folder!~/^supplemental/)) {
  	my %lt=&Apache::lonlocal::texthash(
  			      'hd' => 'Hidden',
  			      'ec' => 'URL hidden');
 	my $enctext=
-	    ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="1"':'');
+	    ((&LONCAPA::map::getparameter($orderidx,'parameter_encrypturl'))[0]=~/^yes$/i?' checked="checked"':'');
 	my $hidtext=
-	    ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="1"':'');
+	    ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i?' checked="checked"':'');
 	$line.=(<<ENDPARMS);
   <td class="LC_docs_entry_parameter">
     $form_start
-    <label><input type="checkbox" name="hiddenresource_$orderidx" onClick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
+    <label><input type="checkbox" name="hiddenresource_$orderidx" onclick="this.form.changeparms.value='hiddenresource';this.form.submit()" $hidtext /> $lt{'hd'}</label>
     $form_end
   </td>
   <td class="LC_docs_entry_parameter">
     $form_start
-    <label><input type="checkbox" name="encrypturl_$orderidx" onClick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
+    <label><input type="checkbox" name="encrypturl_$orderidx" onclick="this.form.changeparms.value='encrypturl';this.form.submit()" $enctext /> $lt{'ec'}</label>
     $form_end
   </td>
   <td class="LC_docs_entry_parameter">$form_start $rand_order_text $form_end</td>
@@ -1979,7 +2077,13 @@ ENDPARMS
     return $line;
 }
 
-# ---------------------------------------------------------------- tie the hash
+=pod
+
+=item tiehash()
+
+tie the hash
+
+=cut
 
 sub tiehash {
     my ($mode)=@_;
@@ -2005,7 +2109,8 @@ sub untiehash {
     return OK;
 }
 
-# --------------------------------------------------------------- check on this
+
+
 
 sub checkonthis {
     my ($r,$url,$level,$title)=@_;
@@ -2014,6 +2119,9 @@ sub checkonthis {
     $r->rflush();
     if (($url) && ($url!~/^\/uploaded\//) && ($url!~/\*$/)) {
        $r->print("\n<br />");
+       if ($level==0) {
+           $r->print("<br />");
+       }
        for (my $i=0;$i<=$level*5;$i++) {
            $r->print('&nbsp;');
        }
@@ -2023,7 +2131,7 @@ sub checkonthis {
 	  my $result=&Apache::lonnet::repcopy(
                               &Apache::lonnet::filelocation('',$url));
           if ($result eq 'ok') {
-             $r->print('<font color="green">'.&mt('ok').'</font>');
+             $r->print('<span class="LC_success">'.&mt('ok').'</span>');
              $r->rflush();
              &Apache::lonnet::countacc($url);
              $url=~/\.(\w+)$/;
@@ -2033,7 +2141,7 @@ sub checkonthis {
                  for (my $i=0;$i<=$level*5;$i++) {
                      $r->print('&nbsp;');
                  }
-                 $r->print('- '.&mt('Rendering').': ');
+                 $r->print('- '.&mt('Rendering:').' ');
 		 my ($errorcount,$warningcount)=split(/:/,
 	       &Apache::lonnet::ssi_body($url,
 			       ('grade_target'=>'web',
@@ -2041,14 +2149,12 @@ sub checkonthis {
                  if (($errorcount) ||
                      ($warningcount)) {
 		     if ($errorcount) {
-                        $r->print('<img src="/adm/lonMisc/bomb.gif" /><span class="LC_error">'.
-			  $errorcount.' '.
-				  &mt('error(s)').'</span> ');
+                        $r->print('<img src="/adm/lonMisc/bomb.gif" alt="'.&mt('bomb').'" /><span class="LC_error">'.
+                          &mt('[quant,_1,error]',$errorcount).'</span>');
                      }
 		     if ($warningcount) {
                         $r->print('<span class="LC_warning">'.
-			  $warningcount.' '.
-				  &mt('warning(s)').'</span>');
+                          &mt('[quant,_1,warning]',$warningcount).'</span>');
                      }
                  } else {
                      $r->print('<span class="LC_success">'.&mt('ok').'</span>');
@@ -2057,70 +2163,82 @@ sub checkonthis {
              }
 	     my $dependencies=
                 &Apache::lonnet::metadata($url,'dependencies');
-             foreach (split(/\,/,$dependencies)) {
-		 if (($_=~/^\/res\//) && (!$alreadyseen{$_})) {
-                    &checkonthis($r,$_,$level+1);
+             foreach my $dep (split(/\,/,$dependencies)) {
+		 if (($dep=~/^\/res\//) && (!$alreadyseen{$dep})) {
+                    &checkonthis($r,$dep,$level+1);
                  }
              }
           } elsif ($result eq 'unavailable') {
              $r->print('<span class="LC_error">'.&mt('connection down').'</span>');
           } elsif ($result eq 'not_found') {
 	      unless ($url=~/\$/) {
-		  $r->print('<span class="LC_error">'.&mt('not found').'</b></font>');
+		  $r->print('<span class="LC_error">'.&mt('not found').'</b></span>');
 	      } else {
-		  $r->print('<span class="LC_unknown">'.&mt('unable to verify variable URL').'</span>');
+		  $r->print('<span class="LC_error">'.&mt('unable to verify variable URL').'</span>');
 	      }
           } else {
              $r->print('<span class="LC_error">'.&mt('access denied').'</span>');
           }
-      }
-   }
+       }
+    }
 }
 
 
-#
-# ----------------------------------------------------------------- List Symbs
-# 
+
+=pod
+
+=item list_symbs()
+
+List Symbs
+
+=cut
+
 sub list_symbs {
     my ($r) = @_;
 
+    my $crstype = &Apache::loncommon::course_type();
     $r->print(&Apache::loncommon::start_page('Symb List'));
     $r->print(&Apache::lonhtmlcommon::breadcrumbs('Symb List'));
     my $navmap = Apache::lonnavmaps::navmap->new();
-    $r->print("<pre>\n");
-    foreach my $res ($navmap->retrieveResources()) {
-	$r->print($res->compTitle()."\t".$res->symb()."\n");
+    if (!defined($navmap)) {
+        $r->print('<h2>'.&mt('Retrieval of List Failed').'</h2>'.
+                  '<div class="LC_error">'.
+                  &mt('Unable to retrieve information about course contents').
+                  '</div>');
+        &Apache::lonnet::logthis('Symb list failed - could not create navmap object in '.lc($crstype).':'.$env{'request.course.id'});
+    } else {
+        $r->print("<pre>\n");
+        foreach my $res ($navmap->retrieveResources()) {
+	    $r->print($res->compTitle()."\t".$res->symb()."\n");
+        }
+        $r->print("\n</pre>\n");
     }
-    $r->print("\n</pre>\n");
     $r->print('<a href="/adm/coursedocs">'.&mt('Return to DOCS').'</a>');
 }
 
 
-#
-# -------------------------------------------------------------- Verify Content
-# 
 sub verifycontent {
     my ($r) = @_;
-    my $type = &Apache::loncommon::course_type();
+    my $crstype = &Apache::loncommon::course_type();
    my $loaderror=&Apache::lonnet::overloaderror($r);
    if ($loaderror) { return $loaderror; }
-   $r->print(&Apache::loncommon::start_page('Verify '.$type.' Documents'));
-   $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$type.' Documents'));
+   $r->print(&Apache::loncommon::start_page('Verify '.$crstype.' Documents'));
+   $r->print(&Apache::lonhtmlcommon::breadcrumbs('Verify '.$crstype.' Documents'));
    $hashtied=0;
    undef %alreadyseen;
    %alreadyseen=();
    &tiehash();
-   foreach (keys %hash) {
-       if ($hash{$_}=~/\.(page|sequence)$/) {
-	   if (($_=~/^src_/) && ($alreadyseen{&unescape($hash{$_})})) {
+   foreach my $key (keys(%hash)) {
+       if ($hash{$key}=~/\.(page|sequence)$/) {
+	   if (($key=~/^src_/) && ($alreadyseen{&unescape($hash{$key})})) {
 	       $r->print('<hr /><span class="LC_error">'.
-			 &mt('The following sequence or page is included more than once in your '.$type.': ').
-			 &unescape($hash{$_}).'</span><br />'.
+                         &mt('The following sequence or page is included more than once in your '.$crstype.': ').
+			 &unescape($hash{$key}).'</span><br />'.
 			 &mt('Note that grading records for problems included in this sequence or folder will overlap.<hr />'));
 	   }
        }
-       if (($_=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$_})})) {
-           &checkonthis($r,$hash{$_},0,$hash{'title_'.$1});
+       if (($key=~/^src\_(.+)$/) && (!$alreadyseen{&unescape($hash{$key})})) {
+           &checkonthis($r,$hash{$key},0,$hash{'title_'.$1});
        }
    }
    &untiehash();
@@ -2129,8 +2247,6 @@ sub verifycontent {
 }
 
 
-# -------------------------------------------------------------- Check Versions
-
 sub devalidateversioncache {
     my $src=shift;
     &Apache::lonnet::devalidate_cache_new('courseresversion',$env{'request.course.id'}.'_'.
@@ -2139,9 +2255,9 @@ sub devalidateversioncache {
 
 sub checkversions {
     my ($r) = @_;
-    my $type = &Apache::loncommon::course_type();
-    $r->print(&Apache::loncommon::start_page("Check $type Document Versions"));
-    $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $type Document Versions"));
+    my $crstype = &Apache::loncommon::course_type();
+    $r->print(&Apache::loncommon::start_page("Check $crstype Document Versions"));
+    $r->print(&Apache::lonhtmlcommon::breadcrumbs("Check $crstype Document Versions"));
     my $header='';
     my $startsel='';
     my $monthsel='';
@@ -2160,16 +2276,16 @@ sub checkversions {
     my %newsetversions=();
     if ($env{'form.setmostrecent'}) {
 	$haschanged=1;
-	foreach (keys %hash) {
-	    if ($_=~/^ids\_(\/res\/.+)$/) {
+	foreach my $key (keys(%hash)) {
+	    if ($key=~/^ids\_(\/res\/.+)$/) {
 		$newsetversions{$1}='mostrecent';
                 &devalidateversioncache($1);
 	    }
 	}
     } elsif ($env{'form.setcurrent'}) {
 	$haschanged=1;
-	foreach (keys %hash) {
-	    if ($_=~/^ids\_(\/res\/.+)$/) {
+	foreach my $key (keys(%hash)) {
+	    if ($key=~/^ids\_(\/res\/.+)$/) {
 		my $getvers=&Apache::lonnet::getversion($1);
 		if ($getvers>0) {
 		    $newsetversions{$1}=$getvers;
@@ -2179,11 +2295,11 @@ sub checkversions {
 	}
     } elsif ($env{'form.setversions'}) {
 	$haschanged=1;
-	foreach (keys %env) {
-	    if ($_=~/^form\.set_version_(.+)$/) {
+	foreach my $key (keys(%env)) {
+	    if ($key=~/^form\.set_version_(.+)$/) {
 		my $src=$1;
-		if (($env{$_}) && ($env{$_} ne $setversions{$src})) {
-		    $newsetversions{$src}=$env{$_};
+		if (($env{$key}) && ($env{$key} ne $setversions{$src})) {
+		    $newsetversions{$src}=$env{$key};
 		    &devalidateversioncache($src);
 		}
 	    }
@@ -2202,10 +2318,10 @@ sub checkversions {
     &changewarning($r,'');
     if ($env{'form.timerange'} eq 'all') {
 # show all documents
-	$header=&mt('All Documents in '.$type);
+        $header=&mt('All Documents in '.$crstype);
 	$allsel=1;
-	foreach (keys %hash) {
-	    if ($_=~/^ids\_(\/res\/.+)$/) {
+	foreach my $key (keys(%hash)) {
+	    if ($key=~/^ids\_(\/res\/.+)$/) {
 		my $src=$1;
 		$changes{$src}=1;
 	    }
@@ -2215,7 +2331,7 @@ sub checkversions {
 	%changes=&Apache::lonnet::dump
 	 ('versionupdate',$env{'course.'.$env{'request.course.id'}.'.domain'},
                      $env{'course.'.$env{'request.course.id'}.'.num'});
-	my $firstkey=(keys %changes)[0];
+	my $firstkey=(keys(%changes))[0];
 	unless ($firstkey=~/^error\:/) {
 	    unless ($env{'form.timerange'}) {
 		$env{'form.timerange'}=604800;
@@ -2247,7 +2363,7 @@ sub checkversions {
 			  $env{'course.'.$env{'request.course.id'}.'.domain'},
 			  $env{'course.'.$env{'request.course.id'}.'.num'});
     my %lt=&Apache::lonlocal::texthash
-	      ('st' => 'Version changes since start of '.$type,
+              ('st' => 'Version changes since start of '.$crstype,
 	       'lm' => 'Version changes since last Month',
 	       'lw' => 'Version changes since last Week',
 	       'sy' => 'Version changes since Yesterday',
@@ -2256,9 +2372,9 @@ sub checkversions {
 	       'fi' => 'File',
 	       'md' => 'Modification Date',
                'mr' => 'Most recently published Version',
-	       've' => 'Version used in '.$type,
-               'vu' => 'Set Version to be used in '.$type,
-'sv' => 'Set Versions to be used in '.$type.' according to Selections below',
+	       've' => 'Version used in '.$crstype,
+               'vu' => 'Set Version to be used in '.$crstype,
+'sv' => 'Set Versions to be used in '.$crstype.' according to Selections below',
 'sm' => 'Keep all Resources up-to-date with most recent Versions (default)',
 'sc' => 'Set all Resource Versions to current Version (Fix Versions)',
 	       'di' => 'Differences');
@@ -2279,14 +2395,14 @@ sub checkversions {
 <input type="submit" name="setversions" value="$lt{'sv'}" />
 <table border="0">
 ENDHEADERS
-    foreach (sort keys %changes) {
-	if ($changes{$_}>$starttime) {
-	    my ($root,$extension)=($_=~/^(.*)\.(\w+)$/);
-	    my $currentversion=&Apache::lonnet::getversion($_);
+    foreach my $key (sort(keys(%changes))) {
+	if ($changes{$key}>$starttime) {
+	    my ($root,$extension)=($key=~/^(.*)\.(\w+)$/);
+	    my $currentversion=&Apache::lonnet::getversion($key);
 	    if ($currentversion<0) {
 		$currentversion=&mt('Could not be determined.');
 	    }
-	    my $linkurl=&Apache::lonnet::clutter($_);
+	    my $linkurl=&Apache::lonnet::clutter($key);
 	    $r->print(
 		      '<tr><td colspan="5"><br /><br /><font size="+1"><b>'.
 		      &Apache::lonnet::gettitle($linkurl).
@@ -2305,7 +2421,7 @@ ENDHEADERS
                       '<td title="'.$lt{'mr'}.'"><span class="LC_nobreak">Most Recent: '.
                       '<font size="+1">'.$currentversion.'</font>'.
                       '</span></td>'.
-                      '<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$type.': '.
+                      '<td title="'.$lt{'ve'}.'"><span class="LC_nobreak">In '.$crstype.': '.
                       '<font size="+1">');
 # Used in course
 	    my $usedversion=$hash{'version_'.$linkurl};
@@ -2322,7 +2438,7 @@ ENDHEADERS
 						      ('select_form_order' =>
 						       ['',1..$currentversion,'mostrecent'],
 						       '' => '',
-						       'mostrecent' => 'most recent',
+						       'mostrecent' => &mt('most recent'),
 						       map {$_,$_} (1..$currentversion))));
 	    $r->print('</span></td></tr><tr><td></td>');
 	    my $lastold=1;
@@ -2423,23 +2539,27 @@ sub changewarning {
 	$message='Changes will become active for your current session after [_1], or the next time you log in.';
     }
     $r->print("\n\n".
-'<script type="text/javascript">function reinit(tf) { tf.submit();'.$postexec.' }</script>'."\n". 
+'<script type="text/javascript">'."\n".
+'// <![CDATA['."\n".
+'function reinit(tf) { tf.submit();'.$postexec.' }'."\n".
+'// ]]>'."\n".
+'</script>'."\n".
 '<form name="reinitform" method="post" action="/adm/roles" target="loncapaclient">'.
 '<input type="hidden" name="orgurl" value="'.$url.
-'" /><input type="hidden" name="selectrole" value="1" /><h3><span class="LC_warning">'.
+'" /><input type="hidden" name="selectrole" value="1" /><p class="LC_warning">'.
 &mt($message,' <input type="hidden" name="'.
     $env{'request.role'}.'" value="1" /><input type="button" value="'.
-    &mt('re-initializing '.$course_type).'" onClick="reinit(this.form)" />').
-$help{'Caching'}.'</span></h3></form>'."\n\n");
+    &mt('re-initializing '.$course_type).'" onclick="reinit(this.form)" />').
+$help{'Caching'}.'</p></form>'."\n\n");
+
 }
 
-# =========================================== Breadcrumbs for special functions
 
 sub init_breadcrumbs {
     my ($form,$text)=@_;
     &Apache::lonhtmlcommon::clear_breadcrumbs();
     &Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/coursedocs",
-					    text=>"Edit ".&Apache::loncommon::course_type(),
+					    text=>&Apache::loncommon::course_type().' Editor',
 					    faq=>273,
 					    bug=>'Instructor Interface',
                                             help => 'Docs_Adding_Course_Doc'});
@@ -2449,22 +2569,24 @@ sub init_breadcrumbs {
 					    bug=>'Instructor Interface'});
 }
 
-# ================================================================ Main Handler
+
+
+
 sub handler {
     my $r = shift;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
     return OK if $r->header_only;
-    my $type = &Apache::loncommon::course_type();
+    my $crstype = &Apache::loncommon::course_type();
 
 # --------------------------------------------- Initialize help topics for this
-    foreach ('Adding_Course_Doc','Main_Course_Documents',
-	     'Adding_External_Resource','Navigate_Content',
-	     'Adding_Folders','Docs_Overview', 'Load_Map',
-	     'Supplemental','Score_Upload_Form','Adding_Pages',
-	     'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
-	     'Check_Resource_Versions','Verify_Content') {
-	$help{$_}=&Apache::loncommon::help_open_topic('Docs_'.$_);
+    foreach my $topic ('Adding_Course_Doc','Main_Course_Documents',
+	               'Adding_External_Resource','Navigate_Content',
+	               'Adding_Folders','Docs_Overview', 'Load_Map',
+	               'Supplemental','Score_Upload_Form','Adding_Pages',
+	               'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+	               'Check_Resource_Versions','Verify_Content') {
+	$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
     }
     # Composite help files
     $help{'Syllabus'} = &Apache::loncommon::help_open_topic(
@@ -2498,7 +2620,7 @@ sub handler {
       &init_breadcrumbs('dumpcourse','Dump '.&Apache::loncommon::course_type().' DOCS to Construction Space');
       &dumpcourse($r);
   } elsif ($allowed && $env{'form.exportcourse'}) {
-      &init_breadcrumbs('exportcourse','Export '.&Apache::loncommon::course_type().' to IMS');
+      &init_breadcrumbs('exportcourse','IMS Export');
       &exportcourse($r);
   } else {
 # is this a standard course?
@@ -2513,6 +2635,26 @@ sub handler {
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
 					    ['folderpath','pagepath',
 					     'pagesymb']);
+# No folderpath, no pagepath, see if we have something stored
+    if ((!$env{'form.folderpath'}) && (!$env{'form.pagepath'})) {
+        &Apache::loncommon::restore_course_settings('docs_folderpath',
+                                              {'folderpath' => 'scalar'});
+    }
+    if (!$env{'form.folderpath'}) {
+        &Apache::loncommon::restore_course_settings('docs_folderpath',
+                                              {'pagepath' => 'scalar'});
+    }
+    if ($env{'form.pagepath'}) {
+       $env{'form.folderpath'}='';
+    }
+    if ($env{'form.folderpath'} =~ /^supplemental_\d+/) {
+        $env{'form.folderpath'} = 'supplemental&'.
+                                  &escape(&mt('Supplemental '.$crstype.' Documents')).'&'.
+                                  $env{'form.folderpath'};
+    }
+    &Apache::loncommon::store_course_settings('docs_folderpath',
+                                                {'pagepath' => 'scalar',
+                                                 'folderpath' => 'scalar'});
     if ($env{'form.folderpath'}) {
 	my (@folderpath)=split('&',$env{'form.folderpath'});
 	$env{'form.foldername'}=&unescape(pop(@folderpath));
@@ -2562,9 +2704,15 @@ sub handler {
 	$script .= &editing_js($udom,$uname);
     }
 # -------------------------------------------------------------------- Body tag
-    $script = '<script type="text/javascript">'."\n".$script."\n".'</script>';
-    $r->print(&Apache::loncommon::start_page("$type Documents", $script,
-					     {'force_register' => $showdoc,}).
+    $script = '<script type="text/javascript">'."\n"
+              .'// <![CDATA['."\n"
+              .$script."\n"
+              .'// ]]>'."\n"
+              .'</script>'."\n";
+    my $brcrum = [{href=>"/adm/createuser",text=>"$crstype Documents"}];
+    $r->print(&Apache::loncommon::start_page("$crstype Documents", $script,
+				    {'force_register' => $showdoc,
+                                     'bread_crumbs' => $brcrum}).
 	      &Apache::loncommon::help_open_menu('','',273,'RAT'));
   
   my %allfiles = ();
@@ -2603,12 +2751,12 @@ sub handler {
                   }
                   my @attributes = ();
                   if ($env{'form.embedded_attrib_'.$i} =~ /:/) {
-                      @attributes = split/:/,$env{'form.embedded_attrib_'.$i};
+                      @attributes = split(/:/,$env{'form.embedded_attrib_'.$i});
                   } else {
                       @attributes = ($env{'form.embedded_attrib_'.$i});
                   }
-                  foreach (@attributes) {
-                      push(@{$attribs{$i}},&unescape($_));
+                  foreach my $attr (@attributes) {
+                      push(@{$attribs{$i}},&unescape($attr));
                   }
                   if ($javacodebase) {
                       $codebase{$i} = $javacodebase;
@@ -2626,7 +2774,7 @@ sub handler {
               my $updateflag = 0;
               my $getstatus = &Apache::lonnet::getuploaded('GET',$primary_url,$coursedom,$coursenum,\$content,\$rtncode);
               if ($getstatus eq 'ok') {
-                  foreach my $item (keys %newname) {
+                  foreach my $item (keys(%newname)) {
                       if ($newname{$item} ne $origname{$item}) {
                           my $attrib_regexp = '';
                           if (@{$attribs{$item}} > 1) {
@@ -2657,8 +2805,8 @@ sub handler {
   unless ($showdoc ||  $upload_result eq 'phasetwo') {
 # -----------------------------------------------------------------------------
        my %lt=&Apache::lonlocal::texthash(
-                'uplm' => 'Upload a new main '.lc($type).' document',
-                'upls' => 'Upload a new supplemental '.lc($type).' document',
+                'uplm' => 'Upload a new main '.lc($crstype).' document',
+                'upls' => 'Upload a new supplemental '.lc($crstype).' document',
                 'impp' => 'Import a document',
                 'pubd' => 'Published documents',
 		'copm' => 'All documents out of a published map into this folder',
@@ -2675,22 +2823,33 @@ sub handler {
                 'extr' => 'External Resource',
                 'syll' => 'Syllabus',
                 'navc' => 'Navigate Contents',
-                'sipa' => 'Simple Page',
+                'sipa' => 'Simple Course Page',
                 'sipr' => 'Simple Problem',
                 'drbx' => 'Drop Box',
                 'scuf' => 'Score Upload Form',
-                'bull' => 'Bulletin Board',
-                'mypi' => 'My Personal Info',
-                'grpo' => 'Group Files',
+                'bull' => 'Discussion Board',
+                'mypi' => 'My Personal Information Page',
+                'grpo' => 'Group Portfolios',
                 'rost' => 'Course Roster',
 		'abou' => 'About User',
-                'imsf' => 'Import IMS package',
+                'imsf' => 'IMS Import',
+                'imsl' => 'Import IMS package',
                 'file' =>  'File',
                 'title' => 'Title',
                 'comment' => 'Comment',
                 'parse' => 'If HTML file, upload embedded images/multimedia files'
 					  );
 # -----------------------------------------------------------------------------
+    my %tabtitles = (
+                       main => {
+                                 Course => &mt('Main Course Documents'),
+                                 Community => &mt('Main Community Documents'),
+                               },
+                       supplemental => {
+                                 Course => &mt('Supplemental Course Documents'),        
+                                 Community => &mt('Supplemental Community Documents'),
+                               },
+                    );
     if ($allowed) {
 	&update_paste_buffer($coursenum,$coursedom);
        my $dumpbut=&dumpbutton();
@@ -2706,8 +2865,7 @@ sub handler {
        if (!$folderpath) {
 	   if ($env{'form.folder'} eq '' ||
 	       $env{'form.folder'} eq 'supplemental') {
-	       $folderpath='default&'.
-		   &escape(&mt('Main '.$type.' Documents'));
+	       $folderpath='default&'.&escape($tabtitles{'main'}{$crstype});
 	   }
        }
        unless ($env{'form.pagepath'}) {
@@ -2750,7 +2908,7 @@ sub handler {
 <div style="clear: both; height: 0px;">&nbsp;</div>
 ENDCOURSEVERIFY
        $r->print(&Apache::loncommon::help_open_topic('Docs_Adding_Course_Doc',
-		     &mt('Editing the Table of Contents for your '.$type)));
+		     &mt('Editing the Table of Contents for your '.$crstype)));
     }
 # --------------------------------------------------------- Standard documents
     $r->print('<table class="LC_docs_documents">');
@@ -2762,24 +2920,29 @@ ENDCOURSEVERIFY
        my $folder=$env{'form.folder'};
        if ($folder eq '' || $folder eq 'supplemental') {
            $folder='default';
-	   $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$type.' Documents'));
+	   $env{'form.folderpath'}='default&'.&escape(&mt('Main '.$crstype.' Documents'));
            $uploadtag = '<input type="hidden" name="folderpath" value="'.
 	       &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
        }
        my $postexec='';
        if ($folder eq 'default') {
-	   $r->print('<script type="text/javascript">this.window.name="loncapaclient";</script>');
+           $r->print('<script type="text/javascript">'."\n"
+                    .'// <![CDATA['."\n"
+                    .'this.window.name="loncapaclient";'."\n"
+                    .'// ]]>'."\n"
+                    .'</script>'."\n"
+       );
        } else {
            #$postexec='self.close();';
        }
        $hadchanges=0;
        my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,
-			   $upload_output);
+			   $upload_output,$crstype);
        if ($error) {
 	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }
        if ($hadchanges) {
-	   &mark_hash_old()
+	   &mark_hash_old();
        }
        &changewarning($r,$postexec);
        my $folderseq='/uploaded/'.$coursedom.'/'.$coursenum.'/default_'.time.
@@ -2811,7 +2974,7 @@ $uploadtag
 <br />
 <span class="LC_nobreak">
 <label>$lt{'parse'}?
-<input type="checkbox" name="parserflag" />
+<input type="checkbox" name="parserflag" checked="checked" />
 </label>
 </span>
 <br />
@@ -2826,27 +2989,27 @@ $uploadtag
 <form action="/adm/coursedocs" method="post" name="simpleeditdefault">
 $lt{'pubd'}<br />
 $uploadtag
-<input type="button" onClick="javascript:groupsearch()" value="$lt{'srch'}" />
+<input type="button" onclick="javascript:groupsearch()" value="$lt{'srch'}" />
 <br />
 <span class="LC_nobreak">
-<input type="button" onClick="javascript:groupimport();" value="$lt{'impo'}" />
+<input type="button" onclick="javascript:groupimport();" value="$lt{'impo'}" />
 $help{'Importing_LON-CAPA_Resource'}
 </span>
 <br />
-<input type="button" onClick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
+<input type="button" onclick="javascript:groupopen(0,1,1);" value="$lt{'book'}" />
 <hr />
 <p>
 $lt{'copm'}<br />
 <input type="text" size="40" name="importmap" /><br />
 <span class="LC_nobreak"><input type="button" 
-onClick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
+onclick="javascript:openbrowser('simpleeditdefault','importmap','sequence,page','')"
 value="$lt{'selm'}" /> <input type="submit" name="loadmap" value="$lt{'load'}" />
 $help{'Load_Map'}</span>
 </p>
 </form>
 <hr />
 <form action="/adm/groupsort" method="post" name="recover">
-<input type="button" name="recovermap" onClick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
+<input type="button" name="recovermap" onclick="javascript:groupopen('$readfile',1,0)" value="$lt{'reco'}" />
 </form>
 ENDFORM
        unless ($env{'form.pagepath'}) {
@@ -2856,13 +3019,13 @@ ENDFORM
 $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
-<input name="newext" type="button" onClick="javascript:makenewext('newext');"
+<input name="newext" type="button" onclick="javascript:makenewext('newext');"
 value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 </span>
 </form>
 <br /><form action="/adm/imsimportdocs" method="post" name="ims">
 <input type="hidden" name="folder" value="$folder" />
-<input name="imsimport" type="button" value="$lt{'imsf'}" onClick="javascript:makeims();" />
+<input name="imsimport" type="button" value="$lt{'imsf'}" title="$lt{imsl}" onclick="javascript:makeims();" />
 </form>
 ENDFORM
        }
@@ -2875,7 +3038,7 @@ ENDFORM
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newfolder" type="button"
-onClick="javascript:makenewfolder(this.form,'$folderseq');"
+onclick="javascript:makenewfolder(this.form,'$folderseq');"
 value="$lt{'newf'}" />$help{'Adding_Folders'}
 </span>
 </form>
@@ -2884,14 +3047,14 @@ value="$lt{'newf'}" />$help{'Adding_Fold
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newpage" type="button"
-onClick="javascript:makenewpage(this.form,'$pageseq');"
+onclick="javascript:makenewpage(this.form,'$pageseq');"
 value="$lt{'newp'}" />$help{'Adding_Pages'}
 </span>
 </form>
 <br /><form action="/adm/coursedocs" method="post" name="newsyl">
 $uploadtag
 <input type="hidden" name="importdetail" 
-value="Syllabus=/public/$coursedom/$coursenum/syllabus" />
+value="$lt{'syll'}=/public/$coursedom/$coursenum/syllabus" />
 <span class="LC_nobreak">
 <input name="newsyl" type="submit" value="$lt{'syll'}" /> 
  $help{'Syllabus'}
@@ -2900,7 +3063,7 @@ value="Syllabus=/public/$coursedom/$cour
 <br /><form action="/adm/coursedocs" method="post" name="newnav">
 $uploadtag
 <input type="hidden" name="importdetail" 
-value="Navigate Content=/adm/navmaps" />
+value="$lt{'navc'}=/adm/navmaps" />
 <span class="LC_nobreak">
 <input name="newnav" type="submit" value="$lt{'navc'}" />
 $help{'Navigate_Content'}
@@ -2911,7 +3074,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newsmppg" type="button" value="$lt{'sipa'}"
-onClick="javascript:makesmppage();" /> $help{'Simple Page'}
+onclick="javascript:makesmppage();" /> $help{'Simple Page'}
 </span>
 </form>
 <br /><form action="/adm/coursedocs" method="post" name="newsmpproblem">
@@ -2919,7 +3082,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
-onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
+onclick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 </span>
 </form>
 <br /><form action="/adm/coursedocs" method="post" name="newdropbox">
@@ -2927,7 +3090,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">          
 <input name="newdropbox" type="button" value="$lt{'drbx'}"
-onClick="javascript:makedropbox();" />
+onclick="javascript:makedropbox();" />
 </span>         
 </form> 
 <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
@@ -2935,7 +3098,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newexamupload" type="button" value="$lt{'scuf'}"
-onClick="javascript:makeexamupload();" />
+onclick="javascript:makeexamupload();" />
 $help{'Score_Upload_Form'}
 </span>
 </form>
@@ -2944,7 +3107,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newbulletin" type="button" value="$lt{'bull'}"
-onClick="javascript:makebulboard();" />
+onclick="javascript:makebulboard();" />
 $help{'Bulletin Board'}
 </span>
 </form>
@@ -2962,13 +3125,13 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newaboutsomeone" type="button" value="$lt{'abou'}" 
-onClick="javascript:makeabout();" />
+onclick="javascript:makeabout();" />
 </span>
 </form>
 <br /><form action="/adm/coursedocs" method="post" name="newgroupfiles">
 $uploadtag
 <input type="hidden" name="importdetail"
-value="Group Files=/adm/$coursedom/$coursenum/aboutme" />
+value="$lt{'grpo'}=/adm/$coursedom/$coursenum/aboutme" />
 <span class="LC_nobreak">
 <input name="newgroupfiles" type="submit" value="$lt{'grpo'}" />
 $help{'Group Files'}
@@ -2977,7 +3140,7 @@ $help{'Group Files'}
 <br /><form action="/adm/coursedocs" method="post" name="newroster">
 $uploadtag
 <input type="hidden" name="importdetail" 
-value="Course Roster=/adm/viewclasslist" />
+value="$lt{'rost'}=/adm/viewclasslist" />
 <span class="LC_nobreak">
 <input name="newroster" type="submit" value="$lt{'rost'}" />
 $help{'Course Roster'}
@@ -2992,7 +3155,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newsmpproblem" type="button" value="$lt{'sipr'}"
-onClick="javascript:makesmpproblem();" />$help{'Simple Problem'}
+onclick="javascript:makesmpproblem();" />$help{'Simple Problem'}
 </span>
 </form>
 <br /><form action="/adm/coursedocs" method="post" name="newexamupload">
@@ -3000,7 +3163,7 @@ $uploadtag
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newexamupload" type="button" value="$lt{'scuf'}"
-onClick="javascript:makeexamupload();" />
+onclick="javascript:makeexamupload();" />
 $help{'Score_Upload_Form'}
 </span>
 </form>
@@ -3020,11 +3183,11 @@ ENDBLOCK
 	   $folder='supplemental';
        }
        if ($folder =~ /^supplemental$/ &&
-	   $env{'form.folderpath'} =~ /^default\&/) {
-	   $env{'form.folderpath'}='supplemental&'.
-	       &escape(&mt('Supplemental '.$type.' Documents'));
+	   (($env{'form.folderpath'} =~ /^default\&/) || ($env{'form.folderpath'} eq ''))) {
+          $env{'form.folderpath'} = 'supplemental&'.
+                                    &escape($tabtitles{'supplemental'}{$crstype});
        }
-       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed);
+       my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype);
        if ($error) {
 	   $r->print('<p><span class="LC_error">'.$error.'</span></p>');
        }
@@ -3051,7 +3214,7 @@ ENDBLOCK
 </span>
 <br /><br />
 $lt{'comment'}:<br />
-<textarea cols=50 rows=4 name='comment'>
+<textarea cols="50" rows="4" name="comment">
 </textarea>
 <br />
 <input type="hidden" name="folderpath" value="$path" />
@@ -3068,7 +3231,7 @@ $lt{'comment'}:<br />
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newfolder" type="button"
-onClick="javascript:makenewfolder(this.form,'$folderseq');"
+onclick="javascript:makenewfolder(this.form,'$folderseq');"
 value="$lt{'newf'}" /> $help{'Adding_Folders'}
 </span>
 </form>
@@ -3077,7 +3240,7 @@ value="$lt{'newf'}" /> $help{'Adding_Fol
 <input type="hidden" name="importdetail" value="" />
 <span class="LC_nobreak">
 <input name="newext" type="button" 
-onClick="javascript:makenewext('supnewext');"
+onclick="javascript:makenewext('supnewext');"
 value="$lt{'extr'}" /> $help{'Adding_External_Resource'}
 </span>
 </form>
@@ -3137,11 +3300,11 @@ sub editing_js {
                                           t_mnf => 'New Folder',
                                           p_mnp => 'Name of New Page',
                                           t_mnp => 'New Page',
-                                          p_mxu => 'Listed Title for the Uploaded Score',
-                                          p_msp => 'Listed Title for the Page',
-                                          p_msb => 'Listed Title for the Problem',
-                                          p_mdb => 'Listed Title for the Drop Box',
-                                          p_mbb => 'Listed Title for the Bulletin Board',
+                                          p_mxu => 'Title for the Uploaded Score',
+                                          p_msp => 'Name of the Simple Course Page',
+                                          p_msb => 'Title for the Problem',
+                                          p_mdb => 'Title for the Drop Box',
+                                          p_mbb => 'Title for the Discussion Board',
                                           p_mab => "Enter user:domain for User's 'About Me' Page",
                                           p_mab2 => "About [_99]",
                                           p_mab_alrt1 => 'Not a valid user:domain',
@@ -3334,3 +3497,126 @@ ENDNEWSCRIPT
 }
 1;
 __END__
+
+
+=head1 NAME
+
+Apache::londocs.pm
+
+=head1 SYNOPSIS
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=item %help=()
+
+Available help topics
+
+=item mapread()
+
+Mapread read maps into LONCAPA::map:: global arrays 
+@order and @resources, determines status
+sets @order - pointer to resources in right order
+sets @resources - array with the resources with correct idx
+
+=item authorhosts()
+
+Return hash with valid author names
+
+=item dumpbutton()
+
+Generate "dump" button
+
+=item clean()
+
+=item dumpcourse()
+
+    Actually dump course
+
+
+=item exportbutton()
+
+    Generate "export" button
+
+=item exportcourse()
+
+=item create_ims_store()
+
+=item build_package()
+
+=item get_dependencies()
+
+=item process_content()
+
+=item replicate_content()
+
+=item extract_media()
+
+=item store_template()
+
+=item group_import()
+
+    Imports the given (name, url) resources into the course
+    coursenum, coursedom, and folder must precede the list
+
+=item breadcrumbs()
+
+=item log_docs()
+
+=item docs_change_log()
+
+=item update_paste_buffer()
+
+=item print_paste_buffer()
+
+=item do_paste_from_buffer()
+
+=item update_parameter()
+
+=item handle_edit_cmd()
+
+=item editor()
+
+=item process_file_upload()
+
+=item process_secondary_uploads()
+
+=item is_supplemental_title()
+
+=item parse_supplemental_title()
+
+=item entryline()
+
+=item tiehash()
+
+=item untiehash()
+
+=item checkonthis()
+
+check on this
+
+=item verifycontent()
+
+Verify Content
+
+=item devalidateversioncache() & checkversions()
+
+Check Versions
+
+=item mark_hash_old()
+
+=item is_hash_old()
+
+=item changewarning()
+
+=item init_breadcrumbs()
+
+Breadcrumbs for special functions
+
+=back
+
+=cut