Author: richter
Date: Fri Dec 23 06:16:19 2005
New Revision: 358807

URL: http://svn.apache.org/viewcvs?rev=358807&view=rev
Log:
Embperl::Form

Added:
    perl/embperl/trunk/Embperl/Form/Control/table.pm   (with props)
Modified:
    perl/embperl/trunk/Embperl/Form/Control.pm
    perl/embperl/trunk/Embperl/Form/Control/radio.pm
    perl/embperl/trunk/Embperl/Form/Control/select.pm

Modified: perl/embperl/trunk/Embperl/Form/Control.pm
URL: 
http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control.pm?rev=358807&r1=358806&r2=358807&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control.pm Fri Dec 23 06:16:19 2005
@@ -187,7 +187,7 @@
 #   show - output the control
 #]
 
-[$ sub show_label ($self) $][+ $self->{text} +][$endsub$]
+[$ sub show_label ($self) $][+ $self->{text} || $self->{name} +][$endsub$]
 
 [# ---------------------------------------------------------------------------
 #

Modified: perl/embperl/trunk/Embperl/Form/Control/radio.pm
URL: 
http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control/radio.pm?rev=358807&r1=358806&r2=358807&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/radio.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/radio.pm Fri Dec 23 06:16:19 2005
@@ -17,11 +17,23 @@
 package Embperl::Form::Control::radio ;
 
 use strict ;
+use vars qw{%fdat} ;
 use base 'Embperl::Form::ControlMultValue' ;
 
 use Embperl::Inline ;
 
+# ---------------------------------------------------------------------------
+#
+#   show_control_readonly - output readonly control
+#
 
+sub show_control_readonly 
+    {
+    my ($self) = @_ ;
+    
+    my $name     = $self -> {name} ;
+    $self -> show_control ("^\Q$fdat{$name}\\E\$") ;
+    }
 
 1 ;
 
@@ -32,26 +44,29 @@
 #   show_control - output the control
 #]
 
-[$ sub show_control ($self) 
+[$ sub show_control ($self, $filter) 
 
     my ($values, $options) = $self -> get_values ;
     my $name     = $self -> {name} ;
-    my $filter   = $self -> {filter} ;
+    $filter    ||= $self -> {filter} ;
     my $addtop   = $self -> {addtop} || [] ;
     my $addbottom= $self -> {addbottom} || [] ;
     my $max      = @$values ;
+    my $set      = !defined ($fdat{$name})?1:0 ;
 
     my $val ;     
     my $i = 0 ;
-$]    
+$]
 [$ foreach $val (@$addtop) $]
     [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    [- $fdat{$name} = $val -> [0], $set = 0 if ($set) ; -]
     <input type="radio" name="[+ $name +]" value="[+ $val -> [0] +]"
     >[+ $val ->[1] || $val -> [0] +]
     [$endif$]
 [$endforeach$]
 [$ foreach $val (@$values) $]
     [$if !defined ($filter) || ($val =~ /$filter/i) $]
+    [- $fdat{$name} = $val, $set = 0 if ($set) ; -]
     <input type="radio" name="[+ $name +]" value="[+ $val +]"
     [$if ($self -> {sublines} || $self -> {subobjects}) $] 
OnClick="show_radio_checked(this,[+ $i +],[+ $max +])" [$endif$]
     >[+ $options ->[$i] || $val +]
@@ -61,6 +76,7 @@
 [$endforeach$]
 [$ foreach $val (@$addbottom) $]
     [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    [- $fdat{$name} = $val -> [0], $set = 0 if ($set) ; -]
     <input type="radio" name="[+ $name +]" value="[+ $val -> [0] +]"
     >[+ $val ->[1] || $val -> [0] +]
     [$endif$]
@@ -68,29 +84,7 @@
 
 [$endsub$]
 
-[# ---------------------------------------------------------------------------
-#
-#   show_control_readonly - output readonly control
-#]
-
-[$ sub show_control_readonly ($self) 
 
-    my ($values, $options) = $self -> get_values ;
-    my $name     = $self -> {name} ;
-    my $max      = @$values ;
-
-    my $val ;     
-    my $i = 0 ;
-$]    
-[$ foreach $val (@$values) $]
-    [$if $val eq $fdat{$name} $]
-    <input type="radio" name="[+ $name +]" value="[+ $val +]">[+ $options ->[ 
$i] || $val +]
-    [$endif$]
-    [* $i++ ; *]
-[$endforeach$]
-
-
-[$endsub$]
 
 __END__
 

Modified: perl/embperl/trunk/Embperl/Form/Control/select.pm
URL: 
http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control/select.pm?rev=358807&r1=358806&r2=358807&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/select.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/select.pm Fri Dec 23 06:16:19 2005
@@ -17,9 +17,23 @@
 package Embperl::Form::Control::select ;
 
 use strict ;
+use vars qw{%fdat} ;
 use base 'Embperl::Form::ControlMultValue' ;
 
 use Embperl::Inline ;
+
+# ---------------------------------------------------------------------------
+#
+#   show_control_readonly - output readonly control
+#
+
+sub show_control_readonly 
+    {
+    my ($self) = @_ ;
+    
+    my $name     = $self -> {name} ;
+    $self -> show_control ("^\Q$fdat{$name}\\E\$") ;
+    }
 
 
 

Added: perl/embperl/trunk/Embperl/Form/Control/table.pm
URL: 
http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control/table.pm?rev=358807&view=auto
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/table.pm (added)
+++ perl/embperl/trunk/Embperl/Form/Control/table.pm Fri Dec 23 06:16:19 2005
@@ -0,0 +1,145 @@
+
+###################################################################################
+#
+#   Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh   www.ecos.de
+#
+#   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::table ;
+
+use strict ;
+use base 'Embperl::Form::Control' ;
+
+use Embperl::Inline ;
+
+1 ;
+
+__EMBPERL__
+    
+[# ---------------------------------------------------------------------------
+#
+#   show_table - output the control
+#]
+
+[$ sub show_table ($self, $data) 
+
+    my $span = ($self->{width_percent})  ;
+
+$]
+<td class="cBase cTabTD" colspan="[+ $span +]">
+[$if $self -> {text} $]
+[# --- heading text --- #]
+<table width="100%"><tr><td class="cLabelBox">
+[+ $self -> {text} +]<br>
+</td></tr></table>
+[$endif$]
+<table width="100%">
+
+[# --- heading columns --- #]
+[- $i = 0 -]
+[$foreach $line (@{$self->{columns}}) $]
+<tr style="background: white">
+[$foreach $c (@$line) $]
+<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[+$self -> {line2} || 
(@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+]">[+ ref 
$c?$c -> [1] || $c -> [0]:$c +]</td>
+[$endforeach$]
+[- $i++ -]
+</tr>
+[$endforeach$]
+
+[# --- data --- #]
+[$foreach $o (@$data) $]
+[- $i = 0 -]
+[$foreach $line (@{$self->{columns}}) $]
+<tr style="background: white">
+[$foreach $c (@$line) $]
+<td colspan="[+ ref $c?$c -> [2] || 1:1 +]" class="[+$self -> {line2} || 
(@{$self->{columns}} > 1 && $i == 0)?'cGridLabelBox':'cControlBox'+]">[- $item 
= ref $c?$o -> {$c -> [0]}:$o -> {$c} -][+ ref $item?join ('; ',@$item):$item 
+]</td>
+[$endforeach$]
+[- $i++ -]
+</tr>
+[$endforeach$]
+[$if $self -> {line2} $]
+    <tr>
+    <td class="cControlBox" colspan="[+ scalar(@{$self->{columns}})+]">[+ join 
('<br>', @{$o->{$self -> {line2}}}) +]</td>
+    </tr>
+[$endif$]
+[$endforeach$]
+</table>
+</td>
+
+[$endsub$]
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Embperl::Form::Control::table - A table which get data from LDAP composed via 
joinAttrValue
+
+
+=head1 SYNOPSIS
+
+  { 
+  type => 'table',
+  text => 'blabla', 
+  columns => [['foo', 'Foo item'], 'bar'],
+  }
+
+=head1 DESCRIPTION
+
+Used as a base class to create an table control inside an Embperl Form.
+See Embperl::Form on how to specify parameters.
+You need to overwrite this class and call the method
+show_table. show_table takes an arrayref of hashrefs as parameter
+which is used as data to display.
+
+=head2 PARAMETER
+
+=head3 type
+
+Needs to be 'table'
+
+=head3 text 
+
+Will be used as label for the control
+
+=head3 columns
+
+Arraryref which contains an arrayrefs with definition of columns names.
+Allows to specify multiple rows per data entry. Column definition
+is either the name in the data hashref or an arrayref with the name in
+the hash ref and the text to display as heading. Example:
+
+    [
+     [['email', 'E-Mail Address'], ['phone', 'Phone']],
+     [['foo', 'Foo'], ['bar', 'Bar']],
+    ]
+
+email and phone will be display on the first line with headings
+'E-Mail Address' and 'Phone' and foo and bar will be displayed
+on the second line for each entry.
+
+=head3 line2
+
+Arrayref with names of which the values should concated and displayed
+below each entry.
+
+
+=head1 Author
+
+G. Richter ([EMAIL PROTECTED])
+
+=head1 See Also
+
+perl(1), Embperl, Embperl::Form
+
+

Propchange: perl/embperl/trunk/Embperl/Form/Control/table.pm
------------------------------------------------------------------------------
    svn:executable = *



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to