1
# See bottom of file for license and copyright details
5
---++ package Foswiki::Form::ListFieldDefinition
6
Form field definitions that accept lists of values in the field definition.
7
This is different to being multi-valued, which means the field type
8
can *store* multiple values.
12
package Foswiki::Form::ListFieldDefinition;
13
use base 'Foswiki::Form::FieldDefinition';
20
---++ ObjectMethod finish()
21
Break circular references.
25
# Note to developers; please undef *all* fields in the object explicitly,
26
# whether they are references or not. That way this method is "golden
27
# documentation" of the live fields in the object.
30
$this->SUPER::finish();
31
undef $this->{_options};
34
# PROTECTED - parse the {value} and extract a list of options.
35
# Done lazily to avoid repeated topic reads.
38
# $web and $topic are where the form definition lives
41
return $this->{_options} if $this->{_options};
45
@vals = split( /,/, $this->{value} );
46
if ( !scalar(@vals) ) {
47
my $topic = $this->{definingTopic} || $this->{name};
48
my $session = $this->{session};
49
my ( $fieldWeb, $fieldTopic ) =
50
$session->normalizeWebTopicName( $this->{web}, $topic );
51
my $store = $session->{store};
52
if ( $store->topicExists( $fieldWeb, $fieldTopic ) ) {
54
$store->readTopic( $session->{user}, $fieldWeb, $fieldTopic,
57
# Process SEARCHES for Lists
60
->handleCommonTags( $text, $this->{web}, $topic, $meta );
62
# SMELL: yet another table parser
64
foreach ( split( /\r?\n/, $text ) ) {
65
if (/^\s*\|\s*\*Name\*\s*\|/) {
68
elsif (/^\s*\|\s*([^|]*?)\s*\|/) {
69
push( @vals, TAINT($1) ) if ($inBlock);
77
@vals = map { $_ =~ s/^\s*(.*)\s*$/$1/; $_; } @vals;
79
$this->{_options} = \@vals;
81
return $this->{_options};
87
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
89
# Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved.
90
# Foswiki Contributors are listed in the AUTHORS file in the root
91
# of this distribution. NOTE: Please extend that file, not this notice.
93
# Additional copyrights apply to some or all of the code in this
96
# Copyright (C) 2001-2007 TWiki Contributors. All Rights Reserved.
97
# TWiki Contributors are listed in the AUTHORS file in the root
98
# of this distribution. NOTE: Please extend that file, not this notice.
100
This program is free software; you can redistribute it and/or
101
modify it under the terms of the GNU General Public License
102
as published by the Free Software Foundation; either version 2
103
of the License, or (at your option) any later version. For
104
more details read LICENSE in the root of this distribution.
106
This program is distributed in the hope that it will be useful,
107
but WITHOUT ANY WARRANTY; without even the implied warranty of
108
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
110
As per the GPL, removal of this notice is prohibited.