MediaWiki  master
ImagePage.php
Go to the documentation of this file.
1 <?php
25 
31 class ImagePage extends Article {
33  private $displayImg;
34 
36  private $repo;
37 
39  private $fileLoaded;
40 
42  protected $mExtraDescription = false;
43 
47  protected $mPage;
48 
53  protected function newPage( Title $title ) {
54  // Overload mPage with a file-specific page
55  return new WikiFilePage( $title );
56  }
57 
62  public function setFile( $file ) {
63  $this->mPage->setFile( $file );
64  $this->displayImg = $file;
65  $this->fileLoaded = true;
66  }
67 
68  protected function loadFile() {
69  if ( $this->fileLoaded ) {
70  return;
71  }
72  $this->fileLoaded = true;
73 
74  $this->displayImg = $img = false;
75 
76  Hooks::run( 'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
77  if ( !$img ) { // not set by hook?
78  $services = MediaWikiServices::getInstance();
79  $img = $services->getRepoGroup()->findFile( $this->getTitle() );
80  if ( !$img ) {
81  $img = $services->getRepoGroup()->getLocalRepo()->newFile( $this->getTitle() );
82  }
83  }
84  $this->mPage->setFile( $img );
85  if ( !$this->displayImg ) { // not set by hook?
86  $this->displayImg = $img;
87  }
88  $this->repo = $img->getRepo();
89  }
90 
91  public function view() {
92  global $wgShowEXIF;
93 
94  // For action=render, include body text only; none of the image extras
95  if ( $this->viewIsRenderAction ) {
96  parent::view();
97  return;
98  }
99 
100  $out = $this->getContext()->getOutput();
101  $request = $this->getContext()->getRequest();
102  $diff = $request->getVal( 'diff' );
103  $diffOnly = $request->getBool(
104  'diffonly',
105  $this->getContext()->getUser()->getOption( 'diffonly' )
106  );
107 
108  if ( $this->getTitle()->getNamespace() != NS_FILE || ( $diff !== null && $diffOnly ) ) {
109  parent::view();
110  return;
111  }
112 
113  $this->loadFile();
114 
115  if ( $this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected() ) {
116  if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null ) {
117  $request->setVal( 'diffonly', 'true' );
118  }
119 
120  parent::view();
121  return;
122  }
123 
124  if ( $wgShowEXIF && $this->displayImg->exists() ) {
125  // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
126  $formattedMetadata = $this->displayImg->formatMetadata( $this->getContext() );
127  $showmeta = $formattedMetadata !== false;
128  } else {
129  $showmeta = false;
130  }
131 
132  if ( !$diff && $this->displayImg->exists() ) {
133  $out->addHTML( $this->showTOC( $showmeta ) );
134  }
135 
136  if ( !$diff ) {
137  $this->openShowImage();
138  }
139 
140  # No need to display noarticletext, we use our own message, output in openShowImage()
141  if ( $this->mPage->getId() ) {
142  # NS_FILE is in the user language, but this section (the actual wikitext)
143  # should be in page content language
144  $pageLang = $this->getTitle()->getPageViewLanguage();
145  $out->addHTML( Xml::openElement( 'div', [ 'id' => 'mw-imagepage-content',
146  'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
147  'class' => 'mw-content-' . $pageLang->getDir() ] ) );
148 
149  parent::view();
150 
151  $out->addHTML( Xml::closeElement( 'div' ) );
152  } else {
153  # Just need to set the right headers
154  $out->setArticleFlag( true );
155  $out->setPageTitle( $this->getTitle()->getPrefixedText() );
156  $this->mPage->doViewUpdates( $this->getContext()->getUser(), $this->getOldID() );
157  }
158 
159  # Show shared description, if needed
160  if ( $this->mExtraDescription ) {
161  $fol = $this->getContext()->msg( 'shareddescriptionfollows' );
162  if ( !$fol->isDisabled() ) {
163  $out->addWikiTextAsInterface( $fol->plain() );
164  }
165  $out->addHTML( '<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n" );
166  }
167 
168  $this->closeShowImage();
169  $this->imageHistory();
170  // TODO: Cleanup the following
171 
172  $out->addHTML( Xml::element( 'h2',
173  [ 'id' => 'filelinks' ],
174  $this->getContext()->msg( 'imagelinks' )->text() ) . "\n" );
175  $this->imageDupes();
176  # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
177  # Yet we return metadata about the target. Definitely an issue in the FileRepo
178  $this->imageLinks();
179 
180  # Allow extensions to add something after the image links
181  $html = '';
182  Hooks::run( 'ImagePageAfterImageLinks', [ $this, &$html ] );
183  if ( $html ) {
184  $out->addHTML( $html );
185  }
186 
187  if ( $showmeta ) {
188  $out->addHTML( Xml::element(
189  'h2',
190  [ 'id' => 'metadata' ],
191  $this->getContext()->msg( 'metadata' )->text() ) . "\n" );
192  $out->wrapWikiTextAsInterface(
193  'mw-imagepage-section-metadata',
194  $this->makeMetadataTable( $formattedMetadata )
195  );
196  $out->addModules( [ 'mediawiki.action.view.metadata' ] );
197  }
198 
199  // Add remote Filepage.css
200  if ( !$this->repo->isLocal() ) {
201  $css = $this->repo->getDescriptionStylesheetUrl();
202  if ( $css ) {
203  $out->addStyle( $css );
204  }
205  }
206 
207  $out->addModuleStyles( [
208  'filepage', // always show the local local Filepage.css, T31277
209  'mediawiki.action.view.filepage', // Add MediaWiki styles for a file page
210  ] );
211  }
212 
216  public function getDisplayedFile() {
217  $this->loadFile();
218  return $this->displayImg;
219  }
220 
227  protected function showTOC( $metadata ) {
228  $r = [
229  '<li><a href="#file">' . $this->getContext()->msg( 'file-anchor-link' )->escaped() . '</a></li>',
230  '<li><a href="#filehistory">' . $this->getContext()->msg( 'filehist' )->escaped() . '</a></li>',
231  '<li><a href="#filelinks">' . $this->getContext()->msg( 'imagelinks' )->escaped() . '</a></li>',
232  ];
233 
234  Hooks::run( 'ImagePageShowTOC', [ $this, &$r ] );
235 
236  if ( $metadata ) {
237  $r[] = '<li><a href="#metadata">' .
238  $this->getContext()->msg( 'metadata' )->escaped() .
239  '</a></li>';
240  }
241 
242  return '<ul id="filetoc">' . implode( "\n", $r ) . '</ul>';
243  }
244 
253  protected function makeMetadataTable( $metadata ) {
254  $r = $this->getContext()->msg( 'metadata-help' )->plain();
255  // Intial state is collapsed
256  // see filepage.css and mediawiki.action.view.metadata module.
257  $r .= "<table id=\"mw_metadata\" class=\"mw_metadata collapsed\">\n";
258  foreach ( $metadata as $type => $stuff ) {
259  foreach ( $stuff as $v ) {
260  $class = str_replace( ' ', '_', $v['id'] );
261  if ( $type == 'collapsed' ) {
262  $class .= ' mw-metadata-collapsible';
263  }
264  $r .= Html::rawElement( 'tr',
265  [ 'class' => $class ],
266  Html::rawElement( 'th', [], $v['name'] )
267  . Html::rawElement( 'td', [], $v['value'] )
268  );
269  }
270  }
271  $r .= "</table>\n";
272  return $r;
273  }
274 
285  $this->loadFile();
286  if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && $this->getId() == 0 ) {
287  return new ParserOutput();
288  }
289  return parent::getEmptyPageParserOutput( $options );
290  }
291 
301  $handler = $file->getHandler();
302  if ( !$handler ) {
303  return null;
304  }
305 
306  $config = MediaWikiServices::getInstance()->getMainConfig();
307  $requestLanguage = $request->getVal( 'lang', $config->get( 'LanguageCode' ) );
308  if ( $handler->validateParam( 'lang', $requestLanguage ) ) {
309  return $file->getMatchedLanguage( $requestLanguage );
310  }
311 
312  return $handler->getDefaultRenderLanguage( $file );
313  }
314 
315  protected function openShowImage() {
317 
318  $this->loadFile();
319  $out = $this->getContext()->getOutput();
320  $user = $this->getContext()->getUser();
321  $lang = $this->getContext()->getLanguage();
322  $dirmark = $lang->getDirMarkEntity();
323  $request = $this->getContext()->getRequest();
324 
325  list( $maxWidth, $maxHeight ) = $this->getImageLimitsFromOption( $user, 'imagesize' );
326 
327  if ( $this->displayImg->exists() ) {
328  # image
329  $page = $request->getIntOrNull( 'page' );
330  if ( is_null( $page ) ) {
331  $params = [];
332  $page = 1;
333  } else {
334  $params = [ 'page' => $page ];
335  }
336 
337  $renderLang = $this->getLanguageForRendering( $request, $this->displayImg );
338  if ( !is_null( $renderLang ) ) {
339  $params['lang'] = $renderLang;
340  }
341 
342  $width_orig = $this->displayImg->getWidth( $page );
343  $width = $width_orig;
344  $height_orig = $this->displayImg->getHeight( $page );
345  $height = $height_orig;
346 
347  $filename = wfEscapeWikiText( $this->displayImg->getName() );
348  $linktext = $filename;
349 
350  // Avoid PHP 7.1 warning from passing $this by reference
351  $imagePage = $this;
352 
353  Hooks::run( 'ImageOpenShowImageInlineBefore', [ &$imagePage, &$out ] );
354 
355  if ( $this->displayImg->allowInlineDisplay() ) {
356  # image
357  # "Download high res version" link below the image
358  # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
359  # Language::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
360  # We'll show a thumbnail of this image
361  if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
362  list( $width, $height ) = $this->getDisplayWidthHeight(
363  $maxWidth, $maxHeight, $width, $height
364  );
365  $linktext = $this->getContext()->msg( 'show-big-image' )->escaped();
366 
367  $thumbSizes = $this->getThumbSizes( $width_orig, $height_orig );
368  # Generate thumbnails or thumbnail links as needed...
369  $otherSizes = [];
370  foreach ( $thumbSizes as $size ) {
371  // We include a thumbnail size in the list, if it is
372  // less than or equal to the original size of the image
373  // asset ($width_orig/$height_orig). We also exclude
374  // the current thumbnail's size ($width/$height)
375  // since that is added to the message separately, so
376  // it can be denoted as the current size being shown.
377  // Vectorized images are limited by $wgSVGMaxSize big,
378  // so all thumbs less than or equal that are shown.
379  if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
380  || ( $this->displayImg->isVectorized()
381  && max( $size[0], $size[1] ) <= $wgSVGMaxSize )
382  )
383  && $size[0] != $width && $size[1] != $height
384  ) {
385  $sizeLink = $this->makeSizeLink( $params, $size[0], $size[1] );
386  if ( $sizeLink ) {
387  $otherSizes[] = $sizeLink;
388  }
389  }
390  }
391  $otherSizes = array_unique( $otherSizes );
392 
393  $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height );
394  $msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview );
395  if ( count( $otherSizes ) ) {
396  $msgsmall .= ' ' .
398  'span',
399  [ 'class' => 'mw-filepage-other-resolutions' ],
400  $this->getContext()->msg( 'show-big-image-other' )
401  ->rawParams( $lang->pipeList( $otherSizes ) )
402  ->params( count( $otherSizes ) )
403  ->parse()
404  );
405  }
406  } elseif ( $width == 0 && $height == 0 ) {
407  # Some sort of audio file that doesn't have dimensions
408  # Don't output a no hi res message for such a file
409  $msgsmall = '';
410  } else {
411  # Image is small enough to show full size on image page
412  $msgsmall = $this->getContext()->msg( 'file-nohires' )->parse();
413  }
414 
415  $params['width'] = $width;
416  $params['height'] = $height;
417  $thumbnail = $this->displayImg->transform( $params );
418  Linker::processResponsiveImages( $this->displayImg, $thumbnail, $params );
419 
420  $anchorclose = Html::rawElement(
421  'div',
422  [ 'class' => 'mw-filepage-resolutioninfo' ],
423  $msgsmall
424  );
425 
426  $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
427  if ( $isMulti ) {
428  $out->addModules( 'mediawiki.page.image.pagination' );
429  $out->addHTML( '<table class="multipageimage"><tr><td>' );
430  }
431 
432  if ( $thumbnail ) {
433  $options = [
434  'alt' => $this->displayImg->getTitle()->getPrefixedText(),
435  'file-link' => true,
436  ];
437  $out->addHTML( '<div class="fullImageLink" id="file">' .
438  $thumbnail->toHtml( $options ) .
439  $anchorclose . "</div>\n" );
440  }
441 
442  if ( $isMulti ) {
443  $count = $this->displayImg->pageCount();
444 
445  if ( $page > 1 ) {
446  $label = $this->getContext()->msg( 'imgmultipageprev' )->text();
447  // on the client side, this link is generated in ajaxifyPageNavigation()
448  // in the mediawiki.page.image.pagination module
450  $this->getTitle(),
451  htmlspecialchars( $label ),
452  [],
453  [ 'page' => $page - 1 ]
454  );
455  $thumb1 = Linker::makeThumbLinkObj(
456  $this->getTitle(),
457  $this->displayImg,
458  $link,
459  $label,
460  'none',
461  [ 'page' => $page - 1 ]
462  );
463  } else {
464  $thumb1 = '';
465  }
466 
467  if ( $page < $count ) {
468  $label = $this->getContext()->msg( 'imgmultipagenext' )->text();
470  $this->getTitle(),
471  htmlspecialchars( $label ),
472  [],
473  [ 'page' => $page + 1 ]
474  );
475  $thumb2 = Linker::makeThumbLinkObj(
476  $this->getTitle(),
477  $this->displayImg,
478  $link,
479  $label,
480  'none',
481  [ 'page' => $page + 1 ]
482  );
483  } else {
484  $thumb2 = '';
485  }
486 
487  global $wgScript;
488 
489  $formParams = [
490  'name' => 'pageselector',
491  'action' => $wgScript,
492  ];
493  $options = [];
494  for ( $i = 1; $i <= $count; $i++ ) {
495  $options[] = Xml::option( $lang->formatNum( $i ), $i, $i == $page );
496  }
497  $select = Xml::tags( 'select',
498  [ 'id' => 'pageselector', 'name' => 'page' ],
499  implode( "\n", $options ) );
500 
501  $out->addHTML(
502  '</td><td><div class="multipageimagenavbox">' .
503  Xml::openElement( 'form', $formParams ) .
504  Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ) .
505  $this->getContext()->msg( 'imgmultigoto' )->rawParams( $select )->parse() .
506  $this->getContext()->msg( 'word-separator' )->escaped() .
507  Xml::submitButton( $this->getContext()->msg( 'imgmultigo' )->text() ) .
508  Xml::closeElement( 'form' ) .
509  "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
510  );
511  }
512  } elseif ( $this->displayImg->isSafeFile() ) {
513  # if direct link is allowed but it's not a renderable image, show an icon.
514  $icon = $this->displayImg->iconThumb();
515 
516  $out->addHTML( '<div class="fullImageLink" id="file">' .
517  $icon->toHtml( [ 'file-link' => true ] ) .
518  "</div>\n" );
519  }
520 
521  $longDesc = $this->getContext()->msg( 'parentheses', $this->displayImg->getLongDesc() )->text();
522 
523  $handler = $this->displayImg->getHandler();
524 
525  // If this is a filetype with potential issues, warn the user.
526  if ( $handler ) {
527  $warningConfig = $handler->getWarningConfig( $this->displayImg );
528 
529  if ( $warningConfig !== null ) {
530  // The warning will be displayed via CSS and JavaScript.
531  // We just need to tell the client side what message to use.
532  $output = $this->getContext()->getOutput();
533  $output->addJsConfigVars( 'wgFileWarning', $warningConfig );
534  $output->addModules( $warningConfig['module'] );
535  $output->addModules( 'mediawiki.filewarning' );
536  }
537  }
538 
539  $medialink = "[[Media:$filename|$linktext]]";
540 
541  if ( !$this->displayImg->isSafeFile() ) {
542  $warning = $this->getContext()->msg( 'mediawarning' )->plain();
543  // dirmark is needed here to separate the file name, which
544  // most likely ends in Latin characters, from the description,
545  // which may begin with the file type. In RTL environment
546  // this will get messy.
547  // The dirmark, however, must not be immediately adjacent
548  // to the filename, because it can get copied with it.
549  // See T27277.
550  // phpcs:disable Generic.Files.LineLength
551  $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
552 <span class="dangerousLink">{$medialink}</span> $dirmark<span class="fileInfo">$longDesc</span>
553 EOT
554  );
555  // phpcs:enable
556  $out->wrapWikiTextAsInterface( 'mediaWarning', $warning );
557  } else {
558  $out->wrapWikiTextAsInterface( 'fullMedia', <<<EOT
559 {$medialink} {$dirmark}<span class="fileInfo">$longDesc</span>
560 EOT
561  );
562  }
563 
564  $renderLangOptions = $this->displayImg->getAvailableLanguages();
565  if ( count( $renderLangOptions ) >= 1 ) {
566  $out->addHTML( $this->doRenderLangOpt( $renderLangOptions, $renderLang ) );
567  }
568 
569  // Add cannot animate thumbnail warning
570  if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
571  // Include the extension so wiki admins can
572  // customize it on a per file-type basis
573  // (aka say things like use format X instead).
574  // additionally have a specific message for
575  // file-no-thumb-animation-gif
576  $ext = $this->displayImg->getExtension();
577  $noAnimMesg = wfMessageFallback(
578  'file-no-thumb-animation-' . $ext,
579  'file-no-thumb-animation'
580  )->plain();
581 
582  $out->wrapWikiTextAsInterface( 'mw-noanimatethumb', $noAnimMesg );
583  }
584 
585  if ( !$this->displayImg->isLocal() ) {
586  $this->printSharedImageText();
587  }
588  } else {
589  # Image does not exist
590  if ( !$this->getId() ) {
591  $dbr = wfGetDB( DB_REPLICA );
592 
593  # No article exists either
594  # Show deletion log to be consistent with normal articles
596  $out,
597  [ 'delete', 'move', 'protect' ],
598  $this->getTitle()->getPrefixedText(),
599  '',
600  [ 'lim' => 10,
601  'conds' => [ 'log_action != ' . $dbr->addQuotes( 'revision' ) ],
602  'showIfEmpty' => false,
603  'msgKey' => [ 'moveddeleted-notice' ]
604  ]
605  );
606  }
607 
608  if ( $wgEnableUploads && $user->isAllowed( 'upload' ) ) {
609  // Only show an upload link if the user can upload
610  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
611  $nofile = [
612  'filepage-nofile-link',
613  $uploadTitle->getFullURL( [ 'wpDestFile' => $this->mPage->getFile()->getName() ] )
614  ];
615  } else {
616  $nofile = 'filepage-nofile';
617  }
618  // Note, if there is an image description page, but
619  // no image, then this setRobotPolicy is overridden
620  // by Article::View().
621  $out->setRobotPolicy( 'noindex,nofollow' );
622  $out->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
623  if ( !$this->getId() && $wgSend404Code ) {
624  // If there is no image, no shared image, and no description page,
625  // output a 404, to be consistent with Article::showMissingArticle.
626  $request->response()->statusHeader( 404 );
627  }
628  }
629  $out->setFileVersion( $this->displayImg );
630  }
631 
639  protected function getThumbPrevText( $params, $sizeLinkBigImagePreview ) {
640  if ( $sizeLinkBigImagePreview ) {
641  // Show a different message of preview is different format from original.
642  $previewTypeDiffers = false;
643  $origExt = $thumbExt = $this->displayImg->getExtension();
644  if ( $this->displayImg->getHandler() ) {
645  $origMime = $this->displayImg->getMimeType();
646  $typeParams = $params;
647  $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
648  list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
649  $origExt, $origMime, $typeParams );
650  if ( $thumbMime !== $origMime ) {
651  $previewTypeDiffers = true;
652  }
653  }
654  if ( $previewTypeDiffers ) {
655  return $this->getContext()->msg( 'show-big-image-preview-differ' )->
656  rawParams( $sizeLinkBigImagePreview )->
657  params( strtoupper( $origExt ) )->
658  params( strtoupper( $thumbExt ) )->
659  parse();
660  } else {
661  return $this->getContext()->msg( 'show-big-image-preview' )->
662  rawParams( $sizeLinkBigImagePreview )->
663  parse();
664  }
665  } else {
666  return '';
667  }
668  }
669 
677  protected function makeSizeLink( $params, $width, $height ) {
678  $params['width'] = $width;
679  $params['height'] = $height;
680  $thumbnail = $this->displayImg->transform( $params );
681  if ( $thumbnail && !$thumbnail->isError() ) {
682  return Html::rawElement( 'a', [
683  'href' => $thumbnail->getUrl(),
684  'class' => 'mw-thumbnail-link'
685  ], $this->getContext()->msg( 'show-big-image-size' )->numParams(
686  $thumbnail->getWidth(), $thumbnail->getHeight()
687  )->parse() );
688  } else {
689  return '';
690  }
691  }
692 
696  protected function printSharedImageText() {
697  $out = $this->getContext()->getOutput();
698  $this->loadFile();
699 
700  $descUrl = $this->mPage->getFile()->getDescriptionUrl();
701  $descText = $this->mPage->getFile()->getDescriptionText( $this->getContext()->getLanguage() );
702 
703  /* Add canonical to head if there is no local page for this shared file */
704  if ( $descUrl && $this->mPage->getId() == 0 ) {
705  $out->setCanonicalUrl( $descUrl );
706  }
707 
708  $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
709  $repo = $this->mPage->getFile()->getRepo()->getDisplayName();
710 
711  if ( $descUrl &&
712  $descText &&
713  $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-'
714  ) {
715  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-here', $repo, $descUrl ] );
716  } elseif ( $descUrl &&
717  $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-'
718  ) {
719  $out->wrapWikiMsg( $wrap, [ 'sharedupload-desc-there', $repo, $descUrl ] );
720  } else {
721  $out->wrapWikiMsg( $wrap, [ 'sharedupload', $repo ], ''/*BACKCOMPAT*/ );
722  }
723 
724  if ( $descText ) {
725  $this->mExtraDescription = $descText;
726  }
727  }
728 
729  public function getUploadUrl() {
730  $this->loadFile();
731  $uploadTitle = SpecialPage::getTitleFor( 'Upload' );
732  return $uploadTitle->getFullURL( [
733  'wpDestFile' => $this->mPage->getFile()->getName(),
734  'wpForReUpload' => 1
735  ] );
736  }
737 
741  protected function uploadLinksBox() {
742  if ( !$this->getContext()->getConfig()->get( 'EnableUploads' ) ) {
743  return;
744  }
745 
746  $this->loadFile();
747  if ( !$this->mPage->getFile()->isLocal() ) {
748  return;
749  }
750 
751  $canUpload = $this->getTitle()->quickUserCan( 'upload', $this->getContext()->getUser() );
752  if ( $canUpload && UploadBase::userCanReUpload(
753  $this->getContext()->getUser(),
754  $this->mPage->getFile() )
755  ) {
756  // "Upload a new version of this file" link
757  $ulink = Linker::makeExternalLink(
758  $this->getUploadUrl(),
759  $this->getContext()->msg( 'uploadnewversion-linktext' )->text()
760  );
761  $attrs = [ 'class' => 'plainlinks', 'id' => 'mw-imagepage-reupload-link' ];
762  $linkPara = Html::rawElement( 'p', $attrs, $ulink );
763  } else {
764  // "You cannot overwrite this file." message
765  $attrs = [ 'id' => 'mw-imagepage-upload-disallowed' ];
766  $msg = $this->getContext()->msg( 'upload-disallowed-here' )->text();
767  $linkPara = Html::element( 'p', $attrs, $msg );
768  }
769 
770  $uploadLinks = Html::rawElement( 'div', [ 'class' => 'mw-imagepage-upload-links' ], $linkPara );
771  $this->getContext()->getOutput()->addHTML( $uploadLinks );
772  }
773 
777  protected function closeShowImage() {
778  }
779 
784  protected function imageHistory() {
785  $this->loadFile();
786  $out = $this->getContext()->getOutput();
787  $pager = new ImageHistoryPseudoPager( $this );
788  $out->addHTML( $pager->getBody() );
789  $out->preventClickjacking( $pager->getPreventClickjacking() );
790 
791  $this->mPage->getFile()->resetHistory(); // free db resources
792 
793  # Exist check because we don't want to show this on pages where an image
794  # doesn't exist along with the noimage message, that would suck. -√¶var
795  if ( $this->mPage->getFile()->exists() ) {
796  $this->uploadLinksBox();
797  }
798  }
799 
805  protected function queryImageLinks( $target, $limit ) {
806  $dbr = wfGetDB( DB_REPLICA );
807 
808  return $dbr->select(
809  [ 'imagelinks', 'page' ],
810  [ 'page_namespace', 'page_title', 'il_to' ],
811  [ 'il_to' => $target, 'il_from = page_id' ],
812  __METHOD__,
813  [ 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', ]
814  );
815  }
816 
817  protected function imageLinks() {
818  $limit = 100;
819 
820  $out = $this->getContext()->getOutput();
821 
822  $rows = [];
823  $redirects = [];
824  foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) {
825  $redirects[$redir->getDBkey()] = [];
826  $rows[] = (object)[
827  'page_namespace' => NS_FILE,
828  'page_title' => $redir->getDBkey(),
829  ];
830  }
831 
832  $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
833  foreach ( $res as $row ) {
834  $rows[] = $row;
835  }
836  $count = count( $rows );
837 
838  $hasMore = $count > $limit;
839  if ( !$hasMore && count( $redirects ) ) {
840  $res = $this->queryImageLinks( array_keys( $redirects ),
841  $limit - count( $rows ) + 1 );
842  foreach ( $res as $row ) {
843  $redirects[$row->il_to][] = $row;
844  $count++;
845  }
846  $hasMore = ( $res->numRows() + count( $rows ) ) > $limit;
847  }
848 
849  if ( $count == 0 ) {
850  $out->wrapWikiMsg(
851  Html::rawElement( 'div',
852  [ 'id' => 'mw-imagepage-nolinkstoimage' ], "\n$1\n" ),
853  'nolinkstoimage'
854  );
855  return;
856  }
857 
858  $out->addHTML( "<div id='mw-imagepage-section-linkstoimage'>\n" );
859  if ( !$hasMore ) {
860  $out->addWikiMsg( 'linkstoimage', $count );
861  } else {
862  // More links than the limit. Add a link to [[Special:Whatlinkshere]]
863  $out->addWikiMsg( 'linkstoimage-more',
864  $this->getContext()->getLanguage()->formatNum( $limit ),
865  $this->getTitle()->getPrefixedDBkey()
866  );
867  }
868 
869  $out->addHTML(
870  Html::openElement( 'ul',
871  [ 'class' => 'mw-imagepage-linkstoimage' ] ) . "\n"
872  );
873  $count = 0;
874 
875  // Sort the list by namespace:title
876  usort( $rows, [ $this, 'compare' ] );
877 
878  // Create links for every element
879  $currentCount = 0;
880  foreach ( $rows as $element ) {
881  $currentCount++;
882  if ( $currentCount > $limit ) {
883  break;
884  }
885 
886  $query = [];
887  # Add a redirect=no to make redirect pages reachable
888  if ( isset( $redirects[$element->page_title] ) ) {
889  $query['redirect'] = 'no';
890  }
892  Title::makeTitle( $element->page_namespace, $element->page_title ),
893  null, [], $query
894  );
895  if ( !isset( $redirects[$element->page_title] ) ) {
896  # No redirects
897  $liContents = $link;
898  } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
899  # Redirect without usages
900  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )
901  ->rawParams( $link, '' )
902  ->parse();
903  } else {
904  # Redirect with usages
905  $li = '';
906  foreach ( $redirects[$element->page_title] as $row ) {
907  $currentCount++;
908  if ( $currentCount > $limit ) {
909  break;
910  }
911 
912  $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
913  $li .= Html::rawElement(
914  'li',
915  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
916  $link2
917  ) . "\n";
918  }
919 
921  'ul',
922  [ 'class' => 'mw-imagepage-redirectstofile' ],
923  $li
924  ) . "\n";
925  $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams(
926  $link, $ul )->parse();
927  }
928  $out->addHTML( Html::rawElement(
929  'li',
930  [ 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
931  $liContents
932  ) . "\n"
933  );
934 
935  }
936  $out->addHTML( Html::closeElement( 'ul' ) . "\n" );
937  $res->free();
938 
939  // Add a links to [[Special:Whatlinkshere]]
940  if ( $count > $limit ) {
941  $out->addWikiMsg( 'morelinkstoimage', $this->getTitle()->getPrefixedDBkey() );
942  }
943  $out->addHTML( Html::closeElement( 'div' ) . "\n" );
944  }
945 
946  protected function imageDupes() {
947  $this->loadFile();
948  $out = $this->getContext()->getOutput();
949 
950  $dupes = $this->mPage->getDuplicates();
951  if ( count( $dupes ) == 0 ) {
952  return;
953  }
954 
955  $out->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
956  $out->addWikiMsg( 'duplicatesoffile',
957  $this->getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->getTitle()->getDBkey()
958  );
959  $out->addHTML( "<ul class='mw-imagepage-duplicates'>\n" );
960 
964  foreach ( $dupes as $file ) {
965  $fromSrc = '';
966  if ( $file->isLocal() ) {
967  $link = Linker::linkKnown( $file->getTitle() );
968  } else {
969  $link = Linker::makeExternalLink( $file->getDescriptionUrl(),
970  $file->getTitle()->getPrefixedText() );
971  $fromSrc = $this->getContext()->msg(
972  'shared-repo-from',
973  $file->getRepo()->getDisplayName()
974  )->escaped();
975  }
976  $out->addHTML( "<li>{$link} {$fromSrc}</li>\n" );
977  }
978  $out->addHTML( "</ul></div>\n" );
979  }
980 
984  public function delete() {
985  $file = $this->mPage->getFile();
986  if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
987  // Standard article deletion
988  parent::delete();
989  return;
990  }
991 
992  $deleter = new FileDeleteForm( $file );
993  $deleter->execute();
994  }
995 
1001  function showError( $description ) {
1002  $out = $this->getContext()->getOutput();
1003  $out->setPageTitle( $this->getContext()->msg( 'internalerror' ) );
1004  $out->setRobotPolicy( 'noindex,nofollow' );
1005  $out->setArticleRelated( false );
1006  $out->enableClientCache( false );
1007  $out->addWikiTextAsInterface( $description );
1008  }
1009 
1018  protected function compare( $a, $b ) {
1019  return $a->page_namespace <=> $b->page_namespace
1020  ?: strcmp( $a->page_title, $b->page_title );
1021  }
1022 
1031  public function getImageLimitsFromOption( $user, $optionName ) {
1032  global $wgImageLimits;
1033 
1034  $option = $user->getIntOption( $optionName );
1035  if ( !isset( $wgImageLimits[$option] ) ) {
1036  $option = User::getDefaultOption( $optionName );
1037  }
1038 
1039  // The user offset might still be incorrect, specially if
1040  // $wgImageLimits got changed (see T10858).
1041  if ( !isset( $wgImageLimits[$option] ) ) {
1042  // Default to the first offset in $wgImageLimits
1043  $option = 0;
1044  }
1045 
1046  // if nothing is set, fallback to a hardcoded default
1047  return $wgImageLimits[$option] ?? [ 800, 600 ];
1048  }
1049 
1057  protected function doRenderLangOpt( array $langChoices, $renderLang ) {
1058  global $wgScript;
1059  $opts = '';
1060 
1061  $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
1062 
1063  foreach ( $langChoices as $lang ) {
1064  $opts .= $this->createXmlOptionStringForLanguage(
1065  $lang,
1066  $matchedRenderLang === $lang
1067  );
1068  }
1069 
1070  // Allow for the default case in an svg <switch> that is displayed if no
1071  // systemLanguage attribute matches
1072  $opts .= "\n" .
1073  Xml::option(
1074  $this->getContext()->msg( 'img-lang-default' )->text(),
1075  'und',
1076  is_null( $matchedRenderLang )
1077  );
1078 
1079  $select = Html::rawElement(
1080  'select',
1081  [ 'id' => 'mw-imglangselector', 'name' => 'lang' ],
1082  $opts
1083  );
1084  $submit = Xml::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() );
1085 
1086  $formContents = $this->getContext()->msg( 'img-lang-info' )
1087  ->rawParams( $select, $submit )
1088  ->parse();
1089  $formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() );
1090 
1091  $langSelectLine = Html::rawElement( 'div', [ 'id' => 'mw-imglangselector-line' ],
1092  Html::rawElement( 'form', [ 'action' => $wgScript ], $formContents )
1093  );
1094  return $langSelectLine;
1095  }
1096 
1102  private function createXmlOptionStringForLanguage( $lang, $selected ) {
1104  $name = Language::fetchLanguageName( $code, $this->getContext()->getLanguage()->getCode() );
1105  if ( $name !== '' ) {
1106  $display = $this->getContext()->msg( 'img-lang-opt', $code, $name )->text();
1107  } else {
1108  $display = $code;
1109  }
1110  return "\n" .
1111  Xml::option(
1112  $display,
1113  $lang,
1114  $selected
1115  );
1116  }
1117 
1132  protected function getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height ) {
1133  if ( !$maxWidth || !$maxHeight ) {
1134  // should never happen
1135  throw new MWException( 'Using a choice from $wgImageLimits that is 0x0' );
1136  }
1137 
1138  if ( !$width || !$height ) {
1139  return [ 0, 0 ];
1140  }
1141 
1142  # Calculate the thumbnail size.
1143  if ( $width <= $maxWidth && $height <= $maxHeight ) {
1144  // Vectorized image, do nothing.
1145  } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1146  # The limiting factor is the width, not the height.
1147  $height = round( $height * $maxWidth / $width );
1148  $width = $maxWidth;
1149  # Note that $height <= $maxHeight now.
1150  } else {
1151  $newwidth = floor( $width * $maxHeight / $height );
1152  $height = round( $height * $newwidth / $width );
1153  $width = $newwidth;
1154  # Note that $height <= $maxHeight now, but might not be identical
1155  # because of rounding.
1156  }
1157  return [ $width, $height ];
1158  }
1159 
1168  protected function getThumbSizes( $origWidth, $origHeight ) {
1169  global $wgImageLimits;
1170  if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1171  $thumbSizes = $wgImageLimits;
1172  // Also include the full sized resolution in the list, so
1173  // that users know they can get it. This will link to the
1174  // original file asset if mustRender() === false. In the case
1175  // that we mustRender, some users have indicated that they would
1176  // find it useful to have the full size image in the rendered
1177  // image format.
1178  $thumbSizes[] = [ $origWidth, $origHeight ];
1179  } else {
1180  # Creating thumb links triggers thumbnail generation.
1181  # Just generate the thumb for the current users prefs.
1182  $thumbSizes = [
1183  $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' )
1184  ];
1185  if ( !$this->displayImg->mustRender() ) {
1186  // We can safely include a link to the "full-size" preview,
1187  // without actually rendering.
1188  $thumbSizes[] = [ $origWidth, $origHeight ];
1189  }
1190  }
1191  return $thumbSizes;
1192  }
1193 
1198  public function getFile() {
1199  return $this->mPage->getFile();
1200  }
1201 
1206  public function isLocal() {
1207  return $this->mPage->isLocal();
1208  }
1209 
1214  public function getDuplicates() {
1215  return $this->mPage->getDuplicates();
1216  }
1217 
1222  public function getForeignCategories() {
1223  return $this->mPage->getForeignCategories();
1224  }
1225 
1226 }
$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:2621
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:1972
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:39
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used $groups Array of ChangesListFilterGroup objects(added in 1.34) 'FileDeleteComplete' 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:1529
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
either a plain
Definition: hooks.txt:2033
$wgScript
The URL path to index.php.
File false $displayImg
Definition: ImagePage.php:33
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:677
getVal( $name, $default=null)
Fetch a scalar from the input or return $default if it&#39;s not set.
Definition: WebRequest.php:448
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Definition: router.php:42
compare( $a, $b)
Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare() ...
Definition: ImagePage.php:1018
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
Definition: Xml.php:484
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:251
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
getImageLimitsFromOption( $user, $optionName)
Returns the corresponding $wgImageLimits entry for the selected user option.
Definition: ImagePage.php:1031
setFile( $file)
Definition: ImagePage.php:62
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getUploadUrl()
Definition: ImagePage.php:729
Class for viewing MediaWiki article and history.
Definition: Article.php:38
Class for viewing MediaWiki file description pages.
Definition: ImagePage.php:31
FileRepo $repo
Definition: ImagePage.php:36
getMatchedLanguage( $userPreferredLanguage)
Get the language code from the available languages for this file that matches the language requested ...
Definition: File.php:601
getLanguageForRendering(WebRequest $request, File $file)
Returns language code to be used for dispaying the image, based on request context and languages avai...
Definition: ImagePage.php:300
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:23
getEmptyPageParserOutput(ParserOptions $options)
Overloading Article&#39;s getEmptyPageParserOutput method.
Definition: ImagePage.php:284
printSharedImageText()
Show a notice that the file is from a shared repository.
Definition: ImagePage.php:696
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:784
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()
Add the re-upload link (or message about not being able to re-upload) to the output.
Definition: ImagePage.php:741
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:2205
getForeignCategories()
Definition: ImagePage.php:1222
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition: hooks.txt:3039
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 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:767
$wgEnableUploads
Allow users to upload files.
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 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:767
getContext()
Gets the context this Article is executed in.
Definition: Article.php:2239
createXmlOptionStringForLanguage( $lang, $selected)
Definition: ImagePage.php:1102
$wgShowEXIF
Show Exif data, on by default if available.
static openElement( $element, $attribs=null)
This opens an XML element.
Definition: Xml.php:108
$css
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 or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Definition: hooks.txt:2205
getHandler()
Get a MediaHandler instance for this file.
Definition: File.php:1388
$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:459
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:1057
$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:639
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:1972
static tags( $element, $attribs, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:130
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:315
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
Definition: Linker.php:845
showTOC( $metadata)
Create the TOC.
Definition: ImagePage.php:227
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:767
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:912
const NS_FILE
Definition: Defines.php:66
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:83
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 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:767
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.
$wgSVGMaxSize
Don&#39;t scale a SVG larger than this.
queryImageLinks( $target, $limit)
Definition: ImagePage.php:805
static getDefaultOption( $opt)
Get a given default option value.
Definition: User.php:1733
getUser( $audience=RevisionRecord::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2561
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:592
static fetchLanguageName( $code, $inLanguage=self::AS_AUTONYMS, $include=self::ALL)
Definition: Language.php:937
showError( $description)
Display an error with a wikitext description.
Definition: ImagePage.php:1001
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 closeElement( $element)
Shortcut to close an XML element.
Definition: Xml.php:117
getId()
Call to WikiPage function for backwards compatibility.
Definition: Article.php:2473
makeMetadataTable( $metadata)
Make a table with metadata to be shown in the output page.
Definition: ImagePage.php:253
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:1168
static hidden( $name, $value, array $attribs=[])
Convenience function to produce an input element with type=hidden.
Definition: Html.php:796
getOldID()
Definition: Article.php:326
getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height)
Get the width and height to display image at.
Definition: ImagePage.php:1132
getDisplayName()
Get the human-readable name of the repo.
Definition: FileRepo.php:1781
if(!is_readable( $file)) $ext
Definition: router.php:48
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:53
bool $mExtraDescription
Definition: ImagePage.php:42
getDisplayedFile()
Definition: ImagePage.php:216
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
Definition: Linker.php:642
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
const DB_REPLICA
Definition: defines.php:25
WikiFilePage $mPage
Definition: ImagePage.php:47
static makeThumbLinkObj(LinkTarget $title, $file, $label='', $alt='', $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
Definition: Linker.php:493
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition: File.php:61
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code, mangling or hiding MediaWiki&#39;s output.
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:2621
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:1454
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:777
openShowImage()
Definition: ImagePage.php:315