Class WFFormatter

Description

WFFormatter

Formatters provide a way for WFWidget objects to convert to and from text. Formatters are used by widgets to convert their "value" object into what is displayed and vice-versa. For instance, you could assign a DATE object (ie int) to a widget, and also a WFDateFormatter, and it would automatically convert the INT into a nice human-readable format. The user could edit this, and then the WFDateFormatter would convert the string back into a date object before proceeding.

Formatters should always allow EMPTY values cleanly. If the developer wants to enforce a non-empty value, that should be done via validation.

Located in /framework/widgets/WFFormatter.php (line 24)

WFObject
   |
   --WFFormatter
Direct descendents
Class Description
WFBaseDateFormatter WFFormatter
WFNumberFormatter The Number format converts between "pretty" numbers with formatting and PHP numeric types.
WFBooleanFormatter The Boolean formatter converts between boolean values and YES / NO equivalents.
WFSensitiveDataFormatter The SensitiveData formatter takes a string of sensitive data and blocks out certain pieces of the info.
Method Summary
WFFormatter __construct ()
string editingStringForValue (mixed $value)
string stringForValue (mixed $value)
mixed valueForString (string $string, object An &$error)
Methods
Constructor __construct (line 26)
WFFormatter __construct ()

Redefinition of:
WFObject::__construct()

Redefined in descendants as:
editingStringForValue (line 48)

Retrieve a string for the passed in value. This is the string that the user would EDIT.

The default implementation simply calls stringForValue.

An example of why you would implement this function would be if the value to edit is different from the value to display. For instance, for a dollar value of 5.00 you might prefer to display "$5.00" and edit "5.00".

  • return: A valid string representing the data passed, or NULL if the conversion is not possible.
  • todo: Make the UI system use this call instead of stringForValue()
string editingStringForValue (mixed $value)
  • mixed $value: The value to convert to a string. Each subclass knows how to properly handle the data types it is intended for.
stringForValue (line 34)

Retrieve a string for the passed in value.

  • return: A valid string representing the data passed, or NULL if the conversion is not possible.
  • abstract:
string stringForValue (mixed $value)
  • mixed $value: The value to convert to a string. Each subclass knows how to properly handle the data types it is intended for.

Redefined in descendants as:
valueForString (line 63)

Retreive a value for the passed in string.

Errors on conversion are detected by the presence of an errorMessage or errorCode.

  • return: The value represented for a string. If there was an error in converting the string to a value, the return value will be ignored. For instance, a WFDateFormatter will return a UNIX EPOCH TIME, while a WFNumberFormatter will return float, int, etc.
  • abstract:
mixed valueForString (string $string, object An &$error)
  • string $string: The string value. Each subclass has algorithms for converting to the particular type of object represented.
  • object An &$error: empty WFError object. Fill out the WFError::setErrorCode() or the WFError::setErrorMessage() if there is an error converting.

Redefined in descendants as:

Inherited Methods

Inherited From WFObject

WFObject::__construct()
WFObject::exposedProperties()
WFObject::getClass()
WFObject::keyPathToTargetAndKey()
WFObject::setValueForKey()
WFObject::setValueForKeyPath()
WFObject::setValuesForKeys()
WFObject::validatedSetValueForKey()
WFObject::validatedSetValueForKeyPath()
WFObject::validateObject()
WFObject::validateValueForKey()
WFObject::validateValueForKeyPath()
WFObject::valueForKey()
WFObject::valueForKeyPath()
WFObject::valueForStaticKey()
WFObject::valueForStaticKeyPath()
WFObject::valueForTargetAndKeyPath()
WFObject::valueForUndefinedKey()
WFObject::valueForUndefinedStaticKey()
WFObject::valuesForKeyPaths()
WFObject::valuesForKeys()
WFObject::_valueForStaticKey()
WFObject::__toString()

Documentation generated on Thu, 14 May 2009 16:20:01 -0400 by phpDocumentor 1.4.2