|
Class: MailForm
Source Location: Program_Root/MailForm/MailForm.php
MailForm provides methods for generating, validating, and handling web
Author(s)
Version
- 4.0, 2004-01-29, $Id: MailForm.php,v 1.14 2007/01/17 21:08:26 lux Exp $
Copyright
- Copyright (C) 2001-2003, Simian Systems Inc.
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
$action =
[line 300]
The value of the action attribute of the HTML form tag. $action is actually an alias for $_attrs['action'].
Tags:
$blacklist = true
[line 495]
Whether to verify the remote address of the form submitter against a list of invalid IP addresses in the database table sitellite_form_blacklist so as to prevent repeated abuse from a single source.
Tags:
$clean_input = false
[line 484]
Whether to strip all HTML and PHP tags/code from all input parameters. This is off by default because it would break forms with the Xed editor by default, so it must be enabled as needed. Note that this can be enabled in a form's settings file under the [Form] block via: clean_input = yes
Tags:
$error_message =
[line 352]
Contains the message from any internal errors.
Tags:
$error_mode = 'single'
[line 365]
Determines the way in which error messages are displayed. The default ('single') is to display the error message for the first invalid field only. The other ('all') is to display a list of all invalid fields with their corresponding error messages. Please note that $error_mode 'all' assumes that a custom error message is provided for every rule.
Tags:
$extra =
[line 344]
A way to pass extra parameters to the HTML form tag, for example 'enctype="multipart/formdata"'. Notice: This property is deprecated in favour of the $_attrs list and the attr() and unset() methods.
Tags:
$handler =
[line 452]
The function or object method to use to handle the submitted form. This function or method will be called by the run() method. Use the setHandler() method to change this setting.
Tags:
$invalid = array ()
[line 374]
A list of all invalid fields in the form, and their corresponding error messages.
Tags:
$invalid_field = ''
[line 282]
Contains the name of the widget that did not validate during the last call to the invalid () method.
Tags:
$message =
[line 333]
The initial message to be displayed at the top of the form.
Tags:
$method =
[line 291]
The value of the method attribute of the HTML form tag. $method is actually an alias for $_attrs['method'].
Tags:
$name =
[line 393]
The name of this form. Optional. $name is actually an alias for $_attrs['name'].
Tags:
$screenReply = 'Thank you. Your form has been sent.'
[line 442]
The response to return upon a successfully submitted form in the default handler. Defaults to "Thank you. Your form has been sent."
Tags:
$sendExtra = ''
[line 425]
Any extra parameters for the mail() function in the default handler.
Tags:
$sendFrom = ''
[line 417]
The email address to send the form from in the default handler.
Tags:
$sendSubject = 'Mail Form'
[line 433]
The subject line of the email to send from the default handler.
Tags:
$sendTo =
[line 409]
The email address to send the form to in the default handler.
Tags:
$template =
[line 317]
The optional template file or data used to customize the look of the form.
Tags:
$title =
[line 325]
The title to be displayed at the top of the form.
Tags:
$uploadFiles = true
[line 461]
Whether to upload files automatically or to leave them for a custom saving mechanism.
Tags:
$verify_sender = false
[line 472]
Whether to verify the REQUEST_METHOD and HTTP_REFERER headers to make it more difficult (although not impossible) for spammers to abuse your form. Note that this can be enabled in a form's settings file under the [Form] block via: verify_sender = yes
Tags:
$verify_session = true
[line 511]
Whether to verify that the submitter can accept session data, which helps ensure they are a legitimate human user. Passing session verification requires cookies to be enabled for the submitter, which may help prevent abuse in combination with the other abuse-prevention techniques because a spambot may ignore the cookie, however this restricts forms for legitimate visitors who have cookies disabled in their browser (only a very small number of users disable cookies, but some do). To disable for a single form, add verify_session = no to its settings.php form.
Tags:
$widgets = array ()
[line 308]
An array of form widgets.
Tags:
Class Methods
constructor MailForm [line 523]
MailForm MailForm(
[string
$action = ''], [string
$method = 'post'])
|
|
Constructor Method. Action will be set to $PHP_SELF if it is empty, unless a global $site object is defined in which case the action with be $site->url . $PHP_SELF.
Tags:
Parameters:
method addWidget [line 579]
object reference &addWidget(
string
$type, string
$name)
|
|
Adds another widget to the form. If the $type is specified as a loader path, it will import from the proper location outside of saf.MailForm.Widget.*, and if you send an object as the $type value addWidget() will use that object as the widget (so make sure it is one!), as of version 3.8.
Tags:
Parameters:
method attr [line 1328]
string attr(
string
$key, [mixed
$value = false])
|
|
This is the accessor method for setting and getting the value of any attribute of the form tag, including 'method' and 'action'. This will replace the $extra property, which is henceforth deprecated. If you call this method and provide no $value, you are using it as a 'getter', as in you are getting the current value. If you provide a value, the new value will be set, so you are acting as a 'setter'. If you simply specify that the $value be true, then it will appear filled with its own name (useful for things like the checked="checked" attribute of a checkbox input field, even though this isn't a checkbox field).
Tags:
Parameters:
method createWidget [line 1160]
void &createWidget(
string
$name, array
$data)
|
|
Creates a widget from a name and an array, usually taken from a parsed settings.php (ini formatted) file.
Tags:
Parameters:
method formatEmail [line 1080]
void formatEmail(
mixed
$vals)
|
|
method getAttrs [line 1363]
Returns a list of all of the attributes of this object's form tag in a string ready to be concatenated into the actual rendered tag output.
Tags:
method getValues [line 875]
associative getValues(
boolean
$uploadFiles)
|
|
Returns the form values as an associative array. If $uploadFiles is set to true, it will return the saved path or false for file widgets, otherwise it will return the saf.CGI.UploadedFile object and not act on the object for you.
Tags:
Parameters:
method handle [line 1038]
boolean handle(
string
$email, [string
$subject = 'Mail Form'], [string
$from_field = ''], [string
$extra = ''])
|
|
Note: Deprecated in favour of the setHandler() and run() methods and subclassing. Handles the form, once it has been satisfactorily completed. If the first parameter points to a file (ie. 'inc/forms/contact.php'), it will use that file as an "action file" to handle the form. Otherwise, the first parameter must be an email address, as handle () will simply send an email of the form contents to the specified email address. Note: Extra will be passed to the PHP mail () function as a fourth parameter, or can be used for any purpose you'd like in an action file.
Tags:
Parameters:
method invalid [line 608]
Validates the form values against a global $cgi object. Used in the logic of "if the form is invalid then...". Also sets an internal $invalid_field property. Returns true if the form is invalid or has not been filled out yet. If the form passes (false returned), it also sets the $submitted value to true.
Tags:
method makeAssoc [line 1283]
associative makeAssoc(
array
$list)
|
|
Takes a non-associative array and creates an associative array out of its values. This is used to send non-associative arrays to the setValues() method of the Widget objects.
Tags:
Parameters:
method onSubmit [line 976]
string onSubmit(
array
$vals)
|
|
This is the default handler function. It is called via run() and can be overridden via subclassing.
Tags:
Parameters:
method parseSettings [line 1115]
boolean parseSettings(
string
$file)
|
|
Parses the specified file using the parse_ini_file() function. Sections in the file correspond to the names of widgets you wish to create, in addition to a [Form] section that sets properties for the form itself. The values in each section correspond to properties or methods of the widgets. This method can be used to simplify the process of defining and customizing a form.
Tags:
Parameters:
method rememberFields [line 1305]
void rememberFields(
array
$list)
|
|
Takes a non-associative array listing the names of each field from $cgi you want to "remember", and creates hidden fields for each of them, so you don't have to hard-code lists of hidden fields in multi-screen forms.
Tags:
Parameters:
method run [line 928]
string run(
[boolean
$uploadFiles = true])
|
|
Runs the form and returns either the rendered form or the output of the handler function. $uploadFiles can be set to false to cause the getValues() method not to call move() on File widgets. This is useful for situations when you need to do something other than simply save the file to a predetermined folder. Please note: The $uploadFiles parameter is deprecated in favour of the $uploadFiles property of the MailForm class. This allows the setting to be managed via a settings.php file.
Tags:
Parameters:
method setHandler [line 910]
void setHandler(
mixed
$func)
|
|
Sets the function to use to handle the output of the current form. To specify a method of an object, pass it an array with an object reference as the first element and the method name as the second. The default handler is the internal onSubmit(). The handler is called using call_user_func() in the run() method.
Tags:
Parameters:
method setValues [line 699]
void setValues(
object
$cgi, [boolean
$invalid = false])
|
|
Sets the values of the form widgets from a provided CGI object. The second parameter is deprecated.
Tags:
Parameters:
method show [line 736]
string show(
[string
$template = ''])
|
|
Generates the HTML form. You can provide an optional template to customize the look of the form. Template directives (ie. ##field##) must be provided for each form widget, as well as ##mailform_action## and ##mailform_method##, which correspond to the action and method attributes of the HTML form tag.
Tags:
Parameters:
method unsetAttr [line 1349]
string unsetAttr(
string
$key)
|
|
Use this method to remove an attribute from the form tag attribute list. Use this instead of passing a false value to attr(), because a false value essentially means "return the current value" in that method. This method returns the old value of the attribute being unset.
Tags:
Parameters:
method verifyReferer [line 1384]
method verifyRequestMethod [line 1377]
void verifyRequestMethod(
)
|
|
|
|