62 $this->mPage->setFile( $file );
63 $this->displayImg = $file;
64 $this->fileLoaded =
true;
68 if ( $this->fileLoaded ) {
71 $this->fileLoaded =
true;
73 $this->displayImg = $img =
false;
75 Hooks::run(
'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
82 $this->mPage->setFile( $img );
83 if ( !$this->displayImg ) {
84 $this->displayImg = $img;
86 $this->repo = $img->getRepo();
94 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
109 if ( $this->
getTitle()->getNamespace() !=
NS_FILE || ( $diff !==
null && $diffOnly ) ) {
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' );
125 if (
$wgShowEXIF && $this->displayImg->exists() ) {
127 $formattedMetadata = $this->displayImg->formatMetadata( $this->
getContext() );
128 $showmeta = $formattedMetadata !==
false;
133 if ( !$diff && $this->displayImg->exists() ) {
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() ] ) );
152 $out->addHTML( Xml::closeElement(
'div' ) );
154 # Just need to set the right headers
155 $out->setArticleFlag(
true );
156 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
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() );
166 $out->addHTML(
'<div id="shared-image-desc">' . $this->mExtraDescription .
"</div>\n" );
173 $out->addHTML( Xml::element(
'h2',
174 [
'id' =>
'filelinks' ],
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
181 # Allow extensions to add something after the image links
183 Hooks::run(
'ImagePageAfterImageLinks', [ $this, &
$html ] );
189 $out->addHTML( Xml::element(
191 [
'id' =>
'metadata' ],
194 $out->addModules( [
'mediawiki.action.view.metadata' ] );
198 if ( !$this->repo->isLocal() ) {
199 $css = $this->repo->getDescriptionStylesheetUrl();
205 $out->addModuleStyles( [
207 'mediawiki.action.view.filepage',
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>',
232 Hooks::run(
'ImagePageShowTOC', [ $this, &$r ] );
235 $r[] =
'<li><a href="#metadata">' .
236 $this->
getContext()->msg(
'metadata' )->escaped() .
240 return '<ul id="filetoc">' . implode(
"\n", $r ) .
'</ul>';
252 $r =
"<div class=\"mw-imagepage-section-metadata\">";
253 $r .= $this->
getContext()->msg(
'metadata-help' )->plain();
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';
263 $r .= Html::rawElement(
'tr',
264 [
'class' => $class ],
265 Html::rawElement(
'th', [], $v[
'name'] )
266 . Html::rawElement(
'td', [], $v[
'value'] )
270 $r .=
"</table>\n</div>\n";
283 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getId() ) {
286 return parent::getContentObject();
290 $handler = $this->displayImg->getHandler();
295 $requestLanguage =
$request->getVal(
'lang' );
296 if ( !is_null( $requestLanguage ) ) {
297 if (
$handler->validateParam(
'lang', $requestLanguage ) ) {
298 return $requestLanguage;
302 return $handler->getDefaultRenderLanguage( $this->displayImg );
312 $dirmark =
$lang->getDirMarkEntity();
317 $maxHeight = $max[1];
319 if ( $this->displayImg->exists() ) {
321 $page =
$request->getIntOrNull(
'page' );
322 if ( is_null( $page ) ) {
330 if ( !is_null( $renderLang ) ) {
334 $width_orig = $this->displayImg->getWidth( $page );
335 $width = $width_orig;
336 $height_orig = $this->displayImg->getHeight( $page );
337 $height = $height_orig;
340 $linktext = $filename;
345 Hooks::run(
'ImageOpenShowImageInlineBefore', [ &$imagePage, &
$out ] );
347 if ( $this->displayImg->allowInlineDisplay() ) {
349 # "Download high res version" link below the image
350 # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
351 # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
352 # We'll show a thumbnail of this image
353 if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
355 $maxWidth, $maxHeight, $width, $height
357 $linktext = $this->
getContext()->msg(
'show-big-image' )->escaped();
359 $thumbSizes = $this->
getThumbSizes( $width_orig, $height_orig );
360 # Generate thumbnails or thumbnail links as needed...
362 foreach ( $thumbSizes as $size ) {
371 if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
372 || ( $this->displayImg->isVectorized()
375 && $size[0] != $width && $size[1] != $height
379 $otherSizes[] = $sizeLink;
383 $otherSizes = array_unique( $otherSizes );
387 if ( count( $otherSizes ) ) {
391 [
'class' =>
'mw-filepage-other-resolutions' ],
392 $this->
getContext()->msg(
'show-big-image-other' )
393 ->rawParams(
$lang->pipeList( $otherSizes ) )
394 ->params( count( $otherSizes ) )
398 } elseif ( $width == 0 && $height == 0 ) {
399 # Some sort of audio file that doesn't have dimensions
400 # Don't output a no hi res message for such a file
403 # Image is small enough to show full size on image page
404 $msgsmall = $this->
getContext()->msg(
'file-nohires' )->parse();
409 $thumbnail = $this->displayImg->transform(
$params );
412 $anchorclose = Html::rawElement(
414 [
'class' =>
'mw-filepage-resolutioninfo' ],
418 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
420 $out->addModules(
'mediawiki.page.image.pagination' );
421 $out->addHTML(
'<table class="multipageimage"><tr><td>' );
426 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
429 $out->addHTML(
'<div class="fullImageLink" id="file">' .
431 $anchorclose .
"</div>\n" );
435 $count = $this->displayImg->pageCount();
438 $label = $this->
getContext()->msg(
'imgmultipageprev' )->text();
445 [
'page' => $page - 1 ]
453 [
'page' => $page - 1 ]
459 if ( $page < $count ) {
460 $label = $this->
getContext()->msg(
'imgmultipagenext' )->text();
465 [
'page' => $page + 1 ]
473 [
'page' => $page + 1 ]
482 'name' =>
'pageselector',
486 for ( $i = 1; $i <= $count; $i++ ) {
487 $options[] = Xml::option(
$lang->formatNum( $i ), $i, $i == $page );
489 $select = Xml::tags(
'select',
490 [
'id' =>
'pageselector',
'name' =>
'page' ],
494 '</td><td><div class="multipageimagenavbox">' .
495 Xml::openElement(
'form', $formParams ) .
496 Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
497 $this->
getContext()->msg(
'imgmultigoto' )->rawParams( $select )->parse() .
498 $this->
getContext()->msg(
'word-separator' )->escaped() .
499 Xml::submitButton( $this->
getContext()->msg(
'imgmultigo' )->
text() ) .
500 Xml::closeElement(
'form' ) .
501 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
504 } elseif ( $this->displayImg->isSafeFile() ) {
505 # if direct link is allowed but it's not a renderable image, show an icon.
506 $icon = $this->displayImg->iconThumb();
508 $out->addHTML(
'<div class="fullImageLink" id="file">' .
509 $icon->toHtml( [
'file-link' =>
true ] ) .
513 $longDesc = $this->
getContext()->msg(
'parentheses', $this->displayImg->getLongDesc() )->text();
515 $handler = $this->displayImg->getHandler();
519 $warningConfig =
$handler->getWarningConfig( $this->displayImg );
521 if ( $warningConfig !==
null ) {
525 $output->addJsConfigVars(
'wgFileWarning', $warningConfig );
526 $output->addModules( $warningConfig[
'module'] );
527 $output->addModules(
'mediawiki.filewarning' );
531 $medialink =
"[[Media:$filename|$linktext]]";
533 if ( !$this->displayImg->isSafeFile() ) {
534 $warning = $this->
getContext()->msg(
'mediawarning' )->plain();
543 $out->addWikiText( <<<EOT
544<
div class=
"fullMedia"><span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span></
div>
545<
div class=
"mediaWarning">$warning</
div>
550 $out->addWikiText( <<<EOT
551<
div class=
"fullMedia">{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
557 $renderLangOptions = $this->displayImg->getAvailableLanguages();
558 if ( count( $renderLangOptions ) >= 1 ) {
563 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
569 $ext = $this->displayImg->getExtension();
571 'file-no-thumb-animation-' .
$ext,
572 'file-no-thumb-animation'
575 $out->addWikiText( <<<EOT
576<
div class=
"mw-noanimatethumb">{$noAnimMesg}</
div>
581 if ( !$this->displayImg->isLocal() ) {
585 # Image does not exist
586 if ( !$this->
getId() ) {
589 # No article exists either
590 # Show deletion log to be consistent with normal articles
593 [
'delete',
'move',
'protect' ],
594 $this->
getTitle()->getPrefixedText(),
597 'conds' => [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ],
598 'showIfEmpty' =>
false,
599 'msgKey' => [
'moveddeleted-notice' ]
606 $uploadTitle = SpecialPage::getTitleFor(
'Upload' );
608 'filepage-nofile-link',
609 $uploadTitle->getFullURL( [
'wpDestFile' => $this->mPage->getFile()->getName() ] )
612 $nofile =
'filepage-nofile';
617 $out->setRobotPolicy(
'noindex,nofollow' );
618 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
619 if ( !$this->
getId() && $wgSend404Code ) {
622 $request->response()->statusHeader( 404 );
625 $out->setFileVersion( $this->displayImg );
636 if ( $sizeLinkBigImagePreview ) {
638 $previewTypeDiffers =
false;
639 $origExt = $thumbExt = $this->displayImg->getExtension();
640 if ( $this->displayImg->getHandler() ) {
641 $origMime = $this->displayImg->getMimeType();
643 $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
644 list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
645 $origExt, $origMime, $typeParams );
646 if ( $thumbMime !== $origMime ) {
647 $previewTypeDiffers =
true;
650 if ( $previewTypeDiffers ) {
651 return $this->
getContext()->msg(
'show-big-image-preview-differ' )->
652 rawParams( $sizeLinkBigImagePreview )->
653 params( strtoupper( $origExt ) )->
654 params( strtoupper( $thumbExt ) )->
657 return $this->
getContext()->msg(
'show-big-image-preview' )->
658 rawParams( $sizeLinkBigImagePreview )->
676 $thumbnail = $this->displayImg->transform(
$params );
677 if ( $thumbnail && !$thumbnail->isError() ) {
678 return Html::rawElement(
'a', [
679 'href' => $thumbnail->getUrl(),
680 'class' =>
'mw-thumbnail-link'
681 ], $this->getContext()->msg(
'show-big-image-size' )->numParams(
682 $thumbnail->getWidth(), $thumbnail->getHeight()
696 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
697 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
700 if ( $descUrl && $this->mPage->getId() == 0 ) {
701 $out->setCanonicalUrl( $descUrl );
704 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
711 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-here',
$repo, $descUrl ] );
712 } elseif ( $descUrl &&
715 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-there',
$repo, $descUrl ] );
717 $out->wrapWikiMsg( $wrap, [
'sharedupload',
$repo ],
'' );
721 $this->mExtraDescription = $descText;
727 $uploadTitle = SpecialPage::getTitleFor(
'Upload' );
728 return $uploadTitle->getFullURL( [
729 'wpDestFile' => $this->mPage->getFile()->getName(),
746 if ( !$this->mPage->getFile()->isLocal() ) {
751 $out->addHTML(
"<ul>\n" );
753 # "Upload a new version of this file" link
757 $this->mPage->getFile() )
763 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\">"
764 .
"<div class=\"plainlinks\">{$ulink}</div></li>\n" );
766 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">"
767 . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
770 $out->addHTML(
"</ul>\n" );
787 $out->addHTML( $pager->getBody() );
788 $out->preventClickjacking( $pager->getPreventClickjacking() );
790 $this->mPage->getFile()->resetHistory();
792 # Exist check because we don't want to show this on pages where an image
793 # doesn't exist along with the noimage message, that would suck. -ævar
794 if ( $this->mPage->getFile()->exists() ) {
808 [
'imagelinks',
'page' ],
809 [
'page_namespace',
'page_title',
'il_to' ],
810 [
'il_to' => $target,
'il_from = page_id' ],
812 [
'LIMIT' => $limit + 1,
'ORDER BY' =>
'il_from', ]
824 $redirects[$redir->getDBkey()] = [];
827 'page_title' => $redir->getDBkey(),
832 foreach (
$res as $row ) {
835 $count = count(
$rows );
837 $hasMore = $count > $limit;
838 if ( !$hasMore && count( $redirects ) ) {
840 $limit - count(
$rows ) + 1 );
841 foreach (
$res as $row ) {
842 $redirects[$row->il_to][] = $row;
845 $hasMore = (
$res->numRows() + count(
$rows ) ) > $limit;
850 Html::rawElement(
'div',
851 [
'id' =>
'mw-imagepage-nolinkstoimage' ],
"\n$1\n" ),
857 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
859 $out->addWikiMsg(
'linkstoimage', $count );
862 $out->addWikiMsg(
'linkstoimage-more',
863 $this->
getContext()->getLanguage()->formatNum( $limit ),
864 $this->
getTitle()->getPrefixedDBkey()
869 Html::openElement(
'ul',
870 [
'class' =>
'mw-imagepage-linkstoimage' ] ) .
"\n"
875 usort(
$rows, [ $this,
'compare' ] );
879 foreach (
$rows as $element ) {
881 if ( $currentCount > $limit ) {
886 # Add a redirect=no to make redirect pages reachable
887 if ( isset( $redirects[$element->page_title] ) ) {
888 $query[
'redirect'] =
'no';
891 Title::makeTitle( $element->page_namespace, $element->page_title ),
894 if ( !isset( $redirects[$element->page_title] ) ) {
897 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
898 # Redirect without usages
899 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )
900 ->rawParams(
$link,
'' )
903 # Redirect with usages
905 foreach ( $redirects[$element->page_title] as $row ) {
907 if ( $currentCount > $limit ) {
911 $link2 =
Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
912 $li .= Html::rawElement(
914 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
919 $ul = Html::rawElement(
921 [
'class' =>
'mw-imagepage-redirectstofile' ],
924 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )->rawParams(
927 $out->addHTML( Html::rawElement(
929 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
935 $out->addHTML( Html::closeElement(
'ul' ) .
"\n" );
939 if ( $count > $limit ) {
940 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
942 $out->addHTML( Html::closeElement(
'div' ) .
"\n" );
949 $dupes = $this->mPage->getDuplicates();
950 if ( count( $dupes ) == 0 ) {
954 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
955 $out->addWikiMsg(
'duplicatesoffile',
956 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
958 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
963 foreach ( $dupes as $file ) {
965 if ( $file->isLocal() ) {
969 $file->getTitle()->getPrefixedText() );
972 $file->getRepo()->getDisplayName()
975 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
977 $out->addHTML(
"</ul></div>\n" );
983 public function delete() {
984 $file = $this->mPage->getFile();
985 if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
1002 $out->setPageTitle( $this->
getContext()->msg(
'internalerror' ) );
1003 $out->setRobotPolicy(
'noindex,nofollow' );
1004 $out->setArticleRelated(
false );
1005 $out->enableClientCache(
false );
1006 $out->addWikiText( $description );
1018 if ( $a->page_namespace == $b->page_namespace ) {
1019 return strcmp( $a->page_title, $b->page_title );
1021 return $a->page_namespace - $b->page_namespace;
1036 $option = $user->getIntOption( $optionName );
1064 $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
1066 foreach ( $langChoices as
$lang ) {
1069 $matchedRenderLang ===
$lang
1079 is_null( $matchedRenderLang )
1082 $select = Html::rawElement(
1084 [
'id' =>
'mw-imglangselector',
'name' =>
'lang' ],
1087 $submit = Xml::submitButton( $this->
getContext()->msg(
'img-lang-go' )->
text() );
1089 $formContents = $this->
getContext()->msg(
'img-lang-info' )
1090 ->rawParams( $select, $submit )
1092 $formContents .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() );
1094 $langSelectLine = Html::rawElement(
'div', [
'id' =>
'mw-imglangselector-line' ],
1095 Html::rawElement(
'form', [
'action' =>
$wgScript ], $formContents )
1097 return $langSelectLine;
1107 $name = Language::fetchLanguageName(
$code, $this->
getContext()->getLanguage()->getCode() );
1108 if ( $name !==
'' ) {
1109 $display = $this->
getContext()->msg(
'img-lang-opt',
$code, $name )->text();
1136 if ( !$maxWidth || !$maxHeight ) {
1138 throw new MWException(
'Using a choice from $wgImageLimits that is 0x0' );
1141 if ( !$width || !$height ) {
1145 # Calculate the thumbnail size.
1146 if ( $width <= $maxWidth && $height <= $maxHeight ) {
1148 } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1149 # The limiting factor is the width, not the height.
1150 $height = round( $height * $maxWidth / $width );
1152 # Note that $height <= $maxHeight now.
1154 $newwidth = floor( $width * $maxHeight / $height );
1155 $height = round( $height * $newwidth / $width );
1157 # Note that $height <= $maxHeight now, but might not be identical
1158 # because of rounding.
1160 return [ $width, $height ];
1173 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1181 $thumbSizes[] = [ $origWidth, $origHeight ];
1183 # Creating thumb links triggers thumbnail generation.
1184 # Just generate the thumb for the current users prefs.
1188 if ( !$this->displayImg->mustRender() ) {
1191 $thumbSizes[] = [ $origWidth, $origHeight ];
1202 return $this->mPage->getFile();
1210 return $this->mPage->isLocal();
1218 return $this->mPage->getDuplicates();
1226 $this->mPage->getForeignCategories();
$wgScript
The URL path to index.php.
$wgSend404Code
Some web hosts attempt to rewrite all responses with a 404 (not found) status code,...
$wgImageLimits
Limit images on image description pages to a user-selectable limit.
$wgSVGMaxSize
Don't scale a SVG larger than this.
$wgEnableUploads
Uploads have to be specially set up to be secure.
$wgShowEXIF
Show Exif data, on by default if available.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfLocalFile( $title)
Get an object referring to a locally registered file.
wfFindFile( $title, $options=[])
Find a file.
wfMessageFallback()
This function accepts multiple message keys and returns a message instance for the first message whic...
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Class for viewing MediaWiki article and history.
getContext()
Gets the context this Article is executed in.
getTitle()
Get the title object of the article.
getId()
Call to WikiPage function for backwards compatibility.
getUser( $audience=Revision::FOR_PUBLIC, User $user=null)
Call to WikiPage function for backwards compatibility.
Base class for file repositories.
getDisplayName()
Get the human-readable name of the repo.
Implements some public methods and some protected utility functions which are required by multiple ch...
Class for viewing MediaWiki file description pages.
getLanguageForRendering(WebRequest $request, File $file)
showError( $description)
Display an error with a wikitext description.
imageHistory()
If the page we've just displayed is in the "Image" namespace, we follow it with an upload history of ...
compare( $a, $b)
Callback for usort() to do link sorts by (namespace, title) Function copied from Title::compare()
createXmlOptionStringForLanguage( $lang, $selected)
getThumbSizes( $origWidth, $origHeight)
Get alternative thumbnail sizes.
getImageLimitsFromOption( $user, $optionName)
Returns the corresponding $wgImageLimits entry for the selected user option.
getDisplayWidthHeight( $maxWidth, $maxHeight, $width, $height)
Get the width and height to display image at.
makeSizeLink( $params, $width, $height)
Creates an thumbnail of specified size and returns an HTML link to it.
doRenderLangOpt(array $langChoices, $renderLang)
Output a drop-down box for language options for the file.
getContentObject()
Overloading Article's getContentObject method.
makeMetadataTable( $metadata)
Make a table with metadata to be shown in the output page.
render()
Handler for action=render Include body text only; none of the image extras.
queryImageLinks( $target, $limit)
uploadLinksBox()
Print out the various links at the bottom of the image page, e.g.
printSharedImageText()
Show a notice that the file is from a shared repository.
closeShowImage()
For overloading.
showTOC( $metadata)
Create the TOC.
view()
This is the default action of the index.php entry point: just view the page of the given title.
getThumbPrevText( $params, $sizeLinkBigImagePreview)
Make the text under the image to say what size preview.
static linkKnown( $target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static processResponsiveImages( $file, $thumb, $hp)
Process responsive images: add 1.5x and 2x subimages to the thumbnail, where applicable.
static makeThumbLinkObj(Title $title, $file, $label='', $alt, $align='right', $params=[], $framed=false, $manualthumb="")
Make HTML for a thumbnail including image, border and caption.
static makeExternalLink( $url, $text, $escape=true, $linktype='', $attribs=[], $title=null)
Make an external link.
static showLogExtract(&$out, $types=[], $page='', $user='', $param=[])
Show log extract.
Represents a title within MediaWiki.
static userCanReUpload(User $user, File $img)
Check if a user is the last uploader.
static getDefaultOption( $opt)
Get a given default option value.
The WebRequest class encapsulates getting at data passed in the URL or via a POSTed form stripping il...
Special handling for file pages.
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
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
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
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
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
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
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
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
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
usually copyright or history_copyright This message must be in HTML not wikitext & $link
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
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
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
if(!is_readable( $file)) $ext
if(!isset( $args[0])) $lang