* ( bug 18264 ) upload-by-url form was still disabled in non-js2 form output
[lhc/web/wiklou.git] / includes / specials / SpecialExport.php
index 306eaf9..de4795a 100644 (file)
@@ -44,7 +44,8 @@ class SpecialExport extends SpecialPage {
                $this->templates = $wgRequest->getCheck( 'templates' );
                $this->images = $wgRequest->getCheck( 'images' ); // Doesn't do anything yet
                $this->pageLinkDepth = $this->validateLinkDepth(
-                                                                                                               $wgRequest->getIntOrNull( 'pagelink-depth' ) );
+                       $wgRequest->getIntOrNull( 'pagelink-depth' ) );
+               $nsindex = '';
                
                if ( $wgRequest->getCheck( 'addcat' ) ) {
                        $page = $wgRequest->getText( 'pages' );
@@ -67,13 +68,13 @@ class SpecialExport extends SpecialPage {
                        $page = $wgRequest->getText( 'pages' );
                        $nsindex = $wgRequest->getText( 'nsindex', '' );
                        
-                       if ( $nsindex !== '' && $nsindex !== null && $nsindex !== false ) {
+                       if ( strval( $nsindex ) !== ''  ) {
                                /**
                                 * 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' );
@@ -87,10 +88,10 @@ class SpecialExport extends SpecialPage {
                        $limit = $wgRequest->getInt( 'limit' );
                        $dir = $wgRequest->getVal( 'dir' );
                        $history = array(
-                                                        'dir' => 'asc',
-                                                        'offset' => false,
-                                                        'limit' => $wgExportMaxHistory,
-                                                        );
+                               'dir' => 'asc',
+                               'offset' => false,
+                               'limit' => $wgExportMaxHistory,
+                       );
                        $historyCheck = $wgRequest->getCheck( 'history' );
                        if ( $this->curonly ) {
                                $history = WikiExporter::CURRENT;
@@ -146,7 +147,7 @@ class SpecialExport extends SpecialPage {
                $wgOut->addWikiMsg( 'exporttext' );
                
                $form = Xml::openElement( 'form', array( 'method' => 'post',
-                                                                                               'action' => $this->getTitle()->getLocalUrl( 'action=submit' ) ) );
+                       '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 />';
                
@@ -190,10 +191,22 @@ class SpecialExport extends SpecialPage {
        private function doExport( $page, $history, $list_authors ) {
                global $wgExportMaxHistory;
                
-               /* Split up the input and look up linked pages */
-               $inputPages = array_filter( explode( "\n", $page ), array( $this, 'filterPage' ) );
-               $pageSet = array_flip( $inputPages );
+               $pageSet = array(); // Inverted index of all pages to look up
+               
+               // Split up and normalize input
+               foreach( explode( "\n", $page ) as $pageName ) {
+                       $pageName = trim( $pageName );
+                       $title = Title::newFromText( $pageName );
+                       if( $title && $title->getInterwiki() == '' && $title->getText() !== '' ) {
+                               // Only record each page once!
+                               $pageSet[$title->getPrefixedText()] = true;
+                       }
+               }
+               
+               // Set of original pages to pass on to further manipulation...
+               $inputPages = array_keys( $pageSet );
                
+               // Look up any linked pages if asked...
                if( $this->templates ) {
                        $pageSet = $this->getTemplates( $inputPages, $pageSet );
                }
@@ -210,7 +223,13 @@ class SpecialExport extends SpecialPage {
                 */
                
                $pages = array_keys( $pageSet );
-               
+
+               // Normalize titles to the same format and remove dupes, see bug 17374
+               foreach( $pages as $k => $v ) {
+                       $pages[$k] = str_replace( " ", "_", $v );
+               }
+               $pages = array_unique( $pages );
+
                /* Ok, let's get to it... */
                if( $history == WikiExporter::CURRENT ) {
                        $lb = false;
@@ -346,6 +365,7 @@ class SpecialExport extends SpecialPage {
                        $pageSet = $this->getLinks( $inputPages, $pageSet, 'pagelinks',
                                                                           array( 'pl_namespace AS namespace', 'pl_title AS title' ),
                                                                           array( 'page_id=pl_from' ) );
+                       $inputPages = array_keys( $pageSet );
                }
                return $pageSet;
        }
@@ -381,7 +401,7 @@ class SpecialExport extends SpecialPage {
                                                                           array_merge( $join,
                                                                                                   array(
                                                                                                                 'page_namespace' => $title->getNamespace(),
-                                                                                                                'page_title' => $title->getDBKey() ) ),
+                                                                                                                'page_title' => $title->getDBkey() ) ),
                                                                           __METHOD__ );
                                foreach( $result as $row ) {
                                        $template = Title::makeTitle( $row->namespace, $row->title );