~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/Configure/Types/REGEX.pm

  • Committer: James Michael DuPont
  • Date: 2009-07-18 19:58:49 UTC
  • Revision ID: jamesmikedupont@gmail.com-20090718195849-vgbmaht2ys791uo2
added foswiki

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See bottom of file for license and copyright information
 
2
 
 
3
package Foswiki::Configure::Types::REGEX;
 
4
 
 
5
use strict;
 
6
 
 
7
use Foswiki::Configure::Types::STRING;
 
8
 
 
9
use base 'Foswiki::Configure::Types::STRING';
 
10
 
 
11
sub prompt {
 
12
    my ( $this, $id, $opts, $value ) = @_;
 
13
    $value = '' unless defined($value);
 
14
    $value = "$value";
 
15
    while ( $value =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
 
16
    $value =~
 
17
      s/([[\x01-\x09\x0b\x0c\x0e-\x1f"%&'*<=>@[_\|])/'&#'.ord($1).';'/ge;
 
18
    my $res =
 
19
        '<input name="' 
 
20
      . $id
 
21
      . '" type="text" size="55%" value="'
 
22
      . $value . '" />';
 
23
    return $res;
 
24
}
 
25
 
 
26
sub string2value {
 
27
    my ( $this, $value ) = @_;
 
28
    while ( $value =~ s/^\(\?-xism:(.*)\)$/$1/ ) { }
 
29
    return qr/$value/;
 
30
}
 
31
 
 
32
sub equals {
 
33
    my ( $this, $val, $def ) = @_;
 
34
    if ( !defined $val ) {
 
35
        return 0 if defined $def;
 
36
        return 1;
 
37
    }
 
38
    elsif ( !defined $def ) {
 
39
        return 0;
 
40
    }
 
41
    while ( $val =~ s/^\(\?-xism:(.*)\)$/$1/ ) {
 
42
    }
 
43
    while ( $def =~ s/^\(\?-xism:(.*)\)$/$1/ ) {
 
44
    }
 
45
    return $val eq $def;
 
46
}
 
47
 
 
48
1;
 
49
__DATA__
 
50
#
 
51
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
 
52
#
 
53
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
54
# Foswiki Contributors are listed in the AUTHORS file in the root
 
55
# of this distribution. NOTE: Please extend that file, not this notice.
 
56
#
 
57
# Additional copyrights apply to some or all of the code in this
 
58
# file as follows:
 
59
#
 
60
# Copyright (C) 2000-2006 TWiki Contributors. All Rights Reserved.
 
61
# TWiki Contributors are listed in the AUTHORS file in the root
 
62
# of this distribution. NOTE: Please extend that file, not this notice.
 
63
#
 
64
# This program is free software; you can redistribute it and/or
 
65
# modify it under the terms of the GNU General Public License
 
66
# as published by the Free Software Foundation; either version 2
 
67
# of the License, or (at your option) any later version. For
 
68
# more details read LICENSE in the root of this distribution.
 
69
#
 
70
# This program is distributed in the hope that it will be useful,
 
71
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
72
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
73
#
 
74
# As per the GPL, removal of this notice is prohibited.