Packageindex Classtrees Modulegroups Elementlist Report XML Files

pxdb.content.input

pxdb_input

pxdb_data
   |
  +-- pxdb_confront
     |
    +-- pxdb_input

public class pxdb_input extends pxdb_confront

This class displays an input form for entering data into a datatype or a "view" (subset of a datatype, with customized labels). This class uses Smarty templates to format the display of the form. It also reads in the global variable (default: $pxdb) to gather any validation errors that were added by the pxdb_commit class. All fields are displayed according to the privileges defined in the field_priv table. Additionally, fields may be hidden or locked (made read-only) by the hide_field() and lock_field() methods, but fields hidden or locked by insufficient privileges may not be revelaed or made writable. You may also disable auto-generation (i.e. make auto-generated fields editable) on a field-by-field basis or on a global basis using the disable_autogen() method.

Authors
Version$Revision: 1.16 $

 

Methods inherited from pxdb_confront

pxdb_confront, _get_form_element_name, _invoke_user_method, _import_uploaded_files, bind_validator

Methods inherited from pxdb_data

pxdb_data, set_show_unapproved, get_datatype, get_datatype_list, get_datatype_array, set_datatype, bind_tpl, bind_auth, lookup_colname, lookup_tfid, get_column_identifiers, get_identifiers, set_user_minimal_columns, sql_minimal_columns, sql_aliased_columns

Public Method Summary

void pxdb_input(integer $dt, [ integer $record_id ])
Constructor
void read()
Updates class vars from the database.
void import([ array $source ])
Imports variables and uploaded files from global scope.Warning: documentation is missing.
void bind_widgets(object pxdb_widgets &$widgets)
Specifies the widget class that this class should use.
void set_auth_required([ boolean $bit ])
Set whether authentication is required.
void set_field_default(string $field, mixed $value)
Sets a default value for a field.
void set_field_options(string $field, array $options)
Sets the pick options for a picklist (primaryrel or pickid type).
array get_view(string $view_name)
Gets the fields for a given view. WARNING: set any default values
array get_fields()
Get all (or a specific subset of) the fields for this datatype.
array _get_fields(array $tf_rows)
Builds a multidimensional array of all the fiels in this pxdb object.
string pass_current_vars()
Creates hidden HTML form elements to with currereturn $formstr; nt FORM values.
array get_current_vars()
Gets an array of current, non-pxdb form variables.
void set_form_var(string $name, mixed $value)
Adds or replaces the value for a var (hidden form element) to showform form.
void unset_form_var(string $name)
Removes a var (hidden form element) from showform form.
string pass_param_vars()
Create HTML form elements for parameters.
array get_param_vars()
Get array of parameter vals to pass to pxdb_adm class.
boolean hide_field(string $field)
Hides a specified field from view.
boolean lock_field(string $field)
Makes a specified field read-only ("locked").
boolean disable_autogen([ string $field ])
Disables auto-generation for a field (or for the entire object).
void showform([ string $template, array $additional_vars ])
Display the pxdb input form.
void set_form_action(string $action)
Set the action for the form.
string get_form_action()
Get the form action.
void set_form_name(string $form_name)
Set the name for the showform.
string get_form_name()
Gets the form name.
void set_submit_label(string $label)
Change the label used for the submit button
void set_submit_vars(array $params)
Specify variables that should be passed to form action on submit.

Private Method Summary

mixed _get_value(object pxdb_typesfield &$objf)
Gets the current value(s) for the typesfield row.
string _get_name(object pxdb_typesfield &$objf)
Gets the name for the form element.
array _get_options(object pxdb_typesfield &$objf)
Gets the possible values for the field.
string _get_label(object pxdb_typesfield &$objf)
Get the label for this field.
string _get_description(object pxdb_typesfield &$objf)
Get the description for this field.
string _get_label_tag(string $form_name, string $element_name, string $label)
Gets a tag given a couple of parameters
string _sql_get_object()
SQL to get the full object, sorted by 'orderby' column.
string _create_elements(string $name, mixed $value, [ string $prefix ])
Recursive function to create hidden HTML form elements for a name/value pair.

Fields inherited from pxdb_confront

$_imported, $validator, $_upload_fields, $_params, $_widget_params, $_data, $data_name_structure, $param_name_structure, $widget_param_name_structure

Fields inherited from pxdb_data

$debug, $errors, $datatype, $auth, $tpl, $show_unapproved, $db, $user_minimal_columns

Public Field Summary

boolean $auth_required
Is authentication required?
integer $record_id
Current record id.
string $submit_jscript
JavaScript that goes into form submit button.
array $current_vars
Current request variables.
array $param_vars
pxdb paramter variables.
boolean $preserve_vars
Whether or not to save pxdb[preserved_vars] array.
array $hidden_fields
Holds user-specified list of fields that are to be hidden.
array $locked_fields
Holds user-specified list of fields that are to be read-only ('locked').
array $autogen_disabled_fields
Holds user-specified list of autogen fields that are to be modified.
boolean $autogen_disabled
Whether auto-generation is disabled for the entire object.
array $widgets
Holds widgets
string $submit_label
Label for submit button

Private Field Summary

string $form_name
The name of the form.
string $form_action
The action of the form.
array $_labels

array $_descriptions

array $_names

array $_values

array $_options

array $_fields
holds a compiled form of all attributes for fields
array $_record
Holds the original record (if we are modifying a record).

Public Method Details

pxdb_input

public void pxdb_input(integer $dt, [ integer $record_id ])

 

Parameter
integer $dt
Datatype for this input class.
integer $record_id = >>null<<
ID of existing record.
Returns void


read

public void read()

  Sets the contents of $_record[] if $record_id is set.

Returns void


import

public void import([ array $source ])

 

Warning: documentation is missing.

Parameter
array $source = >>null<<
The location of source data to use. (for upward compatibility with pxdb::import())
Returns void


bind_widgets

public void bind_widgets(object pxdb_widgets &$widgets)

  The widget class must extend pxdb_widget and therefore must supply all methods that pxdb_widget supplies. (No checking happens to ensure this.)

Parameter
object pxdb_widgets &$widgets
pxdb_widgets Object
Returns void


set_auth_required

public void set_auth_required([ boolean $bit ])

  If auth_required is true, then you will not be able display a form without binding an authentication object.

Parameter
boolean $bit = >>true<<
to set auth_requred to.
Returns void


set_field_default

public void set_field_default(string $field, mixed $value)

 

Parameter
string $field
mixed $value
Returns void


set_field_options

public void set_field_options(string $field, array $options)

  This function does NOT check to see that the field you are setting options for is a field that actually can use options (e.g. a relationship or pick list). $options value is expected to be an array of hashes ['value'] and ['label'] or a simple array.

Parameter
string $field
The field name (identifier)
array $options
Hash (value,label) of options to display.
Returns void


get_view

public array get_view(string $view_name)

  BEFORE calling this function. We may need to deprecate this method in favor of simply setting an instance variable with a view and folding this functionality into get_fields().

Parameter
string $view_name
The id of the view we want to display.
Returns array

Array of all typesfields rows for specified view.


get_fields

public array get_fields()

 

Returns array

Array of all rows found by executing the SQL in _sql_get_object method.


_get_fields

public array _get_fields(array $tf_rows)

  The array that this function builds is sent to get_widget() method of pxdb_widgets class.

Parameter
array $tf_rows
Rows from typesfields.
Returns array


pass_current_vars

public string pass_current_vars()

 

Returns string

The form elements (input type=hidden)


get_current_vars

public array get_current_vars()

 

Returns array

Key -value pairs


set_form_var

public void set_form_var(string $name, mixed $value)

  Note: this will overwrite vars of the same name that are part of the post/get vars that call invoking script.

Parameter
string $name
The name of the variable to add.as
mixed $value
The value of the variable.
Returns void


unset_form_var

public void unset_form_var(string $name)

  This is useful if you don't want all of the current vars being passed to $PHP_SELF every time the page reloads. (e.g. if the environment would cause an action to be performed.)

Parameter
string $name
The name of the variable to remove.
Returns void


pass_param_vars

public string pass_param_vars()

 

Returns string

The HTML form elements


get_param_vars

public array get_param_vars()

 

Returns array

Key -value pairs


hide_field

public boolean hide_field(string $field)

  This function is used to individually/manually override the settings for the current object. In this way you can make a field hidden for one particular object form.

Parameter
string $field
The fieldname (identifier or dbfield name) of field you want to hide.
Returns boolean

True /false on success of finding the matchings typesfield id.


lock_field

public boolean lock_field(string $field)

  This function is used to individually/manually override the settings for the current object. In this way you can make a field read-only for one particular object form.

Parameter
string $field
The fieldname (identifier or dbfield name) of field you want to hide.
Returns boolean

True /false on success of finding the matchings typesfield id.


disable_autogen

public boolean disable_autogen([ string $field ])

  By default autogen fields will not appear on input forms (because the values are calculated automatically once the form is submitted). Disabling autogen will allow the value to be manipulated.

Parameter
string $field = >>null<<
The fieldname (identifier or dbfield name) of field you want to reveal.
Returns boolean

True /false on success of finding the matching typesfield id.


showform

public void showform([ string $template, array $additional_vars ])

  If no template path is given, this function will load _default/showform.tpl.

Parameter
string $template = >>null<<
The path of the template to use.
array $additional_vars = >>null<<
Hash of additional vars that should be set for the template to use.
Returns void


set_form_action

public void set_form_action(string $action)

 

Parameter
string $action
The action for the form
Returns void


get_form_action

public string get_form_action()

 

Returns string

The form action


set_form_name

public void set_form_name(string $form_name)

 

Parameter
string $form_name
Name of the form.
Returns void


get_form_name

public string get_form_name()

 

Returns string

Form name.


set_submit_label

public void set_submit_label(string $label)

 

Parameter
string $label
Returns void


set_submit_vars

public void set_submit_vars(array $params)

  JavaScript is used to set form elements on click of submit button.

Parameter
array $params
Hash of varname => value that will be set (by JavaScript) on submit.
Returns void


Private Method Details

_get_value

private mixed _get_value(object pxdb_typesfield &$objf)

  First it checks to see if there is already a value set for this element, e.g. a widget is re-loading the form, so the data is not written to the db, but is being preserved in the form.

Parameter
object pxdb_typesfield &$objf
typesfield Object current form element.
Returns mixed

The value(s) for the specified field.


_get_name

private string _get_name(object pxdb_typesfield &$objf)

  This is always the identifier from typesfields.

Parameter
object pxdb_typesfield &$objf
The pxdb_typesfields object.
Returns string

The name for the field.


_get_options

private array _get_options(object pxdb_typesfield &$objf)

  This is only relevant for relationships and pick-driven fields.

Parameter
object pxdb_typesfield &$objf
The pxdb_typesfields object.
Returns array

The value options for this field.


_get_label

private string _get_label(object pxdb_typesfield &$objf)

 

Parameter
object pxdb_typesfield &$objf
The pxdb_typesfields object.
Returns string

The form label.


_get_description

private string _get_description(object pxdb_typesfield &$objf)

 

Parameter
object pxdb_typesfield &$objf
The pxdb_typesfields object.
Returns string

The form description.


_get_label_tag

private string _get_label_tag(string $form_name, string $element_name, string $label)

 

Parameter
string $form_name
Name of the form
string $element_name
Name of the field (not the HTML element name)
string $label
Text of the label
Returns string

HTML of tag plus label text


_sql_get_object

private string _sql_get_object()

 

Returns string

SQL statement


_create_elements

private string _create_elements(string $name, mixed $value, [ string $prefix ])

  The recursion is necessary if $value is an array

Parameter
string $name
Element name
mixed $value
Element value
string $prefix = >>''<<
Internally used to build an associative array of elements for PHP to process
Returns string

The completed hidden element


Public Field Details

$auth_required

public boolean $auth_required

>>false<<


$record_id

public integer $record_id

>><<


$submit_jscript

public string $submit_jscript

>>''<<


$current_vars

public array $current_vars

>><<


$param_vars

public array $param_vars

>><<


$preserve_vars

public boolean $preserve_vars

>>true<<


$hidden_fields

public array $hidden_fields

>><<


$locked_fields

public array $locked_fields

>><<


$autogen_disabled_fields

public array $autogen_disabled_fields

>><<


$autogen_disabled

public boolean $autogen_disabled

>>false<<


$widgets

public array $widgets

>><<


$submit_label

public string $submit_label

>>'Submit Form'<<


Private Field Details

$form_name

private string $form_name

>><<


$form_action

private string $form_action

>><<


$_labels

private array $_labels

>><<


$_descriptions

private array $_descriptions

>><<


$_names

private array $_names

>><<


$_values

private array $_values

>><<


$_options

private array $_options

>><<


$_fields

private array $_fields

>><<


$_record

private array $_record

>><<



Packageindex Classtrees Modulegroups Elementlist Report XML Files
Generated on Fri, 28 Apr 2006 19:07:22 -0400 by PHPDoc v1.5 www.phpdoc.de