';
+ my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt, $CourseBreadcrumbs) = @_;
#
+ $css_class ||= 'LC_breadcrumbs';
+
# Make the faq and bug data cascade
- my $faq = '';
- my $bug = '';
- my $help='';
+ my $faq = '';
+ my $bug = '';
+ my $help = '';
+ # Crumb Symbol
+ my $crumbsymbol = '»';
# The last breadcrumb does not have a link, so handle it separately.
my $last = pop(@Crumbs);
#
# The first one should be the course or a menu link
- if (!defined($menulink)) { $menulink=1; }
+ if (!defined($menulink)) { $menulink=1; }
if ($menulink) {
my $description = 'Menu';
my $no_mt_descr = 0;
@@ -1307,44 +1376,46 @@ returns: nothing
$env{'course.'.$env{'request.course.id'}.'.description'};
$no_mt_descr = 1;
}
- unshift(@Crumbs,{
- href =>'/adm/menu',
- title =>'Go to main menu',
- target =>'_top',
- text =>$description,
- no_mt =>$no_mt_descr,
- });
+ $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('->',
+ my $links = join "",
map {
- $faq = $_->{'faq'} if (exists($_->{'faq'}));
- $bug = $_->{'bug'} if (exists($_->{'bug'}));
+ $faq = $_->{'faq'} if (exists($_->{'faq'}));
+ $bug = $_->{'bug'} if (exists($_->{'bug'}));
$help = $_->{'help'} if (exists($_->{'help'}));
- my $result = '{'target'}) && $_->{'target'} ne '') {
- $result .= 'target="'.$_->{'target'}.'" ';
- }
- if ($_->{'no_mt'}) {
- $result .='title="'.$_->{'title'}.'">'.
- $_->{'text'}.' ';
- } else {
- $result .='title="'.&mt($_->{'title'}).'">'.
- &mt($_->{'text'}).'';
- }
- $result;
- } @Crumbs
- );
- $links .= '->' if ($links ne '');
- if ($last->{'no_mt'}) {
- $links .= ''.$last->{'text'}.' ';
- } else {
- $links .= ''.&mt($last->{'text'}).' ';
- }
- #
+
+ my $result = htmltag( 'a',
+ $_->{no_mt} ?
+ $_->{text} : mt($_->{text}),
+ {
+ href => $_->{href},
+ title => $_->{no_mt} ?
+ $_->{title} : mt($_->{title}),
+ target => $_->{target},
+ });
+ $result = htmltag( 'li', "$result $crumbsymbol");
+ } @Crumbs;
+
+ #should the last Element be translated?
+ $links .= htmltag( 'li',
+ htmltag( 'b',
+ $last->{'no_mt'} ?
+ $last->{'text'} : mt($last->{'text'}) ));
+
my $icons = '';
- $faq = $last->{'faq'} if (exists($last->{'faq'}));
- $bug = $last->{'bug'} if (exists($last->{'bug'}));
+ $faq = $last->{'faq'} if (exists($last->{'faq'}));
+ $bug = $last->{'bug'} if (exists($last->{'bug'}));
$help = $last->{'help'} if (exists($last->{'help'}));
$component_help=($component_help?$component_help:$help);
# if ($faq ne '') {
@@ -1353,29 +1424,36 @@ returns: nothing
# if ($bug ne '') {
# $icons .= &Apache::loncommon::help_open_bug($bug);
# }
- if ($faq ne '' || $component_help ne '' || $bug ne '') {
- $icons .= &Apache::loncommon::help_open_menu($component,
- $component_help,
- $faq,$bug);
- }
- #
- $Str .= $links.' ';
- #
- if (defined($component)) {
- $Str .= ''.
- &mt($component);
- if ($icons ne '') {
- $Str .= ' '.$icons;
- }
- $Str .= ' ';
+ if ($faq ne '' || $component_help ne '' || $bug ne '') {
+ $icons .= &Apache::loncommon::help_open_menu($component,
+ $component_help,
+ $faq,$bug);
}
- $Str .= '
'."\n";
#
+
+
+ unless ($CourseBreadcrumbs) {
+ $links = htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
+ } else {
+ $links = htmltag('ul', $links, { id => "LC_CourseBreadcrumbs" });
+ }
+
+ if ($component) {
+ $links = htmltag('span',
+ ( $no_mt ? $component : mt($component) ).
+ ( $icons ? $icons : '' ),
+ { class => 'LC_breadcrumbs_component' } )
+ .$links;
+ }
+
+ $links = htmltag('div', $links,
+ { id => "LC_head_subbox" }) unless ($CourseBreadcrumbs) ;
+
# Return the @Crumbs stack to what we started with
push(@Crumbs,$last);
shift(@Crumbs);
- #
- return $Str;
+ # Return the breadcrumb's line
+ return "$links";
}
sub clear_breadcrumbs {
@@ -1444,6 +1522,9 @@ returns: nothing
# routines, but can also be called directly to start and end rows which have
# needs that are not accommodated by the *_select_row() routines.
+{ # Start: row_count block for pick_box
+my @row_count;
+
sub start_pick_box {
my ($css_class) = @_;
if (defined($css_class)) {
@@ -1451,6 +1532,7 @@ sub start_pick_box {
} else {
$css_class= 'class="LC_pick_box"';
}
+ unshift(@row_count,0);
my $output = <<"END";
+END
+ return $output;
+}
+
sub row_title {
my ($title,$css_title_class,$css_value_class) = @_;
+ $row_count[0]++;
+ my $css_class = ($row_count[0] % 2)?'LC_odd_row':'LC_even_row';
$css_title_class ||= 'LC_pick_box_title';
$css_title_class = 'class="'.$css_title_class.'"';
$css_value_class ||= 'LC_pick_box_value';
- $css_value_class = 'class="'.$css_value_class.'"';
if ($title ne '') {
$title .= ':';
@@ -1480,7 +1571,7 @@ sub row_title {
$title
-
+
ENDONE
return $output;
}
@@ -1502,6 +1593,9 @@ ENDTWO
return $output;
}
+} # End: row_count block for pick_box
+
+
sub role_select_row {
my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_;
my $output;
@@ -1509,7 +1603,7 @@ sub role_select_row {
$output = &row_title($title,$css_class);
}
$output .= qq|
- \n|;
+ \n|;
foreach my $role (@$roles) {
my $plrole;
if ($role eq 'ow') {
@@ -1554,6 +1648,7 @@ sub course_selection {
my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_;
my $output = qq|
|;
my $courseform=''.&Apache::loncommon::selectcourse_link
@@ -1636,7 +1732,7 @@ sub status_select_row {
$output = &row_title($title,$css_class,'LC_pick_box_select');
}
$output .= qq|
- \n|;
+ \n|;
foreach my $status_type (sort(keys(%{$types}))) {
$output .= ' '.$$types{$status_type}.' ';
}
@@ -1710,6 +1806,23 @@ 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
+#
+sub topic_bar {
+ my ($imgnum,$title) = @_;
+ return ''
+ .'
'
+ .' '.$title
+ .'
';
+}
+
+##############################################
+##############################################
# echo_form_input
#
@@ -1958,6 +2071,238 @@ END
}
+# USAGE: htmltag(element, content, {attribute => value,...});
+#
+# EXAMPLES:
+# - htmltag('a', 'this is an anchor', {href => 'www.example.com',
+# title => 'this is a title'})
+#
+# - You might want to set up needed tags like:
+#
+# my $h3 = sub { return htmltag( "h3", @_ ) };
+#
+# ... and use them: $h3->("This is a headline")
+#
+# - To set up a couple of tags, see sub inittags
+#
+# NOTES:
+# - Empty elements, such as are correctly terminated,
+# i.e. htmltag('br') returns
+# - Empty attributes (title="") are filtered out.
+# - The function will not check for deprecated attributes.
+#
+# OUTPUT: content enclosed in xhtml conform tags
+sub htmltag{
+ return
+ qq|<$_[0]|
+ . join( '', map { qq| $_="${$_[2]}{$_}"| if ${$_[2]}{$_} } keys %{ $_[2] } )
+ . ($_[1] ? qq|>$_[1]$_[0]>| : qq|/>|). "\n";
+};
+
+
+# USAGE: inittags(@tags);
+#
+# EXAMPLES:
+# - 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.
+#
+# OUTPUT: List of subroutines.
+sub inittags {
+ my @tags = @_;
+ return map { my $tag = $_;
+ sub { return htmltag( $tag, @_ ) }
+ } @tags;
+}
+
+
+##############################################
+##############################################
+
+# generate_menu
+#
+# Generates html markup for a menu.
+#
+# Inputs:
+# An array of following structure:
+# ({ categorytitle => 'Categorytitle',
+# items => [
+# {
+# linktext => 'Text to be displayed',
+# url => 'URL the link is pointing to, i.e. /adm/site?action=dosomething',
+# permission => 'Contains permissions as returned from lonnet::allowed(),
+# must evaluate to true in order to activate the link',
+# icon => 'icon filename',
+# alttext => 'alt text for the icon',
+# help => 'Name of the corresponding helpfile',
+# linktitle => 'Description of the link (used for title tag)'
+# },
+# ...
+# ]
+# },
+# ...
+# )
+#
+# 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
+ my ($h3, $div, $ul, $li, $a, $img) = inittags( qw(h3 div ul li a img) );
+
+ my @categories; # each element represents the entire markup for a category
+
+ foreach my $category (@menu) {
+ my @links; # contains the links for the current $category
+ foreach my $link (@{$$category{items}}) {
+ next unless $$link{permission};
+
+ # 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.
+ push @links, $li->(
+ $a->(
+ $img->("", {
+ class => "LC_noBorder LC_middle",
+ src => "/res/adm/pages/$$link{icon}",
+ alt => mt(defined($$link{alttext}) ?
+ $$link{alttext} : $$link{linktext})
+ }), {
+ href => $$link{url},
+ title => mt($$link{linktitle})
+ }).
+ $a->(mt($$link{linktext}), {
+ href => $$link{url},
+ title => mt($$link{linktitle}),
+ class => "LC_menubuttons_link"
+ }).
+ (defined($$link{help}) ?
+ Apache::loncommon::help_open_topic($$link{help}) : ''),
+ {class => "LC_menubuttons_inline_text"});
+ }
+
+ # wrap categorytitle in , concatenate with
+ # joined and in tags wrapped @links
+ # and wrap everything in an enclosing and push it into
+ # @categories
+ # such that each element looks like:
+ #
+ # the category won't be added if there aren't any links
+ push @categories,
+ $div->($h3->(mt($$category{categorytitle}), {class=>"LC_hcell"}).
+ $ul->(join('' ,@links), {class =>"LC_ListStyleNormal" }),
+ {class=>"LC_Box LC_400Box"}) if scalar(@links);
+ }
+
+ # wrap the joined @categories in another
(column layout)
+ return $div->(join('', @categories), {class => "LC_columnSection"});
+}
+
+##############################################
+##############################################
+
+=pod
+
+=item &start_funclist
+
+Start list of available functions
+
+Typically used to offer a simple list of available functions
+at top or bottom of page.
+All available functions/actions for the current page
+should be included in this list.
+
+If the optional headline text is not provided, a default text will be used.
+
+
+Related routines:
+=over 4
+add_item_funclist
+end_funclist
+=back
+
+
+Inputs: (optional) headline text
+
+Returns: HTML code with function list start
+
+=cut
+
+##############################################
+##############################################
+
+sub start_funclist {
+ my($legendtext)=@_;
+ $legendtext=&mt('Functions') if !$legendtext;
+ return "
\n$legendtext \n"
+ .''."\n";
+}
+
+
+##############################################
+##############################################
+
+=pod
+
+=item &add_item_funclist
+
+Adds an item to the list of available functions
+
+Related routines:
+=over 4
+start_funclist
+end_funclist
+=back
+
+Inputs: content item with text and link to function
+
+Returns: HTML code with list item for funclist
+
+=cut
+
+##############################################
+##############################################
+
+sub add_item_funclist {
+ my($content) = @_;
+ return ''.$content.' '."\n";
+}
+
+##############################################
+##############################################
+
+=pod
+
+=item &end_funclist
+
+End list of available functions
+
+Related routines:
+=over 4
+start_funclist
+add_item_funclist
+=back
+
+Inputs: ./.
+
+Returns: HTML code with function list end
+
+=cut
+
+##############################################
+##############################################
+
+sub end_funclist {
+ my($r)=@_;
+ return " \n \n";
+}
1;