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