Page MenuHomePhabricator

export.diff

Authored By
bzimport
Nov 21 2014, 9:50 PM
Size
5 KB
Referenced Files
None
Subscribers
None

export.diff

Index: includes/SpecialExport.php
===================================================================
--- includes/SpecialExport.php (revision 24206)
+++ includes/SpecialExport.php (working copy)
@@ -54,12 +54,13 @@
*/
function wfSpecialExport( $page = '' ) {
global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
- global $wgExportAllowHistory, $wgExportMaxHistory;
+ global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxPages;
$curonly = true;
$doexport = false;
if ( $wgRequest->getCheck( 'addcat' ) ) {
+ // Add pages from category
$page = $wgRequest->getText( 'pages' );
$catname = $wgRequest->getText( 'catname' );
@@ -103,6 +104,7 @@
}
if( $page != '' ) $doexport = true;
+ if( $wgRequest->getCheck( 'exportall' ) ) $doexport=true;
} else {
// Default to current-only for GET requests
$page = $wgRequest->getText( 'pages', $page );
@@ -124,6 +126,11 @@
$list_authors = $wgRequest->getCheck( 'listauthors' );
if ( !$curonly || !$wgExportAllowListContributors ) $list_authors = false ;
+
+ /*
+ DO THE EXPORT
+ */
+
if ( $doexport ) {
$wgOut->disable();
@@ -142,33 +149,40 @@
$exporter = new WikiExporter( $db, $history );
$exporter->list_authors = $list_authors ;
$exporter->openStream();
-
- foreach( $pages as $page ) {
- /*
- if( $wgExportMaxHistory && !$curonly ) {
- $title = Title::newFromText( $page );
- if( $title ) {
- $count = Revision::countByTitle( $db, $title );
- if( $count > $wgExportMaxHistory ) {
- wfDebug( __FUNCTION__ .
- ": Skipped $page, $count revisions too big\n" );
- continue;
+ if ( $wgRequest->getCheck( 'exportall' ) ) { // "export all pages" has been clicked
+ if ( ($wgExportMaxPages==false) || ($wgExportMaxPages >= SiteStats::pages()) ) $exporter->allPages();
+ }
+ else {
+ if ( (sizeof($pages) <= $wgExportMaxPages) || $wgExportMaxPages==false ) foreach( $pages as $page ) {
+ /*
+ if( $wgExportMaxHistory && !$curonly ) {
+ $title = Title::newFromText( $page );
+ if( $title ) {
+ $count = Revision::countByTitle( $db, $title );
+ if( $count > $wgExportMaxHistory ) {
+ wfDebug( __FUNCTION__ .
+ ": Skipped $page, $count revisions too big\n" );
+ continue;
+ }
}
- }
- }*/
+ }*/
- #Bug 8824: Only export pages the user can read
- $title = Title::newFromText( $page );
- if( is_null( $title ) ) continue; #TODO: perhaps output an <error> tag or something.
- if( !$title->userCan( 'read' ) ) continue; #TODO: perhaps output an <error> tag or something.
+ #Bug 8824: Only export pages the user can read
+ $title = Title::newFromText( $page );
+ if( is_null( $title ) ) continue; #TODO: perhaps output an <error> tag or something.
+ if( !$title->userCan( 'read' ) ) continue; #TODO: perhaps output an <error> tag or something.
+ $exporter->pageByTitle( $title );
+ }
+ }
- $exporter->pageByTitle( $title );
- }
-
$exporter->closeStream();
return;
}
+ /*
+ SHOW THE PAGE
+ */
+
$self = SpecialPage::getTitleFor( 'Export' );
$wgOut->addHtml( wfMsgExt( 'exporttext', 'parse' ) );
@@ -191,6 +205,10 @@
$form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
$form .= Xml::submitButton( wfMsg( 'export-submit' ) );
+ if ( ($wgExportMaxPages==false) || ($wgExportMaxPages >= SiteStats::pages()) ) {
+ $form .= "&nbsp;";
+ $form .= Xml::SubmitButton( wfMsg( 'export-all' ), array( 'name' => 'exportall' ) ) ;
+ }
$form .= Xml::closeElement( 'form' );
$wgOut->addHtml( $form );
}
\ No newline at end of file
Index: includes/DefaultSettings.php
===================================================================
--- includes/DefaultSettings.php (revision 24206)
+++ includes/DefaultSettings.php (working copy)
@@ -1788,6 +1788,13 @@
*/
$wgExportMaxHistory = 0;
+/**
+ * If set to an integer, Special:Export requests for exporting all pages
+ * will be rejected in case the wiki has more pages than this.
+ * Defaults to false.
+ */
+$wgExportMaxPages = false;
+
$wgExportAllowListContributors = false ;
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 24206)
+++ languages/messages/MessagesEn.php (working copy)
@@ -2115,6 +2115,7 @@
'exportnohistory' => "----
'''Note:''' Exporting the full history of pages through this form has been disabled due to performance reasons.",
'export-submit' => 'Export',
+'export-all' => 'Export all pages',
'export-addcattext' => 'Add pages from category:',
'export-addcat' => 'Add',
'export-download' => 'Offer to save as a file',
Index: languages/messages/MessagesDe.php
===================================================================
--- languages/messages/MessagesDe.php (revision 24206)
+++ languages/messages/MessagesDe.php (working copy)
@@ -1691,6 +1691,7 @@
'exportnohistory' => "----
'''Hinweis:''' Der Export kompletter Versionsgeschichten ist aus Performancegründen bis auf Weiteres nicht möglich.",
'export-submit' => 'Seiten exportieren',
+'export-all' => 'Alle Seiten exportieren',
'export-addcattext' => 'Seiten aus Kategorie hinzufügen:',
'export-addcat' => 'Hinzufügen',
'export-download' => 'Als XML-Datei speichern',

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3657
Default Alt Text
export.diff (5 KB)

Event Timeline