$wgExportAllowListContributors = false ;
+/**
+ * If non-zero, Special:Export accepts a "pagelink-depth" parameter
+ * up to this specified level, which will cause it to include all
+ * pages linked to from the pages you specify. Since this number
+ * can become *insanely large* and could easily break your wiki,
+ * it's disabled by default for now.
+ */
+$wgExportMaxLinkDepth = 0;
+
/**
* Edits matching these regular expressions in body text or edit summary
public function execute( $par ) {
global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
- global $wgExportAllowHistory, $wgExportMaxHistory;
+ global $wgExportAllowHistory, $wgExportMaxHistory, $wgExportMaxLinkDepth;
$this->setHeaders();
$this->outputHeader();
$this->doExport = false;
$this->templates = $wgRequest->getCheck( 'templates' );
$this->images = $wgRequest->getCheck( 'images' ); // Doesn't do anything yet
- $this->pageLinkDepth = $wgRequest->getIntOrNull( 'pagelink-depth' );
+ $this->pageLinkDepth = $this->validateLinkDepth(
+ $wgRequest->getIntOrNull( 'pagelink-depth' ) );
if ( $wgRequest->getCheck( 'addcat' ) ) {
$page = $wgRequest->getText( 'pages' );
$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 />';
+ if( $wgExportMaxLinkDepth ) {
+ $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 />';
array( 'page_id=tl_from' ) );
}
+ /**
+ * Validate link depth setting, if available.
+ */
+ private function validateLinkDepth( $depth ) {
+ global $wgExportMaxLinkDepth;
+ if( $depth < 0 ) {
+ return 0;
+ }
+ if( $depth > $wgExportMaxLinkDepth ) {
+ return $wgExportMaxLinkDepth;
+ }
+ return intval( $depth );
+ }
+
/** Expand a list of pages to include pages linked to from that page. */
private function getPageLinks( $inputPages, $pageSet, $depth ) {
for( $depth=$depth; $depth>0; --$depth ) {