--- loncom/interface/lonhtmlcommon.pm 2009/10/31 14:27:48 1.237 +++ loncom/interface/lonhtmlcommon.pm 2009/11/30 06:32:26 1.251 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.237 2009/10/31 14:27:48 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.251 2009/11/30 06:32:26 raeburn 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 '<a href="/adm/courseprefs?phase=display&actions='.$category.'">'.$text.'</a>'; + } else { + return ''; + } +} + ############################################## ############################################## @@ -111,7 +121,7 @@ sub dragmath_button { } my $buttontext=&mt('Edit Math'); return <<ENDDRAGMATH; - <input type="button" value="$buttontext", onclick="javascript:mathedit('$textarea',document)" />$help_text + <input type="button" value="$buttontext" onclick="javascript:mathedit('$textarea',document)" />$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<option value='$escaped'>". &unescape((split(/\&/,$recent{$value}))[1]). '</option>'; @@ -1128,7 +1141,7 @@ sub crumbs { my $output=''; unless ($noformat) { $output.='<br /><tt><b>'; } $output.='<font size="'.$size.'">'.$prefix.'/'; - if ($env{'user.adv'}) { + if (($env{'user.adv'}) || ($env{'user.author'})) { my $path=$prefix.'/'; foreach my $dir (split('/',$uri)) { if (! $dir) { next; } @@ -1342,6 +1355,7 @@ returns: nothing ############################################################ { my @Crumbs; + my %tools = (); sub breadcrumbs { my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $CourseBreadcrumbs) = @_; @@ -1438,8 +1452,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 +1468,62 @@ returns: nothing sub clear_breadcrumbs { undef(@Crumbs); + undef(%tools); } sub add_breadcrumb { 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 = '<ul class="LC_bct">'; + for my $category ('A','B') { + $html .= '<li class="LC_breadcrumb_tools">' + . '<ul class="LC_breadcrumb_tools' + . " LC_breadcrumb_tools_$category\">"; + for my $item (@{$tools{$category}}){ + #SD ugly! I'll fix that later on + $item =~ s/align="(right|left)"//; + $item =~ s/<span(.*?)\/span>//; + $html .= "<li>$item</li>"; + } + $html .= '</ul></li>'; + if ($category eq 'A') { $html .= "<li>$$links</li>"; } + } + $$links = $html.'</ul>'; + } + + sub add_advtools { + my ($links) = @_; + return unless (defined $tools{'C'}) and (scalar (@{$tools{'C'}}) > 0); + my $html = start_funclist(); + for my $item (@{$tools{'C'}}){ + next unless $item; + $item =~ s/align="(right|left)"//; + $html .= add_item_funclist($item); + } + $html .= end_funclist(); + $html = Apache::loncommon::head_subbox($html); + $$links .= $html; + } + #SD END } # End of scope for @Crumbs @@ -1547,7 +1616,7 @@ END } sub row_title { - my ($title,$css_title_class,$css_value_class) = @_; + my ($title,$css_title_class,$css_value_class, $css_value_furtherAttributes) = @_; $row_count[0]++; my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row'; $css_title_class ||= 'LC_pick_box_title'; @@ -1559,7 +1628,7 @@ sub row_title { $title .= ':'; } my $output = <<"ENDONE"; - <tr class="LC_pick_box_row"> + <tr class="LC_pick_box_row" $css_value_furtherAttributes> <td $css_title_class> $title </td> @@ -1727,7 +1796,7 @@ sub course_selection { $output .= '</tr></table><br />'; } } - $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."','dccourse','dcdomain','coursedesc','','1'".')" />'.$pickspec.' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n"; + $output .= '<input type="radio" name="coursepick" value="specific" onclick="coursePick(this.form);opencrsbrowser('."'".$formname."','dccourse','dcdomain','coursedesc','','1','$crstype'".')" />'.$pickspec.' '.$courseform.' <input type="text" value="0" size="4" name="coursetotal" /><input type="hidden" name="courselist" value="" />selected.<br />'."\n"; return $output; } @@ -1815,16 +1884,21 @@ sub course_custom_roles { # topic_bar # -# Generates a div containing a numbered (static image) followed by a title -# with a background color defined in the corresponding CSS: LC_topic_bar -# +# 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. +# 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) = @_; - return '<div class="LC_topic_bar">' - .'<img src="/res/adm/pages/bl_step'.$imgnum.'.gif"' - .' alt="'.&mt('Step [_1]',$imgnum).'" />' - .' '.$title - .'</div>'; + my ($num,$title) = @_; + my $number = ''; + if ($num ne '') { + $number = '<span>'.$num.'</span>'; + } + return '<div class="LC_topic_bar">'.$number.$title.'</div>'; } ############################################## @@ -2285,8 +2359,7 @@ Returns: HTML code with function list st sub start_funclist { my($legendtext)=@_; $legendtext=&mt('Functions') if !$legendtext; - return "<fieldset>\n<legend>$legendtext</legend>\n" - .'<ul class="LC_funclist">'."\n"; + return '<ul class="LC_funclist"><li style="font-weight:bold; margin-left:0.8em;">'.$legendtext.'</li>'."\n"; } @@ -2344,8 +2417,7 @@ Returns: HTML code with function list en ############################################## sub end_funclist { - my($r)=@_; - return "</ul>\n</fieldset>\n"; + return "</ul>\n"; } 1;