182 |
*/ |
*/ |
183 |
var $_stripslashes = FALSE; |
var $_stripslashes = FALSE; |
184 |
|
|
185 |
|
/** |
186 |
|
* Flag to mark this as having a |
187 |
|
* File Form Element (child of FEFile) |
188 |
|
*/ |
189 |
|
var $_has_file_element = FALSE; |
190 |
|
|
191 |
|
/** |
192 |
|
* index names of all of the file |
193 |
|
* form elements (if any). |
194 |
|
*/ |
195 |
|
var $_file_elements = array(); |
196 |
|
|
197 |
|
|
198 |
|
/** |
199 |
|
* The onsubmit value for the form |
200 |
|
* tag. FormElement childs can |
201 |
|
* automatically add to this |
202 |
|
* by implementing the |
203 |
|
* form_tag_onsubmit() method |
204 |
|
*/ |
205 |
|
var $_form_on_submit = ''; |
206 |
|
|
207 |
|
|
208 |
function FormContent($width="100%", $cancel_action=NULL) { |
function FormContent($width="100%", $cancel_action=NULL) { |
277 |
function pre_confirm() { |
function pre_confirm() { |
278 |
return TRUE; |
return TRUE; |
279 |
} |
} |
280 |
|
|
281 |
|
/** |
282 |
|
* This is a 'hidden' version of pre_confirm |
283 |
|
* to allow calling the form elements pre_confirm |
284 |
|
* methods. This is needed for forms that have |
285 |
|
* a confirmation requirement and has file inputs. |
286 |
|
* If the file input FormElement doesn't save off |
287 |
|
* the uploaded file, then the confirmation page |
288 |
|
* will not get the file. apache may nuke the temp |
289 |
|
* file in /tmp. |
290 |
|
* |
291 |
|
*/ |
292 |
|
function _pre_confirm() { |
293 |
|
foreach( $this->_file_elements as $name ) { |
294 |
|
$this->_elements[$name]->_pre_confirm(); |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
|
|
299 |
/** |
/** |
346 |
*/ |
*/ |
347 |
function build_confirm_table( &$table ) { |
function build_confirm_table( &$table ) { |
348 |
foreach( $this->_elements as $label => $element) { |
foreach( $this->_elements as $label => $element) { |
349 |
$c = container(_HTML_SPACE); |
$c = container(_HTML_SPACE,_HTML_SPACE, |
350 |
|
$element->get_value_text()); |
351 |
$c->set_collapse(); |
$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)); |
|
|
} |
|
|
} |
|
352 |
$div = html_div("", $element->get_label() ); |
$div = html_div("", $element->get_label() ); |
353 |
$div->set_style("white-space:nowrap;"); |
$div->set_style("white-space:nowrap;"); |
354 |
$table->add_row( $div, $c); |
$table->add_row( $div, $c); |
412 |
* @return mixed |
* @return mixed |
413 |
*/ |
*/ |
414 |
function form_success() { |
function form_success() { |
415 |
return container($this->_action_message, html_br(2)); |
if ($this->_action_message != "") { |
416 |
|
return container($this->_action_message, html_br(2)); |
417 |
|
} else { |
418 |
|
return NULL; |
419 |
|
} |
420 |
} |
} |
421 |
|
|
422 |
/** |
/** |
488 |
$element->set_stripslashes( $this->_stripslashes ); |
$element->set_stripslashes( $this->_stripslashes ); |
489 |
//in case the element needs it for js |
//in case the element needs it for js |
490 |
$element->set_form_name( $this->_form_name ); |
$element->set_form_name( $this->_form_name ); |
491 |
$this->_elements[$element->get_label_text()] = &$element; |
$name = $element->get_label_text(); |
492 |
|
$this->_elements[$name] = &$element; |
493 |
|
|
494 |
|
//do we have a File form element? |
495 |
|
if (is_a($element, 'fefile')) { |
496 |
|
$this->_has_file_element = TRUE; |
497 |
|
$this->_file_elements[] = $name; |
498 |
|
} |
499 |
|
if ($element->_has_form_on_submit) { |
500 |
|
$this->_form_on_submit .= $element->form_tag_onsubmit(); |
501 |
|
} |
502 |
} |
} |
503 |
|
|
504 |
/** |
/** |
522 |
*/ |
*/ |
523 |
function element_label($label) { |
function element_label($label) { |
524 |
$this->_test_element($label, "element_label"); |
$this->_test_element($label, "element_label"); |
525 |
return $this->_elements[$label]->get_label(); |
return $this->_elements[$label]->get_label($this); |
526 |
} |
} |
527 |
|
|
528 |
/** |
/** |
612 |
return $this->_hidden_elements[$label]->get_value(); |
return $this->_hidden_elements[$label]->get_value(); |
613 |
} |
} |
614 |
|
|
615 |
|
/** |
616 |
|
* This method is a helper method to set the |
617 |
|
* FormElement's tabindex. |
618 |
|
* |
619 |
|
* @param string - the form label |
620 |
|
* @param int - the FormElement's tabindex |
621 |
|
* @return none |
622 |
|
*/ |
623 |
|
function set_form_tabindex($label, $index) { |
624 |
|
$this->_test_element($label, "set_form_tabindex"); |
625 |
|
$this->_elements[$label]->set_tabindex($index); |
626 |
|
} |
627 |
|
|
628 |
|
/** |
629 |
|
* This method is a helper method to get the |
630 |
|
* FormElement's tabindex. |
631 |
|
* |
632 |
|
* @param string - the form label |
633 |
|
* @param int - the FormElement's tabindex |
634 |
|
* @return the FormElement's current tabindex |
635 |
|
*/ |
636 |
|
function get_form_tabindex($label, $index) { |
637 |
|
$this->_test_element($label, "set_form_tabindex"); |
638 |
|
return $this->_elements[$label]->get_tabindex(); |
639 |
|
} |
640 |
|
|
641 |
|
|
642 |
|
|
643 |
/** |
/** |
644 |
* This method is used to create a new error element |
* This method is used to create a new error element |
985 |
$cancel_button->set_style("vertical-align:middle"); |
$cancel_button->set_style("vertical-align:middle"); |
986 |
return $cancel_button; |
return $cancel_button; |
987 |
} |
} |
|
|
|
|
|
|
|
/** |
|
|
* 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 " "; |
|
|
} |
|
|
} |
|
988 |
|
|
989 |
/** |
/** |
990 |
* This function is used to set the required field marker |
* This function is used to set the required field marker |