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

Class: HTML_QuickForm2_Element_InputFile

Source Location: /HTML_QuickForm2-0.2.0/QuickForm2/Element/InputFile.php

Class Overview

HTML_Common2
   |
   --HTML_QuickForm2_Node
      |
      --HTML_QuickForm2_Element
         |
         --HTML_QuickForm2_Element_Input
            |
            --HTML_QuickForm2_Element_InputFile

Class for <input type="file" /> elements


Author(s):

Version:

  • Release: 0.2.0

Variables

Methods


Inherited Variables

Inherited Methods

Class: HTML_QuickForm2_Element_Input

HTML_QuickForm2_Element_Input::getFrozenHtml()
Returns the field's value without HTML tags
HTML_QuickForm2_Element_Input::getType()
HTML_QuickForm2_Element_Input::getValue()
HTML_QuickForm2_Element_Input::onAttributeChange()
HTML_QuickForm2_Element_Input::setValue()
HTML_QuickForm2_Element_Input::__toString()

Class: HTML_QuickForm2_Element

HTML_QuickForm2_Element::getId()
HTML_QuickForm2_Element::getName()
HTML_QuickForm2_Element::getPersistentContent()
Generates hidden form field containing the element's value
HTML_QuickForm2_Element::onAttributeChange()
HTML_QuickForm2_Element::setId()
HTML_QuickForm2_Element::setName()
HTML_QuickForm2_Element::updateValue()
Called when the element needs to update its value from form's data sources

Class: HTML_QuickForm2_Node

HTML_QuickForm2_Node::__construct()
Class constructor
HTML_QuickForm2_Node::addRule()
Adds a validation rule
HTML_QuickForm2_Node::createRule()
Creates a validation rule
HTML_QuickForm2_Node::generateId()
Generates an id for the element
HTML_QuickForm2_Node::getContainer()
Returns the element containing current
HTML_QuickForm2_Node::getDataSources()
Returns the data sources for this element
HTML_QuickForm2_Node::getError()
Returns the error message for the element
HTML_QuickForm2_Node::getId()
Returns the element's id
HTML_QuickForm2_Node::getLabel()
Returns the element's label(s)
HTML_QuickForm2_Node::getName()
Returns the element's name
HTML_QuickForm2_Node::getType()
Returns the element's type
HTML_QuickForm2_Node::getValue()
Returns the element's value
HTML_QuickForm2_Node::isRequired()
Checks whether an element is required
HTML_QuickForm2_Node::persistentFreeze()
Changes the element's persistent freeze behaviour
HTML_QuickForm2_Node::setContainer()
Adds the link to the element containing current
HTML_QuickForm2_Node::setError()
Sets the error message to the element
HTML_QuickForm2_Node::setId()
Sets the elements id
HTML_QuickForm2_Node::setLabel()
Sets the element's label(s)
HTML_QuickForm2_Node::setName()
Sets the element's name
HTML_QuickForm2_Node::setValue()
Sets the element's value
HTML_QuickForm2_Node::storeId()
Stores the explicitly given id to prevent duplicate id generation
HTML_QuickForm2_Node::toggleFrozen()
Changes the element's frozen status
HTML_QuickForm2_Node::updateValue()
Called when the element needs to update its value from form's data sources
HTML_QuickForm2_Node::validate()
Performs the server-side validation

Class Details

[line 60]
Class for <input type="file" /> elements


[ Top ]


Class Variables

$attributes = array('type' => 'file')

[line 110]

  • Access: protected

Type:   mixed


[ Top ]

$errorMessages = array(
        'en' => array(
            UPLOAD_ERR_INI_SIZE   => 'The uploaded file exceeds size permitted by PHP configuration (%d bytes)',
            UPLOAD_ERR_FORM_SIZE  => 'The uploaded file exceeds the MAX_FILE_SIZE directive in HTML form (%d bytes)',
            UPLOAD_ERR_PARTIAL    => 'The file was only partially uploaded',
            UPLOAD_ERR_NO_TMP_DIR => 'Server error: temporary directory is missing',
            UPLOAD_ERR_CANT_WRITE => 'Server error: failed to write the file to disk',
            UPLOAD_ERR_EXTENSION  => 'File upload was stopped by extension'
        ),'fr'=>array(UPLOAD_ERR_INI_SIZE=>'Le fichier envoy&eacute; exc&egrave;de la taille autoris&eacute;e par la configuration de PHP (%d octets)',UPLOAD_ERR_FORM_SIZE=>'Le fichier envoy&eacute; exc&egrave;de la taille de MAX_FILE_SIZE sp&eacute;cifi&eacute;e dans le formulaire HTML (%d octets)',UPLOAD_ERR_PARTIAL=>'Le fichier n\'a &eacute;t&eacute; que partiellement t&eacute;l&eacute;charg&eacute;',UPLOAD_ERR_NO_TMP_DIR=>'Erreur serveur: le r&eacute;pertoire temporaire est manquant',UPLOAD_ERR_CANT_WRITE=>'Erreur serveur: &eacute;chec de l\'&eacute;criture du fichier sur le disque',UPLOAD_ERR_EXTENSION=>'L\'envoi de fichier est arr&ecirc;t&eacute; par l\'extension'),'ru'=>array(UPLOAD_ERR_INI_SIZE=>'&#x420;&#x430;&#x437;&#x43c;&#x435;&#x440; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d;&#x43d;&#x43e;&#x433;&#x43e; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x43f;&#x440;&#x435;&#x432;&#x43e;&#x441;&#x445;&#x43e;&#x434;&#x438;&#x442; &#x43c;&#x430;&#x43a;&#x441;&#x438;&#x43c;&#x430;&#x43b;&#x44c;&#x43d;&#x43e; &#x440;&#x430;&#x437;&#x440;&#x435;&#x448;&#x451;&#x43d;&#x43d;&#x44b;&#x439; &#x43d;&#x430;&#x441;&#x442;&#x440;&#x43e;&#x439;&#x43a;&#x430;&#x43c;&#x438; PHP (%d &#x431;&#x430;&#x439;&#x442;)',UPLOAD_ERR_FORM_SIZE=>'&#x420;&#x430;&#x437;&#x43c;&#x435;&#x440; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d;&#x43d;&#x43e;&#x433;&#x43e; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x43f;&#x440;&#x435;&#x432;&#x43e;&#x441;&#x445;&#x43e;&#x434;&#x438;&#x442; &#x434;&#x438;&#x440;&#x435;&#x43a;&#x442;&#x438;&#x432;&#x443; MAX_FILE_SIZE, &#x443;&#x43a;&#x430;&#x437;&#x430;&#x43d;&#x43d;&#x443;&#x44e; &#x432; &#x444;&#x43e;&#x440;&#x43c;&#x435; (%d &#x431;&#x430;&#x439;&#x442;)',UPLOAD_ERR_PARTIAL=>'&#x424;&#x430;&#x439;&#x43b; &#x431;&#x44b;&#x43b; &#x437;&#x430;&#x433;&#x440;&#x443;&#x436;&#x435;&#x43d; &#x43d;&#x435; &#x43f;&#x43e;&#x43b;&#x43d;&#x43e;&#x441;&#x442;&#x44c;&#x44e;',UPLOAD_ERR_NO_TMP_DIR=>'&#x41e;&#x448;&#x438;&#x431;&#x43a;&#x430; &#x43d;&#x430; &#x441;&#x435;&#x440;&#x432;&#x435;&#x440;&#x435;: &#x43e;&#x442;&#x441;&#x443;&#x442;&#x441;&#x442;&#x432;&#x443;&#x435;&#x442; &#x43a;&#x430;&#x442;&#x430;&#x43b;&#x43e;&#x433; &#x434;&#x43b;&#x44f; &#x432;&#x440;&#x435;&#x43c;&#x435;&#x43d;&#x43d;&#x44b;&#x445; &#x444;&#x430;&#x439;&#x43b;&#x43e;&#x432;',UPLOAD_ERR_CANT_WRITE=>'&#x41e;&#x448;&#x438;&#x431;&#x43a;&#x430; &#x43d;&#x430; &#x441;&#x435;&#x440;&#x432;&#x435;&#x440;&#x435;: &#x43d;&#x435; &#x443;&#x434;&#x430;&#x43b;&#x43e;&#x441;&#x44c; &#x437;&#x430;&#x43f;&#x438;&#x441;&#x430;&#x442;&#x44c; &#x444;&#x430;&#x439;&#x43b; &#x43d;&#x430; &#x434;&#x438;&#x441;&#x43a;',UPLOAD_ERR_EXTENSION=>'&#x417;&#x430;&#x433;&#x440;&#x443;&#x437;&#x43a;&#x430; &#x444;&#x430;&#x439;&#x43b;&#x430; &#x431;&#x44b;&#x43b;&#x430; &#x43e;&#x441;&#x442;&#x430;&#x43d;&#x43e;&#x432;&#x43b;&#x435;&#x43d;&#x430; &#x440;&#x430;&#x441;&#x448;&#x438;&#x440;&#x435;&#x43d;&#x438;&#x435;&#x43c;'))

[line 71]

Localized error messages for PHP's file upload errors
  • Access: protected

Type:   array


[ Top ]

$language =

[line 102]

Language to display error messages in
  • Access: protected

Type:   string


[ Top ]

$value =  null

[line 108]

Information on uploaded file, from submit data source
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 142]

HTML_QuickForm2_Element_InputFile __construct( [string $name = null], [mixed $attributes = null], [array $data = array()])

Class constructor

Possible keys in $data array are:

  • 'language': language to display error messages in, it should either be already available in the class or provided in 'errorMessages'
  • 'errorMessages': an array of error messages with the following format
          'language code 1' => array(
             UPLOAD_ERR_... => 'message',
             ...
             UPLOAD_ERR_... => 'message'
          ),
          ...
          'language code N' => array(
             ...
          )
    Note that error messages for UPLOAD_ERR_INI_SIZE and UPLOAD_ERR_FORM_SIZE may contain '%d' placeholders that will be automatically replaced by the appropriate size limits. Note also that you don't need to provide messages for every possible error code in the arrays, you may e.g. override just one error message for a particular language.

  • Access: public

Overrides HTML_QuickForm2_Node::__construct() (Class constructor)

Parameters:

string   $name   —  Element name
mixed   $attributes   —  Attributes (either a string or an array)
array   $data   —  Data used to set up error messages for PHP's file upload errors.

[ Top ]

getValue   [line 185]

array|null getValue( )

Returns the information on uploaded file
  • Access: public

Overrides HTML_QuickForm2_Element_Input::getValue() (parent method not documented)
[ Top ]

setValue   [line 196]

HTML_QuickForm2_Element_InputFile setValue( mixed $value)

File upload's value cannot be set here
  • Access: public

Overrides HTML_QuickForm2_Element_Input::setValue() (parent method not documented)

Parameters:

mixed   $value   —  Value for file element, this parameter is ignored

[ Top ]

toggleFrozen   [line 175]

bool toggleFrozen( [bool $freeze = null])

File upload elements cannot be frozen

To properly "freeze" a file upload element one has to store the uploaded file somewhere and store the file info in session. This is way outside the scope of this class.

  • Return: Always returns false
  • Access: public

Overrides HTML_QuickForm2_Node::toggleFrozen() (Changes the element's frozen status)

Parameters:

bool   $freeze   —  Whether element should be frozen or editable. This parameter is ignored in case of file uploads

[ Top ]

updateValue   [line 201]

void updateValue( )

  • Access: protected

Overrides HTML_QuickForm2_Element::updateValue() (Called when the element needs to update its value from form's data sources)
[ Top ]

validate   [line 225]

boolean validate( )

Performs the server-side validation

Before the Rules added to the element kick in, the element checks the error code added to the $_FILES array by PHP. If the code isn't UPLOAD_ERR_OK or UPLOAD_ERR_NO_FILE then a built-in error message will be displayed and no further validation will take place.

  • Return: Whether the element is valid
  • Access: protected

Overrides HTML_QuickForm2_Node::validate() (Performs the server-side validation)
[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:10:21 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.