* (bug 4446) $wgExportAllowHistory option to explicitly disable history in
[lhc/web/wiklou.git] / includes / SpecialExport.php
1 <?php
2 # Copyright (C) 2003 Brion Vibber <brion@pobox.com>
3 # http://www.mediawiki.org/
4 #
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.
9 #
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.
14 #
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 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # http://www.gnu.org/copyleft/gpl.html
19 /**
20 *
21 * @package MediaWiki
22 * @subpackage SpecialPage
23 */
24
25 /** */
26 require_once( 'Revision.php' );
27 require_once( 'Export.php' );
28
29 /**
30 *
31 */
32 function wfSpecialExport( $page = '' ) {
33 global $wgOut, $wgRequest;
34 global $wgExportAllowHistory;
35
36 if( $wgRequest->getVal( 'action' ) == 'submit') {
37 $page = $wgRequest->getText( 'pages' );
38 if( $wgExportAllowHistory ) {
39 $curonly = $wgRequest->getCheck( 'curonly' );
40 } else {
41 $curonly = true;
42 }
43 } else {
44 # Pre-check the 'current version only' box in the UI
45 $curonly = true;
46 }
47
48 if( $page != '' ) {
49 $wgOut->disable();
50 header( "Content-type: application/xml; charset=utf-8" );
51 $pages = explode( "\n", $page );
52
53 $db =& wfGetDB( DB_SLAVE );
54 $history = $curonly ? MW_EXPORT_CURRENT : MW_EXPORT_FULL;
55 $exporter = new WikiExporter( $db, $history );
56 $exporter->openStream();
57 $exporter->pagesByName( $pages );
58 $exporter->closeStream();
59 return;
60 }
61
62 $wgOut->addWikiText( wfMsg( "exporttext" ) );
63 $titleObj = Title::makeTitle( NS_SPECIAL, "Export" );
64 $action = $titleObj->escapeLocalURL( 'action=submit' );
65 if( $wgExportAllowHistory ) {
66 $checkbox = "<label><input type='checkbox' name='curonly' value='true' checked='checked' />
67 " . wfMsgHtml( 'exportcuronly' ) . "</label><br />";
68 } else {
69 $checkbox = "";
70 $wgOut->addWikiText( wfMsg( "exportnohistory" ) );
71 }
72 $wgOut->addHTML( "
73 <form method='post' action=\"$action\">
74 <input type='hidden' name='action' value='submit' />
75 <textarea name='pages' cols='40' rows='10'></textarea><br />
76 $checkbox
77 <input type='submit' />
78 </form>
79 " );
80 }
81
82 ?>