Update of /cvsroot/phplib/php-lib-stable/php
In directory usw-pr-cvs1:/tmp/cvs-serv16892
Modified Files:
of_checkbox.inc of_file.inc of_radio.inc of_select.inc
of_text.inc of_textarea.inc oohforms.inc
Log Message:
clean up code in oohforms.inc:
add braces around one-line conditionals
remove spaces before newlines
one space after a comma in function params
Index: of_checkbox.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_checkbox.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_checkbox.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_checkbox.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 18,22 ****
function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
--- 18,22 ----
function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
***************
*** 24,31 ****
if (is_array($this->value)) {
reset($this->value);
! while (list($k,$v) = each($this->value)) {
if ($v==$val) {
! $str .= " checked";
! break;
}
}
--- 24,31 ----
if (is_array($this->value)) {
reset($this->value);
! while (list($k, $v) = each($this->value)) {
if ($v==$val) {
! $str .= " checked";
! break;
}
}
***************
*** 34,44 ****
$str .= "<input type='checkbox' name='$this->name'";
$str .= " value='$this->value'";
! if ($this->checked)
$str .= " checked";
}
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">\n";
!
$count = 1;
return $str;
--- 34,46 ----
$str .= "<input type='checkbox' name='$this->name'";
$str .= " value='$this->value'";
! if ($this->checked) {
$str .= " checked";
+ }
}
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">\n";
!
$count = 1;
return $str;
***************
*** 47,51 ****
function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$t="";
--- 49,53 ----
function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$t="";
***************
*** 54,58 ****
if (is_array($this->value)) {
reset($this->value);
! while (list($k,$v) = each($this->value)) {
if ($v==$val) {
$x = 1;
--- 56,60 ----
if (is_array($this->value)) {
reset($this->value);
! while (list($k, $v) = each($this->value)) {
if ($v==$val) {
$x = 1;
***************
*** 76,87 ****
return $str;
}
!
function self_load_defaults($val) {
! if ($this->multiple)
$this->value = $val;
! elseif (isset($val) && (!$this->value || $val==$this->value))
$this->checked=1;
! else
$this->checked=0;
}
--- 78,90 ----
return $str;
}
!
function self_load_defaults($val) {
! if ($this->multiple) {
$this->value = $val;
! } elseif (isset($val) && (!$this->value || $val==$this->value)) {
$this->checked=1;
! } else {
$this->checked=0;
+ }
}
Index: of_file.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_file.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_file.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_file.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 16,28 ****
}
! function self_get($val,$which, &$count) {
$str = "";
!
$str .= "<input type='hidden' name='MAX_FILE_SIZE' value=$this->size>\n";
$str .= "<input type='file' name='$this->name'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
$count = 2;
return $str;
--- 16,29 ----
}
! function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='hidden' name='MAX_FILE_SIZE' value=$this->size>\n";
$str .= "<input type='file' name='$this->name'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
$count = 2;
return $str;
Index: of_radio.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_radio.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_radio.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_radio.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 1,5 ****
<?php
/* OOHForms: radio
! *
* Copyright (c) 1998 by Jay Bloodworth
*
--- 1,5 ----
<?php
/* OOHForms: radio
! *
* Copyright (c) 1998 by Jay Bloodworth
*
***************
*** 18,27 ****
function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='radio' name='$this->name' value='$val'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
! if ($this->value==$val)
$str .= " checked";
$str .= ">";
--- 18,29 ----
function self_get($val, $which, &$count) {
$str = "";
!
$str .= "<input type='radio' name='$this->name' value='$val'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
! }
! if ($this->value==$val) {
$str .= " checked";
+ }
$str .= ">";
***************
*** 30,36 ****
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
$x = 0;
if ($this->value==$val) {
--- 32,38 ----
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
if ($this->value==$val) {
***************
*** 42,46 ****
}
$str .= "<tr><td> </tr></td></table>\n";
!
$count = $x;
return $str;
--- 44,48 ----
}
$str .= "<tr><td> </tr></td></table>\n";
!
$count = $x;
return $str;
***************
*** 49,53 ****
function self_get_js($ndx_array) {
$str = "";
!
if ($this->valid_e) {
$n = $this->name;
--- 51,55 ----
function self_get_js($ndx_array) {
$str = "";
!
if ($this->valid_e) {
$n = $this->name;
***************
*** 67,71 ****
function self_validate($val) {
! if ($this->valid_e && !isset($val)) return $this->valid_e;
return false;
}
--- 69,75 ----
function self_validate($val) {
! if ($this->valid_e && !isset($val)) {
! return $this->valid_e;
! }
return false;
}
Index: of_select.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_select.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_select.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_select.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 16,25 ****
function of_select($a) {
$this->setup_element($a);
! if ($a["type"]=="select multiple") $this->multiple=1;
}
!
! function self_get($val,$which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
--- 16,27 ----
function of_select($a) {
$this->setup_element($a);
! if ($a["type"]=="select multiple") {
! $this->multiple=1;
! }
}
!
! function self_get($val, $which, &$count) {
$str = "";
!
if ($this->multiple) {
$n = $this->name . "[]";
***************
*** 30,51 ****
}
$str .= "<$t name='$n'";
! if ($this->size)
$str .= " size='$this->size'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
reset($this->options);
! while (list($k,$o) = each($this->options)) {
$str .= "<option";
! if (is_array($o))
$str .= " value='" . $o["value"] . "'";
! if (!$this->multiple && ($this->value==$o["value"] || $this->value==$o))
$str .= " selected";
! elseif ($this->multiple && is_array($this->value)) {
reset($this->value);
! while (list($tk,$v) = each($this->value)) {
! if ($v==$o["value"] || $v==$o) {
! $str .= " selected"; break;
}
}
--- 32,56 ----
}
$str .= "<$t name='$n'";
! if ($this->size) {
$str .= " size='$this->size'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
reset($this->options);
! while (list($k, $o) = each($this->options)) {
$str .= "<option";
! if (is_array($o)) {
$str .= " value='" . $o["value"] . "'";
! }
! if (!$this->multiple && ($this->value==$o["value"] || $this->value==$o)) {
$str .= " selected";
! } elseif ($this->multiple && is_array($this->value)) {
reset($this->value);
! while (list($tk, $v) = each($this->value)) {
! if ($v==$o["value"] || $v==$o) {
! $str .= " selected"; break;
}
}
***************
*** 54,65 ****
}
$str .= "</select>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
$x = 0;
$n = $this->name . ($this->multiple ? "[]" : "");
--- 59,70 ----
}
$str .= "</select>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
$x = 0;
$n = $this->name . ($this->multiple ? "[]" : "");
***************
*** 67,74 ****
$str .= "<table border=1>\n";
reset($v_array);
! while (list($tk,$tv) = each($v_array)) {
reset($this->options);
! while (list($k,$v) = each($this->options)) {
! if ((is_array($v) &&
(($tmp=$v["value"])==$tv || $v["label"]==$tv))
|| ($tmp=$v)==$tv) {
--- 72,79 ----
$str .= "<table border=1>\n";
reset($v_array);
! while (list($tk, $tv) = each($v_array)) {
reset($this->options);
! while (list($k, $v) = each($this->options)) {
! if ((is_array($v) &&
(($tmp=$v["value"])==$tv || $v["label"]==$tv))
|| ($tmp=$v)==$tv) {
***************
*** 80,84 ****
}
$str .= "</table>\n";
!
$count = $x;
return $str;
--- 85,89 ----
}
$str .= "</table>\n";
!
$count = $x;
return $str;
***************
*** 87,91 ****
function self_get_js($ndx_array) {
$str = "";
!
if (!$this->multiple && $this->valid_e) {
$str .= "if (f.$this->name.selectedIndex == 0) {\n";
--- 92,96 ----
function self_get_js($ndx_array) {
$str = "";
!
if (!$this->multiple && $this->valid_e) {
$str .= "if (f.$this->name.selectedIndex == 0) {\n";
***************
*** 95,99 ****
$str .= "}\n";
}
!
return $str;
}
--- 100,104 ----
$str .= "}\n";
}
!
return $str;
}
***************
*** 103,107 ****
reset($this->options);
$o = current($this->options);
! if ($val==$o["value"] || $val==$o) return $this->valid_e;
}
return false;
--- 108,114 ----
reset($this->options);
$o = current($this->options);
! if ($val==$o["value"] || $val==$o) {
! return $this->valid_e;
! }
}
return false;
Index: of_text.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_text.inc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** of_text.inc 17 Apr 2000 16:40:15 -0000 1.1.1.1
--- of_text.inc 28 Apr 2002 03:59:32 -0000 1.2
***************
*** 21,61 ****
function of_text($a) {
$this->setup_element($a);
! if ($a["type"]=="password")
$this->pass=1;
}
! function self_get($val,$which, &$count) {
$str = "";
!
! if (is_array($this->value))
$v = htmlspecialchars($this->value[$which]);
! else
$v = htmlspecialchars($this->value);
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input name='$n' value=\"$v\"";
$str .= ($this->pass)? " type='password'" : " type='text'";
! if ($this->maxlength)
$str .= " maxlength='$this->maxlength'";
! if ($this->size)
$str .= " size='$this->size'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
!
! if (is_array($this->value))
$v = $this->value[$which];
! else
$v = $this->value;
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input type='hidden' name='$n' value='$v'>\n";
$str .= "<table border=1><tr><td>$v</td></tr></table>\n";
!
$count = 1;
return $str;
--- 21,67 ----
function of_text($a) {
$this->setup_element($a);
! if ($a["type"]=="password") {
$this->pass=1;
+ }
}
! function self_get($val, $which, &$count) {
$str = "";
!
! if (is_array($this->value)) {
$v = htmlspecialchars($this->value[$which]);
! } else {
$v = htmlspecialchars($this->value);
+ }
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input name='$n' value=\"$v\"";
$str .= ($this->pass)? " type='password'" : " type='text'";
! if ($this->maxlength) {
$str .= " maxlength='$this->maxlength'";
! }
! if ($this->size) {
$str .= " size='$this->size'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
!
! if (is_array($this->value)) {
$v = $this->value[$which];
! } else {
$v = $this->value;
+ }
$n = $this->name . ($this->multiple ? "[]" : "");
$str .= "<input type='hidden' name='$n' value='$v'>\n";
$str .= "<table border=1><tr><td>$v</td></tr></table>\n";
!
$count = 1;
return $str;
***************
*** 64,70 ****
function self_get_js($ndx_array) {
$str = "";
!
reset($ndx_array);
! while (list($k,$n) = each($ndx_array)) {
if ($this->length_e) {
$str .= "if (f.elements[${n}].value.length < $this->minlength) {\n";
--- 70,76 ----
function self_get_js($ndx_array) {
$str = "";
!
reset($ndx_array);
! while (list($k, $n) = each($ndx_array)) {
if ($this->length_e) {
$str .= "if (f.elements[${n}].value.length < $this->minlength) {\n";
***************
*** 76,80 ****
$flags = ($this->icase ? "gi" : "g");
$str .= "if (window.RegExp) {\n";
! $str .= " var reg = new RegExp(\"$this->valid_regex\",\"$flags\");\n";
$str .= " if (!reg.test(f.elements[${n}].value)) {\n";
$str .= " alert(\"$this->valid_e\");\n";
--- 82,86 ----
$flags = ($this->icase ? "gi" : "g");
$str .= "if (window.RegExp) {\n";
! $str .= " var reg = new RegExp(\"$this->valid_regex\", \"$flags\");\n";
$str .= " if (!reg.test(f.elements[${n}].value)) {\n";
$str .= " alert(\"$this->valid_e\");\n";
***************
*** 84,105 ****
}
}
!
return $str;
}
function self_validate($val) {
! if (!is_array($val)) $val = array($val);
reset($val);
! while (list($k,$v) = each($val)) {
! if ($this->length_e && (strlen($v) < $this->minlength))
return $this->length_e;
! if ($this->valid_e && (($this->icase &&
! !eregi($this->valid_regex,$v)) ||
(!$this->icase &&
! !ereg($this->valid_regex,$v))))
return $this->valid_e;
}
return false;
! }
} // end TEXT
--- 90,115 ----
}
}
!
return $str;
}
function self_validate($val) {
! if (!is_array($val)) {
! $val = array($val);
! }
reset($val);
! while (list($k, $v) = each($val)) {
! if ($this->length_e && (strlen($v) < $this->minlength)) {
return $this->length_e;
! }
! if ($this->valid_e && (($this->icase &&
! !eregi($this->valid_regex, $v)) ||
(!$this->icase &&
! !ereg($this->valid_regex, $v)))) {
return $this->valid_e;
+ }
}
return false;
! }
} // end TEXT
Index: of_textarea.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/of_textarea.inc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** of_textarea.inc 9 Aug 2001 01:07:13 -0000 1.2
--- of_textarea.inc 28 Apr 2002 03:59:32 -0000 1.3
***************
*** 18,36 ****
}
! function self_get($val,$which, &$count) {
$str = "";
$str .= "<textarea name='$this->name'";
$str .= " rows='$this->rows' cols='$this->cols'";
! if ($this->wrap)
$str .= " wrap='$this->wrap'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">" . htmlspecialchars($this->value) ."</textarea>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val,$which, &$count) {
$str = "";
$str .= "<input type='hidden' name='$this->name'";
--- 18,38 ----
}
! function self_get($val, $which, &$count) {
$str = "";
$str .= "<textarea name='$this->name'";
$str .= " rows='$this->rows' cols='$this->cols'";
! if ($this->wrap) {
$str .= " wrap='$this->wrap'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">" . htmlspecialchars($this->value) ."</textarea>";
!
$count = 1;
return $str;
}
! function self_get_frozen($val, $which, &$count) {
$str = "";
$str .= "<input type='hidden' name='$this->name'";
***************
*** 41,45 ****
$str .= nl2br($this->value);
$str .= "\n</td></tr></table>\n";
!
$count = 1;
return $str;
--- 43,47 ----
$str .= nl2br($this->value);
$str .= "\n</td></tr></table>\n";
!
$count = 1;
return $str;
Index: oohforms.inc
===================================================================
RCS file: /cvsroot/phplib/php-lib-stable/php/oohforms.inc,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** oohforms.inc 19 Mar 2002 22:32:25 -0000 1.3
--- oohforms.inc 28 Apr 2002 03:59:32 -0000 1.4
***************
*** 1,9 ****
<?php
/* OOH! Forms!
! *
* Object Oriented HTML Forms
*
* Copyright (c) 1998 by Jay Bloodworth
! *
* $Id$
*/
--- 1,9 ----
<?php
/* OOH! Forms!
! *
* Object Oriented HTML Forms
*
* Copyright (c) 1998 by Jay Bloodworth
! *
* $Id$
*/
***************
*** 15,28 ****
var $multiple;
var $extrahtml;
!
! function marshal_dispatch($m,$func) {
$vname = $this->name;
global $$vname;
return $this->$func($$vname);
}
!
function self_get($val, $which, &$count) {
}
!
function self_show($val, $which) {
$count = 0;
--- 15,28 ----
var $multiple;
var $extrahtml;
!
! function marshal_dispatch($m, $func) {
$vname = $this->name;
global $$vname;
return $this->$func($$vname);
}
!
function self_get($val, $which, &$count) {
}
!
function self_show($val, $which) {
$count = 0;
***************
*** 47,51 ****
function self_get_js($ndx_array) {
}
!
function self_print_js($ndx_array) {
print $this->self_get_js($ndx_array);
--- 47,51 ----
function self_get_js($ndx_array) {
}
!
function self_print_js($ndx_array) {
print $this->self_get_js($ndx_array);
***************
*** 54,58 ****
// Note that this function is generally quite simple since
// most of the work of dealing with different types of values
! // is now done in show_self. It still needs to be overidable,
// however, for elements like checkbox that deal with state
// differently
--- 54,58 ----
// Note that this function is generally quite simple since
// most of the work of dealing with different types of values
! // is now done in show_self. It still needs to be overridable,
// however, for elements like checkbox that deal with state
// differently
***************
*** 68,74 ****
"extra_html"=>"extrahtml");
reset($a);
! while (list($k,$v) = each($a)) {
! if ($cv_tab[$k]=="ignore") continue;
! else $k = ($cv_tab[$k] ? $cv_tab[$k] : $k);
$this->$k = $v;
}
--- 68,77 ----
"extra_html"=>"extrahtml");
reset($a);
! while (list($k, $v) = each($a)) {
! if ($cv_tab[$k]=="ignore") {
! continue;
! } else {
! $k = ($cv_tab[$k] ? $cv_tab[$k] : $k);
! }
$this->$k = $v;
}
***************
*** 85,89 ****
}
! function self_get($val,$which, &$count) {
$str = "";
--- 88,92 ----
}
! function self_get($val, $which, &$count) {
$str = "";
***************
*** 91,101 ****
$n = $this->name . ($this->multiple ? "[]" : "");
reset($v);
! while (list($k,$tv) = each($v)) {
$str .= "<input type='hidden' name='$n' value='$tv'";
! if ($this->extrahtml)
$str .=" $this->extrahtml";
$str .= ">";
}
!
return $str;
}
--- 94,105 ----
$n = $this->name . ($this->multiple ? "[]" : "");
reset($v);
! while (list($k, $tv) = each($v)) {
$str .= "<input type='hidden' name='$n' value='$tv'";
! if ($this->extrahtml) {
$str .=" $this->extrahtml";
+ }
$str .= ">";
}
!
return $str;
}
***************
*** 112,119 ****
function self_get($val, $which, &$count) {
$str = "<input name='$this->name' type=reset value='$val'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
return $str;
}
--- 116,124 ----
function self_get($val, $which, &$count) {
$str = "<input name='$this->name' type=reset value='$val'";
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
return $str;
}
***************
*** 124,128 ****
var $src;
! function of_submit($a) {
$this->setup_element($a);
}
--- 129,133 ----
var $src;
! function of_submit($a) {
$this->setup_element($a);
}
***************
*** 130,147 ****
function self_get($val, $which, &$count) {
$str = "";
!
$sv = empty($val) ? $this->value : $val;
$str .= "<input name='$this->name' value='$sv'";
! if ($this->src)
$str .= " type='image' src='$this->src'";
! else
$str .= " type='submit'";
! if ($this->extrahtml)
$str .= " $this->extrahtml";
$str .= ">";
!
return $str;
}
!
function self_load_defaults($val) {
// SUBMIT will not change its value
--- 135,154 ----
function self_get($val, $which, &$count) {
$str = "";
!
$sv = empty($val) ? $this->value : $val;
$str .= "<input name='$this->name' value='$sv'";
! if ($this->src) {
$str .= " type='image' src='$this->src'";
! } else {
$str .= " type='submit'";
! }
! if ($this->extrahtml) {
$str .= " $this->extrahtml";
+ }
$str .= ">";
!
return $str;
}
!
function self_load_defaults($val) {
// SUBMIT will not change its value
***************
*** 156,169 ****
var $n;
! function get_start($jvs_name="",$method="",$action="",$target="",$form_name="") {
global $HTTP_SERVER_VARS;
!
$str = "";
!
$this->jvs_name = "";
$this->n = 0;
! if (!$method) $method = "POST";
! if (!$action) $action = $HTTP_SERVER_VARS["PHP_SELF"];
! if (!$target) $target = "_self";
$str .= "<form name='$form_name' ";
--- 163,182 ----
var $n;
! function get_start($jvs_name="", $method="", $action="", $target="", $form_name="") {
global $HTTP_SERVER_VARS;
!
$str = "";
!
$this->jvs_name = "";
$this->n = 0;
! if (!$method) {
! $method = "POST";
! }
! if (!$action) {
! $action = $HTTP_SERVER_VARS["PHP_SELF"];
! }
! if (!$target) {
! $target = "_self";
! }
$str .= "<form name='$form_name' ";
***************
*** 179,200 ****
$str .= " onsubmit=\"return ${jvs_name}_Validator(this)\"";
}
!
$str .= ">";
!
return $str;
}
! function start($jvs_name="",$method="",$action="",$target="",$form_name="") {
! print $this->get_start($jvs_name,$method,$action,$target,$form_name);
}
! function get_finish($after="",$before="") {
global $sess;
$str = "";
!
if ($this->hidden) {
reset($this->hidden);
! while (list($k,$elname) = each($this->hidden))
$str .= $this->get_element($elname);
}
if (is_object($sess) && ($sess->mode == "get")) {
--- 192,214 ----
$str .= " onsubmit=\"return ${jvs_name}_Validator(this)\"";
}
!
$str .= ">";
!
return $str;
}
! function start($jvs_name="", $method="", $action="", $target="", $form_name="") {
! print $this->get_start($jvs_name, $method, $action, $target, $form_name);
}
! function get_finish($after="", $before="") {
global $sess;
$str = "";
!
if ($this->hidden) {
reset($this->hidden);
! while (list($k, $elname) = each($this->hidden)) {
$str .= $this->get_element($elname);
+ }
}
if (is_object($sess) && ($sess->mode == "get")) {
***************
*** 208,245 ****
$str .= "function ${jvs_name}_Validator(f) {\n";
! if (strlen($before))
$str .= "$before\n";
reset($this->elements);
! while (list($k,$elrec) = each($this->elements)) {
$el = $elrec["ob"];
$str .= $el->self_get_js($elrec["ndx_array"]);
}
! if (strlen($after))
$str .= "$after\n";
$str .= "}\n//-->\n</script>";
}
!
return $str;
}
!
! function finish($after="",$before="") {
print $this->get_finish($after, $before);
}
!
function add_element($el) {
! if (!is_array($el))
return false;
!
$cv_tab = array("select multiple"=>"select", "image"=>"submit");
! if ($t = $cv_tab[$el["type"]])
$t = ("of_" . $t);
! else
$t = ("of_" . $el["type"]);
!
// translate names like $foo[int] to $foo{int} so that they can cause no
// harm in $this->elements
# Original match
! # if (preg_match("/(\w+)\[(d+)\]/i", $el[name], $regs)) {
if (ereg("([a-zA-Z_]+)\[([0-9]+)\]", $el["name"], $regs)) {
$el["name"] = sprintf("%s{%s}", $regs[1], $regs[2]);
--- 222,263 ----
$str .= "function ${jvs_name}_Validator(f) {\n";
! if (strlen($before)) {
$str .= "$before\n";
+ }
reset($this->elements);
! while (list($k, $elrec) = each($this->elements)) {
$el = $elrec["ob"];
$str .= $el->self_get_js($elrec["ndx_array"]);
}
! if (strlen($after)) {
$str .= "$after\n";
+ }
$str .= "}\n//-->\n</script>";
}
!
return $str;
}
!
! function finish($after="", $before="") {
print $this->get_finish($after, $before);
}
!
function add_element($el) {
! if (!is_array($el)) {
return false;
! }
!
$cv_tab = array("select multiple"=>"select", "image"=>"submit");
! if ($t = $cv_tab[$el["type"]]) {
$t = ("of_" . $t);
! } else {
$t = ("of_" . $el["type"]);
! }
!
// translate names like $foo[int] to $foo{int} so that they can cause no
// harm in $this->elements
# Original match
! # if (preg_match("/(\w+)\[(d+)\]/i", $el[name], $regs)) {
if (ereg("([a-zA-Z_]+)\[([0-9]+)\]", $el["name"], $regs)) {
$el["name"] = sprintf("%s{%s}", $regs[1], $regs[2]);
***************
*** 248,263 ****
$el = new $t($el);
$el->type = $t; # as suggested by Michael Graham (ma...@th...)
! if ($el->isfile)
$this->isfile = true;
$this->elements[$el->name]["ob"] = $el;
! if ($el->hidden)
$this->hidden[] = $el->name;
}
! function get_element($name,$value=false) {
$str = "";
$x = 0;
$flag_nametranslation = false;
!
// see add_element: translate $foo[int] to $foo{int}
# Original pattern
--- 266,283 ----
$el = new $t($el);
$el->type = $t; # as suggested by Michael Graham (ma...@th...)
! if ($el->isfile) {
$this->isfile = true;
+ }
$this->elements[$el->name]["ob"] = $el;
! if ($el->hidden) {
$this->hidden[] = $el->name;
+ }
}
! function get_element($name, $value=false) {
$str = "";
$x = 0;
$flag_nametranslation = false;
!
// see add_element: translate $foo[int] to $foo{int}
# Original pattern
***************
*** 268,292 ****
$flag_nametranslation = true;
}
-
- if (!isset($this->elements[$name]))
- return false;
! if (!isset($this->elements[$name]["which"]))
$this->elements[$name]["which"] = 0;
!
$el = $this->elements[$name]["ob"];
! if (true == $flag_nametranslation)
! $el->name = $org_name;
! if (false == $value)
! $value = $el->value;
! if ($this->elements[$name]["frozen"])
! $str .= $el->self_get_frozen($value,$this->elements[$name]["which"]++, $x);
! else
! $str .= $el->self_get($value,$this->elements[$name]["which"]++, $x);
$this->elements[$name]["ndx_array"][] = $this->n;
$this->n += $x;
!
return $str;
}
--- 288,317 ----
$flag_nametranslation = true;
}
! if (!isset($this->elements[$name])) {
! return false;
! }
!
! if (!isset($this->elements[$name]["which"])) {
$this->elements[$name]["which"] = 0;
! }
!
$el = $this->elements[$name]["ob"];
! if (true == $flag_nametranslation) {
! $el->name = $org_name;
! }
! if (false == $value) {
! $value = $el->value;
! }
! if ($this->elements[$name]["frozen"]) {
! $str .= $el->self_get_frozen($value, $this->elements[$name]["which"]++, $x);
! } else {
! $str .= $el->self_get($value, $this->elements[$name]["which"]++, $x);
! }
$this->elements[$name]["ndx_array"][] = $this->n;
$this->n += $x;
!
return $str;
}
***************
*** 308,312 ****
}
! function validate($default=false,$vallist="") {
if ($vallist) {
reset($vallist);
--- 333,337 ----
}
! function validate($default=false, $vallist="") {
if ($vallist) {
reset($vallist);
***************
*** 318,323 ****
while ($elrec) {
$el = $elrec["ob"];
! if ($res = $el->marshal_dispatch($this->method,"self_validate"))
! return $res;
if ($vallist) {
next($vallist);
--- 343,349 ----
while ($elrec) {
$el = $elrec["ob"];
! if ($res = $el->marshal_dispatch($this->method, "self_validate")) {
! return $res;
! }
if ($vallist) {
next($vallist);
***************
*** 341,345 ****
while ($elrec) {
$el = $elrec["ob"];
! $el->marshal_dispatch($this->method,"self_load_defaults");
$this->elements[$el->name]["ob"] = $el; // no refs -> must copy back
if ($deflist) {
--- 367,371 ----
while ($elrec) {
$el = $elrec["ob"];
! $el->marshal_dispatch($this->method, "self_load_defaults");
$this->elements[$el->name]["ob"] = $el; // no refs -> must copy back
if ($deflist) {
|