HTML_QuickForm2
[ class tree: HTML_QuickForm2 ] [ index: HTML_QuickForm2 ] [ all elements ]

Class: HTML_QuickForm2_Rule_MimeType

Source Location: /HTML_QuickForm2-2.1.0/HTML/QuickForm2/Rule/MimeType.php

Class Overview

HTML_QuickForm2_Rule
   |
   --HTML_QuickForm2_Rule_MimeType

Rule checking that uploaded file is of the correct MIME type


Author(s):

Version:

  • Release: 2.1.0

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Rule

HTML_QuickForm2_Rule::__construct()
Class constructor
HTML_QuickForm2_Rule::and_()
Adds a rule to the chain with an "and" operator
HTML_QuickForm2_Rule::getConfig()
Returns the rule's configuration data
HTML_QuickForm2_Rule::getJavascript()
Returns the client-side representation of the Rule
HTML_QuickForm2_Rule::getJavascriptCallback()
Returns the client-side validation callback
HTML_QuickForm2_Rule::getJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::getMessage()
Returns the error message output by the rule
HTML_QuickForm2_Rule::getOwnJavascriptTriggers()
Returns IDs of form fields that should trigger "live" Javascript validation
HTML_QuickForm2_Rule::mergeConfig()
Merges local configuration with that provided for registerRule()
HTML_QuickForm2_Rule::or_()
Adds a rule to the chain with an "or" operator
HTML_QuickForm2_Rule::setConfig()
Sets configuration data for the rule
HTML_QuickForm2_Rule::setMessage()
Sets the error message output by the rule
HTML_QuickForm2_Rule::setOwner()
Sets the element that will be validated by this rule
HTML_QuickForm2_Rule::setOwnerError()
Sets the error message on the owner element
HTML_QuickForm2_Rule::validate()
Performs validation
HTML_QuickForm2_Rule::validateOwner()
Validates the owner element

Class Details

[line 46]
Rule checking that uploaded file is of the correct MIME type

The Rule needs one configuration parameter for its work: a string with a desired MIME type or array of such strings. This parameter can be passed either to the Rule constructor as local configuration or to HTML_QuickForm2_Factory::registerRule() as global one. As usual, global configuration overrides local one.

The Rule considers missing file uploads (UPLOAD_ERR_NO_FILE) valid.



[ Top ]


Method Detail

setConfig   [line 72]

HTML_QuickForm2_Rule setConfig( string|array $config)

Sets allowed MIME type(s) for the uploaded file
  • Throws: HTML_QuickForm2_InvalidArgumentException if bogus configuration provided
  • Access: public

Overrides HTML_QuickForm2_Rule::setConfig() (Sets configuration data for the rule)

Parameters:

string|array   $config   —  Allowed MIME type or an array of types

[ Top ]

setOwner   [line 91]

void setOwner( HTML_QuickForm2_Node $owner)

Sets the element that will be validated by this rule
  • Throws: HTML_QuickForm2_InvalidArgumentException if trying to use this Rule on something that isn't a file upload field
  • Access: public

Overrides HTML_QuickForm2_Rule::setOwner() (Sets the element that will be validated by this rule)

Parameters:

HTML_QuickForm2_Node   $owner   —  File upload field to validate

[ Top ]

validateOwner   [line 53]

bool validateOwner( )

Validates the owner element
  • Return: whether uploaded file's MIME type is correct
  • Access: protected

Overrides HTML_QuickForm2_Rule::validateOwner() (Validates the owner element)
[ Top ]


Documentation generated on Wed, 10 Apr 2019 08:56:10 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.