~kosova/+junk/tuxfamily-twiki

« back to all changes in this revision

Viewing changes to foswiki/lib/Foswiki/If/OP_dollar.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 copyright and license details
 
2
 
 
3
=begin TML
 
4
 
 
5
---+ package Foswiki::If::OP_dollar
 
6
 
 
7
=cut
 
8
 
 
9
package Foswiki::If::OP_dollar;
 
10
use base 'Foswiki::Query::UnaryOP';
 
11
 
 
12
use strict;
 
13
 
 
14
sub new {
 
15
    my $class = shift;
 
16
    return $class->SUPER::new(
 
17
        name => '$',
 
18
        prec => 600
 
19
    );
 
20
}
 
21
 
 
22
sub evaluate {
 
23
    my $this    = shift;
 
24
    my $node    = shift;
 
25
    my $a       = $node->{params}->[0];
 
26
    my %domain  = @_;
 
27
    my $session = $domain{tom}->session;
 
28
    throw Error::Simple(
 
29
        'No context in which to evaluate "' . $a->stringify() . '"' )
 
30
      unless $session;
 
31
    my $text = $a->_evaluate(@_) || '';
 
32
    if ( $text && defined( $session->{request}->param($text) ) ) {
 
33
        return $session->{request}->param($text);
 
34
    }
 
35
 
 
36
    $text = "%$text%";
 
37
    Foswiki::expandAllTags( $session, \$text, $session->{topicName},
 
38
        $session->{webName} );
 
39
 
 
40
    return $text || '';
 
41
}
 
42
 
 
43
1;
 
44
 
 
45
__DATA__
 
46
 
 
47
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
 
48
 
 
49
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
50
# Foswiki Contributors are listed in the AUTHORS file in the root
 
51
# of this distribution. NOTE: Please extend that file, not this notice.
 
52
#
 
53
# Additional copyrights apply to some or all of the code in this
 
54
# file as follows:
 
55
#
 
56
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
 
57
# TWiki Contributors are listed in the AUTHORS file in the root
 
58
# of this distribution. NOTE: Please extend that file, not this notice.
 
59
#
 
60
 
 
61
This program is free software; you can redistribute it and/or
 
62
modify it under the terms of the GNU General Public License
 
63
as published by the Free Software Foundation; either version 2
 
64
of the License, or (at your option) any later version. For
 
65
more details read LICENSE in the root of this distribution.
 
66
 
 
67
This program is distributed in the hope that it will be useful,
 
68
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
69
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
70
 
 
71
As per the GPL, removal of this notice is prohibited.
 
72
 
 
73
Author: Crawford Currie http://c-dot.co.uk
 
74
# See bottom of file for copyright and license details
 
75
 
 
76
=begin TML
 
77
 
 
78
---+ package Foswiki::If::OP_dollar
 
79
 
 
80
=cut
 
81
 
 
82
package Foswiki::If::OP_dollar;
 
83
use base 'Foswiki::Query::UnaryOP';
 
84
 
 
85
use strict;
 
86
 
 
87
sub new {
 
88
    my $class = shift;
 
89
    return $class->SUPER::new(
 
90
        name => '$',
 
91
        prec => 600);
 
92
}
 
93
 
 
94
sub evaluate {
 
95
    my $this = shift;
 
96
    my $node = shift;
 
97
    my $a = $node->{params}->[0];
 
98
    my %domain = @_;
 
99
    my $session = $domain{tom}->session;
 
100
    throw Error::Simple('No context in which to evaluate "'.
 
101
                          $a->stringify().'"') unless $session;
 
102
    my $text = $a->_evaluate(@_) || '';
 
103
    if( $text && defined( $session->{request}->param( $text ))) {
 
104
        return $session->{request}->param( $text );
 
105
    }
 
106
 
 
107
    $text = "%$text%";
 
108
    Foswiki::expandAllTags($session, \$text,
 
109
                         $session->{topicName},
 
110
                         $session->{webName});
 
111
 
 
112
    return $text || '';
 
113
}
 
114
 
 
115
1;
 
116
 
 
117
__DATA__
 
118
 
 
119
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
 
120
 
 
121
# Copyright (C) 2008 Foswiki Contributors. All Rights Reserved.
 
122
# Foswiki Contributors are listed in the AUTHORS file in the root
 
123
# of this distribution. NOTE: Please extend that file, not this notice.
 
124
#
 
125
# Additional copyrights apply to some or all of the code in this
 
126
# file as follows:
 
127
#
 
128
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
 
129
# TWiki Contributors are listed in the AUTHORS file in the root
 
130
# of this distribution. NOTE: Please extend that file, not this notice.
 
131
#
 
132
 
 
133
This program is free software; you can redistribute it and/or
 
134
modify it under the terms of the GNU General Public License
 
135
as published by the Free Software Foundation; either version 2
 
136
of the License, or (at your option) any later version. For
 
137
more details read LICENSE in the root of this distribution.
 
138
 
 
139
This program is distributed in the hope that it will be useful,
 
140
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
141
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
142
 
 
143
As per the GPL, removal of this notice is prohibited.
 
144
 
 
145
Author: Crawford Currie http://c-dot.co.uk
 
146
# See bottom of file for copyright and license details
 
147
 
 
148
=begin TML
 
149
 
 
150
---+ package Foswiki::If::OP_dollar
 
151
 
 
152
=cut
 
153
 
 
154
package Foswiki::If::OP_dollar;
 
155
use base 'Foswiki::Query::UnaryOP';
 
156
 
 
157
use strict;
 
158
 
 
159
sub new {
 
160
    my $class = shift;
 
161
    return $class->SUPER::new(
 
162
        name => '$',
 
163
        prec => 600);
 
164
}
 
165
 
 
166
sub evaluate {
 
167
    my $this = shift;
 
168
    my $node = shift;
 
169
    my $a = $node->{params}->[0];
 
170
    my %domain = @_;
 
171
    my $session = $domain{tom}->session;
 
172
    throw Error::Simple('No context in which to evaluate "'.
 
173
                          $a->stringify().'"') unless $session;
 
174
    my $text = $a->_evaluate(@_) || '';
 
175
    if( $text && defined( $session->{request}->param( $text ))) {
 
176
        return $session->{request}->param( $text );
 
177
    }
 
178
 
 
179
    $text = "%$text%";
 
180
    Foswiki::expandAllTags($session, \$text,
 
181
                         $session->{topicName},
 
182
                         $session->{webName});
 
183
 
 
184
    return $text || '';
 
185
}
 
186
 
 
187
1;
 
188
 
 
189
__DATA__
 
190
 
 
191
Module of Foswiki - The Free and Open Source Wiki, http://foswiki.org/, http://Foswiki.org/
 
192
 
 
193
# Copyright (C) 2008-2009 Foswiki Contributors. All Rights Reserved.
 
194
# Foswiki Contributors are listed in the AUTHORS file in the root
 
195
# of this distribution. NOTE: Please extend that file, not this notice.
 
196
#
 
197
# Additional copyrights apply to some or all of the code in this
 
198
# file as follows:
 
199
#
 
200
# Copyright (C) 2005-2007 TWiki Contributors. All Rights Reserved.
 
201
# TWiki Contributors are listed in the AUTHORS file in the root
 
202
# of this distribution. NOTE: Please extend that file, not this notice.
 
203
#
 
204
This program is free software; you can redistribute it and/or
 
205
modify it under the terms of the GNU General Public License
 
206
as published by the Free Software Foundation; either version 2
 
207
of the License, or (at your option) any later version. For
 
208
more details read LICENSE in the root of this distribution.
 
209
 
 
210
This program is distributed in the hope that it will be useful,
 
211
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
212
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
213
 
 
214
As per the GPL, removal of this notice is prohibited.
 
215
 
 
216
Author: Crawford Currie http://c-dot.co.uk