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 
93  public function render() {
94  $this->getContext()->getOutput()->setArticleBodyOnly( true );
95  parent::view();
96  }
97 
98  public function view() {
100 
101  $out = $this->getContext()->getOutput();
102  $request = $this->getContext()->getRequest();
103  $diff = $request->getVal( 'diff' );
104  $diffOnly = $request->getBool(
105  'diffonly',
106  $this->getContext()->getUser()->getOption( 'diffonly' )
107  );
108 
109  if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) {
110  parent::view();
111  return;
112  }
113 
114  $this->loadFile();
115 
116  if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
117  if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
118  $request->setVal( 'diffonly', 'true' );
119  }
120 
121  parent::view();
122  return;
123  }
124 
125  if ( $wgShowEXIF && $this->displayImg->exists() ) {
126  // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
127  $formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() );
128  $showmeta = $formattedMetadata !== false;
129  } else {
130  $showmeta = false;
131  }
132 
133  if ( !$diff && $this->displayImg->exists() ) {
134  $out->addHTML( $this->showTOC( $showmeta ) );
135  }
136 
137  if ( !$diff ) {
138  $this->openShowImage();
139  }
140 
141  # No need to display noarticletext, we use our own message, output in openShowImage()
142  if ( $this->mPage->getId() ) {
143  # NS_FILE is in the user language, but this section (the actual wikitext)
144  # should be in page content language
145  $pageLang = $this->getTitle()->getPageViewLanguage();
146  $out->addHTML( Xml::openElement( 'div', [ 'id' => 'mw-imagepage-content',
147  'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
148  'class' => 'mw-content-' . $pageLang->getDir() ] ) );
149 
150  parent::view();
151 
152  $out->addHTML( Xml::closeElement( 'div' ) );
153  } else {
154  # Just need to set the right headers
155  $out->setArticleFlag( true );
156  $out->setPageTitle( $this->getTitle()->getPrefixedText() );
157  $this->mPage->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() );
158  }
159 
160  # Show shared description, if needed
161  if ( $this->mExtraDescription ) {
162  $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
163  if ( !$fol->isDisabled() ) {
164  $out->addWikiText( $fol->plain() );
165  }
166  $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
167  }
168 
169  $this->closeShowImage();
170  $this->imageHistory();
171  // TODO: Cleanup the following
172 
173  $out->addHTML( Xml::element( 'h2',
174  [ 'id' => 'filelinks' ],
175  $this->getContext()->msg( 'imagelinks' )->text() ) . "\n" );
176  $this->imageDupes();
177  # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
178  # Yet we return metadata about the target. Definitely an issue in the FileRepo
179  $this->imageLinks();
180 
181  # Allow extensions to add something after the image links
182  $html = '';
183  Hooks::run( 'ImagePageAfterImageLinks', [ $this, &$html ] );
184  if ( $html ) {
185  $out->addHTML( $html );
186  }
187 
188  if ( $showmeta ) {
189  $out->addHTML( Xml::element(
190  'h2',
191  [ 'id' => 'metadata' ],
192  $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
193  $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) );
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 = "<div class=\"mw-imagepage-section-metadata\">";
253  $r .= $this->getContext()->msg( 'metadata-help' )->plain();
254  // Intial state is collapsed
255  // see filepage.css and mediawiki.action.view.metadata module.
256  $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
257  foreach ( $metadata as $type => $stuff ) {
258  foreach ( $stuff as $v ) {
259  $class = str_replace( ' ', '_', $v['id'] );
260  if ( $type == 'collapsed' ) {
261  $class .= ' mw-metadata-collapsible';
262  }
263  $r .= Html::rawElement( 'tr',
264  [ 'class' => $class ],
265  Html::rawElement( 'th', [], $v['name'] )
266  . Html::rawElement( 'td', [], $v['value'] )
267  );
268  }
269  }
270  $r .= "</table>\n</div>\n";
271  return $r;
272  }
273 
281  public function getContentObject() {
282  $this->loadFile();
283  if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getId() ) {
284  return null;
285  }
286  return parent::getContentObject();
287  }
288 
289  private function getLanguageForRendering( WebRequest $request, File $file ) {
290  $handler = $this->displayImg->getHandler();
291  if ( !$handler ) {
292  return null;
293  }
294 
295  $requestLanguage = $request->getVal( 'lang' );
296  if ( !is_null( $requestLanguage ) ) {
297  if ( $handler->validateParam( 'lang', $requestLanguage ) ) {
298  return $requestLanguage;
299  }
300  }
301 
302  return $handler->getDefaultRenderLanguage( $this->displayImg );
303  }
304 
305  protected function openShowImage() {
307 
308  $this->loadFile();
309  $out = $this->getContext()->getOutput();
310  $user = $this->getContext()->getUser();
311  $lang = $this->getContext()->getLanguage();
312  $dirmark = $lang->getDirMarkEntity();
313  $request = $this->getContext()->getRequest();
314 
315  $max = $this->getImageLimitsFromOption( $user, 'imagesize' );
316  $maxWidth = $max[0];
317  $maxHeight = $max[1];
318 
319  if ( $this->displayImg->exists() ) {
320  # image
321  $page = $request->getIntOrNull( 'page' );
322  if ( is_null( $page ) ) {
323  $params = [];
324  $page = 1;
325  } else {
326  $params = [ 'page' => $page ];
327  }
328 
329  $renderLang = $this->getLanguageForRendering( $request, $this->displayImg );
330  if ( !is_null( $renderLang ) ) {
331  $params['lang'] = $renderLang;
332  }
333 
334  $width_orig = $this->displayImg->getWidth( $page );
335  $width = $width_orig;
336  $height_orig = $this->displayImg->getHeight( $page );
337  $height = $height_orig;
338 
339  $filename = wfEscapeWikiText( $this->displayImg->getName() );
340  $linktext = $filename;
341 
342  // Avoid PHP 7.1 warning from passing $this by reference
343  $imagePage = $this;
344 
345  Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$imagePage, &$out ] );
346 
347  if ( $this->displayImg->allowInlineDisplay() ) {
348  # image
349  # "Download high res version" link below the image
350  # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
351  # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
352  # We'll show a thumbnail of this image
353  if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
354  list( $width, $height ) = $this->getDisplayWidthHeight(
355  $maxWidth, $maxHeight, $width, $height
356  );
357  $linktext = $this->getContext()->msg( 'show-big-image' )->escaped();
358 
359  $thumbSizes = $this->getThumbSizes( $width_orig, $height_orig );
360  # Generate thumbnails or thumbnail links as needed...
361  $otherSizes = [];
362  foreach ( $thumbSizes as $size ) {
363  // We include a thumbnail size in the list, if it is
364  // less than or equal to the original size of the image
365  // asset ($width_orig/$height_orig). We also exclude
366  // the current thumbnail's size ($width/$height)
367  // since that is added to the message separately, so
368  // it can be denoted as the current size being shown.
369  // Vectorized images are limited by $wgSVGMaxSize big,
370  // so all thumbs less than or equal that are shown.
371  if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
372  || ( $this->displayImg->isVectorized()
373  && max( $size[0], $size[1] ) <= $wgSVGMaxSize )
374  )
375  && $size[0] != $width && $size[1] != $height
376  ) {
377  $sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
378  if ( $sizeLink ) {
379  $otherSizes[] = $sizeLink;
380  }
381  }
382  }
383  $otherSizes = array_unique( $otherSizes );
384 
385  $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height );
386  $msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview );
387  if ( count( $otherSizes ) ) {
388  $msgsmall .= ' ' .
390  'span',
391  [ 'class' => 'mw-filepage-other-resolutions' ],
392  $this->getContext()->msg( 'show-big-image-other' )
393  ->rawParams( $lang->pipeList( $otherSizes ) )
394  ->params( count( $otherSizes ) )
395  ->parse()
396  );
397  }
398  } elseif ( $width == 0 && $height == 0 ) {
399  # Some sort of audio file that doesn't have dimensions
400  # Don't output a no hi res message for such a file
401  $msgsmall = '';
402  } else {
403  # Image is small enough to show full size on image page
404  $msgsmall = $this->getContext()->msg( 'file-nohires' )->parse();
405  }
406 
407  $params['width'] = $width;
408  $params['height'] = $height;
409  $thumbnail = $this->displayImg->transform( $params );
410  Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params );
411 
412  $anchorclose = Html::rawElement(
413  'div',
414  [ 'class' => 'mw-filepage-resolutioninfo' ],
415  $msgsmall
416  );
417 
418  $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
419  if ( $isMulti ) {
420  $out->addModules( 'mediawiki.page.image.pagination' );
421  $out->addHTML( '<table class="multipageimage"><tr><td>' );
422  }
423 
424  if ( $thumbnail ) {
425  $options = [
426  'alt' => $this->displayImg->getTitle()->getPrefixedText(),
427  'file-link' => true,
428  ];
429  $out->addHTML( '<div class="fullImageLink" id="file">' .
430  $thumbnail->toHtml( $options ) .
431  $anchorclose . "</div>\n" );
432  }
433 
434  if ( $isMulti ) {
435  $count = $this->displayImg->pageCount();
436 
437  if ( $page > 1 ) {
438  $label = $this->getContext()->msg( 'imgmultipageprev' )->text();
439  // on the client side, this link is generated in ajaxifyPageNavigation()
440  // in the mediawiki.page.image.pagination module
442  $this->getTitle(),
443  $label,
444  [],
445  [ 'page' => $page - 1 ]
446  );
447  $thumb1 = Linker::makeThumbLinkObj(
448  $this->getTitle(),
449  $this->displayImg,
450  $link,
451  $label,
452  'none',
453  [ 'page' => $page - 1 ]
454  );
455  } else {
456  $thumb1 = '';
457  }
458 
459  if ( $page < $count ) {
460  $label = $this->getContext()->msg( 'imgmultipagenext' )->text();
462  $this->getTitle(),
463  $label,
464  [],
465  [ 'page' => $page + 1 ]
466  );
467  $thumb2 = Linker::makeThumbLinkObj(
468  $this->getTitle(),
469  $this->displayImg,
470  $link,
471  $label,
472  'none',
473  [ 'page' => $page + 1 ]
474  );
475  } else {
476  $thumb2 = '';
477  }
478 
480 
481  $formParams = [
482  'name' => 'pageselector',
483  'action' => $wgScript,
484  ];
485  $options = [];
486  for ( $i = 1; $i <= $count; $i++ ) {
487  $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
488  }
489  $select = Xml::tags( 'select',
490  [ 'id' => 'pageselector', 'name' => 'page' ],
491  implode( "\n", $options ) );
492 
493  $out->addHTML(
494  '</td><td><div class="multipageimagenavbox">' .
495  Xml::openElement( 'form', $formParams ) .
496  Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
497  $this->getContext()->msg( 'imgmultigoto' )->rawParams( $select )->parse() .
498  $this->getContext()->msg( 'word-separator' )->escaped() .
499  Xml::submitButton( $this->getContext()->msg( 'imgmultigo' )->text() ) .
500  Xml::closeElement( 'form' ) .
501  "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
502  );
503  }
504  } elseif ( $this->displayImg->isSafeFile() ) {
505  # if direct link is allowed but it's not a renderable image, show an icon.
506  $icon = $this->displayImg->iconThumb();
507 
508  $out->addHTML( '<div class="fullImageLink" id="file">' .
509  $icon->toHtml( [ 'file-link' => true ] ) .
510  "</div>\n" );
511  }
512 
513  $longDesc = $this->getContext()->msg( 'parentheses', $this->displayImg->getLongDesc() )->text();
514 
515  $handler = $this->displayImg->getHandler();
516 
517  // If this is a filetype with potential issues, warn the user.
518  if ( $handler ) {
519  $warningConfig = $handler->getWarningConfig( $this->displayImg );
520 
521  if ( $warningConfig !== null ) {
522  // The warning will be displayed via CSS and JavaScript.
523  // We just need to tell the client side what message to use.
524  $output = $this->getContext()->getOutput();
525  $output->addJsConfigVars( 'wgFileWarning', $warningConfig );
526  $output->addModules( $warningConfig['module'] );
527  $output->addModules( 'mediawiki.filewarning' );
528  }
529  }
530 
531  $medialink = "[[Media:$filename|$linktext]]";
532 
533  if ( !$this->displayImg->isSafeFile() ) {
534  $warning = $this->getContext()->msg( 'mediawarning' )->plain();
535  // dirmark is needed here to separate the file name, which
536  // most likely ends in Latin characters, from the description,
537  // which may begin with the file type. In RTL environment
538  // this will get messy.
539  // The dirmark, however, must not be immediately adjacent
540  // to the filename, because it can get copied with it.
541  // See T27277.
542  // phpcs:disable Generic.Files.LineLength
543  $out->addWikiText( <<<EOT
544 <div class="fullMedia"><span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span></div>
545 <div class="mediaWarning">$warning</div>
546 EOT
547  );
548  // phpcs:enable
549  } else {
550  $out->addWikiText( <<<EOT
551 <div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
552 </div>
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->addWikiText( <<<EOT
576 <div class="mw-noanimatethumb">{$noAnimMesg}</div>
577 EOT
578  );
579  }
580 
581  if ( !$this->displayImg->isLocal() ) {
582  $this->printSharedImageText();
583  }
584  } else {
585  # Image does not exist
586  if ( !$this->getId() ) {
587  $dbr = wfGetDB( DB_REPLICA );
588 
589  # No article exists either
590  # Show deletion log to be consistent with normal articles
592  $out,
593  [ 'delete', 'move', 'protect' ],
594  $this->getTitle()->getPrefixedText(),
595  '',
596  [ 'lim' => 10,
597  'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
598  'showIfEmpty' => false,
599  'msgKey' => [ 'moveddeleted-notice' ]
600  ]
601  );
602  }
603 
604  if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
605  // Only show an upload link if the user can upload
606  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
607  $nofile = [
608  'filepage-nofile-link',
609  $uploadTitle->getFullURL( [ 'wpDestFile' => $this->mPage->getFile()->getName() ] )
610  ];
611  } else {
612  $nofile = 'filepage-nofile';
613  }
614  // Note, if there is an image description page, but
615  // no image, then this setRobotPolicy is overridden
616  // by Article::View().
617  $out->setRobotPolicy( 'noindex,nofollow' );
618  $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
619  if ( !$this->getId() && $wgSend404Code ) {
620  // If there is no image, no shared image, and no description page,
621  // output a 404, to be consistent with Article::showMissingArticle.
622  $request->response()->statusHeader( 404 );
623  }
624  }
625  $out->setFileVersion( $this->displayImg );
626  }
627 
635  protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) {
636  if ( $sizeLinkBigImagePreview ) {
637  // Show a different message of preview is different format from original.
638  $previewTypeDiffers = false;
639  $origExt = $thumbExt = $this->displayImg->getExtension();
640  if ( $this->displayImg->getHandler() ) {
641  $origMime = $this->displayImg->getMimeType();
642  $typeParams = $params;
643  $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
644  list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
645  $origExt, $origMime, $typeParams );
646  if ( $thumbMime !== $origMime ) {
647  $previewTypeDiffers = true;
648  }
649  }
650  if ( $previewTypeDiffers ) {
651  return $this->getContext()->msg( 'show-big-image-preview-differ' )->
652  rawParams( $sizeLinkBigImagePreview )->
653  params( strtoupper( $origExt ) )->
654  params( strtoupper( $thumbExt ) )->
655  parse();
656  } else {
657  return $this->getContext()->msg( 'show-big-image-preview' )->
658  rawParams( $sizeLinkBigImagePreview )->
659  parse();
660  }
661  } else {
662  return '';
663  }
664  }
665 
673  protected function makeSizeLink( $params, $width, $height ) {
674  $params['width'] = $width;
675  $params['height'] = $height;
676  $thumbnail = $this->displayImg->transform( $params );
677  if ( $thumbnail && !$thumbnail->isError() ) {
678  return Html::rawElement( 'a', [
679  'href' => $thumbnail->getUrl(),
680  'class' => 'mw-thumbnail-link'
681  ], $this->getContext()->msg( 'show-big-image-size' )->numParams(
682  $thumbnail->getWidth(), $thumbnail->getHeight()
683  )->parse() );
684  } else {
685  return '';
686  }
687  }
688 
692  protected function printSharedImageText() {
693  $out = $this->getContext()->getOutput();
694  $this->loadFile();
695 
696  $descUrl = $this->mPage->getFile()->getDescriptionUrl();
697  $descText = $this->mPage->getFile()->getDescriptionText( $this->getContext()->getLanguage() );
698 
699  /* Add canonical to head if there is no local page for this shared file */
700  if ( $descUrl && $this->mPage->getId() == 0 ) {
701  $out->setCanonicalUrl( $descUrl );
702  }
703 
704  $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
705  $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
706 
707  if ( $descUrl &&
708  $descText &&
709  $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-'
710  ) {
711  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-here', $repo, $descUrl ] );
712  } elseif ( $descUrl &&
713  $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-'
714  ) {
715  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-there', $repo, $descUrl ] );
716  } else {
717  $out->wrapWikiMsg( $wrap, [ 'sharedupload', $repo ], ''/*BACKCOMPAT*/ );
718  }
719 
720  if ( $descText ) {
721  $this->mExtraDescription = $descText;
722  }
723  }
724 
725  public function getUploadUrl() {
726  $this->loadFile();
727  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
728  return $uploadTitle->getFullURL( [
729  'wpDestFile' => $this->mPage->getFile()->getName(),
730  'wpForReUpload' => 1
731  ] );
732  }
733 
738  protected function uploadLinksBox() {
740 
741  if ( !$wgEnableUploads ) {
742  return;
743  }
744 
745  $this->loadFile();
746  if ( !$this->mPage->getFile()->isLocal() ) {
747  return;
748  }
749 
750  $out = $this->getContext()->getOutput();
751  $out->addHTML( "<ul>\n" );
752 
753  # "Upload a new version of this file" link
754  $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
755  if ( $canUpload && UploadBase::userCanReUpload(
756  $this->getContext()->getUser(),
757  $this->mPage->getFile() )
758  ) {
759  $ulink = Linker::makeExternalLink(
760  $this->getUploadUrl(),
761  $this->getContext()->msg( 'uploadnewversion-linktext' )->text()
762  );
763  $out->addHTML( "<li id=\"mw-imagepage-reupload-link\">"
764  . "<div class=\"plainlinks\">{$ulink}</div></li>\n" );
765  } else {
766  $out->addHTML( "<li id=\"mw-imagepage-upload-disallowed\">"
767  . $this->getContext()->msg( 'upload-disallowed-here' )->escaped() . "</li>\n" );
768  }
769 
770  $out->addHTML( "</ul>\n" );
771  }
772 
776  protected function closeShowImage() {
777  }
778 
783  protected function imageHistory() {
784  $this->loadFile();
785  $out = $this->getContext()->getOutput();
786  $pager = new ImageHistoryPseudoPager( $this );
787  $out->addHTML( $pager->getBody() );
788  $out->preventClickjacking( $pager->getPreventClickjacking() );
789 
790  $this->mPage->getFile()->resetHistory(); // free db resources
791 
792  # Exist check because we don't want to show this on pages where an image
793  # doesn't exist along with the noimage message, that would suck. -√¶var
794  if ( $this->mPage->getFile()->exists() ) {
795  $this->uploadLinksBox();
796  }
797  }
798 
804  protected function queryImageLinks( $target, $limit ) {
805  $dbr = wfGetDB( DB_REPLICA );
806 
807  return $dbr->select(
808  [ 'imagelinks', 'page' ],
809  [ 'page_namespace', 'page_title', 'il_to' ],
810  [ 'il_to' => $target, 'il_from = page_id' ],
811  __METHOD__,
812  [ 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', ]
813  );
814  }
815 
816  protected function imageLinks() {
817  $limit = 100;
818 
819  $out = $this->getContext()->getOutput();
820 
821  $rows = [];
822  $redirects = [];
823  foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) {
824  $redirects[$redir->getDBkey()] = [];
825  $rows[] = (object)[
826  'page_namespace' => NS_FILE,
827  'page_title' => $redir->getDBkey(),
828  ];
829  }
830 
831  $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
832  foreach ( $res as $row ) {
833  $rows[] = $row;
834  }
835  $count = count( $rows );
836 
837  $hasMore = $count > $limit;
838  if ( !$hasMore && count( $redirects ) ) {
839  $res = $this->queryImageLinks( array_keys( $redirects ),
840  $limit - count( $rows ) + 1 );
841  foreach ( $res as $row ) {
842  $redirects[$row->il_to][] = $row;
843  $count++;
844  }
845  $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
846  }
847 
848  if ( $count == 0 ) {
849  $out->wrapWikiMsg(
850  Html::rawElement( 'div',
851  [ 'id' => 'mw-imagepage-nolinkstoimage' ], "\n$1\n" ),
852  'nolinkstoimage'
853  );
854  return;
855  }
856 
857  $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
858  if ( !$hasMore ) {
859  $out->addWikiMsg( 'linkstoimage', $count );
860  } else {
861  // More links than the limit. Add a link to [[Special:Whatlinkshere]]
862  $out->addWikiMsg( 'linkstoimage-more',
863  $this->getContext()->getLanguage()->formatNum( $limit ),
864  $this->getTitle()->getPrefixedDBkey()
865  );
866  }
867 
868  $out->addHTML(
869  Html::openElement( 'ul',
870  [ 'class' => 'mw-imagepage-linkstoimage' ] ) . "\n"
871  );
872  $count = 0;
873 
874  // Sort the list by namespace:title
875  usort( $rows, [ $this, 'compare' ] );
876 
877  // Create links for every element
878  $currentCount = 0;
879  foreach ( $rows as $element ) {
880  $currentCount++;
881  if ( $currentCount > $limit ) {
882  break;
883  }
884 
885  $query = [];
886  # Add a redirect=no to make redirect pages reachable
887  if ( isset( $redirects[$element->page_title] ) ) {
888  $query['redirect'] = 'no';
889  }
891  Title::makeTitle( $element->page_namespace, $element->page_title ),
892  null, [], $query
893  );
894  if ( !isset( $redirects[$element->page_title] ) ) {
895  # No redirects
896  $liContents = $link;
897  } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
898  # Redirect without usages
899  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )
900  ->rawParams( $link, '' )
901  ->parse();
902  } else {
903  # Redirect with usages
904  $li = '';
905  foreach ( $redirects[$element->page_title] as $row ) {
906  $currentCount++;
907  if ( $currentCount > $limit ) {
908  break;
909  }
910 
911  $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
912  $li .= Html::rawElement(
913  'li',
914  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
915  $link2
916  ) . "\n";
917  }
918 
920  'ul',
921  [ 'class' => 'mw-imagepage-redirectstofile' ],
922  $li
923  ) . "\n";
924  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams(
925  $link, $ul )->parse();
926  }
927  $out->addHTML( Html::rawElement(
928  'li',
929  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
930  $liContents
931  ) . "\n"
932  );
933 
934  };
935  $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
936  $res->free();
937 
938  // Add a links to [[Special:Whatlinkshere]]
939  if ( $count > $limit ) {
940  $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
941  }
942  $out->addHTML( Html::closeElement( 'div' ) . "\n" );
943  }
944 
945  protected function imageDupes() {
946  $this->loadFile();
947  $out = $this->getContext()->getOutput();
948 
949  $dupes = $this->mPage->getDuplicates();
950  if ( count( $dupes ) == 0 ) {
951  return;
952  }
953 
954  $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
955  $out->addWikiMsg( 'duplicatesoffile',
956  $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
957  );
958  $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
959 
963  foreach ( $dupes as $file ) {
964  $fromSrc = '';
965  if ( $file->isLocal() ) {
966  $link = Linker::linkKnown( $file->getTitle() );
967  } else {
968  $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
969  $file->getTitle()->getPrefixedText() );
970  $fromSrc = $this->getContext()->msg(
971  'shared-repo-from',
972  $file->getRepo()->getDisplayName()
973  )->escaped();
974  }
975  $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
976  }
977  $out->addHTML( "</ul></div>\n" );
978  }
979 
983  public function delete() {
984  $file = $this->mPage->getFile();
985  if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
986  // Standard article deletion
987  parent::delete();
988  return;
989  }
990 
991  $deleter = new FileDeleteForm( $file );
992  $deleter->execute();
993  }
994 
1000  function showError( $description ) {
1001  $out = $this->getContext()->getOutput();
1002  $out->setPageTitle( $this->getContext()->msg( 'internalerror' ) );
1003  $out->setRobotPolicy( 'noindex,nofollow' );
1004  $out->setArticleRelated( false );
1005  $out->enableClientCache( false );
1006  $out->addWikiText( $description );
1007  }
1008 
1017  protected function compare( $a, $b ) {
1018  if ( $a->page_namespace == $b->page_namespace ) {
1019  return strcmp( $a->page_title, $b->page_title );
1020  } else {
1021  return $a->page_namespace - $b->page_namespace;
1022  }
1023  }
1024 
1033  public function getImageLimitsFromOption( $user, $optionName ) {
1035 
1036  $option = $user->getIntOption( $optionName );
1037  if ( !isset( $wgImageLimits[$option] ) ) {
1038  $option = User::getDefaultOption( $optionName );
1039  }
1040 
1041  // The user offset might still be incorrect, specially if
1042  // $wgImageLimits got changed (see bug #8858).
1043  if ( !isset( $wgImageLimits[$option] ) ) {
1044  // Default to the first offset in $wgImageLimits
1045  $option = 0;
1046  }
1047 
1048  return isset( $wgImageLimits[$option] )
1049  ? $wgImageLimits[$option]
1050  : [ 800, 600 ]; // if nothing is set, fallback to a hardcoded default
1051  }
1052 
1060  protected function doRenderLangOpt( array $langChoices, $renderLang ) {
1061  global $wgScript;
1062  $opts = '';
1063 
1064  $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
1065 
1066  foreach ( $langChoices as $lang ) {
1067  $opts .= $this->createXmlOptionStringForLanguage(
1068  $lang,
1069  $matchedRenderLang === $lang
1070  );
1071  }
1072 
1073  // Allow for the default case in an svg <switch> that is displayed if no
1074  // systemLanguage attribute matches
1075  $opts .= "\n" .
1076  Xml::option(
1077  $this->getContext()->msg( 'img-lang-default' )->text(),
1078  'und',
1079  is_null( $matchedRenderLang )
1080  );
1081 
1082  $select = Html::rawElement(
1083  'select',
1084  [ 'id' => 'mw-imglangselector', 'name' => 'lang' ],
1085  $opts
1086  );
1087  $submit = Xml::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() );
1088 
1089  $formContents = $this->getContext()->msg( 'img-lang-info' )
1090  ->rawParams( $select, $submit )
1091  ->parse();
1092  $formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
1093 
1094  $langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ],
1095  Html::rawElement( 'form', [ 'action' => $wgScript ], $formContents )
1096  );
1097  return $langSelectLine;
1098  }
1099 
1105  private function createXmlOptionStringForLanguage( $lang, $selected ) {
1107  $name = Language::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
1108  if ( $name !== '' ) {
1109  $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
1110  } else {
1111  $display = $code;
1112  }
1113  return "\n" .
1114  Xml::option(
1115  $display,
1116  $lang,
1117  $selected
1118  );
1119  }
1120 
1135  protected function getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height ) {
1136  if ( !$maxWidth || !$maxHeight ) {
1137  // should never happen
1138  throw new MWException( 'Using a choice from $wgImageLimits that is 0x0' );
1139  }
1140 
1141  if ( !$width || !$height ) {
1142  return [ 0, 0 ];
1143  }
1144 
1145  # Calculate the thumbnail size.
1146  if ( $width <= $maxWidth && $height <= $maxHeight ) {
1147  // Vectorized image, do nothing.
1148  } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1149  # The limiting factor is the width, not the height.
1150  $height = round( $height * $maxWidth / $width );
1151  $width = $maxWidth;
1152  # Note that $height <= $maxHeight now.
1153  } else {
1154  $newwidth = floor( $width * $maxHeight / $height );
1155  $height = round( $height * $newwidth / $width );
1156  $width = $newwidth;
1157  # Note that $height <= $maxHeight now, but might not be identical
1158  # because of rounding.
1159  }
1160  return [ $width, $height ];
1161  }
1162 
1171  protected function getThumbSizes( $origWidth, $origHeight ) {
1173  if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1174  $thumbSizes = $wgImageLimits;
1175  // Also include the full sized resolution in the list, so
1176  // that users know they can get it. This will link to the
1177  // original file asset if mustRender() === false. In the case
1178  // that we mustRender, some users have indicated that they would
1179  // find it useful to have the full size image in the rendered
1180  // image format.
1181  $thumbSizes[] = [ $origWidth, $origHeight ];
1182  } else {
1183  # Creating thumb links triggers thumbnail generation.
1184  # Just generate the thumb for the current users prefs.
1185  $thumbSizes = [
1186  $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' )
1187  ];
1188  if ( !$this->displayImg->mustRender() ) {
1189  // We can safely include a link to the "full-size" preview,
1190  // without actually rendering.
1191  $thumbSizes[] = [ $origWidth, $origHeight ];
1192  }
1193  }
1194  return $thumbSizes;
1195  }
1196 
1201  public function getFile() {
1202  return $this->mPage->getFile();
1203  }
1204 
1209  public function isLocal() {
1210  return $this->mPage->isLocal();
1211  }
1212 
1217  public function getDuplicates() {
1218  return $this->mPage->getDuplicates();
1219  }
1220 
1225  public function getForeignCategories() {
1226  $this->mPage->getForeignCategories();
1227  }
1228 
1229 }
static closeElement($element)
Returns "".
Definition: Html.php:309
$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:2636
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:2019
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
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
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:790
static processResponsiveImages($file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
Definition: Linker.php:655
bool $fileLoaded
Definition: ImagePage.php:38
the array() calling protocol came about after MediaWiki 1.4rc1.
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:1623
either a plain
Definition: hooks.txt:2080
$wgScript
The URL path to index.php.
static element($element, $attribs=null, $contents= '', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
queryImageLinks($target, $limit)
Definition: ImagePage.php:804
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
static getTitleFor($name, $subpage=false, $fragment= '')
Get a localised Title object for a specified special page name If you don't need a full Title object...
Definition: SpecialPage.php:82
showTOC($metadata)
Create the TOC.
Definition: ImagePage.php:225
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
Definition: Html.php:209
if(!isset($args[0])) $lang
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title after the basic globals have been set but before ordinary actions take place $output
Definition: hooks.txt:2252
static hidden($name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:790
getUploadUrl()
Definition: ImagePage.php:725
Class for viewing MediaWiki article and history.
Definition: Article.php:35
Class for viewing MediaWiki file description pages.
Definition: ImagePage.php:30
FileRepo $repo
Definition: ImagePage.php:35
wfMessageFallback()
This function accepts multiple message keys and returns a message instance for the first message whic...
getLanguageForRendering(WebRequest $request, File $file)
Definition: ImagePage.php:289
when a variable name is used in a it is silently declared as a new local masking the global
Definition: design.txt:93
printSharedImageText()
Show a notice that the file is from a shared repository.
Definition: ImagePage.php:692
wfLocalFile($title)
Get an object referring to a locally registered file.
imageHistory()
If the page we've just displayed is in the "Image" namespace, we follow it with an upload history of ...
Definition: ImagePage.php:783
uploadLinksBox()
Print out the various links at the bottom of the image page, e.g.
Definition: ImagePage.php:738
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 For a description of the see design txt $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 submitButton($value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
Definition: Xml.php:460
static userCanReUpload(User $user, File $img)
Check if a user is the last uploader.
createXmlOptionStringForLanguage($lang, $selected)
Definition: ImagePage.php:1105
static showLogExtract(&$out, $types=[], $page= '', $user= '', $param=[])
Show log extract.
getForeignCategories()
Definition: ImagePage.php:1225
getThumbSizes($origWidth, $origHeight)
Get alternative thumbnail sizes.
Definition: ImagePage.php:1171
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3038
$wgEnableUploads
Uploads have to be specially set up to be secure.
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2023
static closeElement($element)
Shortcut to close an XML element.
Definition: Xml.php:118
showError($description)
Display an error with a wikitext description.
Definition: ImagePage.php:1000
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
Definition: Html.php:251
$wgShowEXIF
Show Exif data, on by default if available.
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
$css
$res
Definition: database.txt:21
static option($text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:485
static openElement($element, $attribs=null)
This opens an XML element.
Definition: Xml.php:109
doRenderLangOpt(array $langChoices, $renderLang)
Output a drop-down box for language options for the file.
Definition: ImagePage.php:1060
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
getTitle()
Get the title object of the article.
Definition: Article.php:181
$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:2019
File $displayImg
Definition: ImagePage.php:32
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:941
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
Definition: Linker.php:164
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
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
const NS_FILE
Definition: Defines.php:71
render()
Handler for action=render Include body text only; none of the image extras.
Definition: ImagePage.php:93
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.
compare($a, $b)
Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare() ...
Definition: ImagePage.php:1017
static fetchLanguageName($code, $inLanguage=null, $include= 'all')
Definition: Language.php:896
$wgSVGMaxSize
Don't scale a SVG larger than this.
getVal($name, $default=null)
Fetch a scalar from the input or return $default if it's not set.
Definition: WebRequest.php:441
static makeExternalLink($url, $text, $escape=true, $linktype= '', $attribs=[], $title=null)
Make an external link.
Definition: Linker.php:843
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
static tags($element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
getId()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2252
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 modifiable & $code
Definition: hooks.txt:790
static bcp47($code)
Get the normalised IETF language tag See unit test for examples.
getDisplayWidthHeight($maxWidth, $maxHeight, $width, $height)
Get the width and height to display image at.
Definition: ImagePage.php:1135
getOldID()
Definition: Article.php:249
setFile($file)
Definition: ImagePage.php:61
getDisplayName()
Get the human-readable name of the repo.
Definition: FileRepo.php:1794
newPage(Title $title)
Definition: ImagePage.php:52
bool $mExtraDescription
Definition: ImagePage.php:41
getDisplayedFile()
Definition: ImagePage.php:214
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
makeSizeLink($params, $width, $height)
Creates an thumbnail of specified size and returns an HTML link to it.
Definition: ImagePage.php:673
const DB_REPLICA
Definition: defines.php:25
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 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:790
getThumbPrevText($params, $sizeLinkBigImagePreview)
Make the text under the image to say what size preview.
Definition: ImagePage.php:635
getUser($audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2340
WikiFilePage $mPage
Definition: ImagePage.php:46
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:507
static getDefaultOption($opt)
Get a given default option value.
Definition: User.php:1756
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's output.
$ext
Definition: router.php:55
getImageLimitsFromOption($user, $optionName)
Returns the corresponding $wgImageLimits entry for the selected user option.
Definition: ImagePage.php:1033
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:2636
wfFindFile($title, $options=[])
Find a file.
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:534
makeMetadataTable($metadata)
Make a table with metadata to be shown in the output page.
Definition: ImagePage.php:251
getContentObject()
Overloading Article's getContentObject method.
Definition: ImagePage.php:281
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 local account $user
Definition: hooks.txt:244
closeShowImage()
For overloading.
Definition: ImagePage.php:776
openShowImage()
Definition: ImagePage.php:305