--- loncom/interface/lonhtmlcommon.pm 2009/11/14 18:54:17 1.243 +++ loncom/interface/lonhtmlcommon.pm 2009/12/01 18:07:50 1.252 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.243 2009/11/14 18:54:17 amueller Exp $ +# $Id: lonhtmlcommon.pm,v 1.252 2009/12/01 18:07:50 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,6 +62,16 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA; + +sub coursepreflink { + my ($text,$category)=@_; + if (&Apache::lonnet::allowed('opa',$env{'request.course.id'})) { + return ''.$text.''; + } else { + return ''; + } +} + ############################################## ############################################## @@ -111,7 +121,7 @@ sub dragmath_button { } my $buttontext=&mt('Edit Math'); return <$help_text + $help_text ENDDRAGMATH } @@ -222,6 +232,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'; @@ -1117,47 +1130,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 @@ -1473,6 +1484,10 @@ returns: nothing push @{$tools{$category}}, $html; } + sub clear_breadcrumb_tools { + undef(%tools); + } + sub add_tools { my ($links) = @_; return unless defined %tools; @@ -1487,7 +1502,7 @@ returns: nothing $item =~ s///; $html .= "
  • $item
  • "; } - $html .= ''; + $html .= ''; if ($category eq 'A') { $html .= "
  • $$links
  • "; } } $$links = $html.''; @@ -1867,22 +1882,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.'
    '; } ############################################## @@ -2343,8 +2357,7 @@ Returns: HTML code with function list st sub start_funclist { my($legendtext)=@_; $legendtext=&mt('Functions') if !$legendtext; - return "
    \n$legendtext\n" - .'
      '."\n"; + return '
      • '.$legendtext.'
      • '."\n"; } @@ -2402,8 +2415,7 @@ Returns: HTML code with function list en ############################################## sub end_funclist { - my($r)=@_; - return "
      \n
    \n"; + return "\n"; } 1;