2 # Copyright (C) 2003 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # http://www.gnu.org/copyleft/gpl.html
22 * @subpackage SpecialPage
26 require_once( 'Export.php' );
31 function wfSpecialExport( $page = '' ) {
32 global $wgOut, $wgRequest, $wgExportAllowListContributors;
33 global $wgExportAllowHistory, $wgExportMaxHistory;
42 if( $wgRequest->wasPosted() ) {
43 $page = $wgRequest->getText( 'pages' );
44 $curonly = $wgRequest->getCheck( 'curonly' );
45 $rawOffset = $wgRequest->getVal( 'offset' );
47 $offset = wfTimestamp( TS_MW
, $rawOffset );
51 $limit = $wgRequest->getInt( 'limit' );
52 $dir = $wgRequest->getVal( 'dir' );
58 $historyCheck = $wgRequest->getCheck( 'history' );
60 $history = MW_EXPORT_CURRENT
;
61 } elseif ( !$historyCheck ) {
62 if ( $limit > 0 && $limit < $maxLimit ) {
63 $history['limit'] = $limit;
65 if ( !is_null( $offset ) ) {
66 $history['offset'] = $offset;
68 if ( strtolower( $dir ) == 'desc' ) {
69 $history['dir'] = 'desc';
73 // Default to current-only for GET requests
74 $page = $wgRequest->getText( 'pages', $page );
75 $historyCheck = $wgRequest->getCheck( 'history' );
77 $history = MW_EXPORT_FULL
;
79 $history = MW_EXPORT_CURRENT
;
82 if( !$wgExportAllowHistory ) {
84 $history = MW_EXPORT_CURRENT
;
87 $list_authors = $wgRequest->getCheck( 'listauthors' );
88 if ( !$curonly ||
!$wgExportAllowListContributors ) $list_authors = false ;
93 // Cancel output buffering and gzipping if set
94 // This should provide safer streaming for pages with history
95 while( $status = ob_get_status() ) {
97 if( $status['name'] == 'ob_gzhandler' ) {
98 header( 'Content-Encoding:' );
101 header( "Content-type: application/xml; charset=utf-8" );
102 $pages = explode( "\n", $page );
104 $db =& wfGetDB( DB_SLAVE
);
105 $exporter = new WikiExporter( $db, $history );
106 $exporter->list_authors
= $list_authors ;
107 $exporter->openStream();
109 foreach( $pages as $page ) {
110 if( $wgExportMaxHistory && !$curonly ) {
111 $title = Title
::newFromText( $page );
113 $count = Revision
::countByTitle( $db, $title );
114 if( $count > $wgExportMaxHistory ) {
115 wfDebug( __FUNCTION__
.
116 ": Skipped $page, $count revisions too big\n" );
121 $exporter->pageByName( $page );
124 $exporter->closeStream();
128 $wgOut->addWikiText( wfMsg( "exporttext" ) );
129 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Export" );
131 $form = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $titleObj->getLocalUrl() ) );
132 $form .= wfOpenElement( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ) ) . '</textarea><br />';
133 if( $wgExportAllowHistory ) {
134 $form .= wfCheck( 'curonly', true, array( 'value' => 'true', 'id' => 'curonly' ) );
135 $form .= wfLabel( wfMsg( 'exportcuronly' ), 'curonly' ) . '<br />';
137 $wgOut->addWikiText( wfMsg( 'exportnohistory' ) );
139 $form .= wfHidden( 'action', 'submit' );
140 $form .= wfSubmitButton( wfMsg( 'export-submit' ) ) . '</form>';
141 $wgOut->addHtml( $form );