Index: lib/TWiki.pm
===================================================================
RCS file: /e/www/CVS/twiki-cairo/lib/TWiki.pm,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -c -r1.2 -r1.2.4.1
*** lib/TWiki.pm 26 Dec 2004 12:38:28 -0000 1.2
--- lib/TWiki.pm 27 Dec 2004 16:54:58 -0000 1.2.4.1
***************
*** 3197,3203 ****
my( $theWeb, $theTopic, $text, $meta, $isTopRev ) = @_;
$text =~ s/%META{\s*"form"\s*}%/&TWiki::Render::renderFormData( $theWeb, $theTopic, $meta )/ge; #this renders META:FORM and META:FIELD
! $text =~ s/%META{\s*"formfield"\s*(.*?)}%/&TWiki::Render::renderFormField( $meta, $1 )/ge; #TODO: what does this do? (is this the old forms system, and so can be deleted)
$text =~ s/%META{\s*"attachments"\s*(.*)}%/&TWiki::Attach::renderMetaData( $theWeb,
$theTopic, $meta, $1, $isTopRev )/ge; #renders attachment tables
$text =~ s/%META{\s*"moved"\s*}%/&TWiki::Render::renderMoved( $theWeb, $theTopic, $meta )/ge; #render topic moved information
--- 3197,3203 ----
my( $theWeb, $theTopic, $text, $meta, $isTopRev ) = @_;
$text =~ s/%META{\s*"form"\s*}%/&TWiki::Render::renderFormData( $theWeb, $theTopic, $meta )/ge; #this renders META:FORM and META:FIELD
! $text =~ s/%META{\s*"formfield"\s*(.*)}%/&TWiki::Render::renderFormField( $meta, $1 )/ge;
$text =~ s/%META{\s*"attachments"\s*(.*)}%/&TWiki::Attach::renderMetaData( $theWeb,
$theTopic, $meta, $1, $isTopRev )/ge; #renders attachment tables
$text =~ s/%META{\s*"moved"\s*}%/&TWiki::Render::renderMoved( $theWeb, $theTopic, $meta )/ge; #render topic moved information
Index: lib/TWiki/Form.pm
===================================================================
RCS file: /e/www/CVS/twiki-cairo/lib/TWiki/Form.pm,v
retrieving revision 1.1
retrieving revision 1.1.4.6
diff -c -r1.1 -r1.1.4.6
*** lib/TWiki/Form.pm 7 Sep 2004 17:16:58 -0000 1.1
--- lib/TWiki/Form.pm 16 Feb 2005 17:27:07 -0000 1.1.4.6
***************
*** 33,39 ****
# Get definition from supplied topic text
# Returns array of arrays
# 1st - list fields
! # 2nd - name, title, type, size, vals, tooltip, setting
=pod
---++ sub getFormDefinition ( $text )
--- 33,40 ----
# Get definition from supplied topic text
# Returns array of arrays
# 1st - list fields
! # 2nd - name, title, type, size, vals, tooltip, attributes
! # Possible attributes are "S" (field used as setting), "M" (mandatory field)
=pod
---++ sub getFormDefinition ( $text )
***************
*** 61,67 ****
--- 62,76 ----
my( $title, $type, $size, $vals, $tooltip, $attributes ) = split( /\|/ );
$title =~ s/^\s*//go;
$title =~ s/\s*$//go;
+ my $referenced = "";
+ #PeterKlausner's [[CoreTeam][Approve by]] as field definition
+ if( $title =~ /\[\[(.+)\]\[(.+)\]\]/ ) { # use common defining
+ $referenced = _cleanField( $1 ); # topics with diff.
+ $title = $2; # field titles
+ }
my $name = _cleanField( $title );
+ $referenced = $name unless $referenced;
+
$type = lc $type;
$attributes =~ s/\s*//go;
$attributes = "" if( ! $attributes );
***************
*** 79,84 ****
--- 88,94 ----
}
}
$size = 1 if( ! $size );
+ $vals =~ s/%SEARCH{(.*?)}%/&TWiki::handleSearchWeb($1)/geo;
$vals =~ s/^\s*//go;
$vals =~ s/\s*$//go;
$vals =~ s/"//go; # " would break parsing off META variables
***************
*** 88,94 ****
$tooltip =~ s/^\s*//go;
$tooltip =~ s/\s*$//go;
# FIXME object if too short
! push @fields, [ $name, $title, $type, $size, $vals, $tooltip, $attributes ];
} else {
$inBlock = 0;
}
--- 98,104 ----
$tooltip =~ s/^\s*//go;
$tooltip =~ s/\s*$//go;
# FIXME object if too short
! push @fields, [ $name, $title, $type, $size, $vals, $tooltip, $attributes, $referenced ];
} else {
$inBlock = 0;
}
***************
*** 191,204 ****
# Get each field definition
foreach my $fieldDefP ( @fieldDefs ) {
my @fieldDef = @$fieldDefP;
! my( $name, $title, $type, $size, $posValuesS, $tooltip, $attributes ) = @fieldDef;
my @posValues = ();
if( $posValuesS ) {
! @posValues = split( /,\s*/, $posValuesS );
! }
!
! if( ( ! @posValues ) && &TWiki::Store::topicExists( $webName, $name ) ) {
! my( $meta, $text ) = &TWiki::Store::readTopic( $webName, $name );
@posValues = getPossibleFieldValues( $text );
if( ! $type ) {
$type = "select"; #FIXME keep?
--- 201,220 ----
# Get each field definition
foreach my $fieldDefP ( @fieldDefs ) {
my @fieldDef = @$fieldDefP;
! my( $name, $title, $type, $size, $posValuesS, $tooltip, $attributes, $referenced ) = @fieldDef;
my @posValues = ();
if( $posValuesS ) {
! if ((!($type eq "text")) && (!($type eq "textarea"))) {
! @posValues = split( /,\s*/, $posValuesS );
! } else {
! @posValues = ( $posValuesS );
! }
! }
!
! if( ( ! @posValues ) && &TWiki::Store::topicExists( $webName, $referenced ) ) {
! my( $meta, $text ) = &TWiki::Store::readTopic( $webName, $referenced );
! #SVEN - add processing of SEARCHES for Lists
! $text =~ s/%SEARCH{(.*?)}%/&TWiki::handleSearchWeb($1)/geo;
@posValues = getPossibleFieldValues( $text );
if( ! $type ) {
$type = "select"; #FIXME keep?
***************
*** 218,223 ****
--- 234,240 ----
---++ sub _link ( $web, $name, $tooltip, $heading, $align, $span, $extra )
+ # NOTE: Tooltip must not contain double quotes
Not yet documented.
=cut
***************
*** 249,255 ****
my $link = "$name";
! if( &TWiki::Store::topicExists( $web, $name ) ) {
( $web, $name ) = &TWiki::Store::normalizeWebTopicName( $web, $name );
if( ! $tooltip ) {
$tooltip = "Click to see details in separate window";
--- 266,273 ----
my $link = "$name";
! if( $span && &TWiki::Store::topicExists( $web, $name ) ) {
! # Note: do not link field headings, should space out $name
( $web, $name ) = &TWiki::Store::normalizeWebTopicName( $web, $name );
if( ! $tooltip ) {
$tooltip = "Click to see details in separate window";
***************
*** 296,301 ****
--- 314,321 ----
{
my( $web, $topic, $form, $meta, $query, $getValuesFromFormTopic, @fieldsInfo ) = @_;
+ my $mandatoryFieldsPresent = 0;
+
my $chooseForm = "";
if( TWiki::Prefs::getPreferencesValue( "WEBFORMS", "$web" ) ) {
$chooseForm = chooseFormButton( "Replace form..." );
***************
*** 316,321 ****
--- 336,342 ----
my $size = shift @fieldInfo;
my $tooltip = shift @fieldInfo;
my $attributes = shift @fieldInfo;
+ $mandatoryFieldsPresent = 1 if $attributes =~ /M/;
my %field = $meta->findOne( "FIELD", $fieldName );
my $value = $field{"value"};
***************
*** 323,334 ****
# Allow initialisation based on a preference
$value = &TWiki::Prefs::getPreferencesValue($fieldName);
}
! if( ($getValuesFromFormTopic ) ) {
! my $tmp = $fieldInfo[0] || "";
! $value = &TWiki::handleCommonTags( $tmp, $topic );
}
$value = "" unless defined $value; # allow "0" values
! my $extra = "";
$tooltip =~ s/&/&\;/g;
$tooltip =~ s/"/"\;/g;
--- 344,355 ----
# Allow initialisation based on a preference
$value = &TWiki::Prefs::getPreferencesValue($fieldName);
}
! if( ((! defined $value) && ($type !~ "^checkbox") && $getValuesFromFormTopic ) ) {
! my $tmp = $fieldInfo[0];
! $value = &TWiki::handleCommonTags( $tmp, $topic ) if (defined $tmp);
}
$value = "" unless defined $value; # allow "0" values
! my $extra = ($attributes =~ /M/) ? "*" : "";
$tooltip =~ s/&/&\;/g;
$tooltip =~ s/"/"\;/g;
***************
*** 386,392 ****
} elsif( $type =~ "^checkbox" ) {
if( $type eq "checkbox+buttons" ) {
my $boxes = $#fieldInfo + 1;
! $extra = "
\n \n" .
"\n";
}
--- 407,413 ----
} elsif( $type =~ "^checkbox" ) {
if( $type eq "checkbox+buttons" ) {
my $boxes = $#fieldInfo + 1;
! $extra .= "
\n \n" .
"\n";
}
***************
*** 444,449 ****
--- 465,471 ----
$text .= "