--- nfo/php/libs/com.newsblob.phphtmllib/form/FormContent.inc 2003/09/20 00:18:43 1.2
+++ nfo/php/libs/com.newsblob.phphtmllib/form/FormContent.inc 2004/05/06 16:27:22 1.3
@@ -2,7 +2,7 @@
/**
* This file contains the FormContent class.
*
- * $Id: FormContent.inc,v 1.2 2003/09/20 00:18:43 jonen Exp $
+ * $Id: FormContent.inc,v 1.3 2004/05/06 16:27:22 jonen Exp $
*
* @author Walter A. Boring IV
* @author Suren Markossian
@@ -182,6 +182,27 @@
*/
var $_stripslashes = FALSE;
+ /**
+ * Flag to mark this as having a
+ * File Form Element (child of FEFile)
+ */
+ var $_has_file_element = FALSE;
+
+ /**
+ * index names of all of the file
+ * form elements (if any).
+ */
+ var $_file_elements = array();
+
+
+ /**
+ * The onsubmit value for the form
+ * tag. FormElement childs can
+ * automatically add to this
+ * by implementing the
+ * form_tag_onsubmit() method
+ */
+ var $_form_on_submit = '';
function FormContent($width="100%", $cancel_action=NULL) {
@@ -256,7 +277,23 @@
function pre_confirm() {
return TRUE;
}
-
+
+ /**
+ * This is a 'hidden' version of pre_confirm
+ * to allow calling the form elements pre_confirm
+ * methods. This is needed for forms that have
+ * a confirmation requirement and has file inputs.
+ * If the file input FormElement doesn't save off
+ * the uploaded file, then the confirmation page
+ * will not get the file. apache may nuke the temp
+ * file in /tmp.
+ *
+ */
+ function _pre_confirm() {
+ foreach( $this->_file_elements as $name ) {
+ $this->_elements[$name]->_pre_confirm();
+ }
+ }
/**
@@ -309,24 +346,9 @@
*/
function build_confirm_table( &$table ) {
foreach( $this->_elements as $label => $element) {
- $c = container(_HTML_SPACE);
+ $c = container(_HTML_SPACE,_HTML_SPACE,
+ $element->get_value_text());
$c->set_collapse();
- $value = $element->get_value();
- if (is_array($value)) {
- $str = '';
- foreach($value as $item) {
- $str .= $element->get_value_text($item).",";
- }
- $str = substr($str,0,strlen($str)-1);
- $c->add( _HTML_SPACE, $str );
- } else {
- if (is_a($element, "FEPassword")) {
- $value = str_repeat('*', strlen($value));
- $c->add(_HTML_SPACE, $value);
- } else {
- $c->add(_HTML_SPACE, $element->get_value_text($value));
- }
- }
$div = html_div("", $element->get_label() );
$div->set_style("white-space:nowrap;");
$table->add_row( $div, $c);
@@ -390,7 +412,11 @@
* @return mixed
*/
function form_success() {
- return container($this->_action_message, html_br(2));
+ if ($this->_action_message != "") {
+ return container($this->_action_message, html_br(2));
+ } else {
+ return NULL;
+ }
}
/**
@@ -462,7 +488,17 @@
$element->set_stripslashes( $this->_stripslashes );
//in case the element needs it for js
$element->set_form_name( $this->_form_name );
- $this->_elements[$element->get_label_text()] = &$element;
+ $name = $element->get_label_text();
+ $this->_elements[$name] = &$element;
+
+ //do we have a File form element?
+ if (is_a($element, 'fefile')) {
+ $this->_has_file_element = TRUE;
+ $this->_file_elements[] = $name;
+ }
+ if ($element->_has_form_on_submit) {
+ $this->_form_on_submit .= $element->form_tag_onsubmit();
+ }
}
/**
@@ -486,7 +522,7 @@
*/
function element_label($label) {
$this->_test_element($label, "element_label");
- return $this->_elements[$label]->get_label();
+ return $this->_elements[$label]->get_label($this);
}
/**
@@ -576,6 +612,33 @@
return $this->_hidden_elements[$label]->get_value();
}
+ /**
+ * This method is a helper method to set the
+ * FormElement's tabindex.
+ *
+ * @param string - the form label
+ * @param int - the FormElement's tabindex
+ * @return none
+ */
+ function set_form_tabindex($label, $index) {
+ $this->_test_element($label, "set_form_tabindex");
+ $this->_elements[$label]->set_tabindex($index);
+ }
+
+ /**
+ * This method is a helper method to get the
+ * FormElement's tabindex.
+ *
+ * @param string - the form label
+ * @param int - the FormElement's tabindex
+ * @return the FormElement's current tabindex
+ */
+ function get_form_tabindex($label, $index) {
+ $this->_test_element($label, "set_form_tabindex");
+ return $this->_elements[$label]->get_tabindex();
+ }
+
+
/**
* This method is used to create a new error element
@@ -922,25 +985,6 @@
$cancel_button->set_style("vertical-align:middle");
return $cancel_button;
}
-
-
- /**
- * This returns the required field text
- * if there are any. otherwise it returns NULL
- *
- */
- function get_required_fields_text() {
- if ( count($this->required_fields) ) {
-
- $span = new SPANtag( array( "class" => "formlabel"),
- $this->_required_field_marker.
- $this->required_field_text, FALSE );
-
- return $span;
- } else {
- return " ";
- }
- }
/**
* This function is used to set the required field marker