You are viewing a plain text version of this content. The canonical link for it is here.
Posted to embperl-cvs@perl.apache.org by ri...@apache.org on 2005/12/11 13:17:50 UTC

svn commit: r355958 - in /perl/embperl/trunk/Embperl: Form.pm Form/Control.pm Form/Control/radio.pm Form/Control/select.pm

Author: richter
Date: Sun Dec 11 04:17:43 2005
New Revision: 355958

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

Modified:
    perl/embperl/trunk/Embperl/Form.pm
    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.pm
URL: http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form.pm?rev=355958&r1=355957&r2=355958&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form.pm (original)
+++ perl/embperl/trunk/Embperl/Form.pm Sun Dec 11 04:17:43 2005
@@ -116,7 +116,7 @@
 sub new_controls
 
     {
-    my ($self, $controls, $options, $id, $formid, $validate_rules, $mask, $default) = @_ ;
+    my ($self, $controls, $options, $id, $formid, $validate_rules, $masks, $defaults) = @_ ;
     
     my $n = 0 ;
     my $packages = $self -> get_control_packages ;
@@ -129,8 +129,9 @@
         $control -> {id} ||= "$control->{name}-$n" ;
         $control -> {formid} = $formid ;
         
-        my $default = $defaults -> {$name} || $defaults -> {$type} ;
-        my $mask    = $masks    -> {$name} || $masks -> {$type} ;
+        my $type    = $control -> {type} ;
+        my $default = $defaults -> {$name} || $defaults -> {"*$type"} || $defaults -> {'*'};
+        my $mask    = $masks    -> {$name} || $masks -> {"*$type"} || $masks -> {'*'};
         if ($mask)
             {
             foreach (keys %$mask)
@@ -201,7 +202,7 @@
             foreach my $subcontrols (@{$control -> {sublines}})
                 {
                 next if (!$subcontrols) ;
-                $self -> new_controls ($subcontrols, $options, "$name-$i", $formid, $validate_rules, $mask, $default) ;
+                $self -> new_controls ($subcontrols, $options, "$name-$i", $formid, $validate_rules, $masks, $defaults) ;
                 $i++ ;
                 }
             }
@@ -275,7 +276,8 @@
     my $num = 0 ;
     foreach my $control (@$controls)
         {
-        my $width = int($max_x / ($control -> {width} || 2)) ;
+        next if ($control -> is_disabled) ;
+        my $width = $control -> {width_percent} || int($max_x / ($control -> {width} || 2)) ;
         if ($x + $width > $max_x || $control -> {newline} > 0 || (($control -> {sublines} || $control -> {subobjects}) && @$line))
             { # new line
             if ($x < $max_x)
@@ -687,706 +689,103 @@
 
 __END__
 
-# ---------------------------------------------------------------------------
-
-package main ;
-
-my     @opts = ("pop3","pop2","imap");
-
-print q{
-
-<style>
-.cBase          {font-family: Geneva,Arial,Helvetica;  font-size: 12px;  }
-.cTableDiv      {background: #ffffff; border: black 1px solid; border-top: 0px ; padding: 2px; padding-top: 0px ;
-                 margin: 0px }
-.cTable         {background: #ffffff; border-collapse: collapse; width: 700px;}
-.cTableRow1     {background: #ffffff; }
-.cTableRow      {background: #ffffff; }
-.cControlBox    {background: #D4D4D4; margin: 0px 0px 0px 0px; 
-                    padding: 2px 3px 2px 3px; border: 2px white solid; }
-.cControlButtonBox { text-align: center ; border: 0px ; background: white ; }                    
-.cTransparentBox    {margin: 0px 0px 0px 0px; 
-                    padding: 2px 3px 2px 3px; }
-.cControl          {border: 1px black solid; }
-.cControlButton    {border: 0px }
-.cLabelBox      {background: #FDD11A;  text-align: right; margin: 0px 0px 0px 0px; 
-                    padding: 2px 3px 2px 3px; border: 2px white solid; }
-.cTabTable      {background: #ffffff; padding: 0px; margin: 0px;  
-                    border-collapse: collapse; }
-.cTabRow        {background: #ffffff; padding: 0px; margin: 0px; width: 100%; 
-                    border-collapse: collapse; }
-.cTabCellOn     {background: white ; padding: 0px ; margin: 0px; border: 0px ;
-                    vertical-align: bottom; }
-.cTabCellOff    {background: white ; padding: 0px ; margin: 0px; border: 0px ;
-                    vertical-align: bottom; }
-.cTabCellBlank  {background: white ; padding: 0px ; margin: 0px; border: 0px ;
-                    border-bottom: 1px black solid; vertical-align: bottom; 
-                    width: 95%;}
-.cTabDivOn      {background-image: url(bg_tab_on.gif) ; background-repeat: repeat-x ; 
-                    border: black 1px solid; 
-                    border-bottom: #FFFFFF 1px solid; padding: 4px; 
-                     font-weight: bold ;
-                    font-size:16px; white-space: nowrap ;
-                    }
-.cTabDivOff     {background-image: url(bg_tab_off.gif); background-repeat: repeat-x ; 
-                    border: black 1px solid; padding: 4px; 
-                    font-size:12px; white-space: nowrap ;
-                    }
-
-.cGridTitle     {background: #ffffff; padding: 0px; margin: 0px;  
-                    border-collapse: collapse; width: 100% ; }
-.cGridControlBox {background: #FDD11A;  text-align: right ; margin: 0px 0px 0px 0px; 
-                    padding: 2px 3px 2px 3px; border: 0px; }
-.cGridLabelBox  {background: #FDD11A;  text-align: left; margin: 0px 0px 0px 0px; 
-                    padding: 2px 3px 2px 3px; border: 0px; }
-
-.cGridTable        {background: #ffffff; border-collapse: collapse; width: 100%;
-                    border: 1px solid black; position: relative; }
-.cGridHeader       {background: #D4D4D4; padding: 2px; margin: 0px;  
-                      height: 16px ; border: 1px solid black;}
-
-.cGridData         {background: #ffffff; padding: 0px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridHidden       { visibility: hidden; display: none ; }
-
-
-.cGridCell         { padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridInput        {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridLink         {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridSelect       {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridCheckbox     {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridRadio        {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridDisplay      {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridList         {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-.cGridReadonly     {padding: 2px; margin: 0px;  
-                     border: 1px solid black; }
-
-.cGridInputActive {width: 99%; margin:2px; border: solid 1px #000000;  padding: 1px; color:black; background-color: #eeeeee}
-
-.cGridHighlight    { background-color: highlight; color: highlighttext; }
-
-.cGridChanged      { font-style: italic; font-weight: bold ; }
-
-} ;
-
 =pod
-tr.cChild_attr
-	{
-	display: none;
-    }
-    
-    
-tr.cGlobal_attr
-	{
-	display: none;
-    }
-    
-tr.cChild_attr_VISIBLE
-	{
-	display: yes;
-    }
-    
-tr.cGlobal_attr_VISIBLE
-	{
-	display: yes;
-    }
-    
-#attributAuswahl
-	{
-	overflow:auto;
-    width:740px;
-    height:360px;
-  	left:0px;
-    top:0px;
-    }
 
-    
-    
-    
-td.input {border-style: solid; border-width: 1px; padding: 2px;}
-td.select {border-style: solid; border-width: 1px; padding: 0px;}
-td.checkbox {border-style: solid; border-width: 1px; padding: 0px;}
-td.radio {border-style: solid; border-width: 1px; padding: 0px;}
-td.info {border-style: solid; border-width: 1px; padding: 2px;}
-td.header {border-style: solid; border-width: 1px; padding: 2px;vertical-align:middle;}
-td.display {border-style: solid; border-width: 1px; padding: 2px;}
-td.link {border-style: solid; border-width: 1px; padding: 2px;}
-td.list {border-style: solid; border-width: 1px; padding: 2px;}
+=head1 NAME
 
-td.readonly {border-style: solid; border-width: 1px; padding: 2px;}
+Embperl::Form - Embperl Form class
 
+=head1 SYNOPSIS
 
-td.data {border-style: solid; border-width: 1px ;padding: 2px;border-color:#000000}
-//cGridInputGrid
-input.grid {width: 99%; margin:2px; border-style: solid; border-width: 1px; border-color: #000000; font-family: verdana, arial, sans-serif; font-size: 10px; padding: 1px; color:black; background-color: #FFFFFF}
+=head1 DESCRIPTION
 
-tr.header {background-color: #ffffc0;}
+=head1 METHODS
 
-tr.data      {background-color:#FFFFFF;font-weight:500}
-tr.childdata {background-color:#FFFFFF;font-weight:300;border-color:#000000;color:#AAAAAA}
-tr.changed   {background-color:#DDDDDD;}
+=head2 new ($controls, $options)
 
+=over 4
 
-tr.highlight {background-color:highlight;color:highlighttext;}
+=item * $controls 
 
+Array ref with controls which should be displayed
+inside the form. Each control needs either to be a
+hashref with all parameters for the control or
+a control object.
 
+If hash refs are given it's necessary to specify
+the C<type> parameter, to let Embperl::Form
+know which control to create.
 
-table.hidden {visibility:hidden;}
+See Embperl::Form::Control and Embperl::Form::Control::*
+for a list of available parameters.
 
-a.highlight {
-    text-decoration:underline;
-    color:highlighttext;
-    }   
+=item * $options
 
-a.cGridLink {
-   text-decoration:underline;
-       color:blue;
-    }
+Hash ref which can take the following parameters:
 
-a.cGridLink:hover {
-        text-decoration:none;
-        color:red;
-        }
-=cut
-print q{
+=over 4
 
-</style>
+=item * masks
 
-<script>
+Contains a hash ref which can specify a set of masks
+for the controls. A mask is a set of parameter which 
+overwrite the setting of a control. You can specify
+a mask for a control name (key is name), for a control 
+type (key is *type) or for all controls (key is *).
 
-function set_grid_display(elm,display)
-    {
-    var elements = elm.getElementsByTagName('table');
-    for (var i = 0; i < elements.length ; i++)
-        {
-        if(elements[i].className.search('cGridTable') != -1)
-            {
-            elements[i].style.display = display;
-            }
-        }   
-    }
+Example:
 
-function set_display(value,display)
     {
-    var elm ;
-    if (elm = document.getElementById(value))
-        {
-        elm.style.display = display ;
-        set_grid_display(elm,display);
-        }
-    j = 10 ;
-    dummy= value + j;
-    while (elm = document.getElementById(dummy) )
-        {
-        elm.style.display = display ;
-        j++ ;
-        dummy= value + j;
-        }
-    }
-
-function set_class(name, classval)
-    {
-    var obj = document.getElementById(name) ;
-    if (obj)
-        obj.className = classval ;
-    }
-
-function show_id_setobj(value, name)
-    {
-    var obj = document.getElementById(name) ;
-    if (obj)
-        obj.value = value ;
-            
-    set_display(value,"") ;
-    }
-
-
-function tab_selected(value,name)
-    {
-    var obj = document.getElementById(name) ;
-
-    if (obj && obj.value)
-            {
-            set_display(obj.value,"none") ;
-            set_class('__tabs_' + obj.value, 'cTabDivOff') ;
-            }
-
-    set_class('__tabs_' + value, 'cTabDivOn') ;
-    show_id_setobj(value, name) ;
-    }
-
-function show_selected(obj)
-    {
-    var i ;
-    var x = obj.selectedIndex ;
-    var name = obj.name ;
-    var elm ;
-    var baseid = name + '-'  ;
-    for (i=0;i<obj.options.length;i++)
-        {
-        if (obj.options[i].value != '')
-            {
-            elm = document.getElementById(baseid + i) ;
-            if (elm)
-                {
-                if (i == x)
-                    {
-                    elm.style.display = "" ;
-                    }
-                else
-                    {
-                    elm.style.display = "none" ;
-                    }
-                }
-            j = 10 ;
-	    dummy = baseid + i + '-' + j;
-            while (elm = document.getElementById(dummy) )
-                {
-                if (i == x)
-                    {
-                    elm.style.display = "" ;
-                    }
-                else
-                    {
-                    elm.style.display = "none" ;
-                    }
-                j++ ;
-	        dummy = baseid + i + '-' + j;
-                }
-            }
-        }
-    }
-
-
-function show_checked(obj)
-    {
-    var i ;
-    var x = obj.checked?0:1 ;
-    var name = obj.name ;
-    var elm ;
-    var baseid = name + '-'  ;
-    for (i=0;i<2;i++)
-        {
-        elm = document.getElementById(baseid + i) ;
-        if (elm)
-            {
-            if (i == x)
-                {
-                elm.style.display = "" ;
-                }
-            else
-                {
-                elm.style.display = "none" ;
-                }
-            }
-        j = 10 ;
-        dummy = baseid + i + '-' + j;
-        while (elm = document.getElementById(dummy) )
-            {
-            if (i == x)
-                {
-                elm.style.display = "" ;
-                }
-            else
-                {
-                elm.style.display = "none" ;
-                }
-            j++ ;
-            dummy = baseid + i + '-' + j;
-            }
-        }
-    }
-
-function show_radio_checked(obj,x,max)
-    {
-    var i ;
-    var name = obj.name ;
-    var elm ;
-    var baseid = name + '-'  ;
+    'info'      => { readonly => 1},
+    '*textarea' => { cols => 80 },
+    '*'         => { labelclass => 'myclass', labelnowrap => 1}
+    } 
     
-    for (i=0;i<=max;i++)
-        {
-        elm = document.getElementById(baseid + i) ;
-        if (elm)
-            {
-            if (i == x)
-                {
-                elm.style.display = "" ;
-                }
-            else
-                {
-                elm.style.display = "none" ;
-                }
-            }
-        j = 10 ;
-    dummy = baseid + i + '-' + j;
-        while (elm = document.getElementById(dummy) )
-            {
-            if (i == x)
-                {
-                elm.style.display = "" ;
-                }
-            else
-                {
-                elm.style.display = "none" ;
-                }
-            j++ ;
-        dummy = baseid + i + '-' + j;
-            }
-        }
-    }
+This will force the control with the name C<info> to be readonly, it
+will force all C<textarea> controls to have 80 columns and
+it will force the label of all controls to have a class of myclass
+and not to wrap the text.    
 
-function addremoveInitOptions (src, dest, send, removesource)
-    {
-    var i ;
-	var j ;
-	var found = 0 ;
-	var val ;
-    var vals = send.value.split("\t") ;
-    for (i = 0; i < vals.length; i++)
-        {
-        val = vals[i] ;
-        found = 0 ;
-        for (j = 0; j < src.length; j++)
-            {
-            if (src.options[j].value == val)
-        	   {
-        	   found = 1 ;
-        	   break ;
-        	   }
-            }
-        if (found)
-        	{
-            var newopt = document.createElement('OPTION') ;
-            var oldopt = src.options[j] ;
-            newopt.text = oldopt.text ;
-            newopt.value = oldopt.value ;
-            dest.options.add(newopt) ;
-        	}
-        }
-     if (removesource)
-         { 
-         for (i = 0; i < src.length; i++)
-             {
-             val = src.options[i].value ;
-             for (j = 0; j < vals.length; j++)
-                 {
-                 if (vals[j] == val)
-        	         {
-                     src.options[i] = null ;
-        	         i-- ;
-        	         break ; 
-        	         }
-                 }
-             }
-         }
-     }
-     
-function addremoveBuildOptions (dest, send)
-    {
-    var i ;
-    var val = '' ;
-    for (i = 0; i < dest.length; i++)
-        {
-        val += dest.options[i].value ;
-        if (i < dest.length - 1)
-            val += "\t" ;
-        }
-    send.value=val ;
-    }
+=item * defaults
 
-function addremoveAddOption (src, dest, send, removesource)
-    {
-    if (src.selectedIndex >= 0)
-        {
-        var newopt = document.createElement('OPTION') ;
-        var oldopt = src.options[src.selectedIndex] ;
-        newopt.text = oldopt.text ;
-        newopt.value = oldopt.value ;
-        dest.options.add(newopt) ;
-        if (removesource)
-            src.options[src.selectedIndex] = null ;
-        addremoveBuildOptions (dest, send) ;
-        }
-    else
-        alert ("Bitte einen Eintrag zum Hinzufügen auswählen") ;
+Contains a hash ref which can specify a set of defaults
+for the controls. You can specify
+a default for a control name (key is name), for a control 
+type (key is *type) or for all controls (key is *).
 
-    }
+Example:
 
-function addremoveRemoveOption (src, dest, send, removesource)
     {
-    if (dest.selectedIndex >= 0)
-        {
-        if (removesource)
-			{
-            var newopt = document.createElement('OPTION') ;
-            var oldopt = dest.options[dest.selectedIndex] ;
-            newopt.text = oldopt.text ;
-            newopt.value = oldopt.value ;
-            src.options.add(newopt) ;
-            }
-        //dest.options.remove(dest.selectedIndex) ;
-        dest.options[dest.selectedIndex] = null ;
-        addremoveBuildOptions (dest, send) ;
-        }
-    else
-        alert ("Bitte einen Eintrag zum Entfernen auswählen") ;
-
-    }
-
-
-
-</script>
-<SCRIPT src="TableCtrl.js"></SCRIPT>
+    'info'      => { readonly => 1},
+    '*textarea' => { cols => 80 },
+    '*'         => { labelclass => 'myclass', labelnowrap => 1}
+    } 
+    
+This will make the control with the name C<info> to default to be readonly, it
+will deafult all C<textarea> controls to have 80 columns and
+it will set the default class for the labels of all controls to
+myclass and not to wrap the text.    
 
-} ;
+=back
 
-=pod
-my $form = Embperl::Form -> new ([
-	        { name => 'cn', text => 'Name', width => 2 ,section =>1, validate => [required => 1]},
-	        { name => 'serviceStart', text => 'Starten', section => 1, width => 2, type => 'checkbox'   },            
-	        { name => 'fetchmail-servername', text => 'Servername' ,validate => [required => 1], xtype => 'sf_select_hostdef'},
-	        { name => 'fetchmail-protocol', text => 'Protokoll', type => 'select',options => \@opts, values => \@opts, },
-	        { name => 'fetchmail-protocol', text => 'Protokoll', type => 'radio',options => \@opts, values => \@opts, },
-	        { name => 'fetchmail-username', text => 'Username' ,validate => [required => 1]},
-	        { name => 'fetchmail-password', text => 'Passwort',validate => [required => 1] },
-	        { name => 'fetchmail-postmaster', text => 'Postmaster', width => 4 },
-	        { name => 'fetchmail-localdomains', text => 'lokale Domänen', width => 4  },
-          
-	        { name => 'fetchmail-smtpaddress', text => 'SMTP Adresse' , xtype => 'sf_select_host', validate => [required => 1], width => 4 },
-            
-            
-#            { type => 'blank'},  
-	        { name => 'cronjob-min0', text => 'Minute', width => 5, newline => 1, size => 8 },
-	        { name => 'cronjob-hour0', text => 'Stunde', width => 5, size => 8   },
-	        { name => 'cronjob-day0', text => 'Tag', width => 5, size => 8   },
-	        { name => 'cronjob-mon0', text => 'Monat', width => 5, size => 8   },
-	        { name => 'cronjob-wday0', text => 'Wochentag', width => 5, size => 8   },
-	        { name => 'cronjob-min1', text => 'Minute', width => 5, newline => 1, size => 8 },
-	        { name => 'cronjob-hour1', text => 'Stunde', width => 5, size => 8   },
-	        { name => 'cronjob-day1', text => 'Tag', width => 5, size => 8   },
-	        { name => 'cronjob-mon1', text => 'Monat', width => 5, size => 8   },
-	        { name => 'cronjob-wday1', text => 'Wochentag', width => 5, size => 8   },
-	        { name => 'cronjob-min2', text => 'Minute', width => 5, newline => 1, size => 8 },
-	        { name => 'cronjob-hour2', text => 'Stunde', width => 5, size => 8   },
-	        { name => 'cronjob-day2', text => 'Tag', width => 5, size => 8   },
-	        { name => 'cronjob-mon2', text => 'Monat', width => 5, size => 8   },
-	        { name => 'cronjob-wday2', text => 'Wochentag', width => 5, size => 8   },
-	        { name => 'cronjob-min3', text => 'Minute', width => 5, newline => 1, size => 8 },
-	        { name => 'cronjob-hour3', text => 'Stunde', width => 5, size => 8   },
-	        { name => 'cronjob-day3', text => 'Tag', width => 5, size => 8   },
-	        { name => 'cronjob-mon3', text => 'Monat', width => 5, size => 8   },
-	        { name => 'cronjob-wday3', text => 'Wochentag', width => 5, size => 8   },
-                { name => 'fetchmail', text => 'Benutzerliste', newline => 1, xtype => 'grid', hidden => 'fetchmail-user', colspan => 16}, 
-
-
-]) ;
-=cut
-
-            my @tabid = qw (---- verbindungsmonitor ipsec internet intranet1 intranet2 intranet3 intranet4 ppp ippp dsl local syscfg pptp ipx tunnel1 tunnel2 tunnel3 tunnel4);
-            my @auth =("esp","ah");
-            my @auto =("ignore","add","route", "start");
-            my @pfs =("yes","no");
-            my @jn   =("Ja","Nein");
-
-
-our $form = Embperl::Form -> new ([
-                Embperl::Form -> add_tabs ( 
-                    [
-                    {
-                    text => 'Allgemein',
-                    fields => [
-	       { name => 'cn', text => 'Name', section=>1,validate => [required => 1]},
-    	       { name => 'ipsec-auto', section => 1, text => 'Automatisch starten', type => 'select', 
-			options => ['Aus', 'Konfigurieren', 'Routing', 'Ja'], values => \@auto  },
-
-	               { name => 'description', text => 'Beschreibung',width=>1  },
-	               { name => 'ipsec-right',        text => 'Lokale Adresse', , type => 'sf_select_interface_id', addtop =>
-		          [['%defaultroute', 'Adresse der Defaultroute']],     validate => [required => 1] },
-	               { name => 'ipsec-left',         text => 'Remote Adresse', , type => 'sf_select_host', addtop => [['%any', 'Jede']], validate => [required => 1] },
-	               { name => 'ipsec-rightnexthop', text => 'Lokales Gateway',  type => 'sf_select_host' },
-	               {},
-	               #{ name => 'ipsec-leftnexthop',  text => 'Remote Gateway',   type => 'sf_select_host' },
-	               Embperl::Form -> add_sublines({width => 1, section => 1, name => 'ipsec-type', text => 'Verbindungsart'},
-	                   [
-	                   {
-	                   name => 'tunnel',
-	                   text => 'tunnel',
-	                   fields => [
-                                        { name => 'ipsec-rightsubnet',  text => 'Lokales Subnetz',   
-			                  type   => 'sf_select_network_group', 
-                                          addtop => [['', '---'], ['0/0', 'Alles (0/0)']] 
-                                        },
-                                        { name => 'ipsec-leftsubnet',   text => 'Remote Subnetz',
-                                                type => 'sf_select_network_group',  
-                                                addtop => [['', '---'], ['0/0', 'Alles (0/0)']] 
-                                        },
-                                      ]
-	                   },
-	                   {
-	                   name => 'transport',
-	                   text => 'transport',
-	                   fields => []
-	                   }
-                           ]),
-
-	               { name => 'ipsec-rightproto',   text => 'Lokales Protokoll',  type => 'sf_select_protocol' },
-               	       { name => 'ipsec-leftproto',    text => 'Remote Protokoll',   type => 'sf_select_protocol' },
-	               { name => 'ipsec-rightport',    text => 'Lokaler Port',       type => 'sf_select_port' },
-	               { name => 'ipsec-leftport',     text => 'Remote Port',        type => 'sf_select_port' },
-                       { name => 'ipsec-rightsourceip', text => 'Lokale Quelladresse', type=> 'sf_select_interface_adress'},
-                       { name => 'ipRoute-tableid', text => 'Routing Table-ID', type=> 'select', values=>\@tabid , options=>\@tabid},
-	               Embperl::Form -> add_sublines(
-                            {name => 'ipsec-authby', text => 'Authentifizierung durch', width => 1, section => 1,},
-                            [
-                            {
-                            name => 'rsasig',
-                            text => 'Zertifikate',
-                            fields => [ 
-                                        { name => 'ipsec-rightcert',    text => 'Lokales Zertifikat', type => ecos::BBFeatures::is_sthc()?'sf_select_allcert':'sf_select_caservercert', addtop => [] },
-	                                { name => 'ipsec-leftid',       text => 'Remote Zertifikat(e)' , type => !ecos::BBFeatures::is_sthc()?'sf_select_allcert':'sf_select_caservercert'},
-                                       ]
-                            },
-                            { 
-                            name => 'secret',
-                            text => 'Shared Secret',
-                            fields => [ { name => 'ipsec-secret',  text => 'Shared Secret', width => 1 },
-                                        { name => 'ipsec-rightid', text => 'Lokale ID'},
-                                        { name => 'ipsec-leftid-name',  text => 'Remote ID'}
-                                       ]
-                            }
-                            ], 'radio')
-                             ]
-            },
-            { 
-            text => 'Erweitert',
-            fields =>   [
-	                   { name => 'ipsec-dpddelay', text => 'Dead Peer Detection Delay' , 
-	                          validate => [emptyok => 1, -type => 'Integer', ge => 0] },
-	                   { name => 'ipsec-dpdtimeout', text => 'DPD Timeout', 
-	                           validate => [emptyok => 1, -type => 'Integer', ge => 0] },
-	                   { name => 'ipsec-dpdaction', text => 'Dead Peer Detection Action', type => 'select', 
-	                       values => ['', 'clear', 'hold'], options => ['---', 'Löschen', 'Halten'] },
-                                {},
-                            { name => 'ipsec-auth',  text => 'auth', type => 'select', options => \@auth, values => \@auth,width=>4, controlclass => 'cInputSelectNarrow'  },
-                        	    { name => 'ipsec-pfs',   text => 'pfs',  type => 'select', options => \@jn,   values => \@pfs ,width=>4, controlclass => 'cInputSelectNarrow' },
-                        	    { name => 'ipsec-rekey', text => 'rekey',type => 'select', options => \@jn,   values => \@pfs ,width=>4, controlclass => 'cInputSelectNarrow' },
-                        	    { name => 'ipsec-compress', text => 'Kompression', type => 'select', 
-                        	    values => ['no', 'yes'], options => ['Nein', 'Ja'], width => 4, controlclass => 'cInputSelectNarrow' },
+=back
 
-                Embperl::Form -> add_checkbox_subform ( 
-                    {
-                    name => '__erweitert' ,
-                    text => 'test check',
-                    fields => [[
-                        	    { name => 'ipsec-ikelifetime', text => 'Phase I (ISAKMP SA) rekey intervall', type => 'number', unit => 'm/h/d', validate => [emptyok => 1, -type => 'TimeValue'], },
-                                    { name => 'ipsec-keylife',     text => 'Phase II (IPsec SA) rekey intervall', type => 'number', unit => 'm/h/d', validate => [emptyok => 1, -type => 'TimeValue'],  },
-                        	    { name => 'ipsec-rekeymargin', text => 'Start Rekeying vor Ende', type => 'number', unit => 'm/h/d', validate => [emptyok => 1, -type => 'TimeValue'], },
-                        	    { name => 'ipsec-keyingtries', text => 'Anzahl Rekey Versuche', type => 'number', validate => [emptyok => 1, -type => 'PosInteger'] },
-                        	    { name => 'ipsec-esp', text => 'ESP Encryption' },
-                        	    { name => 'ipsec-ah',  text => 'AH Encryption' },
-                        	    { name => 'ipsec-espenckey', text => 'ESP enckey' },
-                        	    { },
-                        	    { name => 'ipsec-espauthkey', text => 'ESP authkey' },
-                        	    { name => 'ipsec-ahkey', text => 'AH authkey' },
-                        	    { name => 'ipsec-espreplay--window', text => 'ESP replay_window', type => 'number', validate => [emptyok => 1, -type => 'PosInteger']},
-                        	    { name => 'ipsec-ahreplay--window', text => 'AH replay_window', type => 'number', validate => [emptyok => 1, -type => 'PosInteger']},
-                        	    { name => 'ipsec-leftespspi', text => 'ESP leftspi', type => 'number', validate => [emptyok => 1, ] },
-                        	    { name => 'ipsec-leftahspi', text => 'AH leftspi', type => 'number', validate => [emptyok => 1, ] },
-                        	    { name => 'ipsec-spi', text => 'spi'},
-                        	    { name => 'ipsec-spibase', text => 'spibase'},
-                            ]],
-                    }),
+=head2 layout
 
-                    ],
-            },
-            {
-            text => 'Dynamische Freigabe',
-            #fn => '.dyn-enable.epl'
-            fields =>   [
-	                   { name => 'ipsec-dpddelay', text => 'Dead Peer Detection Delay' , 
-	                          validate => [emptyok => 1, -type => 'Integer', ge => 0] },
-	                   { name => 'ipsec-dpdtimeout', text => 'DPD Timeout', 
-	                           validate => [emptyok => 1, -type => 'Integer', ge => 0] },
-	                   { name => 'ipsec-dpdaction', text => 'Dead Peer Detection Action', type => 'select', 
-	                       values => ['', 'clear', 'hold'], options => ['---', 'Löschen', 'Halten'] },
-                                {},
-                ],
-                    },
-            {
-            text => 'Grid',
-            fields =>   [
-	       { name => 'cn2', text => 'Name', section=>1,validate => [required => 1]},
-    	       { name => 'ipsec-auto2', section => 1, text => 'Automatisch starten', type => 'select', 
-			options => ['Aus', 'Konfigurieren', 'Routing', 'Ja'], values => \@auto  },
-
-	               { name => 'description2', text => 'Beschreibung',width=>1  },
-
-        { name => 'testgrid', text => 'Test Grid' , type => 'grid',
-          fields => 
-            [
-        {name => 'active',      text => 'Aktiv',                type => 'checkbox',width => '10%'},                 
-        {name => 'param',       text => 'parameter',            type => 'input',   width => '50%'},            
-        {name => 'param',       text => 'Auswahl',              type => 'select',  width => '40%',
-                values => [1,2,3], options => ['a', 'b', 'c']},            
-            ],
-            
-             },
+=head2 show
 
 
-	                   { name => 'ipsec-dpdaction', text => 'Dead Peer Detection Action', type => 'select', 
-	                       values => ['', 'clear', 'hold'], options => ['---', 'Löschen', 'Halten'] },
-                {}],
-                    },
-
-            {fields => [
-                             { name => '_host-based-on', text => 'Die Konfiguration dieses Hosts basiert auf der Konfiguration des/der folgenden Host(s)', type => 'blank', width => 1  },
-                             { name => 'dest_host_based_on', text => 'Basiert auf', type => 'select', rows => 4, width => 2 },
-                             { name => 'host-based-on',  type => 'addremove', src => 'src_host_based_on', dest => 'dest_host_based_on', removesource => 1, width => 4  },
-                             { name => 'src_host_based_on', text => 'Auswahl', type => 'sf_select_bb5000_id', rows => 4, addtop => [], width => 4, values => [1,2,3], options => ['hosta', 'hostb', 'hostc']   },
-                             { name => '_host-add-to', text => 'Die Konfiguration dieses Hosts zu folgenden Hosts hinzufügen', type => 'blank', width => 1  },
-                             { name => 'host-add-to-first', text => 'Nur zum ersten verfügbaren Host hinzufügen', type => 'checkbox', width => 1  },
-                             { name => 'dest_host_add_to', text => 'Hinzufügen zu', type => 'select', rows => 4, width => 2 },
-                             { name => 'host-add-to',  type => 'addremove', src => 'src_host_add_to', dest => 'dest_host_add_to', removesource => 1, width => 4  },
-                             { name => 'src_host_add_to', text => 'Auswahl', type => 'sf_select_bb5000_id', rows => 4, addtop => [], width => 4   },
-                            ],
-            text => 'Abhängigkeiten',                
-            },
+=head1 AUTHOR
 
+G. Richter (richter@dev.ecos.de)
 
-                    
-            ]),
-        { type => 'transparent', width => 1, },
-Embperl::Form -> add_line ([
-	{ type => 'submit', text => 'Übernehmen', image => 'button_uebernehmen.gif'},
-	{ type => 'submit', text => 'Neu', image => 'button_neu.gif', novalidate => 1},
-	{ type => 'submit', text => 'Neu Untergeordnet', image => 'button_neuuntergeordnet.gif', novalidate => 1},
-	{ type => 'submit', text => 'Klonen', image => 'button_klonen.gif', novalidate => 1},
-	{ type => 'submit', text => 'Verschieben', image => 'button_verschieben.gif', novalidate => 1},
-	{ type => 'submit', text => 'Kopieren', image => 'button_kopieren.gif', novalidate => 1},
-	{ type => 'submit', text => 'Löschen', image => 'button_loeschen.gif', novalidate => 1},
-	{ type => 'submit', text => 'Berechtigungen', image => 'button_berechtigung.gif', novalidate => 1},
-	{ type => 'submit', text => 'Hilfe', image => 'button_hilfe.gif', novalidate => 1},
-        ], 100),
-	]);
+=head1 SEE ALSO
 
+perl(1), Embperl, Embperl::Form::Control
 
-$form  -> layout ;
 
 
 
-my $x = '$escmode = 0 ; select (OUT) ; $::form  -> show ( { "__auswahlx"=> 2}); ' ;
 
-Embperl::Execute ({input => \$x, syntax => 'Perl' }) ;
 
 
-sub ecos::BBFeatures::is_sthc { 0 }
-        
\ No newline at end of file

Modified: perl/embperl/trunk/Embperl/Form/Control.pm
URL: http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control.pm?rev=355958&r1=355957&r2=355958&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control.pm Sun Dec 11 04:17:43 2005
@@ -17,6 +17,7 @@
 package Embperl::Form::Control ;
 
 use strict ;
+use vars qw{%fdat} ;
 
 use Embperl::Inline ;
 
@@ -88,7 +89,7 @@
     {
     my ($self, $data) = @_ ;
 
-    $fdat{$self -> {name}} = $self -> {default} if ($fdat{$self -> {name}} eq '' && exists ($self -> {default}))
+    $fdat{$self -> {name}} = $self -> {default} if ($fdat{$self -> {name}} eq '' && exists ($self -> {default})) ;
     my $span = 0 ;
     $span += $self -> show_label_cell ($span);
     return $self -> show_control_cell ($span, $data) ;
@@ -365,10 +366,16 @@
 
 =head2 width
 
-Gives the widths of the control. The value is 1/width
+Gives the widths of the control. The value is C<1/width>
 of the the whole width of the form. So if you want to
-have four controls in one line set width to 4. The default value
+have four controls in one line set C<width> to 4. The default value
 is 2.
+
+=head2 width_percent
+
+With this parameter you can also specify the width of
+the control in percent. This parameter take precendence over
+C<width>
 
 =head1 AUTHOR
 

Modified: perl/embperl/trunk/Embperl/Form/Control/radio.pm
URL: http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control/radio.pm?rev=355958&r1=355957&r2=355958&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/radio.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/radio.pm Sun Dec 11 04:17:43 2005
@@ -36,16 +36,56 @@
 
     my ($values, $options) = $self -> get_values ;
     my $name     = $self -> {name} ;
+    my $filter   = $self -> {filter} ;
+    my $addtop   = $self -> {addtop} || [] ;
+    my $addbottom= $self -> {addbottom} || [] ;
     my $max      = @$values ;
 
     my $val ;     
     my $i = 0 ;
 $]    
+[$ foreach $val (@$addtop) $]
+    [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    <input type="radio" name="[+ $name +]" value="[+ $val -> [0] +]"
+    >[+ $val ->[1] || $val -> [0] +]
+    [$endif$]
+[$endforeach$]
 [$ foreach $val (@$values) $]
+    [$if !defined ($filter) || ($val =~ /$filter/i) $]
     <input type="radio" name="[+ $name +]" value="[+ $val +]"
     [$if ($self -> {sublines} || $self -> {subobjects}) $] OnClick="show_radio_checked(this,[+ $i +],[+ $max +])" [$endif$]
     >[+ $options ->[$i] || $val +]
     [- $vert = $self -> {vert} -][$while $vert-- > 0 $]<br/>[$endwhile$]
+    [$endif$]
+    [* $i++ ; *]
+[$endforeach$]
+[$ foreach $val (@$addbottom) $]
+    [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    <input type="radio" name="[+ $name +]" value="[+ $val -> [0] +]"
+    >[+ $val ->[1] || $val -> [0] +]
+    [$endif$]
+[$endforeach$]
+
+[$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$]
 
@@ -103,6 +143,31 @@
 
 If specified arranges the radio button vertically. The number given specifies
 the number of <br>'s used the separate the radio buttons.
+
+=head3 addtop
+
+Array ref which contains items that should be added at the left or top
+of the radio buttons. Each item consists of an array ref with two 
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+    addtop => [ [1 => 'first item'], [2 => 'second item']]
+
+=head3 addbottom
+
+Array ref which contains items that should be added at the right or bottom
+of the radio buttons. Each item consists of an array ref with two 
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+    addbottom => [ [9999 => 'last item'], [9999 => 'very last item']]
+
+=head3 filter
+
+If given, only items where the value matches the regex given in 
+C<filter> are displayed.
 
 =head1 Author
 

Modified: perl/embperl/trunk/Embperl/Form/Control/select.pm
URL: http://svn.apache.org/viewcvs/perl/embperl/trunk/Embperl/Form/Control/select.pm?rev=355958&r1=355957&r2=355958&view=diff
==============================================================================
--- perl/embperl/trunk/Embperl/Form/Control/select.pm (original)
+++ perl/embperl/trunk/Embperl/Form/Control/select.pm Sun Dec 11 04:17:43 2005
@@ -36,13 +36,32 @@
 
     my ($values, $options) = $self -> get_values ;
     my $name     = $self -> {name} ;
+    my $filter   = $self -> {filter} ;
+    my $addtop   = $self -> {addtop} || [] ;
+    my $addbottom= $self -> {addbottom} || [] ;
     my $val ;     
+    my $i = 0 ;
 $]    
 <select  class="cBase cControl" name="[+ $name +]" id="[+ $name +]"
 [$if ($self -> {sublines} || $self -> {subobjects}) $] OnChange="show_selected(this)" [$endif$]
 [$if ($self -> {rows}) $] size="[+ $self->{rows} +]" [$endif$]
 >
-    <option value="[+ do { $val = $values -> [$row] } +]">[+ $options ->[$row] || $val +]</option>
+[$ foreach $val (@$addtop) $]
+    [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    <option value="[+ $val->[0] +]">[+ $val ->[1] || $val -> [0] +]</option>
+    [$endif$]
+[$endforeach$]
+[$ foreach $val (@$values) $]
+    [$if !defined ($filter) || ($val =~ /$filter/i) $]
+    <option value="[+ $val +]">[+ $options ->[$i] || $val +]</option>
+    [$endif$]
+    [* $i++ ; *]
+[$endforeach$]
+[$ foreach $val (@$addbottom) $]
+    [$if !defined ($filter) || ($val->[0] =~ /$filter/i) $]
+    <option value="[+ $val->[0] +]">[+ $val ->[1] || $val -> [0] +]</option>
+    [$endif$]
+[$endforeach$]
 </select>
 
 [$endsub$]
@@ -99,6 +118,32 @@
 
 If specified a select box is display with the given number of lines.
 If not specified or undef, a drop down list is shown.
+
+=head3 addtop
+
+Array ref which contains items that should be added at the top
+of the select box. Each item consists of an array ref with two 
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+    addtop => [ [1 => 'first item'], [2 => 'second item']]
+
+=head3 addbottom
+
+Array ref which contains items that should be added at the bottom
+of the select box. Each item consists of an array ref with two 
+entries, the first is the value and the second is the option
+that is displayed on the page. If the second is missing the
+value (first entry)is displayed. Example:
+
+    addbottom => [ [9999 => 'last item'], [9999 => 'very last item']]
+
+=head3 filter
+
+If given, only items where the value matches the regex given in 
+C<filter> are displayed.
+
 
 =head1 Author
 



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-cvs-help@perl.apache.org