~ubuntu-branches/debian/sid/libembperl-perl/sid

« back to all changes in this revision

Viewing changes to Embperl/Form/Control/mult.pm

  • Committer: Bazaar Package Importer
  • Author(s): Gunnar Wolf, Jonathan Yu, Damyan Ivanov, Ryan Niebur, gregor herrmann, Gunnar Wolf
  • Date: 2009-10-15 11:43:24 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20091015114324-2rnqzsj9jmpwd9nt
Tags: 2.3.0-1
[ Jonathan Yu ]
* New upstream release
  + SSI syntax now behaves more like mod_include
  + Improved XHTML/XML support
  + Fix to correctly retrieve Cookie header under apache2
  + Fix segfault when a value of an input attribute is removed
* Bringing this package under the pkg-perl group (Closes: #543609)
* Updated d/watch with CPAN search site
* Standards-Version 3.8.3
  + Remove version dependency on perl
  + Add Vcs-* and Homepage fields
* Drop version dependency on:
  + apache2-prefork-dev (>= 2.2.3-3.3) [oldstable 2.2.3-4]
  + apache2-mpm-prefork (>= 2.2.3-3.3) [oldstable  2.2.3-4]
  + libapache2-mod-perl2 (>= 2.0.2-2.3) [oldstable 2.0.2-2.4]
* Remove libcgi-pm-perl | perl-modules (>= 5.8.0) | libcgi-perl,
  which is always satisfied by perl
* Add extensive patches to fix POD errors and add whatis entries
* Add a patch to remove some Unicode data from POD; it was causing
  an obscure error with `AE' (thanks Ryan52!)

[ Damyan Ivanov ]
* debian/rules: fix target dependencies

[ Ryan Niebur ]
* Update jawnsy's email address
* Update ryan52's email address

[ gregor herrmann ]
* Split out all changes to upstream code into proper patches managed by
  quilt.
* Add patch cgi_pm.patch by Niko Tyni to avoid FTBFS if a newer CGI.pm is
  present at test time (closes: #521971).
* Update debian/copyright.
* debian/rules:
  - clean up a bit
  - call make with "-j1", the upstream build system is not parallel-build safe
  - add support for DEB_BUILD_OPTIONS nocheck
* Change Section to "perl".
* Remove dbinitembperlapache (created by test suite).

[ Gunnar Wolf ]
* Updated README.Debian to reflect the current reality re: thread
  safety, dropping mentions of obsolete mod_perl v1 and mentioning the
  deprecation of embperl itself
* Reload Apache if a2enmod/a2dismod was called in postinst/prerm
* Added Suggests: apache2-mpm-prefork, as it is the closer we can get to
  get the non-threaded versions of Apache2 by default besides
  documenting, which is already done in README.Debian. (Closes: #412521)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
###################################################################################
 
3
#
 
4
#   Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh   www.ecos.de
 
5
#
 
6
#   You may distribute under the terms of either the GNU General Public
 
7
#   License or the Artistic License, as specified in the Perl README file.
 
8
#
 
9
#   THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
 
10
#   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 
11
#   WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
12
#
 
13
#   $Id$
 
14
#
 
15
###################################################################################
 
16
 
 
17
package Embperl::Form::Control::mult ;
 
18
 
 
19
use strict ;
 
20
use base 'Embperl::Form::Control::grid' ;
 
21
 
 
22
use vars qw{%fdat $epreq} ;
 
23
 
 
24
use Embperl::Inline ;
 
25
 
 
26
# ---------------------------------------------------------------------------
 
27
#
 
28
#   new - create a new control
 
29
#
 
30
 
 
31
 
 
32
sub new
 
33
 
 
34
    {
 
35
    my ($class, $args) = @_ ;
 
36
 
 
37
    my $self = Embperl::Form::ControlMultValue -> new($args) ;
 
38
    bless $self, $class ;
 
39
    
 
40
    $self -> init ;
 
41
    
 
42
    return $self ;
 
43
    }
 
44
 
 
45
# ---------------------------------------------------------------------------
 
46
#
 
47
#   init - init the new control
 
48
#
 
49
 
 
50
sub init
 
51
 
 
52
    {
 
53
    my ($self) = @_ ;
 
54
    
 
55
    my $form = $self -> form ;
 
56
    $self -> {fields} ||= [$self -> {field}] ;
 
57
    $self -> {class}  ||= 'cMult' ;
 
58
    $form -> new_controls ($self -> {fields}, $form -> {options}) ;
 
59
 
 
60
    return $self ;
 
61
    }
 
62
 
 
63
# ------------------------------------------------------------------------------------------
 
64
#
 
65
#   init_data - daten aufteilen
 
66
#
 
67
 
 
68
sub init_data
 
69
    {
 
70
    my ($self, $req) = @_ ;
 
71
    
 
72
    my $ldap    = $req->{ldap};
 
73
    my $name    = $self->{name} ;
 
74
    my @entries = split("\t",$fdat{$name});
 
75
use Data::Dumper ;
 
76
print STDERR 'init_data', Dumper (\%fdat, $name, \@entries) ;
 
77
 
 
78
    my $i = 0 ;
 
79
    foreach my $entry (@entries)
 
80
        {
 
81
            $fdat{"$name--$i"} = $entry ;
 
82
warn "init_data mult     field=$name--$i fd=" . $fdat{"$name--$i"} ;
 
83
            
 
84
        $i++ ;
 
85
        }
 
86
    $fdat{"$name-max"} = $i?$i:1;
 
87
    }
 
88
 
 
89
# ------------------------------------------------------------------------------------------
 
90
#
 
91
#   prepare_fdat - daten zusammenfuehren
 
92
#
 
93
 
 
94
sub prepare_fdat
 
95
    {
 
96
    my ($self, $req) = @_ ;
 
97
    my $ldap    = $req->{ldap};
 
98
    my $name    = $self->{name} ;
 
99
    my $max     = $fdat{"$name-max"} || 1 ;
 
100
warn "prepare_dat mult     name =$name, max=$max" ;
 
101
use Data::Dumper ;
 
102
print STDERR Dumper (\%fdat) ;
 
103
 
 
104
    my @rows;
 
105
    my $val ;
 
106
    for (my $i = 0; $i < $max; $i++)
 
107
        {
 
108
warn "prepare_dat mult     field=$name--$i fd=" . $fdat{"$name--$i"} ;
 
109
        $val = $fdat{"$name--$i"} ;
 
110
        push @rows, $val if ($val ne '') ;
 
111
        }
 
112
    $fdat{$name} = \@rows ;    
 
113
print STDERR Dumper (\%fdat, \@rows) ;
 
114
    }
 
115
 
 
116
sub show { Embperl::Form::Control::show (@_) } 
 
117
 
 
118
1 ;
 
119
 
 
120
__EMBPERL__
 
121
 
 
122
 
 
123
[# ---------------------------------------------------------------------------
 
124
#
 
125
#   show_control - output the control
 
126
#]
 
127
 
 
128
[$ sub show_control ($self, $req)
 
129
 
 
130
    my $name     = $self -> {name} ;
 
131
    my $span = ($self->{width_percent})  ;
 
132
    my $nsprefix = $self -> form -> {jsnamespace} ;
 
133
    my $jsname = $name ;
 
134
    $jsname =~ s/[^a-zA-Z0-9]/_/g ;
 
135
    $jsname .= 'Grid' ;
 
136
    my $max    = $fdat{"$name-max"} ;
 
137
$]
 
138
  [-
 
139
    $fdat{$name} = $self -> {default} if ($fdat{$name} eq '' && exists ($self -> {default})) ;
 
140
    my $span = 0 ;
 
141
  -]
 
142
  <input type="hidden" name="[+ $self -> {name} +]-max" id="[+ $self -> {id} +]-max">
 
143
  <table class="[+ $self -> {class} +]Table cBase" id="[+ $self -> {id} +]">
 
144
    [- $self -> show_grid_table ($req) ; -]
 
145
  </table>
 
146
  <table id="[+ $self -> {id} +]-newrow" style="display: none">
 
147
    [-
 
148
    local $req -> {epf_no_script} = 1 ;
 
149
    $self -> show_grid_table_row ($req, '%row%') ;
 
150
    -]
 
151
  </table>
 
152
  <script>
 
153
      [+ $jsname +] = new [+ $nsprefix +]Grid (document.getElementById('[+ $self -> {id} +]'),
 
154
                                               document.getElementById('[+ $self -> {id} +]-newrow'),
 
155
                                               document.getElementById('[+ $self -> {id} +]-max')) ;
 
156
  </script>
 
157
[$endsub$]
 
158
  
 
159
 
 
160
 
 
161
[# ---------------------------------------------------------------------------
 
162
#
 
163
#    show_grid_table_row     Erzeugt eine Grid-Tabelle-Zeile
 
164
#]
 
165
 
 
166
[$ sub show_grid_table_row ($self, $req, $i) 
 
167
 
 
168
    $field = $self -> {fields}[0] ;
 
169
    $id     = $self -> {id};
 
170
    $name   = $self -> {name} ;
 
171
    my $jsname = $name ;
 
172
    $jsname =~ s/[^a-zA-Z0-9]/_/g ;
 
173
    $jsname .= 'Grid' ;
 
174
    $]
 
175
 
 
176
    <tr class="cGridRow" id="[+ "$id-row-$i" +]">
 
177
 
 
178
            <td class="[+ $self -> {class} +]Cell">
 
179
              [-
 
180
                local $field -> {name} = "$name--$i" ;
 
181
                $field -> show_control ($req)
 
182
                -]
 
183
            </td>
 
184
    </tr>             
 
185
[$ endsub $]
 
186
 
 
187
 
 
188
[$ sub show_label_icon ($self)
 
189
    $name   = $self -> {name} ;
 
190
    my $jsname = $name ;
 
191
    $jsname =~ s/[^a-zA-Z0-9]/_/g ;
 
192
    $jsname .= 'Grid' ;
 
193
 
 
194
 
 
195
 $]
 
196
              <img src="/images/button_plus.gif" id="cmdAdd" name="-add" title="Zeile Hinzuf&uuml;gen" onclick="[+ $jsname +].addRow()">
 
197
              <img src="/images/button_kreuz.gif"  id="cmdDelete"  name="-delete" title="Zeile L&ouml;schen" onclick="[+ $jsname +].delRow()">
 
198
[$endsub$]
 
199
             
 
200
[# ---------------------------------------------------------------------------
 
201
#
 
202
#    show_grid_table     Erzeugt eine Grid-Tabelle
 
203
#]
 
204
 
 
205
[$ sub show_grid_table ($self, $req) 
 
206
    my $name    = $self->{name} ;
 
207
    my $fields = $self -> {fields} ;
 
208
    my $id     = $self -> {id};
 
209
    my $i      = 0 ;
 
210
    my $max    = $fdat{"$name-max"} || 1 ;
 
211
    $]
 
212
 
 
213
    [* for ($i = 0; $i < $max ; $i++ ) { *]
 
214
        [- $self -> show_grid_table_row ($req, $i) ; -]
 
215
    [* } *]
 
216
    
 
217
[$endsub$]
 
218
 
 
219
 
 
220
 
 
221
__END__
 
222
 
 
223
=pod
 
224
 
 
225
=head1 NAME
 
226
 
 
227
Embperl::Form::Control::grid - A grid control inside an Embperl Form
 
228
 
 
229
 
 
230
=head1 SYNOPSIS
 
231
 
 
232
 
 
233
=head1 DESCRIPTION
 
234
 
 
235
Used to create a grid control inside an Embperl Form.
 
236
See Embperl::Form on how to specify parameters.
 
237
 
 
238
=head2 PARAMETER
 
239
 
 
240
=head3 type
 
241
 
 
242
Needs to be 'grid'
 
243
 
 
244
=head3 fields
 
245
 
 
246
Array ref with field definitions
 
247
 
 
248
=head3 header_bottom
 
249
 
 
250
If grid has more rows as given in this parameter,
 
251
a header line is also displayed at the bottom of the
 
252
grid. Default is 10. Set to -1 to always get a
 
253
header at the bottom.
 
254
 
 
255
=head2 Example
 
256
 
 
257
     {
 
258
     name => 'provider-path',
 
259
     text => 'Suchpfad',
 
260
     type => 'grid', 
 
261
     fields =>
 
262
        [
 
263
        { name => 'active', text => 'Aktiv', type => 'checkbox', width => '30' },
 
264
        { name => 'path',   text => 'Pfad' },
 
265
        ],
 
266
    },
 
267
 
 
268
=head1 Author
 
269
 
 
270
G. Richter (richter@dev.ecos.de)
 
271
 
 
272
=head1 See Also
 
273
 
 
274
perl(1), Embperl, Embperl::Form
 
275
 
 
276