--- loncom/interface/lonhtmlcommon.pm 2012/10/31 12:54:13 1.328 +++ loncom/interface/lonhtmlcommon.pm 2012/11/16 23:37:16 1.331 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.328 2012/10/31 12:54:13 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.331 2012/11/16 23:37:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -61,7 +61,7 @@ use Time::HiRes; use Apache::lonlocal; use Apache::lonnet; use HTML::Entities(); -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); sub java_not_enabled { return "\n".''. @@ -1651,6 +1651,14 @@ returns: nothing $description = $env{'course.'.$env{'request.course.id'}.'.description'}; $no_mt_descr = 1; + if ($env{'request.noversionuri'} =~ + m{^/public/($match_domain)/($match_courseid)/syllabus$}) { + unless (($env{'course.'.$env{'request.course.id'}.'.domain'} eq $1) && + ($env{'course.'.$env{'request.course.id'}.'.num'} eq $2)) { + $description = 'Menu'; + $no_mt_descr = 0; + } + } } $menulink = { href =>'/adm/menu', title =>'Go to main menu', @@ -1666,7 +1674,7 @@ returns: nothing } } my $links; - if ((&show_return_link) && (!$CourseBreadcrumbs)) { + if ((&show_return_link) && (!$CourseBreadcrumbs) && (ref($last) eq 'HASH')) { my $alttext = &mt('Go Back'); $links=&htmltag( 'a',''.$alttext.'', { href => '/adm/flip?postdata=return:', @@ -1701,8 +1709,10 @@ returns: nothing # last breadcrumb is the first order heading of a page # for course breadcrumbs it's just bold - $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1', - $lasttext), {title => $lasttext}); + if ($lasttext ne '') { + $links .= &htmltag( 'li', htmltag($CourseBreadcrumbs ? 'b' : 'h1', + $lasttext), {title => $lasttext}); + } my $icons = ''; $faq = $last->{'faq'} if (exists($last->{'faq'})); @@ -1723,11 +1733,12 @@ returns: nothing # - - unless ($CourseBreadcrumbs) { - $links = &htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" }); - } else { - $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" }); + if ($links ne '') { + unless ($CourseBreadcrumbs) { + $links = &htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" }); + } else { + $links = &htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" }); + } } @@ -1871,6 +1882,68 @@ returns: nothing } # End of scope for @Crumbs +sub docs_breadcrumbs { + my ($allowed,$crstype,$contenteditor)=@_; + my ($folderpath,@folders); + if ($env{'form.pagepath'}) { + @folders = split('&',$env{'form.pagepath'}); + } else { + @folders=split('&',$env{'form.folderpath'}); + } + my $plain=''; + my ($randompick,$isencrypted,$ishidden,$is_random_order) = (-1,0,0,0); + &clear_breadcrumbs(); + while (@folders) { + my $folder=shift(@folders); + my $foldername=shift(@folders); + if ($folderpath) {$folderpath.='&';} + $folderpath.=$folder.'&'.$foldername; + my $url; + if ($allowed) { + $url = '/adm/coursedocs?folderpath='; + } else { + $url = '/adm/supplemental?folderpath='; + } + $url .= &escape($folderpath); + my $name=&unescape($foldername); +# each of randompick number, hidden, encrypted, random order are +# appended with ":"s to the foldername + $name=~s/\:(\d*)\:(\w*)\:(\w*):(\d*)$//; + if ($contenteditor) { + if ($1 ne '') { + $randompick=$1; + } else { + $randompick=-1; + } + if ($2) { $ishidden=1; } + if ($3) { $isencrypted=1; } + if ($4 ne '') { $is_random_order = 1; } + } + if ($folder eq 'supplemental') { + $name = &mt('Supplemental '.$crstype.' Content'); + } + if ($contenteditor) { + $plain.=$name.' > '; + } + &add_breadcrumb( + {'href' => $url, + 'title' => $name, + 'text' => $name, + 'no_mt' => 1, + }); + } + unless ($contenteditor) { + if ($env{'httpref.'.$env{'request.noversionuri'}} ne '') { + &add_breadcrumb({text => 'View Resource'}); + } + } else { + $plain=~s/\>\;\s*$//; + } + return (&breadcrumbs(undef,undef,0,'nohelp',undef,undef,$contenteditor), + $randompick,$ishidden,$isencrypted,$plain, + $is_random_order); +} + ############################################################ ############################################################ @@ -2925,29 +2998,6 @@ PARAMSONE if (itemid.offsetWidth != itemwstart) { listwchange = 1; } -THIRD - if ($context eq 'docs') { - $output .= <<"DOCSTWO"; - if (activeTab == 'cc1') { - if (document.getElementById('cc_hrule') != null) { - document.getElementById('cc_hrule').style.width=actabw+"px"; - } - } else { - if (activeTab == 'bb1') { - if (document.getElementById('bb_hrule') != null) { - document.getElementById('bb_hrule').style.width=actabw+"px"; - } - } else { - if (activeTab == 'ee2') { - if (document.getElementById('ee_hrule') != null) { - document.getElementById('ee_hrule').style.width=actabw+"px"; - } - } - } - } -DOCSTWO - } - $output .= <<"FOURTH"; } if ((chkh == 1) || (listwchange)) { var primaryheight = document.getElementById('LC_nav_bar').offsetHeight; @@ -3007,7 +3057,7 @@ function callResize() { timer=setTimeout('resize_scrollbox("$names{'scroll'}","1","1")',500); } -FOURTH +THIRD return $output; } @@ -3041,21 +3091,32 @@ ENDUTILITY } sub jump_to_editres { - my ($cfile,$home,$switchserver,$uploaded,$symb) = @_; + my ($cfile,$home,$switchserver,$forceedit,$forcereg,$symb) = @_; my $jscall; if ($switchserver) { if ($symb && $home) { $cfile = '/adm/switchserver?otherserver='.$home.'&role='. - &HTML::Entities::encode($env{'request.role'},'"<>&').'&'. - 'symb='.&HTML::Entities::encode($env{'request.symb'},'"<>&'); - if ($uploaded) { + &HTML::Entities::encode($env{'request.role'},'"<>&'). + '&symb='.&HTML::Entities::encode($symb,'"<>&'); + if ($forceedit) { $cfile .= '&forceedit=1'; } + if ($forcereg) { + $cfile .= '&register=1'; + } $jscall = "need_switchserver('$cfile');"; } } else { - if ($uploaded) { - $cfile .= '?forceedit=1'; + unless ($cfile =~ m{^/priv/}) { + if ($symb) { + $cfile .= (($cfile=~/\?/)?'&':'?')."symb=$symb"; + } + if ($forceedit) { + $cfile .= (($cfile=~/\?/)?'&':'?').'forceedit=1'; + } + if ($forcereg) { + $cfile .= (($cfile=~/\?/)?'&':'?').'register=1'; + } } $jscall = "go('$cfile')"; }