MediaWiki  1.30.0
SpecialImport.php
Go to the documentation of this file.
1 <?php
32 class SpecialImport extends SpecialPage {
33  private $sourceName = false;
34  private $interwiki = false;
35  private $subproject;
37  private $mapping = 'default';
38  private $namespace;
39  private $rootpage = '';
40  private $frompage = '';
41  private $logcomment = false;
42  private $history = true;
43  private $includeTemplates = false;
44  private $pageLinkDepth;
45  private $importSources;
46 
47  public function __construct() {
48  parent::__construct( 'Import', 'import' );
49  }
50 
51  public function doesWrites() {
52  return true;
53  }
54 
61  function execute( $par ) {
63 
64  $this->setHeaders();
65  $this->outputHeader();
66 
67  $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
68 
69  $this->getOutput()->addModules( 'mediawiki.special.import' );
70 
71  $this->importSources = $this->getConfig()->get( 'ImportSources' );
72  Hooks::run( 'ImportSources', [ &$this->importSources ] );
73 
74  $user = $this->getUser();
75  if ( !$user->isAllowedAny( 'import', 'importupload' ) ) {
76  throw new PermissionsError( 'import' );
77  }
78 
79  # @todo Allow Title::getUserPermissionsErrors() to take an array
80  # @todo FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
81  # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
82  $errors = wfMergeErrorArrays(
83  $this->getPageTitle()->getUserPermissionsErrors(
84  'import', $user, true,
85  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
86  ),
87  $this->getPageTitle()->getUserPermissionsErrors(
88  'importupload', $user, true,
89  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
90  )
91  );
92 
93  if ( $errors ) {
94  throw new PermissionsError( 'import', $errors );
95  }
96 
97  $this->checkReadOnly();
98 
99  $request = $this->getRequest();
100  if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) {
101  $this->doImport();
102  }
103  $this->showForm();
104  }
105 
109  private function doImport() {
110  $isUpload = false;
111  $request = $this->getRequest();
112  $this->sourceName = $request->getVal( "source" );
113 
114  $this->logcomment = $request->getText( 'log-comment' );
115  $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0
116  ? 0
117  : $request->getIntOrNull( 'pagelink-depth' );
118 
119  $this->mapping = $request->getVal( 'mapping' );
120  if ( $this->mapping === 'namespace' ) {
121  $this->namespace = $request->getIntOrNull( 'namespace' );
122  } elseif ( $this->mapping === 'subpage' ) {
123  $this->rootpage = $request->getText( 'rootpage' );
124  } else {
125  $this->mapping = 'default';
126  }
127 
128  $user = $this->getUser();
129  if ( !$user->matchEditToken( $request->getVal( 'editToken' ) ) ) {
130  $source = Status::newFatal( 'import-token-mismatch' );
131  } elseif ( $this->sourceName === 'upload' ) {
132  $isUpload = true;
133  if ( $user->isAllowed( 'importupload' ) ) {
135  } else {
136  throw new PermissionsError( 'importupload' );
137  }
138  } elseif ( $this->sourceName === 'interwiki' ) {
139  if ( !$user->isAllowed( 'import' ) ) {
140  throw new PermissionsError( 'import' );
141  }
142  $this->interwiki = $this->fullInterwikiPrefix = $request->getVal( 'interwiki' );
143  // does this interwiki have subprojects?
144  $hasSubprojects = array_key_exists( $this->interwiki, $this->importSources );
145  if ( !$hasSubprojects && !in_array( $this->interwiki, $this->importSources ) ) {
146  $source = Status::newFatal( "import-invalid-interwiki" );
147  } else {
148  if ( $hasSubprojects ) {
149  $this->subproject = $request->getVal( 'subproject' );
150  $this->fullInterwikiPrefix .= ':' . $request->getVal( 'subproject' );
151  }
152  if ( $hasSubprojects &&
153  !in_array( $this->subproject, $this->importSources[$this->interwiki] )
154  ) {
155  $source = Status::newFatal( "import-invalid-interwiki" );
156  } else {
157  $this->history = $request->getCheck( 'interwikiHistory' );
158  $this->frompage = $request->getText( "frompage" );
159  $this->includeTemplates = $request->getCheck( 'interwikiTemplates' );
161  $this->fullInterwikiPrefix,
162  $this->frompage,
163  $this->history,
164  $this->includeTemplates,
165  $this->pageLinkDepth );
166  }
167  }
168  } else {
169  $source = Status::newFatal( "importunknownsource" );
170  }
171 
172  $out = $this->getOutput();
173  if ( !$source->isGood() ) {
174  $out->addWikiText( "<p class=\"error\">\n" .
175  $this->msg( 'importfailed', $source->getWikiText() )->parse() . "\n</p>" );
176  } else {
177  $importer = new WikiImporter( $source->value, $this->getConfig() );
178  if ( !is_null( $this->namespace ) ) {
179  $importer->setTargetNamespace( $this->namespace );
180  } elseif ( !is_null( $this->rootpage ) ) {
181  $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
182  if ( !$statusRootPage->isGood() ) {
183  $out->wrapWikiMsg(
184  "<p class=\"error\">\n$1\n</p>",
185  [
186  'import-options-wrong',
187  $statusRootPage->getWikiText(),
188  count( $statusRootPage->getErrorsArray() )
189  ]
190  );
191 
192  return;
193  }
194  }
195 
196  $out->addWikiMsg( "importstart" );
197 
198  $reporter = new ImportReporter(
199  $importer,
200  $isUpload,
201  $this->fullInterwikiPrefix,
202  $this->logcomment
203  );
204  $reporter->setContext( $this->getContext() );
205  $exception = false;
206 
207  $reporter->open();
208  try {
209  $importer->doImport();
210  } catch ( Exception $e ) {
211  $exception = $e;
212  }
213  $result = $reporter->close();
214 
215  if ( $exception ) {
216  # No source or XML parse error
217  $out->wrapWikiMsg(
218  "<p class=\"error\">\n$1\n</p>",
219  [ 'importfailed', $exception->getMessage() ]
220  );
221  } elseif ( !$result->isGood() ) {
222  # Zero revisions
223  $out->wrapWikiMsg(
224  "<p class=\"error\">\n$1\n</p>",
225  [ 'importfailed', $result->getWikiText() ]
226  );
227  } else {
228  # Success!
229  $out->addWikiMsg( 'importsuccess' );
230  }
231  $out->addHTML( '<hr />' );
232  }
233  }
234 
235  private function getMappingFormPart( $sourceName ) {
236  $isSameSourceAsBefore = ( $this->sourceName === $sourceName );
237  $defaultNamespace = $this->getConfig()->get( 'ImportTargetNamespace' );
238  return "<tr>
239  <td>
240  </td>
241  <td class='mw-input'>" .
243  $this->msg( 'import-mapping-default' )->text(),
244  'mapping',
245  'default',
246  // mw-import-mapping-interwiki-default, mw-import-mapping-upload-default
247  "mw-import-mapping-$sourceName-default",
248  ( $isSameSourceAsBefore ?
249  ( $this->mapping === 'default' ) :
250  is_null( $defaultNamespace ) )
251  ) .
252  "</td>
253  </tr>
254  <tr>
255  <td>
256  </td>
257  <td class='mw-input'>" .
259  $this->msg( 'import-mapping-namespace' )->text(),
260  'mapping',
261  'namespace',
262  // mw-import-mapping-interwiki-namespace, mw-import-mapping-upload-namespace
263  "mw-import-mapping-$sourceName-namespace",
264  ( $isSameSourceAsBefore ?
265  ( $this->mapping === 'namespace' ) :
266  !is_null( $defaultNamespace ) )
267  ) . ' ' .
269  [
270  'selected' => ( $isSameSourceAsBefore ?
271  $this->namespace :
272  ( $defaultNamespace || '' ) ),
273  ], [
274  'name' => "namespace",
275  // mw-import-namespace-interwiki, mw-import-namespace-upload
276  'id' => "mw-import-namespace-$sourceName",
277  'class' => 'namespaceselector',
278  ]
279  ) .
280  "</td>
281  </tr>
282  <tr>
283  <td>
284  </td>
285  <td class='mw-input'>" .
287  $this->msg( 'import-mapping-subpage' )->text(),
288  'mapping',
289  'subpage',
290  // mw-import-mapping-interwiki-subpage, mw-import-mapping-upload-subpage
291  "mw-import-mapping-$sourceName-subpage",
292  ( $isSameSourceAsBefore ? ( $this->mapping === 'subpage' ) : '' )
293  ) . ' ' .
294  Xml::input( 'rootpage', 50,
295  ( $isSameSourceAsBefore ? $this->rootpage : '' ),
296  [
297  // Should be "mw-import-rootpage-...", but we keep this inaccurate
298  // ID for legacy reasons
299  // mw-interwiki-rootpage-interwiki, mw-interwiki-rootpage-upload
300  'id' => "mw-interwiki-rootpage-$sourceName",
301  'type' => 'text'
302  ]
303  ) . ' ' .
304  "</td>
305  </tr>";
306  }
307 
308  private function showForm() {
309  $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
310  $user = $this->getUser();
311  $out = $this->getOutput();
312  $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import', true );
313 
314  if ( $user->isAllowed( 'importupload' ) ) {
315  $mappingSelection = $this->getMappingFormPart( 'upload' );
316  $out->addHTML(
317  Xml::fieldset( $this->msg( 'import-upload' )->text() ) .
319  'form',
320  [
321  'enctype' => 'multipart/form-data',
322  'method' => 'post',
323  'action' => $action,
324  'id' => 'mw-import-upload-form'
325  ]
326  ) .
327  $this->msg( 'importtext' )->parseAsBlock() .
328  Html::hidden( 'action', 'submit' ) .
329  Html::hidden( 'source', 'upload' ) .
330  Xml::openElement( 'table', [ 'id' => 'mw-import-table-upload' ] ) .
331  "<tr>
332  <td class='mw-label'>" .
333  Xml::label( $this->msg( 'import-upload-filename' )->text(), 'xmlimport' ) .
334  "</td>
335  <td class='mw-input'>" .
336  Html::input( 'xmlimport', '', 'file', [ 'id' => 'xmlimport' ] ) . ' ' .
337  "</td>
338  </tr>
339  <tr>
340  <td class='mw-label'>" .
341  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-import-comment' ) .
342  "</td>
343  <td class='mw-input'>" .
344  Xml::input( 'log-comment', 50,
345  ( $this->sourceName === 'upload' ? $this->logcomment : '' ),
346  [ 'id' => 'mw-import-comment', 'type' => 'text' ] ) . ' ' .
347  "</td>
348  </tr>
349  $mappingSelection
350  <tr>
351  <td></td>
352  <td class='mw-submit'>" .
353  Xml::submitButton( $this->msg( 'uploadbtn' )->text() ) .
354  "</td>
355  </tr>" .
356  Xml::closeElement( 'table' ) .
357  Html::hidden( 'editToken', $user->getEditToken() ) .
358  Xml::closeElement( 'form' ) .
359  Xml::closeElement( 'fieldset' )
360  );
361  } else {
362  if ( empty( $this->importSources ) ) {
363  $out->addWikiMsg( 'importnosources' );
364  }
365  }
366 
367  if ( $user->isAllowed( 'import' ) && !empty( $this->importSources ) ) {
368  # Show input field for import depth only if $wgExportMaxLinkDepth > 0
369  $importDepth = '';
370  if ( $this->getConfig()->get( 'ExportMaxLinkDepth' ) > 0 ) {
371  $importDepth = "<tr>
372  <td class='mw-label'>" .
373  $this->msg( 'export-pagelinks' )->parse() .
374  "</td>
375  <td class='mw-input'>" .
376  Xml::input( 'pagelink-depth', 3, 0 ) .
377  "</td>
378  </tr>";
379  }
380  $mappingSelection = $this->getMappingFormPart( 'interwiki' );
381 
382  $out->addHTML(
383  Xml::fieldset( $this->msg( 'importinterwiki' )->text() ) .
385  'form',
386  [
387  'method' => 'post',
388  'action' => $action,
389  'id' => 'mw-import-interwiki-form'
390  ]
391  ) .
392  $this->msg( 'import-interwiki-text' )->parseAsBlock() .
393  Html::hidden( 'action', 'submit' ) .
394  Html::hidden( 'source', 'interwiki' ) .
395  Html::hidden( 'editToken', $user->getEditToken() ) .
396  Xml::openElement( 'table', [ 'id' => 'mw-import-table-interwiki' ] ) .
397  "<tr>
398  <td class='mw-label'>" .
399  Xml::label( $this->msg( 'import-interwiki-sourcewiki' )->text(), 'interwiki' ) .
400  "</td>
401  <td class='mw-input'>" .
403  'select',
404  [ 'name' => 'interwiki', 'id' => 'interwiki' ]
405  )
406  );
407 
408  $needSubprojectField = false;
409  foreach ( $this->importSources as $key => $value ) {
410  if ( is_int( $key ) ) {
411  $key = $value;
412  } elseif ( $value !== $key ) {
413  $needSubprojectField = true;
414  }
415 
416  $attribs = [
417  'value' => $key,
418  ];
419  if ( is_array( $value ) ) {
420  $attribs['data-subprojects'] = implode( ' ', $value );
421  }
422  if ( $this->interwiki === $key ) {
423  $attribs['selected'] = 'selected';
424  }
425  $out->addHTML( Html::element( 'option', $attribs, $key ) );
426  }
427 
428  $out->addHTML(
429  Xml::closeElement( 'select' )
430  );
431 
432  if ( $needSubprojectField ) {
433  $out->addHTML(
435  'select',
436  [ 'name' => 'subproject', 'id' => 'subproject' ]
437  )
438  );
439 
440  $subprojectsToAdd = [];
441  foreach ( $this->importSources as $key => $value ) {
442  if ( is_array( $value ) ) {
443  $subprojectsToAdd = array_merge( $subprojectsToAdd, $value );
444  }
445  }
446  $subprojectsToAdd = array_unique( $subprojectsToAdd );
447  sort( $subprojectsToAdd );
448  foreach ( $subprojectsToAdd as $subproject ) {
449  $out->addHTML( Xml::option( $subproject, $subproject, $this->subproject === $subproject ) );
450  }
451 
452  $out->addHTML(
453  Xml::closeElement( 'select' )
454  );
455  }
456 
457  $out->addHTML(
458  "</td>
459  </tr>
460  <tr>
461  <td class='mw-label'>" .
462  Xml::label( $this->msg( 'import-interwiki-sourcepage' )->text(), 'frompage' ) .
463  "</td>
464  <td class='mw-input'>" .
465  Xml::input( 'frompage', 50, $this->frompage, [ 'id' => 'frompage' ] ) .
466  "</td>
467  </tr>
468  <tr>
469  <td>
470  </td>
471  <td class='mw-input'>" .
473  $this->msg( 'import-interwiki-history' )->text(),
474  'interwikiHistory',
475  'interwikiHistory',
476  $this->history
477  ) .
478  "</td>
479  </tr>
480  <tr>
481  <td>
482  </td>
483  <td class='mw-input'>" .
485  $this->msg( 'import-interwiki-templates' )->text(),
486  'interwikiTemplates',
487  'interwikiTemplates',
488  $this->includeTemplates
489  ) .
490  "</td>
491  </tr>
492  $importDepth
493  <tr>
494  <td class='mw-label'>" .
495  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-interwiki-comment' ) .
496  "</td>
497  <td class='mw-input'>" .
498  Xml::input( 'log-comment', 50,
499  ( $this->sourceName === 'interwiki' ? $this->logcomment : '' ),
500  [ 'id' => 'mw-interwiki-comment', 'type' => 'text' ] ) . ' ' .
501  "</td>
502  </tr>
503  $mappingSelection
504  <tr>
505  <td>
506  </td>
507  <td class='mw-submit'>" .
509  $this->msg( 'import-interwiki-submit' )->text(),
511  ) .
512  "</td>
513  </tr>" .
514  Xml::closeElement( 'table' ) .
515  Xml::closeElement( 'form' ) .
516  Xml::closeElement( 'fieldset' )
517  );
518  }
519  }
520 
521  protected function getGroupName() {
522  return 'pagetools';
523  }
524 }
SpecialImport\showForm
showForm()
Definition: SpecialImport.php:308
SpecialImport
MediaWiki page data importer.
Definition: SpecialImport.php:32
SpecialImport\$pageLinkDepth
$pageLinkDepth
Definition: SpecialImport.php:44
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:244
SpecialImport\$includeTemplates
$includeTemplates
Definition: SpecialImport.php:43
WikiImporter
XML file reader for the page data importer.
Definition: WikiImporter.php:34
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
wfMergeErrorArrays
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
Definition: GlobalFunctions.php:276
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
Xml\label
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:358
captcha-old.count
count
Definition: captcha-old.py:249
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:12
SpecialImport\$fullInterwikiPrefix
$fullInterwikiPrefix
Definition: SpecialImport.php:36
$result
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. & $title:Title object for the current page & $request:WebRequest & $ignoreRedirect:boolean to skip redirect check & $target:Title/string of redirect target & $article:Article object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) & $article:article(object) being checked 'IsTrustedProxy':Override the result of IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of Sanitizer::validateEmail(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetMagic':DEPRECATED! Use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language & $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetSpecialPageAliases':DEPRECATED! Use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language & $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code:language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Array with elements of the form "language:title" in the order that they will be output. & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
Definition: hooks.txt:1963
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:68
Xml\option
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:484
SpecialPage\useTransactionalTimeLimit
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition: SpecialPage.php:850
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition: PermissionsError.php:28
ImportReporter
Reporting callback.
Definition: ImportReporter.php:27
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
SpecialImport\$namespace
$namespace
Definition: SpecialImport.php:38
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
Html\input
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:642
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:609
SpecialImport\$subproject
$subproject
Definition: SpecialImport.php:35
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:785
SpecialImport\execute
execute( $par)
Execute.
Definition: SpecialImport.php:61
SpecialImport\doImport
doImport()
Do the actual import.
Definition: SpecialImport.php:109
SpecialImport\$importSources
$importSources
Definition: SpecialImport.php:45
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:714
$attribs
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
Definition: hooks.txt:1965
SpecialImport\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialImport.php:521
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:484
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:685
SpecialImport\doesWrites
doesWrites()
Indicates whether this special page may perform database writes.
Definition: SpecialImport.php:51
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:648
ImportStreamSource\newFromInterwiki
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
Definition: ImportStreamSource.php:142
SpecialImport\$interwiki
$interwiki
Definition: SpecialImport.php:34
$request
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
Definition: hooks.txt:2581
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:725
SpecialImport\$frompage
$frompage
Definition: SpecialImport.php:40
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2141
$value
$value
Definition: styleTest.css.php:45
Linker\tooltipAndAccesskeyAttribs
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[])
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2111
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:813
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:665
SpecialImport\$logcomment
$logcomment
Definition: SpecialImport.php:41
Xml\radioLabel
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:444
Xml\closeElement
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:118
SpecialImport\$sourceName
$sourceName
Definition: SpecialImport.php:33
history
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
Definition: hooks.txt:1750
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
SpecialImport\__construct
__construct()
Definition: SpecialImport.php:47
$source
$source
Definition: mwdoc-filter.php:46
SpecialImport\$mapping
$mapping
Definition: SpecialImport.php:37
Xml\input
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:274
SpecialPage\checkReadOnly
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
Definition: SpecialPage.php:319
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialImport\$rootpage
$rootpage
Definition: SpecialImport.php:39
WikiImporter\setTargetNamespace
setTargetNamespace( $namespace)
Set a target namespace to override the defaults.
Definition: WikiImporter.php:250
SpecialImport\$history
$history
Definition: SpecialImport.php:42
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:583
ImportStreamSource\newFromUpload
static newFromUpload( $fieldname="xmlimport")
Definition: ImportStreamSource.php:69
Xml\submitButton
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:459
Xml\checkLabel
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:419
SpecialImport\getMappingFormPart
getMappingFormPart( $sourceName)
Definition: SpecialImport.php:235
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
Definition: hooks.txt:781