From 29440d710b614c019062ecbea6b6bc3d35ff834e Mon Sep 17 00:00:00 2001 From: Raimond Spekking Date: Thu, 19 Feb 2009 08:43:35 +0000 Subject: [PATCH] * Some cleanup for Special:Import: ** Do not show input field for import depth if $wgExportMaxLinkDepth == 0 ** Add missing 'mw-label' for 2 labels ** Change class 'mw-label' to 'mw-submit' for the submit button for consistency with other forms ** Remove FIXME note as nothing to fix :) ** Add IDs to input forms ** Use specific Xml::fieldset functions --- RELEASE-NOTES | 2 ++ includes/specials/SpecialImport.php | 44 +++++++++++++++++------------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 1e7c34380e..06c34d355c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -230,6 +230,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 17502) meta=siteinfo&siprop=namespacealiases no longer lists namespace aliases already listed in siprop=namespaces * (bug 17529) rvend ignored when rvstartid is specified +* Special:Import: Do not show input field for import depth if + $wgExportMaxLinkDepth == 0 === Languages updated in 1.15 === diff --git a/includes/specials/SpecialImport.php b/includes/specials/SpecialImport.php index 6d9b2c8723..457e03b4d8 100644 --- a/includes/specials/SpecialImport.php +++ b/includes/specials/SpecialImport.php @@ -66,13 +66,13 @@ class SpecialImport extends SpecialPage { * Do the actual import */ private function doImport() { - global $wgOut, $wgRequest, $wgUser, $wgImportSources; + global $wgOut, $wgRequest, $wgUser, $wgImportSources, $wgExportMaxLinkDepth; $isUpload = false; $this->namespace = $wgRequest->getIntOrNull( 'namespace' ); $sourceName = $wgRequest->getVal( "source" ); $this->logcomment = $wgRequest->getText( 'log-comment' ); - $this->pageLinkDepth = $wgRequest->getIntOrNull( 'pagelink-depth' ); + $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $wgRequest->getIntOrNull( 'pagelink-depth' ); if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'editToken' ) ) ) { $source = new WikiErrorMsg( 'import-token-mismatch' ); @@ -132,9 +132,7 @@ class SpecialImport extends SpecialPage { } private function showForm() { - global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources; - # FIXME: Quick hack to disable import for non privileged users /Raymond - # Regression from 43963 + global $wgUser, $wgOut, $wgRequest, $wgTitle, $wgImportSources, $wgExportMaxLinkDepth; if( !$wgUser->isAllowed( 'import' ) && !$wgUser->isAllowed( 'importupload' ) ) return $wgOut->permissionRequired( 'import' ); @@ -143,9 +141,9 @@ class SpecialImport extends SpecialPage { if( $wgUser->isAllowed( 'importupload' ) ) { $wgOut->addWikiMsg( "importtext" ); $wgOut->addHTML( - Xml::openElement( 'fieldset' ). - Xml::element( 'legend', null, wfMsg( 'import-upload' ) ) . - Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) . + Xml::fieldset( wfMsg( 'import-upload' ) ). + Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', + 'action' => $action, 'id' => 'mw-import-upload-form' ) ) . Xml::hidden( 'action', 'submit' ) . Xml::hidden( 'source', 'upload' ) . Xml::openElement( 'table', array( 'id' => 'mw-import-table' ) ) . @@ -169,7 +167,7 @@ class SpecialImport extends SpecialPage { - " . + " . Xml::submitButton( wfMsg( 'uploadbtn' ) ) . " " . @@ -185,10 +183,22 @@ class SpecialImport extends SpecialPage { } if( $wgUser->isAllowed( 'import' ) && !empty( $wgImportSources ) ) { + # Show input field for import depth only if $wgExportMaxLinkDepth > 0 + $importDepth = ''; + if( $wgExportMaxLinkDepth > 0 ) { + $importDepth = " + " . + wfMsgExt( 'export-pagelinks', 'parseinline' ) . + " + " . + Xml::input( 'pagelink-depth', 3, 0 ) . + " + "; + } + $wgOut->addHTML( - Xml::openElement( 'fieldset' ) . - Xml::element( 'legend', null, wfMsg( 'importinterwiki' ) ) . - Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action ) ) . + Xml::fieldset( wfMsg( 'importinterwiki' ) ) . + Xml::openElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'mw-import-interwiki-form' ) ) . wfMsgExt( 'import-interwiki-text', array( 'parse' ) ) . Xml::hidden( 'action', 'submit' ) . Xml::hidden( 'source', 'interwiki' ) . @@ -205,6 +215,7 @@ class SpecialImport extends SpecialPage { $selected = ( $this->interwiki === $prefix ) ? ' selected="selected"' : ''; $wgOut->addHTML( Xml::option( $prefix, $prefix, $selected ) ); } + $wgOut->addHTML( Xml::closeElement( 'select' ) . Xml::input( 'frompage', 50, $this->frompage ) . @@ -224,12 +235,9 @@ class SpecialImport extends SpecialPage { Xml::checkLabel( wfMsg( 'import-interwiki-templates' ), 'interwikiTemplates', 'interwikiTemplates', $this->includeTemplates ) . " + $importDepth - ".wfMsgExt( 'export-pagelinks', 'parseinline' )." - " . Xml::input( 'pagelink-depth', 20, 0 ) . "
- - - " . + " . Xml::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) . " " . @@ -248,7 +256,7 @@ class SpecialImport extends SpecialPage { - " . + " . Xml::submitButton( wfMsg( 'import-interwiki-submit' ), array( 'accesskey' => 's' ) ) . " " . -- 2.20.1