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 #9365: Account: when viewing another person's contribution, it displays my name
|
||||||
- fixed #9351: Cannot translate phrase
|
- fixed #9351: Cannot translate phrase
|
||||||
- fixed #9368: Gallery: All children included into navigation
|
- 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
|
7.6.7
|
||||||
- fixed #9263: Thingy possibleValues processing, and List type autodetection.
|
- 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 ( )
|
=head2 isDynamicCompatible ( )
|
||||||
|
|
||||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
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
|
=cut
|
||||||
|
|
||||||
sub toHtml {
|
sub toHtml {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my %units;
|
my %units;
|
||||||
tie %units, 'Tie::IxHash';
|
tie %units, 'Tie::IxHash';
|
||||||
my $i18n = WebGUI::International->new($self->session);
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
%units = ('seconds'=>$i18n->get(704),
|
%units = (seconds => $i18n->get(704),
|
||||||
'minutes'=>$i18n->get(705),
|
minutes => $i18n->get(705),
|
||||||
'hours'=>$i18n->get(706),
|
hours => $i18n->get(706),
|
||||||
'days'=>$i18n->get(700),
|
days => $i18n->get(700),
|
||||||
'weeks'=>$i18n->get(701),
|
weeks => $i18n->get(701),
|
||||||
'months'=>$i18n->get(702),
|
months => $i18n->get(702),
|
||||||
'years'=>$i18n->get(703));
|
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
|
my %reverseUnits = reverse %units;
|
||||||
# they fail under some circumstnaces
|
my ($interval, $units) = $self->session->datetime->secondsToInterval($self->getOriginalValue);
|
||||||
my $cmd = "WebGUI::Form::Integer";
|
# not sure why, but these things need to be defined like this or
|
||||||
my $out = $cmd->new($self->session,
|
# they fail under some circumstnaces
|
||||||
name=>$self->get("name")."_interval",
|
my $cmd = "WebGUI::Form::Integer";
|
||||||
value=>$interval,
|
my $out = $cmd->new($self->session,
|
||||||
extras=>$self->get("extras"),
|
name => $self->get("name")."_interval",
|
||||||
id=>$self->get('id')."_interval",
|
value => $interval,
|
||||||
)->toHtml;
|
extras => $self->get("extras"),
|
||||||
$cmd = "WebGUI::Form::SelectBox";
|
id => $self->get('id')."_interval",
|
||||||
$out .= $cmd->new($self->session,
|
)->toHtml;
|
||||||
options=>\%units,
|
$cmd = "WebGUI::Form::SelectBox";
|
||||||
name=>$self->get("name")."_units",
|
my $key = $reverseUnits{$units};
|
||||||
id=>$self->get('id')."_units",
|
$out .= $cmd->new($self->session,
|
||||||
value=>$units
|
options => \%units,
|
||||||
)->toHtml;
|
name => $self->get("name")."_units",
|
||||||
return $out;
|
id => $self->get('id')."_units",
|
||||||
|
value => $key,
|
||||||
|
)->toHtml;
|
||||||
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -810,7 +810,7 @@ sub new {
|
||||||
|
|
||||||
=head2 secondsToInterval ( seconds )
|
=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
|
=head3 seconds
|
||||||
|
|
||||||
|
|
@ -825,31 +825,31 @@ sub secondsToInterval {
|
||||||
my ($interval, $units);
|
my ($interval, $units);
|
||||||
if ($seconds >= 31536000) {
|
if ($seconds >= 31536000) {
|
||||||
$interval = round($seconds/31536000);
|
$interval = round($seconds/31536000);
|
||||||
$units = $i18n->get("years");
|
$units = $i18n->get("703");
|
||||||
}
|
}
|
||||||
elsif ($seconds >= 2592000) {
|
elsif ($seconds >= 2592000) {
|
||||||
$interval = round($seconds/2592000);
|
$interval = round($seconds/2592000);
|
||||||
$units = $i18n->get("months");
|
$units = $i18n->get("702");
|
||||||
}
|
}
|
||||||
elsif ($seconds >= 604800) {
|
elsif ($seconds >= 604800) {
|
||||||
$interval = round($seconds/604800);
|
$interval = round($seconds/604800);
|
||||||
$units = $i18n->get("weeks");
|
$units = $i18n->get("701");
|
||||||
}
|
}
|
||||||
elsif ($seconds >= 86400) {
|
elsif ($seconds >= 86400) {
|
||||||
$interval = round($seconds/86400);
|
$interval = round($seconds/86400);
|
||||||
$units = $i18n->get("days");
|
$units = $i18n->get("700");
|
||||||
}
|
}
|
||||||
elsif ($seconds >= 3600) {
|
elsif ($seconds >= 3600) {
|
||||||
$interval = round($seconds/3600);
|
$interval = round($seconds/3600);
|
||||||
$units = $i18n->get("hours");
|
$units = $i18n->get("706");
|
||||||
}
|
}
|
||||||
elsif ($seconds >= 60) {
|
elsif ($seconds >= 60) {
|
||||||
$interval = round($seconds/60);
|
$interval = round($seconds/60);
|
||||||
$units = $i18n->get("minutes");
|
$units = $i18n->get("705");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$interval = $seconds;
|
$interval = $seconds;
|
||||||
$units = $i18n->get("seconds");
|
$units = $i18n->get("704");
|
||||||
}
|
}
|
||||||
return ($interval, $units);
|
return ($interval, $units);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4290,48 +4290,6 @@ Users may override this setting in their profile.
|
||||||
context => q{i18n label for YUI paginator},
|
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' => {
|
'profile privacy settings' => {
|
||||||
message => q{Privacy Settings},
|
message => q{Privacy Settings},
|
||||||
lastUpdated => 1226706547,
|
lastUpdated => 1226706547,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue