cvs: pear /HTML_OOH_Form form.php
| From: | Ulf Wendel | Date: | Tue, 20 Nov 2001 01:21:26 +0000 |
| Subject: | cvs: pear /HTML_OOH_Form form.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-1383@lists.php.net to get a copy of this message | ||
uw Mon Nov 19 20:21:26 2001 EDT
Modified files:
/pear/HTML_OOH_Form form.php
Log:
JavaScript changes
Index: pear/HTML_OOH_Form/form.php
diff -u pear/HTML_OOH_Form/form.php:1.8 pear/HTML_OOH_Form/form.php:1.9
--- pear/HTML_OOH_Form/form.php:1.8 Sat Nov 3 18:06:37 2001
+++ pear/HTML_OOH_Form/form.php Mon Nov 19 20:21:26 2001
@@ -16,7 +16,7 @@
// | Authors: Ulf Wendel <ulf.wendel@phpdoc.de> |
// +----------------------------------------------------------------------+
//
-// $Id: form.php,v 1.8 2001/11/03 23:06:37 uw Exp $
+// $Id: form.php,v 1.9 2001/11/20 01:21:26 uw Exp $
require_once('HTML_OOH_Form/form_commonobject.php');
@@ -47,11 +47,11 @@
* - tree (select box with options show as a tree)
*
* @author Ulf Wendel <ulf.wendel@phpdoc.de>
-* @version $Id: form.php,v 1.8 2001/11/03 23:06:37 uw Exp $
+* @version $Id: form.php,v 1.9 2001/11/20 01:21:26 uw Exp $
* @access public
* @package HTML_OOH_Form
*/
-class form extends form_commonobject {
+class form2 extends form_commonobject {
/**
* Some default values.
@@ -216,7 +216,13 @@
* @see setAdditionalHTML(), Finish(), getFinish()
*/
var $additional_html;
+
+ //////////////////////////////////////////////
+
+
+
+ //////////////////////////////////////////////
/**
* Sets all paramters required for the opening [form} Tag
*
@@ -226,15 +232,14 @@
* @param string HTML target attribute.
* @global $PHP_SELF
*/
- function form($js_name = '', $method = '', $action = '', $target =
'') {
+ function form2($js_name = '', $method = '', $action = '', $target =
'') {
global $PHP_SELF;
if ('' != $js_name)
$this->js_name = $js_name;
$this->setMethod($method);
-
- if ('' === $action)
+ if ('' == $action)
$this->action = $PHP_SELF;
else if ('' != $action)
$this->action = $action;
@@ -371,6 +376,7 @@
return true;
} // end func autoloadValues
+
/**
* Sets the value of one element or a group of elements.
@@ -498,13 +504,13 @@
* @access public
*/
function getStart() {
-
- $html = sprintf('<form action="%s" target="%s" method =
"%s" ',
+
+ $html = sprintf('<form action="%s" target="%s"
method="%s" ',
$this->action,
$this->target,
$this->method
);
-
+
if ($this->flag_file) {
$html .= 'enctype="multipart/form-data" ';
$method = 'POST';
@@ -786,11 +792,12 @@
* Use the function within your custom validation functions.
*
* @param string $name element name
+ * @param boolean encoded value?
* @return mixed $value
* @throws form_error
* @access public
*/
- function getValue($name) {
+ function getValue($name, $encoded = false) {
if (!$this->ElementExists($name)) {
$this->exceptions[] = new form_error("'$name' is unknown", __FILE__,
__LINE__);
return NULL;
@@ -1057,6 +1064,7 @@
$js = '';
$custom = '';
$get_value = '';
+ $set_value = '';
// list of already send get_value functions
$send_func = array();
@@ -1079,33 +1087,60 @@
}
// custom validator and get_value function
- list($eldata, $getvalue_func, $getvalue_fname, $js_validator) = $el->getJS($complex);
+ $jsdata = $el->getJS($complex);
// replace newlines, otherwise we'll get unterminated string literals.
- $eldata = str_replace(array("\n", "\m"), array('',
''), $eldata);
+ $eldata = str_replace(array("\n", "\m"), array('',
''), $jsdata['eldata']);
- if ($js_validator)
- $custom .= $js_validator . "\n";
+ if ($jsdata['js_validator'])
+ $custom .= $jsdata['js_validator'] . "\n";
// remove the element name prefix
$elname = str_replace($this->element_prefix, '', $el->getName());
$js .= str_replace($el->getName(), $elname, $eldata);
- if ($getvalue_fname) {
+ if ($jsdata['decode_func'] &&
!isset($send_func[$jsdata['decode_func']])) {
+ $custom .= $jsdata['decode_func'] . "\n";
+ $send_func[$jsdata['decode_func']] = true;
+ }
+
+ if ($jsdata['encode_func'] &&
!isset($send_func[$jsdata['encode_func']])) {
+ $custom .= $jsdata['encode_func'] . "\n";
+ $send_func[$jsdata['encode_func']] = true;
+ }
+
+ if ($jsdata['getvalue_fname']) {
// don't radio entries twice
if (!isset($send_gv_el[$elname])) {
- $get_value .= sprintf('"%s", "%s", ', $elname,
$getvalue_fname);
+ $get_value .= sprintf('"%s", "%s", ', $elname,
$jsdata['getvalue_fname']);
$send_gv_el[$elname] = true;
}
// complex function used to get the value of this form element
- if (!isset($send_func[$getvalue_fname])) {
- $base_code = $base_code . " " . $getvalue_func . ';';
- $send_func[$getvalue_fname] = true;
+ if (!isset($send_func[$jsdata['getvalue_fname']])) {
+ $base_code = $base_code . " " . $jsdata['getvalue_func'] .
';';
+ $send_func[$jsdata['getvalue_fname']] = true;
}
}
+
+ if ($jsdata['setvalue_fname']) {
+
+ // don't radio entries twice
+ if (!isset($send_gv_el[$elname])) {
+ $set_value .= sprintf('"%s", "%s", ', $elname,
$jsdata['setvalue_fname']);
+ $send_gv_el[$elname] = true;
+ }
+
+ // complex function used to get the value of this form element
+ if (!isset($send_func[$jsdata['setvalue_fname']])) {
+ $base_code = $base_code . " " . $jsdata['setvalue_func'] .
';';
+ $send_func[$jsdata['setvalue_fname']] = true;
+ }
+
+ }
+
}