This file is indexed.

/usr/lib/x86_64-linux-gnu/perl5/5.22/Embperl/Form/ControlMultValue.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
###################################################################################
#
#   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::ControlMultValue ;

use strict ;
use vars qw{%fdat} ;

use base 'Embperl::Form::Control' ;

use Embperl::Inline ;

# ---------------------------------------------------------------------------
#
#   init - Init the new control
#


sub init

    {
    my ($self) = @_ ;

    if ($self -> {datasrc})
        {
        my $name = $self -> {datasrc} ;
        $name =~ s/[#\/].+$// ;
        my $form = $self -> form ;
        my $packages = $form -> get_datasrc_packages ;
        $self -> {datasrcobj} = $form -> new_object ($packages, $name, $self, { datarsc => $self -> {datasrc}}) ;
        }

    $self -> SUPER::init ;

    return $self ;
    }

# ---------------------------------------------------------------------------
#
#   constrain_attrs - returns attrs that might change the form layout
#                     if there value changes
#

sub constrain_attrs

    {
    my ($self, $req) = @_ ;

    return if (!$self -> {datasrcobj}) ;
        
    return $self -> {datasrcobj} -> constrain_attrs ($req) ;
    }

# ---------------------------------------------------------------------------
#
#   get_all_values - returns all values and options, including addtop and addbottom
#

sub get_all_values

    {
    my ($self, $req) = @_ ;

    my $key = "all_values:$self" ;
    my $v ;
    return @$v if ($v = $req -> {$key}) ;

    my $addtop = $self -> {addtop} ;
    my $addbottom = $self -> {addbottom} ;

    my $values ;
    my $options ;
    my $nocache = 0 ;
    
    if ($self -> {datasrcobj})
        {
        my $key = "all_values_datasrc:$self->{datasrcobj}" ;
        if (my $v = $req -> {$key})
            {
            ($values, $options) = @$v ;
            }
        else
            {
            ($values, $options) = $self -> {datasrcobj} -> get_values ($req, $self)  ;
            $options ||= $values ;
            $nocache = $self -> {datasrcobj} -> values_no_cache ;
            $req -> {$key} = [$values, $options] if (!$nocache) ;
            }
        }
    else
        {
        $values  = $self -> {values} ;    
        $options = $self -> {options} || $values ;
        $options = $self -> form -> convert_options ($self, $self -> {values}, $options, $req)
            if (!$self -> {showoptions}) ;
        }
 
    if (!$addtop && !$addbottom)
        {
        $req -> {$key} = [$values, $options] ;
        return ($values, $options) 
        }
    my @values ;
    my @options ;    
    if ($addtop)
        {
        push @values,  map { ref $_?$_ -> [0]:$_ } @$addtop ;
        push @options, map { ref $_?$_ -> [1]:$_ } @$addtop ;
        }
        
    if ($values)
        {
        if ($addtop && $values -> [0] eq '' && $options -> [0] eq '---')
            {
            push @values, @{$values}[1..$#$values] ;
            push @options, @{$options}[1..$#$options]  ;
            }
        else
            {
            push @values, @$values ;
            push @options, @$options  ;
            }
        }
        
    if ($addbottom)
        {
        push @values, map { $_ -> [0] } @$addbottom ;
        push @options, map { $_ -> [1] } @$addbottom ;
        }

    $req -> {$key} = [\@values, \@options] if (!$nocache) ;
    return (\@values, \@options) ;
    }

# ---------------------------------------------------------------------------
#
#   get_values - returns values and options, possibly filter applied
#

sub get_values

    {
    my ($self, $req) = @_ ;

    
    my ($values, $options) = $self -> get_all_values ($req) ;
    my $filter = $self -> {filter} ;
    return ($values, $options) if (!$filter) ;

    my @values ;
    my @options ;
    my $i = 0 ;
    foreach (@$values)
        {
        if (/$filter/)
            {
            push @values, $_ ;
            push @options, $options -> [$i] ;
            }
        $i++ ;
        }
    return (\@values, \@options) ;
    }
        

# ---------------------------------------------------------------------------
#
#   get_datasource_controls - returns additional controls provided by the
#   datasource object e.g. a browse button
#

sub get_datasource_controls

    {
    my ($self, $req) = @_ ;

    return $self -> {datasrcobj} -> get_datasource_controls ($req, $self) if ($self -> {datasrcobj}) ;
    return ;
    }

# ---------------------------------------------------------------------------
#
#   get_id_from_value - returns id for a given value
#

sub get_id_from_value

    {
    my ($self, $value) = @_ ;

    return if (!$self -> {datasrcobj}) ;
    return $self -> {datasrcobj} -> get_id_from_value ($value) ;
    }

# ---------------------------------------------------------------------------
#
#   get_option_form_value - returns the option for a given value
#
#   in  $value  value
#   ret         option
#

sub get_option_from_value

    {
    my ($self, $value, $req) = @_ ;
    
    my $addtop = $self -> {addtop} ;
    if ($addtop)
        {
        foreach (@$addtop)
            {
            if ($_ -> [0] eq $value)
                {
                return $_ -> [1] ;
                }
            }
        }    

    if ($self->{datasrc})
        {
        my $option = $self -> {datasrcobj} -> get_option_from_value ($value, $req, $self) ;
    
        return $option if (defined ($option)) ;
        }
    elsif (ref $self -> {values})
        {
        my $i = 0 ;
        foreach (@{$self -> {values}})
            {
            if ($_ eq $value)
                {
                my $options = [$self -> {options}[$i] || $value] ;
                $options = $self -> form -> convert_options ($self, [$value], $options, $req)
                    if (!$self -> {showoptions}) ;
                return $options -> [0] ;
                }
            $i++ ;
            }
        }

    my $addbottom = $self -> {addbottom} ;
    if ($addbottom)
        {
        foreach (@$addbottom)
            {
            if ($_ -> [0] eq $value)
                {
                return $_ -> [1] ;
                }
            }
        }    

    return ;
    }

# ---------------------------------------------------------------------------
#
#   get_active_id - get the id of the value which is currently active
#

sub get_active_id

    {
    my ($self, $req)   = @_ ;

    my $key = "active_id:$self" ;
    my $id ;
    return $id if ($id = $req -> {$key}) ;

    my ($values, $options) = $self -> get_values ($req) ;
    my $name     = $self -> {name} ;
    my $dataval  = $fdat{$name} || $values -> [0] ;
    my $activeid ;

    my $i = 0 ;
    foreach my $val (@$values)
        {
        if ($val eq $dataval)
            {
            $activeid = "$name-$i" ;
            last ;
            }
        $i++ ;
        }

    return $req -> {$key} = $activeid ;
    }

# ---------------------------------------------------------------------------
#
#   is_with_id - returns true if the control shows something that has an internal id
#

sub is_with_id

    {
    my ($self, $req) = @_ ;

    return 1 ;
    }
    
# ------------------------------------------------------------------------------------------
#
#   get_display_text - returns the text that should be displayed
#

sub get_display_text
    {
    my ($self, $req, $value) = @_ ;

    $value = $self -> get_value ($req) if (!defined ($value)) ;
    $value = $self -> get_option_from_value ($value, $req) ;

    return $value ;
    }
    
# ---------------------------------------------------------------------------
#
#   init_markup - add any dynamic markup to the form data
#

sub init_markup

    {
    my ($self, $req, $parentctl, $method) = @_ ;

    return if (!$self -> is_readonly($req) && (! $parentctl || ! $parentctl -> is_readonly($req))) ;
    
    my $val = $self -> get_value ($req) ;
    if ($val ne '')
        {
        my $name = $self -> {name} ;
        my $fdat = $req -> {docdata} || \%Embperl::fdat ;
        $fdat -> {'_opt_' . $name} = $self -> get_option_from_value ($val, $req) ;
        $fdat -> {'_id_' .  $name} = $self -> get_id_from_value ($val, $req) ;
        }
    }
    
1 ;

# damit %fdat etc definiert ist
__EMBPERL__


[# ---------------------------------------------------------------------------
#
#   show_control_readonly - output the control as readonly
#]

[$ sub show_control_readonly ($self, $req, $value) 

my $text  = $self -> get_display_text ($req, $value)  ;
my $id    = $self -> get_id_from_value ($val, $req) ; 
my $name  = $self -> {force_name} || $self -> {name} ;
$]
<div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly', 'ef-control-with-id') } +] _ef_divname="_opt_[+ $name +]">[+ $text +]</div>
[$ if $self->{hidden} $]
<input type="hidden" name="[+ $name +]" value="[+ $value +]">
[$endif$]
<input type="hidden" name="_id_[+ $name +]" value="[+ $id +]">
[$endsub$]

[# ---------------------------------------------------------------------------
#
#   show_control_addons - output additional things after the control
#]

[$ sub show_control_addons ($self, $req)
 
my $datasrc_ctrls  ;
$datasrc_ctrls = $self -> get_datasource_controls ($req)
    unless ($self -> {no_datasource_controls}) ;

$][$if $datasrc_ctrls $]
[$foreach my $ctrl (@$datasrc_ctrls) $]
<a class="cControlAddonA" href="[+ $ctrl->{href} +]" onClick="[+ $ctrl->{onclick} +]">[$if $ctrl -> {icon} $]<img class="cControlAddonImg" src="[+ $ctrl -> {icon} +]" title="[+ $ctrl -> {text} +]" alt="[+ $ctrl -> {text} +]">[$else$][+ $ctrl -> {text} +][$endif$]</a>
[$endforeach$]
[$endif$]
[$endsub$]


__END__

=pod

=head1 NAME

Embperl::Form::ControlMultValue - Base class for controls inside
an Embperl Form which have multiple values to select from, like
a select box or radio buttons.


=head1 SYNOPSIS

Do not use directly, instead derive a class

=head1 DESCRIPTION

This class is not used directly, it is used as a base class for
all controls which have multiple values to select from inside
an Embperl Form. It provides a set of methods
that could be overwritten to customize the behaviour of your controls.

=head1 METHODS

=head2 get_values

returns the values and options

=head2 get_datasource_controls

returns additional controls provided by the
datasource object e.g. a browse button

=head2 get_active_id

get the id of the value which is currently active

=head1 PARAMETERS

=head3 values

Arrayref with the values to select from. This is what gets
submited back to the server.

=head3 options

Arrayref with the options to select from. This is what the user sees.

=head3 datasrc

Name of an class which provides the values for the
values and options parameters. Either a full package name or
a name, in which case all packages which are returned
by Embperl::Form::get_datasrc_packages are searched.
Everything after '#' is ignored and can be used by the
DataSource module to do further selections.

=head3 no_datasource_controls

Disables the output of the additional controls

=head1 AUTHOR

G. Richter (richter at embperl dot org)

=head1 SEE ALSO

perl(1), Embperl, Embperl::Form, Embperl::From::Control, Embperl::Form::DataSource