MediaWiki  1.29.2
SpecialImport.php
Go to the documentation of this file.
1 <?php
28 
34 class SpecialImport extends SpecialPage {
35  private $sourceName = false;
36  private $interwiki = false;
37  private $subproject;
39  private $mapping = 'default';
40  private $namespace;
41  private $rootpage = '';
42  private $frompage = '';
43  private $logcomment = false;
44  private $history = true;
45  private $includeTemplates = false;
46  private $pageLinkDepth;
47  private $importSources;
48 
52  public function __construct() {
53  parent::__construct( 'Import', 'import' );
54  }
55 
56  public function doesWrites() {
57  return true;
58  }
59 
66  function execute( $par ) {
68 
69  $this->setHeaders();
70  $this->outputHeader();
71 
72  $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
73 
74  $this->getOutput()->addModules( 'mediawiki.special.import' );
75 
76  $this->importSources = $this->getConfig()->get( 'ImportSources' );
77  Hooks::run( 'ImportSources', [ &$this->importSources ] );
78 
79  $user = $this->getUser();
80  if ( !$user->isAllowedAny( 'import', 'importupload' ) ) {
81  throw new PermissionsError( 'import' );
82  }
83 
84  # @todo Allow Title::getUserPermissionsErrors() to take an array
85  # @todo FIXME: Title::checkSpecialsAndNSPermissions() has a very wierd expectation of what
86  # getUserPermissionsErrors() might actually be used for, hence the 'ns-specialprotected'
87  $errors = wfMergeErrorArrays(
88  $this->getPageTitle()->getUserPermissionsErrors(
89  'import', $user, true,
90  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
91  ),
92  $this->getPageTitle()->getUserPermissionsErrors(
93  'importupload', $user, true,
94  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
95  )
96  );
97 
98  if ( $errors ) {
99  throw new PermissionsError( 'import', $errors );
100  }
101 
102  $this->checkReadOnly();
103 
104  $request = $this->getRequest();
105  if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) {
106  $this->doImport();
107  }
108  $this->showForm();
109  }
110 
114  private function doImport() {
115  $isUpload = false;
116  $request = $this->getRequest();
117  $this->sourceName = $request->getVal( "source" );
118 
119  $this->logcomment = $request->getText( 'log-comment' );
120  $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0
121  ? 0
122  : $request->getIntOrNull( 'pagelink-depth' );
123 
124  $this->mapping = $request->getVal( 'mapping' );
125  if ( $this->mapping === 'namespace' ) {
126  $this->namespace = $request->getIntOrNull( 'namespace' );
127  } elseif ( $this->mapping === 'subpage' ) {
128  $this->rootpage = $request->getText( 'rootpage' );
129  } else {
130  $this->mapping = 'default';
131  }
132 
133  $user = $this->getUser();
134  if ( !$user->matchEditToken( $request->getVal( 'editToken' ) ) ) {
135  $source = Status::newFatal( 'import-token-mismatch' );
136  } elseif ( $this->sourceName === 'upload' ) {
137  $isUpload = true;
138  if ( $user->isAllowed( 'importupload' ) ) {
140  } else {
141  throw new PermissionsError( 'importupload' );
142  }
143  } elseif ( $this->sourceName === 'interwiki' ) {
144  if ( !$user->isAllowed( 'import' ) ) {
145  throw new PermissionsError( 'import' );
146  }
147  $this->interwiki = $this->fullInterwikiPrefix = $request->getVal( 'interwiki' );
148  // does this interwiki have subprojects?
149  $hasSubprojects = array_key_exists( $this->interwiki, $this->importSources );
150  if ( !$hasSubprojects && !in_array( $this->interwiki, $this->importSources ) ) {
151  $source = Status::newFatal( "import-invalid-interwiki" );
152  } else {
153  if ( $hasSubprojects ) {
154  $this->subproject = $request->getVal( 'subproject' );
155  $this->fullInterwikiPrefix .= ':' . $request->getVal( 'subproject' );
156  }
157  if ( $hasSubprojects &&
158  !in_array( $this->subproject, $this->importSources[$this->interwiki] )
159  ) {
160  $source = Status::newFatal( "import-invalid-interwiki" );
161  } else {
162  $this->history = $request->getCheck( 'interwikiHistory' );
163  $this->frompage = $request->getText( "frompage" );
164  $this->includeTemplates = $request->getCheck( 'interwikiTemplates' );
166  $this->fullInterwikiPrefix,
167  $this->frompage,
168  $this->history,
169  $this->includeTemplates,
170  $this->pageLinkDepth );
171  }
172  }
173  } else {
174  $source = Status::newFatal( "importunknownsource" );
175  }
176 
177  $out = $this->getOutput();
178  if ( !$source->isGood() ) {
179  $out->wrapWikiMsg(
180  "<p class=\"error\">\n$1\n</p>",
181  [ 'importfailed', $source->getWikiText() ]
182  );
183  } else {
184  $importer = new WikiImporter( $source->value, $this->getConfig() );
185  if ( !is_null( $this->namespace ) ) {
186  $importer->setTargetNamespace( $this->namespace );
187  } elseif ( !is_null( $this->rootpage ) ) {
188  $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
189  if ( !$statusRootPage->isGood() ) {
190  $out->wrapWikiMsg(
191  "<p class=\"error\">\n$1\n</p>",
192  [
193  'import-options-wrong',
194  $statusRootPage->getWikiText(),
195  count( $statusRootPage->getErrorsArray() )
196  ]
197  );
198 
199  return;
200  }
201  }
202 
203  $out->addWikiMsg( "importstart" );
204 
205  $reporter = new ImportReporter(
206  $importer,
207  $isUpload,
208  $this->fullInterwikiPrefix,
209  $this->logcomment
210  );
211  $reporter->setContext( $this->getContext() );
212  $exception = false;
213 
214  $reporter->open();
215  try {
216  $importer->doImport();
217  } catch ( Exception $e ) {
218  $exception = $e;
219  }
220  $result = $reporter->close();
221 
222  if ( $exception ) {
223  # No source or XML parse error
224  $out->wrapWikiMsg(
225  "<p class=\"error\">\n$1\n</p>",
226  [ 'importfailed', $exception->getMessage() ]
227  );
228  } elseif ( !$result->isGood() ) {
229  # Zero revisions
230  $out->wrapWikiMsg(
231  "<p class=\"error\">\n$1\n</p>",
232  [ 'importfailed', $result->getWikiText() ]
233  );
234  } else {
235  # Success!
236  $out->addWikiMsg( 'importsuccess' );
237  }
238  $out->addHTML( '<hr />' );
239  }
240  }
241 
242  private function getMappingFormPart( $sourceName ) {
243  $isSameSourceAsBefore = ( $this->sourceName === $sourceName );
244  $defaultNamespace = $this->getConfig()->get( 'ImportTargetNamespace' );
245  return "<tr>
246  <td>
247  </td>
248  <td class='mw-input'>" .
250  $this->msg( 'import-mapping-default' )->text(),
251  'mapping',
252  'default',
253  // mw-import-mapping-interwiki-default, mw-import-mapping-upload-default
254  "mw-import-mapping-$sourceName-default",
255  ( $isSameSourceAsBefore ?
256  ( $this->mapping === 'default' ) :
257  is_null( $defaultNamespace ) )
258  ) .
259  "</td>
260  </tr>
261  <tr>
262  <td>
263  </td>
264  <td class='mw-input'>" .
266  $this->msg( 'import-mapping-namespace' )->text(),
267  'mapping',
268  'namespace',
269  // mw-import-mapping-interwiki-namespace, mw-import-mapping-upload-namespace
270  "mw-import-mapping-$sourceName-namespace",
271  ( $isSameSourceAsBefore ?
272  ( $this->mapping === 'namespace' ) :
273  !is_null( $defaultNamespace ) )
274  ) . ' ' .
276  [
277  'selected' => ( $isSameSourceAsBefore ?
278  $this->namespace :
279  ( $defaultNamespace || '' ) ),
280  ], [
281  'name' => "namespace",
282  // mw-import-namespace-interwiki, mw-import-namespace-upload
283  'id' => "mw-import-namespace-$sourceName",
284  'class' => 'namespaceselector',
285  ]
286  ) .
287  "</td>
288  </tr>
289  <tr>
290  <td>
291  </td>
292  <td class='mw-input'>" .
294  $this->msg( 'import-mapping-subpage' )->text(),
295  'mapping',
296  'subpage',
297  // mw-import-mapping-interwiki-subpage, mw-import-mapping-upload-subpage
298  "mw-import-mapping-$sourceName-subpage",
299  ( $isSameSourceAsBefore ? ( $this->mapping === 'subpage' ) : '' )
300  ) . ' ' .
301  Xml::input( 'rootpage', 50,
302  ( $isSameSourceAsBefore ? $this->rootpage : '' ),
303  [
304  // Should be "mw-import-rootpage-...", but we keep this inaccurate
305  // ID for legacy reasons
306  // mw-interwiki-rootpage-interwiki, mw-interwiki-rootpage-upload
307  'id' => "mw-interwiki-rootpage-$sourceName",
308  'type' => 'text'
309  ]
310  ) . ' ' .
311  "</td>
312  </tr>";
313  }
314 
315  private function showForm() {
316  $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
317  $user = $this->getUser();
318  $out = $this->getOutput();
319  $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import', true );
320 
321  if ( $user->isAllowed( 'importupload' ) ) {
322  $mappingSelection = $this->getMappingFormPart( 'upload' );
323  $out->addHTML(
324  Xml::fieldset( $this->msg( 'import-upload' )->text() ) .
326  'form',
327  [
328  'enctype' => 'multipart/form-data',
329  'method' => 'post',
330  'action' => $action,
331  'id' => 'mw-import-upload-form'
332  ]
333  ) .
334  $this->msg( 'importtext' )->parseAsBlock() .
335  Html::hidden( 'action', 'submit' ) .
336  Html::hidden( 'source', 'upload' ) .
337  Xml::openElement( 'table', [ 'id' => 'mw-import-table-upload' ] ) .
338  "<tr>
339  <td class='mw-label'>" .
340  Xml::label( $this->msg( 'import-upload-filename' )->text(), 'xmlimport' ) .
341  "</td>
342  <td class='mw-input'>" .
343  Html::input( 'xmlimport', '', 'file', [ 'id' => 'xmlimport' ] ) . ' ' .
344  "</td>
345  </tr>
346  <tr>
347  <td class='mw-label'>" .
348  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-import-comment' ) .
349  "</td>
350  <td class='mw-input'>" .
351  Xml::input( 'log-comment', 50,
352  ( $this->sourceName === 'upload' ? $this->logcomment : '' ),
353  [ 'id' => 'mw-import-comment', 'type' => 'text' ] ) . ' ' .
354  "</td>
355  </tr>
356  $mappingSelection
357  <tr>
358  <td></td>
359  <td class='mw-submit'>" .
360  Xml::submitButton( $this->msg( 'uploadbtn' )->text() ) .
361  "</td>
362  </tr>" .
363  Xml::closeElement( 'table' ) .
364  Html::hidden( 'editToken', $user->getEditToken() ) .
365  Xml::closeElement( 'form' ) .
366  Xml::closeElement( 'fieldset' )
367  );
368  } else {
369  if ( empty( $this->importSources ) ) {
370  $out->addWikiMsg( 'importnosources' );
371  }
372  }
373 
374  if ( $user->isAllowed( 'import' ) && !empty( $this->importSources ) ) {
375  # Show input field for import depth only if $wgExportMaxLinkDepth > 0
376  $importDepth = '';
377  if ( $this->getConfig()->get( 'ExportMaxLinkDepth' ) > 0 ) {
378  $importDepth = "<tr>
379  <td class='mw-label'>" .
380  $this->msg( 'export-pagelinks' )->parse() .
381  "</td>
382  <td class='mw-input'>" .
383  Xml::input( 'pagelink-depth', 3, 0 ) .
384  "</td>
385  </tr>";
386  }
387  $mappingSelection = $this->getMappingFormPart( 'interwiki' );
388 
389  $out->addHTML(
390  Xml::fieldset( $this->msg( 'importinterwiki' )->text() ) .
392  'form',
393  [
394  'method' => 'post',
395  'action' => $action,
396  'id' => 'mw-import-interwiki-form'
397  ]
398  ) .
399  $this->msg( 'import-interwiki-text' )->parseAsBlock() .
400  Html::hidden( 'action', 'submit' ) .
401  Html::hidden( 'source', 'interwiki' ) .
402  Html::hidden( 'editToken', $user->getEditToken() ) .
403  Xml::openElement( 'table', [ 'id' => 'mw-import-table-interwiki' ] ) .
404  "<tr>
405  <td class='mw-label'>" .
406  Xml::label( $this->msg( 'import-interwiki-sourcewiki' )->text(), 'interwiki' ) .
407  "</td>
408  <td class='mw-input'>" .
410  'select',
411  [ 'name' => 'interwiki', 'id' => 'interwiki' ]
412  )
413  );
414 
415  $needSubprojectField = false;
416  foreach ( $this->importSources as $key => $value ) {
417  if ( is_int( $key ) ) {
418  $key = $value;
419  } elseif ( $value !== $key ) {
420  $needSubprojectField = true;
421  }
422 
423  $attribs = [
424  'value' => $key,
425  ];
426  if ( is_array( $value ) ) {
427  $attribs['data-subprojects'] = implode( ' ', $value );
428  }
429  if ( $this->interwiki === $key ) {
430  $attribs['selected'] = 'selected';
431  }
432  $out->addHTML( Html::element( 'option', $attribs, $key ) );
433  }
434 
435  $out->addHTML(
436  Xml::closeElement( 'select' )
437  );
438 
439  if ( $needSubprojectField ) {
440  $out->addHTML(
442  'select',
443  [ 'name' => 'subproject', 'id' => 'subproject' ]
444  )
445  );
446 
447  $subprojectsToAdd = [];
448  foreach ( $this->importSources as $key => $value ) {
449  if ( is_array( $value ) ) {
450  $subprojectsToAdd = array_merge( $subprojectsToAdd, $value );
451  }
452  }
453  $subprojectsToAdd = array_unique( $subprojectsToAdd );
454  sort( $subprojectsToAdd );
455  foreach ( $subprojectsToAdd as $subproject ) {
456  $out->addHTML( Xml::option( $subproject, $subproject, $this->subproject === $subproject ) );
457  }
458 
459  $out->addHTML(
460  Xml::closeElement( 'select' )
461  );
462  }
463 
464  $out->addHTML(
465  "</td>
466  </tr>
467  <tr>
468  <td class='mw-label'>" .
469  Xml::label( $this->msg( 'import-interwiki-sourcepage' )->text(), 'frompage' ) .
470  "</td>
471  <td class='mw-input'>" .
472  Xml::input( 'frompage', 50, $this->frompage, [ 'id' => 'frompage' ] ) .
473  "</td>
474  </tr>
475  <tr>
476  <td>
477  </td>
478  <td class='mw-input'>" .
480  $this->msg( 'import-interwiki-history' )->text(),
481  'interwikiHistory',
482  'interwikiHistory',
483  $this->history
484  ) .
485  "</td>
486  </tr>
487  <tr>
488  <td>
489  </td>
490  <td class='mw-input'>" .
492  $this->msg( 'import-interwiki-templates' )->text(),
493  'interwikiTemplates',
494  'interwikiTemplates',
495  $this->includeTemplates
496  ) .
497  "</td>
498  </tr>
499  $importDepth
500  <tr>
501  <td class='mw-label'>" .
502  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-interwiki-comment' ) .
503  "</td>
504  <td class='mw-input'>" .
505  Xml::input( 'log-comment', 50,
506  ( $this->sourceName === 'interwiki' ? $this->logcomment : '' ),
507  [ 'id' => 'mw-interwiki-comment', 'type' => 'text' ] ) . ' ' .
508  "</td>
509  </tr>
510  $mappingSelection
511  <tr>
512  <td>
513  </td>
514  <td class='mw-submit'>" .
516  $this->msg( 'import-interwiki-submit' )->text(),
518  ) .
519  "</td>
520  </tr>" .
521  Xml::closeElement( 'table' ) .
522  Xml::closeElement( 'form' ) .
523  Xml::closeElement( 'fieldset' )
524  );
525  }
526  }
527 
528  protected function getGroupName() {
529  return 'pagetools';
530  }
531 }
532 
538  private $reason = false;
539  private $logTags = [];
540  private $mOriginalLogCallback = null;
542  private $mLogItemCount = 0;
543 
550  function __construct( $importer, $upload, $interwiki, $reason = false ) {
551  $this->mOriginalPageOutCallback =
552  $importer->setPageOutCallback( [ $this, 'reportPage' ] );
553  $this->mOriginalLogCallback =
554  $importer->setLogItemCallback( [ $this, 'reportLogItem' ] );
555  $importer->setNoticeCallback( [ $this, 'reportNotice' ] );
556  $this->mPageCount = 0;
557  $this->mIsUpload = $upload;
558  $this->mInterwiki = $interwiki;
559  $this->reason = $reason;
560  }
561 
568  public function setChangeTags( array $tags ) {
569  $this->logTags = $tags;
570  }
571 
572  function open() {
573  $this->getOutput()->addHTML( "<ul>\n" );
574  }
575 
576  function reportNotice( $msg, array $params ) {
577  $this->getOutput()->addHTML(
578  Html::element( 'li', [], $this->msg( $msg, $params )->text() )
579  );
580  }
581 
582  function reportLogItem( /* ... */ ) {
583  $this->mLogItemCount++;
584  if ( is_callable( $this->mOriginalLogCallback ) ) {
585  call_user_func_array( $this->mOriginalLogCallback, func_get_args() );
586  }
587  }
588 
597  public function reportPage( $title, $foreignTitle, $revisionCount,
598  $successCount, $pageInfo ) {
599  $args = func_get_args();
600  call_user_func_array( $this->mOriginalPageOutCallback, $args );
601 
602  if ( $title === null ) {
603  # Invalid or non-importable title; a notice is already displayed
604  return;
605  }
606 
607  $this->mPageCount++;
608  $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
609  if ( $successCount > 0 ) {
610  // <bdi> prevents jumbling of the versions count
611  // in RTL wikis in case the page title is LTR
612  $this->getOutput()->addHTML(
613  "<li>" . $linkRenderer->makeLink( $title ) . " " .
614  "<bdi>" .
615  $this->msg( 'import-revision-count' )->numParams( $successCount )->escaped() .
616  "</bdi>" .
617  "</li>\n"
618  );
619 
620  $logParams = [ '4:number:count' => $successCount ];
621  if ( $this->mIsUpload ) {
622  $detail = $this->msg( 'import-logentry-upload-detail' )->numParams(
623  $successCount )->inContentLanguage()->text();
624  $action = 'upload';
625  } else {
626  $pageTitle = $foreignTitle->getFullText();
627  $fullInterwikiPrefix = $this->mInterwiki;
628  Hooks::run( 'ImportLogInterwikiLink', [ &$fullInterwikiPrefix, &$pageTitle ] );
629 
630  $interwikiTitleStr = $fullInterwikiPrefix . ':' . $pageTitle;
631  $interwiki = '[[:' . $interwikiTitleStr . ']]';
632  $detail = $this->msg( 'import-logentry-interwiki-detail' )->numParams(
633  $successCount )->params( $interwiki )->inContentLanguage()->text();
634  $action = 'interwiki';
635  $logParams['5:title-link:interwiki'] = $interwikiTitleStr;
636  }
637  if ( $this->reason ) {
638  $detail .= $this->msg( 'colon-separator' )->inContentLanguage()->text()
639  . $this->reason;
640  }
641 
642  $comment = $detail; // quick
643  $dbw = wfGetDB( DB_MASTER );
644  $latest = $title->getLatestRevID();
645  $nullRevision = Revision::newNullRevision(
646  $dbw,
647  $title->getArticleID(),
648  $comment,
649  true,
650  $this->getUser()
651  );
652 
653  $nullRevId = null;
654  if ( !is_null( $nullRevision ) ) {
655  $nullRevId = $nullRevision->insertOn( $dbw );
657  # Update page record
658  $page->updateRevisionOn( $dbw, $nullRevision );
659  Hooks::run(
660  'NewRevisionFromEditComplete',
661  [ $page, $nullRevision, $latest, $this->getUser() ]
662  );
663  }
664 
665  // Create the import log entry
666  $logEntry = new ManualLogEntry( 'import', $action );
667  $logEntry->setTarget( $title );
668  $logEntry->setComment( $this->reason );
669  $logEntry->setPerformer( $this->getUser() );
670  $logEntry->setParameters( $logParams );
671  $logid = $logEntry->insert();
672  if ( count( $this->logTags ) ) {
673  $logEntry->setTags( $this->logTags );
674  }
675  // Make sure the null revision will be tagged as well
676  $logEntry->setAssociatedRevId( $nullRevId );
677 
678  $logEntry->publish( $logid );
679 
680  } else {
681  $this->getOutput()->addHTML( "<li>" . $linkRenderer->makeKnownLink( $title ) . " " .
682  $this->msg( 'import-nonewrevisions' )->escaped() . "</li>\n" );
683  }
684  }
685 
686  function close() {
687  $out = $this->getOutput();
688  if ( $this->mLogItemCount > 0 ) {
689  $msg = $this->msg( 'imported-log-entries' )->numParams( $this->mLogItemCount )->parse();
690  $out->addHTML( Xml::tags( 'li', null, $msg ) );
691  } elseif ( $this->mPageCount == 0 && $this->mLogItemCount == 0 ) {
692  $out->addHTML( "</ul>\n" );
693 
694  return Status::newFatal( 'importnopages' );
695  }
696  $out->addHTML( "</ul>\n" );
697 
698  return Status::newGood( $this->mPageCount );
699  }
700 }
SpecialImport\showForm
showForm()
Definition: SpecialImport.php:315
SpecialImport
MediaWiki page data importer.
Definition: SpecialImport.php:34
SpecialImport\$pageLinkDepth
$pageLinkDepth
Definition: SpecialImport.php:46
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:628
SpecialImport\$includeTemplates
$includeTemplates
Definition: SpecialImport.php:45
WikiImporter
XML file reader for the page data importer.
Definition: WikiImporter.php:34
$request
error also a ContextSource you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2612
wfMergeErrorArrays
wfMergeErrorArrays()
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
Definition: GlobalFunctions.php:242
ContextSource\msg
msg()
Get a Message object with context set Parameters are the same as wfMessage()
Definition: ContextSource.php:187
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
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:225
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
ImportReporter\$mOriginalPageOutCallback
$mOriginalPageOutCallback
Definition: SpecialImport.php:541
SpecialImport\$fullInterwikiPrefix
$fullInterwikiPrefix
Definition: SpecialImport.php:38
$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:1954
use
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
Definition: MIT-LICENSE.txt:10
$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:246
StatusValue\newFatal
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:63
$params
$params
Definition: styleTest.css.php:40
Xml\option
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:484
$linkRenderer
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 after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
Definition: hooks.txt:1956
SpecialPage\useTransactionalTimeLimit
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
Definition: SpecialPage.php:846
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: SpecialImport.php:537
ContextSource\getUser
getUser()
Get the User object.
Definition: ContextSource.php:133
Xml\openElement
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
SpecialImport\$namespace
$namespace
Definition: SpecialImport.php:40
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:663
Xml\fieldset
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:577
SpecialImport\$subproject
$subproject
Definition: SpecialImport.php:37
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:66
SpecialImport\doImport
doImport()
Do the actual import.
Definition: SpecialImport.php:114
SpecialImport\$importSources
$importSources
Definition: SpecialImport.php:47
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:714
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:934
WikiPage\factory
static factory(Title $title)
Create a WikiPage object of the appropriate class for the given title.
Definition: WikiPage.php:120
ImportReporter\$logTags
$logTags
Definition: SpecialImport.php:539
ImportReporter\reportLogItem
reportLogItem()
Definition: SpecialImport.php:582
ImportReporter\reportPage
reportPage( $title, $foreignTitle, $revisionCount, $successCount, $pageInfo)
Definition: SpecialImport.php:597
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:3060
$page
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
Definition: hooks.txt:2536
ContextSource\getOutput
getOutput()
Get the OutputPage object.
Definition: ContextSource.php:123
ContextSource
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
Definition: ContextSource.php:30
$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:1956
SpecialImport\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialImport.php:528
ImportReporter\__construct
__construct( $importer, $upload, $interwiki, $reason=false)
Definition: SpecialImport.php:550
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:56
DB_MASTER
const DB_MASTER
Definition: defines.php:26
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:36
Html\hidden
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:746
ImportReporter\$mOriginalLogCallback
$mOriginalLogCallback
Definition: SpecialImport.php:540
SpecialImport\$frompage
$frompage
Definition: SpecialImport.php:42
$e
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2122
ImportReporter\reportNotice
reportNotice( $msg, array $params)
Definition: SpecialImport.php:576
$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:2098
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:746
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:76
Html\namespaceSelector
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:834
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:43
ImportReporter\close
close()
Definition: SpecialImport.php:686
ImportReporter\$reason
$reason
Definition: SpecialImport.php:538
ImportReporter\$mLogItemCount
$mLogItemCount
Definition: SpecialImport.php:542
$args
if( $line===false) $args
Definition: cdb.php:63
reason
c Accompany it with the information you received as to the offer to distribute corresponding source complete source code means all the source code for all modules it plus any associated interface definition plus the scripts used to control compilation and installation of the executable as a special the source code distributed need not include anything that is normally and so on of the operating system on which the executable unless that component itself accompanies the executable If distribution of executable or object code is made by offering access to copy from a designated then offering equivalent access to copy the source code from the same place counts as distribution of the source even though third parties are not compelled to copy the source along with the object code You may not or distribute the Program except as expressly provided under this License Any attempt otherwise to sublicense or distribute the Program is and will automatically terminate your rights under this License parties who have received or from you under this License will not have their licenses terminated so long as such parties remain in full compliance You are not required to accept this since you have not signed it nothing else grants you permission to modify or distribute the Program or its derivative works These actions are prohibited by law if you do not accept this License by modifying or distributing the you indicate your acceptance of this License to do and all its terms and conditions for distributing or modifying the Program or works based on it Each time you redistribute the the recipient automatically receives a license from the original licensor to distribute or modify the Program subject to these terms and conditions You may not impose any further restrictions on the recipients exercise of the rights granted herein You are not responsible for enforcing compliance by third parties to this License as a consequence of a court judgment or allegation of patent infringement or for any other reason(not limited to patent issues)
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:35
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:1741
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
ImportReporter\setChangeTags
setChangeTags(array $tags)
Sets change tags to apply to the import log entry and null revision.
Definition: SpecialImport.php:568
SpecialImport\__construct
__construct()
Constructor.
Definition: SpecialImport.php:52
$source
$source
Definition: mwdoc-filter.php:45
ManualLogEntry
Class for creating log entries manually, to inject them into the database.
Definition: LogEntry.php:396
SpecialImport\$mapping
$mapping
Definition: SpecialImport.php:39
Revision\newNullRevision
static newNullRevision( $dbw, $pageId, $summary, $minor, $user=null)
Create a new null-revision for insertion into a page's history.
Definition: Revision.php:1693
ImportReporter\open
open()
Definition: SpecialImport.php:572
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
MediaWikiServices
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 MediaWikiServices
Definition: injection.txt:23
SpecialImport\$rootpage
$rootpage
Definition: SpecialImport.php:41
WikiImporter\setTargetNamespace
setTargetNamespace( $namespace)
Set a target namespace to override the defaults.
Definition: WikiImporter.php:243
SpecialImport\$history
$history
Definition: SpecialImport.php:44
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:131
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
array
the array() calling protocol came about after MediaWiki 1.4rc1.
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:242
$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:783