");
+ $("#LC_rt_"+id).click(editorHandler);
+ });
+
+ });
+';
+ $output.="\nwindow.status='Activated Editfields';\n"
+ .'// ]]>'."\n"
+ .' '.
&disablelink(@fields);
return $output;
}
@@ -1265,15 +1383,13 @@ sub htmlareabrowser {
=item breadcrumbs
Compiles the previously registered breadcrumbs into an series of links.
-FAQ and BUG links will be placed on the left side of the table if they
-are defined for the last registered breadcrumb.
Additionally supports a 'component', which will be displayed on the
-right side of the table (without a link).
+right side of the breadcrumbs enclosing div (without a link).
A link to help for the component will be included if one is specified.
All inputs can be undef without problems.
-Inputs: $component (the large text on the right side of the table),
+Inputs: $component (the text on the right side of the breadcrumbs trail),
$component_help
$menulink (boolean, controls whether to include a link to /adm/menu)
$helplink (if 'nohelp' don't include the orange help link)
@@ -1303,25 +1419,24 @@ returns: nothing
############################################################
{
my @Crumbs;
+ my %tools = ();
sub breadcrumbs {
- my ($component,$component_help,$menulink,$helplink,$css_class,$no_mt) = @_;
- #
- $css_class ||= 'LC_breadcrumbs';
- my $Str1 = '';
- my $Str = '';
+ 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='';
- # Crumb Symbol
- my $crumbsymbol = '▶ ';
+ 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;
@@ -1331,44 +1446,47 @@ 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,
- });
- }
- my $links .= '
'."\n";
+ if ($faq ne '' || $component_help ne '' || $bug ne '') {
+ $icons .= &Apache::loncommon::help_open_menu($component,
+ $component_help,
+ $faq,$bug);
}
#
+
+
+ unless ($CourseBreadcrumbs) {
+ $links = htmltag('ol', $links, { id => "LC_MenuBreadcrumbs" });
+ } else {
+ $links = htmltag('ul', $links, { class => "LC_CourseBreadcrumbs" });
+ }
+
+ if ($component) {
+ $links = htmltag('span',
+ ( $no_mt ? $component : mt($component) ).
+ ( $icons ? $icons : '' ),
+ { class => 'LC_breadcrumbs_component' } )
+ .$links;
+ }
+
+ render_tools(\$links);
+ $links = htmltag('div', $links,
+ { id => "LC_breadcrumbs" }) unless ($CourseBreadcrumbs) ;
+ render_advtools(\$links);
+
# Return the @Crumbs stack to what we started with
push(@Crumbs,$last);
shift(@Crumbs);
- #
- return "$Str\n$Str1";
+ # Return the breadcrumb's line
+ return "$links";
}
sub clear_breadcrumbs {
undef(@Crumbs);
+ undef(%tools);
}
sub add_breadcrumb {
- push (@Crumbs,@_);
+ push(@Crumbs,@_);
+ }
+
+=item add_breadcrumb_tool($category, $html)
+
+Adds $html to $category of the breadcrumb toolbar container.
+
+$html is usually a link to a page that invokes a function on the currently
+displayed data (e.g. print when viewing a problem)
+
+Currently there are 3 possible values for $category:
+
+=over
+
+=item navigation
+left of breadcrumbs line
+
+=item tools
+right of breadcrumbs line
+
+=item advtools
+advanced tools shown in a separate box below breadcrumbs line
+
+=back
+
+returns: nothing
+
+=cut
+
+ sub add_breadcrumb_tool {
+ my ($category, @html) = @_;
+ return unless @html;
+ if (!defined(%tools)) {
+ %tools = ( navigation => [], tools => [], advtools => []);
+ }
+
+ #this cleans data received from lonmenu::innerregister
+ @html = grep {defined $_ && $_ ne ''} @html;
+ for (@html) {
+ s/align="(right|left)"//;
+ s/// 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);
+ }
+
+=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 defined %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'}) );
}
} # End of scope for @Crumbs
@@ -1505,9 +1728,9 @@ END
}
sub row_title {
+ 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';
- my ($title,$css_title_class,$css_value_class) = @_;
$css_title_class ||= 'LC_pick_box_title';
$css_title_class = 'class="'.$css_title_class.'"';
@@ -1517,7 +1740,7 @@ sub row_title {
$title .= ':';
}
my $output = <<"ENDONE";
-
+
$title
@@ -1548,6 +1771,10 @@ ENDTWO
sub role_select_row {
my ($roles,$title,$css_class,$show_separate_custom,$cdom,$cnum) = @_;
+ my $crstype = 'Course';
+ if ($cdom ne '' && $cnum ne '') {
+ $crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
+ }
my $output;
if (defined($title)) {
$output = &row_title($title,$css_class);
@@ -1572,7 +1799,7 @@ sub role_select_row {
$plrole = &mt('Custom Role');
}
} else {
- $plrole=&Apache::lonnet::plaintext($role);
+ $plrole=&Apache::lonnet::plaintext($role,$crstype);
}
if (($role ne 'cr') || (!$show_separate_custom)) {
$output .= '
'.$plrole.'
';
@@ -1587,17 +1814,18 @@ sub role_select_row {
sub course_select_row {
my ($title,$formname,$totcodes,$codetitles,$idlist,$idlist_titles,
- $css_class) = @_;
+ $css_class,$crstype) = @_;
my $output = &row_title($title,$css_class);
- $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+ $output .= &course_selection($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype);
$output .= &row_closure();
return $output;
}
sub course_selection {
- my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles) = @_;
+ my ($formname,$totcodes,$codetitles,$idlist,$idlist_titles,$crstype) = @_;
my $output = qq|
|;
+
+ my ($allcrs,$pickspec);
+ if ($crstype eq 'Community') {
+ $allcrs = &mt('All communities');
+ $pickspec = &mt('Pick specific communities:');
+ } else {
+ $allcrs = &mt('All courses');
+ $pickspec = &mt('Pick specific course(s):');
+ }
+
my $courseform=''.&Apache::loncommon::selectcourse_link
- ($formname,'pickcourse','pickdomain','coursedesc','',1).'';
- $output .= ''.&mt('All courses').' ';
+ ($formname,'pickcourse','pickdomain','coursedesc','',1,$crstype).'';
+ $output .= ''.$allcrs.' ';
if ($totcodes > 0) {
my $numtitles = @$codetitles;
if ($numtitles > 0) {
@@ -1669,7 +1908,7 @@ sub course_selection {
$output .= '
';
}
}
- $output .= ''.&mt('Pick specific course(s):').' '.$courseform.' selected. '."\n";
+ $output .= ''.$pickspec.' '.$courseform.' selected. '."\n";
return $output;
}
@@ -1724,7 +1963,6 @@ sub email_default_row {
sub submit_row {
my ($title,$cmd,$submit_text,$css_class) = @_;
- $submit_text = &mt($submit_text);
my $output = &row_title($title,$css_class,'LC_pick_box_submit');
$output .= qq|
@@ -1758,23 +1996,25 @@ 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 '
-
-
- '.$title.'
-
-';
+ my ($num,$title) = @_;
+ my $number = '';
+ if ($num ne '') {
+ $number = ''.$num.'';
+ }
+ return '
'.$number.$title.'
';
}
##############################################
##############################################
-
# echo_form_input
#
# Generates html markup to add form elements from the referrer page
@@ -1839,7 +2079,6 @@ sub echo_form_input {
##############################################
##############################################
-
# set_form_elements
#
# Generates javascript to set form elements to values based on
@@ -1904,7 +2143,7 @@ sub set_form_elements {
$values{$name}[$i] =~ s/([\r\n\f]+)/\\n/g;
$values{$name}[$i] =~ s/"/\\"/g;
}
- if ($$elements{$name} eq 'text') {
+ if (($$elements{$name} eq 'text') || ($$elements{$name} eq 'hidden')) {
my $numvalues = @{$values{$name}};
if ($numvalues > 1) {
my $valuestring = join('","',@{$values{$name}});
@@ -1939,6 +2178,8 @@ sub set_form_elements {
$output .= qq|
if (courseForm.elements['$name'].value == "$value") {
courseForm.elements['$name'].checked = true;
+ } else {
+ courseForm.elements['$name'].checked = false;
}|;
}
}
@@ -1980,6 +2221,7 @@ sub set_form_elements {
}
}
$output .= "
+ return;
}\n";
return $output;
}
@@ -2021,6 +2263,120 @@ END
return $scripttag;
}
+
+# 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;
+}
+
+
+# USAGE: scripttag(scriptcode, [start|end|both]);
+#
+# EXAMPLES:
+# - scripttag("alert('Hello World!')", 'both')
+# returns:
+#
+#
+# NOTES:
+# - works currently only for javascripts
+#
+# OUTPUT:
+# Scriptcode properly enclosed in