MediaWiki  master
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;
47  private $usernamePrefix;
48 
49  public function __construct() {
50  parent::__construct( 'Import', 'import' );
51  }
52 
53  public function doesWrites() {
54  return true;
55  }
56 
63  function execute( $par ) {
65 
66  $this->setHeaders();
67  $this->outputHeader();
68 
69  $this->namespace = $this->getConfig()->get( 'ImportTargetNamespace' );
70 
71  $this->getOutput()->addModules( 'mediawiki.special.import' );
72 
73  $this->importSources = $this->getConfig()->get( 'ImportSources' );
74  Hooks::run( 'ImportSources', [ &$this->importSources ] );
75 
76  $user = $this->getUser();
77  if ( !$user->isAllowedAny( 'import', 'importupload' ) ) {
78  throw new PermissionsError( 'import' );
79  }
80 
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'
84  $errors = wfMergeErrorArrays(
85  $this->getPageTitle()->getUserPermissionsErrors(
86  'import', $user, true,
87  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
88  ),
89  $this->getPageTitle()->getUserPermissionsErrors(
90  'importupload', $user, true,
91  [ 'ns-specialprotected', 'badaccess-group0', 'badaccess-groups' ]
92  )
93  );
94 
95  if ( $errors ) {
96  throw new PermissionsError( 'import', $errors );
97  }
98 
99  $this->checkReadOnly();
100 
101  $request = $this->getRequest();
102  if ( $request->wasPosted() && $request->getVal( 'action' ) == 'submit' ) {
103  $this->doImport();
104  }
105  $this->showForm();
106  }
107 
111  private function doImport() {
112  $isUpload = false;
113  $request = $this->getRequest();
114  $this->sourceName = $request->getVal( "source" );
115  $this->assignKnownUsers = $request->getCheck( 'assignKnownUsers' );
116 
117  $this->logcomment = $request->getText( 'log-comment' );
118  $this->pageLinkDepth = $this->getConfig()->get( 'ExportMaxLinkDepth' ) == 0
119  ? 0
120  : $request->getIntOrNull( 'pagelink-depth' );
121 
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' );
127  } else {
128  $this->mapping = 'default';
129  }
130 
131  $user = $this->getUser();
132  if ( !$user->matchEditToken( $request->getVal( 'editToken' ) ) ) {
133  $source = Status::newFatal( 'import-token-mismatch' );
134  } elseif ( $this->sourceName === 'upload' ) {
135  $isUpload = true;
136  $this->usernamePrefix = $this->fullInterwikiPrefix = $request->getVal( 'usernamePrefix' );
137  if ( $user->isAllowed( 'importupload' ) ) {
139  } else {
140  throw new PermissionsError( 'importupload' );
141  }
142  } elseif ( $this->sourceName === 'interwiki' ) {
143  if ( !$user->isAllowed( 'import' ) ) {
144  throw new PermissionsError( 'import' );
145  }
146  $this->interwiki = $this->fullInterwikiPrefix = $request->getVal( 'interwiki' );
147  // does this interwiki have subprojects?
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" );
151  } else {
152  if ( $hasSubprojects ) {
153  $this->subproject = $request->getVal( 'subproject' );
154  $this->fullInterwikiPrefix .= ':' . $request->getVal( 'subproject' );
155  }
156  if ( $hasSubprojects &&
157  !in_array( $this->subproject, $this->importSources[$this->interwiki] )
158  ) {
159  $source = Status::newFatal( "import-invalid-interwiki" );
160  } else {
161  $this->history = $request->getCheck( 'interwikiHistory' );
162  $this->frompage = $request->getText( "frompage" );
163  $this->includeTemplates = $request->getCheck( 'interwikiTemplates' );
165  $this->fullInterwikiPrefix,
166  $this->frompage,
167  $this->history,
168  $this->includeTemplates,
169  $this->pageLinkDepth );
170  }
171  }
172  } else {
173  $source = Status::newFatal( "importunknownsource" );
174  }
175 
176  if ( (string)$this->fullInterwikiPrefix === '' ) {
177  $source->fatal( 'importnoprefix' );
178  }
179 
180  $out = $this->getOutput();
181  if ( !$source->isGood() ) {
182  $out->wrapWikiTextAsInterface( 'error',
183  $this->msg( 'importfailed', $source->getWikiText() )->plain()
184  );
185  } else {
186  $importer = new WikiImporter( $source->value, $this->getConfig() );
187  if ( !is_null( $this->namespace ) ) {
188  $importer->setTargetNamespace( $this->namespace );
189  } elseif ( !is_null( $this->rootpage ) ) {
190  $statusRootPage = $importer->setTargetRootPage( $this->rootpage );
191  if ( !$statusRootPage->isGood() ) {
192  $out->wrapWikiMsg(
193  "<div class=\"error\">\n$1\n</div>",
194  [
195  'import-options-wrong',
196  $statusRootPage->getWikiText(),
197  count( $statusRootPage->getErrorsArray() )
198  ]
199  );
200 
201  return;
202  }
203  }
204  $importer->setUsernamePrefix( $this->fullInterwikiPrefix, $this->assignKnownUsers );
205 
206  $out->addWikiMsg( "importstart" );
207 
208  $reporter = new ImportReporter(
209  $importer,
210  $isUpload,
211  $this->fullInterwikiPrefix,
212  $this->logcomment
213  );
214  $reporter->setContext( $this->getContext() );
215  $exception = false;
216 
217  $reporter->open();
218  try {
219  $importer->doImport();
220  } catch ( Exception $e ) {
221  $exception = $e;
222  }
223  $result = $reporter->close();
224 
225  if ( $exception ) {
226  # No source or XML parse error
227  $out->wrapWikiMsg(
228  "<div class=\"error\">\n$1\n</div>",
229  [ 'importfailed', $exception->getMessage() ]
230  );
231  } elseif ( !$result->isGood() ) {
232  # Zero revisions
233  $out->wrapWikiMsg(
234  "<div class=\"error\">\n$1\n</div>",
235  [ 'importfailed', $result->getWikiText() ]
236  );
237  } else {
238  # Success!
239  $out->addWikiMsg( 'importsuccess' );
240  }
241  $out->addHTML( '<hr />' );
242  }
243  }
244 
245  private function getMappingFormPart( $sourceName ) {
246  $isSameSourceAsBefore = ( $this->sourceName === $sourceName );
247  $defaultNamespace = $this->getConfig()->get( 'ImportTargetNamespace' );
248  return "<tr>
249  <td>
250  </td>
251  <td class='mw-input'>" .
253  $this->msg( 'import-mapping-default' )->text(),
254  'mapping',
255  'default',
256  // mw-import-mapping-interwiki-default, mw-import-mapping-upload-default
257  "mw-import-mapping-$sourceName-default",
258  ( $isSameSourceAsBefore ?
259  ( $this->mapping === 'default' ) :
260  is_null( $defaultNamespace ) )
261  ) .
262  "</td>
263  </tr>
264  <tr>
265  <td>
266  </td>
267  <td class='mw-input'>" .
269  $this->msg( 'import-mapping-namespace' )->text(),
270  'mapping',
271  'namespace',
272  // mw-import-mapping-interwiki-namespace, mw-import-mapping-upload-namespace
273  "mw-import-mapping-$sourceName-namespace",
274  ( $isSameSourceAsBefore ?
275  ( $this->mapping === 'namespace' ) :
276  !is_null( $defaultNamespace ) )
277  ) . ' ' .
279  [
280  'selected' => ( $isSameSourceAsBefore ?
281  $this->namespace :
282  ( $defaultNamespace || '' ) ),
283  'in-user-lang' => true,
284  ], [
285  'name' => "namespace",
286  // mw-import-namespace-interwiki, mw-import-namespace-upload
287  'id' => "mw-import-namespace-$sourceName",
288  'class' => 'namespaceselector',
289  ]
290  ) .
291  "</td>
292  </tr>
293  <tr>
294  <td>
295  </td>
296  <td class='mw-input'>" .
298  $this->msg( 'import-mapping-subpage' )->text(),
299  'mapping',
300  'subpage',
301  // mw-import-mapping-interwiki-subpage, mw-import-mapping-upload-subpage
302  "mw-import-mapping-$sourceName-subpage",
303  ( $isSameSourceAsBefore ? ( $this->mapping === 'subpage' ) : '' )
304  ) . ' ' .
305  Xml::input( 'rootpage', 50,
306  ( $isSameSourceAsBefore ? $this->rootpage : '' ),
307  [
308  // Should be "mw-import-rootpage-...", but we keep this inaccurate
309  // ID for legacy reasons
310  // mw-interwiki-rootpage-interwiki, mw-interwiki-rootpage-upload
311  'id' => "mw-interwiki-rootpage-$sourceName",
312  'type' => 'text'
313  ]
314  ) . ' ' .
315  "</td>
316  </tr>";
317  }
318 
319  private function showForm() {
320  $action = $this->getPageTitle()->getLocalURL( [ 'action' => 'submit' ] );
321  $user = $this->getUser();
322  $out = $this->getOutput();
323  $this->addHelpLink( '//meta.wikimedia.org/wiki/Special:MyLanguage/Help:Import', true );
324 
325  if ( $user->isAllowed( 'importupload' ) ) {
326  $mappingSelection = $this->getMappingFormPart( 'upload' );
327  $out->addHTML(
328  Xml::fieldset( $this->msg( 'import-upload' )->text() ) .
330  'form',
331  [
332  'enctype' => 'multipart/form-data',
333  'method' => 'post',
334  'action' => $action,
335  'id' => 'mw-import-upload-form'
336  ]
337  ) .
338  $this->msg( 'importtext' )->parseAsBlock() .
339  Html::hidden( 'action', 'submit' ) .
340  Html::hidden( 'source', 'upload' ) .
341  Xml::openElement( 'table', [ 'id' => 'mw-import-table-upload' ] ) .
342  "<tr>
343  <td class='mw-label'>" .
344  Xml::label( $this->msg( 'import-upload-filename' )->text(), 'xmlimport' ) .
345  "</td>
346  <td class='mw-input'>" .
347  Html::input( 'xmlimport', '', 'file', [ 'id' => 'xmlimport' ] ) . ' ' .
348  "</td>
349  </tr>
350  <tr>
351  <td class='mw-label'>" .
352  Xml::label( $this->msg( 'import-upload-username-prefix' )->text(),
353  'mw-import-usernamePrefix' ) .
354  "</td>
355  <td class='mw-input'>" .
356  Xml::input( 'usernamePrefix', 50,
357  $this->usernamePrefix,
358  [ 'id' => 'usernamePrefix', 'type' => 'text' ] ) . ' ' .
359  "</td>
360  </tr>
361  <tr>
362  <td></td>
363  <td class='mw-input'>" .
365  $this->msg( 'import-assign-known-users' )->text(),
366  'assignKnownUsers',
367  'assignKnownUsers',
368  $this->assignKnownUsers
369  ) .
370  "</td>
371  </tr>
372  <tr>
373  <td class='mw-label'>" .
374  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-import-comment' ) .
375  "</td>
376  <td class='mw-input'>" .
377  Xml::input( 'log-comment', 50,
378  ( $this->sourceName === 'upload' ? $this->logcomment : '' ),
379  [ 'id' => 'mw-import-comment', 'type' => 'text' ] ) . ' ' .
380  "</td>
381  </tr>
382  $mappingSelection
383  <tr>
384  <td></td>
385  <td class='mw-submit'>" .
386  Xml::submitButton( $this->msg( 'uploadbtn' )->text() ) .
387  "</td>
388  </tr>" .
389  Xml::closeElement( 'table' ) .
390  Html::hidden( 'editToken', $user->getEditToken() ) .
391  Xml::closeElement( 'form' ) .
392  Xml::closeElement( 'fieldset' )
393  );
394  } else {
395  if ( empty( $this->importSources ) ) {
396  $out->addWikiMsg( 'importnosources' );
397  }
398  }
399 
400  if ( $user->isAllowed( 'import' ) && !empty( $this->importSources ) ) {
401  # Show input field for import depth only if $wgExportMaxLinkDepth > 0
402  $importDepth = '';
403  if ( $this->getConfig()->get( 'ExportMaxLinkDepth' ) > 0 ) {
404  $importDepth = "<tr>
405  <td class='mw-label'>" .
406  $this->msg( 'export-pagelinks' )->parse() .
407  "</td>
408  <td class='mw-input'>" .
409  Xml::input( 'pagelink-depth', 3, 0 ) .
410  "</td>
411  </tr>";
412  }
413  $mappingSelection = $this->getMappingFormPart( 'interwiki' );
414 
415  $out->addHTML(
416  Xml::fieldset( $this->msg( 'importinterwiki' )->text() ) .
418  'form',
419  [
420  'method' => 'post',
421  'action' => $action,
422  'id' => 'mw-import-interwiki-form'
423  ]
424  ) .
425  $this->msg( 'import-interwiki-text' )->parseAsBlock() .
426  Html::hidden( 'action', 'submit' ) .
427  Html::hidden( 'source', 'interwiki' ) .
428  Html::hidden( 'editToken', $user->getEditToken() ) .
429  Xml::openElement( 'table', [ 'id' => 'mw-import-table-interwiki' ] ) .
430  "<tr>
431  <td class='mw-label'>" .
432  Xml::label( $this->msg( 'import-interwiki-sourcewiki' )->text(), 'interwiki' ) .
433  "</td>
434  <td class='mw-input'>" .
436  'select',
437  [ 'name' => 'interwiki', 'id' => 'interwiki' ]
438  )
439  );
440 
441  $needSubprojectField = false;
442  foreach ( $this->importSources as $key => $value ) {
443  if ( is_int( $key ) ) {
444  $key = $value;
445  } elseif ( $value !== $key ) {
446  $needSubprojectField = true;
447  }
448 
449  $attribs = [
450  'value' => $key,
451  ];
452  if ( is_array( $value ) ) {
453  $attribs['data-subprojects'] = implode( ' ', $value );
454  }
455  if ( $this->interwiki === $key ) {
456  $attribs['selected'] = 'selected';
457  }
458  $out->addHTML( Html::element( 'option', $attribs, $key ) );
459  }
460 
461  $out->addHTML(
462  Xml::closeElement( 'select' )
463  );
464 
465  if ( $needSubprojectField ) {
466  $out->addHTML(
468  'select',
469  [ 'name' => 'subproject', 'id' => 'subproject' ]
470  )
471  );
472 
473  $subprojectsToAdd = [];
474  foreach ( $this->importSources as $key => $value ) {
475  if ( is_array( $value ) ) {
476  $subprojectsToAdd = array_merge( $subprojectsToAdd, $value );
477  }
478  }
479  $subprojectsToAdd = array_unique( $subprojectsToAdd );
480  sort( $subprojectsToAdd );
481  foreach ( $subprojectsToAdd as $subproject ) {
482  $out->addHTML( Xml::option( $subproject, $subproject, $this->subproject === $subproject ) );
483  }
484 
485  $out->addHTML(
486  Xml::closeElement( 'select' )
487  );
488  }
489 
490  $out->addHTML(
491  "</td>
492  </tr>
493  <tr>
494  <td class='mw-label'>" .
495  Xml::label( $this->msg( 'import-interwiki-sourcepage' )->text(), 'frompage' ) .
496  "</td>
497  <td class='mw-input'>" .
498  Xml::input( 'frompage', 50, $this->frompage, [ 'id' => 'frompage' ] ) .
499  "</td>
500  </tr>
501  <tr>
502  <td>
503  </td>
504  <td class='mw-input'>" .
506  $this->msg( 'import-interwiki-history' )->text(),
507  'interwikiHistory',
508  'interwikiHistory',
509  $this->history
510  ) .
511  "</td>
512  </tr>
513  <tr>
514  <td>
515  </td>
516  <td class='mw-input'>" .
518  $this->msg( 'import-interwiki-templates' )->text(),
519  'interwikiTemplates',
520  'interwikiTemplates',
521  $this->includeTemplates
522  ) .
523  "</td>
524  </tr>
525  <tr>
526  <td></td>
527  <td class='mw-input'>" .
529  $this->msg( 'import-assign-known-users' )->text(),
530  'assignKnownUsers',
531  'interwikiAssignKnownUsers',
532  $this->assignKnownUsers
533  ) .
534  "</td>
535  </tr>
536  $importDepth
537  <tr>
538  <td class='mw-label'>" .
539  Xml::label( $this->msg( 'import-comment' )->text(), 'mw-interwiki-comment' ) .
540  "</td>
541  <td class='mw-input'>" .
542  Xml::input( 'log-comment', 50,
543  ( $this->sourceName === 'interwiki' ? $this->logcomment : '' ),
544  [ 'id' => 'mw-interwiki-comment', 'type' => 'text' ] ) . ' ' .
545  "</td>
546  </tr>
547  $mappingSelection
548  <tr>
549  <td>
550  </td>
551  <td class='mw-submit'>" .
553  $this->msg( 'import-interwiki-submit' )->text(),
555  ) .
556  "</td>
557  </tr>" .
558  Xml::closeElement( 'table' ) .
559  Xml::closeElement( 'form' ) .
560  Xml::closeElement( 'fieldset' )
561  );
562  }
563  }
564 
565  protected function getGroupName() {
566  return 'pagetools';
567  }
568 }
execute( $par)
Execute.
doImport()
Do the actual import.
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:785
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
either a plain
Definition: hooks.txt:2057
getContext()
Gets the context this SpecialPage is executed in.
MediaWiki page data importer.
XML file reader for the page data importer.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
Definition: hooks.txt:2173
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:486
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
Definition: Xml.php:276
$source
$value
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getOutput()
Get the OutputPage being used for this instance.
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
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 'ImportHandleUnknownUser':When a user doesn 't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, return false. $name:User name '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. '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 '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 since 1.28! 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:1994
static newFatal( $message)
Factory function for fatal errors.
Definition: StatusValue.php:68
wfMergeErrorArrays(... $args)
Merge arrays in the style of getUserPermissionsErrors, with duplicate removal e.g.
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:110
static fieldset( $legend=false, $content=false, $attribs=[])
Shortcut for creating fieldsets.
Definition: Xml.php:611
static newFromUpload( $fieldname="xmlimport")
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:461
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
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:1996
static input( $name, $value='', $type='text', array $attribs=[])
Convenience function to produce an "<input>" element.
Definition: Html.php:666
getMappingFormPart( $sourceName)
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
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
Definition: Xml.php:360
static radioLabel( $label, $name, $value, $id, $checked=false, $attribs=[])
Convenience function to build an HTML radio button with a label.
Definition: Xml.php:446
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
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:1780
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
static newFromInterwiki( $interwiki, $page, $history=false, $templates=false, $pageLinkDepth=0)
useTransactionalTimeLimit()
Call wfTransactionalTimeLimit() if this request was POSTed.
setTargetNamespace( $namespace)
Set a target namespace to override the defaults.
getUser()
Shortcut to get the User executing this instance.
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:795
getConfig()
Shortcut to get main config object.
Show an error when a user tries to do something they do not have the necessary permissions for...
msg( $key)
Wrapper around wfMessage that sets the current context.
Reporting callback.
static checkLabel( $label, $name, $id, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox with a label.
Definition: Xml.php:421
getRequest()
Get the WebRequest being used for this instance.
static tooltipAndAccesskeyAttribs( $name, array $msgParams=[], $options=null)
Returns the attributes for the tooltip and access key.
Definition: Linker.php:2147
checkReadOnly()
If the wiki is currently in readonly mode, throws a ReadOnlyError.
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:2626
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1487
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
static namespaceSelector(array $params=[], array $selectAttribs=[])
Build a drop-down box for selecting a namespace.
Definition: Html.php:887