/usr/lib/x86_64-linux-gnu/perl5/5.22/Embperl/Form/Control/mult.pm is in libembperl-perl 2.5.0-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | ###################################################################################
#
# Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de
# Embperl - Copyright (c) 2008-2014 Gerald Richter
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
#
# THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# $Id$
#
###################################################################################
package Embperl::Form::Control::mult ;
use strict ;
use base 'Embperl::Form::Control::grid' ;
use vars qw{%fdat $epreq} ;
use Embperl::Inline ;
# ---------------------------------------------------------------------------
#
# new - create a new control
#
sub new
{
my ($class, $args) = @_ ;
my $self = Embperl::Form::ControlMultValue -> new($args) ;
bless $self, $class ;
$self -> init ;
return $self ;
}
# ---------------------------------------------------------------------------
#
# init - init the new control
#
sub init
{
my ($self) = @_ ;
my $form = $self -> form ;
$self -> {fields} ||= [$self -> {field}] ;
$self -> {class} ||= 'ef-control-mult' ;
my $options = $form -> {options} ;
$form -> new_controls ($self -> {fields}, $options, undef, undef, $options -> {masks}, $options -> {defaults}, 1) ;
return $self ;
}
# ------------------------------------------------------------------------------------------
#
# init_data - daten aufteilen
#
sub init_data
{
my ($self, $req) = @_ ;
my $fdat = $req -> {docdata} || \%fdat ;
my $name = $self->{name} ;
my @entries = ref $fdat->{$name} eq 'ARRAY'?@{$fdat->{$name}}:split("\t",$fdat->{$name});
my $field = $self -> {fields}[0] ;
my $i = 0 ;
foreach my $entry (@entries)
{
$fdat->{"__${name}__$i"} = $entry ;
if ($field -> can ('init_data'))
{
local $field->{name} = "__${name}__$i" ;
local $field -> {fullid} = "$self->{fullid}__$i" ;
$field -> init_data ($req, $self) ;
}
$i++ ;
}
$fdat->{"__${name}_max"} = $i?$i:1;
}
# ------------------------------------------------------------------------------------------
#
# prepare_fdat - daten zusammenfuehren
#
sub prepare_fdat
{
my ($self, $req) = @_ ;
my $fdat = $req -> {form} || \%fdat ;
my $name = $self->{name} ;
my $max = $fdat->{"__${name}_max"} || 1 ;
my $field = $self -> {fields}[0] ;
my @rows;
my $val ;
for (my $i = 0; $i < $max; $i++)
{
if ((ref ($field) =~ /::/) && $field -> can ('prepare_fdat'))
{
local $field->{name} = "__${name}__$i" ;
local $field -> {fullid} = "$self->{fullid}__$i" ;
$field -> prepare_fdat ($req) ;
}
$val = $fdat->{"__${name}__$i"} ;
push @rows, $val if ($val ne '') ;
}
$fdat->{$name} = \@rows if (@rows > 1 || defined ($rows[0]) || $fdat->{"__${name}_max"} > 0) ;
foreach my $key (keys %$fdat)
{
delete $fdat->{$key} if ($key =~ /^__\Q$name\E__/) ;
}
}
# ------------------------------------------------------------------------------------------
#
# get_display_text - returns the text that should be displayed
#
sub get_display_text
{
my ($self, $req, $value) = @_ ;
my $field = $self -> {fields}[0] ;
return if (!$field) ;
return $field -> get_display_text ($req, $value) ;
}
# ------------------------------------------------------------------------------------------
sub show
{
$_[0] -> {fullid} = $_[1] -> {uuid} . '_' . $_[0] -> {id} ;
Embperl::Form::Control::show (@_)
}
#sub show_control_readonly { my $self = shift ; $self -> show_control (@_) }
1 ;
__EMBPERL__
[# ---------------------------------------------------------------------------
#
# show - output the whole control including the label
#]
[$sub show ($self, $req)
$fdat{$self -> {name}} = $self -> {default} if ($fdat{$self -> {name}} eq '' && exists ($self -> {default})) ;
my $span = 0 ;
$]<table class="ef-element ef-element-width-[+ $self -> {width_percent} +] ef-element-[+ $self -> {type} +] [+ $self -> {state} +]"
[$ if (!$self -> is_readonly($req) ) $]_ef_attach="ef_mult"[$endif$] >
<tr>
[-
$span += $self -> show_label_cell ($req, $span);
$self -> show_control_cell ($req, $span) ;
-]
</tr>
</table>[$
endsub $]
[# ---------------------------------------------------------------------------
#
# show_control - output the control
#]
[$ sub show_control ($self, $req)
my $name = $self -> {name} ;
my $max = $fdat{"__${name}_max"} ||= 1 ;
my $span = ($self->{width_percent}) ;
my $nsprefix = $self -> form -> {jsnamespace} ;
my $jsname = $name ;
$jsname =~ s/[^a-zA-Z0-9]/_/g ;
$jsname .= 'Grid' ;
$]
[$ if ($max == 1 && $self -> is_readonly($req) ) $]
[-
my $field = $self -> {fields}[0] ;
local $field -> {name} = "__${name}__0" ;
$field -> show_control_readonly ($req) ;
-]
[$else$]
[-
$fdat{$name} = $self -> {default} if ($fdat{$name} eq '' && exists ($self -> {default})) ;
my $span = 0 ;
-]
<div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req) } +]>
<input type="hidden" class="ef-control-mult-max" name="__[+ $self -> {name} +]_max" >
<table class="ef-control-mult-table" >
[- $self -> show_grid_table ($req) ; -]
</table>
<table class="ef-control-mult-newrow" style="display: none">
[-
local $req -> {epf_no_script} = 1 ;
$self -> show_grid_table_row ($req, '%row%') ;
-]
</table>
</div>
[$endif$]
[$endsub$]
[# ---------------------------------------------------------------------------
#
# show_grid_table_row Erzeugt eine Grid-Tabelle-Zeile
#]
[$ sub show_grid_table_row ($self, $req, $i)
$field = $self -> {fields}[0] ;
$id = $self -> {fullid};
$name = $self -> {name} ;
my $jsname = $name ;
$jsname =~ s/[^a-zA-Z0-9]/_/g ;
$jsname .= 'Grid' ;
my $ro = $self -> is_readonly ($req) ;
$]
<tr class="cGridRow" id="[+ "${id}_mult-row-$i" +]">
<td class="[+ $self -> {class} +]Cell">
[-
local $field -> {name} = "__${name}__$i" ;
if ($ro)
{
$field -> show_control_readonly ($req)
}
else
{
$field -> show_control ($req)
}
-]
</td>
</tr>
[$ endsub $]
[$ sub show_label_icon ($self)
$name = $self -> {name} ;
my $jsname = $name ;
$jsname =~ s/[^a-zA-Z0-9]/_/g ;
$jsname .= 'Grid' ;
$]
[$if (! $self -> is_readonly ($req)) $]
<span class="ui-icon ui-icon-circle-plus ef-icon ef-control-mult-add" title="Zeile Hinzufügen"></span>
<span class="ui-icon ui-icon-circle-minus ef-icon ef-control-mult-del" title="Zeile Löschen"></span>
[$endif$]
[$endsub$]
[# ---------------------------------------------------------------------------
#
# show_grid_table Erzeugt eine Grid-Tabelle
#]
[$ sub show_grid_table ($self, $req)
my $name = $self->{name} ;
my $fields = $self -> {fields} ;
my $id = $self -> {fullid};
my $i = 0 ;
my $max = $fdat{"__${name}_max"} || 1 ;
$]
[* for ($i = 0; $i < $max ; $i++ ) { *]
[- $self -> show_grid_table_row ($req, $i) ; -]
[* } *]
[$endsub$]
__END__
=pod
=head1 NAME
Embperl::Form::Control::grid - A grid control inside an Embperl Form
=head1 SYNOPSIS
=head1 DESCRIPTION
Used to create a grid control inside an Embperl Form.
See Embperl::Form on how to specify parameters.
=head2 PARAMETER
=head3 type
Needs to be 'grid'
=head3 fields
Array ref with field definitions
=head3 header_bottom
If grid has more rows as given in this parameter,
a header line is also displayed at the bottom of the
grid. Default is 10. Set to -1 to always get a
header at the bottom.
=head2 Example
{
name => 'provider-path',
text => 'Suchpfad',
type => 'grid',
fields =>
[
{ name => 'active', text => 'Aktiv', type => 'checkbox', width => '30' },
{ name => 'path', text => 'Pfad' },
],
},
=head1 Author
G. Richter (richter at embperl dot org)
=head1 See Also
perl(1), Embperl, Embperl::Form
|