diff --git a/.gitignore b/.gitignore index 79cd3aa..77de36f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ *.gz *.swp -FlexFormPlugin.md5 -FlexFormPlugin.sha1 -FlexFormPlugin.tgz -FlexFormPlugin.txt -FlexFormPlugin.zip -FlexFormPlugin_installer -FlexFormPlugin_installer.pl +/FlexFormPlugin.md5 +/FlexFormPlugin.sha1 +/FlexFormPlugin.tgz +/FlexFormPlugin.txt +/FlexFormPlugin.zip +/FlexFormPlugin_installer +/FlexFormPlugin_installer.pl diff --git a/data/System/FlexFormPlugin.txt b/data/System/FlexFormPlugin.txt index fa20682..ee3563f 100644 --- a/data/System/FlexFormPlugin.txt +++ b/data/System/FlexFormPlugin.txt @@ -20,7 +20,7 @@ be avoided by using a %RENDERFOREDIT macro that loops over all formfields i to render the input form in a more dynamic way while still customizing the overall output. In addition, !FlexFormPlugin facilitates the extraction of field default values (such as valid schema options) from -!DataForm. See http://foswiki.org/Development/MacroForRetrievingFieldDefaultValues for background. +!DataForm. See https://foswiki.org/Development/MacroForRetrievingFieldDefaultValues for background. While %RENDERFOREDIT% and %%RENDERFORDISPLAY render forms for the net data using a !DataForm the %RENDERFORMDEF= macro renders information about the !DataForm definition itself identpendent of @@ -180,6 +180,7 @@ Note that the actual results may vary depending on the formfield type of the !Da %$DEPENDENCIES% ---++ Change History +| 02 Sep 2016: | improved support to translate formfields using Foswiki:Extensions.MultiLingualPlugin | | 08 Mar 2016: | clean up formfield title before trying to translate it; \ added =hideempty= for RENDERFOREDIT | | 17 Jul 2015: | fixed use of =param()= in list context | diff --git a/lib/Foswiki/Plugins/FlexFormPlugin.pm b/lib/Foswiki/Plugins/FlexFormPlugin.pm index 00b6bbf..64ab2f9 100644 --- a/lib/Foswiki/Plugins/FlexFormPlugin.pm +++ b/lib/Foswiki/Plugins/FlexFormPlugin.pm @@ -18,8 +18,8 @@ package Foswiki::Plugins::FlexFormPlugin; use strict; use warnings; -our $VERSION = '5.20'; -our $RELEASE = '08 Mar 2016'; +our $VERSION = '5.21'; +our $RELEASE = '02 Sep 2016'; our $SHORTDESCRIPTION = 'Flexible way to render DataForms'; our $NO_PREFS_IN_TOPIC = 1; our $renderForEditInstance; diff --git a/lib/Foswiki/Plugins/FlexFormPlugin/Base.pm b/lib/Foswiki/Plugins/FlexFormPlugin/Base.pm index 5c601b2..5aa2bfc 100644 --- a/lib/Foswiki/Plugins/FlexFormPlugin/Base.pm +++ b/lib/Foswiki/Plugins/FlexFormPlugin/Base.pm @@ -69,17 +69,8 @@ sub translate { return "" unless defined $text && $text ne ""; return $text unless Foswiki::Func::getContext()->{MultiLingualPluginEnabled}; - - unless ($this->{translator}) { - require Foswiki::Plugins::MultiLingualPlugin; - $this->{translator} = Foswiki::Plugins::MultiLingualPlugin::getCore(); - } - - my $params = { - _DEFAULT => $text, - }; - - return $this->{translator}->TRANSLATE($this->{session}, $params, $topic, $web); + require Foswiki::Plugins::MultiLingualPlugin; + return Foswiki::Plugins::MultiLingualPlugin::translate($text, $web, $topic); } sub translateField { diff --git a/lib/Foswiki/Plugins/FlexFormPlugin/DEPENDENCIES b/lib/Foswiki/Plugins/FlexFormPlugin/DEPENDENCIES index e69de29..1321b0b 100644 --- a/lib/Foswiki/Plugins/FlexFormPlugin/DEPENDENCIES +++ b/lib/Foswiki/Plugins/FlexFormPlugin/DEPENDENCIES @@ -0,0 +1 @@ +Foswiki::Plugins::MultiLingualPlugin,>=3.00,perl,Optional diff --git a/lib/Foswiki/Plugins/FlexFormPlugin/RenderForDisplay.pm b/lib/Foswiki/Plugins/FlexFormPlugin/RenderForDisplay.pm index 9f0d812..a0b86ec 100644 --- a/lib/Foswiki/Plugins/FlexFormPlugin/RenderForDisplay.pm +++ b/lib/Foswiki/Plugins/FlexFormPlugin/RenderForDisplay.pm @@ -226,7 +226,7 @@ sub handle { $field = $fieldClone; } - $fieldValue = $fieldDefault unless defined $fieldValue; + $fieldValue = $fieldDefault unless defined $fieldValue && $fieldValue ne ''; next if $theHideEmpty && (!defined($fieldValue) || $fieldValue eq ''); next if $theInclude && $fieldName !~ /$theInclude/; diff --git a/lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm b/lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm index e961357..110bac4 100644 --- a/lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm +++ b/lib/Foswiki/Plugins/FlexFormPlugin/RenderForEdit.pm @@ -245,7 +245,7 @@ sub handle { $fieldValue = $metaField->{value} if $metaField; } - $fieldValue = $fieldDefault unless defined $fieldValue; + $fieldValue = $fieldDefault unless defined $fieldValue && $fieldValue ne ''; next if $theInclude && $fieldName !~ /$theInclude/; next if $theExclude && $fieldName =~ /$theExclude/; diff --git a/lib/Foswiki/Plugins/FlexFormPlugin/build.pl b/lib/Foswiki/Plugins/FlexFormPlugin/build.pl index 24eb7dd..cf7e0ae 100755 --- a/lib/Foswiki/Plugins/FlexFormPlugin/build.pl +++ b/lib/Foswiki/Plugins/FlexFormPlugin/build.pl @@ -1,24 +1,10 @@ -#!/usr/bin/perl -w +#!/usr/bin/env perl BEGIN { unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} ); } use Foswiki::Contrib::Build; # Create the build object $build = new Foswiki::Contrib::Build('FlexFormPlugin'); -# (Optional) Set the details of the repository for uploads. -# This can be any web on any accessible Foswiki installation. -# These defaults will be used when expanding tokens in .txt -# files, but be warned, they can be overridden at upload time! - -# name of web to upload to -$build->{UPLOADTARGETWEB} = 'Extensions'; -# Full URL of pub directory -$build->{UPLOADTARGETPUB} = 'http://foswiki.org/pub'; -# Full URL of bin directory -$build->{UPLOADTARGETSCRIPT} = 'http://foswiki.org/bin'; -# Script extension -$build->{UPLOADTARGETSUFFIX} = ''; - # Build the target on the command line, or the default target $build->build($build->{target});