--- loncom/interface/loncommon.pm	2013/04/11 15:30:37	1.1121
+++ loncom/interface/loncommon.pm	2013/05/25 21:56:23	1.1130
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1121 2013/04/11 15:30:37 raeburn Exp $
+# $Id: loncommon.pm,v 1.1130 2013/05/25 21:56:23 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -5155,16 +5155,12 @@ sub bodytag {
     my $bodytag = "<body $extra_body_attr>".
 	&Apache::lontexconvert::init_math_support($args->{'inherit_jsmath'});
 
-    if ($bodyonly) {
+    if (($bodyonly) || ($no_nav_bar) || ($env{'form.inhibitmenu'} eq 'yes')) {
         return $bodytag;
-    } 
+    }
 
-    my $name = &plainname($env{'user.name'},$env{'user.domain'});
     if ($public) {
 	undef($role);
-    } else {
-	$name = &aboutmewrapper($name,$env{'user.name'},$env{'user.domain'},
-                                undef,'LC_menubuttons_link');
     }
     
     my $titleinfo = '<h1>'.$title.'</h1>';
@@ -5182,35 +5178,31 @@ sub bodytag {
     $role = '<span class="LC_nobreak">('.$role.')</span>' if $role;
     &get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']);
 
-        if ($no_nav_bar || $env{'form.inhibitmenu'} eq 'yes') { 
-            return $bodytag; 
-        } 
-
         if ($env{'request.state'} eq 'construct') { $forcereg=1; }
 
         #    if ($env{'request.state'} eq 'construct') {
         #        $titleinfo = &CSTR_pageheader(); #FIXME: Will be removed once all scripts have their own calls
         #    }
 
+        $bodytag .= Apache::lonhtmlcommon::scripttag(
+            Apache::lonmenu::utilityfunctions(), 'start');
 
+        my ($left,$right) = Apache::lonmenu::primary_menu();
 
         if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) {
              if ($dc_info) {
                  $dc_info = qq|<span class="LC_cusr_subheading">$dc_info</span>|;
              }
-             $bodytag .= qq|<div id="LC_nav_bar">$name $role<br />
+             $bodytag .= qq|<div id="LC_nav_bar">$left $role<br />
                 <em>$realm</em> $dc_info</div>|;
             return $bodytag;
         }
 
         unless ($env{'request.symb'} =~ m/\.page___\d+___/) {
-            $bodytag .= qq|<div id="LC_nav_bar">$name $role</div>|;
+            $bodytag .= qq|<div id="LC_nav_bar">$left $role</div>|;
         }
 
-        $bodytag .= Apache::lonhtmlcommon::scripttag(
-            Apache::lonmenu::utilityfunctions(), 'start');
-
-        $bodytag .= Apache::lonmenu::primary_menu();
+        $bodytag .= $right;
 
         if ($dc_info) {
             $dc_info = &dc_courseid_toggle($dc_info);
@@ -5410,6 +5402,14 @@ form, .inline {
   vertical-align:middle;
 }
 
+.LC_floatleft {
+  float: left;
+}
+
+.LC_floatright {
+  float: right;
+}
+
 .LC_400Box {
   width:400px;
 }
@@ -6480,6 +6480,11 @@ div.LC_edit_problem_saves {
   padding-bottom: 5px;
 }
 
+.LC_edit_opt {
+  padding-left: 1em;
+  white-space: nowrap;
+}
+
 img.stift {
   border-width: 0;
   vertical-align: middle;
@@ -6494,6 +6499,7 @@ div.LC_createcourse {
 }
 
 .LC_dccid {
+  float: right;
   margin: 0.2em 0 0 0;
   padding: 0;
   font-size: 90%;
@@ -6591,7 +6597,6 @@ fieldset > legend {
 }
 
 ol.LC_primary_menu {
-  float: right;
   margin: 0;
   padding: 0;
   background-color: $pgbg_or_bgcolor;
@@ -7813,11 +7818,9 @@ sub LCprogressbar {
     $LCcurrentid=$$.'_'.$LCidcnt;
     my $starting=&mt('Starting');
     my $content=(<<ENDPROGBAR);
-<p>
   <div id="progressbar$LCcurrentid">
     <span class="pblabel">$starting</span>
   </div>
-</p>
 ENDPROGBAR
     &r_print($r,$content.&LCprogressbar_script($LCcurrentid));
 }
@@ -9560,18 +9563,23 @@ sub ask_for_embedded_content {
     my $heading = &mt('Upload embedded files');
     my $buttontext = &mt('Upload');
 
-    my $navmap;
+    my ($navmap,$cdom,$cnum);
     if ($env{'request.course.id'}) {
-        $navmap = Apache::lonnavmaps::navmap->new();
+        if ($actionurl eq '/adm/dependencies') {
+            $navmap = Apache::lonnavmaps::navmap->new();
+        }
+        $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+        $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
     }
-    if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
+    if (($actionurl eq '/adm/portfolio') || 
+        ($actionurl eq '/adm/coursegrp_portfolio')) {
         my $current_path='/';
         if ($env{'form.currentpath'}) {
             $current_path = $env{'form.currentpath'};
         }
         if ($actionurl eq '/adm/coursegrp_portfolio') {
-            $udom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-            $uname = $env{'course.'.$env{'request.course.id'}.'.num'};
+            $udom = $cdom;
+            $uname = $cnum;
             $url = '/userfiles/groups/'.$env{'form.group'}.'/portfolio';
         } else {
             $udom = $env{'user.domain'};
@@ -9603,24 +9611,42 @@ sub ask_for_embedded_content {
         }
     } elsif ($actionurl eq '/adm/dependencies')  {
         if ($env{'request.course.id'} ne '') {
-            $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-            $cnum =  $env{'course.'.$env{'request.course.id'}.'.num'};
             if (ref($args) eq 'HASH') {
                 $url = $args->{'docs_url'};
                 $title = $args->{'docs_title'};
-                $toplevel = "/$url";
+                $toplevel = $url; 
+                unless ($toplevel =~ m{^/}) {
+                    $toplevel = "/$url";
+                }
                 ($rem) = ($toplevel =~ m{^(.+/)[^/]+$});
-                ($path) =  
-                    ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/});
+                if ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E)}) {
+                    $path = $1;
+                } else {
+                    ($path) =
+                        ($toplevel =~ m{^(\Q/uploaded/$cdom/$cnum/\E(?:docs|supplemental)/(?:default|\d+)/\d+)/});
+                }
                 $fileloc = &Apache::lonnet::filelocation('',$toplevel);
                 $fileloc =~ s{^/}{};
                 ($filename) = ($fileloc =~ m{.+/([^/]+)$});
                 $heading = &mt('Status of dependencies in [_1]',"$title ($filename)");
             }
         }
-    }
-    my $now = time();
-    foreach my $embed_file (keys(%{$allfiles})) {
+    } elsif ($actionurl eq "/public/$cdom/$cnum/syllabus") {
+        $udom = $cdom;
+        $uname = $cnum;
+        $url = "/uploaded/$cdom/$cnum/portfolio/syllabus";
+        $toplevel = $url;
+        $path = $url;
+        $fileloc = &Apache::lonnet::filelocation('',$toplevel).'/';
+        $fileloc =~ s{^/}{};
+    }
+    foreach my $file (keys(%{$allfiles})) {
+        my $embed_file;
+        if (($path eq "/uploaded/$cdom/$cnum/portfolio/syllabus") && ($file =~ m{^\Q$path/\E(.+)$})) {
+            $embed_file = $1;
+        } else {
+            $embed_file = $file;
+        }
         my $absolutepath;
         if ($embed_file =~ m{^\w+://}) {
             $newfiles{$embed_file} = 1;
@@ -9658,7 +9684,8 @@ sub ask_for_embedded_content {
     my $dirptr = 16384;
     foreach my $path (keys(%subdependencies)) {
         $currsubfile{$path} = {};
-        if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) { 
+        if (($actionurl eq '/adm/portfolio') || 
+            ($actionurl eq '/adm/coursegrp_portfolio')) {
             my ($sublistref,$listerror) =
                 &Apache::lonnet::dirlist($url.$path,$udom,$uname,$getpropath);
             if (ref($sublistref) eq 'ARRAY') {
@@ -9674,9 +9701,15 @@ sub ask_for_embedded_content {
             }
         } elsif (($actionurl eq '/adm/dependencies') ||
                  (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') &&
-                  ($args->{'context'} eq 'paste'))) {
+                  ($args->{'context'} eq 'paste')) ||
+                 ($actionurl eq "/public/$cdom/$cnum/syllabus")) {
             if ($env{'request.course.id'} ne '') {
-                my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$});
+                my $dir;
+                if ($actionurl eq "/public/$cdom/$cnum/syllabus") {
+                    $dir = $fileloc;
+                } else {
+                    ($dir) = ($fileloc =~ m{^(.+/)[^/]+$});
+                }
                 if ($dir ne '') {
                     my ($sublistref,$listerror) =
                         &Apache::lonnet::dirlist($dir.$path,$cdom,$cnum,$getpropath,undef,'/');
@@ -9724,7 +9757,8 @@ sub ask_for_embedded_content {
         }
     }
     my %currfile;
-    if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
+    if (($actionurl eq '/adm/portfolio') ||
+        ($actionurl eq '/adm/coursegrp_portfolio')) {
         my ($dirlistref,$listerror) =
             &Apache::lonnet::dirlist($url,$udom,$uname,$getpropath);
         if (ref($dirlistref) eq 'ARRAY') {
@@ -9740,7 +9774,8 @@ sub ask_for_embedded_content {
         }
     } elsif (($actionurl eq '/adm/dependencies') ||
              (($actionurl eq '/adm/coursedocs') && (ref($args) eq 'HASH') &&
-              ($args->{'context'} eq 'paste'))) {
+              ($args->{'context'} eq 'paste')) ||
+             ($actionurl eq "/public/$cdom/$cnum/syllabus")) {
         if ($env{'request.course.id'} ne '') {
             my ($dir) = ($fileloc =~ m{^(.+/)[^/]+$});
             if ($dir ne '') {
@@ -9775,12 +9810,14 @@ sub ask_for_embedded_content {
                 ($file eq $filename.'.bak') ||
                 ($dependencies{$file})) {
             if ($actionurl eq '/adm/dependencies') {
-                next if (($rem ne '') &&
-                         (($env{"httpref.$rem".$file} ne '') ||
-                          (ref($navmap) &&
-                          (($navmap->getResourceByUrl($rem.$file) ne '') ||
-                           (($file =~ /^(.*\.s?html?)\.bak$/i) &&
-                            ($navmap->getResourceByUrl($rem.$1)))))));
+                unless ($toplevel =~ m{^\Q/uploaded/$cdom/$cnum/portfolio/syllabus\E}) {
+                    next if (($rem ne '') &&
+                             (($env{"httpref.$rem".$file} ne '') ||
+                              (ref($navmap) &&
+                              (($navmap->getResourceByUrl($rem.$file) ne '') ||
+                               (($file =~ /^(.*\.s?html?)\.bak$/i) &&
+                                ($navmap->getResourceByUrl($rem.$1)))))));
+                }
             }
             $unused{$file} = 1;
         }
@@ -9789,28 +9826,38 @@ sub ask_for_embedded_content {
         ($args->{'context'} eq 'paste')) {
         $counter = scalar(keys(%existing));
         $numpathchg = scalar(keys(%pathchanges));
-        return ($output,$counter,$numpathchg,\%existing); 
+        return ($output,$counter,$numpathchg,\%existing);
+    } elsif (($actionurl eq "/public/$cdom/$cnum/syllabus") && 
+             (ref($args) eq 'HASH') && ($args->{'context'} eq 'rewrites')) {
+        $counter = scalar(keys(%existing));
+        $numpathchg = scalar(keys(%pathchanges));
+        return ($output,$counter,$numpathchg,\%existing,\%mapping);
     }
     foreach my $embed_file (sort {lc($a) cmp lc($b)} keys(%newfiles)) {
         if ($actionurl eq '/adm/dependencies') {
             next if ($embed_file =~ m{^\w+://});
         }
         $upload_output .= &start_data_table_row().
-                          '<td><img src="'.&icon($embed_file).'" />&nbsp;'.
+                          '<td valign="top"><img src="'.&icon($embed_file).'" />&nbsp;'.
                           '<span class="LC_filename">'.$embed_file.'</span>';
         unless ($mapping{$embed_file} eq $embed_file) {
-            $upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.&mt('changed from: [_1]',$mapping{$embed_file}).'</span>';
+            $upload_output .= '<br /><span class="LC_info" style="font-size:smaller;">'.
+                              &mt('changed from: [_1]',$mapping{$embed_file}).'</span>';
         }
-        $upload_output .= '</td><td>';
+        $upload_output .= '</td>';
         if ($args->{'ignore_remote_references'} && $embed_file =~ m{^\w+://}) { 
-            $upload_output.='<span class="LC_warning">'.&mt("URL points to other server.").'</span>';
+            $upload_output.='<td align="right">'.
+                            '<span class="LC_info LC_fontsize_medium">'.
+                            &mt("URL points to web address").'</span>';
             $numremref++;
         } 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>';
+            $upload_output.='<td align="right"><span class="LC_warning">'.
+                            &mt('Invalid characters').'</span>';
             $numinvalid++;
         } else {
-            $upload_output .= &embedded_file_element('upload_embedded',$counter,
+            $upload_output .= '<td>'.
+                              &embedded_file_element('upload_embedded',$counter,
                                                      $embed_file,\%mapping,
                                                      $allfiles,$codebase,'upload');
             $counter ++;
@@ -9839,8 +9886,9 @@ sub ask_for_embedded_content {
             $counter ++;
         } else {
             $upload_output .= &start_data_table_row().
-                              '<td><span class="LC_filename">'.$embed_file.'</span></td>';
-                              '<td><span class="LC_warning">'.&mt('Already exists').'</span></td>'.
+                              '<td valign="top"><img src="'.&icon($embed_file).'" />&nbsp;'.
+                              '<span class="LC_filename">'.$embed_file.'</span></td>'.
+                              '<td align="right"><span class="LC_info LC_fontsize_medium">'.&mt('Already exists').'</span></td>'.
                               &Apache::loncommon::end_data_table_row()."\n";
         }
     }
@@ -9935,7 +9983,7 @@ sub ask_for_embedded_content {
         $output = '<b>'.&mt('Referenced files').'</b>:<br />';
         if ($applies > 1) {
             $output .=  
-                &mt('No files need to be uploaded, as one of the following applies to each reference:').'<ul>';
+                &mt('No dependencies need to be uploaded, as one of the following applies to each reference:').'<ul>';
             if ($numremref) {
                 $output .= '<li>'.&mt('reference is to a URL which points to another server').'</li>'."\n";
             }
@@ -9978,7 +10026,7 @@ sub ask_for_embedded_content {
             $chgcount ++;
         }
     }
-    if ($counter) {
+    if (($counter) || ($numunused)) {
         if ($numpathchg) {
             $output .= '<input type ="hidden" name="number_pathchange_items" value="'.
                        $numpathchg.'" />'."\n";
@@ -9991,13 +10039,13 @@ sub ask_for_embedded_content {
         } elsif ($actionurl eq '/adm/dependencies') {
             $output .= '<input type="hidden" name="action" value="process_changes" />';
         }
-        $output .=  '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n";
+        $output .= '<input type ="submit" value="'.$buttontext.'" />'."\n".'</form>'."\n";
     } elsif ($numpathchg) {
         my %pathchange = ();
         $output .= &modify_html_form('pathchange',$actionurl,$state,\%pathchange,$pathchange_output);
         if (($actionurl eq '/adm/portfolio') || ($actionurl eq '/adm/coursegrp_portfolio')) {
             $output .= '<p>'.&mt('or').'</p>'; 
-        } 
+        }
     }
     return ($output,$counter,$numpathchg);
 }
@@ -10137,17 +10185,19 @@ sub upload_embedded {
             next;
         }
         $env{'form.embedded_item_'.$i.'.filename'}=$fname;
+        my $subdir = $path;
+        $subdir =~ s{/+$}{};
         if ($context eq 'portfolio') {
             my $result;
             if ($state eq 'existingfile') {
                 $result=
                     &Apache::lonnet::userfileupload('embedded_item_'.$i,'existingfile',
-                                                    $dirpath.$env{'form.currentpath'}.$path);
+                                                    $dirpath.$env{'form.currentpath'}.$subdir);
             } else {
                 $result=
                     &Apache::lonnet::userfileupload('embedded_item_'.$i,'',
                                                     $dirpath.
-                                                    $env{'form.currentpath'}.$path);
+                                                    $env{'form.currentpath'}.$subdir);
                 if ($result !~ m|^/uploaded/|) {
                     $output .= '<span class="LC_error">'
                                .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
@@ -10159,10 +10209,11 @@ sub upload_embedded {
                                $path.$fname.'</span>').'<br />';     
                 }
             }
-        } elsif ($context eq 'coursedoc') {
+        } elsif (($context eq 'coursedoc') || ($context eq 'syllabus')) {
+            my $extendedsubdir = $dirpath.'/'.$subdir;
+            $extendedsubdir =~ s{/+$}{};
             my $result =
-                &Apache::lonnet::userfileupload('embedded_item_'.$i,'coursedoc',
-                                                $dirpath.'/'.$path);
+                &Apache::lonnet::userfileupload('embedded_item_'.$i,$context,$extendedsubdir);
             if ($result !~ m|^/uploaded/|) {
                 $output .= '<span class="LC_error">'
                            .&mt('An error occurred ([_1]) while trying to upload [_2] for embedded element [_3].'
@@ -10172,6 +10223,9 @@ sub upload_embedded {
             } else {
                 $output .= &mt('Uploaded [_1]','<span class="LC_filename">'.
                            $path.$fname.'</span>').'<br />';
+                if ($context eq 'syllabus') {
+                    &Apache::lonnet::make_public_indefinitely($result);
+                }
             }
         } else {
 # Save the file
@@ -10303,7 +10357,7 @@ sub modify_html_form {
 }
 
 sub modify_html_refs {
-    my ($context,$dirpath,$uname,$udom,$dir_root) = @_;
+    my ($context,$dirpath,$uname,$udom,$dir_root,$url) = @_;
     my $container;
     if ($context eq 'portfolio') {
         $container = $env{'form.container'};
@@ -10312,12 +10366,14 @@ sub modify_html_refs {
     } elsif ($context eq 'manage_dependencies') {
         (undef,undef,$container) = &Apache::lonnet::decode_symb($env{'form.symb'});
         $container = "/$container";
+    } elsif ($context eq 'syllabus') {
+        $container = $url;
     } else {
         $container = $Apache::lonnet::perlvar{'lonDocRoot'}.$env{'form.filename'};
     }
     my (%allfiles,%codebase,$output,$content);
     my @changes = &get_env_multiple('form.namechange');
-    unless (@changes > 0) {
+    unless ((@changes > 0) || ($context eq 'syllabus')) {
         if (wantarray) {
             return ('',0,0); 
         } else {
@@ -10325,7 +10381,7 @@ sub modify_html_refs {
         }
     }
     if (($context eq 'portfolio') || ($context eq 'coursedoc') || 
-        ($context eq 'manage_dependencies')) {
+        ($context eq 'manage_dependencies') || ($context eq 'syllabus')) {
         unless ($container =~ m{^/uploaded/\Q$udom\E/\Q$uname\E/}) {
             if (wantarray) {
                 return ('',0,0);
@@ -10381,6 +10437,7 @@ sub modify_html_refs {
                     if ($content =~ m{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}) {
                         my $numchg = ($content =~ s{($attrib_regexp\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi);
                         $count += $numchg;
+                        $allfiles{$newname} = $allfiles{$ref};
                     }
                     if ($env{'form.embedded_codebase_'.$i} ne '') {
                         $codebase = &unescape($env{'form.embedded_codebase_'.$i});
@@ -10389,10 +10446,11 @@ sub modify_html_refs {
                     }
                 }
             }
+            my $skiprewrites;
             if ($count || $codebasecount) {
                 my $saveresult;
                 if (($context eq 'portfolio') || ($context eq 'coursedoc') || 
-                    ($context eq 'manage_dependencies')) {
+                    ($context eq 'manage_dependencies') || ($context eq 'syllabus')) {
                     my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult);
                     if ($url eq $container) {
                         my ($fname) = ($container =~ m{/([^/]+)$});
@@ -10405,6 +10463,11 @@ sub modify_html_refs {
                                    '<span class="LC_filename">'.
                                    $container.'</span>').'</p>';
                     }
+                    if ($context eq 'syllabus') {
+                        unless ($saveresult eq 'ok') {
+                            $skiprewrites = 1;
+                        }
+                    }
                 } else {
                     if (open(my $fh,">$container")) {
                         print $fh $content;
@@ -10420,6 +10483,47 @@ sub modify_html_refs {
                     }
                 }
             }
+            if (($context eq 'syllabus') && (!$skiprewrites)) {
+                my ($actionurl,$state);
+                $actionurl = "/public/$udom/$uname/syllabus";
+                my ($ignore,$num,$numpathchanges,$existing,$mapping) =
+                    &ask_for_embedded_content($actionurl,$state,\%allfiles,
+                                              \%codebase,
+                                              {'context' => 'rewrites',
+                                               'ignore_remote_references' => 1,});
+                if (ref($mapping) eq 'HASH') {
+                    my $rewrites = 0;
+                    foreach my $key (keys(%{$mapping})) {
+                        next if ($key =~ m{^https?://});
+                        my $ref = $mapping->{$key};
+                        my $newname = "/uploaded/$udom/$uname/portfolio/syllabus/$key";
+                        my $attrib;
+                        if (ref($allfiles{$mapping->{$key}}) eq 'ARRAY') {
+                            $attrib = join('|',@{$allfiles{$mapping->{$key}}});
+                        }
+                        if ($content =~ m{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}) {
+                            my $numchg = ($content =~ s{($attrib\s*=\s*['"]?)\Q$ref\E(['"]?)}{$1$newname$2}gi);
+                            $rewrites += $numchg;
+                        }
+                    }
+                    if ($rewrites) {
+                        my $saveresult; 
+                        my $url = &Apache::lonnet::store_edited_file($container,$content,$udom,$uname,\$saveresult);
+                        if ($url eq $container) {
+                            my ($fname) = ($container =~ m{/([^/]+)$});
+                            $output .= '<p>'.&mt('Rewrote [quant,_1,link] as [quant,_1,absolute link] in [_2].',
+                                            $count,'<span class="LC_filename">'.
+                                            $fname.'</span>').'</p>';
+                        } else {
+                            $output .= '<p class="LC_error">'.
+                                       &mt('Error: could not update links in [_1].',
+                                       '<span class="LC_filename">'.
+                                       $container.'</span>').'</p>';
+
+                        }
+                    }
+                }
+            }
         } else {
             &logthis('Failed to parse '.$container.
                      ' to modify references: '.$parse_result);
@@ -11722,7 +11826,7 @@ sub get_folder_hierarchy {
                 my @pcs = split(/,/,$pcslist);
                 foreach my $pc (@pcs) {
                     if ($pc == 1) {
-                        push(@pathitems,&mt('Main Course Documents'));
+                        push(@pathitems,&mt('Main Content'));
                     } else {
                         my $res = $navmap->getByMapPc($pc);
                         if (ref($res)) {
@@ -11737,7 +11841,7 @@ sub get_folder_hierarchy {
             }
             if ($showitem) {
                 if ($mapres->{ID} eq '0.0') {
-                    push(@pathitems,&mt('Main Course Documents'));
+                    push(@pathitems,&mt('Main Content'));
                 } else {
                     my $maptitle = $mapres->compTitle();
                     $maptitle =~ s/\W+/_/g;
@@ -14298,7 +14402,7 @@ sub symb_to_docspath {
         $path =~ s/^\&//;
         my $maptitle = $mapresobj->title();
         if ($mapurl eq 'default') {
-            $maptitle = 'Main Course Documents';
+            $maptitle = 'Main Content';
         }
         $path .= (($path ne '')? '&' : '').
                  &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
@@ -14312,14 +14416,14 @@ sub symb_to_docspath {
         my $maptitle = &Apache::lonnet::gettitle($mapurl);
         my $ispage = (($type eq 'page')? 1 : '');
         if ($mapurl eq 'default') {
-            $maptitle = 'Main Course Documents';
+            $maptitle = 'Main Content';
         }
         $path = &Apache::lonhtmlcommon::entity_encode($mapurl).'&'.
                 &Apache::lonhtmlcommon::entity_encode($maptitle).':::::'.$ispage;
     }
     unless ($mapurl eq 'default') {
         $path = 'default&'.
-                &Apache::lonhtmlcommon::entity_encode('Main Course Documents').
+                &Apache::lonhtmlcommon::entity_encode('Main Content').
                 ':::::&'.$path;
     }
     return $path;