// if $category ne 'advtools';
+ }
+
+ push @{$tools{$category}}, @html;
}
+=item clear_breadcrumb_tools()
+
+Clears the breadcrumb toolbar container.
+
+returns: nothing
+
+=cut
+
sub clear_breadcrumb_tools {
undef(%tools);
}
- sub add_tools {
- my ($links) = @_;
- return unless defined %tools;
- my $html = '';
- for my $category ('A','B') {
- $html .= '- '
- . '
';
- if ($category eq 'A') { $html .= "$$links"; }
- }
- $$links = $html.'';
- }
-
- 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;
+=item render_tools(\$breadcrumbs)
+
+Creates html for breadcrumb tools (categories navigation and tools) and inserts
+\$breadcrumbs at the correct position.
+
+input: \$breadcrumbs - a reference to the string containing prepared
+breadcrumbs.
+
+returns: nothing
+=cut
+
+#TODO might split this in separate functions for each category
+ sub render_tools {
+ my ($breadcrumbs) = @_;
+ return unless (keys(%tools));
+
+ my $navigation = list_from_array($tools{navigation},
+ { listattr => { class=>"LC_breadcrumb_tools_navigation" } });
+ my $tools = list_from_array($tools{tools},
+ { listattr => { class=>"LC_breadcrumb_tools_tools" } });
+ $$breadcrumbs = list_from_array([$navigation, $tools, $$breadcrumbs],
+ { listattr => { class=>'LC_breadcrumb_tools_outerlist' } });
+ }
+
+=item render_advtools(\$breadcrumbs)
+
+Creates html for advanced tools (category advtools) and inserts \$breadcrumbs
+at the correct position.
+
+input: \$breadcrumbs - a reference to the string containing prepared
+breadcrumbs (after render_tools call).
+
+returns: nothing
+=cut
+
+ sub render_advtools {
+ my ($breadcrumbs) = @_;
+ return unless (defined $tools{'advtools'})
+ and (scalar(@{$tools{'advtools'}}) > 0);
+
+ $$breadcrumbs .= Apache::loncommon::head_subbox(
+ funclist_from_array($tools{'advtools'}) );
}
- #SD END
} # End of scope for @Crumbs
@@ -1643,7 +1855,6 @@ ENDTWO
} # End: row_count block for pick_box
-
sub role_select_row {
my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_;
my $crstype = 'Course';
@@ -1689,15 +1900,15 @@ sub role_select_row {
sub course_select_row {
my ($title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles,
- $css_class,$crstype) = @_;
+ $css_class,$crstype,$standardnames) = @_;
my $output = &row_title($title,$css_class);
- $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype);
+ $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype,$standardnames);
$output .= &row_closure();
return $output;
}
sub course_selection {
- my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype) = @_;
+ my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype,$standardnames) = @_;
my $output = qq|
+
+$arrayindexofjs
+
+ENDSCRIPT
+}
+
+##############################################
+##############################################
+
# javascript_valid_email
#
# Generates javascript to validate an e-mail address.
@@ -2174,7 +2650,7 @@ sub htmltag{
# USAGE: inittags(@tags);
#
# EXAMPLES:
-# - my ($h1, $h2, $h3) = initTags( qw( h1 h2 h3 ) )
+# - my ($h1, $h2, $h3) = inittags( qw( h1 h2 h3 ) )
# $h1->("This is a headline") #Returns: This is a headline
#
# NOTES: See sub htmltag for further information.
@@ -2223,6 +2699,40 @@ sub scripttag {
};
+=item list_from_array( \@array, { listattr =>{}, itemattr =>{} } )
+
+Constructs a XHTML list from \@array.
+
+input:
+
+=over
+
+=item \@array
+
+A reference to the array containing text that will be wrapped in tags.
+
+=item { listattr => {}, itemattr =>{} }
+
+Attributes for and - passed in as hash references.
+See htmltag() for more details.
+
+=back
+
+returns: XHTML list as String.
+
+=cut
+
+# \@items, {listattr => { class => 'abc', id => 'xyx' }, itemattr => {class => 'abc', id => 'xyx'}}
+sub list_from_array {
+ my ($items, $args) = @_;
+ return unless (ref($items) eq 'ARRAY');
+ return unless scalar @$items;
+ my ($ul, $li) = inittags( qw(ul li) );
+ my $listitems = join '', map { $li->($_, $args->{itemattr}) } @$items;
+ return $ul->( $listitems, $args->{listattr} );
+}
+
+
##############################################
##############################################
@@ -2252,12 +2762,6 @@ sub scripttag {
#
# Outputs: A scalar containing the html markup for the menu.
-# ---- Remove when done ----
-# This routine is part of the redesign of LON-CAPA and it's
-# subject to change during this project.
-# Don't rely on its current functionality as it might be
-# changed or removed.
-# --------------------------
sub generate_menu {
my @menu = @_;
# subs for specific html elements
@@ -2273,11 +2777,15 @@ sub generate_menu {
# create the markup for the current $link and push it into @links.
# each entry consists of an image and a text optionally followed
# by a help link.
+ my $src;
+ if ($$link{icon} ne '') {
+ $src = '/res/adm/pages/'.$$link{icon};
+ }
push(@links,$li->(
$a->(
$img->("", {
class => "LC_noBorder LC_middle",
- src => "/res/adm/pages/$$link{icon}",
+ src => $src,
alt => mt(defined($$link{alttext}) ?
$$link{alttext} : $$link{linktext})
}), {
@@ -2380,9 +2888,6 @@ sub add_item_funclist {
return '
- '.$content.'
'."\n";
}
-##############################################
-##############################################
-
=pod
=item &end_funclist
@@ -2398,16 +2903,47 @@ add_item_funclist
Inputs: ./.
Returns: HTML code with function list end
-
=cut
-##############################################
-##############################################
-
sub end_funclist {
return "
\n";
}
+=pod
+
+=item funclist_from_array( \@array, {legend => 'text for legend'} )
+
+Constructs a XHTML list from \@array with the first item being visually
+highlighted and set to the value of legend or 'Functions' if legend is
+empty.
+
+=over
+
+=item \@array
+
+A reference to the array containing text that will be wrapped in tags.
+
+=item { legend => 'text' }
+
+A string that's used as visually highlighted first item. 'Functions' is used if
+it's value evaluates to false.
+
+=back
+
+returns: XHTML list as string.
+
+=back
+
+=cut
+
+sub funclist_from_array {
+ my ($items, $args) = @_;
+ return unless(ref($items) eq 'ARRAY');
+ $args->{legend} ||= mt('Functions');
+ return list_from_array( [$args->{legend}, @$items],
+ { listattr => {class => 'LC_funclist'} });
+}
+
1;
__END__
500 Internal Server Error
Internal Server Error
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.