}
}
- 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' );
}
$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" );
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
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. :)
$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 />';
$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' );
$this->interwiki,
$this->frompage,
$this->history,
- $this->includeTemplates );
+ $this->includeTemplates,
+ $this->pageLinkDepth );
}
} else {
$source = new WikiErrorMsg( "importunknownsource" );
<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' ) .
'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',