Partial revert of r101912 -- restores r99315 'includexmlnamespace' parameter for...
authorBrion Vibber <brion@users.mediawiki.org>
Fri, 4 Nov 2011 01:31:15 +0000 (01:31 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Fri, 4 Nov 2011 01:31:15 +0000 (01:31 +0000)
includes/api/ApiFormatXml.php
includes/filerepo/File.php

index 6e59961..6931eb5 100644 (file)
@@ -38,6 +38,7 @@ class ApiFormatXml extends ApiFormatBase {
        private $mRootElemName = 'api';
        public static $namespace = 'http://www.mediawiki.org/xml/api/';
        private $mDoubleQuote = false;
+       private $mIncludeNamespace = false;
        private $mXslt = null;
 
        public function __construct( $main, $format ) {
@@ -59,18 +60,22 @@ class ApiFormatXml extends ApiFormatBase {
        public function execute() {
                $params = $this->extractRequestParams();
                $this->mDoubleQuote = $params['xmldoublequote'];
+               $this->mIncludeNamespace = $params['includexmlnamespace'];
                $this->mXslt = $params['xslt'];
 
                $this->printText( '<?xml version="1.0"?>' );
                if ( !is_null( $this->mXslt ) ) {
                        $this->addXslt();
                }
-
-               // If the result data already contains an 'xmlns' namespace added
-               // for custom XML output types, it will override the one for the
-               // generic API results.
-               // This allows API output of other XML types like Atom, RSS, RSD.
-               $data = $this->getResultData() + array( 'xmlns' => self::$namespace );
+               if ( $this->mIncludeNamespace ) {
+                       // If the result data already contains an 'xmlns' namespace added
+                       // for custom XML output types, it will override the one for the
+                       // generic API results.
+                       // This allows API output of other XML types like Atom, RSS, RSD.
+                       $data = $this->getResultData() + array( 'xmlns' => self::$namespace );
+               } else {
+                       $data = $this->getResultData();
+               }
 
                $this->printText(
                        self::recXmlPrint( $this->mRootElemName,
@@ -208,6 +213,7 @@ class ApiFormatXml extends ApiFormatBase {
                return array(
                        'xmldoublequote' => false,
                        'xslt' => null,
+                       'includexmlnamespace' => false,
                );
        }
 
@@ -215,6 +221,7 @@ class ApiFormatXml extends ApiFormatBase {
                return array(
                        'xmldoublequote' => 'If specified, double quotes all attributes and content',
                        'xslt' => 'If specified, adds <xslt> as stylesheet',
+                       'includexmlnamespace' => 'If specified, adds an XML namespace'
                );
        }
 
index e78eca4..78a618d 100644 (file)
@@ -1476,15 +1476,18 @@ abstract class File {
                        # Get size in bytes
                        $info['size'] = filesize( $path );
 
+                       wfDebug("XXX $path $ext {$info[file-mime]} {$info[mime]} {$info[major_mime]} {$info[minor_mime]} {$info[media_type]} {$info[size]}\n");
                        # Height, width and metadata
                        $handler = MediaHandler::getHandler( $info['mime'] );
                        if ( $handler ) {
                                $tempImage = (object)array();
                                $info['metadata'] = $handler->getMetadata( $tempImage, $path );
                                $gis = $handler->getImageSize( $tempImage, $path, $info['metadata'] );
+                               wfDebug("XXX $path has handler, metadata is {$info[metadata]}\n");
                        } else {
                                $gis = false;
                                $info['metadata'] = '';
+                               wfDebug("XXX $path no handler, no metadata\n");
                        }
                        $info['sha1'] = self::sha1Base36( $path );