Date: 04/28/00
- Next message: Leif Jakob: "[phplib-dev] Bug in db/mysql/db_sql.inc table_names() - patch included"
- Previous message: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: uw
Date: Fri Apr 28 16:50:13 2000
Modified files:
php-lib/php/form/assistant.inc
Log message:
- added some new functions currentPageID(), currentPageName()
- improved some functions isValid(page), getPageValues(page)
Index: php-lib/php/form/assistant.inc
diff -u php-lib/php/form/assistant.inc:1.6 php-lib/php/form/assistant.inc:1.7
--- php-lib/php/form/assistant.inc:1.6 Fri Apr 28 13:14:18 2000
+++ php-lib/php/form/assistant.inc Fri Apr 28 16:49:42 2000
@@ -13,7 +13,7 @@
$this->saveFormValues();
$this->setPageErrors();
$this->findPosition();
- #$this->loadFormValues();
+ $this->loadFormValues();
} // end func restoreAssistant
@@ -49,7 +49,7 @@
* <email protected> string $now
* <email protected> private
*/
- var $now = 0;
+ var $now = -1;
/**
* Opening form tag
@@ -225,12 +225,22 @@
} // end func Init()
/*
- * Return the session hash with all values
- * <email protected> array $page_values
- * <email protected> public
- */
- function getPageValues() {
- return $this->page_values;
+ * Return the session hash with values of one page or all pages.
+ * <email protected> string $page_name = "", "" means return all pages
+ * <email protected> array $page_values
+ * <email protected> public
+ * <email protected> isValid()
+ */
+ function getPageValues($page_name="") {
+ if (""==$page_name)
+ return $this->page_values;
+
+ $p_id = $this->PageNametoPageID($page_name);
+ if (-1 == $p_id) {
+ $this->setError(60, "assistant -> getPageValues(), unknown page '$page_name'");
+ return array();
+ }
+ return array($p_id => $this->page_values[$p_id]);
} // end func getPageValues
/**
@@ -673,29 +683,94 @@
* <email protected> private
*/
function loadFormValues() {
- if ($this->lastviewed == $this->now)
+ if ($this->lastviewed == $this->now || !isset($this->page_values[$this->now]))
return;
-
+
$obj = $this->pages[$this->now]["object"];
- $obj->restoreSessionHash($this->page_values[$this->lastviewed]);
+ $obj->restoreSessionHash($this->page_values[$this->now]);
$this->pages[$this->now]["object"] = $obj;
} // end func loadFormValues()
+ /**
+ * Return the name of the current page
+ * <email protected> string $page_name
+ * <email protected> public
+ * <email protected> isValid(), currentPageID()
+ */
+ function currentPageName() {
+ if (!isset($this->pages[$this->now]["name"]))
+ return "";
+ return $this->pages[$this->now]["name"];
+ } // end func currentPageName
+
+ /**
+ * Returns the ID of the current page. The first page defined with
+ * addPage() call gets the ID 0, the second 1 and so on.
+ * If a negative number is returned the help or exit button is pressed.
+ * <email protected> int $page_id
+ * <email protected> public
+ * <email protected> isValid(), currentPageName()s
+ */
+ function currentPageID() {
+ return $this->now;
+ } // end func currentPageID
+
/**
- * Are all pages valid?
+ * Returns the page_id (page__values/page_errors index) of a
+ * page name.
+ * <email protected> string $page_name
+ * <email protected> int $page_id, if -1 the page was not found
+ * <email protected> private
+ * <email protected> isValid(), getPageValues()
+ */
+ function PageNametoPageID($page_name) {
+ if (""==$page_name) {
+ $this->setError(47, "assistant -> PageNametoPageID(), illegal function call");
+ return -1;
+ }
+
+ $found = -1;
+ reset($this->pages);
+ while (list($p_id, $page)=each($this->pages))
+ if ($page_name == $page["name"]) {
+ $found = $p_id;
+ break;
+ }
+
+ return $found;
+ } // end func PageNametoPageID
+
+ /**
+ * Are all pages valid, is the requested page valid?
+ * <email protected> string $page = "", if empty test all
* <email protected> boolean $ok
* <email protected> public
*/
- function isValid() {
+ function isValid($page="") {
if (0==count($this->pages)) {
$this->setError(12, "assistant -> isValid(), no pages in assistant");
return false;
}
- reset($this->page_errors);
- while (list($p_id, $valid)=each($this->page_errors))
- if (!$valid)
+
+ if (""!=$page) {
+
+ $p_id = $this->PageNametoPageID($page);
+ if (-1==$p_id) {
+ $this->setError(48, "assistant -> isValid(), unknown page '$page'");
return false;
- return true;
+ }
+
+ if (isset($this->page_errors[$p_id]))
+ return $this->page_errors[$p_id];
+ return false;
+
+ } else {
+ reset($this->page_errors);
+ while (list($p_id, $valid)=each($this->page_errors))
+ if (!$valid)
+ return false;
+ return true;
+ }
} // end func isValid
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: Leif Jakob: "[phplib-dev] Bug in db/mysql/db_sql.inc table_names() - patch included"
- Previous message: uw: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

