Page MenuHomePhabricator

mw-head-exportns.patch

Authored By
bzimport
Nov 21 2014, 10:33 PM
Size
4 KB
Referenced Files
None
Subscribers
None

mw-head-exportns.patch

Index: maintenance/language/messages.inc
===================================================================
--- maintenance/language/messages.inc (revision 48348)
+++ maintenance/language/messages.inc (working copy)
@@ -1972,6 +1972,8 @@
'export-submit',
'export-addcattext',
'export-addcat',
+ 'export-addnstext',
+ 'export-addns',
'export-download',
'export-templates',
'export-pagelinks',
Index: includes/specials/SpecialExport.php
===================================================================
--- includes/specials/SpecialExport.php (revision 48348)
+++ includes/specials/SpecialExport.php (working copy)
@@ -62,6 +62,18 @@
}
}
}
+ else if( $wgRequest->getCheck( 'addns' ) ) {
+ $page = $wgRequest->getText( 'pages' );
+ $nsindex = $wgRequest->getText( 'nsindex' );
+
+ if ( $nsindex !== '' && $nsindex !== NULL && $nsindex !== false ) {
+ /**
+ * Same implementation as above, so same @fixme
+ */
+ $nspages = $this->getPagesFromNamespace( $nsindex );
+ if ( $nspages ) $page .= "\n" . implode( "\n", $nspages );
+ }
+ }
else if( $wgRequest->wasPosted() && $par == '' ) {
$page = $wgRequest->getText( 'pages' );
$this->curonly = $wgRequest->getCheck( 'curonly' );
@@ -136,6 +148,10 @@
'action' => $this->getTitle()->getLocalUrl( 'action=submit' ) ) );
$form .= Xml::inputLabel( wfMsg( 'export-addcattext' ) , 'catname', 'catname', 40 ) . ' ';
$form .= Xml::submitButton( wfMsg( 'export-addcat' ), array( 'name' => 'addcat' ) ) . '<br />';
+
+ $form .= Xml::namespaceSelector( '', null, 'nsindex', wfMsg( 'export-addnstext' ) ) . '&nbsp;';
+ $form .= Xml::submitButton( wfMsg( 'export-addns' ), array( 'name' => 'addns' ) ) . '<br />';
+
$form .= Xml::element( 'textarea', array( 'name' => 'pages', 'cols' => 40, 'rows' => 10 ), $page, false );
$form .= '<br />';
@@ -232,20 +248,42 @@
}
}
+
private function getPagesFromCategory( $title ) {
global $wgContLang;
$name = $title->getDBkey();
$dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( array('page', 'categorylinks' ),
+ array( 'page_namespace', 'page_title' ),
+ array('cl_from=page_id', 'cl_to' => $name ),
+ __METHOD__, array('LIMIT' => '5000'));
- list( $page, $categorylinks ) = $dbr->tableNamesN( 'page', 'categorylinks' );
- $sql = "SELECT page_namespace, page_title FROM $page " .
- "JOIN $categorylinks ON cl_from = page_id " .
- "WHERE cl_to = " . $dbr->addQuotes( $name );
+ $pages = array();
+ while ( $row = $dbr->fetchObject( $res ) ) {
+ $n = $row->page_title;
+ if ($row->page_namespace) {
+ $ns = $wgContLang->getNsText( $row->page_namespace );
+ $n = $ns . ':' . $n;
+ }
+ $pages[] = $n;
+ }
+ $dbr->freeResult($res);
+
+ return $pages;
+ }
+
+ private function getPagesFromNamespace( $nsindex ) {
+ global $wgContLang;
+
+ $dbr = wfGetDB( DB_SLAVE );
+ $res = $dbr->select( 'page', array('page_namespace', 'page_title'),
+ array('page_namespace' => $nsindex),
+ __METHOD__, array('LIMIT' => '5000') );
+
$pages = array();
- $res = $dbr->query( $sql, __METHOD__ );
while ( $row = $dbr->fetchObject( $res ) ) {
$n = $row->page_title;
if ($row->page_namespace) {
@@ -257,9 +295,8 @@
}
$dbr->freeResult($res);
- return $pages;
+ return $pages;
}
-
/**
* Expand a list of pages to include templates used in those pages.
* @param $inputPages array, list of titles to look up
Index: languages/messages/MessagesEn.php
===================================================================
--- languages/messages/MessagesEn.php (revision 48348)
+++ languages/messages/MessagesEn.php (working copy)
@@ -2822,6 +2822,8 @@
'export-submit' => 'Export',
'export-addcattext' => 'Add pages from category:',
'export-addcat' => 'Add',
+'export-addnstext' => 'Add pages from namespace:',
+'export-addns' => 'Add',
'export-download' => 'Save as file',
'export-templates' => 'Include templates',
'export-pagelinks' => 'Include linked pages to a depth of:',
Index: RELEASE-NOTES
===================================================================
--- RELEASE-NOTES (revision 48348)
+++ RELEASE-NOTES (working copy)
@@ -140,6 +140,7 @@
dynamic dates.
* (bug 4582) Provide preference-based autoformatting of unlinked dates with the dateformat
parser function.
+* (bug 17886) Special:Export now allows you to export a whole namespace (limited to 5000 pages)
=== Bug fixes in 1.15 ===
* (bug 16968) Special:Upload no longer throws useless warnings.
@@ -260,6 +261,7 @@
* (bug 17900) Fixed User Groups interface log display after saving groups.
* (bug 17897) Fixed string offset error in <pre> tags
* (bug 17778) MediaWiki:Catseparator can now have HTML entities
+* Special:Export doesn't use raw SQL queris anymore
== API changes in 1.15 ==
* (bug 16858) Revamped list=deletedrevs to make listing deleted contributions

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5123
Default Alt Text
mw-head-exportns.patch (4 KB)

Event Timeline