Date: 05/21/01
- Next message: Karthik Sethuraman: "[phplib-dev] Unsubscribe me please."
- Previous message: uw: "[phplib-dev] cvs commit"
- In reply to: uw: "[phplib-dev] cvs commit"
- Next in thread: Ulf Wendel: "Re: [phplib-dev] please unsubscribe"
- Reply: Ulf Wendel: "Re: [phplib-dev] please unsubscribe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
----- Original Message -----
From: uw <phplib-dev <email protected>>
To: <phplib-dev <email protected>>
Sent: Sunday, May 20, 2001 7:35 PM
Subject: [phplib-dev] cvs commit
> From: uw
> Date: Sun May 20 16:05:38 2001
> Modified files:
> php-lib/pages/form/example_form.inc
> php-lib/pages/form/xml/tests/form_text.xml
> php-lib/php/form/form.inc
> php-lib/php/form/form_commonobject.inc
> php-lib/php/form/form_xmlfactory.inc
> php-lib/php/form/elements/form_element.inc
> php-lib/php/form/elements/form_element_date.inc
> php-lib/php/form/elements/form_element_radio.inc
> php-lib/php/form/elements/form_element_select.inc
> php-lib/php/form/js/form_js_complex.js
> php-lib/php/form/js/form_js_simple.js
>
> Log message:
> - fixed several javascript bugs - looks good now :)
>
>
> Index: php-lib/pages/form/example_form.inc
> diff -u php-lib/pages/form/example_form.inc:1.8
php-lib/pages/form/example_form.inc:1.9
> --- php-lib/pages/form/example_form.inc:1.8 Mon Jan 8 02:01:29 2001
> +++ php-lib/pages/form/example_form.inc Sun May 20 16:05:29 2001
> @@ -34,7 +34,7 @@
> "frozen" => false,
> "multiple" => false,
>
> - "validator" => "DependencieValidator",
> + "validator" =>
"DependencieValidator",
> "js_validator" => 'function DependencieValidator(formobj) {
>
> var i, v;
> Index: php-lib/pages/form/xml/tests/form_text.xml
> diff -u php-lib/pages/form/xml/tests/form_text.xml:1.2
php-lib/pages/form/xml/tests/form_text.xml:1.3
> --- php-lib/pages/form/xml/tests/form_text.xml:1.2 Sat May 19 22:50:45
2001
> +++ php-lib/pages/form/xml/tests/form_text.xml Sun May 20 16:05:30 2001
> @@ -26,10 +26,16 @@
> <css class="css class" id="id">style</css>
> <html accesskey="" tabindex="">additional html</html>
> <validation>
> - <length min="1" max="3">length_e</length>
> + <length min="1" max="4">length_e</length>
> <regexp reg="[a-z]" icase="true">valid_e</regexp>
> <phpfunction callback="true">callback</phpfunction>
> - <jsfunction></jsfunction>
> + <jsfunction>
> + // must have the name of the (phpfunction)
> + function callback(form) {
> + // switch off length validaton
> + form.val_off("name_text", "l");
> + }
> + </jsfunction>
> </validation>
> </text>
>
> Index: php-lib/php/form/form.inc
> diff -u php-lib/php/form/form.inc:1.32 php-lib/php/form/form.inc:1.33
> --- php-lib/php/form/form.inc:1.32 Sat May 19 22:50:46 2001
> +++ php-lib/php/form/form.inc Sun May 20 16:05:31 2001
> @@ -28,7 +28,7 @@
> * - tree (select box with options show as a tree)
> *
> * <email protected> Ulf Wendel <ulf.wendel <email protected>>
> -* <email protected> $Id: form.inc,v 1.32 2001/05/19 20:50:46 uw Exp $
> +* <email protected> $Id: form.inc,v 1.33 2001/05/20 14:05:31 uw Exp $
> * <email protected> public
> * <email protected> Form
> */
> @@ -719,10 +719,10 @@
>
> foreach ($this->getCustomValidators($vallist) as $k => $validator) {
>
> - $func = $validator["php"];
> - if ($validator["callback"])
> + $func = $validator["name"];
> + if ($validator["callback"] && function_exists($func))
> ${func}(&$this);
> - else
> + else if (method_exists($this, $func))
> $this->${func}();
>
> }
> @@ -788,9 +788,9 @@
> $validator = $this->elements[$name]->getValidator();
> if ("" != $validator[0])
> $validators[] = array(
> - "php" => $validator[0],
> + "name" => $validator[0],
> "callback" => $validator[1],
> - "js" => $validator[2]
> + "jscode" => $validator[2]
> );
> }
>
> @@ -883,8 +883,8 @@
>
> $validators = array();
> foreach ($this->getCustomValidators() as $k => $validator)
> - if ("" != $validator["js"])
> - $validators[] = $validator["js"];
> + if ("" != $validator["jscode"])
> + $validators[] = $validator["name"];
>
> if (0 != count($validators)) {
> $complex = true;
> @@ -907,6 +907,7 @@
> $js = "";
> $custom = "";
> $get_value = "";
> +
> // list of already send get_value functions
> $send_func = array();
> $send_gv_el = array();
> @@ -930,7 +931,8 @@
> if ($js_validator)
> $custom .= $js_validator . "\n";
>
> - $js .= $eldata;
> + // remove the element name prefix
> + $js .= str_replace($el->getName(), str_replace($this->element_prefix,
"", $el->getName()), $eldata);
>
> if ($getvalue_fname) {
>
> @@ -972,6 +974,7 @@
> // customize the error message
> $base_code = str_replace("{ERROR_MSG_PREFIX}", $this->js_error_prefix,
$base_code);
> $base_code = str_replace("{ERROR_MSG_POSTFIX}", $this->js_error_postfix,
$base_code);
> + $base_code = str_replace("{NAMEPREFIX}", $this->element_prefix,
$base_code);
>
> $js = sprintf('<script language="JavaScript1.2"><!--//
> %s
> Index: php-lib/php/form/form_commonobject.inc
> diff -u php-lib/php/form/form_commonobject.inc:1.5
php-lib/php/form/form_commonobject.inc:1.6
> --- php-lib/php/form/form_commonobject.inc:1.5 Sat May 19 20:56:45 2001
> +++ php-lib/php/form/form_commonobject.inc Sun May 20 16:05:31 2001
> @@ -15,7 +15,7 @@
> * <email protected> string $CR_HTML Default is "\n"
> * <email protected> CR_JS
> */
> - var $CR_HTML = "\n";
> + var $CR_HTML = "";
>
> /**
> * Line break sign used whenever JavaScript code is generated
> Index: php-lib/php/form/form_xmlfactory.inc
> diff -u php-lib/php/form/form_xmlfactory.inc:1.8
php-lib/php/form/form_xmlfactory.inc:1.9
> --- php-lib/php/form/form_xmlfactory.inc:1.8 Sat May 19 22:50:46 2001
> +++ php-lib/php/form/form_xmlfactory.inc Sun May 20 16:05:31 2001
> @@ -527,13 +527,8 @@
> */
> function cdata($parser, $cdata) {
>
> - // WARNING
> - if ("" == trim($cdata))
> - return;
> + $data = trim($cdata);
>
> - // Hmm, do you know a better way?
> - $cdata = trim($cdata);
> -
> switch ($this->current_tag) {
>
> case "calendar":
> @@ -551,16 +546,45 @@
> case "text":
> case "textarea":
> case "textedit":
> - $this->attributes["value"] = (string)$cdata;
> + if ($data)
> + $this->attributes["value"] .= $data;
> break;
>
> case "image":
> - $this->attributes["src"] = (string)$cdata;
> - break;
> -
> + if ($data)
> + $this->attributes["src"] .= $data;
> + break;
> +
> + case "additionalhtml":
> + case "css":
> + case "day":
> + case "elements":
> + case "form":
> + case "html":
> + case "intro":
> + case "intros":
> + case "javascript":
> + case "length":
> + case "mode":
> + case "month":
> + case "nameprefix":
> + case "option":
> + case "options":
> + case "phpfunction":
> + case "preselect":
> + case "regexp":
> + case "validation":
> + case "year":
> + $this->cdata .= $data;
> + break;
> +
> + case "jsfunction":
> + default:
> + $this->cdata .= $cdata;
> + break;
> +
> }
>
> - $this->cdata = $cdata;
> } // end func cdata
>
>
> Index: php-lib/php/form/elements/form_element.inc
> diff -u php-lib/php/form/elements/form_element.inc:1.6
php-lib/php/form/elements/form_element.inc:1.7
> --- php-lib/php/form/elements/form_element.inc:1.6 Sat May 19 22:50:47
2001
> +++ php-lib/php/form/elements/form_element.inc Sun May 20 16:05:32 2001
> @@ -5,21 +5,23 @@
> * Superclass of all form elements.
> *
> * <email protected> Ulf Wendel <uw <email protected>>
> -* <email protected> $Id: form_element.inc,v 1.6 2001/05/19 20:50:47 uw Exp $
> +* <email protected> $Id: form_element.inc,v 1.7 2001/05/20 14:05:32 uw Exp $
> * <email protected> public
> * <email protected> Form
> * <email protected>
> */
> class form_element extends form_commonobject {
>
> - /**
> +
> + /**
> * <email protected> boolean $flag_config_ok
> * <email protected> public
> * <email protected> checkConfiguration()
> */
> var $flag_config_ok = true;
>
> - /**
> +
> + /**
> * Alias name of the element.
> *
> * Every element can have two names. One "name" used
> @@ -33,7 +35,8 @@
> */
> var $elname = "";
>
> - /**
> +
> + /**
> * HTML name attribute of the element.
> *
> * Make sure that the name of select multiple
> @@ -43,14 +46,16 @@
> */
> var $name = "";
>
> - /**
> +
> + /**
> * Value of the element.
> *
> * <email protected> mixed $value
> */
> var $value = "";
>
> - /**
> +
> + /**
> * Additional HTML attributes.
> *
> * The string will be added to the generated HTML without any validation.
> @@ -59,34 +64,39 @@
> */
> var $additional_html = "";
>
> - /**
> +
> + /**
> * Is the element frozen?
> *
> * <email protected> boolean $frozen
> */
> var $frozen = false;
>
> - /**
> +
> + /**
> * HTML/CSS class attribute.
> *
> * <email protected> string $class The default of an empty string means: don't print
that attribute.
> */
> var $class = "";
>
> - /**
> +
> + /**
> * HTML/CSS id attribute.
> *
> * <email protected> string $id The default of an empty string means: don't print that
attribute.
> */
> var $id = "";
>
> - /**
> +
> + /**
> * HTML/CSS style attribute
> *
> * <email protected> string $style The default of an empty string means: don't print
that attribute.
> */
> var $style = "";
>
> +
> /**
> * List of required fields every element needs and their type.
> *
> @@ -101,6 +111,7 @@
> "name" => "string"
> );
>
> +
> /**
> * List of required fields provided by a derived class.
> *
> @@ -109,6 +120,7 @@
> */
> var $required_fields = array();
>
> +
> /**
> * List of optional fields and their type.
> *
> @@ -123,9 +135,9 @@
> "elname" => "string",
> "additional_html" => "string",
>
> - "validator" => "string",
> - "validator_callback" =>
"boolean",
> - "js_validator" => "string",
> + "validator" => "string",
> + "validator_callback" =>
"boolean",
> + "js_validator" => "string",
>
> "frozen" => "boolean",
>
> @@ -134,6 +146,7 @@
> "style" => "string"
> );
>
> +
> /**
> * List of optional fields provided by a derived class.
> *
> @@ -142,12 +155,14 @@
> */
> var $optional_fields = array();
>
> +
> /**
> * Method (POST|GET) used in the form.
> *
> * <email protected> string
> */
> var $method = "";
> +
>
> /**
> * Check for ... errors.
> @@ -160,6 +175,7 @@
> "intro" => true
> );
>
> +
> /**
> * JavaScript validation mode.
> *
> @@ -169,6 +185,7 @@
> */
> var $js_mode = "";
>
> +
> /**
> * Name of the form that contains the element.
> *
> @@ -202,6 +219,7 @@
> */
> var $js_validator = "";
>
> +
> /**
> * Creates a new form element.
> *
> @@ -235,10 +253,10 @@
>
> if ("" != $js_mode)
> $js_mode = ("weak" == strtolower($js_mode)) ? "weak" : "strong";
> - $this->js_mode = $js_mode;
> - $this->form_name = $form_name;
> -
> - $this->method = strtoupper($method);
> +
> + $this->js_mode = $js_mode;
> + $this->form_name = $form_name;
> + $this->method = strtoupper($method);
>
> $this->setup();
>
> @@ -517,10 +535,10 @@
> function validateLength($value = "") {
>
> $value = ($value) ? $value : $this->value;
> +
> if ($this->doValidation("length") && (strlen($value) < $this->minlength
|| ($this->maxlength >= 0 && strlen($value) > $this->maxlength)))
> return $this->length_e . " ";
> return "";
> -
> } // end func validateLength
>
> /**
> @@ -538,7 +556,6 @@
> if ($this->doValidation("valid") && !preg_match($reg, ($value) ? $value
: $this->value))
> return $this->valid_e . " ";
> return "";
> -
> } // end func validateRegEx
>
> /**
> @@ -804,7 +821,7 @@
> * <email protected> array [JavaScript function code, JavaScript function name]
> */
> function getJSvalue() {
> - return array("", "");
> + return array('["", ""]', "");
> } // end func getJSvalue
>
> /**
> Index: php-lib/php/form/elements/form_element_date.inc
> diff -u php-lib/php/form/elements/form_element_date.inc:1.4
php-lib/php/form/elements/form_element_date.inc:1.5
> --- php-lib/php/form/elements/form_element_date.inc:1.4 Sat May 19
20:07:10 2001
> +++ php-lib/php/form/elements/form_element_date.inc Sun May 20 16:05:32
2001
> @@ -7,7 +7,7 @@
> * Use this meta element to make sure that the user enters a valid date.
> *
> * <email protected> Ulf Wendel <uw <email protected>>
> -* <email protected> $Id: form_element_date.inc,v 1.4 2001/05/19 18:07:10 uw Exp $
> +* <email protected> $Id: form_element_date.inc,v 1.5 2001/05/20 14:05:32 uw Exp $
> * <email protected> Form
> */
> class form_element_date extends form_element {
> @@ -424,22 +424,24 @@
> } // end func getJSonActivation
> */
>
> - function getJSvalue() {
> +function getJSvalue() {
>
> $js = 'function form_date(f, e) {
> - var v = n = "";
> + var v = s = n = "";
> var i = j = 0;
> with (document.forms[f])
> for ( ; i < length; i++) {
> n = elements[i].name;
> if (-1 != n.search(new RegExp(e + "_[aAdDFhHgGijlmnMswYyz]"))) {
> + if (!s)
> + s = n;
> with (elements[i])
> for (j = 0; j < options.length; j++)
> if (options[j].selected)
> v += options[j].value;
> }
> }
> - return v;
> + return [v, s];
> }';
>
> return array($js, "form_date");
> Index: php-lib/php/form/elements/form_element_radio.inc
> diff -u php-lib/php/form/elements/form_element_radio.inc:1.5
php-lib/php/form/elements/form_element_radio.inc:1.6
> --- php-lib/php/form/elements/form_element_radio.inc:1.5 Sat May 19
20:15:02 2001
> +++ php-lib/php/form/elements/form_element_radio.inc Sun May 20 16:05:33
2001
> @@ -5,7 +5,7 @@
> * Generation of radio elements, [input type="radio" value=""].
> *
> * <email protected> Ulf Wendel <uw <email protected>>
> -* <email protected> $Id: form_element_radio.inc,v 1.5 2001/05/19 18:15:02 uw Exp
$
> +* <email protected> $Id: form_element_radio.inc,v 1.6 2001/05/20 14:05:33 uw Exp
$
> * <email protected> public
> * <email protected> Form
> */
> @@ -62,8 +62,8 @@
> with (document.forms[f])
> for (var i = t = 0, t = elements[e]; i < t.length; i++)
> if (t[i].checked)
> - return t[i].value;
> - return "";
> + return [t[i].value, ""];
> + return ["", ""];
> }', "form_radio");
>
> } // end func getJSValue
> Index: php-lib/php/form/elements/form_element_select.inc
> diff -u php-lib/php/form/elements/form_element_select.inc:1.5
php-lib/php/form/elements/form_element_select.inc:1.6
> --- php-lib/php/form/elements/form_element_select.inc:1.5 Sat May 19
20:07:12 2001
> +++ php-lib/php/form/elements/form_element_select.inc Sun May 20 16:05:34
2001
> @@ -6,7 +6,7 @@
> *
> * <email protected> Ulf Wendel <uw <email protected>>
> * <email protected> Form
> -* <email protected> $Id: form_element_select.inc,v 1.5 2001/05/19 18:07:12 uw Exp
$
> +* <email protected> $Id: form_element_select.inc,v 1.6 2001/05/20 14:05:34 uw Exp
$
> */
> class form_element_select extends form_element_selectobject {
>
> @@ -64,8 +64,8 @@
> with (document.forms[f].elements[e])
> for (var i = o = 0, o = options; i < o.length; i++)
> if (o[i].selected)
> - return o[i].value;
> - return "";
> + return [o[i].value, ""];
> + return ["", ""];
> }', "form_select");
>
> } // end func getJSvalue
> Index: php-lib/php/form/js/form_js_complex.js
> diff -u php-lib/php/form/js/form_js_complex.js:1.1
php-lib/php/form/js/form_js_complex.js:1.2
> --- php-lib/php/form/js/form_js_complex.js:1.1 Thu May 10 18:16:26 2001
> +++ php-lib/php/form/js/form_js_complex.js Sun May 20 16:05:35 2001
> @@ -4,6 +4,7 @@
> this.gv = gv;
> this.val = val;
> this.err = [];
> + this.p = "{NAMEPREFIX}";
> };
> new form;
>
> @@ -22,7 +23,8 @@
> d = this.els;
> for (i = 0; i < d.length; i += 3) {
> el = this.els[i];
> - if (a.length && a[0].name != el)
> +
> + if (a.length && a[0] != this.p + el)
> continue;
>
> vd = d[i + 1];
> @@ -37,7 +39,7 @@
> c = vd[j];
> l = vl.length;
> j += 4;
> -
> +
> if ("l" == c && this.val_ev(el, "l") && (l < vd[j - 3] || (-1 != vd[j -
2] && l > vd[j - 2])))
> this.err[i] += vd[j - 1] + "\n";
>
> @@ -56,7 +58,7 @@
>
> if (m) {
> alert("{ERROR_MSG_PREFIX}" + m + "{ERROR_MSG_POSTFIX}");
> - document.forms[n].elements[f].focus();
> + document.forms[n].elements[this.p + f].focus();
> return false;
> }
> return true;
> @@ -67,8 +69,8 @@
> g = f.gv;
> for (i = 0; i < g.length; i+= 2)
> if (g[i] == el)
> - return eval(g[i +1] + "('" + f.name + "', '" + el + "');");
> - return [document.forms[f.name].elements[el].value, ""];
> + return eval(g[i +1] + "('" + f.name + "', '" + this.p + el + "');");
> + return [document.forms[f.name].elements[this.p + el].value, ""];
> };
>
> form.prototype.val_on = function (el, events) {
> Index: php-lib/php/form/js/form_js_simple.js
> diff -u php-lib/php/form/js/form_js_simple.js:1.3
php-lib/php/form/js/form_js_simple.js:1.4
> --- php-lib/php/form/js/form_js_simple.js:1.3 Sat May 19 20:15:02 2001
> +++ php-lib/php/form/js/form_js_simple.js Sun May 20 16:05:35 2001
> @@ -1,18 +1,19 @@
> function form(n, els) {
> this.name = n;
> - this.els = els
> + this.els = els;
> + this.p = "{NAMEPREFIX}";
> };
> new form;
>
> form.prototype.validate = function () {
>
> - var e = f = "";
> + var e = f = s = "";
> var i, el, vd, j, vl, c, l, a, d, n;
> n = this.name;
> d = this.els;
>
> for (i = 0; i < d.length; i += 2) {
> - el = d[i];
> + el = this.p + d[i];
>
> a = arguments;
> if (a.length && a[0] != el)
> @@ -27,8 +28,11 @@
> c = vd[j];
> j += 4;
>
> - if ("v" == c)
> + if ("v" == c) {
> eval("vl = " + vd[j - 3] + "('" + n + "', '" + el + "'); j -= 2;");
> + s = vl[1];
> + vl = vl[0];
> + }
>
> l = vl.length;
> if ("l" == c && (l < vd[j - 3] || (vd[j -2] >= 0 && l > vd[j - 2])))
> @@ -43,7 +47,7 @@
> }
>
> if (!f && e)
> - f = el;
> + f = (s) ? s : el;
> }
>
> if (e) {
>
>
>
> ---------------------------------------------------------------------
> To c, e-mail: phplib-dev-unsubscribe <email protected>
> For additional commands, e-mail: phplib-dev-help <email protected>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: Karthik Sethuraman: "[phplib-dev] Unsubscribe me please."
- Previous message: uw: "[phplib-dev] cvs commit"
- In reply to: uw: "[phplib-dev] cvs commit"
- Next in thread: Ulf Wendel: "Re: [phplib-dev] please unsubscribe"
- Reply: Ulf Wendel: "Re: [phplib-dev] please unsubscribe"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

