## P4A_Field

Description

A fields is a GUI element that shows its value, and this value can be changed.

- author: Andrea Giardina <andrea.giardina@crealabs.it>
- author: Fabrizio Balliano <fabrizio.balliano@crealabs.it>

Located in /p4a/objects/widgets/field.php (line 45)

    P4A_Object
       |
       --P4A_Widget
          |
          --P4A_Field

Variable Summary
string $align
integer $allow_null
array $buttons
data_source $data
string $data_description_field
data_field $data_field
data_field $data_member
string $data_value_field
string $encryption_type
string $formatted
string $formatter_name
string $format_name
integer $max_thumbnail_size
integer $null_message
string $type
boolean $upload
string $upload_subpath
Method Summary
P4A_Field P4A_Field (string $name, [string $add_default_data_field = TRUE])
void allowNull ([string $message = NULL])
void cleanNewValue ()
string composeLabel ()
string composeStringProperties ()
string composeStringValue ()
void enableUpload ([mixed $enable = true])
void fileDeleteOnClick ()
void fileDownloadOnClick ()
void filePreviewOnClick ()
string format (string $value)
string getAsCheckbox ()
void getAsDate ()
string getAsFile ()
string getAsHidden ()
string getAsImage ()
string getAsLabel ()
void getAsMulticheckbox ()
void getAsMultiselect ()
string getAsPassword ()
string getAsRadio ()
string getAsRichTextarea ()
string getAsSelect ()
string getAsString ()
string getAsText ()
string getAsTextarea ()
string getEncryptionType ()
string getLabel ()
integer getMaxThumbnailSize ()
string getNewValue ([integer $index = NULL])
string getSourceDescriptionField ()
string getSourceValueField ()
string getStringValue ()
string getType ()
string getUnformattedNewValue ([integer $index = NULL])
void getUploadSubpath ()
mixed getValue ()
boolean isFormattable ()
boolean isFormatted ()
boolean isNullAllowed ()
void noAllowNull ()
void setAlign (string $align)
void setDataField (DATA_FIELD &$data_field)
void setDefaultVisualizationProperties ()
void setEncryptionType (mixed $type)
void setFormat (string $formatter_name, string $format_name)
void setFormatted ([mixed $value = true])
void setLabel (string $value)
void setMaxThumbnailSize (integer $size)
void setNewValue (mixed $new_value)
void setSource (data_source &$data_source)
void setSourceDescriptionField (string $name)
void setSourceValueField (string $name)
void setType (strings $type)
void setUploadSubpath ([string $subpath = NULL])
void setValue (mixed $value)
string unformat (string $value)
void unsetFormat ()
void unsetFormatted ()
void unsetMaxThumbnailSize ()
void unsetUploadSubpath ()
Variables
string $align = 'left' (line 123)

Field align.

- access: private

integer $allow_null = false (line 109)

Defines if a SELECT has "none selected" record.

- access: private

array $buttons = NULL (line 52)

Buttons collection.

- access: private

data_source $data = NULL (line 59)

Data source for the field.

- access: private

string $data_description_field = NULL (line 87)

The data source member that contains the descriptions for this field.

- access: private

data_field $data_field = NULL (line 66)

Data source for the field.

- access: private

data_field $data_member = NULL (line 73)

Will be used for future implementations.

- access: private

string $data_value_field = NULL (line 80)

The data source member that contains the values for this field.

- access: private

string $encryption_type = 'md5' (line 158)

Type of encryption to use for password fields

- access: private

string $formatted = true (line 130)

Tells if the fields content is formatted or not.

- access: private

string $formatter_name = NULL (line 137)

The formatter class name for the data field.

- access: private

string $format_name = NULL (line 144)

The format name for the data field.

- access: private

integer $max_thumbnail_size = 100 (line 102)

Max size in pixels for image thumbnail.

- access: private

integer $null_message = NULL (line 116)

Defines the message for "none selected" record for select.

- access: private

string $type = 'text' (line 95)

Field type.

- see: set_type()
- access: private

boolean $upload = false (line 166)

Is upload enabled on rich text area? This is disabled by default for security reasons, enable it only after a well done permission check.

- access: private

string $upload_subpath = NULL (line 151)

Path under P4A_UPLOADS_PATH where uploads happens.

- access: private

#### Inherited Variables

Inherited from P4A_Widget

> P4A_Widget::$actions
> P4A_Widget::$enabled
> P4A_Widget::$label
> P4A_Widget::$map_actions
> P4A_Widget::$properties
> P4A_Widget::$style
> P4A_Widget::$template_name
> P4A_Widget::$use_template
> P4A_Widget::$value
> P4A_Widget::$visible
> P4A_Widget::$_temp_vars

Inherited from P4A_Object

> P4A_Object::$_id
> P4A_Object::$_map_actions
> P4A_Object::$_name
> P4A_Object::$_objects
> P4A_Object::$_parent_id

Methods
Constructor P4A_Field (line 175)

Class constructor.

Istances the widget, sets name and initializes its value.

- access: private

P4A_Field P4A_Field (string $name, [string $add_default_data_field = TRUE])

- string $name: Mnemonic identifier for the object.
- string $add_default_data_field: If it's false the widget doesn't instance a default data_field. You must to set a data_field for the widget before call get_value, get_new_value or getAsstring.

allowNull (line 974)

Used ony for select, sets the select to allow a "none selected" record.

- access: public

void allowNull ([string $message = NULL])

- string $message: The message for "none selected"

cleanNewValue (line 649)

Resets the "new_value".

- access: public

void cleanNewValue ()
composeLabel (line 1321)

Gets the HTML rendered field's label.

- access: public

string composeLabel ()
composeStringProperties (line 1342)

Composes a string containing all the HTML properties of the widget.

Note: it will also contain the name and the value.

- access: public

string composeStringProperties ()

Redefinition of:

P4A_Widget::composeStringProperties()
  Composes a string containing all the HTML properties of the widget.

composeStringValue (line 1360)

Returns the field's value differently if we are in an '<input value="' environment on in a '<tag>value</tag>' environment.

- access: public

string composeStringValue ()
enableUpload (line 1384)
void enableUpload ([mixed $enable = true])
fileDeleteOnClick (line 1122)

Action handler for file deletetion.

- access: public

void fileDeleteOnClick ()
fileDownloadOnClick (line 1143)

Action handler for file download.

- access: public

void fileDownloadOnClick ()
filePreviewOnClick (line 1131)

Action handler for file preview (only images).

- access: public

void filePreviewOnClick ()
format (line 609)

Format the given value using the current formatting options.

Empty values are not formatted.
If formatting is turned of it does nothing.

- access: private

string format (string $value)

- string $value: The value to be formatted.

getAsCheckbox (line 1050)

Returns the HTML rendered field as checkbox.

- access: public

string getAsCheckbox ()
getAsDate (line 696)
void getAsDate ()
getAsFile (line 1076)

Returns the HTML rendered field as file upload.

- access: public

string getAsFile ()
getAsHidden (line 799)

Returns the HTML rendered field as '<input type="hidden"'.

- access: public

string getAsHidden ()
getAsImage (line 1191)

Returns the HTML rendered field as image upload.

- access: public

string getAsImage ()
getAsLabel (line 813)

Returns the HTML rendered field as '<div>$value</div>'.

- access: public

string getAsLabel ()
getAsMulticheckbox (line 934)
void getAsMulticheckbox ()
getAsMultiselect (line 891)
void getAsMultiselect ()
getAsPassword (line 736)

Returns the HTML rendered field as '<input type="password"'.

We use P4A_PASSWORD_OBFUSCATOR for password value so the old password isn't sent over the net.

- access: public

string getAsPassword ()
getAsRadio (line 1004)

Returns the HTML rendered field as radio buttons group.

- access: public

string getAsRadio ()
getAsRichTextarea (line 781)

Returns the HTML rendered field as '<input type="textarea"' with rich text editing features.

- access: public

string getAsRichTextarea ()
getAsSelect (line 845)

Returns the HTML rendered field as combo box.

- access: public

string getAsSelect ()
getAsString (line 659)

Returns the HTML rendered field.

- access: public

string getAsString ()

Redefinition of:

P4A_Widget::getAsString()
  Returns the HTML rendered widget.

getAsText (line 683)

Returns the HTML rendered field as '<input type="text"'.

- access: public

string getAsText ()
getAsTextarea (line 758)

Returns the HTML rendered field as '<input type="textarea"'.

- access: public

string getAsTextarea ()
getEncryptionType (line 525)

Returns the encryption type (for password fields)

- access: public

string getEncryptionType ()
getLabel (line 1311)

Returns the label for the field.

- access: public

string getLabel ()

Redefinition of:

P4A_Widget::getLabel()
  Returns the label for the widget.

getMaxThumbnailSize (line 1289)

Returns the maximum size for image thumbnails.

- access: public

integer getMaxThumbnailSize ()
getNewValue (line 329)

Returns the "new_value" for the field (with locale formatting).

- access: public

string getNewValue ([integer $index = NULL])

- integer $index: If the value is an array that we can return only one element.

getSourceDescriptionField (line 504)

Returns the name of the data source member that keeps the field's description.

- access: public

string getSourceDescriptionField ()
getSourceValueField (line 494)

Returns the name of the data source member that keeps the field's value.

- access: public

string getSourceValueField ()
getStringValue (line 277)

Return the field's value always as string.

If the value is an array, it will be encoded in {value1, value2}

- access: public

string getStringValue ()
getType (line 514)

Returns the field's type.

- access: public

string getType ()
getUnformattedNewValue (line 356)

Returns the "new_value" for the field (without locale formatting).

- access: public

string getUnformattedNewValue ([integer $index = NULL])

- integer $index: If the value is an array that we can return only one element.

getUploadSubpath (line 1181)

Return the subpath for upload..

- access: public

void getUploadSubpath ()
getValue (line 266)

Returns the value for the field.

- access: public

mixed getValue ()

Redefinition of:

P4A_Widget::getValue()
  Retuns the value of the widget.

isFormattable (line 534)

Returns true if the field is text or textarea.

- access: public

boolean isFormattable ()
isFormatted (line 552)

Returns true if a formatting format for the field has been set.

- access: public

boolean isFormatted ()
isNullAllowed (line 994)

Used ony for select, returns if the select allows a "none selected" record.

- access: public

boolean isNullAllowed ()
noAllowNull (line 984)

Used ony for select, sets the select to do not allow a "none selected" record.

- access: public

void noAllowNull ()
setAlign (line 1331)

Sets the alignment property for the field.

- access: public

void setAlign (string $align)

- string $align: The align property.

setDataField (line 201)

Sets a data field as current data_field.

This changes default text alignment for integer, decimal, float, date, time to right.

- access: public

void setDataField (DATA_FIELD &$data_field)

- DATA_FIELD &$data_field: The new data field

setDefaultVisualizationProperties (line 226)

Sets the default visualization property for the field.

- access: private

void setDefaultVisualizationProperties ()
setEncryptionType (line 408)

Set type of encryption to use for password fields (md5|none)

- access: public

void setEncryptionType (mixed $type)
setFormat (line 583)

Sets the field formatter and format.

This also turns formatting on.
Eg: set_format('numbers', 'decimal')

- access: public

void setFormat (string $formatter_name, string $format_name)

- string $formatter_name: The formatter name.
- string $format_name: The format name.

setFormatted (line 561)

Sets the field as formatted.

- access: public

void setFormatted ([mixed $value = true])
setLabel (line 1301)

Sets the label for the field.

In rendering phase it will be added with ': '.

- see: P4A_Widget::$label
- access: public

void setLabel (string $value)

- string $value: The string to set as label.

Redefinition of:

P4A_Widget::setLabel()
  Sets the label for the widget.

setMaxThumbnailSize (line 1270)

Sets the maximum size for image thumbnails.

- access: public

void setMaxThumbnailSize (integer $size)

- integer $size: Max size (width and height)

setNewValue (line 294)

Examines the value passed by the web form and set the new value.

- access: public

void setNewValue (mixed $new_value)

- mixed $new_value: The new value for the field.

setSource (line 426)

If we use fields like combo box we have to set a data source.

By default we'll take the data source primary key as value field and the first fiels (not pk) as description.

- access: public

void setSource (data_source &$data_source)

- data_source &$data_source: The data source.

setSourceDescriptionField (line 481)

Sets what data source member is the keeper of the field's description.

- access: public

void setSourceDescriptionField (string $name)

- string $name: The name of the data source member.

setSourceValueField (line 469)

Sets what data source member is the keeper of the field's value.

- access: public

void setSourceValueField (string $name)

- string $name: The name of the data source member.

setType (line 380)

Sets the field's type.

- access: public

void setType (strings $type)

- strings $type: The type (text|password|textarea|rich_textarea|date|hidden|label|select|radio|checkbox|multiselect|multicheckbox).

setUploadSubpath (line 1163)

Sets the subpath of P4A_UPLOADS_PATH where the upload will happen.

- access: public

void setUploadSubpath ([string $subpath = NULL])

- string $subpath: The subdir (can be "test", "test/", "test/test", "test/test/test/")

setValue (line 256)

Sets the value for the field.

- access: public

void setValue (mixed $value)

- mixed $value: Value.

Redefinition of:

P4A_Widget::setValue()
  Sets the value of the widget.

unformat (line 631)

Takes the formatted passed value and takes it back to its unformatted form.

- see: P4A_Date::unformat()
- see: P4A_Number::unformat()
- access: private

string unformat (string $value)

- string $value: The formatted value.

unsetFormat (line 594)

Removes formatting options and turns formatting off.

- access: public

void unsetFormat ()
unsetFormatted (line 570)

Sets the field as not formatted.

- access: public

void unsetFormatted ()
unsetMaxThumbnailSize (line 1279)

Removes the maximum size for image thumbnails.

- access: public

void unsetMaxThumbnailSize ()
unsetUploadSubpath (line 1172)

Removes the subpath for upload.

- access: public

void unsetUploadSubpath ()

#### Inherited Methods

Inherited From P4A_Widget

> P4A_Widget::addAction()
> P4A_Widget::addTempVar()
> P4A_Widget::changeEvent()
> P4A_Widget::clearTemplateVars()
> P4A_Widget::clearTempVars()
> P4A_Widget::composeStringActions()
> P4A_Widget::composeStringClassStyle()
> P4A_Widget::composeStringProperties()
> P4A_Widget::composeStringStyle()
> P4A_Widget::disable()
> P4A_Widget::display()
> P4A_Widget::dropAction()
> P4A_Widget::dropTempVar()
> P4A_Widget::enable()
> P4A_Widget::fetchTemplate()
> P4A_Widget::getAccessKey()
> P4A_Widget::getAsString()
> P4A_Widget::getHeight()
> P4A_Widget::getLabel()
> P4A_Widget::getProperty()
> P4A_Widget::getStyleProperty()
> P4A_Widget::getValue()
> P4A_Widget::getWidth()
> P4A_Widget::isEnabled()
> P4A_Widget::isVisible()
> P4A_Widget::onChange()
> P4A_Widget::onClick()
> P4A_Widget::onKeyPress()
> P4A_Widget::onMouseOver()
> P4A_Widget::onReturnPress()
> P4A_Widget::p4a_widget()
> P4A_Widget::raise()
> P4A_Widget::requireConfirmation()
> P4A_Widget::setAccessKey()
> P4A_Widget::setBgcolor()
> P4A_Widget::setBgimage()
> P4A_Widget::setDefaultLabel()
> P4A_Widget::setFontColor()
> P4A_Widget::setFontWeight()
> P4A_Widget::setHeight()
> P4A_Widget::setInvisible()
> P4A_Widget::setLabel()
> P4A_Widget::setProperty()
> P4A_Widget::setStyleProperty()
> P4A_Widget::setValue()
> P4A_Widget::setVisible()
> P4A_Widget::setWidth()
> P4A_Widget::unrequireConfirmation()
> P4A_Widget::unsetProperty()
> P4A_Widget::unsetStyleProperty()
> P4A_Widget::useTemplate()

Inherited From P4A_Object

> P4A_Object::actionHandler()
> P4A_Object::build()
> P4A_Object::destroy()
> P4A_Object::errorHandler()
> P4A_Object::getId()
> P4A_Object::getName()
> P4A_Object::getObjectType()
> P4A_Object::getParentID()
> P4A_Object::implementMethod()
> P4A_Object::intercept()
> P4A_Object::isActionTriggered()
> P4A_Object::p4a_object()
> P4A_Object::setName()
> P4A_Object::setParentID()
> P4A_Object::void()

Documentation generated on Fri, 26 May 2006 12:43:08 +0200 by phpDocumentor 1.3.0RC5