global $wgImportTargetNamespace;
$interwiki = false;
- $articleName = '';
$namespace = $wgImportTargetNamespace;
$frompage = '';
$history = true;
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
+
if( $wgRequest->wasPosted() && $wgRequest->getVal( 'action' ) == 'submit') {
$isUpload = false;
- $articleName = htmlspecialchars( $wgRequest->getText( 'articlename' ) );
$namespace = $wgRequest->getIntOrNull( 'namespace' );
switch( $wgRequest->getVal( "source" ) ) {
}
if( WikiError::isError( $source ) ) {
- $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $source->getMessage() ) ) . '</p>' );
+ $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $source->getMessage() ) );
} else {
- $wgOut->addWikiText( wfMsg( "importstart" ) );
+ $wgOut->addWikiMsg( "importstart" );
$importer = new WikiImporter( $source );
if( !is_null( $namespace ) ) {
$importer->setTargetNamespace( $namespace );
}
- if( !is_null( $articleName ) ) {
- $importer->setTargetArticleName( $articleName );
- }
$reporter = new ImportReporter( $importer, $isUpload, $interwiki );
$reporter->open();
if( WikiError::isError( $result ) ) {
# No source or XML parse error
- $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $result->getMessage() ) ) . '</p>' );
+ $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $result->getMessage() ) );
} elseif( WikiError::isError( $resultCount ) ) {
# Zero revisions
- $wgOut->addWikiText( '<p class="error">' . wfMsg( "importfailed", wfEscapeWikiText( $resultCount->getMessage() ) ) . '</p>' );
+ $wgOut->wrapWikiMsg( '<p class="error">$1</p>', array( 'importfailed', $resultCount->getMessage() ) );
} else {
# Success!
- $wgOut->addWikiText( wfMsg( "importsuccess" ) );
+ $wgOut->addWikiMsg( 'importsuccess' );
}
$wgOut->addWikiText( '<hr />' );
}
}
- $action = $wgTitle->escapeLocalUrl( 'action=submit' );
+ $action = $wgTitle->getLocalUrl( 'action=submit' );
if( $wgUser->isAllowed( 'importupload' ) ) {
- $wgOut->addWikiText( wfMsg( "importtext" ) );
+ $wgOut->addWikiMsg( "importtext" );
$wgOut->addHTML(
Xml::openElement( 'fieldset' ).
Xml::element( 'legend', null, wfMsg( 'upload' ) ) .
Xml::openElement( 'form', array( 'enctype' => 'multipart/form-data', 'method' => 'post', 'action' => $action ) ) .
Xml::hidden( 'action', 'submit' ) .
Xml::hidden( 'source', 'upload' ) .
- Xml::hidden( 'MAX_FILE_SIZE', '2000000' ) .
"<input type='file' name='xmlimport' value='' size='30' />" . // No Xml function for type=file? Todo?
Xml::submitButton( wfMsg( 'uploadbtn' ) ) .
Xml::closeElement( 'form' ) .
- Xml::closeElement( 'fieldset' ) );
+ Xml::closeElement( 'fieldset' )
+ );
} else {
if( empty( $wgImportSources ) ) {
- $wgOut->addWikiText( wfMsg( 'importnosources' ) );
+ $wgOut->addWikiMsg( 'importnosources' );
}
}
Xml::openElement( 'table' ) .
"<tr>
<td>" .
- Xml::openElement( 'select', array( 'name' => 'interwiki' ) ) );
+ Xml::openElement( 'select', array( 'name' => 'interwiki' ) )
+ );
foreach( $wgImportSources as $prefix ) {
$iw = htmlspecialchars( $prefix );
$selected = ($interwiki === $prefix) ? ' selected="selected"' : '';
$wgOut->addHTML( Xml::option( $iw, $iw, $selected ) );
}
- $wgOut->addHTML(
+ $wgOut->addHTML(
Xml::closeElement( 'select' ) .
"</td>
<td>" .
"</td>
</tr>
<tr>
- <td></td>
+ <td>
+ </td>
<td>" .
Xml::checkLabel( wfMsg( 'import-interwiki-history' ), 'interwikiHistory', 'interwikiHistory', $history ) .
"</td>
</tr>
<tr>
- <td></td>
- <td>" .
- Xml::inputLabel( wfMsg( 'import-articlename' ), 'articlename', 'articlename', 50, $articleName ) .
- "</td>
- </tr>
- <tr>
- <td></td>
+ <td>
+ </td>
<td>" .
Xml::label( wfMsg( 'import-interwiki-namespace' ), 'namespace' ) .
Xml::namespaceSelector( $namespace, '' ) .
"</td>
</tr>
<tr>
- <td></td>
+ <td>
+ </td>
<td>" .
Xml::submitButton( wfMsg( 'import-interwiki-submit' ) ) .
"</td>
</tr>" .
Xml::closeElement( 'table' ).
Xml::closeElement( 'form' ) .
- Xml::closeElement( 'fieldset' ) );
+ Xml::closeElement( 'fieldset' )
+ );
}
}
$contentCount = $wgContLang->formatNum( $successCount );
if( $successCount > 0 ) {
- $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) .
- " " .
+ $wgOut->addHtml( "<li>" . $skin->makeKnownLinkObj( $title ) . " " .
wfMsgExt( 'import-revision-count', array( 'parsemag', 'escape' ), $localCount ) .
- "</li>\n" );
+ "</li>\n"
+ );
$log = new LogPage( 'import' );
if( $this->mIsUpload ) {
- $detail = wfMsgForContent( 'import-logentry-upload-detail',
+ $detail = wfMsgExt( 'import-logentry-upload-detail', array( 'content', 'parsemag' ),
$contentCount );
$log->addEntry( 'upload', $title, $detail );
} else {
$interwiki = '[[:' . $this->mInterwiki . ':' .
$origTitle->getPrefixedText() . ']]';
- $detail = wfMsgForContent( 'import-logentry-interwiki-detail',
+ $detail = wfMsgExt( 'import-logentry-interwiki-detail', array( 'content', 'parsemag' ),
$contentCount, $interwiki );
$log->addEntry( 'interwiki', $title, $detail );
}
$nullRevision = Revision::newNullRevision(
$dbw, $title->getArticleId(), $comment, true );
$nullRevision->insertOn( $dbw );
+ # Update page record
+ $article = new Article( $title );
+ $article->updateRevisionOn( $dbw, $nullRevision );
} else {
- $wgOut->addHtml( '<li>' . wfMsgExt( 'import-nonewrevisions', array( 'parse', ) ) . '</li>' );
+ $wgOut->addHtml( '<li>' . wfMsgHtml( 'import-nonewrevisions' ) . '</li>' );
}
-
}
function close() {
var $mPageOutCallback = null;
var $mRevisionCallback = null;
var $mTargetNamespace = null;
- var $mTargetArticleName = null;
var $lastfield;
function WikiImporter( $source ) {
}
}
- /**
- * Set a target articlename to override the defaults
- */
- function setTargetArticleName( $articleName ) {
- $this->mTargetArticleName = is_null( $articleName ) ? null : $articleName;
- }
-
/**
* Default per-revision callback, performs the import.
* @param WikiRevision $revision
switch( $this->appendfield ) {
case "title":
$this->workTitle = $this->appenddata;
-
- if( $this->mTargetArticleName != '' ) {
- // Import article with a different target article name
- $this->workTitle = $this->mTargetArticleName;
- }
$this->origTitle = Title::newFromText( $this->workTitle );
if( !is_null( $this->mTargetNamespace ) && !is_null( $this->origTitle ) ) {
$this->pageTitle = Title::makeTitle( $this->mTargetNamespace,
- $this->origTitle->getDbKey() );
+ $this->origTitle->getDBkey() );
} else {
$this->pageTitle = Title::newFromText( $this->workTitle );
}
return new WikiErrorMsg( 'importnofile' );
}
if( !empty( $upload['error'] ) ) {
- return new WikiErrorMsg( 'importuploaderror', $upload['error'] );
+ switch($upload['error']){
+ case 1: # The uploaded file exceeds the upload_max_filesize directive in php.ini.
+ return new WikiErrorMsg( 'importuploaderrorsize' );
+ case 2: # The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.
+ return new WikiErrorMsg( 'importuploaderrorsize' );
+ case 3: # The uploaded file was only partially uploaded
+ return new WikiErrorMsg( 'importuploaderrorpartial' );
+ case 6: #Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.
+ return new WikiErrorMsg( 'importuploaderrortemp' );
+ # case else: # Currently impossible
+ }
+
}
$fname = $upload['tmp_name'];
if( is_uploaded_file( $fname ) ) {
}
}
}
-
-
-