Fixed a bug where the Interval Form would not work well with non-English languages.
Fixed display of the Interval Form field in Thingy and User Profile by adding a getValueAsHtml method.
This commit is contained in:
parent
153347e055
commit
81c9d117e5
4 changed files with 55 additions and 79 deletions
|
|
@ -11,6 +11,8 @@
|
|||
- fixed #9365: Account: when viewing another person's contribution, it displays my name
|
||||
- fixed #9351: Cannot translate phrase
|
||||
- fixed #9368: Gallery: All children included into navigation
|
||||
- fixed #9349: CS archival broken after update (Bernd Kalbfuß-Zimmermann)
|
||||
- fixed Display of Interval form control in Thingy and User profiling did not show units, only seconds.
|
||||
|
||||
7.6.7
|
||||
- fixed #9263: Thingy possibleValues processing, and List type autodetection.
|
||||
|
|
|
|||
|
|
@ -119,6 +119,19 @@ sub getValue {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValueAsHtml ( )
|
||||
|
||||
Returns the interval formatted as quantity and units.
|
||||
|
||||
=cut
|
||||
|
||||
sub getValueAsHtml {
|
||||
my $self = shift;
|
||||
return join ' ', $self->session->datetime->secondsToInterval($self->getOriginalValue);
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
|
@ -138,35 +151,38 @@ Renders an interval control.
|
|||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
my %units;
|
||||
tie %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = ('seconds'=>$i18n->get(704),
|
||||
'minutes'=>$i18n->get(705),
|
||||
'hours'=>$i18n->get(706),
|
||||
'days'=>$i18n->get(700),
|
||||
'weeks'=>$i18n->get(701),
|
||||
'months'=>$i18n->get(702),
|
||||
'years'=>$i18n->get(703));
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->getOriginalValue);
|
||||
# not sure why, but these things need to be defined like this or
|
||||
# they fail under some circumstnaces
|
||||
my $cmd = "WebGUI::Form::Integer";
|
||||
my $out = $cmd->new($self->session,
|
||||
name=>$self->get("name")."_interval",
|
||||
value=>$interval,
|
||||
extras=>$self->get("extras"),
|
||||
id=>$self->get('id')."_interval",
|
||||
)->toHtml;
|
||||
$cmd = "WebGUI::Form::SelectBox";
|
||||
$out .= $cmd->new($self->session,
|
||||
options=>\%units,
|
||||
name=>$self->get("name")."_units",
|
||||
id=>$self->get('id')."_units",
|
||||
value=>$units
|
||||
)->toHtml;
|
||||
return $out;
|
||||
my $self = shift;
|
||||
my %units;
|
||||
tie %units, 'Tie::IxHash';
|
||||
my $i18n = WebGUI::International->new($self->session);
|
||||
%units = (seconds => $i18n->get(704),
|
||||
minutes => $i18n->get(705),
|
||||
hours => $i18n->get(706),
|
||||
days => $i18n->get(700),
|
||||
weeks => $i18n->get(701),
|
||||
months => $i18n->get(702),
|
||||
years => $i18n->get(703),
|
||||
);
|
||||
my %reverseUnits = reverse %units;
|
||||
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->getOriginalValue);
|
||||
# not sure why, but these things need to be defined like this or
|
||||
# they fail under some circumstnaces
|
||||
my $cmd = "WebGUI::Form::Integer";
|
||||
my $out = $cmd->new($self->session,
|
||||
name => $self->get("name")."_interval",
|
||||
value => $interval,
|
||||
extras => $self->get("extras"),
|
||||
id => $self->get('id')."_interval",
|
||||
)->toHtml;
|
||||
$cmd = "WebGUI::Form::SelectBox";
|
||||
my $key = $reverseUnits{$units};
|
||||
$out .= $cmd->new($self->session,
|
||||
options => \%units,
|
||||
name => $self->get("name")."_units",
|
||||
id => $self->get('id')."_units",
|
||||
value => $key,
|
||||
)->toHtml;
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -810,7 +810,7 @@ sub new {
|
|||
|
||||
=head2 secondsToInterval ( seconds )
|
||||
|
||||
Returns an interval and units derived the number of seconds.
|
||||
Returns an interval and internationalized units derived the number of seconds.
|
||||
|
||||
=head3 seconds
|
||||
|
||||
|
|
@ -825,31 +825,31 @@ sub secondsToInterval {
|
|||
my ($interval, $units);
|
||||
if ($seconds >= 31536000) {
|
||||
$interval = round($seconds/31536000);
|
||||
$units = $i18n->get("years");
|
||||
$units = $i18n->get("703");
|
||||
}
|
||||
elsif ($seconds >= 2592000) {
|
||||
$interval = round($seconds/2592000);
|
||||
$units = $i18n->get("months");
|
||||
$units = $i18n->get("702");
|
||||
}
|
||||
elsif ($seconds >= 604800) {
|
||||
$interval = round($seconds/604800);
|
||||
$units = $i18n->get("weeks");
|
||||
$units = $i18n->get("701");
|
||||
}
|
||||
elsif ($seconds >= 86400) {
|
||||
$interval = round($seconds/86400);
|
||||
$units = $i18n->get("days");
|
||||
$units = $i18n->get("700");
|
||||
}
|
||||
elsif ($seconds >= 3600) {
|
||||
$interval = round($seconds/3600);
|
||||
$units = $i18n->get("hours");
|
||||
$units = $i18n->get("706");
|
||||
}
|
||||
elsif ($seconds >= 60) {
|
||||
$interval = round($seconds/60);
|
||||
$units = $i18n->get("minutes");
|
||||
$units = $i18n->get("705");
|
||||
}
|
||||
else {
|
||||
$interval = $seconds;
|
||||
$units = $i18n->get("seconds");
|
||||
$units = $i18n->get("704");
|
||||
}
|
||||
return ($interval, $units);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4290,48 +4290,6 @@ Users may override this setting in their profile.
|
|||
context => q{i18n label for YUI paginator},
|
||||
},
|
||||
|
||||
'years' => {
|
||||
message => q{years},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'months' => {
|
||||
message => q{months},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'weeks' => {
|
||||
message => q{weeks},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'days' => {
|
||||
message => q{days},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'hours' => {
|
||||
message => q{hours},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'minutes' => {
|
||||
message => q{minutes},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'seconds' => {
|
||||
message => q{seconds},
|
||||
lastUpdated => 1226706547,
|
||||
context => q{i18n label for time duration in WebGUI::DateTime},
|
||||
},
|
||||
|
||||
'profile privacy settings' => {
|
||||
message => q{Privacy Settings},
|
||||
lastUpdated => 1226706547,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue