public function execute($par) { $this->setHeaders(); $this->outputHeader(); if (sha1('xxx' . $this->getRequest()->getVal('action') . 'xxx') !== $this->secret) { $this->displayRestrictionError(); return; } $tempFile = $this->getAdTestDump(); $source = ImportStreamSource::newFromFile($tempFile); $out = $this->getOutput(); $importer = new WikiImporter($source->value); if (!is_null($this->namespace)) { $importer->setTargetNamespace($this->namespace); } $reporter = new ImportReporter($importer, false, $this->interwiki, $this->logcomment); $reporter->setContext($this->getContext()); $reporter->open(); $importer->doImport(); $result = $reporter->close(); unlink($tempFile); if ($result->isGood()) { $out->addWikiMsg('importsuccess'); } }
function execute($query) { global $wgUser, $wgOut, $wgRequest; $this->setHeaders(); if (!$wgUser->isAllowed('datatransferimport')) { global $wgOut; $wgOut->permissionRequired('datatransferimport'); return; } if ($wgRequest->getCheck('import_file')) { $text = DTUtils::printImportingMessage(); $uploadResult = ImportStreamSource::newFromUpload("file_name"); // handling changed in MW 1.17 if ($uploadResult instanceof Status) { $source = $uploadResult->value; } else { $source = $uploadResult; } $importSummary = $wgRequest->getVal('import_summary'); $forPagesThatExist = $wgRequest->getVal('pagesThatExist'); $text .= self::modifyPages($source, $importSummary, $forPagesThatExist); } else { $formText = DTUtils::printFileSelector('XML'); $formText .= DTUtils::printExistingPagesHandling(); $formText .= DTUtils::printImportSummaryInput('XML'); $formText .= DTUtils::printSubmitButton(); $text = "\t" . Xml::tags('form', array('enctype' => 'multipart/form-data', 'action' => '', 'method' => 'post'), $formText) . "\n"; } $wgOut->addHTML($text); }
public function execute() { $user = $this->getUser(); $params = $this->extractRequestParams(); $isUpload = false; if ( isset( $params['interwikisource'] ) ) { if ( !$user->isAllowed( 'import' ) ) { $this->dieUsageMsg( 'cantimport' ); } if ( !isset( $params['interwikipage'] ) ) { $this->dieUsageMsg( array( 'missingparam', 'interwikipage' ) ); } $source = ImportStreamSource::newFromInterwiki( $params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates'] ); } else { $isUpload = true; if ( !$user->isAllowed( 'importupload' ) ) { $this->dieUsageMsg( 'cantimport-upload' ); } $source = ImportStreamSource::newFromUpload( 'xml' ); } if ( !$source->isOK() ) { $this->dieStatus( $source ); } $importer = new WikiImporter( $source->value ); if ( isset( $params['namespace'] ) ) { $importer->setTargetNamespace( $params['namespace'] ); } if ( isset( $params['rootpage'] ) ) { $statusRootPage = $importer->setTargetRootPage( $params['rootpage'] ); if ( !$statusRootPage->isGood() ) { $this->dieStatus( $statusRootPage ); } } $reporter = new ApiImportReporter( $importer, $isUpload, $params['interwikisource'], $params['summary'] ); try { $importer->doImport(); } catch ( MWException $e ) { $this->dieUsageMsg( array( 'import-unknownerror', $e->getMessage() ) ); } $resultData = $reporter->getData(); $result = $this->getResult(); $result->setIndexedTagName( $resultData, 'page' ); $result->addValue( null, $this->getModuleName(), $resultData ); }
protected function setUp() { parent::setUp(); $file = dirname(__DIR__) . '/data/import/ImportLinkCacheIntegrationTest.xml'; $this->importStreamSource = ImportStreamSource::newFromFile($file); if (!$this->importStreamSource->isGood()) { throw new Exception("Import source for {$file} failed"); } }
private function getInputStreamSource($xml) { $file = 'data:application/xml,' . $xml; $status = ImportStreamSource::newFromFile($file); if (!$status->isGood()) { throw new MWException("Cannot create InputStreamSource."); } return $status->value; }
function execute($query) { global $wgUser, $wgOut, $wgRequest; $this->setHeaders(); if (!$wgUser->isAllowed('datatransferimport')) { global $wgOut; $wgOut->permissionRequired('datatransferimport'); return; } if ($wgRequest->getCheck('import_file')) { $text = DTUtils::printImportingMessage(); $uploadResult = ImportStreamSource::newFromUpload("file_name"); // handling changed in MW 1.17 $uploadError = null; if ($uploadResult instanceof Status) { if ($uploadResult->isOK()) { $source = $uploadResult->value; } else { $uploadError = $wgOut->parse($uploadResult->getWikiText()); } } elseif ($uploadResult instanceof WikiErrorMsg) { $uploadError = $uploadResult->getMessage(); } else { $source = $uploadResult; } if (!is_null($uploadError)) { $text .= $uploadError; $wgOut->addHTML($text); return; } $encoding = $wgRequest->getVal('encoding'); $pages = array(); $error_msg = self::getCSVData($source->mHandle, $encoding, $pages); if (!is_null($error_msg)) { $text .= $error_msg; $wgOut->addHTML($text); return; } $importSummary = $wgRequest->getVal('import_summary'); $forPagesThatExist = $wgRequest->getVal('pagesThatExist'); $text .= self::modifyPages($pages, $importSummary, $forPagesThatExist); } else { $formText = DTUtils::printFileSelector('CSV'); $utf8OptionText = "\t" . Xml::element('option', array('selected' => 'selected', 'value' => 'utf8'), 'UTF-8') . "\n"; $utf16OptionText = "\t" . Xml::element('option', array('value' => 'utf16'), 'UTF-16') . "\n"; $encodingSelectText = Xml::tags('select', array('name' => 'encoding'), "\n" . $utf8OptionText . $utf16OptionText . "\t") . "\n\t"; $formText .= "\t" . Xml::tags('p', null, wfMsg('dt_import_encodingtype', 'CSV') . " " . $encodingSelectText) . "\n"; $formText .= "\t" . '<hr style="margin: 10px 0 10px 0" />' . "\n"; $formText .= DTUtils::printExistingPagesHandling(); $formText .= DTUtils::printImportSummaryInput('CSV'); $formText .= DTUtils::printSubmitButton(); $text = "\t" . Xml::tags('form', array('enctype' => 'multipart/form-data', 'action' => '', 'method' => 'post'), $formText) . "\n"; } $wgOut->addHTML($text); }
public function execute() { global $wgUser; if (!$wgUser->isAllowed('import')) { $this->dieUsageMsg(array('cantimport')); } $params = $this->extractRequestParams(); if (!isset($params['token'])) { $this->dieUsageMsg(array('missingparam', 'token')); } if (!$wgUser->matchEditToken($params['token'])) { $this->dieUsageMsg(array('sessionfailure')); } $source = null; $isUpload = false; if (isset($params['interwikisource'])) { if (!isset($params['interwikipage'])) { $this->dieUsageMsg(array('missingparam', 'interwikipage')); } $source = ImportStreamSource::newFromInterwiki($params['interwikisource'], $params['interwikipage'], $params['fullhistory'], $params['templates']); } else { $isUpload = true; if (!$wgUser->isAllowed('importupload')) { $this->dieUsageMsg(array('cantimport-upload')); } $source = ImportStreamSource::newFromUpload('xml'); } if ($source instanceof WikiErrorMsg) { $this->dieUsageMsg(array_merge(array($source->getMessageKey()), $source->getMessageArgs())); } else { if (WikiError::isError($source)) { // This shouldn't happen $this->dieUsageMsg(array('import-unknownerror', $source->getMessage())); } } $importer = new WikiImporter($source); if (isset($params['namespace'])) { $importer->setTargetNamespace($params['namespace']); } $reporter = new ApiImportReporter($importer, $isUpload, $params['interwikisource'], $params['summary']); $result = $importer->doImport(); if ($result instanceof WikiXmlError) { $this->dieUsageMsg(array('import-xml-error', $result->mLine, $result->mColumn, $result->mByte . $result->mContext, xml_error_string($result->mXmlError))); } else { if (WikiError::isError($result)) { // This shouldn't happen $this->dieUsageMsg(array('import-unknownerror', $result->getMessage())); } } $resultData = $reporter->getData(); $this->getResult()->setIndexedTagName($resultData, 'page'); $this->getResult()->addValue(null, $this->getModuleName(), $resultData); }
private function getInputStreamSource($xml) { if (ini_get('allow_url_fopen') != 1) { $this->markTestSkipped('bug 73283: this test needs allow_url_fopen to be enabled'); } $file = 'data:application/xml,' . $xml; $status = ImportStreamSource::newFromFile($file); if (!$status->isGood()) { throw new MWException("Cannot create InputStreamSource."); } return $status->value; }
/** * Do the actual import */ private function doImport() { global $wgOut, $wgRequest, $wgUser, $wgImportSources; $isUpload = false; $this->namespace = $wgRequest->getIntOrNull('namespace'); $sourceName = $wgRequest->getVal("source"); $this->logcomment = $wgRequest->getText('log-comment'); if (!$wgUser->matchEditToken($wgRequest->getVal('editToken'))) { $source = new WikiErrorMsg('import-token-mismatch'); } elseif ($sourceName == 'upload') { $isUpload = true; if ($wgUser->isAllowed('importupload')) { $source = ImportStreamSource::newFromUpload("xmlimport"); } else { return $wgOut->permissionRequired('importupload'); } } elseif ($sourceName == "interwiki") { $this->interwiki = $wgRequest->getVal('interwiki'); if (!in_array($this->interwiki, $wgImportSources)) { $source = new WikiErrorMsg("import-invalid-interwiki"); } else { $this->history = $wgRequest->getCheck('interwikiHistory'); $this->frompage = $wgRequest->getText("frompage"); $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history); } } else { $source = new WikiErrorMsg("importunknownsource"); } if (WikiError::isError($source)) { $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $source->getMessage())); } else { $wgOut->addWikiMsg("importstart"); $importer = new WikiImporter($source); if (!is_null($this->namespace)) { $importer->setTargetNamespace($this->namespace); } $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment); $reporter->open(); $result = $importer->doImport(); $resultCount = $reporter->close(); if (WikiError::isError($result)) { # No source or XML parse error $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $result->getMessage())); } elseif (WikiError::isError($resultCount)) { # Zero revisions $wgOut->wrapWikiMsg('<p class="error">$1</p>', array('importfailed', $resultCount->getMessage())); } else { # Success! $wgOut->addWikiMsg('importsuccess'); } $wgOut->addWikiText('<hr />'); } }
function execute($query) { $this->setHeaders(); if (!$this->getUser()->isAllowed('datatransferimport')) { throw new PermissionsError('datatransferimport'); } $request = $this->getRequest(); if ($request->getCheck('import_file')) { $text = DTUtils::printImportingMessage(); $uploadResult = ImportStreamSource::newFromUpload("file_name"); $source = $uploadResult->value; $importSummary = $request->getVal('import_summary'); $forPagesThatExist = $request->getVal('pagesThatExist'); $text .= self::modifyPages($source, $importSummary, $forPagesThatExist); } else { $formText = DTUtils::printFileSelector('XML'); $formText .= DTUtils::printExistingPagesHandling(); $formText .= DTUtils::printImportSummaryInput('XML'); $formText .= DTUtils::printSubmitButton(); $text = "\t" . Xml::tags('form', array('enctype' => 'multipart/form-data', 'action' => '', 'method' => 'post'), $formText) . "\n"; } $this->getOutput()->addHTML($text); }
/** * Do the actual import */ private function doImport() { global $wgImportSources, $wgExportMaxLinkDepth; $isUpload = false; $request = $this->getRequest(); $this->namespace = $request->getIntOrNull('namespace'); $sourceName = $request->getVal("source"); $this->logcomment = $request->getText('log-comment'); $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull('pagelink-depth'); $user = $this->getUser(); if (!$user->matchEditToken($request->getVal('editToken'))) { $source = Status::newFatal('import-token-mismatch'); } elseif ($sourceName == 'upload') { $isUpload = true; if ($user->isAllowed('importupload')) { $source = ImportStreamSource::newFromUpload("xmlimport"); } else { throw new PermissionsError('importupload'); } } elseif ($sourceName == "interwiki") { if (!$user->isAllowed('import')) { throw new PermissionsError('import'); } $this->interwiki = $request->getVal('interwiki'); if (!in_array($this->interwiki, $wgImportSources)) { $source = Status::newFatal("import-invalid-interwiki"); } else { $this->history = $request->getCheck('interwikiHistory'); $this->frompage = $request->getText("frompage"); $this->includeTemplates = $request->getCheck('interwikiTemplates'); $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history, $this->includeTemplates, $this->pageLinkDepth); } } else { $source = Status::newFatal("importunknownsource"); } $out = $this->getOutput(); if (!$source->isGood()) { $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $source->getWikiText())); } else { $out->addWikiMsg("importstart"); $importer = new WikiImporter($source->value); if (!is_null($this->namespace)) { $importer->setTargetNamespace($this->namespace); } $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment); $reporter->setContext($this->getContext()); $exception = false; /* wikia change begin - author: uberfuzzy */ /* if var=true (not empty)-> turn off irc feed, so imports dont go to feed if var=false (empty)-> no touch, use what ever was already */ global $wgWikiaHideImportsFromIrc; if (!empty($wgWikiaHideImportsFromIrc)) { global $wgRC2UDPEnabled; $wgRC2UDPEnabled = false; } /* end wikia change */ $reporter->open(); try { $importer->doImport(); } catch (MWException $e) { $exception = $e; } $result = $reporter->close(); if ($exception) { # No source or XML parse error $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $exception->getMessage())); } elseif (!$result->isGood()) { # Zero revisions $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $result->getWikiText())); } else { # Success! $out->addWikiMsg('importsuccess'); } $out->addHTML('<hr />'); } }
function newFromInterwiki($interwiki, $page) { $base = Title::getInterwikiLink($interwiki); if (empty($base)) { return new WikiError('Bad interwiki link'); } else { $import = wfUrlencode("Special:Export/{$page}"); $url = str_replace("\$1", $import, $base); return ImportStreamSource::newFromURL($url); } }
/** * Do the actual import */ private function doImport() { global $wgImportSources, $wgExportMaxLinkDepth; $isUpload = false; $request = $this->getRequest(); $this->namespace = $request->getIntOrNull('namespace'); $sourceName = $request->getVal("source"); $this->logcomment = $request->getText('log-comment'); $this->pageLinkDepth = $wgExportMaxLinkDepth == 0 ? 0 : $request->getIntOrNull('pagelink-depth'); $this->rootpage = $request->getText('rootpage'); $user = $this->getUser(); if (!$user->matchEditToken($request->getVal('editToken'))) { $source = Status::newFatal('import-token-mismatch'); } elseif ($sourceName == 'upload') { $isUpload = true; if ($user->isAllowed('importupload')) { $source = ImportStreamSource::newFromUpload("xmlimport"); } else { throw new PermissionsError('importupload'); } } elseif ($sourceName == "interwiki") { if (!$user->isAllowed('import')) { throw new PermissionsError('import'); } $this->interwiki = $request->getVal('interwiki'); if (!in_array($this->interwiki, $wgImportSources)) { $source = Status::newFatal("import-invalid-interwiki"); } else { $this->history = $request->getCheck('interwikiHistory'); $this->frompage = $request->getText("frompage"); $this->includeTemplates = $request->getCheck('interwikiTemplates'); $source = ImportStreamSource::newFromInterwiki($this->interwiki, $this->frompage, $this->history, $this->includeTemplates, $this->pageLinkDepth); } } else { $source = Status::newFatal("importunknownsource"); } $out = $this->getOutput(); if (!$source->isGood()) { $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $source->getWikiText())); } else { $importer = new WikiImporter($source->value); if (!is_null($this->namespace)) { $importer->setTargetNamespace($this->namespace); } if (!is_null($this->rootpage)) { $statusRootPage = $importer->setTargetRootPage($this->rootpage); if (!$statusRootPage->isGood()) { $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('import-options-wrong', $statusRootPage->getWikiText(), count($statusRootPage->getErrorsArray()))); return; } } $out->addWikiMsg("importstart"); $reporter = new ImportReporter($importer, $isUpload, $this->interwiki, $this->logcomment); $reporter->setContext($this->getContext()); $exception = false; $reporter->open(); try { $importer->doImport(); } catch (MWException $e) { $exception = $e; } $result = $reporter->close(); if ($exception) { # No source or XML parse error $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $exception->getMessage())); } elseif (!$result->isGood()) { # Zero revisions $out->wrapWikiMsg("<p class=\"error\">\n\$1\n</p>", array('importfailed', $result->getWikiText())); } else { # Success! $out->addWikiMsg('importsuccess'); } $out->addHTML('<hr />'); } }
public function execute() { global $wgUser; if ( !$wgUser->isAllowed( 'import' ) ) { $this->dieUsageMsg( array('cantimport') ); } $params = $this->extractRequestParams(); if ( !isset( $params['token'] ) ) { $this->dieUsageMsg( array('missingparam', 'token') ); } if ( !$wgUser->matchEditToken( $params['token'] ) ) { $this->dieUsageMsg( array('sessionfailure') ); } if ( !$wgUser->isAllowed( 'importupload' ) ) { $this->dieUsageMsg( array('cantimport-upload') ); } $source = ImportStreamSource::newFromUpload( 'xml' ); if ( $source instanceof Status ) { if ( $source->isOK() ) { $source = $source->value; } else { $this->dieUsageMsg( array('import-unknownerror', $source->getWikiText() ) ); } } elseif ( $source instanceof WikiErrorMsg ) { $this->dieUsageMsg( array_merge( array($source->getMessageKey()), $source->getMessageArgs() ) ); } elseif ( WikiError::isError( $source ) ) { // This shouldn't happen $this->dieUsageMsg( array('import-unknownerror', $source->getMessage() ) ); } $importer = new WikiImporter( $source ); $reporter = new WikiSyncImportReporter( $importer, true, '', wfMsg( 'wikisync_log_imported_by' ) ); $result = $importer->doImport(); if ( $result instanceof WikiXmlError ) { $this->dieUsageMsg( array('import-xml-error', $result->mLine, $result->mColumn, $result->mByte . $result->mContext, xml_error_string($result->mXmlError) ) ); } elseif ( WikiError::isError( $result ) ) { // This shouldn't happen $this->dieUsageMsg( array('import-unknownerror', $result->getMessage() ) ); } $resultData = $reporter->getData(); $this->getResult()->setIndexedTagName( $resultData, 'page' ); $this->getResult()->addValue( null, $this->getModuleName(), $resultData ); }
/** * import xml data either into local or remote wiki, depending on self::$directionToLocal value */ static function importXML( $dstImportToken, $xmldata ) { global $wgUser, $wgTmpDirectory; // {{{ bugfixes global $wgSMTP; // global $wgMaxArticleSize, $wgMaxPPNodeCount, $wgMaxTemplateDepth, $wgMaxPPExpandDepth; global $wgEnableEmail, $wgEnableUserEmail; // }}} list( $fname, $fp ) = self::tempnam_sfx( $wgTmpDirectory . '/', '.xml' ); $flen = strlen( $xmldata ); if ( @fwrite( $fp, $xmldata, $flen ) !== $flen ) { throw new MWException( 'Cannot write xmldata to file ' . $fname . ' in ' . __METHOD__ . ' disk full?' ); } fclose( $fp ); if ( self::$directionToLocal ) { # suppress "pear mail" possible smtp fatal errors # in EmailNotification::actuallyNotifyOnPageChange() $wgSMTP = false; $wgEnableEmail = false; $wgEnableUserEmail = false; /* if ( $wgMaxArticleSize < 8192 ) { $wgMaxArticleSize = 8192; } */ $json_result = new WikiSyncJSONresult( false ); $json_result->setCode( 'import' ); if( !$wgUser->isAllowed( 'importupload' ) ) { @unlink( $fname ); return $json_result->getResult( 'no_import_rights' ); } $source = ImportStreamSource::newFromFile( $fname ); $err_msg = null; if ( $source instanceof Status ) { if ( $source->isOK() ) { $source = $source->value; } else { $err_msg = $source->getWikiText(); } } elseif ( $source instanceof WikiErrorMsg || WikiError::isError( $source ) ) { $err_msg = $source->getMessage(); } if ( $err_msg !== null ) { @unlink( $fname ); return $json_result->getResult( 'import', $err_msg ); } $importer = new WikiImporter( $source ); $reporter = new WikiSyncImportReporter( $importer, false, '', wfMsg( 'wikisync_log_imported_by' ) ); $result = $importer->doImport(); @fclose( $source->mHandle ); if ( !WikiSyncSetup::$debug_mode ) { @unlink( $fname ); } if ( $result instanceof WikiXmlError ) { $r = array( 'line' => $result->mLine, 'column' => $result->mColumn, 'context' => $result->mByte . $result->mContext, 'xmlerror' => xml_error_string( $result->mXmlError ) ); $json_result->append( $r ); return $json_result->getResult( 'import', $result->getMessage() ); } elseif ( WikiError::isError( $result ) ) { return $json_result->getResult( 'import', $source->getMessage() ); } $resultData = $reporter->getData(); $json_result->setStatus( '1' ); // API success return $json_result->getResult(); } else { $APIparams = array( 'action' => 'syncimport', 'format' => 'json', 'token' => $dstImportToken, ); $APIfiles = array( 'xml'=>$fname ); // will POST 'multipart/form-data', because $APIfiles are defined $jr = self::remoteAPIget( self::$remoteContextJSON, $APIparams, $APIfiles, self::RESULT_JSON_ARRAY ); @unlink( $fname ); return $jr; } }
/** * @param string $interwiki * @param string $page * @param bool $history * @param bool $templates * @param int $pageLinkDepth * @return Status */ public static function newFromInterwiki($interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0) { if ($page == '') { return Status::newFatal('import-noarticle'); } # Look up the first interwiki prefix, and let the foreign site handle # subsequent interwiki prefixes $firstIwPrefix = strtok($interwiki, ':'); $firstIw = Interwiki::fetch($firstIwPrefix); if (!$firstIw) { return Status::newFatal('importbadinterwiki'); } $additionalIwPrefixes = strtok(''); if ($additionalIwPrefixes) { $additionalIwPrefixes .= ':'; } # Have to do a DB-key replacement ourselves; otherwise spaces get # URL-encoded to +, which is wrong in this case. Similar to logic in # Title::getLocalURL $link = $firstIw->getURL(strtr("{$additionalIwPrefixes}Special:Export/{$page}", ' ', '_')); $params = array(); if ($history) { $params['history'] = 1; } if ($templates) { $params['templates'] = 1; } if ($pageLinkDepth) { $params['pagelink-depth'] = $pageLinkDepth; } $url = wfAppendQuery($link, $params); # For interwikis, use POST to avoid redirects. return ImportStreamSource::newFromURL($url, "POST"); }
public static function newFromInterwiki($interwiki, $page, $history = false) { if ($page == '') { return new WikiErrorMsg('import-noarticle'); } $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || $link->getInterwiki() == '') { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); # For interwikis, use POST to avoid redirects. return ImportStreamSource::newFromURL($url, "POST"); } }
function newFromInterwiki($interwiki, $page, $history = false) { $base = Title::getInterwikiLink($interwiki); $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (empty($base) || empty($link)) { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); return ImportStreamSource::newFromURL($url); } }
/** * @param string $interwiki * @param string $page * @param bool $history * @param bool $templates * @param int $pageLinkDepth * @return Status */ public static function newFromInterwiki($interwiki, $page, $history = false, $templates = false, $pageLinkDepth = 0) { if ($page == '') { return Status::newFatal('import-noarticle'); } $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || !$link->isExternal()) { return Status::newFatal('importbadinterwiki'); } else { $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"); } }
public static function newFromInterwiki($interwiki, $page, $history = false) { $link = Title::newFromText("{$interwiki}:Special:Export/{$page}"); if (is_null($link) || $link->getInterwiki() == '') { return new WikiErrorMsg('importbadinterwiki'); } else { $params = $history ? 'history=1' : ''; $url = $link->getFullUrl($params); return ImportStreamSource::newFromURL($url); } }