1
# See bottom of file for license and copyright information
3
# Base class of all types. Types are involved *only* in the presentation
4
# of values in the configure interface. They do not play any part in
5
# loading, saving or checking configuration values.
7
package Foswiki::Configure::Type;
13
use vars qw( %knownTypes );
16
my ( $class, $id ) = @_;
18
return bless( { name => $id }, $class );
24
my $typer = $knownTypes{$id};
26
my $typeClass = 'Foswiki::Configure::Types::' . $id;
28
eval 'use ' . $typeClass . '; new ' . $typeClass . '("' . $id . '")';
30
# unknown type - give it default string behaviours
31
$typer = new Foswiki::Configure::Type($id) unless $typer;
32
$knownTypes{$id} = $typer;
37
# Generates a suitable HTML prompt for the type. Default behaviour
38
# is a string 55% of the width of the display area.
40
my ( $this, $id, $opts, $value ) = @_;
43
if ( $opts =~ /\b(\d+)\b/ ) {
46
# These numbers are somewhat arbitrary..
51
return CGI::textfield(
55
-class => 'foswikiInputField'
59
# Test to determine if two values of this type are equal.
61
my ( $this, $val, $def ) = @_;
63
if ( !defined $val ) {
64
return 0 if defined $def;
67
elsif ( !defined $def ) {
73
# Used to process input values from CGI. Values taken from the query
74
# are run through this method before being saved in the value store.
75
# It should *not* be used to do validation - use a Checker to do that, or
76
# JavaScript invoked from the prompt.
78
my ( $this, $val ) = @_;
85
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
87
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
88
# Foswiki Contributors are listed in the AUTHORS file in the root
89
# of this distribution. NOTE: Please extend that file, not this notice.
91
# Additional copyrights apply to some or all of the code in this
94
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
95
# TWiki Contributors are listed in the AUTHORS file in the root
96
# of this distribution. NOTE: Please extend that file, not this notice.
98
# This program is free software; you can redistribute it and/or
99
# modify it under the terms of the GNU General Public License
100
# as published by the Free Software Foundation; either version 2
101
# of the License, or (at your option) any later version. For
102
# more details read LICENSE in the root of this distribution.
104
# This program is distributed in the hope that it will be useful,
105
# but WITHOUT ANY WARRANTY; without even the implied warranty of
106
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
108
# As per the GPL, removal of this notice is prohibited.