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

Class: HTML_QuickForm2_Rule_MaxFileSize

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

Class Overview

HTML_QuickForm2_Rule
   |
   --HTML_QuickForm2_Rule_MaxFileSize

Rule checking that uploaded file size does not exceed the given limit


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 50]
Rule checking that uploaded file size does not exceed the given limit

The Rule needs one configuration parameter for its work: the size limit. This limit 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.

Note that if file upload failed due to upload_max_filesize php.ini setting or MAX_FILE_SIZE form field, then this rule won't even be called, due to File element's built-in validation setting the error message.

The Rule considers missing file uploads (UPLOAD_ERR_NO_FILE) valid.



[ Top ]


Method Detail

setConfig   [line 74]

HTML_QuickForm2_Rule setConfig( int $config)

Sets maximum allowed file size
  • Throws: HTML_QuickForm2_InvalidArgumentException if a bogus size limit was provided
  • Access: public

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

Parameters:

int   $config   —  Maximum allowed size

[ Top ]

setOwner   [line 93]

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 57]

bool validateOwner( )

Validates the owner element
  • Return: whether uploaded file's size is within given limit
  • 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.