Merge commit 'b8845e25fa' into WebGUI8. Up to 7.10.0

This commit is contained in:
Colin Kuskie 2010-09-22 07:58:06 -07:00
commit 0180b11064
45 changed files with 480 additions and 46 deletions

View file

@ -61,7 +61,6 @@ sub appendCommonVars {
eval { WebGUI::Shop::Vendor->newByUserId($session, $session->user->userId); };
$var->{ 'userIsVendor' } = ! Exception::Class->caught();
$session->log->warn($@);
}
#-------------------------------------------------------------------

View file

@ -1635,8 +1635,12 @@ sub www_edit {
});
$var{'userDefined'.$x.'.form.htmlarea'}
= WebGUI::Form::HTMLArea($session, {
name => "userDefined".$x,
value => $userDefinedValue,
name => "userDefined".$x,
value => $userDefinedValue,
richEditId => ($self->isa("WebGUI::Asset::Post::Thread")
? $self->getThread->getParent->get("richEditor")
: $self->getThread->getParent->get("replyRichEditor")
),
});
$var{'userDefined'.$x.'.form.float'}
= WebGUI::Form::Float($session, {

View file

@ -294,7 +294,7 @@ override getEditForm => sub {
$tabform->getTab('properties')->addField( "jsonTable",
name => 'attachmentsJson',
value => $self->get('attachmentsJson'),
label => $i18n->get("attachments display label"),
label => $i18n->get("attachment display label"),
fields => [
{
type => "text",

View file

@ -54,6 +54,7 @@ sub process {
my $self = shift;
my $template = shift;
my $vars = $self->addSessionVars(shift);
$self->downgrade($vars);
my $t;
eval {
$t = HTML::Template->new(

View file

@ -81,6 +81,7 @@ sub process {
my $class = shift;
my $template = shift;
my $vars = $class->addSessionVars(shift);
$class->downgrade($vars);
my $t;
eval {
$t = HTML::Template::Expr->new(scalarref=>\$template,

View file

@ -16,6 +16,7 @@ package WebGUI::Asset::Template::Parser;
use strict;
use WebGUI::International;
use Scalar::Util qw(blessed);
#-------------------------------------------------------------------
@ -63,6 +64,49 @@ sub addSessionVars {
#-------------------------------------------------------------------
=head2 downgrade ( vars )
Removes or converts things HTML::Template-like engines can't handle. Coderefs
are removed, blessed objects are removed, and hashes are recursively flattened
by appending keys separated by dots (e.g. { foo => { bar => 'baz' } } becomes
{ 'foo.bar' => 'baz' }. Also, array elements that aren't hashes are converted
to hashes via { value => $bareValue }.
=cut
sub downgrade {
my ($self, $vars) = @_;
for my $k (keys %$vars) {
my $v = $vars->{$k};
if (blessed($v) || ref $v eq 'CODE') {
delete $vars->{$k};
}
elsif (ref $v eq 'ARRAY') {
for my $i (0..$#$v) {
if (ref $v->[$i] eq 'HASH') {
$self->downgrade($v->[$i]);
}
else {
my %hash = ( value => $v->[$i] );
$self->downgrade(\%hash);
$v->[$i] = \%hash;
}
}
}
elsif (ref $v eq 'HASH') {
delete $vars->{$k};
my %flatter;
for my $subkey (keys %$v) {
$flatter{"$k.$subkey"} = $v->{$subkey};
}
$self->downgrade(\%flatter);
@{$vars}{keys %flatter} = values %flatter;
}
}
}
#-------------------------------------------------------------------
=head2 new ( session )
Constructor.

View file

@ -133,8 +133,8 @@ sub generateFeed {
my $cache = $session->cache;
my $sort = $self->sortItems;
my %opt = (use_ixhash => 1) if $sort eq 'feed';
my $feed = XML::FeedPP::Atom->new(%opt);
my @opt = (use_ixhash => 1) if $sort eq 'feed';
my $feed = XML::FeedPP::Atom->new(@opt);
# build one feed out of many
my $newlyCached = 0;
@ -163,7 +163,7 @@ sub generateFeed {
}, $self->cacheTimeout );
eval {
my $singleFeed = XML::FeedPP->new($value, utf8_flag => 1, -type => 'string', xml_deref => 1, %opt);
my $singleFeed = XML::FeedPP->new($value, utf8_flag => 1, -type => 'string', xml_deref => 1, @opt);
$feed->merge_channel($singleFeed);
$feed->merge_item($singleFeed);
};

View file

@ -86,7 +86,7 @@ sub www_viewActiveSessions {
and users.userId<>1 order by users.username,userSession.lastPageView desc");
my $pn = $p->getPageNumber;
foreach my $data (@{ $p->getPageData() }) {
$output = '<tr class="tableData"><td>'.$data->{username}.' ('.$data->{userId}.')</td>';
$output .= '<tr class="tableData"><td>'.$data->{username}.' ('.$data->{userId}.')</td>';
$output .= '<td>'.$data->{sessionId}.'</td>';
$output .= '<td>'.$session->datetime->epochToHuman($data->{expires}).'</td>';
$output .= '<td>'.$session->datetime->epochToHuman($data->{lastPageView}).'</td>';

View file

@ -404,7 +404,7 @@ sub missingFields {
$addressData = $address;
}
my @missingFields = ();
FIELD: foreach my $field (qw/label firstName lastName address1 city state code country phoneNumber/) {
FIELD: foreach my $field (qw/firstName lastName address1 city state code country phoneNumber/) {
push @missingFields, $field if $addressData->{$field} eq '';
}
return @missingFields;
@ -495,11 +495,10 @@ sub processAddressForm {
email => $form->get($prefix . "email", "email"),
organization => $form->get($prefix . "organization"),
);
#my $label = $field eq 'address1' ? 'address'
# : $field eq 'phoneNumber' ? 'phone number'
# : $field
# ;
##Label is optional in the form, but required for the UI and API.
##Use the first address line in its place if it's missing
$addressData{label} = $addressData{address1} if ! $addressData{label};
return %addressData;
}

View file

@ -425,7 +425,6 @@ sub getI18nError {
my $i18n = WebGUI::International->new($self->session, 'Shop');
return $error eq 'no billing address' ? $i18n->get('no billing address')
: $error eq 'no shipping address' ? $i18n->get('no shipping address')
: $error eq 'billing label' ? $i18n->get('billing label')
: $error eq 'billing firstName' ? $i18n->get('billing firstName')
: $error eq 'billing lastName' ? $i18n->get('billing lastName')
: $error eq 'billing address1' ? $i18n->get('billing address1')
@ -434,7 +433,6 @@ sub getI18nError {
: $error eq 'billing state' ? $i18n->get('billing state')
: $error eq 'billing country' ? $i18n->get('billing country')
: $error eq 'billing phoneNumber' ? $i18n->get('billing phoneNumber')
: $error eq 'shipping label' ? $i18n->get('shipping label')
: $error eq 'shipping firstName' ? $i18n->get('shipping firstName')
: $error eq 'shipping lastName' ? $i18n->get('shipping lastName')
: $error eq 'shipping address1' ? $i18n->get('shipping address1')

View file

@ -94,7 +94,7 @@ sub appendCartVariables {
$var ||= {};
my $cart = $self->getCart;
$var->{shippableItemsInCart} = $cart->requiresShipping;
$var->{subtotal} = $cart->calculateSubtotal;
$var->{subtotal} = $cart->formatCurrency($cart->calculateSubtotal);
$var->{shipping} = $cart->calculateShipping;
$var->{taxes} = $cart->calculateTaxes;
my $totalPrice = $var->{subtotal} + $var->{shipping} + $var->{taxes};