web/lib/Zend/View/Helper/FormFile.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_View
       
    17  * @subpackage Helper
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: FormFile.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 
       
    24 /**
       
    25  * Abstract class for extension
       
    26  */
       
    27 require_once 'Zend/View/Helper/FormElement.php';
       
    28 
       
    29 
       
    30 /**
       
    31  * Helper to generate a "file" element
       
    32  *
       
    33  * @category   Zend
       
    34  * @package    Zend_View
       
    35  * @subpackage Helper
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_View_Helper_FormFile extends Zend_View_Helper_FormElement
       
    40 {
       
    41     /**
       
    42      * Generates a 'file' element.
       
    43      *
       
    44      * @access public
       
    45      *
       
    46      * @param string|array $name If a string, the element name.  If an
       
    47      * array, all other parameters are ignored, and the array elements
       
    48      * are extracted in place of added parameters.
       
    49      *
       
    50      * @param array $attribs Attributes for the element tag.
       
    51      *
       
    52      * @return string The element XHTML.
       
    53      */
       
    54     public function formFile($name, $attribs = null)
       
    55     {
       
    56         $info = $this->_getInfo($name, null, $attribs);
       
    57         extract($info); // name, id, value, attribs, options, listsep, disable
       
    58 
       
    59         // is it disabled?
       
    60         $disabled = '';
       
    61         if ($disable) {
       
    62             $disabled = ' disabled="disabled"';
       
    63         }
       
    64 
       
    65         // XHTML or HTML end tag?
       
    66         $endTag = ' />';
       
    67         if (($this->view instanceof Zend_View_Abstract) && !$this->view->doctype()->isXhtml()) {
       
    68             $endTag= '>';
       
    69         }
       
    70 
       
    71         // build the element
       
    72         $xhtml = '<input type="file"'
       
    73                 . ' name="' . $this->view->escape($name) . '"'
       
    74                 . ' id="' . $this->view->escape($id) . '"'
       
    75                 . $disabled
       
    76                 . $this->_htmlAttribs($attribs)
       
    77                 . $endTag;
       
    78 
       
    79         return $xhtml;
       
    80     }
       
    81 }