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