[phplib-dev] cvs commit From: uw (phplib-dev <email protected>)
Date: 05/08/00

From: uw
Date: Mon May 8 19:31:39 2000
Modified files:
      php-lib/php/form/assistant.inc
      php-lib/php/form/form.inc

Log message:
bugfixes - there's one known ugly bug in assistant.inc, don't use the
current version.

Index: php-lib/php/form/assistant.inc
diff -u php-lib/php/form/assistant.inc:1.9 php-lib/php/form/assistant.inc:1.10
--- php-lib/php/form/assistant.inc:1.9 Fri May 5 16:47:31 2000
+++ php-lib/php/form/assistant.inc Mon May 8 19:31:37 2000
@@ -323,6 +323,39 @@
                 return array($p_id => $this->page_values[$p_id]);
         } // end func getPageValues
         
+
+ // LEAB HACK
+ function getPageValuesWithTranslatedNames() {
+
+ $values_with_names = array();
+ $form_names = array();
+ $radio_elements = array();
+
+ reset($this->pages);
+ while (list($p_id, $data)=each($this->pages)) {
+ $obj = $data["object"];
+
+ if ($p_id!=$this->now)
+ $obj->restoreSessionHash($this->page_values[$p_id]);
+ $name_translation_list = $obj->getNameTranslationList();
+
+ while (list($form_elname, $data)=each($name_translation_list)) {
+
+ if (!isset($values_with_names[$p_id][$data["name"]])) {
+ $values_with_names[$p_id][$data["name"]] = $data["value"];
+
+ } else {
+ if (""!=$data["value"])
+ $values_with_names[$p_id][$data["name"]] = $data["value"];
+ }
+
+ }
+
+ }
+
+ return $values_with_names;
+ } // end func getPageValuesWithTranslatedNames
+
         /**
         * Set the label, name and comment text that belongs to the help button
         *  <email protected> array $data
@@ -751,7 +784,7 @@
         *  <email protected> private
         */
         function saveFormValues() {
- if (""==(string)$this->lastviewed || $this->lastviewed == $this->now)
+ if (""==(string)$this->lastviewed)
                         return;
 
                 $obj = $this->pages[$this->lastviewed]["object"];
Index: php-lib/php/form/form.inc
diff -u php-lib/php/form/form.inc:1.4 php-lib/php/form/form.inc:1.5
--- php-lib/php/form/form.inc:1.4 Wed Apr 26 15:44:57 2000
+++ php-lib/php/form/form.inc Mon May 8 19:31:38 2000
@@ -126,6 +126,21 @@
         */
         var $method="POST";
         
+
+ /**
+ * Is this checkbox checked
+ *  <email protected> boolean $checked
+
+ */
+ function isChecked($elname) {
+ if (!isset($this->elements[$elname])) {
+ $this->setError(46, "form->isChecked(), unknown element '$elname'");
+ return false;
+ }
+
+ $el =$this->elements[$elname];
+ return $el->isChecked();
+ } // end func isChecked
         /**
         * Set the JavaScript mode
         *  <email protected> $js_mode = "weak"
@@ -249,6 +264,7 @@
                 
                 return true;
         } // end func autoloadValues
+
         /**
         * Sets the values of elements
         * You'll need it to reload submitted values
@@ -263,11 +279,10 @@
                 }
 
                 $ok = true;
-
                 reset($values);
                 while (list($name, $value)=each($values))
                         if (isset($this->elements[$name])) {
-
+
                                 $el = $this->elements[$name];
                                 $el->setValue($value);
                                 $this->elements[$name] = $el;
@@ -330,7 +345,7 @@
                                         $this->elements[$name] = $el;
                                 }
                                 
- }
+ }
                         
                 return true;
         } // end func Validation
@@ -802,6 +817,39 @@
                 return $this->getValidationResult();
         } // end func validate
 
+ function getNameTranslationList($ellist) {
+
+ if (""==$ellist)
+ $ellist = $this->getElementNames();
+
+ if (!is_array($ellist))
+ $ellist = array( $ellist );
+
+ $names = array();
+
+ reset($ellist);
+ while (list($k, $name)=each($ellist)) {
+ if (isset($this->radio_elements[$name])) {
+
+ $names[$name] = array(
+ "name" => $this->radio_elements[$name],
+ "value" => $this->getValue($name)
+ );
+
+ } else if (isset($this->elements[$name])) {
+
+ $el = $this->elements[$name];
+ $names[$name] = array(
+ "name" => $el->getName(),
+ "value" => $el->getValue()
+ );
+
+ }
+ }
+
+ return $names;
+ } // end func getNameTranslationList
+
         function getElementnames() {
                 
                 $elements = array();
@@ -1023,7 +1071,7 @@
                 $this->defaultSize = (int)$size;
                 return true;
         } // end func setSize
-
+
         /**
         * Set the default maxlength, works with text and textarea elements
         *  <email protected> int $maxlength

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>