--- loncom/interface/lonhtmlcommon.pm 2010/10/04 14:34:46 1.284 +++ loncom/interface/lonhtmlcommon.pm 2011/01/03 13:10:12 1.285 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common html routines # -# $Id: lonhtmlcommon.pm,v 1.284 2010/10/04 14:34:46 www Exp $ +# $Id: lonhtmlcommon.pm,v 1.285 2011/01/03 13:10:12 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1603,7 +1603,7 @@ returns: nothing sub add_breadcrumb_tool { my ($category, @html) = @_; return unless @html; - if (!defined(%tools)) { + if (!keys(%tools)) { %tools = ( navigation => [], tools => [], advtools => []); } @@ -1643,7 +1643,7 @@ returns: nothing #TODO might split this in separate functions for each category sub render_tools { my ($breadcrumbs) = @_; - return unless defined %tools; + return unless (keys(%tools)); my $navigation = list_from_array($tools{navigation}, { listattr => { class=>"LC_breadcrumb_tools_navigation" } }); @@ -2105,30 +2105,30 @@ sub echo_form_input { if ($key =~ /^form\.(.+)$/) { my $name = $1; my $match = 0; - if ((!@{$excluded}) || (!grep/^$name$/,@{$excluded})) { - if (defined($regexps)) { - if (@{$regexps} > 0) { - foreach my $regexp (@{$regexps}) { - if ($name =~ /\Q$regexp\E/) { - $match = 1; - last; - } + if (ref($excluded) eq 'ARRAY') { + next if (grep(/^\Q$name\E$/,@{$excluded})); + } + if (ref($regexps) eq 'ARRAY') { + if (@{$regexps} > 0) { + foreach my $regexp (@{$regexps}) { + if ($name =~ /$regexp/) { + $match = 1; + last; } } } - if (!$match) { - if (ref($env{$key})) { - foreach my $value (@{$env{$key}}) { - $value = &HTML::Entities::encode($value,'<>&"'); - $output .= ''."\n"; - } - } else { - my $value = &HTML::Entities::encode($env{$key},'<>&"'); - $output .= ''."\n"; - } + } + next if ($match); + if (ref($env{$key}) eq 'ARRAY') { + foreach my $value (@{$env{$key}}) { + $value = &HTML::Entities::encode($value,'<>&"'); + $output .= ''."\n"; } + } else { + my $value = &HTML::Entities::encode($env{$key},'<>&"'); + $output .= ''."\n"; } } } @@ -2429,6 +2429,7 @@ returns: XHTML list as String. # \@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; @@ -2641,6 +2642,7 @@ returns: XHTML list as string. 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'} });