60 $this->mPage->setFile( $file );
61 $this->displayImg = $file;
62 $this->fileLoaded =
true;
66 if ( $this->fileLoaded ) {
69 $this->fileLoaded =
true;
71 $this->displayImg = $img =
false;
72 Hooks::run(
'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
79 $this->mPage->setFile( $img );
80 if ( !$this->displayImg ) {
81 $this->displayImg = $img;
83 $this->repo = $img->getRepo();
91 $this->
getContext()->getOutput()->setArticleBodyOnly(
true );
106 if ( $this->
getTitle()->getNamespace() !=
NS_FILE || ( $diff !==
null && $diffOnly ) ) {
113 if ( $this->
getTitle()->getNamespace() ==
NS_FILE && $this->mPage->getFile()->getRedirected() ) {
114 if ( $this->
getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !==
null ) {
117 $request->setVal(
'diffonly',
'true' );
123 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
125 Title::makeTitle(
NS_FILE, $this->mPage->getFile()->getName() ),
134 if ( $wgShowEXIF && $this->displayImg->exists() ) {
136 $formattedMetadata = $this->displayImg->formatMetadata( $this->
getContext() );
137 $showmeta = $formattedMetadata !==
false;
142 if ( !$diff && $this->displayImg->exists() ) {
150 # No need to display noarticletext, we use our own message, output in openShowImage()
151 if ( $this->mPage->getId() ) {
152 # NS_FILE is in the user language, but this section (the actual wikitext)
153 # should be in page content language
154 $pageLang = $this->
getTitle()->getPageViewLanguage();
156 'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
157 'class' =>
'mw-content-' . $pageLang->getDir() ] ) );
163 # Just need to set the right headers
164 $out->setArticleFlag(
true );
165 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
169 # Show shared description, if needed
170 if ( $this->mExtraDescription ) {
171 $fol = $this->
getContext()->msg(
'shareddescriptionfollows' );
172 if ( !$fol->isDisabled() ) {
173 $out->addWikiText( $fol->plain() );
175 $out->addHTML(
'<div id="shared-image-desc">' . $this->mExtraDescription .
"</div>\n" );
183 [
'id' =>
'filelinks' ],
186 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
187 # Yet we return metadata about the target. Definitely an issue in the FileRepo
190 # Allow extensions to add something after the image links
192 Hooks::run(
'ImagePageAfterImageLinks', [ $this, &
$html ] );
200 [
'id' =>
'metadata' ],
203 $out->addModules( [
'mediawiki.action.view.metadata' ] );
207 if ( !$this->repo->isLocal() ) {
208 $css = $this->repo->getDescriptionStylesheetUrl();
214 $out->addModuleStyles( [
216 'mediawiki.action.view.filepage',
237 '<li><a href="#file">' . $this->
getContext()->msg(
'file-anchor-link' )->escaped() .
'</a></li>',
238 '<li><a href="#filehistory">' . $this->
getContext()->msg(
'filehist' )->escaped() .
'</a></li>',
239 '<li><a href="#filelinks">' . $this->
getContext()->msg(
'imagelinks' )->escaped() .
'</a></li>',
242 Hooks::run(
'ImagePageShowTOC', [ $this, &$r ] );
245 $r[] =
'<li><a href="#metadata">' .
246 $this->
getContext()->msg(
'metadata' )->escaped() .
250 return '<ul id="filetoc">' . implode(
"\n", $r ) .
'</ul>';
262 $r =
"<div class=\"mw-imagepage-section-metadata\">";
263 $r .= $this->
getContext()->msg(
'metadata-help' )->plain();
264 $r .=
"<table id=\"mw_metadata\" class=\"mw_metadata\">\n";
265 foreach ( $metadata
as $type => $stuff ) {
266 foreach ( $stuff
as $v ) {
267 # @todo FIXME: Why is this using escapeId for a class?!
268 $class = Sanitizer::escapeId( $v[
'id'] );
269 if (
$type ==
'collapsed' ) {
271 $class .=
' collapsable';
273 $r .=
"<tr class=\"$class\">\n";
274 $r .=
"<th>{$v['name']}</th>\n";
275 $r .=
"<td>{$v['value']}</td>\n</tr>";
278 $r .=
"</table>\n</div>\n";
291 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && 0 == $this->getId() ) {
294 return parent::getContentObject();
304 $dirmark =
$lang->getDirMarkEntity();
309 $maxHeight = $max[1];
311 if ( $this->displayImg->exists() ) {
314 if ( is_null(
$page ) ) {
321 $renderLang =
$request->getVal(
'lang' );
322 if ( !is_null( $renderLang ) ) {
323 $handler = $this->displayImg->getHandler();
331 $width_orig = $this->displayImg->getWidth(
$page );
332 $width = $width_orig;
333 $height_orig = $this->displayImg->getHeight(
$page );
334 $height = $height_orig;
337 $linktext = $filename;
342 Hooks::run(
'ImageOpenShowImageInlineBefore', [ &$imagePage, &
$out ] );
344 if ( $this->displayImg->allowInlineDisplay() ) {
346 # "Download high res version" link below the image
347 # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
348 # Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
349 # We'll show a thumbnail of this image
350 if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
352 $maxWidth, $maxHeight, $width, $height
354 $linktext = $this->
getContext()->msg(
'show-big-image' )->escaped();
356 $thumbSizes = $this->
getThumbSizes( $width_orig, $height_orig );
357 # Generate thumbnails or thumbnail links as needed...
359 foreach ( $thumbSizes
as $size ) {
368 if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
369 || ( $this->displayImg->isVectorized()
372 && $size[0] != $width && $size[1] != $height
376 $otherSizes[] = $sizeLink;
380 $otherSizes = array_unique( $otherSizes );
384 if ( count( $otherSizes ) ) {
388 [
'class' =>
'mw-filepage-other-resolutions' ],
389 $this->
getContext()->msg(
'show-big-image-other' )
390 ->rawParams(
$lang->pipeList( $otherSizes ) )
391 ->params( count( $otherSizes ) )
395 } elseif ( $width == 0 && $height == 0 ) {
396 # Some sort of audio file that doesn't have dimensions
397 # Don't output a no hi res message for such a file
400 # Image is small enough to show full size on image page
401 $msgsmall = $this->
getContext()->msg(
'file-nohires' )->parse();
406 $thumbnail = $this->displayImg->transform(
$params );
409 $anchorclose = Html::rawElement(
411 [
'class' =>
'mw-filepage-resolutioninfo' ],
415 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
417 $out->addModules(
'mediawiki.page.image.pagination' );
418 $out->addHTML(
'<table class="multipageimage"><tr><td>' );
423 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
426 $out->addHTML(
'<div class="fullImageLink" id="file">' .
428 $anchorclose .
"</div>\n" );
432 $count = $this->displayImg->pageCount();
435 $label =
$out->parse( $this->
getContext()->msg(
'imgmultipageprev' )->
text(),
false );
442 [
'page' =>
$page - 1 ]
450 [
'page' =>
$page - 1 ]
457 $label = $this->
getContext()->msg(
'imgmultipagenext' )->text();
462 [
'page' =>
$page + 1 ]
470 [
'page' =>
$page + 1 ]
479 'name' =>
'pageselector',
483 for ( $i = 1; $i <=
$count; $i++ ) {
487 [
'id' =>
'pageselector',
'name' =>
'page' ],
491 '</td><td><div class="multipageimagenavbox">' .
493 Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
494 $this->
getContext()->msg(
'imgmultigoto' )->rawParams( $select )->parse() .
497 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
500 } elseif ( $this->displayImg->isSafeFile() ) {
501 # if direct link is allowed but it's not a renderable image, show an icon.
502 $icon = $this->displayImg->iconThumb();
504 $out->addHTML(
'<div class="fullImageLink" id="file">' .
505 $icon->toHtml( [
'file-link' =>
true ] ) .
509 $longDesc = $this->
getContext()->msg(
'parentheses', $this->displayImg->getLongDesc() )->text();
511 $handler = $this->displayImg->getHandler();
515 $warningConfig =
$handler->getWarningConfig( $this->displayImg );
517 if ( $warningConfig !==
null ) {
527 $medialink =
"[[Media:$filename|$linktext]]";
529 if ( !$this->displayImg->isSafeFile() ) {
530 $warning = $this->
getContext()->msg(
'mediawarning' )->plain();
539 $out->addWikiText( <<<EOT
540<div
class=
"fullMedia"><span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span></div>
541<div
class=
"mediaWarning">$warning</div>
546 $out->addWikiText( <<<EOT
547<div
class=
"fullMedia">{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
553 $renderLangOptions = $this->displayImg->getAvailableLanguages();
554 if ( count( $renderLangOptions ) >= 1 ) {
555 $currentLanguage = $renderLang;
556 $defaultLang = $this->displayImg->getDefaultRenderLanguage();
557 if ( is_null( $currentLanguage ) ) {
558 $currentLanguage = $defaultLang;
560 $out->addHTML( $this->
doRenderLangOpt( $renderLangOptions, $currentLanguage, $defaultLang ) );
564 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
570 $ext = $this->displayImg->getExtension();
572 'file-no-thumb-animation-' .
$ext,
573 'file-no-thumb-animation'
576 $out->addWikiText( <<<EOT
577<div
class=
"mw-noanimatethumb">{$noAnimMesg}</div>
582 if ( !$this->displayImg->isLocal() ) {
586 # Image does not exist
587 if ( !$this->
getId() ) {
588 # No article exists either
589 # Show deletion log to be consistent with normal articles
592 [
'delete',
'move' ],
593 $this->
getTitle()->getPrefixedText(),
596 'conds' => [
"log_action != 'revision'" ],
597 'showIfEmpty' =>
false,
598 'msgKey' => [
'moveddeleted-notice' ]
607 'filepage-nofile-link',
608 $uploadTitle->getFullURL( [
'wpDestFile' => $this->mPage->getFile()->getName() ] )
611 $nofile =
'filepage-nofile';
616 $out->setRobotPolicy(
'noindex,nofollow' );
617 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
618 if ( !$this->
getId() && $wgSend404Code ) {
621 $request->response()->statusHeader( 404 );
624 $out->setFileVersion( $this->displayImg );
635 if ( $sizeLinkBigImagePreview ) {
637 $previewTypeDiffers =
false;
638 $origExt = $thumbExt = $this->displayImg->getExtension();
639 if ( $this->displayImg->getHandler() ) {
640 $origMime = $this->displayImg->getMimeType();
642 $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
643 list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
644 $origExt, $origMime, $typeParams );
645 if ( $thumbMime !== $origMime ) {
646 $previewTypeDiffers =
true;
649 if ( $previewTypeDiffers ) {
650 return $this->
getContext()->msg(
'show-big-image-preview-differ' )->
651 rawParams( $sizeLinkBigImagePreview )->
652 params( strtoupper( $origExt ) )->
653 params( strtoupper( $thumbExt ) )->
656 return $this->
getContext()->msg(
'show-big-image-preview' )->
657 rawParams( $sizeLinkBigImagePreview )->
675 $thumbnail = $this->displayImg->transform(
$params );
676 if ( $thumbnail && !$thumbnail->isError() ) {
677 return Html::rawElement(
'a', [
678 'href' => $thumbnail->getUrl(),
679 'class' =>
'mw-thumbnail-link'
680 ], $this->getContext()->msg(
'show-big-image-size' )->numParams(
681 $thumbnail->getWidth(), $thumbnail->getHeight()
695 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
696 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
699 if ( $descUrl && $this->mPage->getId() == 0 ) {
700 $out->setCanonicalUrl( $descUrl );
703 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
710 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-here',
$repo, $descUrl ] );
711 } elseif ( $descUrl &&
714 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-there',
$repo, $descUrl ] );
716 $out->wrapWikiMsg( $wrap, [
'sharedupload',
$repo ],
'' );
720 $this->mExtraDescription = $descText;
727 return $uploadTitle->getFullURL( [
728 'wpDestFile' => $this->mPage->getFile()->getName(),
745 if ( !$this->mPage->getFile()->isLocal() ) {
750 $out->addHTML(
"<ul>\n" );
752 # "Upload a new version of this file" link
756 $this->mPage->getFile() )
762 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\">"
763 .
"<div class=\"plainlinks\">{$ulink}</div></li>\n" );
765 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">"
766 . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
769 $out->addHTML(
"</ul>\n" );
786 $out->addHTML( $pager->getBody() );
787 $out->preventClickjacking( $pager->getPreventClickjacking() );
789 $this->mPage->getFile()->resetHistory();
791 # Exist check because we don't want to show this on pages where an image
792 # doesn't exist along with the noimage message, that would suck. -ævar
793 if ( $this->mPage->getFile()->exists() ) {
807 [
'imagelinks',
'page' ],
808 [
'page_namespace',
'page_title',
'il_to' ],
809 [
'il_to' => $target,
'il_from = page_id' ],
811 [
'LIMIT' =>
$limit + 1,
'ORDER BY' =>
'il_from', ]
823 $redirects[$redir->getDBkey()] = [];
826 'page_title' => $redir->getDBkey(),
831 foreach (
$res as $row ) {
837 if ( !$hasMore && count( $redirects ) ) {
839 $limit - count( $rows ) + 1 );
840 foreach (
$res as $row ) {
841 $redirects[$row->il_to][] = $row;
844 $hasMore = (
$res->numRows() + count( $rows ) ) >
$limit;
849 Html::rawElement(
'div',
850 [
'id' =>
'mw-imagepage-nolinkstoimage' ],
"\n$1\n" ),
856 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
861 $out->addWikiMsg(
'linkstoimage-more',
862 $this->
getContext()->getLanguage()->formatNum( $limit ),
863 $this->
getTitle()->getPrefixedDBkey()
868 Html::openElement(
'ul',
869 [
'class' =>
'mw-imagepage-linkstoimage' ] ) .
"\n"
874 usort( $rows, [ $this,
'compare' ] );
878 foreach ( $rows
as $element ) {
880 if ( $currentCount >
$limit ) {
885 # Add a redirect=no to make redirect pages reachable
886 if ( isset( $redirects[$element->page_title] ) ) {
887 $query[
'redirect'] =
'no';
890 Title::makeTitle( $element->page_namespace, $element->page_title ),
893 if ( !isset( $redirects[$element->page_title] ) ) {
896 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
897 # Redirect without usages
898 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )
899 ->rawParams(
$link,
'' )
902 # Redirect with usages
904 foreach ( $redirects[$element->page_title]
as $row ) {
906 if ( $currentCount >
$limit ) {
910 $link2 =
Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
911 $li .= Html::rawElement(
913 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
918 $ul = Html::rawElement(
920 [
'class' =>
'mw-imagepage-redirectstofile' ],
923 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )->rawParams(
926 $out->addHTML( Html::rawElement(
928 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
934 $out->addHTML( Html::closeElement(
'ul' ) .
"\n" );
939 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
941 $out->addHTML( Html::closeElement(
'div' ) .
"\n" );
948 $dupes = $this->mPage->getDuplicates();
949 if ( count( $dupes ) == 0 ) {
953 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
954 $out->addWikiMsg(
'duplicatesoffile',
955 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
957 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
962 foreach ( $dupes
as $file ) {
964 if ( $file->isLocal() ) {
968 $file->getTitle()->getPrefixedText() );
971 $file->getRepo()->getDisplayName()
974 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
976 $out->addHTML(
"</ul></div>\n" );
982 public function delete() {
983 $file = $this->mPage->getFile();
984 if ( !$file->exists() || !$file->isLocal() || $file->getRedirected() ) {
1001 $out->setPageTitle( $this->
getContext()->msg(
'internalerror' ) );
1002 $out->setRobotPolicy(
'noindex,nofollow' );
1003 $out->setArticleRelated(
false );
1004 $out->enableClientCache(
false );
1005 $out->addWikiText( $description );
1017 if ( $a->page_namespace == $b->page_namespace ) {
1018 return strcmp( $a->page_title, $b->page_title );
1020 return $a->page_namespace - $b->page_namespace;
1035 $option =
$user->getIntOption( $optionName );
1037 $option = User::getDefaultOption( $optionName );
1062 sort( $langChoices );
1063 $curLang =
wfBCP47( $curLang );
1064 $defaultLang =
wfBCP47( $defaultLang );
1066 $haveCurrentLang =
false;
1067 $haveDefaultLang =
false;
1075 foreach ( $langChoices
as $lang ) {
1078 if (
$name !==
'' ) {
1084 if ( $curLang ===
$code ) {
1085 $haveCurrentLang =
true;
1087 if ( $defaultLang ===
$code ) {
1088 $haveDefaultLang =
true;
1091 if ( !$haveDefaultLang ) {
1097 $defaultLang === $curLang
1100 if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
1101 $name = Language::fetchLanguageName( $curLang, $this->
getContext()->getLanguage()->getCode() );
1102 if (
$name !==
'' ) {
1103 $display = $this->
getContext()->msg(
'img-lang-opt', $curLang,
$name )->text();
1105 $display = $curLang;
1107 $opts =
Xml::option( $display, $curLang,
true ) . $opts;
1110 $select = Html::rawElement(
1112 [
'id' =>
'mw-imglangselector',
'name' =>
'lang' ],
1117 $formContents = $this->
getContext()->msg(
'img-lang-info' )
1118 ->rawParams( $select, $submit )
1120 $formContents .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() );
1122 $langSelectLine = Html::rawElement(
'div', [
'id' =>
'mw-imglangselector-line' ],
1123 Html::rawElement(
'form', [
'action' =>
$wgScript ], $formContents )
1125 return $langSelectLine;
1143 if ( !$maxWidth || !$maxHeight ) {
1145 throw new MWException(
'Using a choice from $wgImageLimits that is 0x0' );
1148 if ( !$width || !$height ) {
1152 # Calculate the thumbnail size.
1153 if ( $width <= $maxWidth && $height <= $maxHeight ) {
1155 } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1156 # The limiting factor is the width, not the height.
1157 $height = round( $height * $maxWidth / $width );
1159 # Note that $height <= $maxHeight now.
1161 $newwidth = floor( $width * $maxHeight / $height );
1162 $height = round( $height * $newwidth / $width );
1164 # Note that $height <= $maxHeight now, but might not be identical
1165 # because of rounding.
1167 return [ $width, $height ];
1180 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1188 $thumbSizes[] = [ $origWidth, $origHeight ];
1190 # Creating thumb links triggers thumbnail generation.
1191 # Just generate the thumb for the current users prefs.
1195 if ( !$this->displayImg->mustRender() ) {
1198 $thumbSizes[] = [ $origWidth, $origHeight ];
1209 return $this->mPage->getFile();
1217 return $this->mPage->isLocal();
1225 return $this->mPage->getDuplicates();
1233 $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.
wfBCP47( $code)
Get the normalised IETF language tag See unit test for examples.
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.
viewRedirect( $target, $appendSubtitle=true, $forceKnown=false)
Return the HTML for the top of a redirect page.
getRequest()
Get the WebRequest object.
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.
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()
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.
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.
doRenderLangOpt(array $langChoices, $curLang, $defaultLang)
Output a drop-down box for language options for the file.
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.
addJsConfigVars( $keys, $value=null)
Add one or more variables to be set in mw.config in JavaScript.
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,...
Represents a title within MediaWiki.
static userCanReUpload(User $user, File $img)
Check if a user is the last uploader.
Special handling for file pages.
static closeElement( $element)
Shortcut to close an XML element.
static openElement( $element, $attribs=null)
This opens an XML element.
static submitButton( $value, $attribs=[])
Convenience function to build an HTML submit button When $wgUseMediaWikiUIEverywhere is true it will ...
static option( $text, $value=null, $selected=false, $attribs=[])
Convenience function to build an HTML drop-down list item.
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
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
when a variable name is used in a it is silently declared as a new local masking the global
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
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
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
the array() calling protocol came about after MediaWiki 1.4rc1.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $user
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
error also a ContextSource you ll probably need to make sure the header is varied on $request
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object to manipulate or replace but no entry for that model exists in $wgContentHandlers if desired whether it is OK to use $contentModel on $title Handler functions that modify $ok should generally return false to prevent further hooks from further modifying $ok inclusive $limit
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
Allows to change the fields on the form that will be generated $name
namespace are movable Hooks may change this value to override the return value of MWNamespace::isMovable(). 'NewDifferenceEngine' do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
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
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
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
if(!isset( $args[0])) $lang