2
0
Просмотр исходного кода

[ZF-5145] Zend_File_Count:

- fixed spelling

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18683 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 лет назад
Родитель
Сommit
c5c236bd22

+ 47 - 1
documentation/manual/en/ref/migration-110.xml

@@ -10,6 +10,52 @@
 
     <sect2 id="migration.110.zend.file.transfer">
         <title>Zend_File_Transfer</title>
+        <sect3 id="migration.110.zend.file.transfer.count">
+            <title>Count validation</title>
+
+            <para>
+                Before release 1.10 the <classname>MimeType</classname> validator used a wrong
+                naming. For consistency the following constants have been changed:
+            </para>
+
+            <table id="migration.110.zend.file.transfer.count.table">
+                <title>Changed Validation Messages</title>
+                <tgroup cols="4">
+                    <thead>
+                        <row>
+                            <entry>Old</entry>
+                            <entry>New</entry>
+                            <entry>Value</entry>
+                        </row>
+                    </thead>
+
+                    <tbody>
+                        <row>
+                            <entry><constant>TOO_MUCH</constant></entry>
+                            <entry><constant>TOO_MANY</constant></entry>
+                            <entry>
+                                Too many files, maximum '%max%' are allowed but '%count%' are given
+                            </entry>
+                        </row>
+
+                        <row>
+                            <entry><constant>TOO_LESS</constant></entry>
+                            <entry><constant>TOO_FEW</constant></entry>
+                            <entry>
+                                Too few files, minimum '%min%' are expected but '%count%' are given
+                            </entry>
+                        </row>
+                    </tbody>
+                </tgroup>
+            </table>
+
+            <para>
+                When you are translating these messages within your code then use the new constants.
+                As benefit you don't need to translate the original string anymore to get a correct
+                spelling.
+            </para>
+        </sect3>
+
         <sect3 id="migration.110.zend.file.transfer.mimetype">
             <title>MimeType validation</title>
 
@@ -48,7 +94,7 @@ $valid = new Zend_File_Transfer_Adapter_Http(array('headerCheck' => true);
 // or afterwards
 $valid->enableHeaderCheck();
 ]]></programlisting>
-        </example>
+            </example>
         </sect3>
     </sect2>
 

+ 8 - 8
library/Zend/Validate/File/Count.php

@@ -37,16 +37,16 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract
     /**#@+
      * @const string Error constants
      */
-    const TOO_MUCH = 'fileCountTooMuch';
-    const TOO_LESS = 'fileCountTooLess';
+    const TOO_MANY = 'fileCountTooMany';
+    const TOO_FEW  = 'fileCountTooFew';
     /**#@-*/
 
     /**
      * @var array Error message templates
      */
     protected $_messageTemplates = array(
-        self::TOO_MUCH => "Too much files, maximum '%max%' are allowed but '%count%' are given",
-        self::TOO_LESS => "Too less files, minimum '%min%' are expected but '%count%' are given"
+        self::TOO_MANY => "Too many files, maximum '%max%' are allowed but '%count%' are given",
+        self::TOO_FEW  => "Too few files, minimum '%min%' are expected but '%count%' are given"
     );
 
     /**
@@ -241,22 +241,22 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract
      */
     public function isValid($value, $file = null)
     {
-        if (!array_key_exists('destination', $file)) {
+        if (($file !== null) && !array_key_exists('destination', $file)) {
             $file['destination'] = dirname($value);
         }
 
-        if (array_key_exists('tmp_name', $file)) {
+        if (($file !== null) && array_key_exists('tmp_name', $file)) {
             $value = $file['destination'] . DIRECTORY_SEPARATOR . $file['name'];
         }
 
         $this->addFile($value);
         $this->_count = count($this->_files);
         if (($this->_max !== null) && ($this->_count > $this->_max)) {
-            return $this->_throw($file, self::TOO_MUCH);
+            return $this->_throw($file, self::TOO_MANY);
         }
 
         if (($this->_min !== null) && ($this->_count < $this->_min)) {
-            return $this->_throw($file, self::TOO_LESS);
+            return $this->_throw($file, self::TOO_FEW);
         }
 
         return true;