Adding hlist module to mediawiki
[lhc/web/wiklou.git] / includes / media / MediaHandler.php
old mode 100644 (file)
new mode 100755 (executable)
index 779e23c..ddb8efd
@@ -187,6 +187,43 @@ abstract class MediaHandler {
                return self::METADATA_GOOD;
        }
 
+       /**
+        * Get an array of standard (FormatMetadata type) metadata values.
+        *
+        * The returned data is largely the same as that from getMetadata(),
+        * but formatted in a standard, stable, handler-independent way.
+        * The idea being that some values like ImageDescription or Artist
+        * are universal and should be retrievable in a handler generic way.
+        *
+        * The specific properties are the type of properties that can be
+        * handled by the FormatMetadata class. These values are exposed to the
+        * user via the filemetadata parser function.
+        *
+        * Details of the response format of this function can be found at
+        * https://www.mediawiki.org/wiki/Manual:File_metadata_handling
+        * tl/dr: the response is an associative array of
+        * properties keyed by name, but the value can be complex. You probably
+        * want to call one of the FormatMetadata::flatten* functions on the
+        * property values before using them, or call
+        * FormatMetadata::getFormattedData() on the full response array, which
+        * transforms all values into prettified, human-readable text.
+        *
+        * Subclasses overriding this function must return a value which is a
+        * valid API response fragment (all associative array keys are valid
+        * XML tagnames).
+        *
+        * Note, if the file simply has no metadata, but the handler supports
+        * this interface, it should return an empty array, not false.
+        *
+        * @param File $file
+        *
+        * @return Array or false if interface not supported
+        * @since 1.23
+        */
+       public function getCommonMetaArray( File $file ) {
+               return false;
+       }
+
        /**
         * Get a MediaTransformOutput object representing an alternate of the transformed
         * output which will call an intermediary thumbnail assist script.
@@ -436,16 +473,7 @@ abstract class MediaHandler {
         * @access protected
         */
        function visibleMetadataFields() {
-               $fields = array();
-               $lines = explode( "\n", wfMessage( 'metadata-fields' )->inContentLanguage()->text() );
-               foreach ( $lines as $line ) {
-                       $matches = array();
-                       if ( preg_match( '/^\\*\s*(.*?)\s*$/', $line, $matches ) ) {
-                               $fields[] = $matches[1];
-                       }
-               }
-               $fields = array_map( 'strtolower', $fields );
-               return $fields;
+               return FormatMetadata::getVisibleFields();
        }
 
        /**