--- loncom/interface/lonhtmlcommon.pm 2009/11/21 22:36:23 1.247 +++ loncom/interface/lonhtmlcommon.pm 2009/12/08 05:19:08 1.253.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.247 2009/11/21 22:36:23 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.253.2.2 2009/12/08 05:19:08 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,6 +72,12 @@ sub coursepreflink { } } +sub raw_href_to_link { + my ($message)=@_; + $message=~s/(https?\:\/\/[^\s\'\"]+)(\s|$)/$1<\/tt><\/a>$2/gi; + return $message; +} + ############################################## ############################################## @@ -232,6 +238,9 @@ sub select_recent { unless ($value =~/^error\:/) { my $escaped = &Apache::loncommon::escape_url($value); &Apache::loncommon::inhibit_menu_check(\$escaped); + if ($area eq 'residx') { + next if ((!&Apache::lonnet::allowed('bre',$value)) && (!&Apache::lonnet::allowed('bro',$value))); + } $return.="\n'; @@ -1127,47 +1136,45 @@ sub r_print { # ------------------------------------------------------- Puts directory header sub crumbs { - my ($uri,$target,$prefix,$form,$size,$noformat,$skiplast)=@_; - if (! defined($size)) { - $size = '+2'; - } + my ($uri,$target,$prefix,$form,$skiplast)=@_; if ($target) { $target = ' target="'. &Apache::loncommon::escape_single($target).'"'; } - my $output=''; - unless ($noformat) { $output.='
'; } - $output.=''.$prefix.'/'; - if (($env{'user.adv'}) | ($env{'user.author'})) { - my $path=$prefix.'/'; - foreach my $dir (split('/',$uri)) { + my $output=''; + $output.=$prefix.'/'; + if (($env{'user.adv'}) || ($env{'user.author'})) { + my $path=$prefix.'/'; + foreach my $dir (split('/',$uri)) { if (! $dir) { next; } $path .= $dir; - if ($path eq $uri) { - if ($skiplast) { - $output.=$dir; + if ($path eq $uri) { + if ($skiplast) { + $output.=$dir; last; - } - } else { - $path.='/'; - } + } + } else { + $path.='/'; + } my $href_path = &HTML::Entities::encode($path,'<>&"'); - &Apache::loncommon::inhibit_menu_check(\$href_path); - if ($form) { - my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; - $output.=qq{
$dir/}; - } else { - $output.=qq{$dir/}; - } - } + &Apache::loncommon::inhibit_menu_check(\$href_path); + if ($form) { + my $href = 'javascript:'.$form.".action='".$href_path."';".$form.'.submit();'; + $output.=qq{$dir/}; + } else { + $output.=qq{$dir/}; + } + } } else { - foreach my $dir (split('/',$uri)) { + foreach my $dir (split('/',$uri)) { if (! $dir) { next; } - $output.=$dir.'/'; - } + $output.=$dir.'/'; + } } if ($uri !~ m|/$|) { $output=~s|/$||; } - return $output.''.($noformat?'':'
'); + $output.=''; + + return $output; } # --------------------- A function that generates a window for the spellchecker @@ -1371,25 +1378,23 @@ returns: nothing # The first one should be the course or a menu link if (!defined($menulink)) { $menulink=1; } if ($menulink) { - my $description = 'Menu'; - my $no_mt_descr = 0; - if (exists($env{'request.course.id'}) && - $env{'request.course.id'} ne '') { - $description = - $env{'course.'.$env{'request.course.id'}.'.description'}; - $no_mt_descr = 1; - } - $menulink = { href =>'/adm/menu', - title =>'Go to main menu', - target =>'_top', - text =>$description, - no_mt =>$no_mt_descr, }; - if($last) { - #$last set, so we have some crumbs - unshift(@Crumbs,$menulink); + if ($menulink eq '_nomenu') { + return unless($last); } else { - #only menulink crumb present - $last = $menulink; + my $description = 'Menu'; + my $no_mt_descr = 0; + $menulink = { href =>'/adm/menu', + title =>'Go to main menu', + target =>'_top', + text =>$description, + no_mt =>$no_mt_descr, }; + if($last) { + #$last set, so we have some crumbs + unshift(@Crumbs,$menulink); + } else { + #only menulink crumb present + $last = $menulink; + } } } my $links = join "", @@ -1501,7 +1506,7 @@ returns: nothing $item =~ s///; $html .= "
  • $item
  • "; } - $html .= ''; + $html .= ''; if ($category eq 'A') { $html .= "
  • $$links
  • "; } } $$links = $html.''; @@ -1881,22 +1886,21 @@ sub course_custom_roles { # topic_bar # -# Generates a div containing an (optional) numbered (static) image followed by a +# Generates a div containing an (optional) number with a white background followed by a # title with a background color defined in the corresponding CSS: LC_topic_bar # Inputs: -# 1. number to display (corresponding static image should exist). -# img tag will be included if arg is an integer in the range 1 to 9. +# 1. number to display. +# If input for number is empty only the title will be displayed. # 2. title text to display. # Outputs - a scalar containing html mark-up for the div. sub topic_bar { - my ($imgnum,$title) = @_; - my $imgtag; - if ($imgnum =~ /^[1-9]$/) { - $imgtag = ''.&mt('Step [_1]',$imgnum).' '; + my ($num,$title) = @_; + my $number = ''; + if ($num ne '') { + $number = ''.$num.''; } - return '
    '.$imgtag.$title.'
    '; + return '
    '.$number.$title.'
    '; } ##############################################