diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index 285cab129..97e207f65 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -58,7 +58,14 @@ property parser => ( fieldType => 'selectBox', lazy => 1, builder => '_default_parser', - lazy => 1, + options => sub { + my $self = shift; + my $session = $self->session; + tie my %parsers, 'Tie::IxHash'; + for my $class ( @{$session->config->get('templateParsers')} ) { + $parsers{$class} = $self->getParser($session, $class)->getName(); + } + }, ); sub _default_parser { my $self = shift; @@ -107,7 +114,25 @@ property storageIdExample => ( property attachmentsJson => ( fieldType => 'JsonTable', - label => [ "attachments display label", "Asset_Template" ], + label => [ "attachment display label", "Asset_Template" ], + fields => [ + { + type => "text", + name => "url", + label => [ 'attachment header url', 'Asset_Template' ], + size => '48', + }, + { + type => "select", + name => "type", + label => ['attachment header type','Asset_Template'], + options => [ + stylesheet => ['css label','Asset_Template'], + headScript => ['js head label','Asset_Template'], + bodyScript => ['js body label','Asset_Template'], + ], + }, + ], ); use WebGUI::International; @@ -417,47 +442,6 @@ override getEditForm => sub { templatePreview.js ); - if($session->config->get("templateParsers")){ - my @temparray = @{$session->config->get("templateParsers")}; - tie my %parsers, 'Tie::IxHash'; - while(my $a = shift @temparray){ - $parsers{$a} = $self->getParser($session, $a)->getName(); - } - my $value = [$self->parser]; - $value = \[$session->config->get("defaultTemplateParser")] if(!$self->parser); - $tabform->getTab("properties")->addField( "SelectBox", - name=>"parser", - options=>\%parsers, - value=>$value, - label=>$i18n->get('parser'), - hoverHelp=>$i18n->get('parser description'), - ); - } - - $tabform->getTab('properties')->addField( "jsonTable", - name => 'attachmentsJson', - value => $self->get('attachmentsJson'), - label => $i18n->get("attachment display label"), - fields => [ - { - type => "text", - name => "url", - label => $i18n->get('attachment header url'), - size => '48', - }, - { - type => "select", - name => "type", - label => $i18n->get('attachment header type'), - options => [ - stylesheet => $i18n->get('css label'), - headScript => $i18n->get('js head label'), - bodyScript => $i18n->get('js body label'), - ], - }, - ], - ); - $tabform->getTab('properties')->addField( image => name => 'storageIdExample', value => $self->storageIdExample, diff --git a/lib/WebGUI/Form/JsonTable.pm b/lib/WebGUI/Form/JsonTable.pm index 837dd9f63..7244806c4 100644 --- a/lib/WebGUI/Form/JsonTable.pm +++ b/lib/WebGUI/Form/JsonTable.pm @@ -163,7 +163,8 @@ sub toHtml { # Table headers $output .= ''; for my $field ( @{ $self->get('fields') } ) { - $output .= ''; + my $label = ref $field->{label} eq 'ARRAY' ? $i18n->get(@{$field->{label}}) : $field->{label}; + $output .= ''; } $output .= ''; # Extra column for buttons @@ -190,6 +191,10 @@ sub toHtml { for my $i ( 0 .. $opts-1 ) { my $optValue = $field->{options}[$i*2]; my $optLabel = $field->{options}[$i*2+1]; + # If the label is an arrayref, get the i18n value + if ( ref $optLabel eq 'ARRAY' ) { + $optLabel = $i18n->get(@{$optLabel}); + } $fieldHtml .= ''; } $fieldHtml .= '';
' . $field->{label} . '' . $label . '