1
# See bottom of file for license and copyright information
3
package Foswiki::Configure::UIs::Value;
6
use base 'Foswiki::Configure::UI';
8
# Generates the appropriate HTML for getting a value to configure the
9
# entry. The actual input field is decided by the type.
11
my ( $this, $value, $valuer, $expert ) = @_;
13
my $type = $value->getType();
14
return '' if $value->{hidden};
17
my $isExpert = 0; # true if this is an EXPERT setting
18
if ( $value->isExpertsOnly() ) {
20
$info = CGI::h6('EXPERT') . $info;
22
$info .= $value->{desc};
23
my $keys = $value->getKeys();
25
my $checker = Foswiki::Configure::UI::loadChecker( $keys, $value );
29
my $check = $checker->check($value);
36
if ( $check && $check eq 'NOT USED IN THIS CONFIGURATION' ) {
41
# Hide rows if this is an EXPERT setting in non-experts mode, or
42
# this is a hidden or unused value
45
|| !$isBroken && ( $isExpert && !$expert || $value->{hidden} ) )
47
$hiddenClass = 'foswikiHidden';
50
# Generate the documentation row
51
my $hiddenTypeOf = $this->hidden( 'TYPEOF:' . $keys, $value->{typename} );
52
my $row1 = $hiddenTypeOf . $info;
54
# Generate col1 of the prompter row
56
$row2col1 = CGI::span( { class => 'mandatory' }, $row2col1 )
57
if $value->{mandatory};
58
if ( $value->needsSaving($valuer) ) {
59
my $defaultValue = $valuer->defaultValue($value) || '';
61
# special case are Perl data structures
62
# in order to edit this in the browser, it must get translated to a string
63
if ( $value->{typename} eq 'PERL' || $value->{typename} eq 'HASH' ) {
65
$Data::Dumper::Terse = 1;
66
$defaultValue = Dumper($defaultValue);
68
# create stubs for special characters, put them back with javascript
69
$defaultValue =~ s/'/#26;/go;
70
$defaultValue =~ s/"/#22;/go;
71
$defaultValue =~ s/\n/#13;/go;
74
$row2col1 .= CGI::span(
76
title => $defaultValue,
77
class => $value->{typename} . ' delta foswikiAlert'
82
# prepare javascript call
83
( my $safeKeys = $keys ) =~ s/'/#26;/go;
85
'this', "\'$value->{typename}\'",
86
"\'$safeKeys\'", "\'$defaultValue\'"
88
my $onClickParamsString = join( ", ", @onClickParams );
90
# first link CSS class name must be type
91
# a bit of a hack but we need to pass the type of the field the link
97
title => $defaultValue,
98
class => $value->{typename} . ' defaultValueLink foswikiSmall',
100
onclick => 'resetToDefaultValue('
101
. $onClickParamsString
102
. '); return false;',
108
# Generate col2 of the prompter row
110
if ( !$isUnused && ( $isBroken || !$isExpert || $expert ) ) {
112
# Generate a prompter for the value.
113
my $class = $value->{typename};
114
$class .= ' mandatory' if ( $value->{mandatory} );
115
$row2col2 = CGI::span(
118
$keys, $value->{opts}, $valuer->currentValue($value)
124
# Non-expert - just pass the value through a hidden
125
$row2col2 = CGI::hidden( $keys, $valuer->currentValue($value) );
129
{ class => $hiddenClass },
130
CGI::td( { class => 'firstCol' }, $row2col1 ) . "\n"
131
. CGI::td( { class => 'secondCol' }, $row2col2 )
134
. CGI::Tr( { class => $hiddenClass },
135
CGI::td( { colspan => "2", class => 'docdata info' }, $row1 ) )
147
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
149
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
150
# Foswiki Contributors are listed in the AUTHORS file in the root
151
# of this distribution. NOTE: Please extend that file, not this notice.
153
# Additional copyrights apply to some or all of the code in this
156
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
157
# TWiki Contributors are listed in the AUTHORS file in the root
158
# of this distribution. NOTE: Please extend that file, not this notice.
160
# This program is free software; you can redistribute it and/or
161
# modify it under the terms of the GNU General Public License
162
# as published by the Free Software Foundation; either version 2
163
# of the License, or (at your option) any later version. For
164
# more details read LICENSE in the root of this distribution.
166
# This program is distributed in the hope that it will be useful,
167
# but WITHOUT ANY WARRANTY; without even the implied warranty of
168
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
170
# As per the GPL, removal of this notice is prohibited.
172
# UI generating package for simple values