63 $this->mPage->setFile(
$file );
64 $this->displayImg =
$file;
65 $this->fileLoaded =
true;
69 if ( $this->fileLoaded ) {
72 $this->fileLoaded =
true;
74 $this->displayImg = $img =
false;
76 Hooks::run(
'ImagePageFindFile', [ $this, &$img, &$this->displayImg ] );
83 $this->mPage->setFile( $img );
84 if ( !$this->displayImg ) {
85 $this->displayImg = $img;
87 $this->repo = $img->getRepo();
94 if ( $this->viewIsRenderAction ) {
107 if ( $this->
getTitle()->getNamespace() !=
NS_FILE || ( $diff !==
null && $diffOnly ) ) {
114 if ( $this->
getTitle()->getNamespace() ==
NS_FILE && $this->mPage->getFile()->getRedirected() ) {
115 if ( $this->
getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !==
null ) {
116 $request->setVal(
'diffonly',
'true' );
123 if (
$wgShowEXIF && $this->displayImg->exists() ) {
125 $formattedMetadata = $this->displayImg->formatMetadata( $this->
getContext() );
126 $showmeta = $formattedMetadata !==
false;
131 if ( !$diff && $this->displayImg->exists() ) {
139 # No need to display noarticletext, we use our own message, output in openShowImage()
140 if ( $this->mPage->getId() ) {
141 # NS_FILE is in the user language, but this section (the actual wikitext)
142 # should be in page content language
143 $pageLang = $this->
getTitle()->getPageViewLanguage();
144 $out->addHTML( Xml::openElement(
'div', [
'id' =>
'mw-imagepage-content',
145 'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
146 'class' =>
'mw-content-' . $pageLang->getDir() ] ) );
150 $out->addHTML( Xml::closeElement(
'div' ) );
152 # Just need to set the right headers
153 $out->setArticleFlag(
true );
154 $out->setPageTitle( $this->
getTitle()->getPrefixedText() );
158 # Show shared description, if needed
159 if ( $this->mExtraDescription ) {
160 $fol = $this->
getContext()->msg(
'shareddescriptionfollows' );
161 if ( !$fol->isDisabled() ) {
162 $out->addWikiTextAsInterface( $fol->plain() );
164 $out->addHTML(
'<div id="shared-image-desc">' . $this->mExtraDescription .
"</div>\n" );
171 $out->addHTML( Xml::element(
'h2',
172 [
'id' =>
'filelinks' ],
175 # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
176 # Yet we return metadata about the target. Definitely an issue in the FileRepo
179 # Allow extensions to add something after the image links
181 Hooks::run(
'ImagePageAfterImageLinks', [ $this, &
$html ] );
187 $out->addHTML( Xml::element(
189 [
'id' =>
'metadata' ],
191 $out->wrapWikiTextAsInterface(
192 'mw-imagepage-section-metadata',
195 $out->addModules( [
'mediawiki.action.view.metadata' ] );
199 if ( !$this->repo->isLocal() ) {
200 $css = $this->repo->getDescriptionStylesheetUrl();
206 $out->addModuleStyles( [
208 'mediawiki.action.view.filepage',
228 '<li><a href="#file">' . $this->
getContext()->msg(
'file-anchor-link' )->escaped() .
'</a></li>',
229 '<li><a href="#filehistory">' . $this->
getContext()->msg(
'filehist' )->escaped() .
'</a></li>',
230 '<li><a href="#filelinks">' . $this->
getContext()->msg(
'imagelinks' )->escaped() .
'</a></li>',
233 Hooks::run(
'ImagePageShowTOC', [ $this, &$r ] );
236 $r[] =
'<li><a href="#metadata">' .
237 $this->
getContext()->msg(
'metadata' )->escaped() .
241 return '<ul id="filetoc">' . implode(
"\n", $r ) .
'</ul>';
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'] )
285 if ( $this->mPage->getFile() && !$this->mPage->getFile()->isLocal() && $this->getId() == 0 ) {
288 return parent::getEmptyPageParserOutput(
$options );
305 $config = MediaWikiServices::getInstance()->getMainConfig();
306 $requestLanguage =
$request->getVal(
'lang', $config->get(
'LanguageCode' ) );
307 if (
$handler->validateParam(
'lang', $requestLanguage ) ) {
308 return $file->getMatchedLanguage( $requestLanguage );
321 $dirmark =
$lang->getDirMarkEntity();
326 if ( $this->displayImg->exists() ) {
328 $page =
$request->getIntOrNull(
'page' );
329 if ( is_null( $page ) ) {
337 if ( !is_null( $renderLang ) ) {
341 $width_orig = $this->displayImg->getWidth( $page );
342 $width = $width_orig;
343 $height_orig = $this->displayImg->getHeight( $page );
344 $height = $height_orig;
347 $linktext = $filename;
352 Hooks::run(
'ImageOpenShowImageInlineBefore', [ &$imagePage, &
$out ] );
354 if ( $this->displayImg->allowInlineDisplay() ) {
356 # "Download high res version" link below the image
357 # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
358 # Language::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
359 # We'll show a thumbnail of this image
360 if ( $width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized() ) {
362 $maxWidth, $maxHeight, $width, $height
364 $linktext = $this->
getContext()->msg(
'show-big-image' )->escaped();
366 $thumbSizes = $this->
getThumbSizes( $width_orig, $height_orig );
367 # Generate thumbnails or thumbnail links as needed...
369 foreach ( $thumbSizes
as $size ) {
378 if ( ( ( $size[0] <= $width_orig && $size[1] <= $height_orig )
379 || ( $this->displayImg->isVectorized()
382 && $size[0] != $width && $size[1] != $height
386 $otherSizes[] = $sizeLink;
390 $otherSizes = array_unique( $otherSizes );
394 if ( count( $otherSizes ) ) {
398 [
'class' =>
'mw-filepage-other-resolutions' ],
399 $this->
getContext()->msg(
'show-big-image-other' )
400 ->rawParams(
$lang->pipeList( $otherSizes ) )
401 ->params( count( $otherSizes ) )
405 } elseif ( $width == 0 && $height == 0 ) {
406 # Some sort of audio file that doesn't have dimensions
407 # Don't output a no hi res message for such a file
410 # Image is small enough to show full size on image page
411 $msgsmall = $this->
getContext()->msg(
'file-nohires' )->parse();
416 $thumbnail = $this->displayImg->transform(
$params );
419 $anchorclose = Html::rawElement(
421 [
'class' =>
'mw-filepage-resolutioninfo' ],
425 $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
427 $out->addModules(
'mediawiki.page.image.pagination' );
428 $out->addHTML(
'<table class="multipageimage"><tr><td>' );
433 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
436 $out->addHTML(
'<div class="fullImageLink" id="file">' .
438 $anchorclose .
"</div>\n" );
442 $count = $this->displayImg->pageCount();
445 $label = $this->
getContext()->msg(
'imgmultipageprev' )->text();
450 htmlspecialchars( $label ),
452 [
'page' => $page - 1 ]
460 [
'page' => $page - 1 ]
466 if ( $page < $count ) {
467 $label = $this->
getContext()->msg(
'imgmultipagenext' )->text();
470 htmlspecialchars( $label ),
472 [
'page' => $page + 1 ]
480 [
'page' => $page + 1 ]
489 'name' =>
'pageselector',
493 for ( $i = 1; $i <= $count; $i++ ) {
494 $options[] = Xml::option(
$lang->formatNum( $i ), $i, $i == $page );
496 $select = Xml::tags(
'select',
497 [
'id' =>
'pageselector',
'name' =>
'page' ],
501 '</td><td><div class="multipageimagenavbox">' .
502 Xml::openElement(
'form', $formParams ) .
503 Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() ) .
504 $this->
getContext()->msg(
'imgmultigoto' )->rawParams( $select )->parse() .
505 $this->
getContext()->msg(
'word-separator' )->escaped() .
506 Xml::submitButton( $this->
getContext()->msg(
'imgmultigo' )->
text() ) .
507 Xml::closeElement(
'form' ) .
508 "<hr />$thumb1\n$thumb2<br style=\"clear: both\" /></div></td></tr></table>"
511 } elseif ( $this->displayImg->isSafeFile() ) {
512 # if direct link is allowed but it's not a renderable image, show an icon.
513 $icon = $this->displayImg->iconThumb();
515 $out->addHTML(
'<div class="fullImageLink" id="file">' .
516 $icon->toHtml( [
'file-link' =>
true ] ) .
520 $longDesc = $this->
getContext()->msg(
'parentheses', $this->displayImg->getLongDesc() )->text();
522 $handler = $this->displayImg->getHandler();
526 $warningConfig =
$handler->getWarningConfig( $this->displayImg );
528 if ( $warningConfig !==
null ) {
532 $output->addJsConfigVars(
'wgFileWarning', $warningConfig );
533 $output->addModules( $warningConfig[
'module'] );
534 $output->addModules(
'mediawiki.filewarning' );
538 $medialink =
"[[Media:$filename|$linktext]]";
540 if ( !$this->displayImg->isSafeFile() ) {
541 $warning = $this->
getContext()->msg(
'mediawarning' )->plain();
550 $out->wrapWikiTextAsInterface(
'fullMedia', <<<EOT
551<span
class=
"dangerousLink">{$medialink}</span> $dirmark<span
class=
"fileInfo">$longDesc</span>
555 $out->wrapWikiTextAsInterface(
'mediaWarning', $warning );
557 $out->wrapWikiTextAsInterface(
'fullMedia', <<<EOT
558{$medialink} {$dirmark}<span
class=
"fileInfo">$longDesc</span>
563 $renderLangOptions = $this->displayImg->getAvailableLanguages();
564 if ( count( $renderLangOptions ) >= 1 ) {
569 if ( !$this->displayImg->canAnimateThumbIfAppropriate() ) {
575 $ext = $this->displayImg->getExtension();
577 'file-no-thumb-animation-' .
$ext,
578 'file-no-thumb-animation'
581 $out->wrapWikiTextAsInterface(
'mw-noanimatethumb', $noAnimMesg );
584 if ( !$this->displayImg->isLocal() ) {
588 # Image does not exist
589 if ( !$this->
getId() ) {
592 # No article exists either
593 # Show deletion log to be consistent with normal articles
596 [
'delete',
'move',
'protect' ],
597 $this->
getTitle()->getPrefixedText(),
600 'conds' => [
'log_action != ' .
$dbr->addQuotes(
'revision' ) ],
601 'showIfEmpty' =>
false,
602 'msgKey' => [
'moveddeleted-notice' ]
609 $uploadTitle = SpecialPage::getTitleFor(
'Upload' );
611 'filepage-nofile-link',
612 $uploadTitle->getFullURL( [
'wpDestFile' => $this->mPage->getFile()->getName() ] )
615 $nofile =
'filepage-nofile';
620 $out->setRobotPolicy(
'noindex,nofollow' );
621 $out->wrapWikiMsg(
"<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
622 if ( !$this->
getId() && $wgSend404Code ) {
625 $request->response()->statusHeader( 404 );
628 $out->setFileVersion( $this->displayImg );
639 if ( $sizeLinkBigImagePreview ) {
641 $previewTypeDiffers =
false;
642 $origExt = $thumbExt = $this->displayImg->getExtension();
643 if ( $this->displayImg->getHandler() ) {
644 $origMime = $this->displayImg->getMimeType();
646 $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams );
647 list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType(
648 $origExt, $origMime, $typeParams );
649 if ( $thumbMime !== $origMime ) {
650 $previewTypeDiffers =
true;
653 if ( $previewTypeDiffers ) {
654 return $this->
getContext()->msg(
'show-big-image-preview-differ' )->
655 rawParams( $sizeLinkBigImagePreview )->
656 params( strtoupper( $origExt ) )->
657 params( strtoupper( $thumbExt ) )->
660 return $this->
getContext()->msg(
'show-big-image-preview' )->
661 rawParams( $sizeLinkBigImagePreview )->
679 $thumbnail = $this->displayImg->transform(
$params );
680 if ( $thumbnail && !$thumbnail->isError() ) {
681 return Html::rawElement(
'a', [
682 'href' => $thumbnail->getUrl(),
683 'class' =>
'mw-thumbnail-link'
684 ], $this->getContext()->msg(
'show-big-image-size' )->numParams(
685 $thumbnail->getWidth(), $thumbnail->getHeight()
699 $descUrl = $this->mPage->getFile()->getDescriptionUrl();
700 $descText = $this->mPage->getFile()->getDescriptionText( $this->
getContext()->getLanguage() );
703 if ( $descUrl && $this->mPage->getId() == 0 ) {
704 $out->setCanonicalUrl( $descUrl );
707 $wrap =
"<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
714 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-here',
$repo, $descUrl ] );
715 } elseif ( $descUrl &&
718 $out->wrapWikiMsg( $wrap, [
'sharedupload-desc-there',
$repo, $descUrl ] );
720 $out->wrapWikiMsg( $wrap, [
'sharedupload',
$repo ],
'' );
724 $this->mExtraDescription = $descText;
730 $uploadTitle = SpecialPage::getTitleFor(
'Upload' );
731 return $uploadTitle->getFullURL( [
732 'wpDestFile' => $this->mPage->getFile()->getName(),
749 if ( !$this->mPage->getFile()->isLocal() ) {
754 $out->addHTML(
"<ul>\n" );
756 # "Upload a new version of this file" link
760 $this->mPage->getFile() )
766 $out->addHTML(
"<li id=\"mw-imagepage-reupload-link\">"
767 .
"<div class=\"plainlinks\">{$ulink}</div></li>\n" );
769 $out->addHTML(
"<li id=\"mw-imagepage-upload-disallowed\">"
770 . $this->
getContext()->msg(
'upload-disallowed-here' )->escaped() .
"</li>\n" );
773 $out->addHTML(
"</ul>\n" );
790 $out->addHTML( $pager->getBody() );
791 $out->preventClickjacking( $pager->getPreventClickjacking() );
793 $this->mPage->getFile()->resetHistory();
795 # Exist check because we don't want to show this on pages where an image
796 # doesn't exist along with the noimage message, that would suck. -ævar
797 if ( $this->mPage->getFile()->exists() ) {
811 [
'imagelinks',
'page' ],
812 [
'page_namespace',
'page_title',
'il_to' ],
813 [
'il_to' => $target,
'il_from = page_id' ],
815 [
'LIMIT' => $limit + 1,
'ORDER BY' =>
'il_from', ]
827 $redirects[$redir->getDBkey()] = [];
830 'page_title' => $redir->getDBkey(),
835 foreach (
$res as $row ) {
838 $count = count(
$rows );
840 $hasMore = $count > $limit;
841 if ( !$hasMore && count( $redirects ) ) {
843 $limit - count(
$rows ) + 1 );
844 foreach (
$res as $row ) {
845 $redirects[$row->il_to][] = $row;
848 $hasMore = (
$res->numRows() + count(
$rows ) ) > $limit;
853 Html::rawElement(
'div',
854 [
'id' =>
'mw-imagepage-nolinkstoimage' ],
"\n$1\n" ),
860 $out->addHTML(
"<div id='mw-imagepage-section-linkstoimage'>\n" );
862 $out->addWikiMsg(
'linkstoimage', $count );
865 $out->addWikiMsg(
'linkstoimage-more',
866 $this->
getContext()->getLanguage()->formatNum( $limit ),
867 $this->
getTitle()->getPrefixedDBkey()
872 Html::openElement(
'ul',
873 [
'class' =>
'mw-imagepage-linkstoimage' ] ) .
"\n"
878 usort(
$rows, [ $this,
'compare' ] );
882 foreach (
$rows as $element ) {
884 if ( $currentCount > $limit ) {
889 # Add a redirect=no to make redirect pages reachable
890 if ( isset( $redirects[$element->page_title] ) ) {
891 $query[
'redirect'] =
'no';
894 Title::makeTitle( $element->page_namespace, $element->page_title ),
897 if ( !isset( $redirects[$element->page_title] ) ) {
900 } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
901 # Redirect without usages
902 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )
903 ->rawParams(
$link,
'' )
906 # Redirect with usages
908 foreach ( $redirects[$element->page_title]
as $row ) {
910 if ( $currentCount > $limit ) {
914 $link2 =
Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
915 $li .= Html::rawElement(
917 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
922 $ul = Html::rawElement(
924 [
'class' =>
'mw-imagepage-redirectstofile' ],
927 $liContents = $this->
getContext()->msg(
'linkstoimage-redirect' )->rawParams(
930 $out->addHTML( Html::rawElement(
932 [
'class' =>
'mw-imagepage-linkstoimage-ns' . $element->page_namespace ],
938 $out->addHTML( Html::closeElement(
'ul' ) .
"\n" );
942 if ( $count > $limit ) {
943 $out->addWikiMsg(
'morelinkstoimage', $this->
getTitle()->getPrefixedDBkey() );
945 $out->addHTML( Html::closeElement(
'div' ) .
"\n" );
952 $dupes = $this->mPage->getDuplicates();
953 if ( count( $dupes ) == 0 ) {
957 $out->addHTML(
"<div id='mw-imagepage-section-duplicates'>\n" );
958 $out->addWikiMsg(
'duplicatesoffile',
959 $this->
getContext()->getLanguage()->formatNum( count( $dupes ) ), $this->
getTitle()->getDBkey()
961 $out->addHTML(
"<ul class='mw-imagepage-duplicates'>\n" );
968 if (
$file->isLocal() ) {
972 $file->getTitle()->getPrefixedText() );
975 $file->getRepo()->getDisplayName()
978 $out->addHTML(
"<li>{$link} {$fromSrc}</li>\n" );
980 $out->addHTML(
"</ul></div>\n" );
986 public function delete() {
987 $file = $this->mPage->getFile();
988 if ( !
$file->exists() || !
$file->isLocal() ||
$file->getRedirected() ) {
1005 $out->setPageTitle( $this->
getContext()->msg(
'internalerror' ) );
1006 $out->setRobotPolicy(
'noindex,nofollow' );
1007 $out->setArticleRelated(
false );
1008 $out->enableClientCache(
false );
1009 $out->addWikiTextAsInterface( $description );
1021 return $a->page_namespace <=> $b->page_namespace
1022 ?: strcmp( $a->page_title, $b->page_title );
1036 $option =
$user->getIntOption( $optionName );
1063 $matchedRenderLang = $this->displayImg->getMatchedLanguage( $renderLang );
1065 foreach ( $langChoices
as $lang ) {
1068 $matchedRenderLang ===
$lang
1078 is_null( $matchedRenderLang )
1081 $select = Html::rawElement(
1083 [
'id' =>
'mw-imglangselector',
'name' =>
'lang' ],
1086 $submit = Xml::submitButton( $this->
getContext()->msg(
'img-lang-go' )->
text() );
1088 $formContents = $this->
getContext()->msg(
'img-lang-info' )
1089 ->rawParams( $select, $submit )
1091 $formContents .= Html::hidden(
'title', $this->
getTitle()->getPrefixedDBkey() );
1093 $langSelectLine = Html::rawElement(
'div', [
'id' =>
'mw-imglangselector-line' ],
1094 Html::rawElement(
'form', [
'action' =>
$wgScript ], $formContents )
1096 return $langSelectLine;
1107 if (
$name !==
'' ) {
1135 if ( !$maxWidth || !$maxHeight ) {
1137 throw new MWException(
'Using a choice from $wgImageLimits that is 0x0' );
1140 if ( !$width || !$height ) {
1144 # Calculate the thumbnail size.
1145 if ( $width <= $maxWidth && $height <= $maxHeight ) {
1147 } elseif ( $width / $height >= $maxWidth / $maxHeight ) {
1148 # The limiting factor is the width, not the height.
1149 $height = round( $height * $maxWidth / $width );
1151 # Note that $height <= $maxHeight now.
1153 $newwidth = floor( $width * $maxHeight / $height );
1154 $height = round( $height * $newwidth / $width );
1156 # Note that $height <= $maxHeight now, but might not be identical
1157 # because of rounding.
1159 return [ $width, $height ];
1172 if ( $this->displayImg->getRepo()->canTransformVia404() ) {
1180 $thumbSizes[] = [ $origWidth, $origHeight ];
1182 # Creating thumb links triggers thumbnail generation.
1183 # Just generate the thumb for the current users prefs.
1187 if ( !$this->displayImg->mustRender() ) {
1190 $thumbSizes[] = [ $origWidth, $origHeight ];
1201 return $this->mPage->getFile();
1209 return $this->mPage->isLocal();
1217 return $this->mPage->getDuplicates();
1225 return $this->mPage->getForeignCategories();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
$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
Allow users to upload files.
$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(... $keys)
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)
Returns language code to be used for dispaying the image, based on request context and languages avai...
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.
makeMetadataTable( $metadata)
Make a table with metadata to be shown in the output page.
getEmptyPageParserOutput(ParserOptions $options)
Overloading Article's getEmptyPageParserOutput method.
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.
Set options of the Parser.
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
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 $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
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
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
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
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable & $code
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
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
return true to allow those checks to and false if checking is done & $user
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
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
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!is_readable( $file)) $ext
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
if(!isset( $args[0])) $lang