50 parent::__construct(
'Import',
'import' );
69 $this->
namespace = $this->
getConfig()->get( 'ImportTargetNamespace' );
71 $this->
getOutput()->addModules(
'mediawiki.special.import' );
73 $this->importSources = $this->
getConfig()->get(
'ImportSources' );
74 Hooks::run(
'ImportSources', [ &$this->importSources ] );
77 if ( !$user->isAllowedAny(
'import',
'importupload' ) ) {
81 # @todo Allow Title::getUserPermissionsErrors() to take an array
82 # @todo FIXME: Title::checkSpecialsAndNSPermissions() has a very weird expectation of what
83 # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
86 'import', $user,
true,
87 [
'ns-specialprotected',
'badaccess-group0',
'badaccess-groups' ]
90 'importupload', $user,
true,
91 [
'ns-specialprotected',
'badaccess-group0',
'badaccess-groups' ]
114 $this->sourceName =
$request->getVal(
"source" );
115 $this->assignKnownUsers =
$request->getCheck(
'assignKnownUsers' );
117 $this->logcomment =
$request->getText(
'log-comment' );
118 $this->pageLinkDepth = $this->
getConfig()->get(
'ExportMaxLinkDepth' ) == 0
120 :
$request->getIntOrNull(
'pagelink-depth' );
122 $this->mapping =
$request->getVal(
'mapping' );
123 if ( $this->mapping ===
'namespace' ) {
124 $this->
namespace =
$request->getIntOrNull( 'namespace' );
125 }
elseif ( $this->mapping ===
'subpage' ) {
126 $this->rootpage =
$request->getText(
'rootpage' );
128 $this->mapping =
'default';
132 if ( !$user->matchEditToken(
$request->getVal(
'editToken' ) ) ) {
133 $source = Status::newFatal(
'import-token-mismatch' );
134 }
elseif ( $this->sourceName ===
'upload' ) {
136 $this->usernamePrefix = $this->fullInterwikiPrefix =
$request->getVal(
'usernamePrefix' );
137 if ( $user->isAllowed(
'importupload' ) ) {
142 }
elseif ( $this->sourceName ===
'interwiki' ) {
143 if ( !$user->isAllowed(
'import' ) ) {
146 $this->interwiki = $this->fullInterwikiPrefix =
$request->getVal(
'interwiki' );
148 $hasSubprojects =
array_key_exists( $this->interwiki, $this->importSources );
149 if ( !$hasSubprojects && !
in_array( $this->interwiki, $this->importSources ) ) {
150 $source = Status::newFatal(
"import-invalid-interwiki" );
152 if ( $hasSubprojects ) {
153 $this->subproject =
$request->getVal(
'subproject' );
154 $this->fullInterwikiPrefix .=
':' .
$request->getVal(
'subproject' );
156 if ( $hasSubprojects &&
157 !
in_array( $this->subproject, $this->importSources[$this->interwiki] )
159 $source = Status::newFatal(
"import-invalid-interwiki" );
162 $this->frompage =
$request->getText(
"frompage" );
163 $this->includeTemplates =
$request->getCheck(
'interwikiTemplates' );
165 $this->fullInterwikiPrefix,
168 $this->includeTemplates,
169 $this->pageLinkDepth );
173 $source = Status::newFatal(
"importunknownsource" );
176 if ( (
string)$this->fullInterwikiPrefix ===
'' ) {
177 $source->fatal(
'importnoprefix' );
182 $out->wrapWikiTextAsInterface(
'error',
183 $this->
msg(
'importfailed',
$source->getWikiText() )->plain()
187 if ( !
is_null( $this->
namespace ) ) {
188 $importer->setTargetNamespace( $this->
namespace );
190 $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
191 if ( !$statusRootPage->isGood() ) {
193 "<div class=\"error\">\n$1\n</div>",
195 'import-options-wrong',
196 $statusRootPage->getWikiText(),
197 count( $statusRootPage->getErrorsArray() )
204 $importer->setUsernamePrefix( $this->fullInterwikiPrefix, $this->assignKnownUsers );
206 $out->addWikiMsg(
"importstart" );
211 $this->fullInterwikiPrefix,
219 $importer->doImport();
220 }
catch ( Exception
$e ) {
223 $result = $reporter->close();
226 # No source or XML parse error
228 "<div class=\"error\">\n$1\n</div>",
229 [
'importfailed', $exception->getMessage() ]
231 }
elseif ( !$result->isGood() ) {
234 "<div class=\"error\">\n$1\n</div>",
235 [
'importfailed', $result->getWikiText() ]
239 $out->addWikiMsg(
'importsuccess' );
241 $out->addHTML(
'<hr />' );
246 $isSameSourceAsBefore = ( $this->sourceName ===
$sourceName );
247 $defaultNamespace = $this->
getConfig()->get(
'ImportTargetNamespace' );
251 <td class='mw-input'>" .
253 $this->
msg(
'import-mapping-default' )->
text(),
257 "mw-import-mapping-$sourceName-default",
258 ( $isSameSourceAsBefore ?
259 ( $this->mapping ===
'default' ) :
267 <td class='mw-input'>" .
269 $this->
msg(
'import-mapping-namespace' )->
text(),
273 "mw-import-mapping-$sourceName-namespace",
274 ( $isSameSourceAsBefore ?
275 ( $this->mapping ===
'namespace' ) :
276 !
is_null( $defaultNamespace ) )
278 Html::namespaceSelector(
280 'selected' => ( $isSameSourceAsBefore ?
282 ( $defaultNamespace ||
'' ) ),
283 'in-user-lang' =>
true,
285 'name' =>
"namespace",
287 'id' =>
"mw-import-namespace-$sourceName",
288 'class' =>
'namespaceselector',
296 <td class='mw-input'>" .
298 $this->
msg(
'import-mapping-subpage' )->text(),
302 "mw-import-mapping-$sourceName-subpage",
303 ( $isSameSourceAsBefore ? ( $this->mapping ===
'subpage' ) :
'' )
305 Xml::input(
'rootpage', 50,
306 ( $isSameSourceAsBefore ? $this->rootpage :
'' ),
311 'id' =>
"mw-interwiki-rootpage-$sourceName",
320 $action = $this->
getPageTitle()->getLocalURL( [
'action' =>
'submit' ] );
323 $this->
addHelpLink(
'//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import',
true );
325 if ( $user->isAllowed(
'importupload' ) ) {
328 Xml::fieldset( $this->
msg(
'import-upload' )->
text() ) .
332 'enctype' =>
'multipart/form-data',
335 'id' =>
'mw-import-upload-form'
338 $this->
msg(
'importtext' )->parseAsBlock() .
339 Html::hidden(
'action',
'submit' ) .
340 Html::hidden(
'source',
'upload' ) .
341 Xml::openElement(
'table', [
'id' =>
'mw-import-table-upload' ] ) .
343 <td class='mw-label'>" .
344 Xml::label( $this->
msg(
'import-upload-filename' )->
text(),
'xmlimport' ) .
346 <td class='mw-input'>" .
347 Html::input(
'xmlimport',
'',
'file', [
'id' =>
'xmlimport' ] ) .
' ' .
351 <td class='mw-label'>" .
352 Xml::label( $this->
msg(
'import-upload-username-prefix' )->
text(),
353 'mw-import-usernamePrefix' ) .
355 <td class='mw-input'>" .
356 Xml::input(
'usernamePrefix', 50,
357 $this->usernamePrefix,
358 [
'id' =>
'usernamePrefix',
'type' =>
'text' ] ) .
' ' .
363 <td class='mw-input'>" .
365 $this->
msg(
'import-assign-known-users' )->
text(),
368 $this->assignKnownUsers
373 <td class='mw-label'>" .
374 Xml::label( $this->
msg(
'import-comment' )->
text(),
'mw-import-comment' ) .
376 <td class='mw-input'>" .
377 Xml::input(
'log-comment', 50,
378 ( $this->sourceName ===
'upload' ? $this->logcomment :
'' ),
379 [
'id' =>
'mw-import-comment',
'type' =>
'text' ] ) .
' ' .
385 <td class='mw-submit'>" .
386 Xml::submitButton( $this->
msg(
'uploadbtn' )->
text() ) .
389 Xml::closeElement(
'table' ) .
390 Html::hidden(
'editToken', $user->getEditToken() ) .
391 Xml::closeElement(
'form' ) .
392 Xml::closeElement(
'fieldset' )
394 }
elseif ( empty( $this->importSources ) ) {
395 $out->addWikiMsg(
'importnosources' );
398 if ( $user->isAllowed(
'import' ) && !empty( $this->importSources ) ) {
399 # Show input field for import depth only if $wgExportMaxLinkDepth > 0
401 if ( $this->
getConfig()->
get(
'ExportMaxLinkDepth' ) > 0 ) {
403 <td class='mw-label'>" .
404 $this->
msg(
'export-pagelinks' )->parse() .
406 <td class='mw-input'>" .
407 Xml::input(
'pagelink-depth', 3, 0 ) .
414 Xml::fieldset( $this->
msg(
'importinterwiki' )->
text() ) .
420 'id' =>
'mw-import-interwiki-form'
423 $this->
msg(
'import-interwiki-text' )->parseAsBlock() .
424 Html::hidden(
'action',
'submit' ) .
425 Html::hidden(
'source',
'interwiki' ) .
426 Html::hidden(
'editToken', $user->getEditToken() ) .
427 Xml::openElement(
'table', [
'id' =>
'mw-import-table-interwiki' ] ) .
429 <td class='mw-label'>" .
430 Xml::label( $this->msg(
'import-interwiki-sourcewiki' )->text(),
'interwiki' ) .
432 <td class='mw-input'>" .
435 [
'name' =>
'interwiki',
'id' =>
'interwiki' ]
439 $needSubprojectField =
false;
440 foreach ( $this->importSources as $key =>
$value ) {
444 $needSubprojectField =
true;
453 if ( $this->interwiki === $key ) {
456 $out->addHTML( Html::element(
'option',
$attribs, $key ) );
460 Xml::closeElement(
'select' )
463 if ( $needSubprojectField ) {
467 [
'name' =>
'subproject',
'id' =>
'subproject' ]
471 $subprojectsToAdd = [];
472 foreach ( $this->importSources as $key =>
$value ) {
478 sort( $subprojectsToAdd );
484 Xml::closeElement(
'select' )
492 <td class='mw-label'>" .
493 Xml::label( $this->
msg(
'import-interwiki-sourcepage' )->
text(),
'frompage' ) .
495 <td class='mw-input'>" .
496 Xml::input(
'frompage', 50, $this->frompage, [
'id' =>
'frompage' ] ) .
502 <td class='mw-input'>" .
504 $this->
msg(
'import-interwiki-history' )->
text(),
514 <td class='mw-input'>" .
516 $this->
msg(
'import-interwiki-templates' )->
text(),
517 'interwikiTemplates',
518 'interwikiTemplates',
519 $this->includeTemplates
525 <td class='mw-input'>" .
527 $this->
msg(
'import-assign-known-users' )->
text(),
529 'interwikiAssignKnownUsers',
530 $this->assignKnownUsers
536 <td class='mw-label'>" .
537 Xml::label( $this->
msg(
'import-comment' )->
text(),
'mw-interwiki-comment' ) .
539 <td class='mw-input'>" .
540 Xml::input(
'log-comment', 50,
541 ( $this->sourceName ===
'interwiki' ? $this->logcomment :
'' ),
542 [
'id' =>
'mw-interwiki-comment',
'type' =>
'text' ] ) .
' ' .
549 <td class='mw-submit'>" .
551 $this->
msg(
'import-interwiki-submit' )->
text(),
556 Xml::closeElement(
'table' ) .
557 Xml::closeElement(
'form' ) .
558 Xml::closeElement(
'fieldset' )
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfMergeErrorArrays(... $args)
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
static newFromUpload( $fieldname="xmlimport")
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Show an error when a user tries to do something they do not have the necessary permissions for.
MediaWiki page data importer.
doesWrites()
Indicates whether this special page may perform database writes.
getMappingFormPart( $sourceName)
doImport()
Do the actual import.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
getPageTitle( $subpage=false)
Get a self-referential title object.
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
XML file reader for the page data importer.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
presenting them properly to the user as errors is done by the caller return true use this to change the list i e etc next in line in page history
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
returning false will NOT prevent logging $e