FORMfields


FORMfields.fields.UploadWebImageField

Class UploadWebImageField

FormField
|
+--FileField
|
+--UploadField
|
+--UploadWebImageField

public class UploadWebImageField
extends UploadField

UploadWebImageField is a field for uploading a web image: "gif", "jpg", "jpeg" or "png".

Since:
FORMfields v3.0

Field Summary
mixed

$maxImageHeight

The maximum permitted height of an image or null if there isn't a max.

mixed

$maxImageWidth

The maximum permitted width of an image or null if there isn't a max.

mixed

$validImageExts

An array of only the valid web image extensions.

Fields inherited from FORMfields.fields.UploadField
allowAllExts, clearButton, enableUploadNow, fileProperties, maxFileSize, newUpload, prohibitedExts, subFieldsCannotBeEmpty, uploadDir, uploadDirUrl, uploadNowButton, uploadedFile, uploadedFileField, uploadedFilename, uploadedLocalFile
Fields inherited from FORMfields.fields.FileField
MAX_SIZE
Fields inherited from FORMfields.fields.FormField
autoPropagate, data, disableEnterHandler, displayValuesOnNewLine, editable, enabled, endingString, enterTabHandler, enterTabs, error, extraHtml, fieldBelowLabel, formError, help, hidden, htmlify, id, isData, label, labelForId, multiValues, name, required, subFieldDisplayValueSeparator, subFieldSeparator, subFieldValueSeparator, subFields, subFieldsCannotBeEmpty, trimWhitespace, validators, value, valueIsHtml
Constructor Summary

UploadWebImageField(string name, string label, int required, int maxFileSize, int uploadDir, int uploadDirUrl, int maxImageWidth, int maxImageHeight)

Creates a new UploadWebImageField.

__construct(string name, string label, int required, int maxFileSize, int uploadDir, int uploadDirUrl, int maxImageWidth, int maxImageHeight)

Creates a new UploadWebImageField.

Method Summary
string

getImageTag(string alt)

Returns an HTML image tag for displaying the uploaded image.

boolean

isValid()

Checks for field errors detected by this field, including a check for blank.

void

validImageExtension(mixed ext)

Methods inherited from FORMfields.fields.UploadField
getDisplayHtmlValue, getEditableFieldTag, getParameter, getValue, isValid, moveUploadedFile, setValue, uploadFile, validExtension
Methods inherited from FORMfields.fields.FileField
getEditableFieldTag
Methods inherited from FORMfields.fields.FormField
addFieldValidator, addSubField, checkForBlank, clearValue, disable, formatRequestParameter, formatText, getButtonClicked, getData, getDbValue, getDisableFieldJs, getDisableJs, getDisableLabelJs, getDisplayFieldTag, getDisplayHtmlValue, getDisplayLabelTag, getDisplayValue, getEditable, getEditableFieldTag, getEditableLabelTag, getEnabled, getError, getExtraHtml, getFieldTag, getFormError, getHelp, getHelpTag, getHidden, getHiddenFieldTag, getId, getIsData, getIsHidden, getLabel, getLabelHtml, getLabelTag, getName, getOrNull, getParameter, getRawDbValue, getRequired, getValue, isBlank, isEmpty, isValid, setAutoPropagate, setData, setDbValue, setDisplayValuesOnNewLine, setEditable, setEnabled, setEndingString, setError, setExtraHtml, setFieldBelowLabel, setFormError, setHelp, setHidden, setHtmlify, setId, setIsData, setIsHidden, setLabel, setName, setRequired, setTrimWhitespace, setValue, setValueIsHtml, validate

Field Detail

maxImageHeight

public mixed $maxImageHeight = null

The maximum permitted height of an image or null if there isn't a max.

Since:
FORMfields v3.0

maxImageWidth

public mixed $maxImageWidth = null

The maximum permitted width of an image or null if there isn't a max.

Since:
FORMfields v3.0

validImageExts

public mixed $validImageExts = array("gif"

An array of only the valid web image extensions.

Since:
FORMfields v3.0

Constructor Detail

UploadWebImageField

public UploadWebImageField(string name, string label, int required, int maxFileSize, int uploadDir, int uploadDirUrl, int maxImageWidth, int maxImageHeight)

Creates a new UploadWebImageField.

Parameters:
name - the name of the form field. This value must not be a SQL reserved word and should follow all the standard variable naming conventions in PHP.
label - this form field's label. The label is the printable text that is typically displayed on the left side of the field.
required - Sets whether the field must be filled in and whether it looks like it must be filled in: FORM_FIELD_REQUIRED, FORM_FIELD_NOT_REQUIRED, FORM_FIELD_LOOKS_REQUIRED or FORM_FIELD_REQUIRED_NO_LOOK
maxFileSize - The max file size in bytes permitted. If this parameter is omitted or null, the max default size will be 2 MB.
uploadDir - The local path to the directory where this file should be uploaded. If this parameter is omitted or null, the file will be uploaded to the FORMfields/uploads directory.
uploadDirUrl - The URL to the directory where this file should be uploaded. If this parameter is omitted or null, the file will be uploaded to the FORMfields/uploads directory.
maxImageWidth - The maximum permitted width of an image or null if there isn't a max
maxImageHeight - The maximum permitted height of an image or null if there isn't a max
See Also:
FORM_FIELD_REQUIRED
FORM_FIELD_NOT_REQUIRED
FORM_FIELD_LOOKS_REQUIRED
FORM_FIELD_REQUIRED_NO_LOOK
Since:
FORMfields v3.0
Deprecated:
deprecated as this constructor syntax is not expected in PHP 5 - will be removed once PHP 5 becomes a minimum requirement for FORMfields

Method Detail

getImageTag

public string getImageTag(string alt)

Returns an HTML image tag for displaying the uploaded image.

Parameters:
alt - the value of the alt attribute in the image tag
Returns:
the HTML image tag for displaying the uploaded image
Since:
FORMfields v3.0

isValid

public boolean isValid()

Checks for field errors detected by this field, including a check for blank. This method checks for any errors that may have occured while trying to upload the file. It also checks for valid file extensions: "gif", "jpg", "jpeg" or "png". Moreover, it checks to make sure that the image width and height are within the specified range, if the range was specified. Upon a successful upload, this method copies the file to the uploads directory. If an error is detected, the setError() method is called to set the appropriate error message.

Returns:
true if there is an error or false otherwise
Since:
FORMfields v3.0

validImageExtension

public void validImageExtension(mixed ext)
Since:
FORMfields v3.0

FORMfields