* (bug 17224) Added siprop=rightsinfo to meta=siteinfo
* (bug 17239) Added prop=displaytitle to action=parse
* (bug 17317) Added watch parameter to action=protect
+* (bug 17007) Added export and exportnowrap parameters to action=query
=== Languages updated in 1.15 ===
'ApiFormatFeedWrapper' => 'includes/api/ApiFormatBase.php',
'ApiFormatJson' => 'includes/api/ApiFormatJson.php',
'ApiFormatPhp' => 'includes/api/ApiFormatPhp.php',
+ 'ApiFormatRaw' => 'includes/api/ApiFormatRaw.php',
'ApiFormatTxt' => 'includes/api/ApiFormatTxt.php',
'ApiFormatWddx' => 'includes/api/ApiFormatWddx.php',
'ApiFormatXml' => 'includes/api/ApiFormatXml.php',
--- /dev/null
+<?php
+
+/*
+ * Created on Feb 2, 2009
+ *
+ * API for MediaWiki 1.8+
+ *
+ * Copyright (C) 2008 Roan Kattouw <Firstname>.<Lastname>@home.nl
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+if (!defined('MEDIAWIKI')) {
+ // Eclipse helper - will be ignored in production
+ require_once ('ApiFormatBase.php');
+}
+
+/**
+ * Formatter that spits out anything you like with any desired MIME type
+ * @ingroup API
+ */
+class ApiFormatRaw extends ApiFormatBase {
+
+ public function __construct($main, $format) {
+ parent :: __construct($main, $format);
+ }
+
+ public function getMimeType() {
+ $data = $this->getResultData();
+ if(!isset($data['mime']))
+ ApiBase::dieDebug(__METHOD__, "No MIME type set for raw formatter");
+ return $data['mime'];
+ }
+
+ public function execute() {
+ $data = $this->getResultData();
+ if(!isset($data['text']))
+ ApiBase::dieDebug(__METHOD__, "No text given for raw formatter");
+ $this->printText($data['text']);
+ }
+
+ public function getVersion() {
+ return __CLASS__ . ': $Id$';
+ }
+}
function getModules() {
return array_merge($this->mQueryPropModules, $this->mQueryListModules, $this->mQueryMetaModules);
}
+
+ public function getCustomPrinter() {
+ // If &exportnowrap is set, use the raw formatter
+ if ($this->getParameter('exportnowrap'))
+ return new ApiFormatRaw($this->getMain());
+ else
+ return null;
+ }
/**
* Query execution happens in the following steps:
$result->setIndexedTagName($pages, 'page');
$result->addValue('query', 'pages', $pages);
+
+ if ($this->params['export']) {
+ $exporter = new WikiExporter($this->getDB());
+ // WikiExporter writes to stdout, so catch its
+ // output with an ob
+ ob_start();
+ $exporter->openStream();
+ foreach ($pageSet->getGoodTitles() as $title)
+ if ($title->userCanRead())
+ $exporter->pageByTitle($title);
+ $exporter->closeStream();
+ $exportxml = ob_get_contents();
+ ob_end_clean();
+ if ($this->params['exportnowrap']) {
+ $result->reset();
+ // Raw formatter will handle this
+ $result->addValue(null, 'text', $exportxml);
+ $result->addValue(null, 'mime', 'text/xml');
+ } else
+ $result->addValue('query', 'export', $exportxml);
+ }
}
}
),
'redirects' => false,
'indexpageids' => false,
+ 'export' => false,
+ 'exportnowrap' => false,
);
}
'meta' => 'Which meta data to get about the site',
'generator' => 'Use the output of a list as the input for other prop/list/meta items',
'redirects' => 'Automatically resolve redirects',
- 'indexpageids' => 'Include an additional pageids section listing all returned page IDs.'
+ 'indexpageids' => 'Include an additional pageids section listing all returned page IDs.',
+ 'export' => 'Export the current revisions of all given or generated pages',
+ 'exportnowrap' => 'Return the export XML without wrapping it in an XML result',
);
}
public function getDescription() {
return array (
'Query API module allows applications to get needed pieces of data from the MediaWiki databases,',
- 'and is loosely based on the Query API interface currently available on all MediaWiki servers.',
+ 'and is loosely based on the old query.php interface.',
'All data modifications will first have to use query to acquire a token to prevent abuse from malicious sites.'
);
}