--- loncom/interface/lonhtmlcommon.pm 2010/01/22 13:54:06 1.182.4.9 +++ loncom/interface/lonhtmlcommon.pm 2009/04/04 20:06:37 1.206 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.182.4.9 2010/01/22 13:54:06 raeburn Exp $ +# $Id: lonhtmlcommon.pm,v 1.206 2009/04/04 20:06:37 bisitz Exp $ # # Copyright Michigan State University Board of Trustees # @@ -62,31 +62,6 @@ use Apache::lonlocal; use Apache::lonnet; use LONCAPA; -############################################## -############################################## - -=pod - -=item confirm_success - -Successful completion of an operation message - -=cut - -sub confirm_success { - my ($message,$failure)=@_; - if ($failure) { - return ''."\n" - .''.&mt('Error').' '."\n" - .$message."\n" - .''."\n"; - } else { - return ''."\n" - .''.&mt('OK').' '."\n" - .$message."\n" - .''."\n"; - } -} ############################################## ############################################## @@ -130,13 +105,11 @@ sub dragmath_js { my ($popup) = @_; return < - // ENDDRAGMATHJS @@ -432,7 +405,6 @@ sub date_setter { my $result = "\n\n"; $result .= < -// ENDJS - $result .= ' '; + $result .= ' '; my $monthselector = qq{'; # Day my $dayselector = qq{}; # Year - my $yearselector = qq{}; + my $yearselector = qq{}; # my $hourselector = qq{\n|; + '.$allcrs.'
'; + ($formname,'pickcourse','pickdomain','coursedesc','',1).''; + $output .= ''.&mt('All courses').'
'; if ($totcodes > 0) { my $numtitles = @$codetitles; if ($numtitles > 0) { @@ -1731,7 +1680,7 @@ sub course_selection { $output .= '
'; } } - $output .= ''.$pickspec.' '.$courseform.'  selected.
'."\n"; + $output .= ''.&mt('Pick specific course(s):').' '.$courseform.'  selected.
'."\n"; return $output; } @@ -1786,6 +1735,7 @@ 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|
@@ -1827,7 +1777,8 @@ sub topic_bar { return '
'.&mt('Step [_1]',$imgnum).
-              ' '.$title.' + '"src="/res/adm/pages/bl_step'.$imgnum.'.gif" />  + '.$title.'
'; } @@ -1964,7 +1915,7 @@ sub set_form_elements { $values{$name}[$i] =~ s/([\r\n\f]+)/\\n/g; $values{$name}[$i] =~ s/"/\\"/g; } - if (($$elements{$name} eq 'text') || ($$elements{$name} eq 'hidden')) { + if ($$elements{$name} eq 'text') { my $numvalues = @{$values{$name}}; if ($numvalues > 1) { my $valuestring = join('","',@{$values{$name}}); @@ -1999,8 +1950,6 @@ sub set_form_elements { $output .= qq| if (courseForm.elements['$name'].value == "$value") { courseForm.elements['$name'].checked = true; - } else { - courseForm.elements['$name'].checked = false; }|; } } @@ -2042,7 +1991,6 @@ sub set_form_elements { } } $output .= " - return; }\n"; return $output; } @@ -2084,7 +2032,108 @@ END return $scripttag; } +############################################## +############################################## +# 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 = @_; + + # usage: $wrap->(element, content, {attribute => value,...}); + # output: content enclosed in html conform tags + my $wrap = sub { + return + qq|<$_[0]| + . join( '', map { qq| $_="${$_[2]}{$_}"| } keys %{ $_[2] } ) + . ($_[1] ? qq|>$_[1]| : qq|/>|). "\n"; + }; + + # subs for specific html elements + my $h3 = sub { return $wrap->( "h3", @_ ) }; + my $div = sub { return $wrap->( "div", @_ ) }; + my $ul = sub { return $wrap->( "ul", @_ ) }; + my $li = sub { return $wrap->( "li", @_ ) }; + my $a = sub { return $wrap->( "a", @_ ) }; + my $img = sub { return $wrap->( "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: + #

    title

    • ...
    • ...
    + # 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_ContentBoxSpecial LC_400Box"}) if scalar(@links); + } + + # wrap the joined @categories in another
    (column layout) + return $div->(join('', @categories), {class => "LC_columnSection"}); +} 1;