Add 'include pages linked to from these pages' to Special:Export and the correspondin...
authorAndrew Garrett <werdna@users.mediawiki.org>
Fri, 6 Feb 2009 22:44:28 +0000 (22:44 +0000)
committerAndrew Garrett <werdna@users.mediawiki.org>
Fri, 6 Feb 2009 22:44:28 +0000 (22:44 +0000)
includes/Import.php
includes/specials/SpecialExport.php
includes/specials/SpecialImport.php
languages/messages/MessagesEn.php

index 17560a7..4daf73b 100644 (file)
@@ -1116,7 +1116,7 @@ class ImportStreamSource {
                }
        }
 
-       public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false ) {
+       public static function newFromInterwiki( $interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0 ) {
                if( $page == '' ) {
                        return new WikiErrorMsg( 'import-noarticle' );
                }
@@ -1127,6 +1127,7 @@ class ImportStreamSource {
                        $params = array();
                        if ( $history ) $params['history'] = 1;
                        if ( $templates ) $params['templates'] = 1;
+                       if ( $pageLinkDepth ) $params['pagelink-depth'] = $pageLinkDepth;
                        $url = $link->getFullUrl( $params );
                        # For interwikis, use POST to avoid redirects.
                        return ImportStreamSource::newFromURL( $url, "POST" );
index 898b5a7..04f0d6b 100644 (file)
@@ -62,6 +62,17 @@ function wfExportGetTemplates( $inputPages, $pageSet ) {
                array( 'page_id=tl_from' ) );
 }
 
+/** Expand a list of pages to include pages linked to from that page. */
+function wfExportGetPageLinks( $inputPages, $pageSet, $depth ) {
+       for( $depth=$depth; $depth>0; --$depth ) {
+               $pageSet = wfExportGetLinks( $inputPages, $pageSet, 'pagelinks',
+                       array( 'pl_namespace AS namespace', 'pl_title AS title' ),
+                       array( 'page_id=pl_from' ) );
+       }
+       
+       return $pageSet;
+}
+
 /**
  * Expand a list of pages to include images used in those pages.
  * @param $inputPages array, list of titles to look up
@@ -211,6 +222,10 @@ function wfSpecialExport( $page = '' ) {
                if( $wgRequest->getCheck( 'templates' ) ) {
                        $pageSet = wfExportGetTemplates( $inputPages, $pageSet );
                }
+               
+               if( $linkDepth = $wgRequest->getIntOrNull( 'pagelink-depth' ) ) {
+                       $pageSet = wfExportGetPageLinks( $inputPages, $pageSet, $linkDepth );
+               }
 
                /*
                // Enable this when we can do something useful exporting/importing image information. :)
@@ -292,6 +307,7 @@ function wfSpecialExport( $page = '' ) {
                $wgOut->addHTML( wfMsgExt( 'exportnohistory', 'parse' ) );
        }
        $form .= Xml::checkLabel( wfMsg( 'export-templates' ), 'templates', 'wpExportTemplates', false ) . '<br />';
+       $form .= Xml::inputLabel( wfMsg( 'export-pagelinks' ), 'pagelink-depth', 'pagelink-depth', 20, 0 ) . '<br />';
        // Enable this when we can do something useful exporting/importing image information. :)
        //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
        $form .= Xml::checkLabel( wfMsg( 'export-download' ), 'wpDownload', 'wpDownload', true ) . '<br />';
index b6318c6..6d9b2c8 100644 (file)
@@ -72,6 +72,7 @@ class SpecialImport extends SpecialPage {
                $sourceName = $wgRequest->getVal( "source" );
 
                $this->logcomment = $wgRequest->getText( 'log-comment' );
+               $this->pageLinkDepth = $wgRequest->getIntOrNull( 'pagelink-depth' );
 
                if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) {
                        $source = new WikiErrorMsg( 'import-token-mismatch' );
@@ -94,7 +95,8 @@ class SpecialImport extends SpecialPage {
                                        $this->interwiki,
                                        $this->frompage,
                                        $this->history,
-                                       $this->includeTemplates );
+                                       $this->includeTemplates,
+                                       $this->pageLinkDepth );
                        }
                } else {
                        $source = new WikiErrorMsg( "importunknownsource" );
@@ -221,6 +223,11 @@ class SpecialImport extends SpecialPage {
                                        <td class='mw-input'>" .
                                                Xml::checkLabel( wfMsg( 'import-interwiki-templates' ), 'interwikiTemplates', 'interwikiTemplates', $this->includeTemplates ) .
                                        "</td>
+                               </tr>
+                               <tr>
+                                       <td>".wfMsgExt( 'export-pagelinks', 'parseinline' )."</td>
+                                       <td class=\"mw-input\">" . Xml::input( 'pagelink-depth', 20, 0 ) . "<br/>
+                               </tr>
                                <tr>
                                        <td>" .
                                                Xml::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) .
index 8daccf3..777068b 100644 (file)
@@ -2794,6 +2794,7 @@ In the latter case you can also use a link, e.g. [[{{ns:special}}:Export/{{Media
 'export-addcat'     => 'Add',
 'export-download'   => 'Save as file',
 'export-templates'  => 'Include templates',
+'export-pagelinks'  => 'Include linked pages to a depth of:',
 
 # Namespace 8 related
 'allmessages'               => 'System messages',