equal
deleted
inserted
replaced
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-2012 Zend Technologies USA Inc. (http://www.zend.com) |
17 * @copyright Copyright (c) 2005-2015 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-2012 Zend Technologies USA Inc. (http://www.zend.com) |
30 * @copyright Copyright (c) 2005-2015 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 25225 2013-01-17 15:59:16Z frosch $ |
32 * @version $Id$ |
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 |
77 { |
77 { |
78 if ($this->loadDefaultDecoratorsIsDisabled()) { |
78 if ($this->loadDefaultDecoratorsIsDisabled()) { |
79 return $this; |
79 return $this; |
80 } |
80 } |
81 |
81 |
82 $decorators = $this->getDecorators(); |
82 parent::loadDefaultDecorators(); |
83 if (empty($decorators)) { |
83 |
84 $this->addDecorator('File') |
84 // This element needs the File decorator and not the ViewHelper decorator |
85 ->addDecorator('Errors') |
85 if (false !== $this->getDecorator('ViewHelper')) { |
86 ->addDecorator('Description', array('tag' => 'p', 'class' => 'description')) |
86 $this->removeDecorator('ViewHelper'); |
87 ->addDecorator('HtmlTag', array('tag' => 'dd')) |
87 } |
88 ->addDecorator('Label', array('tag' => 'dt')); |
88 if (false === $this->getDecorator('File')) { |
89 } |
89 // Add File decorator to the beginning |
|
90 $decorators = $this->getDecorators(); |
|
91 array_unshift($decorators, 'File'); |
|
92 $this->setDecorators($decorators); |
|
93 } |
|
94 |
90 return $this; |
95 return $this; |
91 } |
96 } |
92 |
97 |
93 /** |
98 /** |
94 * Set plugin loader |
99 * Set plugin loader |
166 /** |
171 /** |
167 * Set transfer adapter |
172 * Set transfer adapter |
168 * |
173 * |
169 * @param string|Zend_File_Transfer_Adapter_Abstract $adapter |
174 * @param string|Zend_File_Transfer_Adapter_Abstract $adapter |
170 * @return Zend_Form_Element_File |
175 * @return Zend_Form_Element_File |
|
176 * @throws Zend_Form_Element_Exception |
171 */ |
177 */ |
172 public function setTransferAdapter($adapter) |
178 public function setTransferAdapter($adapter) |
173 { |
179 { |
174 if ($adapter instanceof Zend_File_Transfer_Adapter_Abstract) { |
180 if ($adapter instanceof Zend_File_Transfer_Adapter_Abstract) { |
175 $this->_adapter = $adapter; |
181 $this->_adapter = $adapter; |
339 } |
345 } |
340 |
346 |
341 /** |
347 /** |
342 * Sets a filter for the class, erasing all previous set; proxy to adapter |
348 * Sets a filter for the class, erasing all previous set; proxy to adapter |
343 * |
349 * |
344 * @param string|array $filter Filter to set |
350 * @param array $filters Filters to set |
345 * @return Zend_Form_Element_File |
351 * @return Zend_Form_Element_File |
346 */ |
352 */ |
347 public function setFilters(array $filters) |
353 public function setFilters(array $filters) |
348 { |
354 { |
349 $adapter = $this->getTransferAdapter(); |
355 $adapter = $this->getTransferAdapter(); |
854 * Render form element |
860 * Render form element |
855 * Checks for decorator interface to prevent errors |
861 * Checks for decorator interface to prevent errors |
856 * |
862 * |
857 * @param Zend_View_Interface $view |
863 * @param Zend_View_Interface $view |
858 * @return string |
864 * @return string |
|
865 * @throws Zend_Form_Element_Exception |
859 */ |
866 */ |
860 public function render(Zend_View_Interface $view = null) |
867 public function render(Zend_View_Interface $view = null) |
861 { |
868 { |
862 $marker = false; |
869 $marker = false; |
863 foreach ($this->getDecorators() as $decorator) { |
870 foreach ($this->getDecorators() as $decorator) { |