web/lib/Zend/Form/Element/File.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    12  * obtain it through the world-wide-web, please send an email
    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.
    13  * to license@zend.com so we can send you a copy immediately.
    14  *
    14  *
    15  * @category   Zend
    15  * @category   Zend
    16  * @package    Zend_Form
    16  * @package    Zend_Form
    17  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    17  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    18  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    19  */
    19  */
    20 
    20 
    21 /** Zend_Form_Element_Xhtml */
    21 /** Zend_Form_Element_Xhtml */
    22 require_once 'Zend/Form/Element/Xhtml.php';
    22 require_once 'Zend/Form/Element/Xhtml.php';
    25  * Zend_Form_Element
    25  * Zend_Form_Element
    26  *
    26  *
    27  * @category   Zend
    27  * @category   Zend
    28  * @package    Zend_Form
    28  * @package    Zend_Form
    29  * @subpackage Element
    29  * @subpackage Element
    30  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    30  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    31  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    32  * @version    $Id: File.php 22371 2010-06-04 20:09:44Z thomas $
    32  * @version    $Id: File.php 25225 2013-01-17 15:59:16Z frosch $
    33  */
    33  */
    34 class Zend_Form_Element_File extends Zend_Form_Element_Xhtml
    34 class Zend_Form_Element_File extends Zend_Form_Element_Xhtml
    35 {
    35 {
    36     /**
    36     /**
    37      * Plugin loader type
    37      * Plugin loader type
    69     protected static $_maxFileSize = -1;
    69     protected static $_maxFileSize = -1;
    70 
    70 
    71     /**
    71     /**
    72      * Load default decorators
    72      * Load default decorators
    73      *
    73      *
    74      * @return void
    74      * @return Zend_Form_Element_File
    75      */
    75      */
    76     public function loadDefaultDecorators()
    76     public function loadDefaultDecorators()
    77     {
    77     {
    78         if ($this->loadDefaultDecoratorsIsDisabled()) {
    78         if ($this->loadDefaultDecoratorsIsDisabled()) {
    79             return $this;
    79             return $this;
   148         if (!empty($type) && ($type != self::TRANSFER_ADAPTER)) {
   148         if (!empty($type) && ($type != self::TRANSFER_ADAPTER)) {
   149             return parent::addPrefixPath($prefix, $path, $type);
   149             return parent::addPrefixPath($prefix, $path, $type);
   150         }
   150         }
   151 
   151 
   152         if (empty($type)) {
   152         if (empty($type)) {
   153             $pluginPrefix = rtrim($prefix, '_') . '_Transfer_Adapter';
   153             $nsSeparator = (false !== strpos($prefix, '\\'))?'\\':'_';
       
   154             $pluginPrefix = rtrim($prefix, $nsSeparator) . $nsSeparator . 'Transfer' . $nsSeparator . 'Adapter';
   154             $pluginPath   = rtrim($path, DIRECTORY_SEPARATOR) . '/Transfer/Adapter/';
   155             $pluginPath   = rtrim($path, DIRECTORY_SEPARATOR) . '/Transfer/Adapter/';
   155             $loader       = $this->getPluginLoader(self::TRANSFER_ADAPTER);
   156             $loader       = $this->getPluginLoader(self::TRANSFER_ADAPTER);
   156             $loader->addPrefixPath($pluginPrefix, $pluginPath);
   157             $loader->addPrefixPath($pluginPrefix, $pluginPath);
   157             return parent::addPrefixPath($prefix, $path, null);
   158             return parent::addPrefixPath($prefix, $path, null);
   158         }
   159         }
   428         if (!$this->isRequired()) {
   429         if (!$this->isRequired()) {
   429             $adapter->setOptions(array('ignoreNoFile' => true), $this->getName());
   430             $adapter->setOptions(array('ignoreNoFile' => true), $this->getName());
   430         } else {
   431         } else {
   431             $adapter->setOptions(array('ignoreNoFile' => false), $this->getName());
   432             $adapter->setOptions(array('ignoreNoFile' => false), $this->getName());
   432             if ($this->autoInsertNotEmptyValidator() && !$this->getValidator('NotEmpty')) {
   433             if ($this->autoInsertNotEmptyValidator() && !$this->getValidator('NotEmpty')) {
   433                 $this->addValidator = array('validator' => 'NotEmpty', 'breakChainOnFailure' => true);
   434                 $this->addValidator('NotEmpty', true);
   434             }
   435             }
   435         }
   436         }
   436 
   437 
   437         if($adapter->isValid($this->getName())) {
   438         if($adapter->isValid($this->getName())) {
   438             $this->_validated = true;
   439             $this->_validated = true;