MediaWiki  master
ImagePage.php
Go to the documentation of this file.
1 <?php
24 
30 class ImagePage extends Article {
32  private $displayImg;
33 
35  private $repo;
36 
38  private $fileLoaded;
39 
41  protected $mExtraDescription = false;
42 
46  protected $mPage;
47 
52  protected function newPage( Title $title ) {
53  // Overload mPage with a file-specific page
54  return new WikiFilePage( $title );
55  }
56 
61  public function setFile( $file ) {
62  $this->mPage->setFile( $file );
63  $this->displayImg = $file;
64  $this->fileLoaded = true;
65  }
66 
67  protected function loadFile() {
68  if ( $this->fileLoaded ) {
69  return;
70  }
71  $this->fileLoaded = true;
72 
73  $this->displayImg = $img = false;
74 
75  Hooks::run( 'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
76  if ( !$img ) { // not set by hook?
77  $img = wfFindFile( $this->getTitle() );
78  if ( !$img ) {
79  $img = wfLocalFile( $this->getTitle() );
80  }
81  }
82  $this->mPage->setFile( $img );
83  if ( !$this->displayImg ) { // not set by hook?
84  $this->displayImg = $img;
85  }
86  $this->repo = $img->getRepo();
87  }
88 
89  public function view() {
90  global $wgShowEXIF;
91 
92  // For action=render, include body text only; none of the image extras
93  if ( $this->viewIsRenderAction ) {
94  parent::view();
95  return;
96  }
97 
98  $out = $this->getContext()->getOutput();
99  $request = $this->getContext()->getRequest();
100  $diff = $request->getVal( 'diff' );
101  $diffOnly = $request->getBool(
102  'diffonly',
103  $this->getContext()->getUser()->getOption( 'diffonly' )
104  );
105 
106  if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) {
107  parent::view();
108  return;
109  }
110 
111  $this->loadFile();
112 
113  if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
114  if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
115  $request->setVal( 'diffonly', 'true' );
116  }
117 
118  parent::view();
119  return;
120  }
121 
122  if ( $wgShowEXIF && $this->displayImg->exists() ) {
123  // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
124  $formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() );
125  $showmeta = $formattedMetadata !== false;
126  } else {
127  $showmeta = false;
128  }
129 
130  if ( !$diff && $this->displayImg->exists() ) {
131  $out->addHTML( $this->showTOC( $showmeta ) );
132  }
133 
134  if ( !$diff ) {
135  $this->openShowImage();
136  }
137 
138  # No need to display noarticletext, we use our own message, output in openShowImage()
139  if ( $this->mPage->getId() ) {
140  # NS_FILE is in the user language, but this section (the actual wikitext)
141  # should be in page content language
142  $pageLang = $this->getTitle()->getPageViewLanguage();
143  $out->addHTML( Xml::openElement( 'div', [ 'id' => 'mw-imagepage-content',
144  'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
145  'class' => 'mw-content-' . $pageLang->getDir() ] ) );
146 
147  parent::view();
148 
149  $out->addHTML( Xml::closeElement( 'div' ) );
150  } else {
151  # Just need to set the right headers
152  $out->setArticleFlag( true );
153  $out->setPageTitle( $this->getTitle()->getPrefixedText() );
154  $this->mPage->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() );
155  }
156 
157  # Show shared description, if needed
158  if ( $this->mExtraDescription ) {
159  $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
160  if ( !$fol->isDisabled() ) {
161  $out->addWikiTextAsInterface( $fol->plain() );
162  }
163  $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
164  }
165 
166  $this->closeShowImage();
167  $this->imageHistory();
168  // TODO: Cleanup the following
169 
170  $out->addHTML( Xml::element( 'h2',
171  [ 'id' => 'filelinks' ],
172  $this->getContext()->msg( 'imagelinks' )->text() ) . "\n" );
173  $this->imageDupes();
174  # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
175  # Yet we return metadata about the target. Definitely an issue in the FileRepo
176  $this->imageLinks();
177 
178  # Allow extensions to add something after the image links
179  $html = '';
180  Hooks::run( 'ImagePageAfterImageLinks', [ $this, &$html ] );
181  if ( $html ) {
182  $out->addHTML( $html );
183  }
184 
185  if ( $showmeta ) {
186  $out->addHTML( Xml::element(
187  'h2',
188  [ 'id' => 'metadata' ],
189  $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
190  $out->wrapWikiTextAsInterface(
191  'mw-imagepage-section-metadata',
192  $this->makeMetadataTable( $formattedMetadata )
193  );
194  $out->addModules( [ 'mediawiki.action.view.metadata' ] );
195  }
196 
197  // Add remote Filepage.css
198  if ( !$this->repo->isLocal() ) {
199  $css = $this->repo->getDescriptionStylesheetUrl();
200  if ( $css ) {
201  $out->addStyle( $css );
202  }
203  }
204 
205  $out->addModuleStyles( [
206  'filepage', // always show the local local Filepage.css, T31277
207  'mediawiki.action.view.filepage', // Add MediaWiki styles for a file page
208  ] );
209  }
210 
214  public function getDisplayedFile() {
215  $this->loadFile();
216  return $this->displayImg;
217  }
218 
225  protected function showTOC( $metadata ) {
226  $r = [
227  '<li><a href="#file">' . $this->getContext()->msg( 'file-anchor-link' )->escaped() . '</a></li>',
228  '<li><a href="#filehistory">' . $this->getContext()->msg( 'filehist' )->escaped() . '</a></li>',
229  '<li><a href="#filelinks">' . $this->getContext()->msg( 'imagelinks' )->escaped() . '</a></li>',
230  ];
231 
232  Hooks::run( 'ImagePageShowTOC', [ $this, &$r ] );
233 
234  if ( $metadata ) {
235  $r[] = '<li><a href="#metadata">' .
236  $this->getContext()->msg( 'metadata' )->escaped() .
237  '</a></li>';
238  }
239 
240  return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
241  }
242 
251  protected function makeMetadataTable( $metadata ) {
252  $r = $this->getContext()->msg( 'metadata-help' )->plain();
253  // Intial state is collapsed
254  // see filepage.css and mediawiki.action.view.metadata module.
255  $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
256  foreach ( $metadata as $type => $stuff ) {
257  foreach ( $stuff as $v ) {
258  $class = str_replace( ' ', '_', $v['id'] );
259  if ( $type == 'collapsed' ) {
260  $class .= ' mw-metadata-collapsible';
261  }
262  $r .= Html::rawElement( 'tr',
263  [ 'class' => $class ],
264  Html::rawElement( 'th', [], $v['name'] )
265  . Html::rawElement( 'td', [], $v['value'] )
266  );
267  }
268  }
269  $r .= "</table>\n";
270  return $r;
271  }
272 
283  $this->loadFile();
284  if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && $this->getId() == 0 ) {
285  return new ParserOutput();
286  }
287  return parent::getEmptyPageParserOutput( $options );
288  }
289 
290  private function getLanguageForRendering( WebRequest $request, File $file ) {
291  $handler = $this->displayImg->getHandler();
292  if ( !$handler ) {
293  return null;
294  }
295 
296  $requestLanguage = $request->getVal( 'lang' );
297  if ( !is_null( $requestLanguage ) ) {
298  if ( $handler->validateParam( 'lang', $requestLanguage ) ) {
299  return $requestLanguage;
300  }
301  }
302 
303  return $handler->getDefaultRenderLanguage( $this->displayImg );
304  }
305 
306  protected function openShowImage() {
308 
309  $this->loadFile();
310  $out = $this->getContext()->getOutput();
311  $user = $this->getContext()->getUser();
312  $lang = $this->getContext()->getLanguage();
313  $dirmark = $lang->getDirMarkEntity();
314  $request = $this->getContext()->getRequest();
315 
316  $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
317  $maxWidth = $max[0];
318  $maxHeight = $max[1];
319 
320  if ( $this->displayImg->exists() ) {
321  # image
322  $page = $request->getIntOrNull( 'page' );
323  if ( is_null( $page ) ) {
324  $params = [];
325  $page = 1;
326  } else {
327  $params = [ 'page' => $page ];
328  }
329 
330  $renderLang = $this->getLanguageForRendering( $request, $this->displayImg );
331  if ( !is_null( $renderLang ) ) {
332  $params['lang'] = $renderLang;
333  }
334 
335  $width_orig = $this->displayImg->getWidth( $page );
336  $width = $width_orig;
337  $height_orig = $this->displayImg->getHeight( $page );
338  $height = $height_orig;
339 
340  $filename = wfEscapeWikiText( $this->displayImg->getName() );
341  $linktext = $filename;
342 
343  // Avoid PHP 7.1 warning from passing $this by reference
344  $imagePage = $this;
345 
346  Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$imagePage, &$out ] );
347 
348  if ( $this->displayImg->allowInlineDisplay() ) {
349  # image
350  # "Download high res version" link below the image
351  # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
352  # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
353  # We'll show a thumbnail of this image
354  if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
355  list( $width, $height ) = $this->getDisplayWidthHeight(
356  $maxWidth, $maxHeight, $width, $height
357  );
358  $linktext = $this->getContext()->msg( 'show-big-image' )->escaped();
359 
360  $thumbSizes = $this->getThumbSizes( $width_orig, $height_orig );
361  # Generate thumbnails or thumbnail links as needed...
362  $otherSizes = [];
363  foreach ( $thumbSizes as $size ) {
364  // We include a thumbnail size in the list, if it is
365  // less than or equal to the original size of the image
366  // asset ($width_orig/$height_orig). We also exclude
367  // the current thumbnail's size ($width/$height)
368  // since that is added to the message separately, so
369  // it can be denoted as the current size being shown.
370  // Vectorized images are limited by $wgSVGMaxSize big,
371  // so all thumbs less than or equal that are shown.
372  if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
373  || ( $this->displayImg->isVectorized()
374  && max( $size[0], $size[1] ) <= $wgSVGMaxSize )
375  )
376  && $size[0] != $width && $size[1] != $height
377  ) {
378  $sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
379  if ( $sizeLink ) {
380  $otherSizes[] = $sizeLink;
381  }
382  }
383  }
384  $otherSizes = array_unique( $otherSizes );
385 
386  $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height );
387  $msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview );
388  if ( count( $otherSizes ) ) {
389  $msgsmall .= ' ' .
391  'span',
392  [ 'class' => 'mw-filepage-other-resolutions' ],
393  $this->getContext()->msg( 'show-big-image-other' )
394  ->rawParams( $lang->pipeList( $otherSizes ) )
395  ->params( count( $otherSizes ) )
396  ->parse()
397  );
398  }
399  } elseif ( $width == 0 && $height == 0 ) {
400  # Some sort of audio file that doesn't have dimensions
401  # Don't output a no hi res message for such a file
402  $msgsmall = '';
403  } else {
404  # Image is small enough to show full size on image page
405  $msgsmall = $this->getContext()->msg( 'file-nohires' )->parse();
406  }
407 
408  $params['width'] = $width;
409  $params['height'] = $height;
410  $thumbnail = $this->displayImg->transform( $params );
411  Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params );
412 
413  $anchorclose = Html::rawElement(
414  'div',
415  [ 'class' => 'mw-filepage-resolutioninfo' ],
416  $msgsmall
417  );
418 
419  $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
420  if ( $isMulti ) {
421  $out->addModules( 'mediawiki.page.image.pagination' );
422  $out->addHTML( '<table class="multipageimage"><tr><td>' );
423  }
424 
425  if ( $thumbnail ) {
426  $options = [
427  'alt' => $this->displayImg->getTitle()->getPrefixedText(),
428  'file-link' => true,
429  ];
430  $out->addHTML( '<div class="fullImageLink" id="file">' .
431  $thumbnail->toHtml( $options ) .
432  $anchorclose . "</div>\n" );
433  }
434 
435  if ( $isMulti ) {
436  $count = $this->displayImg->pageCount();
437 
438  if ( $page > 1 ) {
439  $label = $this->getContext()->msg( 'imgmultipageprev' )->text();
440  // on the client side, this link is generated in ajaxifyPageNavigation()
441  // in the mediawiki.page.image.pagination module
443  $this->getTitle(),
444  htmlspecialchars( $label ),
445  [],
446  [ 'page' => $page - 1 ]
447  );
448  $thumb1 = Linker::makeThumbLinkObj(
449  $this->getTitle(),
450  $this->displayImg,
451  $link,
452  $label,
453  'none',
454  [ 'page' => $page - 1 ]
455  );
456  } else {
457  $thumb1 = '';
458  }
459 
460  if ( $page < $count ) {
461  $label = $this->getContext()->msg( 'imgmultipagenext' )->text();
463  $this->getTitle(),
464  htmlspecialchars( $label ),
465  [],
466  [ 'page' => $page + 1 ]
467  );
468  $thumb2 = Linker::makeThumbLinkObj(
469  $this->getTitle(),
470  $this->displayImg,
471  $link,
472  $label,
473  'none',
474  [ 'page' => $page + 1 ]
475  );
476  } else {
477  $thumb2 = '';
478  }
479 
480  global $wgScript;
481 
482  $formParams = [
483  'name' => 'pageselector',
484  'action' => $wgScript,
485  ];
486  $options = [];
487  for ( $i = 1; $i <= $count; $i++ ) {
488  $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
489  }
490  $select = Xml::tags( 'select',
491  [ 'id' => 'pageselector', 'name' => 'page' ],
492  implode( "\n", $options ) );
493 
494  $out->addHTML(
495  '</td><td><div class="multipageimagenavbox">' .
496  Xml::openElement( 'form', $formParams ) .
497  Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
498  $this->getContext()->msg( 'imgmultigoto' )->rawParams( $select )->parse() .
499  $this->getContext()->msg( 'word-separator' )->escaped() .
500  Xml::submitButton( $this->getContext()->msg( 'imgmultigo' )->text() ) .
501  Xml::closeElement( 'form' ) .
502  "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
503  );
504  }
505  } elseif ( $this->displayImg->isSafeFile() ) {
506  # if direct link is allowed but it's not a renderable image, show an icon.
507  $icon = $this->displayImg->iconThumb();
508 
509  $out->addHTML( '<div class="fullImageLink" id="file">' .
510  $icon->toHtml( [ 'file-link' => true ] ) .
511  "</div>\n" );
512  }
513 
514  $longDesc = $this->getContext()->msg( 'parentheses', $this->displayImg->getLongDesc() )->text();
515 
516  $handler = $this->displayImg->getHandler();
517 
518  // If this is a filetype with potential issues, warn the user.
519  if ( $handler ) {
520  $warningConfig = $handler->getWarningConfig( $this->displayImg );
521 
522  if ( $warningConfig !== null ) {
523  // The warning will be displayed via CSS and JavaScript.
524  // We just need to tell the client side what message to use.
525  $output = $this->getContext()->getOutput();
526  $output->addJsConfigVars( 'wgFileWarning', $warningConfig );
527  $output->addModules( $warningConfig['module'] );
528  $output->addModules( 'mediawiki.filewarning' );
529  }
530  }
531 
532  $medialink = "[[Media:$filename|$linktext]]";
533 
534  if ( !$this->displayImg->isSafeFile() ) {
535  $warning = $this->getContext()->msg( 'mediawarning' )->plain();
536  // dirmark is needed here to separate the file name, which
537  // most likely ends in Latin characters, from the description,
538  // which may begin with the file type. In RTL environment
539  // this will get messy.
540  // The dirmark, however, must not be immediately adjacent
541  // to the filename, because it can get copied with it.
542  // See T27277.
543  // phpcs:disable Generic.Files.LineLength
544  $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
545 <span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span>
546 EOT
547  );
548  // phpcs:enable
549  $out->wrapWikiTextAsInterface( 'mediaWarning', $warning );
550  } else {
551  $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
552 {$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
553 EOT
554  );
555  }
556 
557  $renderLangOptions = $this->displayImg->getAvailableLanguages();
558  if ( count( $renderLangOptions ) >= 1 ) {
559  $out->addHTML( $this->doRenderLangOpt( $renderLangOptions, $renderLang ) );
560  }
561 
562  // Add cannot animate thumbnail warning
563  if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
564  // Include the extension so wiki admins can
565  // customize it on a per file-type basis
566  // (aka say things like use format X instead).
567  // additionally have a specific message for
568  // file-no-thumb-animation-gif
569  $ext = $this->displayImg->getExtension();
570  $noAnimMesg = wfMessageFallback(
571  'file-no-thumb-animation-' . $ext,
572  'file-no-thumb-animation'
573  )->plain();
574 
575  $out->wrapWikiTextAsInterface( 'mw-noanimatethumb', $noAnimMesg );
576  }
577 
578  if ( !$this->displayImg->isLocal() ) {
579  $this->printSharedImageText();
580  }
581  } else {
582  # Image does not exist
583  if ( !$this->getId() ) {
584  $dbr = wfGetDB( DB_REPLICA );
585 
586  # No article exists either
587  # Show deletion log to be consistent with normal articles
589  $out,
590  [ 'delete', 'move', 'protect' ],
591  $this->getTitle()->getPrefixedText(),
592  '',
593  [ 'lim' => 10,
594  'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
595  'showIfEmpty' => false,
596  'msgKey' => [ 'moveddeleted-notice' ]
597  ]
598  );
599  }
600 
601  if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
602  // Only show an upload link if the user can upload
603  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
604  $nofile = [
605  'filepage-nofile-link',
606  $uploadTitle->getFullURL( [ 'wpDestFile' => $this->mPage->getFile()->getName() ] )
607  ];
608  } else {
609  $nofile = 'filepage-nofile';
610  }
611  // Note, if there is an image description page, but
612  // no image, then this setRobotPolicy is overridden
613  // by Article::View().
614  $out->setRobotPolicy( 'noindex,nofollow' );
615  $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
616  if ( !$this->getId() && $wgSend404Code ) {
617  // If there is no image, no shared image, and no description page,
618  // output a 404, to be consistent with Article::showMissingArticle.
619  $request->response()->statusHeader( 404 );
620  }
621  }
622  $out->setFileVersion( $this->displayImg );
623  }
624 
632  protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) {
633  if ( $sizeLinkBigImagePreview ) {
634  // Show a different message of preview is different format from original.
635  $previewTypeDiffers = false;
636  $origExt = $thumbExt = $this->displayImg->getExtension();
637  if ( $this->displayImg->getHandler() ) {
638  $origMime = $this->displayImg->getMimeType();
639  $typeParams = $params;
640  $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
641  list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
642  $origExt, $origMime, $typeParams );
643  if ( $thumbMime !== $origMime ) {
644  $previewTypeDiffers = true;
645  }
646  }
647  if ( $previewTypeDiffers ) {
648  return $this->getContext()->msg( 'show-big-image-preview-differ' )->
649  rawParams( $sizeLinkBigImagePreview )->
650  params( strtoupper( $origExt ) )->
651  params( strtoupper( $thumbExt ) )->
652  parse();
653  } else {
654  return $this->getContext()->msg( 'show-big-image-preview' )->
655  rawParams( $sizeLinkBigImagePreview )->
656  parse();
657  }
658  } else {
659  return '';
660  }
661  }
662 
670  protected function makeSizeLink( $params, $width, $height ) {
671  $params['width'] = $width;
672  $params['height'] = $height;
673  $thumbnail = $this->displayImg->transform( $params );
674  if ( $thumbnail && !$thumbnail->isError() ) {
675  return Html::rawElement( 'a', [
676  'href' => $thumbnail->getUrl(),
677  'class' => 'mw-thumbnail-link'
678  ], $this->getContext()->msg( 'show-big-image-size' )->numParams(
679  $thumbnail->getWidth(), $thumbnail->getHeight()
680  )->parse() );
681  } else {
682  return '';
683  }
684  }
685 
689  protected function printSharedImageText() {
690  $out = $this->getContext()->getOutput();
691  $this->loadFile();
692 
693  $descUrl = $this->mPage->getFile()->getDescriptionUrl();
694  $descText = $this->mPage->getFile()->getDescriptionText( $this->getContext()->getLanguage() );
695 
696  /* Add canonical to head if there is no local page for this shared file */
697  if ( $descUrl && $this->mPage->getId() == 0 ) {
698  $out->setCanonicalUrl( $descUrl );
699  }
700 
701  $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
702  $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
703 
704  if ( $descUrl &&
705  $descText &&
706  $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-'
707  ) {
708  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-here', $repo, $descUrl ] );
709  } elseif ( $descUrl &&
710  $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-'
711  ) {
712  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-there', $repo, $descUrl ] );
713  } else {
714  $out->wrapWikiMsg( $wrap, [ 'sharedupload', $repo ], ''/*BACKCOMPAT*/ );
715  }
716 
717  if ( $descText ) {
718  $this->mExtraDescription = $descText;
719  }
720  }
721 
722  public function getUploadUrl() {
723  $this->loadFile();
724  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
725  return $uploadTitle->getFullURL( [
726  'wpDestFile' => $this->mPage->getFile()->getName(),
727  'wpForReUpload' => 1
728  ] );
729  }
730 
735  protected function uploadLinksBox() {
736  global $wgEnableUploads;
737 
738  if ( !$wgEnableUploads ) {
739  return;
740  }
741 
742  $this->loadFile();
743  if ( !$this->mPage->getFile()->isLocal() ) {
744  return;
745  }
746 
747  $out = $this->getContext()->getOutput();
748  $out->addHTML( "<ul>\n" );
749 
750  # "Upload a new version of this file" link
751  $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
752  if ( $canUpload && UploadBase::userCanReUpload(
753  $this->getContext()->getUser(),
754  $this->mPage->getFile() )
755  ) {
756  $ulink = Linker::makeExternalLink(
757  $this->getUploadUrl(),
758  $this->getContext()->msg( 'uploadnewversion-linktext' )->text()
759  );
760  $out->addHTML( "<li id=\"mw-imagepage-reupload-link\">"
761  . "<div class=\"plainlinks\">{$ulink}</div></li>\n" );
762  } else {
763  $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">"
764  . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
765  }
766 
767  $out->addHTML( "</ul>\n" );
768  }
769 
773  protected function closeShowImage() {
774  }
775 
780  protected function imageHistory() {
781  $this->loadFile();
782  $out = $this->getContext()->getOutput();
783  $pager = new ImageHistoryPseudoPager( $this );
784  $out->addHTML( $pager->getBody() );
785  $out->preventClickjacking( $pager->getPreventClickjacking() );
786 
787  $this->mPage->getFile()->resetHistory(); // free db resources
788 
789  # Exist check because we don't want to show this on pages where an image
790  # doesn't exist along with the noimage message, that would suck. -√¶var
791  if ( $this->mPage->getFile()->exists() ) {
792  $this->uploadLinksBox();
793  }
794  }
795 
801  protected function queryImageLinks( $target, $limit ) {
802  $dbr = wfGetDB( DB_REPLICA );
803 
804  return $dbr->select(
805  [ 'imagelinks', 'page' ],
806  [ 'page_namespace', 'page_title', 'il_to' ],
807  [ 'il_to' => $target, 'il_from = page_id' ],
808  __METHOD__,
809  [ 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', ]
810  );
811  }
812 
813  protected function imageLinks() {
814  $limit = 100;
815 
816  $out = $this->getContext()->getOutput();
817 
818  $rows = [];
819  $redirects = [];
820  foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) {
821  $redirects[$redir->getDBkey()] = [];
822  $rows[] = (object)[
823  'page_namespace' => NS_FILE,
824  'page_title' => $redir->getDBkey(),
825  ];
826  }
827 
828  $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
829  foreach ( $res as $row ) {
830  $rows[] = $row;
831  }
832  $count = count( $rows );
833 
834  $hasMore = $count > $limit;
835  if ( !$hasMore && count( $redirects ) ) {
836  $res = $this->queryImageLinks( array_keys( $redirects ),
837  $limit - count( $rows ) + 1 );
838  foreach ( $res as $row ) {
839  $redirects[$row->il_to][] = $row;
840  $count++;
841  }
842  $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
843  }
844 
845  if ( $count == 0 ) {
846  $out->wrapWikiMsg(
847  Html::rawElement( 'div',
848  [ 'id' => 'mw-imagepage-nolinkstoimage' ], "\n$1\n" ),
849  'nolinkstoimage'
850  );
851  return;
852  }
853 
854  $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
855  if ( !$hasMore ) {
856  $out->addWikiMsg( 'linkstoimage', $count );
857  } else {
858  // More links than the limit. Add a link to [[Special:Whatlinkshere]]
859  $out->addWikiMsg( 'linkstoimage-more',
860  $this->getContext()->getLanguage()->formatNum( $limit ),
861  $this->getTitle()->getPrefixedDBkey()
862  );
863  }
864 
865  $out->addHTML(
866  Html::openElement( 'ul',
867  [ 'class' => 'mw-imagepage-linkstoimage' ] ) . "\n"
868  );
869  $count = 0;
870 
871  // Sort the list by namespace:title
872  usort( $rows, [ $this, 'compare' ] );
873 
874  // Create links for every element
875  $currentCount = 0;
876  foreach ( $rows as $element ) {
877  $currentCount++;
878  if ( $currentCount > $limit ) {
879  break;
880  }
881 
882  $query = [];
883  # Add a redirect=no to make redirect pages reachable
884  if ( isset( $redirects[$element->page_title] ) ) {
885  $query['redirect'] = 'no';
886  }
888  Title::makeTitle( $element->page_namespace, $element->page_title ),
889  null, [], $query
890  );
891  if ( !isset( $redirects[$element->page_title] ) ) {
892  # No redirects
893  $liContents = $link;
894  } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
895  # Redirect without usages
896  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )
897  ->rawParams( $link, '' )
898  ->parse();
899  } else {
900  # Redirect with usages
901  $li = '';
902  foreach ( $redirects[$element->page_title] as $row ) {
903  $currentCount++;
904  if ( $currentCount > $limit ) {
905  break;
906  }
907 
908  $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
909  $li .= Html::rawElement(
910  'li',
911  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
912  $link2
913  ) . "\n";
914  }
915 
917  'ul',
918  [ 'class' => 'mw-imagepage-redirectstofile' ],
919  $li
920  ) . "\n";
921  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams(
922  $link, $ul )->parse();
923  }
924  $out->addHTML( Html::rawElement(
925  'li',
926  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
927  $liContents
928  ) . "\n"
929  );
930 
931  };
932  $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
933  $res->free();
934 
935  // Add a links to [[Special:Whatlinkshere]]
936  if ( $count > $limit ) {
937  $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
938  }
939  $out->addHTML( Html::closeElement( 'div' ) . "\n" );
940  }
941 
942  protected function imageDupes() {
943  $this->loadFile();
944  $out = $this->getContext()->getOutput();
945 
946  $dupes = $this->mPage->getDuplicates();
947  if ( count( $dupes ) == 0 ) {
948  return;
949  }
950 
951  $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
952  $out->addWikiMsg( 'duplicatesoffile',
953  $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
954  );
955  $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
956 
960  foreach ( $dupes as $file ) {
961  $fromSrc = '';
962  if ( $file->isLocal() ) {
963  $link = Linker::linkKnown( $file->getTitle() );
964  } else {
965  $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
966  $file->getTitle()->getPrefixedText() );
967  $fromSrc = $this->getContext()->msg(
968  'shared-repo-from',
969  $file->getRepo()->getDisplayName()
970  )->escaped();
971  }
972  $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
973  }
974  $out->addHTML( "</ul></div>\n" );
975  }
976 
980  public function delete() {
981  $file = $this->mPage->getFile();
982  if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
983  // Standard article deletion
984  parent::delete();
985  return;
986  }
987 
988  $deleter = new FileDeleteForm( $file );
989  $deleter->execute();
990  }
991 
997  function showError( $description ) {
998  $out = $this->getContext()->getOutput();
999  $out->setPageTitle( $this->getContext()->msg( 'internalerror' ) );
1000  $out->setRobotPolicy( 'noindex,nofollow' );
1001  $out->setArticleRelated( false );
1002  $out->enableClientCache( false );
1003  $out->addWikiTextAsInterface( $description );
1004  }
1005 
1014  protected function compare( $a, $b ) {
1015  return $a->page_namespace <=> $b->page_namespace
1016  ?: strcmp( $a->page_title, $b->page_title );
1017  }
1018 
1027  public function getImageLimitsFromOption( $user, $optionName ) {
1028  global $wgImageLimits;
1029 
1030  $option = $user->getIntOption( $optionName );
1031  if ( !isset( $wgImageLimits[$option] ) ) {
1032  $option = User::getDefaultOption( $optionName );
1033  }
1034 
1035  // The user offset might still be incorrect, specially if
1036  // $wgImageLimits got changed (see T10858).
1037  if ( !isset( $wgImageLimits[$option] ) ) {
1038  // Default to the first offset in $wgImageLimits
1039  $option = 0;
1040  }
1041 
1042  // if nothing is set, fallback to a hardcoded default
1043  return $wgImageLimits[$option] ?? [ 800, 600 ];
1044  }
1045 
1053  protected function doRenderLangOpt( array $langChoices, $renderLang ) {
1054  global $wgScript;
1055  $opts = '';
1056 
1057  $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
1058 
1059  foreach ( $langChoices as $lang ) {
1060  $opts .= $this->createXmlOptionStringForLanguage(
1061  $lang,
1062  $matchedRenderLang === $lang
1063  );
1064  }
1065 
1066  // Allow for the default case in an svg <switch> that is displayed if no
1067  // systemLanguage attribute matches
1068  $opts .= "\n" .
1069  Xml::option(
1070  $this->getContext()->msg( 'img-lang-default' )->text(),
1071  'und',
1072  is_null( $matchedRenderLang )
1073  );
1074 
1075  $select = Html::rawElement(
1076  'select',
1077  [ 'id' => 'mw-imglangselector', 'name' => 'lang' ],
1078  $opts
1079  );
1080  $submit = Xml::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() );
1081 
1082  $formContents = $this->getContext()->msg( 'img-lang-info' )
1083  ->rawParams( $select, $submit )
1084  ->parse();
1085  $formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
1086 
1087  $langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ],
1088  Html::rawElement( 'form', [ 'action' => $wgScript ], $formContents )
1089  );
1090  return $langSelectLine;
1091  }
1092 
1098  private function createXmlOptionStringForLanguage( $lang, $selected ) {
1100  $name = Language::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
1101  if ( $name !== '' ) {
1102  $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
1103  } else {
1104  $display = $code;
1105  }
1106  return "\n" .
1107  Xml::option(
1108  $display,
1109  $lang,
1110  $selected
1111  );
1112  }
1113 
1128  protected function getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height ) {
1129  if ( !$maxWidth || !$maxHeight ) {
1130  // should never happen
1131  throw new MWException( 'Using a choice from $wgImageLimits that is 0x0' );
1132  }
1133 
1134  if ( !$width || !$height ) {
1135  return [ 0, 0 ];
1136  }
1137 
1138  # Calculate the thumbnail size.
1139  if ( $width <= $maxWidth && $height <= $maxHeight ) {
1140  // Vectorized image, do nothing.
1141  } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1142  # The limiting factor is the width, not the height.
1143  $height = round( $height * $maxWidth / $width );
1144  $width = $maxWidth;
1145  # Note that $height <= $maxHeight now.
1146  } else {
1147  $newwidth = floor( $width * $maxHeight / $height );
1148  $height = round( $height * $newwidth / $width );
1149  $width = $newwidth;
1150  # Note that $height <= $maxHeight now, but might not be identical
1151  # because of rounding.
1152  }
1153  return [ $width, $height ];
1154  }
1155 
1164  protected function getThumbSizes( $origWidth, $origHeight ) {
1165  global $wgImageLimits;
1166  if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1167  $thumbSizes = $wgImageLimits;
1168  // Also include the full sized resolution in the list, so
1169  // that users know they can get it. This will link to the
1170  // original file asset if mustRender() === false. In the case
1171  // that we mustRender, some users have indicated that they would
1172  // find it useful to have the full size image in the rendered
1173  // image format.
1174  $thumbSizes[] = [ $origWidth, $origHeight ];
1175  } else {
1176  # Creating thumb links triggers thumbnail generation.
1177  # Just generate the thumb for the current users prefs.
1178  $thumbSizes = [
1179  $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' )
1180  ];
1181  if ( !$this->displayImg->mustRender() ) {
1182  // We can safely include a link to the "full-size" preview,
1183  // without actually rendering.
1184  $thumbSizes[] = [ $origWidth, $origHeight ];
1185  }
1186  }
1187  return $thumbSizes;
1188  }
1189 
1194  public function getFile() {
1195  return $this->mPage->getFile();
1196  }
1197 
1202  public function isLocal() {
1203  return $this->mPage->isLocal();
1204  }
1205 
1210  public function getDuplicates() {
1211  return $this->mPage->getDuplicates();
1212  }
1213 
1218  public function getForeignCategories() {
1219  $this->mPage->getForeignCategories();
1220  }
1221 
1222 }
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
$article view()
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 $rows
Definition: hooks.txt:2625
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 & $html
Definition: hooks.txt:1995
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
bool $fileLoaded
Definition: ImagePage.php:38
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1598
either a plain
Definition: hooks.txt:2056
$wgScript
The URL path to index.php.
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
makeSizeLink( $params, $width, $height)
Creates an thumbnail of specified size and returns an HTML link to it.
Definition: ImagePage.php:670
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it&#39;s not set.
Definition: WebRequest.php:440
compare( $a, $b)
Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare() ...
Definition: ImagePage.php:1014
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:486
if(!isset( $args[0])) $lang
globals will be eliminated from MediaWiki replaced by an application object which would be passed to constructors Whether that would be an convenient solution remains to be but certainly PHP makes such object oriented programming models easier than they were in previous versions For the time being MediaWiki programmers will have to work in an environment with some global context At the time of globals were initialised on startup by MediaWiki of these were configuration which are documented in DefaultSettings php There is no comprehensive documentation for the remaining however some of the most important ones are listed below They are typically initialised either in index php or in Setup php $wgTitle Title object created from the request URL $wgOut OutputPage object for HTTP response $wgUser User object for the user associated with the current request $wgLang Language object selected by user preferences $wgContLang Language object associated with the wiki being viewed $wgParser Parser object Parser extensions register their hooks here $wgRequest WebRequest object
Definition: globals.txt:25
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing &#39;/&#39;...
Definition: Html.php:252
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:210
getImageLimitsFromOption( $user, $optionName)
Returns the corresponding $wgImageLimits entry for the selected user option.
Definition: ImagePage.php:1027
setFile( $file)
Definition: ImagePage.php:61
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getUploadUrl()
Definition: ImagePage.php:722
Class for viewing MediaWiki article and history.
Definition: Article.php:38
Class for viewing MediaWiki file description pages.
Definition: ImagePage.php:30
FileRepo $repo
Definition: ImagePage.php:35
getLanguageForRendering(WebRequest $request, File $file)
Definition: ImagePage.php:290
getEmptyPageParserOutput(ParserOptions $options)
Overloading Article&#39;s getEmptyPageParserOutput method.
Definition: ImagePage.php:282
printSharedImageText()
Show a notice that the file is from a shared repository.
Definition: ImagePage.php:689
wfLocalFile( $title)
Get an object referring to a locally registered file.
imageHistory()
If the page we&#39;ve just displayed is in the "Image" namespace, we follow it with an upload history of ...
Definition: ImagePage.php:780
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
uploadLinksBox()
Print out the various links at the bottom of the image page, e.g.
Definition: ImagePage.php:735
static userCanReUpload(User $user, File $img)
Check if a user is the last uploader.
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2220
getForeignCategories()
Definition: ImagePage.php:1218
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3042
$wgEnableUploads
Allow users to upload files.
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2238
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition: hooks.txt:780
createXmlOptionStringForLanguage( $lang, $selected)
Definition: ImagePage.php:1098
$wgShowEXIF
Show Exif data, on by default if available.
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:110
$css
wfFindFile( $title, $options=[])
Find a file.
$res
Definition: database.txt:21
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:461
wfMessageFallback(... $keys)
This function accepts multiple message keys and returns a message instance for the first message whic...
doRenderLangOpt(array $langChoices, $renderLang)
Output a drop-down box for language options for the file.
Definition: ImagePage.php:1053
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
getThumbPrevText( $params, $sizeLinkBigImagePreview)
Make the text under the image to say what size preview.
Definition: ImagePage.php:632
getTitle()
Get the title object of the article.
Definition: Article.php:221
$params
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 & $options
Definition: hooks.txt:1995
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:132
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:316
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition: Linker.php:827
showTOC( $metadata)
Create the TOC.
Definition: ImagePage.php:225
File $displayImg
Definition: ImagePage.php:32
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not null
Definition: hooks.txt:780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:935
const NS_FILE
Definition: Defines.php:70
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don&#39;t need a full Title object...
Definition: SpecialPage.php:82
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 modifiable & $code
Definition: hooks.txt:780
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
Special handling for file pages.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2560
$wgSVGMaxSize
Don&#39;t scale a SVG larger than this.
queryImageLinks( $target, $limit)
Definition: ImagePage.php:801
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1818
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:545
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:940
showError( $description)
Display an error with a wikitext description.
Definition: ImagePage.php:997
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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:780
static closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:119
getId()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2472
makeMetadataTable( $metadata)
Make a table with metadata to be shown in the output page.
Definition: ImagePage.php:251
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to &#39;known&#39;.
Definition: Linker.php:141
getThumbSizes( $origWidth, $origHeight)
Get alternative thumbnail sizes.
Definition: ImagePage.php:1164
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:801
getOldID()
Definition: Article.php:326
getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height)
Get the width and height to display image at.
Definition: ImagePage.php:1128
getDisplayName()
Get the human-readable name of the repo.
Definition: FileRepo.php:1787
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
newPage(Title $title)
Definition: ImagePage.php:52
bool $mExtraDescription
Definition: ImagePage.php:41
getDisplayedFile()
Definition: ImagePage.php:214
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
Definition: Linker.php:639
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
static makeThumbLinkObj(Title $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
Definition: Linker.php:491
const DB_REPLICA
Definition: defines.php:25
WikiFilePage $mPage
Definition: ImagePage.php:46
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:51
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code, mangling or hiding MediaWiki&#39;s output.
$ext
Definition: router.php:55
File deletion user interface.
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:2625
static bcp47( $code)
Get the normalised IETF language tag See unit test for examples.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1486
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
closeShowImage()
For overloading.
Definition: ImagePage.php:773
openShowImage()
Definition: ImagePage.php:306