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_Validate |
16 * @package Zend_Validate |
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 * @version $Id: Extension.php 24593 2012-01-05 20:35:02Z matthew $ |
19 * @version $Id$ |
20 */ |
20 */ |
21 |
21 |
22 /** |
22 /** |
23 * @see Zend_Validate_Abstract |
23 * @see Zend_Validate_Abstract |
24 */ |
24 */ |
27 /** |
27 /** |
28 * Validator for the file extension of a file |
28 * Validator for the file extension of a file |
29 * |
29 * |
30 * @category Zend |
30 * @category Zend |
31 * @package Zend_Validate |
31 * @package Zend_Validate |
32 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) |
32 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) |
33 * @license http://framework.zend.com/license/new-bsd New BSD License |
33 * @license http://framework.zend.com/license/new-bsd New BSD License |
34 */ |
34 */ |
35 class Zend_Validate_File_Extension extends Zend_Validate_Abstract |
35 class Zend_Validate_File_Extension extends Zend_Validate_Abstract |
36 { |
36 { |
37 /** |
37 /** |
69 ); |
69 ); |
70 |
70 |
71 /** |
71 /** |
72 * Sets validator options |
72 * Sets validator options |
73 * |
73 * |
74 * @param string|array|Zend_Config $options |
74 * @param string|array|Zend_Config $options |
75 * @return void |
|
76 */ |
75 */ |
77 public function __construct($options) |
76 public function __construct($options) |
78 { |
77 { |
79 if ($options instanceof Zend_Config) { |
78 if ($options instanceof Zend_Config) { |
80 $options = $options->toArray(); |
79 $options = $options->toArray(); |
194 |
193 |
195 if ($file !== null) { |
194 if ($file !== null) { |
196 $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1); |
195 $info['extension'] = substr($file['name'], strrpos($file['name'], '.') + 1); |
197 } else { |
196 } else { |
198 $info = pathinfo($value); |
197 $info = pathinfo($value); |
|
198 if (!array_key_exists('extension', $info)) { |
|
199 // From the manual at http://php.net/pathinfo: |
|
200 // "If the path does not have an extension, no extension element |
|
201 // will be returned (see second example below)." |
|
202 return false; |
|
203 } |
199 } |
204 } |
200 |
205 |
201 $extensions = $this->getExtension(); |
206 $extensions = $this->getExtension(); |
202 |
207 |
203 if ($this->_case && (in_array($info['extension'], $extensions))) { |
208 if ($this->_case && (in_array($info['extension'], $extensions))) { |