* Don't autovifivy @fields array entries.
[interchange.git] / code / SystemTag / warnings.coretag
1 # Copyright 2002-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 # $Id: warnings.coretag,v 1.9 2007-09-21 16:15:48 kwalsh Exp $
9
10 UserTag warning  Alias      warnings
11
12 UserTag warnings Order      message
13 UserTag warnings addAttr
14 UserTag warnings PosNumber  1
15 UserTag warnings Version    $Revision: 1.9 $
16 UserTag warnings Routine    <<EOR
17 sub {
18         my($message, $opt) = @_;
19
20         if($message) {
21                 my $param = ref $opt->{param} ? $opt->{param} : [$opt->{param}];
22                 push_warning($message, @$param);
23                 return unless $opt->{show};
24         }
25
26         return unless $Vend::Session->{warnings};
27
28         my $out = $opt->{header} || "";
29         if($opt->{auto}) {
30                 $opt->{list_container} ||= 'ul';
31                 $out .= "<$opt->{list_container}";
32                 for(qw/ class style extra /) {
33                         next unless $opt->{"list_$_"};
34                         if($opt->{"list_$_"} =~ m{^\s*$_\s*=}i) {
35                                 $out .= ' ' . $opt->{"list_$_"};
36                         }
37                         else {
38                                 $out .= qq{ $_="$opt->{"list_$_"}"};
39                         }
40                 }
41                 $out .= '>';
42                 $opt->{joiner} = '<li>'
43                         if ! length($opt->{joiner});
44                 $out .= $opt->{joiner};
45         }
46         elsif(! length($opt->{joiner})) {
47                 $opt->{joiner} = "\n";
48         }
49         $out .= join $opt->{joiner}, grep /\S/, @{$Vend::Session->{warnings}};
50         $out .= "</$opt->{list_container}>" if $opt->{auto};
51         $out .= $opt->{footer} if length($opt->{footer});
52         delete $Vend::Session->{warnings} unless $opt->{keep};
53         return $out;
54 }
55 EOR