CWIS Developer Documentation
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
FormUI_Base Class Reference

Base class (covering non-presentation elements) supplying a standard user interface for presenting and working with HTML forms. More...

Inheritance diagram for FormUI_Base:
Inheritance graph
[legend]

Public Member Functions

 __construct ($FieldParams, $FieldValues=array(), $UniqueKey=NULL)
 Class constructor. More...
 
 DisplayFormTable ($TableId=NULL, $TableStyle=NULL)
 Display HTML table with settings parameters. More...
 
 ValidateFieldInput ()
 Validate field values on submitted form. More...
 
 AddValidationParameters ()
 Add values to be passed to input validation functions, in addition to field name and value. More...
 
 GetNewValuesFromForm ()
 Retrieve values set by form. More...
 
 GetFieldValue ($FieldName)
 Get value for form field. More...
 
 HandleUploads ()
 Handle image and file uploads. More...
 
 HandleDeletes ()
 Handle image and file deletions. More...
 
 SetEventToSignalOnChange ($EventName, $EventParams=array())
 Set event to signal when retrieving values from form when settings have changed. More...
 
 ValidateEmail ($FieldName, $FieldValues)
 Validate value as valid-appearing email address. More...
 
 ValidateUrl ($FieldName, $FieldValues)
 Validate value as valid-appearing URL. More...
 
 ValidateHostName ($FieldName, $FieldValues)
 Validate value as valid host name (i.e. More...
 

Static Public Member Functions

static LogError ($Msg, $Field=NULL)
 Log error message for later display. More...
 
static GetLoggedErrors ()
 Get logged errors. More...
 
static ErrorsLogged ($Field=FALSE)
 Report whether errors have been logged. More...
 
static ClearLoggedErrors ($Field=FALSE)
 Clear logged errors. More...
 
static DidValueChange ($OldValue, $NewValue)
 Determine if a new form field value is different from an old one. More...
 
static LoadValue ($Type, $Data)
 Load value of requested type from supplied data. More...
 

Public Attributes

const FTYPE_FILE = "File"
 Supported field types. More...
 
const FTYPE_FLAG = "Flag"
 
const FTYPE_IMAGE = "Image"
 
const FTYPE_METADATAFIELD = "MetadataField"
 
const FTYPE_NUMBER = "Number"
 
const FTYPE_OPTION = "Option"
 
const FTYPE_PARAGRAPH = "Paragraph"
 
const FTYPE_PASSWORD = "Password"
 
const FTYPE_PRIVILEGES = "Privileges"
 
const FTYPE_SEARCHPARAMS = "Search Parameters"
 
const FTYPE_TEXT = "Text"
 
const FTYPE_URL = "URL"
 
const FTYPE_USER = "User"
 
const FTYPE_QUICKSEARCH = "Quick Search"
 
const FTYPE_HEADING = "Heading"
 Supported field pseudo-types. More...
 
const NO_VALUE_FOR_FIELD = "NO VALUE"
 Marker used to indicate currently no value for field. More...
 

Protected Member Functions

 DisplayFormField ($Name, $Value, $Params)
 Display HTML form field for specified field. More...
 
 GetFormFieldName ($FieldName, $IncludePrefix=TRUE)
 Get HTML form field name for specified field. More...
 
 GetHiddenFieldsHtml ()
 Get HTML for hidden form fields associated with form processing. More...
 
 ConvertItemIdsToNames ($MField, $ItemIds)
 Take an array of ItemIds and convert it to [ ItemId => ItemName ]. More...
 

Protected Attributes

 $DeletedFiles = array()
 
 $DeletedImages = array()
 
 $ExtraValidationParams = array()
 
 $ExtraValues = array()
 
 $FieldParams
 
 $FieldValues
 
 $HiddenFields = array()
 
 $SettingChangeEventName = NULL
 
 $SettingChangeEventParams = array()
 

Static Protected Attributes

static $ErrorMessages = array()
 

Detailed Description

Base class (covering non-presentation elements) supplying a standard user interface for presenting and working with HTML forms.

Definition at line 14 of file FormUI_Base.php.

Constructor & Destructor Documentation

FormUI_Base::__construct (   $FieldParams,
  $FieldValues = array(),
  $UniqueKey = NULL 
)

Class constructor.

Parameters
array$FieldParamsAssociative array of associative arrays of form field parameters, with field names for the top index.
array$FieldValuesAssociative array of current values for form fields, with field names for the index. (OPTIONAL, as values may also be supplied via $FieldParams.)
string$UniqueKeyUnique string to include in form field names to distinguish them from other fields in the form. (OPTIONAL)

Definition at line 46 of file FormUI_Base.php.

References $FieldParams, $FieldValues, DisplayFormTable(), MetadataSchema\FieldExistsInAnySchema(), MetadataSchema\GetCanonicalFieldIdentifier(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TREE, and MetadataSchema\MDFTYPE_USER.

Member Function Documentation

FormUI_Base::AddValidationParameters ( )

Add values to be passed to input validation functions, in addition to field name and value.

See also
FormUI_Base::ValidateFieldInput()

Definition at line 346 of file FormUI_Base.php.

static FormUI_Base::ClearLoggedErrors (   $Field = FALSE)
static

Clear logged errors.

Parameters
string$FieldClear only errors for specified field. (OPTIONAL)

Definition at line 186 of file FormUI_Base.php.

FormUI_Base::ConvertItemIdsToNames (   $MField,
  $ItemIds 
)
protected

Take an array of ItemIds and convert it to [ ItemId => ItemName ].

Parameters
MetadataField$MFieldField giving the namespace of the ItemIds.
array$ItemIdsInt item ids.
Returns
array keyed by ItemId with values giving item names.

Definition at line 1149 of file FormUI_Base.php.

References Item\ItemExists(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TREE, and MetadataSchema\MDFTYPE_USER.

Referenced by GetFieldValue().

Here is the caller graph for this function:

static FormUI_Base::DidValueChange (   $OldValue,
  $NewValue 
)
static

Determine if a new form field value is different from an old one.

Parameters
mixed$OldValueOld field value.
mixed$NewValueNew field value.
Returns
Returns TRUE if the values are different and FALSE otherwise.

Definition at line 863 of file FormUI_Base.php.

FormUI_Base::DisplayFormField (   $Name,
  $Value,
  $Params 
)
abstractprotected

Display HTML form field for specified field.

Parameters
string$NameField name.
mixed$ValueCurrent value for field.
array$ParamsField parameters.
FormUI_Base::DisplayFormTable (   $TableId = NULL,
  $TableStyle = NULL 
)
abstract

Display HTML table with settings parameters.

Parameters
string$TableIdCSS ID for table element. (OPTIONAL)
string$TableStyleCSS styles for table element. (OPTIONAL)

Referenced by __construct().

Here is the caller graph for this function:

static FormUI_Base::ErrorsLogged (   $Field = FALSE)
static

Report whether errors have been logged.

Parameters
string$FieldField to check – specify NULL to check for any errors with no field associated. (OPTIONAL)
Returns
bool TRUE if errors have been logged, otherwise FALSE.

Definition at line 170 of file FormUI_Base.php.

FormUI_Base::GetFieldValue (   $FieldName)

Get value for form field.

Parameters
string$FieldNameCanonical field name.
Returns
mixed Value or array of values for field.

Definition at line 578 of file FormUI_Base.php.

References ConvertItemIdsToNames(), and GetFormFieldName().

Referenced by FormUI\DisplayFormTable(), and FormUI\HandleDeletes().

Here is the caller graph for this function:

FormUI_Base::GetFormFieldName (   $FieldName,
  $IncludePrefix = TRUE 
)
protected

Get HTML form field name for specified field.

Parameters
string$FieldNameField name.
bool$IncludePrefixIf TRUE, "F_" prefix is included. (OPTIONAL, defaults to TRUE.)
Returns
string Form field name.

Definition at line 1107 of file FormUI_Base.php.

Referenced by FormUI\DisplayFileField(), FormUI\DisplayFormField(), FormUI\DisplayFormTable(), FormUI\DisplayImageField(), GetFieldValue(), GetNewValuesFromForm(), FormUI\HandleDeletes(), HandleDeletes(), HandleUploads(), and FormUI\PrintFieldHidingJavascript().

Here is the caller graph for this function:

FormUI_Base::GetHiddenFieldsHtml ( )
protected

Get HTML for hidden form fields associated with form processing.

Definition at line 1117 of file FormUI_Base.php.

Referenced by FormUI\DisplayFormTable().

Here is the caller graph for this function:

static FormUI_Base::GetLoggedErrors ( )
static

Get logged errors.

Returns
array Logged errors, with associated fields for the index (NULL for errors with no association) and an array of error messages for each value.

Definition at line 159 of file FormUI_Base.php.

FormUI_Base::GetNewValuesFromForm ( )

Retrieve values set by form.

Returns
array Array of configuration settings, with setting names for the index, and new setting values for the values.

Definition at line 356 of file FormUI_Base.php.

References $SettingChangeEventParams, and GetFormFieldName().

Referenced by ConfigSettingsUI\GetNewSettingsFromForm(), and ValidateFieldInput().

Here is the caller graph for this function:

FormUI_Base::HandleDeletes ( )

Handle image and file deletions.

Definition at line 801 of file FormUI_Base.php.

References GetFormFieldName().

FormUI_Base::HandleUploads ( )

Handle image and file uploads.

Definition at line 690 of file FormUI_Base.php.

References $FieldParams, AI_OKAY, AI_UNKNOWNTYPE, AI_UNSUPPORTEDFORMAT, File\Create(), File\FILESTAT_ZEROLENGTH, GetFormFieldName(), and LogError().

static FormUI_Base::LoadValue (   $Type,
  $Data 
)
static

Load value of requested type from supplied data.

Parameters
string$TypeType of value (FTYPE_*).
mixed$DataData to use in loading value.
Returns
mixed Loaded value.

Definition at line 965 of file FormUI_Base.php.

static FormUI_Base::LogError (   $Msg,
  $Field = NULL 
)
static

Log error message for later display.

Parameters
string$MsgError message.
string$FieldField associated with error. (OPTIONAL, defaults to no field association)

Definition at line 148 of file FormUI_Base.php.

Referenced by HandleUploads().

Here is the caller graph for this function:

FormUI_Base::SetEventToSignalOnChange (   $EventName,
  $EventParams = array() 
)

Set event to signal when retrieving values from form when settings have changed.

If the supplied event parameters include parameter names (indexes) of "SettingName", "OldValue", or "NewValue", the parameter value will be replaced with an appropriate value before the event is signaled.

Parameters
string$EventNameName of event to signal.
array$EventParamsArray of event parameters, with CamelCase parameter names for index. (OPTIONAL)
See also
FormUI_Base::GetNewsettingsFromForm()

Definition at line 851 of file FormUI_Base.php.

FormUI_Base::ValidateEmail (   $FieldName,
  $FieldValues 
)

Validate value as valid-appearing email address.

This is intended to be used with the "ValidateFunction" capability, like this:

"ValidateFunction" => array("FormUI", "ValidateEmail"),

(The "FormUI" part will be replaced by the appropropriate FormUI object before the method is called.)

Parameters
string$FieldNameName of form field.
array$FieldValuesForm values being validated.
Returns
string Error message or NULL if value appears valid.

Definition at line 1004 of file FormUI_Base.php.

References $FieldValues.

FormUI_Base::ValidateFieldInput ( )

Validate field values on submitted form.

Validation functions (specified via the "ValidateFunction" parameter) should take a field name and value as parameters, and return NULL if the field validates successfully, or an error message if it does not.

Returns
int Number of fields with invalid values found.

Definition at line 205 of file FormUI_Base.php.

References GetNewValuesFromForm().

FormUI_Base::ValidateHostName (   $FieldName,
  $FieldValues 
)

Validate value as valid host name (i.e.

one that can be resolved to an IP address via DNS). This is intended to be used with the "ValidateFunction" capability, like this:

"ValidateFunction" => array("FormUI", "ValidateHostName"),

(The "FormUI" part will be replaced by the appropropriate FormUI object before the method is called.)

Parameters
string$FieldNameName of form field.
array$FieldValuesForm values being validated.
Returns
string Error message or NULL if value appears valid.

Definition at line 1059 of file FormUI_Base.php.

References $FieldValues.

FormUI_Base::ValidateUrl (   $FieldName,
  $FieldValues 
)

Validate value as valid-appearing URL.

This is intended to be used with the "ValidateFunction" capability, like this:

"ValidateFunction" => array("FormUI", "ValidateUrl"),

(The "FormUI" part will be replaced by the appropropriate FormUI object before the method is called.)

Parameters
string$FieldNameName of form field.
array$FieldValuesForm values being validated.
Returns
string Error message or NULL if value appears valid.

Definition at line 1031 of file FormUI_Base.php.

References $FieldValues.

Member Data Documentation

FormUI_Base::$DeletedFiles = array()
protected

Definition at line 1077 of file FormUI_Base.php.

Referenced by FormUI\DisplayFileField().

FormUI_Base::$DeletedImages = array()
protected

Definition at line 1078 of file FormUI_Base.php.

Referenced by FormUI\DisplayImageField().

FormUI_Base::$ErrorMessages = array()
staticprotected

Definition at line 1087 of file FormUI_Base.php.

FormUI_Base::$ExtraValidationParams = array()
protected

Definition at line 1079 of file FormUI_Base.php.

FormUI_Base::$ExtraValues = array()
protected

Definition at line 1080 of file FormUI_Base.php.

FormUI_Base::$FieldParams
protected

Definition at line 1081 of file FormUI_Base.php.

Referenced by __construct(), and HandleUploads().

FormUI_Base::$FieldValues
protected

Definition at line 1082 of file FormUI_Base.php.

Referenced by __construct(), ValidateEmail(), ValidateHostName(), and ValidateUrl().

FormUI_Base::$HiddenFields = array()
protected

Definition at line 1083 of file FormUI_Base.php.

FormUI_Base::$SettingChangeEventName = NULL
protected

Definition at line 1084 of file FormUI_Base.php.

FormUI_Base::$SettingChangeEventParams = array()
protected

Definition at line 1085 of file FormUI_Base.php.

Referenced by GetNewValuesFromForm().

const FormUI_Base::FTYPE_FILE = "File"

Supported field types.

Definition at line 19 of file FormUI_Base.php.

const FormUI_Base::FTYPE_FLAG = "Flag"

Definition at line 20 of file FormUI_Base.php.

const FormUI_Base::FTYPE_HEADING = "Heading"

Supported field pseudo-types.

Definition at line 34 of file FormUI_Base.php.

Referenced by UserEditingUI\GetRequestAccountForm().

const FormUI_Base::FTYPE_IMAGE = "Image"

Definition at line 21 of file FormUI_Base.php.

const FormUI_Base::FTYPE_METADATAFIELD = "MetadataField"

Definition at line 22 of file FormUI_Base.php.

const FormUI_Base::FTYPE_NUMBER = "Number"

Definition at line 23 of file FormUI_Base.php.

const FormUI_Base::FTYPE_OPTION = "Option"

Definition at line 24 of file FormUI_Base.php.

Referenced by UserEditingUI\GetRequestAccountForm().

const FormUI_Base::FTYPE_PARAGRAPH = "Paragraph"

Definition at line 25 of file FormUI_Base.php.

const FormUI_Base::FTYPE_PASSWORD = "Password"

Definition at line 26 of file FormUI_Base.php.

Referenced by UserEditingUI\GetRequestAccountForm().

const FormUI_Base::FTYPE_PRIVILEGES = "Privileges"

Definition at line 27 of file FormUI_Base.php.

const FormUI_Base::FTYPE_QUICKSEARCH = "Quick Search"

Definition at line 32 of file FormUI_Base.php.

const FormUI_Base::FTYPE_SEARCHPARAMS = "Search Parameters"

Definition at line 28 of file FormUI_Base.php.

const FormUI_Base::FTYPE_TEXT = "Text"

Definition at line 29 of file FormUI_Base.php.

Referenced by UserEditingUI\GetRequestAccountForm().

const FormUI_Base::FTYPE_URL = "URL"

Definition at line 30 of file FormUI_Base.php.

const FormUI_Base::FTYPE_USER = "User"

Definition at line 31 of file FormUI_Base.php.

const FormUI_Base::NO_VALUE_FOR_FIELD = "NO VALUE"

Marker used to indicate currently no value for field.

Definition at line 1090 of file FormUI_Base.php.


The documentation for this class was generated from the following file: