| 1 | |||
| 2 | ################################################################################### | ||
| 3 | # | ||
| 4 | # Embperl - Copyright (c) 1997-2008 Gerald Richter / ecos gmbh www.ecos.de | ||
| 5 | # Embperl - Copyright (c) 2008-2015 Gerald Richter | ||
| 6 | # Embperl - Copyright (c) 2015-2023 actevy.io | ||
| 7 | # | ||
| 8 | # You may distribute under the terms of either the GNU General Public | ||
| 9 | # License or the Artistic License, as specified in the Perl README file. | ||
| 10 | # | ||
| 11 | # THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR | ||
| 12 | # IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | ||
| 13 | # WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
| 14 | # | ||
| 15 | # $Id$ | ||
| 16 | # | ||
| 17 | ################################################################################### | ||
| 18 | |||
| 19 | package Embperl::Form::Control::displaylink ; | ||
| 20 | |||
| 21 | use strict ; | ||
| 22 | use base 'Embperl::Form::Control' ; | ||
| 23 | |||
| 24 | use Embperl::Inline ; | ||
| 25 | |||
| 26 | # --------------------------------------------------------------------------- | ||
| 27 | # | ||
| 28 | # show_control_readonly - output readonly control | ||
| 29 | # | ||
| 30 | |||
| 31 | sub show_control_readonly | ||
| 32 | { | ||
| 33 | my ($self, $req) = @_ ; | ||
| 34 | |||
| 35 | $self -> show_control ($req) ; | ||
| 36 | } | ||
| 37 | |||
| 38 | 1 ; | ||
| 39 | |||
| 40 | __EMBPERL__ | ||
| 41 | |||
| 42 | [# --------------------------------------------------------------------------- | ||
| 43 | # | ||
| 44 | # show_control - output the control | ||
| 45 | #] | ||
| 46 | |||
| 47 | [$ sub show_control ($self, $req) | ||
| 48 | |||
| 49 | my $name = $self->{name}; | ||
| 50 | my $hrefs = $self -> {href} ; | ||
| 51 | my $targets = $self -> {target} ; | ||
| 52 | my $opens = $self -> {open} ; | ||
| 53 | my $displays = $self -> {link} || $self -> {value} ; | ||
| 54 | my $form = $self -> form ; | ||
| 55 | my $showoptions = $self -> {showoptions} ; | ||
| 56 | my $state = $self -> {state} ; | ||
| 57 | |||
| 58 | $hrefs = [$hrefs] if (!ref $hrefs) ; | ||
| 59 | $targets = [$targets] if ($targets && !ref $targets) ; | ||
| 60 | $opens = [$opens] if ($opens && !ref $opens) ; | ||
| 61 | $displays = [$displays] if (!ref $displays) ; | ||
| 62 | |||
| 63 | |||
| 64 | @hrefs = map { my $x = $_ ; $x =~ s/%%%name%%%/$epreq->Escape ($fdat{$name},6)/eg ; $x =~ s/%%(.+?)%%/$epreq->Escape ($fdat{$1}, 6)/eg ; $x } ref ($hrefs)?@$hrefs:($hrefs) ; | ||
| 65 | @opens = map { my $x = $_ ; $x =~ s/%%%name%%%/$epreq->Escape ($fdat{$name},6)/eg ; $x =~ s/%%(.+?)%%/$epreq->Escape ($fdat{$1}, 6)/eg ; $x } ref ($opens)?@$opens:($opens) ; | ||
| 66 | @displays = map { my $x = $_ ; $x =~ s/%%%name%%%/$fdat{$name}/g ; $x =~ s/%%(.+?)%%/$fdat{$1}/eg ; $x } @$displays ; | ||
| 67 | |||
| 68 | my $dispn = 0 ; | ||
| 69 | $] | ||
| 70 | <div [+ do { local $escmode = 0 ; $self -> get_std_control_attr($req, '', 'readonly') } +]> | ||
| 71 | [$ foreach $display (@displays) $] | ||
| 72 | [$if $opens[$dispn] $] | ||
| 73 | <a href="#" class="[+ $state +]" onclick="if (this.className.search('ef-disabled') == -1) [+ $opens[$dispn] +][$if $hrefs[$dispn] $]('[+ $hrefs[$dispn] +]')[$endif$]" [+ do { local $escmode = 0 ; $self -> {eventattrs} } +]> | ||
| 74 | [$else$] | ||
| 75 | <a href="[+ do {local $escmode=0;$hrefs[$dispn]} +]" class="[+ $state +]" | ||
| 76 | [$if $targets -> [$dispn] $]target="[+ $targets -> [$dispn] +]"[$endif$] | ||
| 77 | [+ do { local $escmode = 0 ; $self -> {eventattrs} } +]> | ||
| 78 | [$endif$][$ if $showoptions < 0 $][+ do { local $escmode = 0 ; $display } +][$else$][+ $showoptions?$display:$form -> convert_text ($self, $display, undef, $req) +][$endif$]</a> | ||
| 79 | [- $dispn++ -] | ||
| 80 | [$endforeach$] | ||
| 81 | </div> | ||
| 82 | __END__ |