(bug 17886) Export all pages by namespace. Also cleans up some hard-coded SQL in...
authorChad Horohoe <demon@users.mediawiki.org>
Thu, 12 Mar 2009 13:10:59 +0000 (13:10 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Thu, 12 Mar 2009 13:10:59 +0000 (13:10 +0000)
RELEASE-NOTES
includes/specials/SpecialExport.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 2f1cea2..7f8f874 100644 (file)
@@ -140,6 +140,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   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 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (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
index eebd93c..302bdfe 100644 (file)
@@ -62,6 +62,18 @@ class SpecialExport extends SpecialPage {
                                }
                        }
                }
+               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 @@ class SpecialExport extends SpecialPage {
                        'action' => $this->getTitle()->getLocalUrl( 'action=submit' ) ) );
                $form .= Xml::inputLabel( wfMsg( 'export-addcattext' )  , 'catname', 'catname', 40 ) . '&nbsp;';
                $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,19 @@ class SpecialExport extends SpecialPage {
                }
        }
 
+
        private function getPagesFromCategory( $title ) {
                global $wgContLang;
 
                $name = $title->getDBkey();
 
                $dbr = wfGetDB( DB_SLAVE );
-
-               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 );
+               $res = $dbr->select( array('page', 'categorylinks' ), 
+                                       array( 'page_namespace', 'page_title' ), 
+                                       array('cl_from=page_id', 'cl_to' => $name ), 
+                                       __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 +272,31 @@ class SpecialExport extends SpecialPage {
                }
                $dbr->freeResult($res);
 
-       return $pages;
+               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();
+               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;
+       }
        /**
         * Expand a list of pages to include templates used in those pages.
         * @param $inputPages array, list of titles to look up
index 629aeb4..ac63f2b 100644 (file)
@@ -2822,6 +2822,8 @@ In the latter case you can also use a link, for example [[{{#Special:Export}}/{{
 '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 1194633..25dd4b7 100644 (file)
@@ -1972,6 +1972,8 @@ $wgMessageStructure = array(
                'export-submit',
                'export-addcattext',
                'export-addcat',
+               'export-addnstext',
+               'export-addns',
                'export-download',
                'export-templates',
                'export-pagelinks',