--- loncom/interface/lonhtmlcommon.pm 2009/08/10 16:27:39 1.230
+++ 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.230 2009/08/10 16:27:39 bisitz 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 '';
+ }
+}
+
##############################################
##############################################
@@ -82,7 +92,7 @@ sub confirm_success {
.''."\n";
} else {
return ''."\n"
- .' '."\n"
+ .'
'."\n"
.$message."\n"
.''."\n";
}
@@ -111,7 +121,7 @@ sub dragmath_button {
}
my $buttontext=&mt('Edit Math');
return <
'.
&Apache::loncommon::help_open_topic('About_Bombs');
@@ -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';
@@ -239,7 +252,7 @@ sub get_recent {
# Begin filling return_hash with any 'always_include' option
my %time_hash = ();
my %return_hash = ();
- foreach my $item (keys %recent) {
+ foreach my $item (keys(%recent)) {
my ($thistime,$thisvalue)=(split(/\&/,$recent{$item}));
if ($thistime eq 'always_include') {
$return_hash{$item} = &unescape($thisvalue);
@@ -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'}) {
- 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
@@ -1342,6 +1353,7 @@ returns: nothing
############################################################
{
my @Crumbs;
+ my %tools = ();
sub breadcrumbs {
my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $CourseBreadcrumbs) = @_;
@@ -1438,8 +1450,12 @@ returns: nothing
.$links;
}
+ #SD START (work in progress!)
+ add_tools(\$links);
+ #SD END
$links = htmltag('div', $links,
{ id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ;
+ add_advtools(\$links);
# Return the @Crumbs stack to what we started with
push(@Crumbs,$last);
@@ -1450,11 +1466,62 @@ returns: nothing
sub clear_breadcrumbs {
undef(@Crumbs);
+ undef(%tools);
}
sub add_breadcrumb {
- push (@Crumbs,@_);
+ push(@Crumbs,@_);
+ }
+
+
+ #SD START (work in progress!)
+ sub add_breadcrumb_tool {
+ my ($category, $html) = @_;
+ return unless $html;
+ if (!defined(%tools)) {
+ my %tools = ( A => [], B => [], C => []);
+ }
+ push @{$tools{$category}}, $html;
+ }
+
+ sub clear_breadcrumb_tools {
+ undef(%tools);
+ }
+
+ sub add_tools {
+ my ($links) = @_;
+ return unless defined %tools;
+ my $html = '