20 |
my $class = shift; |
my $class = shift; |
21 |
my $self = bless {}, $class; |
my $self = bless {}, $class; |
22 |
$self->{fmt2str} = Message::Util::make_clone |
$self->{fmt2str} = Message::Util::make_clone |
23 |
($Message::Field::Date::DEFAULT{-fmt2str}); |
(\%Message::Field::Date::FMT2STR); |
24 |
$self; |
$self; |
25 |
} |
} |
26 |
|
|
51 |
$self->{'hook_'.$name} = $function; |
$self->{'hook_'.$name} = $function; |
52 |
} |
} |
53 |
|
|
54 |
|
sub set_element_decoders ($%) { |
55 |
|
my $self = shift; |
56 |
|
my %list = @_; |
57 |
|
for (keys %list) { |
58 |
|
if ($list{$_} eq 'enentity_html') { |
59 |
|
$list{$_} = \&Message::Util::enentity_html; |
60 |
|
} elsif ($list{$_} eq 'deentity_html') { |
61 |
|
$list{$_} = \&Message::Util::deentity_html; |
62 |
|
## TODO: escape_uri, unescape_uri |
63 |
|
} |
64 |
|
} |
65 |
|
$self->{element_decoder} = %list; |
66 |
|
} |
67 |
|
|
68 |
sub set_format ($$\&) { |
sub set_format ($$\&) { |
69 |
my $self = shift; |
my $self = shift; |
70 |
my $name = shift; |
my $name = shift; |
151 |
for my $i (0..$#{$self->{elements_message}}) { |
for my $i (0..$#{$self->{elements_message}}) { |
152 |
$p{$self->{elements_message}->[$i]} = ${$i+1}; |
$p{$self->{elements_message}->[$i]} = ${$i+1}; |
153 |
} |
} |
154 |
|
for my $n (keys %{$self->{element_decoder}}) { |
155 |
|
if ($p{$n} && ref $self->{element_decoder}->{$n}) { |
156 |
|
$p{$n} = &{ $self->{element_decoder}->{$n} } ($p{$n}); |
157 |
|
} |
158 |
|
} |
159 |
my $msg = &$f ($self, %p); |
my $msg = &$f ($self, %p); |
160 |
push @msg, $msg; |
push @msg, $msg; |
161 |
}gesx; |
}gesx; |
170 |
-fill_date => 0, |
-fill_date => 0, |
171 |
-fill_msgid => 0, |
-fill_msgid => 0, |
172 |
-fill_ua_name => 'x-shimbun-agent', |
-fill_ua_name => 'x-shimbun-agent', |
173 |
|
-format => 'news-usefor', |
174 |
-parse_all => 1, |
-parse_all => 1, |
175 |
; |
; |
176 |
my $hdr = $msg->header; |
my $hdr = $msg->header; |
219 |
if ($p{base_uri} && /uri/ && length $p{$_}) { |
if ($p{base_uri} && /uri/ && length $p{$_}) { |
220 |
require URI::WithBase; |
require URI::WithBase; |
221 |
$a->add ($name => URI::WithBase->new ($p{$_}, $p{base_uri})->abs); |
$a->add ($name => URI::WithBase->new ($p{$_}, $p{base_uri})->abs); |
222 |
|
} elsif (/color/) { |
223 |
|
$p{$_} = '#'.$p{$_} if $p{$_} =~ /^[A-Za-z0-9]{6}$/; |
224 |
|
$a->add ($name => $p{$_}) if length $p{$_}; |
225 |
} else { |
} else { |
226 |
$a->add ($name => $p{$_}) if length $p{$_}; |
$a->add ($name => $p{$_}) if length $p{$_}; |
227 |
} |
} |
243 |
$uri->display_name ($p{list_name}) if length $p{list_name}; |
$uri->display_name ($p{list_name}) if length $p{list_name}; |
244 |
} |
} |
245 |
if ($p{urn_template}) { |
if ($p{urn_template}) { |
246 |
my $urn = $self->Message::Field::Date::_date2str ({ |
my $urn = $date->stringify ( |
247 |
format_template => $p{urn_template}, |
-format_macros => $self->{fmt2str}, |
248 |
date_time => $date->unix_time, |
-format_template => $p{urn_template}, |
249 |
zone => $date->zone, |
-format_parameters => \%p, |
250 |
fmt2str => $self->{fmt2str}, |
); |
251 |
}, \%p); |
#my $urn = $self->Message::Field::Date::_date2str ({ |
252 |
|
# format_template => $p{urn_template}, |
253 |
|
# date_time => $date->unix_time, |
254 |
|
# zone => $date->zone, |
255 |
|
# fmt2str => $self->{fmt2str}, |
256 |
|
#}, \%p); |
257 |
$hdr->add ('x-uri')->value ($urn); |
$hdr->add ('x-uri')->value ($urn); |
258 |
} |
} |
259 |
## Additional information |
## Additional information |