Date: 12/19/00
- Next message: uw: "[phplib-dev] cvs commit"
- Previous message: Holger Bahr: "[phplib-dev] another Template Class"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: sbergmann: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
From: uw
Date: Tue Dec 19 11:39:53 2000
Modified files:
php-lib/php/form/form.inc
php-lib/php/form/form_baseobject.inc
php-lib/php/form/form_element_date.inc
php-lib/php/form/panemanager.inc
Log message:
some cleanup
Index: php-lib/php/form/form.inc
diff -u php-lib/php/form/form.inc:1.13 php-lib/php/form/form.inc:1.14
--- php-lib/php/form/form.inc:1.13 Wed Dec 13 15:13:53 2000
+++ php-lib/php/form/form.inc Tue Dec 19 11:39:49 2000
@@ -3,7 +3,7 @@
* Public methods of the form class.
*
* <email protected> Ulf Wendel <ulf.wendel <email protected>>
-* <email protected> $Id: form.inc,v 1.13 2000/12/13 14:13:53 uw Exp $
+* <email protected> $Id: form.inc,v 1.14 2000/12/19 10:39:49 uw Exp $
* <email protected> Form
*/
class form extends form_copiedapi {
@@ -30,6 +30,24 @@
} // end func setMethod
/**
+ * Sets a global Prefix for element names.
+ *
+ * <email protected> string
+ * <email protected> boolean
+ * <email protected> $element_prefix
+ */
+ function setElementnamePrefix($prefix) {
+ if ("" == $prefix) {
+ $this->exeptions[] = new form_error("No prefix given", __FILE__, __LINE__);
+ return false;
+ }
+
+ $this->element_prefix = $prefix;
+ return true;
+ } // end func setElementnamePrefix
+
+
+ /**
* Loads the form with HTTP_[POST|GET]_VARS
*
* <email protected> array $ellist
@@ -61,7 +79,7 @@
foreach ($ellist as $k => $name) {
- $http_x_name = $this->elements[$name]->name;
+ $http_x_name = $this->element_prefix . $this->elements[$name]->name;
if ("]" == substr($http_x_name, -1) && $start = strpos($http_x_name, "[")) {
@@ -362,6 +380,9 @@
return false;
}
+ if (isset($element_data["name"]) && "" != $element_data["name"])
+ $element_data["name"] = $this->element_prefix . $element_data["name"];
+
$element_data["type"] = strtolower($element_data["type"]);
$objectname = $element_data["type"];
Index: php-lib/php/form/form_baseobject.inc
diff -u php-lib/php/form/form_baseobject.inc:1.5 php-lib/php/form/form_baseobject.inc:1.6
--- php-lib/php/form/form_baseobject.inc:1.5 Tue Dec 12 02:37:32 2000
+++ php-lib/php/form/form_baseobject.inc Tue Dec 19 11:39:50 2000
@@ -4,12 +4,13 @@
*
* <email protected> Ulf Wendel <ulf.wendel <email protected>>
* <email protected> Form
-* <email protected> $Id: form_baseobject.inc,v 1.5 2000/12/12 01:37:32 uw Exp $
+* <email protected> $Id: form_baseobject.inc,v 1.6 2000/12/19 10:39:50 uw Exp $
*/
class form_baseobject extends form_commonobject {
/**
- * Some default values
+ * Some default values.
+ *
* <email protected> array $defaults
* <email protected> defaults
*/
@@ -36,17 +37,32 @@
/**
* Array of all elements.
+ *
* <email protected> $elements array
*/
var $elements = array();
/**
* List of all element names.
+ *
+ * <email protected> array
*/
var $element_names = array();
/**
+ * Global element name prefix.
+ *
+ * In multipage forms a global element name prefix can be
+ * used to avoid name clashes.
+ *
+ * <email protected> string
+ * <email protected> setElementnamePrefix()
+ */
+ var $element_prefix = "";
+
+ /**
* Results of the last validation.
+ *
* <email protected> array $validation_flags $validation_flags[ $name ] = $message
* <email protected> validate(), setValidationError(), getValidationResult(), $validation_msg
*/
@@ -54,6 +70,7 @@
/**
* String with all error messages.
+ *
* <email protected> string $validation_msg
* <email protected> validate(), setValidationError(), getValidationResult(), $validation_flags
*/
Index: php-lib/php/form/form_element_date.inc
diff -u php-lib/php/form/form_element_date.inc:1.4 php-lib/php/form/form_element_date.inc:1.5
--- php-lib/php/form/form_element_date.inc:1.4 Tue Dec 12 01:25:13 2000
+++ php-lib/php/form/form_element_date.inc Tue Dec 19 11:39:51 2000
@@ -119,7 +119,7 @@
} // end func setup
/**
- * FIXME
+ * FIXME - EVEN MORE FIXME: element_prefix
* Returns the selected value.
*
* The date selector consists of several select boxes.
Index: php-lib/php/form/panemanager.inc
diff -u php-lib/php/form/panemanager.inc:1.2 php-lib/php/form/panemanager.inc:1.3
--- php-lib/php/form/panemanager.inc:1.2 Tue Jun 20 08:40:12 2000
+++ php-lib/php/form/panemanager.inc Tue Dec 19 11:39:51 2000
@@ -3,7 +3,7 @@
* Base class of Assistant and TabbedPane. This class holds some functions to
* render buttons and to care on persistant data
* <email protected> Ulf Wendel <ulf <email protected>>
-* <email protected> 0.1alpha
+* <email protected> $Id: panemanager.inc,v 1.3 2000/12/19 10:39:51 uw Exp $
*/
class panemanager extends form_commonobject {
@@ -101,60 +101,64 @@
/**
* Use this method to provide the structure of the assistant
- * The method gets called by the constructor
+ *
+ * The method gets called by the constructor.
+ *
* <email protected> void
* <email protected> void
* <email protected> public
*/
function Init() {
- die();
+ $this->exceptions[] = new FormError("Call to abstract method", __FILE__, __LINE__);
} // end func Init()
/**
* Restores the Assistant. Load the pages with values, sets validation flags etc.
- * <email protected> private
+ *
+ * <email protected> private
+ * <email protected>
*/
function restoreAssistant() {
- die();
+ $this->exceptions[] = new FormError("Call to abstract method", __FILE__, __LINE__);
} // end func restoreAssistant
/**
- * return the current page
- * <email protected> string $html
- * <email protected> runtime
- * <email protected> public
- * <email protected> show()
+ * Returns the current page
+ *
+ * <email protected> string $html
+ * <email protected> public
+ * <email protected> show()
+ * <email protected>
*/
function get() {
- die();
+ $this->exceptions[] = new FormError("Call to abstract method", __FILE__, __LINE__);
} // end func get
- function isError($obj) {
- die();
- } // end func isError
-
/**
* Adds a page to the assistant / tabbed pane
+ *
+ * <email protected>
*/
function addPage() {
- die();
+ $this->exceptions[] = new FormError("Call to abstract method", __FILE__, __LINE__);
} // end func addPage
/*
* 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> Runtime
+ * <email protected> FormError
* <email protected> public
* <email protected> isValid()
*/
- function getPageValues($page_name="") {
- if (""==$page_name)
+ function getPageValues($page_name = "") {
+ if ("" == $page_name)
return $this->page_values;
$p_id = $this->PageNametoPageID($page_name);
if (-1 == $p_id) {
- $this->error = new exception_runtime("getPageValues(), unknown page '$page_name'", 60, __FILE__, __LINE__);
+ $this->exceptions[] = new FormError("getPageValues(), unknown page '$page_name'",__FILE__, __LINE__);
return array();
}
return array($p_id => $this->page_values[$p_id]);
@@ -182,7 +186,7 @@
$values_with_names[$p_id][$data["name"]] = $data["value"];
} else {
- if (""!=$data["value"])
+ if ("" != $data["value"])
$values_with_names[$p_id][$data["name"]] = $data["value"];
}
@@ -195,6 +199,7 @@
/**
* print, generate and return the current page
+ *
* <email protected> string $html
* <email protected> public
* <email protected> get()
@@ -204,37 +209,39 @@
print $html;
return $html;
} // end func show()
+
/**
- * return a reset button
+ * Returns a HTML reset button
* <email protected> string $label
* <email protected> string $hmtl
- * <email protected> Runtime
+ * <email protected> FormError
* <email protected> private
*/
function getResetButton($label) {
- if (""==(string)$label) {
- $this->error = new exception_runtime("getResetButton(), illegal function call", 16, __FILE__, __LINE__);
+ if (""== (string)$label) {
+ $this->exceptions[] = new FormError("getResetButton(), illegal function call", __FILE__, __LINE__);
return "";
}
return sprintf('<input type="reset" value="%s">', $label);
} // end getResetButton
/**
- * return a submit button
+ * Returns a submit button.
+ *
* <email protected> string $label
* <email protected> string $value
* <email protected> string $name
* <email protected> string $html
* <email protected> private
*/
- function getButton($label, $value, $name="") {
- if (""==(string)$label || (""==(string)$value && ""==(string)$name)) {
- $this->setError(15, "assistent -> getButton(), illegal function call");
+ function getButton($label, $value, $name = "") {
+ if ("" == (string)$label || ("" == (string)$value && "" == (string)$name)) {
+ $this->exceptions[] = new FormError("assistent -> getButton(), illegal function call", __FILE__, __LINE__);
return "";
}
- if (""==$name)
- $name = sprintf("%s_%d", $this->buttonname, $value);
+ if ("" == $name)
+ $name = sprintf("%s_%d_%d", $this->buttonname, $this->now, $value);
$html = sprintf('<input type="submit" value="%s" name="%s">',
$label,
@@ -244,7 +251,8 @@
} // end func getButton
/**
- * Generate a tab.
+ * Generates a tab.
+ *
* <email protected> string $label
* <email protected> bool $optional
* <email protected> bool $noerror
@@ -253,9 +261,10 @@
*/
function getTab($label, $value, $optional, $noerror) {
- $html = sprintf('<input type="submit" value="%s" name="%s_%d">',
+ $html = sprintf('<input type="submit" value="%s" name="%s_%d_%d">',
$label,
$this->buttonname,
+ $this->now,
$value
);
if ($noerror)
@@ -274,13 +283,13 @@
* <email protected> bool $ok
* <email protected> isHelpPressed(), isExitPressed(), isFinishPressed()
* <email protected> private
- * <email protected> Runtime
+ * <email protected> FormError
*/
function issetHTTPXVAR($varname) {
global $HTTP_POST_VARS, $HTTP_GET_VARS;
- if(""==$varname) {
- $this->error = new exception_runtime("issetHTTPXVars(), no varname given.", 69, __FILE__, __LINE__);
+ if("" == $varname) {
+ $this->exceptions = new FormError("issetHTTPXVars(), no varname given.", __FILE__, __LINE__);
return false;
}
@@ -295,23 +304,24 @@
break;
default:
- $this->error = new exception_runtime("issetHTTPXVAR(), unknown form method", 65, __FILE__, __LINE__);
+ $this->exceptions[] = new form_error("issetHTTPXVAR(), unknown form method", __FILE__, __LINE__);
$ok = false;
break;
}
return $ok;
} // end func issetHTTPXVAR
+
/**
* Is the Button "Finish" pressed?
* <email protected> bool $ok
- * <email protected> isExitPressed(), isHelpPressed
+ * <email protected> isExitPressed(), isHelpPressed()
* <email protected> public
- * <email protected> Runtime
+ * <email protected> FormError
*/
function isFinishPressed() {
if (!isset($this->finish_button["name"])) {
- $this->error = new exception_runtime("isFinishPressed(), there's no finish button defined", 66, __FILE__, __LINE__);
+ $this->exceptions[] = new FormError("isFinishPressed(), there's no finish button defined", __FILE__, __LINE__);
return false;
}
@@ -323,11 +333,11 @@
* <email protected> bool $ok
* <email protected> isFinishPressed(), isHelpPressed()
* <email protected> public
- * <email protected> Runtime
+ * <email protected> FormError
*/
function isExitPressed() {
if (!isset($this->exit["name"])) {
- $this->error = new exception_runtime("isExitPressed(), there's no exit button defined", 67, __FILE__, __LINE__);
+ $this->exceptions[] = new FormError("isExitPressed(), there's no exit button defined", __FILE__, __LINE__);
return false;
}
return $this->issetHTTPXVARS($this->exit["name"]);
@@ -336,13 +346,13 @@
/**
* Is the Button "Help" pressed?
* <email protected> bool $ok
- * <email protected> Runtime
+ * <email protected> FormError
* <email protected> isFinishPressed(), isExitPressed()
* <email protected> public
*/
function isHelpPressed() {
if (!isset($this->help["name"])) {
- $this->error = new exception_runtime("isHelpPressed(), there's no help button defined", 68, __FILE__, __LINE__);
+ $this->exceptions[] = new FormError("isHelpPressed(), there's no help button defined", 68, __FILE__, __LINE__);
return false;
}
return $this->issetHTTPXVARS($this->help["name"]);
@@ -352,13 +362,13 @@
* Set the label, name and comment text that belongs to the help button
* <email protected> array $data
* <email protected> bool $ok
- * <email protected> Runtime_WrongParam
+ * <email protected> FormError
* <email protected> public
* <email protected> setExitButton()
*/
function setHelp($data) {
if (!is_array($data)) {
- $this->error = new exception_runtime_wrongparam("setHelp(), illegal function call", 19, __FILE__, __LINE__);
+ $this->exceptions[] = new FormError("setHelp(), illegal function call", __FILE__, __LINE__);
return false;
}
$this->help = array (
@@ -373,17 +383,18 @@
* Set the laben and the name of the exit button
* <email protected> string $label
* <email protected> string $name
- * <email protected> Runtime_WrongParam
+ * <email protected> FormError
* <email protected> public
* <email protected> setHelp()
*/
function setExitButton($label, $name) {
- global $PHP_SELF
- if (""==$name || ""==$label) {
- $this->error = new exception_runtime_wrongparam("setExitButton(), illegal function call", 18, __FILE__, __LINE__);
+ global $PHP_SELF;
+
+ if ("" == $name || "" == $label) {
+ $this->exceptions[] = new FormError("setExitButton(), illegal function call", __FILE__, __LINE__);
return false;
}
- if (""==$action)
+ if ("" == $action)
$action = $PHP_SELF;
$this->exit = array (
@@ -394,19 +405,20 @@
} // end func setExitButton
/**
- * Sets the label and name of a button that allows to exit the assistant
- * as soon as all forms are valid
+ * Sets the label and name of a button that allows to exit the assistant as soon as all forms are valid.
+ *
* <email protected> string $name
* <email protected> string $label
* <email protected> bool $ok
- * <email protected> Runtime_WrongParam
- * <email protected> finish
+ * <email protected> FormError
+ * <email protected> $finish
*/
function setFinishButton($label, $name) {
- if (""==$name || ""==$label ) {
- $this->error = new exception_runtime_wrongparam("setFinishButton(), illegal function call", 17, __FILE__, __LINE__);
+ if ("" == $name || "" == $label ) {
+ $this->exceptions[] = new FormError("setFinishButton(), illegal function call", __FILE__, __LINE__);
return false;
}
+
$this->finish_button = array (
"name" => $name,
"label" => $label
@@ -416,26 +428,27 @@
/**
* Generate tabs?
+ *
* <email protected> bool $ok
* <email protected> public
* <email protected> show_tabs
*/
- function showTabs($ok=true) {
- if (true!=$ok)
- $ok = false;
- $this->show_tabs = $ok;
+ function showTabs($ok = true) {
+ $this->show_tabs = ($ok) ? true : false;
} // end func showTabs
/**
- * Sets the opening form tag
+ * Sets the opening form tag.
+ *
* <email protected> string $html
* <email protected> string $method
* <email protected> bool $ok
* <email protected> public
- * <email protected> getStart(), Start(), form_start
+ * <email protected> FormError
+ * <email protected> getStart(), Start(), $form_start
*/
- function setStart($html, $method="POST") {
- if (""==$html) {
+ function setStart($html, $method = "POST") {
+ if ("" == $html) {
$this->setError(13, "assistant -> setStart(), illegal function call");
return false;
}
@@ -444,16 +457,12 @@
return false;
} // end func setStart
- function setMethod($method="POST") {
- if ("POST"!=strtoupper($method))
+ function setMethod($method = "POST") {
+ if ("POST" != strtoupper($method))
$method = "GET";
- reset($this->pages);
- while (list($p_id, $data)=each($this->pages)) {
- $obj = $data["object"];
- $obj->setMethod($method);
- $this->pages[$p_id]["object"] = $obj;
- }
+ foreach ($this->pages as $p_id => $data)
+ $this->pages[$p_id]["object"]->setMethod($method);
$this->method = $method;
} // end fun setMethod
@@ -469,36 +478,34 @@
* <email protected> public
* <email protected> setStart(), getStart()
*/
- function getStart($js_name="", $method="POST", $action="", $target="", $form_name="") {
+ function getStart($js_name = "", $method = "POST", $action = "", $target = "", $form_name = "") {
global $PHP_SELF;
$html = "";
- $html.= sprintf('<form action="%s" target="%s" ',
- (""==$action) ? $PHP_SELF : $action,
- (""==$target) ? "_self" : $target
+ $html .= sprintf('<form action="%s" target="%s" ',
+ ("" == $action) ? $PHP_SELF : $action,
+ ("" == $target) ? "_self" : $target
);
- $method = ("GET"==strtoupper($method)) ? "GET" : "POST";
+ $method = ("GET" == strtoupper($method)) ? "GET" : "POST";
if ($this->flag_file) {
- $html.= 'enctype="multipart/form-data" ';
+ $html .= 'enctype="multipart/form-data" ';
$method = "POST";
}
+
$html.= sprintf('method="%s" ', $method );
$this->setMethod($method);
- if (""!=$js_name) {
+ if ("" != $js_name) {
$this->js_name = $js_name;
- $html.= sprintf('name="%s" onSubmit="return %s_Validator(this, \'\')" ',
+ $html .= sprintf('name="%s" onSubmit="return %s_Validator(this, \'\')" ',
$js_name,
$js_name
);
}
- $html = substr($html, 0, -1);
- $html.=">".$this->CR_HTML;
-
- return $html;
+ return substr($html, 0, -1) . ">" . $this->CR_HTML;
} // end fun getStart
@@ -513,7 +520,7 @@
* <email protected> public
* <email protected> getStart(), setStart()
*/
- function Start($js_name="", $method="POST", $action="", $target="", $form_name="") {
+ function Start($js_name = "", $method = "POST", $action = "", $target = "", $form_name = "") {
$this->form_start = $this->getStart($js_name, $method, $action, $target, $form_name);
} // end func Start
@@ -525,8 +532,8 @@
* <email protected> getFinish(), Finish(), form_end
*/
function setFinish($html) {
- if (""==$html) {
- $this->setError(13, "assistant -> setFinish(), illegal function call");
+ if ("" == $html) {
+ $this->exceptions[] = new FormError("assistant -> setFinish(), illegal function call", __FILE__, __LINE__);
return false;
}
$this->form_end = $html;
@@ -540,8 +547,8 @@
* <email protected> public
* <email protected> setFinish(), Finish(), form_end
*/
- function getFinish($additional_html="") {
- return "</form>".$additional_html;
+ function getFinish($additional_html = "") {
+ return "</form>" . $additional_html;
}
/**
@@ -551,8 +558,8 @@
* <email protected> public
* <email protected> setFinish(), getFinish(), form_end
*/
- function Finish($additional_html="") {
- $this->form_end = $this->getFinish($additional_html="");
+ function Finish($additional_html = "") {
+ $this->form_end = $this->getFinish($additional_html = "");
} // end func Finish()
} // end class panemanager
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-dev-unsubscribe <email protected>
For additional commands, e-mail: phplib-dev-help <email protected>
- Next message: uw: "[phplib-dev] cvs commit"
- Previous message: Holger Bahr: "[phplib-dev] another Template Class"
- Next in thread: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: uw: "[phplib-dev] cvs commit"
- Maybe reply: sbergmann: "[phplib-dev] cvs commit"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

