diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 1d381fa91..1934747d0 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -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. diff --git a/lib/WebGUI/Form/Interval.pm b/lib/WebGUI/Form/Interval.pm index b062b3709..eaa0ae7a6 100644 --- a/lib/WebGUI/Form/Interval.pm +++ b/lib/WebGUI/Form/Interval.pm @@ -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; } diff --git a/lib/WebGUI/Session/DateTime.pm b/lib/WebGUI/Session/DateTime.pm index 8912c4136..6fbb2f6f8 100644 --- a/lib/WebGUI/Session/DateTime.pm +++ b/lib/WebGUI/Session/DateTime.pm @@ -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); } diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index 9c6e7af2b..55426ec3a 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -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,